DateTimeAxis labels formatting when using different time granularity

I'm using an SfCartesianChart and using an X-axis that's a DateTimeAxis

My data is quite varied, so sometimes I'll have date covering 24 hours and sometimes covering months, so using the automatic handling is great for showing the correct granularity on the labels.

My only issue is that with times the user has the option in the app of setting 12 hour or 24 hour clocks.

I've seen the `dateFormat` property on `primaryXAxis`, but I don't know which granularity the graph is currently using.

So my question is, is there a way to customize the dateFormat on a label and still have the power of the dynamic labels based on the data supplied ot the chart


1 Reply

LP Lokesh Palani Syncfusion Team April 8, 2024 11:13 AM UTC

Hi Andrew,


You can achieve your requirement by using the axisLabelFormatter callback in the DateTimeAxis. This allows you to get each axis label text and format it using the DateFormat before returning it as a String datatype. We have provided a user guide documentation for your reference. Please inform us if you require additional assistance.


UG Link,

https://help.syncfusion.com/flutter/cartesian-charts/callbacks#axislabelformatter


Regards,


Loader.
Up arrow icon