|
Data Density |
Posted by Lofi on May-30-2011 19:33 |
|
Hello,
is there a way to control the data density in the chart? Example:
I have the following Y values:
41,290002
41,290001
41,290001
41,290001
41,290001
41,290001
41,290001
41,290001
41,29
41,29
41,29
41,29
41,289999
41,289999
41,289999
41,289999
ChartDirector creates a nice chart from it. However, in this case it is not requested. I'd rather have a flat line.
How can i control this behaviour?
Thanks in advance!
|
Re: Data Density |
Posted by Lofi on May-30-2011 19:35 |
|
additional information: i don't want to set any min/max scale values, since the numbers can vary. |
Re: Data Density |
Posted by Peter Kwan on May-31-2011 02:43 |
|
Hi Lofi,
The auto-scaling can be configured using Axis.setTickDensity, Axis.setAutoScale, Axis.setRounding and Axis.setMinTickInc. For example, the following code asks ChartDirector to use less labels on the y-axis, and forces the axis scale to always include 0 (in which case your chart will look like a flat line):
//always include 0 in the axis scale
c.yAxis().setAutoScale(0.05, 0.05, 1);
//no less than 50 pixels per label
c.yAxis().setTickDensity(50);
Hope this can help.
Regards
Peter Kwan |
Re: Data Density |
Posted by Lofi on May-31-2011 14:35 |
|
Hello Peter,
thank you very much. However, I want to include e. g. 0 in the axis only in the above case, not always. Is there e. g. a way to specify a delta at which 0 will be used in the axis? E. g. if min/max differ by 0.1, then show a flat line, otherwise show the full details?
Best regard
Lofi |
Re: Data Density |
Posted by Peter Kwan on May-31-2011 17:28 |
|
Hi Lofi,
Yes. Just call setAutoScale only if min/max differ by 0.1. There is a ChartDirector utility ArrayMath that allows you to obtain the min/max of your data easily. For example:
if (new ArrayMath(myData).max() - new ArrayMath(myData).min() >= 0.1)
//always include 0 in the axis scale
c.yAxis().setAutoScale(0.05, 0.05, 1);
If your intention is to make sure that the difference between two axis labels must be at least 0.1, you may use setMinTickInc. For example:
//tick increment must be at least 0.1
c.yAxis().setMinTickInc(0.1);
Hope this can help.
Regards
Peter Kwan |
|