We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Date not binding properly at X val using EF 5 bound datasource

I have a simple test app which adds rows to  table NmsSummaries with Date as Xval  and a random number used for Y.

ChartControl is bound to this through EF5  to display a simple line chart. 
I also have a  Datagridview bound to the same source so I can see what is happening in real time.
The chart is updating as I add rows and I see the new Y value corresponding to the random value generated  but the x value dates are all starting at Dec30 1899!

A similar test using datasets works properly adding points at current date
Any ideas what is wrong?

Code below
Public Class Form1

    Dim context As IdirectLocalDbDAL.LocalDbEntities


    Sub InitChart()

        Dim model As New ChartDataBindModel(context.NmsSummaries.Local.ToBindingList)
        Dim X = model.XIndex

        model.XName = "TheDate"
        model.YNames = New String() {"MaxCn"}

        Dim series As New ChartSeries("Series")

        series.Text = series.Name
        series.SeriesIndexedModelImpl = model

        series.Type = ChartSeriesType.Line
        ChartControl1.PrimaryXAxis.ValueType = ChartValueType.DateTime

        Me.ChartControl1.Series.Add(series)


    End Sub



3 Replies

AT Anandaraj T Syncfusion Team May 14, 2013 07:07 AM UTC

Hi Dennis,

Thanks for using Syncfusion products.

When value type of x axis is set to date time, then data bound with x axis should be also of type "DateTime". If data bound with x axis is not of type "DateTime" and x axis value type is set to date time, then labels will be displayed starting from December 30 1899 by default.

From the code snippet provided by you, the column "TheDate" is bound with x axis. If the values of this column is not of type "DateTime", we suggest you to set the value type of x axis to "Custom".

For more information about data binding, please refer our online documentation in the following link:
Binding a DataSet to the Chart

Please let us know if you have any concerns.

Regards,
Anandaraj


DB Dennis Beaugrand May 27, 2013 11:20 PM UTC

Problem was that I was using indexed model and first Date index is apparently 1900.
I switched to seriesmodel and all is working fine.


AT Anandaraj T Syncfusion Team May 30, 2013 04:35 AM UTC

Hi Dennis,

Thanks for the update. We are glad to know that your issue has been resolved.

Please let us know if you have any concerns.

Regards,
Anandaraj

Loader.
Live Chat Icon For mobile
Up arrow icon