How to specify the datetime display format in WinForms Chart?
To display both the hours and minutes together using Syncfusion® WinForms Chart, you can utilize the DateTimeFormat property of the primary X-axis. By setting the DateTimeFormat to "hh:mm", you can achieve the desired display format.
//Assign the X and Y axes
this.chartControl1.PrimaryXAxis.ValueType = ChartValueType.DateTime;
this.chartControl1.PrimaryYAxis.ValueType = ChartValueType.Double;
this.chartControl1.PrimaryXAxis.EdgeLabelsDrawingMode = ChartAxisEdgeLabelsDrawingMode.Shift;
//Update the data points to the chart series
foreach(var item in dataSource)
{
chartSeries.Points.Add(item.Date, item.Sales);
}
this.chartControl1.Series.Add(chartSeries);
//Assign the DateTime X axis format
this.chartControl1.PrimaryXAxis.DateTimeFormat = "hh:mm";
'Assign the X and Y axes
columnChart.PrimaryYAxis.ValueType = ChartValueType.Double
columnChart.PrimaryXAxis.ValueType = ChartValueType.DateTime
columnChart.PrimaryXAxis.EdgeLabelsDrawingMode = ChartAxisEdgeLabelsDrawingMode.Shift
'Update the data points to the chart series
For Each item In viewModel.PlantDetails5
ChartSeries1.Points.Add(item.Date1, item.Sales)
Next
columnChart.Series.Add(ChartSeries1)
'Assign the DateTime X axis format
columnChart.PrimaryXAxis.DateTimeFormat = "hh:mm"Output:
Conclusion
I hope you enjoyed learning about how to specify the datetime display format in WinForms Chart.
You can refer to our WinForms Chart feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. You can also explore our WinForms Chart examples to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!