Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
622
Irregular intervals between datapoints in LineChart
posted

Hello,

I have a chart which has to draw a value serie vs. time.  So I need a axe X which represent a day, with grid line each hour.  Axe Y has numeric values.

My problem is that datapoints are irregular on one day period.  I could have 3 points with 5 minutes interval then the next one 15 minutes later.  My line must not be broken.  I read that I'm supposed to use ScatterLine chart, but I've not been able to make it work.

Could you help me ? I attach a sample with a fake line to draw my grid line every hour, and a real line with random intervals.

Patrick.

WpfApplication1.zip
Parents
No Data
Reply
  • 30945
    Offline posted

    Hello Patrick,

     

    I have been reading though the functionality that you are looking for and after some investigation I have created a sample application which demonstrates how you can implement functionality similar the one that you described. I have created a data source that contains three properties: one from type double that represents the Y values, one from type DateTime and the last property returns the double representation of DateTime property using the ToOADate method of the DAteTime class.

     

    I have created a collection of the objects that I have described and use it as a DataSource for a Scatter Line  Series. I have used the first double property to map it to the  Y Value of the DataPoitns and for the X Value I have used the double representation of the DateTime property. By using this approach the XamChart will arrange the DataPoints on the X axis based on the DateTime.

     

    I have created a Converter, and bind the Minimum, Maximum and Interval properties of the Primary X axis to the data context of the chart using the converter. In the Convert method of the Converter I am setting the Minimum and Maximum properties to the minimum and maximum values of the double representation of the DateTime of the data source and I am also calculating what the interval should be in order for the XamChart to display vertical gridlines for each hour. By following this approach you will be able to achieve the same appearance as show in the screenshot that you have attached. Since the XamChart does not currently support styling and templating the labels on the axis, when following this approach, the XamChart will display double representation of the DateTime instead of the hour.

     

     

    Please let me know if you need any further assistance on the matter.

     

    Sincerely,

    Krasimir

    Developer Support Engineer

    Infragistics

    www.infragistics.com/support

    XamChartDateTimeX.zip
Children
No Data