Nevron Forum

How to draw custom object with value of datetime

https://www.nevron.com/Forum/Topic6673.aspx

By Xiaolong Zhu - Tuesday, July 10, 2012

Hi experts

i need to draw thousands of line segments in one chart. Currently i get two ways to do this:

1> Create one line series for one line segment. so the num of the line series is same as the line segments. it has been proved to be works but with very low performance.

2> using GDI to draw these line segments by the API of INPaintCallBack. But the x value of the line segment is the type of datetime i don't know how to do the transformation from model space to client space. you can see the code snippet below:

var dataSeries = series as TimeBasedLineSeries;

vecModelStartPoint.X = (float)dataSeries.XValues[0].ToOADate();

vecModelStartPoint.Y = (float) dataSeries.YValues[0];

vecModelStartPoint.Z = 0;

vecModelEndPoint.X = (float)dataSeries.XValues[1].ToOADate();

vecModelEndPoint.Y = (float)dataSeries.YValues[1];

vecModelEndPoint.Z = 0;

_chart.TransformModelToClient(_chartCtrl.View.Context, vecModelStartPoint, ref vecClientStartPoint);

_chart.TransformModelToClient(_chartCtrl.View.Context, vecModelEndPoint, ref vecClientEndPoint);

graphics.DrawLine(new NStrokeStyle(1, dataSeries.Colors[0]), new NPointF(vecClientStartPoint.X, vecClientStartPoint.Y),new NPointF(vecClientEndPoint.X, vecClientEndPoint.Y));

So how to do the conversion? or is there any other solution to this case? thanks in advance.

 

By Nevron Support - Tuesday, July 10, 2012

Hi Xiaolong,

You're doing the conversion correctly (ToOADate will get the double equivalent of the date time). What's not working exactly? Can you send a complete app replicating the problem to support@nevron.com ?

You can also use the regular line series with different appearance settings per data point.

By Xiaolong Zhu - Thursday, July 12, 2012

Thanks for your answer. So could you please take a look at the attached code?
By Nevron Support - Thursday, July 12, 2012

Hi Xialong,

The problem in this case is that the chart does not have valid data points - therefore the axes will not be scaled. We would recommend to use the CustomSeries in the new version for this purpose.