|
Value lines below X axis |
Posted by Massimo on Aug-16-2016 17:01 |
|
Hi Peter,
there is a way to stop chart director to render value lines outside the plot area?
I am changing my code to have the chart displayed if I have a set minimum number of points but I would like to know if I can stop the lines to drop out the plot area.
Thanks
|
Re: Value lines below X axis |
Posted by Peter Kwan on Aug-16-2016 22:13 |
|
Hi Massimo,
You can use XYChart.setClipping. For example:
c.setClipping();
Hope this can help.
Regards
Peter Kwan |
Re: Value lines below X axis |
Posted by Massimo on Aug-17-2016 00:13 |
|
perfect!!
thanks
Peter Kwan wrote:
Hi Massimo,
You can use XYChart.setClipping. For example:
c.setClipping();
Hope this can help.
Regards
Peter Kwan
|
Re: Value lines below X axis |
Posted by Massimo on Aug-17-2016 17:10 |
|
Hi Peter,
I have another requirement which I quote below; before I am going to reply that is not possible, can you please confirm to me that I am right?
"Only misgiving I have is that when there are no values, all the lines (median etc) default to 0. The AGP then suggests they are experiencing hypos when this is not the case. Can the lines simply be interrupted if there are no values (perhaps that hour could be greyed out to indicate a lack of data?), before continuing at the next hour where data are available?" |
Re: Value lines below X axis |
Posted by Peter Kwan on Aug-18-2016 01:04 |
|
Hi Massimo,
In ChartDirector, the value 0 is treated as 0, and no value is Chart.NoValue. Does your code use Chart.NoValue to represent "no value"?
Note that if your code creates an array, but leave some array positions unfilled, those positions will contain the "default value" as according to your programming language. In C++, the default value is undefined and in practice, it is a random number. In C#, VB and Java, the default value is 0. In any case, the "default value" is not "no value". So your code must explicitly fill the "no value" positions with Chart.NoValue, or it can initialize the array to contain all Chart.NoValue.
Hope this can help.
Regards
Peter Kwan |
Re: Value lines below X axis |
Posted by Massimo on Aug-18-2016 01:06 |
|
OK thanks Peter,
I will amend my code to use Chart.NoValue but then how these values will be rendered on the chart?
Peter Kwan wrote:
Hi Massimo,
In ChartDirector, the value 0 is treated as 0, and no value is Chart.NoValue. Does your code use Chart.NoValue to represent "no value"?
Note that if your code creates an array, but leave some array positions unfilled, those positions will contain the "default value" as according to your programming language. In C++, the default value is undefined and in practice, it is a random number. In C#, VB and Java, the default value is 0. In any case, the "default value" is not "no value". So your code must explicitly fill the "no value" positions with Chart.NoValue, or it can initialize the array to contain all Chart.NoValue.
Hope this can help.
Regards
Peter Kwan
|
Re: Value lines below X axis |
Posted by Peter Kwan on Aug-18-2016 01:50 |
|
Hi Massimo,
The exact behaviour depends on the chart type. For line layer or spline layer, the behaviour is configurable. See:
http://www.advsofteng.com/doc/cdnet.htm#missingpoints.htm
In brief, for a line layer or spline layer, ChartDirector will join the line segment through the missing points. The line color can be different for line segments that join through missing points, and can be transparent, in which case it will become an interrupted line.
Note that for your chart, if you use an interrupted line, nothing will be drawn. It is because each of the 3 data points in your chart are separate with missing data points on both the left and right sides. That means the line is interrupted on both sides, so no line segments can be drawn through the point. To make the data points visible, you may want to add data symbols for the points like in the above sample code.
Hope this can help.
Regards
Peter Kwan |
Re: Value lines below X axis |
Posted by massimo on Aug-18-2016 02:01 |
|
Thanks Peter that is really useful as always.
Just one question...
>>To make the data points visible, you may want to add data symbols for the points like in the above sample code
I apologise but I do not see any data symbols code.
Peter Kwan wrote:
Hi Massimo,
The exact behaviour depends on the chart type. For line layer or spline layer, the behaviour is configurable. See:
http://www.advsofteng.com/doc/cdnet.htm#missingpoints.htm
In brief, for a line layer or spline layer, ChartDirector will join the line segment through the missing points. The line color can be different for line segments that join through missing points, and can be transparent, in which case it will become an interrupted line.
Note that for your chart, if you use an interrupted line, nothing will be drawn. It is because each of the 3 data points in your chart are separate with missing data points on both the left and right sides. That means the line is interrupted on both sides, so no line segments can be drawn through the point. To make the data points visible, you may want to add data symbols for the points like in the above sample code.
Hope this can help.
Regards
Peter Kwan
|
Re: Value lines below X axis |
Posted by Peter Kwan on Aug-19-2016 00:49 |
|
Hi massimo,
In the "Missing Data Points" sample code, the DataSet.setDataSymbol is used to add symbols to the data points. For example, one line in the sample code is:
layer1.addDataSet(data1, 0x00ff00, "Atom Synthesizer").setDataSymbol(Chart.GlassSphere2Shape, 11);
The above line sets the data symbol as a "glass sphere" shape of size 11 pixels.
Hope this can help.
Regards
Peter Kwan |
Re: Value lines below X axis |
Posted by Massimo on Aug-19-2016 00:55 |
|
I need glasses!!
Ok thanks Peter. I think I solved using a grey colour; still debugging to see if it works though |
Re: Value lines below X axis |
Posted by Massimo on Aug-19-2016 01:23 |
|
Peter wrote:
layer1.addDataSet(data1, 0x00ff00, "Atom Synthesizer").setDataSymbol(Chart.GlassSphere2Shape, 11);
but I am using a SplineLayer which does not have a setDataSymbol method I think |
Re: Value lines below X axis |
Posted by Massimo on Aug-19-2016 01:48 |
|
and my last question is how can I add the chart.novalue chosen color to the legend? |
Re: Value lines below X axis |
Posted by Peter Kwan on Aug-19-2016 23:47 |
|
Hi Massimo,
If you need a legend entry for the NoValue color, you may consider to use Legend.addKey to add it as a custom legend key. For example:
LegendBox b = c.addLegend(.....);
... create chart as usual .....
b.addKey("My Text", "My color", ....);
See:
http://www.advsofteng.com/doc/cdnet.htm#LegendBox.addKey.htm
Hope this can help.
Regards
Peter Kwan |
Re: Value lines below X axis |
Posted by Peter Kwan on Aug-19-2016 23:15 |
|
Hi Massimo,
The DataSet.setDataSymbol is a method of the DataSet object, which is available for the SplineLayer as well. In fact, the "Spline Line Chart" sample code that comes with ChartDirector shows the spline curve with data symbols. See:
http://www.advsofteng.com/doc/cdnet.htm#splineline.htm
In your own code, if you are using addDataSet to add the data series to the SplineLayer, then the returned value is the DataSet object, and you can use setDataSymbol to set the symbol just like in the above sample code.
If you are directly using XYChart.addSplineLayer to add the SplineLayer without using addDataSet, then you can use Layer.getDataSet to obtain the DataSet object from the SplineLayer and the use the setDataSymbol method. It is like:
SplineLayer myLayer = c.addSplineLayer(...........);
myLayer.getDataSet(0).setDataSymbol(...........);
Hope this can help.
Regards
Peter Kwan |
|