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

xaxis Date Labels nto correct

I have been working a scatter chart. It is nearly completed. However I need to sort out my xAxis and its labels.

The xAxis is a datatime. I need to show the date only on it . However, I get strange dates that are not even in the data. So obviously I have missed something. This is the image of the output as it sites today:

This is my code setup. The xAxis is Closed Date which is a DateTime type

When I change the xAxis name to "Date" I see this.

Here is my code (VB.net) . Somethings are commented out, other comments tell what I am trying to do.

Any guidance is appreciated, its a mess right now.

John W.


'Working Chart Code

Dim xAxisLableModel As ChartDataBindAxisLabelModel = Nothing

Dim modChart As ChartDataBindModel = Nothing

Dim dsChartData As New DataSet

'Add datatable to dataset or chart


'*****Chart Setup******

'Count Rows in dataset for testing

Dim x As Integer = dsChartData.Tables("Table1").Rows.Count

'load data into model

modChart = New ChartDataBindModel(dsChartData, "Table1")

'Set x and y

modChart.XName = "CloseDate"
modChart.YNames = New String() {"Close Price"}

'Create Trend Line

Dim trend As New TrendlineCollection
Dim trndLne As New Trendline
Dim polyTrend As New Trendline

'TrendLine 1 create and add

trndLne.Type = TrendlineType.Linear
trndLne.Name = "Trend1"
trndLne.Visible = True
trndLne.Style = Drawing2D.DashStyle.Solid
trndLne.Width = 2.0F
trndLne.Color = Color.Red
trndLne.ForwardForecast = False

'Trend Line Poly 2 to create and add

polyTrend.Type = TrendlineType.Polynomial
polyTrend.PolynomialOrder = 3
polyTrend.Name = "Trend2"
polyTrend.Visible = True
polyTrend.Style = Drawing2D.DashStyle.Solid
polyTrend.Width = 2.0F
polyTrend.Color = Color.Blue
polyTrend.ForwardForecast = False

'Create series and chart type

Dim series As New ChartSeries("Import Data")
series.Type = ChartSeriesType.Scatter
series.Text = series.Name

series.SeriesModel = modChart

series.Style.TextColor = Color.Black
series.Style.Font.Bold = True

' series.Style.DisplayText = True


ChartControl1.PrimaryXAxis.ValueType = ChartValueType.DateTime
ChartControl1.PrimaryXAxis.DateTimeFormat = "MMM dd"
ChartControl1.PrimaryXAxis.LabelRotate = True
ChartControl1.PrimaryXAxis.LabelRotateAngle = 30
ChartControl1.PrimaryYAxis.ValueType = ChartValueType.Double
ChartControl1.PrimaryYAxis.Format = "c"

'Dim i As UInteger = ChartControl1.Series.VisibleCount
'xAxisLableModel = New ChartDataBindAxisLabelModel(dsChartData, "Table1")

'xAxisLableModel.LabelName = "Date"
ChartControl1.PrimaryXAxis.RangePaddingType = ChartAxisRangePaddingType.Calculate
'ChartControl1.PrimaryXAxis.LabelsImpl = xAxisLableModel

4 Replies

JW John willems March 15, 2023 07:02 PM UTC

I tried to edit the first post but when I change the xAxis.name to "Date" the column header in datatable I see this.

A real mess of things. 

John W

NM Nanthini Mahalingam Syncfusion Team March 16, 2023 02:16 PM UTC

Hello John Willems,

We have analyzed your query and would like to inform you that if you use ChartValueType as 'Category', all the axis labels will display on the PrimaryXAxis by setting the interval to 1. Based on your requirements, since you are using linear data, the axis label should display based on its range base. Therefore, we recommend displaying all the axis labels by setting custom labels.

Please refer to the following documentation, which will be helpful to you:


Please let us know if you need further assistance.


Nanthini Mahalingam.

JW John willems March 16, 2023 04:12 PM UTC

Thank you, that sorted the xAxis labeling.

My hopefully last question has to do with the trendline. When sort the data by date or cost it changes the chart/graph. The trendline will go up or down depending on the order. The x(date) and y(cost) remained paired but the graph changes. (See Images)

I need to correct this behavior. Is there a  way to fix to this?

John W

NM Nanthini Mahalingam Syncfusion Team March 17, 2023 10:25 AM UTC

We are pleased to learn that our solution meets your requirements. According to Trendline behaviors, trend lines should be drawn based on PrimaryXAxis values. Therefore, we recommend sorting the date values and displaying the trend lines.

Additionally, we suggest using Trendline forecasting if you wish to display previous or future predictions.

Please refer to the following document, which will be helpful to you:


Please let us know if you need further assistance.

Live Chat Icon For mobile
Up arrow icon