Chart is not displaying the data I want

Hello everyone. I would like your help about this problem of mine.
I used Syncfusion Chart for the first time and I managed to bind my dataset to the chart.
Now the problem is, it is not displaying the data the way I expected it to.


Check chart above for the chart.

All I want is that, it would display the Date of the data, not some gibberish numbers like what I am seeing below.

I hope you can help me. I dont really understand. 

Here is my current code by the way. 

Update: I tried setting the value type of the PrimaryXAxis to custom and now the graph is alignment of data is way off the mark.
Here is the image

Here is the code:

    chartProcedureResult.Series.Clear()
            chartProcedureResult.Text = seriesName & " results history"
            Dim model As ChartDataBindModel = Nothing
            Dim xAxisLabelModel As ChartDataBindAxisLabelModel = Nothing
            model = New ChartDataBindModel(chartDS, "TestResult")
            model.XName = "procedure_date"
            model.YNames = New String() {"result"}
            chartProcedureResult.Indexed = True

            Dim series As New ChartSeries(seriesName, ChartSeriesType.Spline)
            With series
                .SeriesModel = model
                .Text = series.Name
                .Style.DisplayText = True
                .Style.Border.Width = 3
                .Style.TextOrientation = ChartTextOrientation.Smart
                .Style.Symbol.Shape = ChartSymbolShape.Circle
            End With
            Me.chartProcedureResult.Series.Add(series)
            xAxisLabelModel = New ChartDataBindAxisLabelModel(chartDS, "TestResult")

            xAxisLabelModel.LabelName = "procedure_date"


            chartProcedureResult.PrimaryXAxis.LabelsImpl = xAxisLabelModel
            chartProcedureResult.PrimaryXAxis.ValueType = ChartValueType.Custom
            chartProcedureResult.PrimaryXAxis.Title = "Procedure date"
            chartProcedureResult.PrimaryYAxis.Title = "Results"
            chartProcedureResult.PrimaryYAxis.ValueType = ChartValueType.Double


1 Reply

SK Sanjith Kesavan Syncfusion Team June 12, 2018 09:05 AM UTC

Hi John, 

Thanks for contacting Syncfusion support. we have analyzed your queries and code examples. To avoid this kind of problem, please follow the below steps. 

While adding data in table, please set the type of the data as “DateTime”. Kindly check the below code.  

[VB.NET] 
Dim dataset As New DataSet() 
Dim table As New DataTable("Demographics") 
table.Columns.Add("X", Type.GetType("System.DateTime")) 
table.Columns.Add("Y")         
table.Rows.Add(New Date(2000, 1, 1), 20) 
table.Rows.Add(New Date(2000, 1, 2), 10) 
table.Rows.Add(New Date(2000, 1, 3), 15) 
table.Rows.Add(New Date(2000, 1, 4), 25) 
table.Rows.Add(New Date(2000, 1, 5), 10) 
dataset.Tables.Add(table) 

Instead of setting axis type as custom, please set axis type as “DateTime” and set the “DateTimeRange” for primary x-axis based on your data. Kindly check the below code.  

[VB.NET] 
chart.PrimaryXAxis.ValueType = ChartValueType.DateTime 
chart.PrimaryXAxis.DateTimeRange = New ChartDateTimeRange(New Date(1999, 12, 31), New Date(2000, 1, 6), 1, ChartDateTimeIntervalType.Days) 
chart.PrimaryXAxis.DateTimeFormat = "dd-MM-yyyy" 

in the above code we have set axis value type as “DateTime”, minimum, maximum, interval and interval type for primary x-axis. Now the chart will render like below. 
 
In the below link, we have attached sample for your reference.  
Sample link: chart-sample 

Check the sample and let us know if you have any concern. 

Thanks, 
Sanjith. 


Loader.
Up arrow icon