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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

108725 May 8,2013 06:33 PM May 30,2013 12:35 AM Windows Forms 3
loading
Tags: Chart
Dennis Beaugrand
Asked On May 8, 2013 06:33 PM

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



Anandaraj T [Syncfusion]
Replied On May 14, 2013 03:07 AM

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

Dennis Beaugrand
Replied On May 27, 2013 07:20 PM

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

Anandaraj T [Syncfusion]
Replied On May 30, 2013 12:35 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;