Profile Picture

How to draw custom object with value of datetime

Posted By Xiaolong Zhu 12 Years Ago
Author
Message
Xiaolong Zhu
Posted 12 Years Ago
View Quick Profile
Junior Member

Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 18, Visits: 1

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.

 



Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

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.



Best Regards,
Nevron Support Team



Xiaolong Zhu
Posted 12 Years Ago
View Quick Profile
Junior Member

Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 18, Visits: 1
Thanks for your answer. So could you please take a look at the attached code?

Attachments
WindowsFormsApplication1.zip (80 views, 2.00 MB)
Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

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.



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic