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

DateTime Axis Label Formatting

When zooming in on a line chart with a date axis, the date part get's removed and it is just the time, which could span a couple days and is quite confusing. Is there a way to tell it to keep the date when zooming in?
The Blazor LabelFormat documentation is partial and the rest is missing. 
  
Links to blank page:

https://help.syncfusion.com/cr/blazor#Syncfusion_Blazor_Charts_ChartCommonAxis_LabelFormat/Syncfusion.Blazor.html

Googling around I found this which helped
https://www.syncfusion.com/kb/3936/how-to-format-labels-in-date-time-axis

LabelFormat="MM/dd/yyyy h:mm tt"
This is pretty much it but it's not dynamic, ie it would be nice to show just the date when zoomed out but the date + time when zoomed in. 
Also is there a way to set high/low data cutoffs, for example if most values are 100000 but 0 gets into the data it skews the axis range. 


1 Reply

DG Durga Gopalakrishnan Syncfusion Team January 4, 2023 03:27 PM UTC

Hi Jedon,


By default when LabelFormat is specified for date time axis, then axis labels will be rendered in specified format. While zooming the chart and when data available in zoomed position doesn’t match the LabelFormat, then labels won’t be displayed. The LabelFormat is applicable for static datasource in which data is specified based on specified format. It is an actual behavior.


When LabelFormat is not specified then while zooming the chart axis labels will be calculated automatically based on zoomed data. You can customize the labels in OnAxisLabelRender event based on your requirement. Please check with the below documentation link.


UG : https://blazor.syncfusion.com/documentation/chart/events#onaxislabelrender


Initial Rendering


After Zooming

Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/DatetimeLabels94208634.zip


Kindly revert us if you have any concerns.


Regards,

Durga Gopalakrishnan.


Loader.
Up arrow icon