|
setting datetime x axis |
Posted by Craig Roberts on Dec-31-2024 07:37 |
|
Hello Peter,
I am using XYChart and plotting a linelayer in vb.net.
I am trying to set the
c.xAxis.setDateScale(DateTime.Parse("2024-12-21 06:00"), DateTime.Parse("2024-12-22 06:00"))
to fix the c.xAxis startdate / enddate of chart
I am formatting as c.xAxis.setLabelFormat("{value|hh:mn}")
my data labels looks like;
2024-12-21 06:01: AM
2024-12-21 06:06: AM
2024-12-21 06:11: AM
2024-12-21 06:16: AM
2024-12-21 06:21: AM
2024-12-21 06:26: AM
Problem : I cannot get the data to show
Any suggestions, I have checked forum and tried various things.
Regards
Craig Roberts |
Re: setting datetime x axis |
Posted by Peter Kwan on Dec-31-2024 13:23 |
|
Hi Craig,
By "I cannot get the data to show", do you mean you cannot get the line in your LineLayer to show? Or are you referring to showing the axis labels?
If you can see the linelayer without the setDataScale, but you cannot see the line layer with setDateScale, it is likely because your LineLayer has no x-coordinates.
If you add a LineLayer without providing x-coordinates (using Layer.setXData), ChartDirector will automatically use the array index (0, 1, 2, 3, ...) as the x-coordinates.
If you use Axis.setLabels to add labels to the x-axis, the labels are just names and has no meaning to ChartDirector. (The labels can be "Apple", "2024-12-31 06:00", "999" or any text.) They are displayed as is. The x-coordinates of the labels are also its array index (0, 1, 2, 3, ...). That's why the data points and the will match.
The following is an example that uses no x-coordinates:
https://www.advsofteng.com/doc/cdnet.htm#symbolline2.htm
If you then configure the x-axis with setDateScale, it will not match the automatic x-coordinates (0, 1, 2, 3. ...) for the LineLayer, so the line may not be visible. That means if you use setDataScale, you also need to provide the x-coordinates for the data points.
The following is an example:
https://www.advsofteng.com/doc/cdnet.htm#unevenpoints.htm
If the above still does not solve problem, would you mind to inform me of your code that adds and set up the LineLayer ?
Best Regards
Peter Kwan |
|