|
line disappear after adjusting setDateScale |
Posted by Vicky on Aug-17-2012 23:23 |
|
Hello, I have essentially the following code to add a new data set to a line based on different "idString"
-------------------------------
Dim linelayer As LineLayer = c.addLineLayer2()
....
'''''for each idstring in ids
linelayer.addDataSet(data, -1, idString).setDataSymbol(Chart.CircleSymbol, 4)
labelArr = DirectCast(labelAL.ToArray(GetType(Date)), Date())
c.xAxis().setLabels(labelArr)
c.xAxis.setLabelFormat("{value|mm/dd}") 'Only display month and date on X Axis
---------------------------------
the 'data' container has close to 1000 data points, so when displayed, the x axis labels(also ~1000 count) are all blurred together.
I tried using
----------
c.xAxis.setDateScale(labelArr(0), labelArr(labelArr.Count() - 1), 86400)
---------
to control the x axis tick to be a day, while (hopefully) still maintaining the same trend line. But when I added setDateScale, my trend line completely disappeared.
Please give some pointer on how to achieve just the thinning out of X axis labels.
Thanks,
-Vicky |
Re: line disappear after adjusting setDateScale |
Posted by Peter Kwan on Aug-18-2012 01:29 |
|
Hi Vicky,
The line disappear because its x-coordinates does not match the x-axis scale on the axis.
If you add a line layer without specifying the x-coordinates, ChartDirector will assume the x-coordinates of the data points to be their array index 0, 1, 2, 3, ... Similary, if your code put some labels on the x-axis (eg. using Axis.setLabels or Axis.setLabels2) without defining a scale, ChartDirector will assume the x-coordinates of the labels to be their array index 0, 1, 2, 3, ... So each data point matches with a label on the x-axis.
However, if your use Axis.setDateScale to define a date scale, the x-axis scale is no longer 0, 1, 2, 3 ... But the data points are still using x = 0, 1, 2, 3 ... So the data points are outside the x-axis range and will not be displayed.
To solve the problem, you may set the x-coordinates of the data points using setXData:
linelayer.setXData(labelArr)
You can optionally set the x-axis scale (if you do not set the x-axis scale, it will be auto-scaled like the y-axis):
'The following lines are optional
c.xAxis.setDateScale(labelArr(0), labelArr(labelArr.Count() - 1), 86400)
c.xAxis.setLabelFormat("{value|mm/dd}")
Hope this can help.
Regards
Peter Kwan |
Re: line disappear after adjusting setDateScale |
Posted by Vicky on Aug-18-2012 03:14 |
|
Peter, you are a genius. This makes perfect sense. Thanks a million!
-Vicky |
|