|
setXData issue |
Posted by niket singh on Nov-07-2013 15:32 |
|
Hi,
If i use setXData() function with line layer and at the same moment if i use
c.xAxis().SetLinearScale() what will happen ?
Actually the problem is i want to fix the xAxis for some value for 10 ms and for another 10
ms again i want to fix it for some value.
for example :- for 1st 10 millisecond the range for X-axis is 0 to 190, now for the next 10
ms x-axis value will be 10 to 200 just each value shifted and new value entered.
But when i set value for xAxis using setXData say 0 to 190 it sets 0 to 200 ...
Could you please tell me how i can fix this problem .
Regards
Niket Kumar singh |
Re: setXData issue |
Posted by Peter Kwan on Nov-08-2013 00:19 |
|
Hi niket,
If you use setXData, then ChartDirector will plot the data points using the x-coordinates you provided. For example, if your data points are at x = [1.2763, 2.344, 4.168], then ChartDirector will plot the data points at these 3 x-coordinates.
If you use Axis.setLinearScale, then ChartDirector will set up the x-axis to the axis range you choose. For example, if you use setLinearScale(0, 10, 1), then ChartDirector will set up the axis range to be 0 to 10. So for the above 3 points, they will be plotted on [1.8763, 2.344, 4.568] on the 0 to 10 axis (that is, all of them will be on the left half of the chart).
If you do not provided any axis scale configuration (that is, do not call setLinearScale, setLogScale or setLabels), ChartDirector will need to automatically come up with an axis scale to accomodate the data. For example, ChartDirector may choose 0 to 5 for the 3 data points. The exact choice depends on your data range, auto-scale configuration (scale extensions, zero affinity, end-point rounding, tick density etc), and also on the chart geometry (size, label orietation, etc).
So setLinearScale and setXData can coexist. They do not cause any conflict. For example, in the "Realtime Chart" sample code that comes with ChartDirector, both setXData and setLinearScale are used.
It is possible to configure ChartDirector to tell it to auto-scale the axis in 10ms increments (use Axis.setMinTickInc). However, if you would like to use an axis scale not related to your data, then you would need to use setLinearScale to tell ChartDirector the scale you would like to use. For example, if you only have 10ms of data, but you still want to use an axis from 0ms to 190ms, then the axis scale is not related to the data (Where does 190ms come from? It does not come from the data.) In this case, you would need to use setLinearScale to tell ChartDirector the scale yoiu would like to use.
You can change the setLinearScale when you update the chart. For example, when new data come in, and you think the axis scale should be changed to 10ms to 200ms, you can always do so.
Hope this can help.
Regards
Peter Kwan |
Re: setXData issue |
Posted by niket singh on Nov-08-2013 02:25 |
|
Hi Peter,
First of all thanks for your active response. Peter i am using both call when i am creating
chart for every 10ms interval.
i used this code : - dataLayer.setXData(timesData);
c.xAxis().setLinearScale(timesData[0], timesData[timesData.Length - 1], sampleSize);
where sampleSize is 100 for now .
Where timesData is an double array having size of 100 . for first i initalized it with data
range
[0............................TO........900] like i have added 100 time 10 .
After 10 ms interval the zero Index data that is 0 replaced with index one and so on and
last index that is (length - 1) having a new value which nothing but addition of 10 with the
last value in the array .
see in both code i have used timesData ,but when i used only
dataLayer.setXData(timesData) it will plot xaxis with scale having more data say if i give 0
to 990 it will plot it with 0 to 1000 , as a result when i give y axis data which ranges only 0
to 990 then chart seems partial when it plot at the end .
Actually i felt some difficulty to explain the problem so if u say i can send the .exe file for
both code as well as code also if you dont mind. |
Re: setXData issue |
Posted by Peter Kwan on Nov-08-2013 23:05 |
|
Hi niket,
If you do not use setLinearScale, ChartDirector will auto-scale the axis. For example, if your x-data are from 143.809374 to 157.0238324, ChartDirector may auto-scale the axis to be from 140 to 160 with labels like [140, 145, 150, 155, 160] (the exact labels depend on your axis length). This applies to both the x-axis and the y-axis. So it is normal the axis end points are not equal to the data range. ChartDirector will try to extend the axis end points so that it is at a labelled position. That is why ChartDirector will not choose 157.0238324 as the axis end point, as it is not a labelled position, and it chooses 160 instead.
If you use setLinearScale(a, b, c), of course ChartDirector will accurate following your code to use (a, b) as the axis end points. This is the expected behaviour.
For auto-scaling, you may use Axis.setAutoScale, Axis.setTickDensity, Axis.setRounding to affect how ChartDirector choose the axis scales. For example, you may use Axis.setRounding to disable extending the axis end points to a labelled position if you do not want this effect.
Hope this can help.
Regards
Peter Kwan |
|