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

How to add labels for the last day of a month in a DateTimeAxis with zooming


How do i add labels for a DateTimeAxis for the last day of the month?

If i set Interval to 1 and IntervalType to Months, i get labels for the first day of the month.

I can achieve it by setting Interval to 1, IntervalType to Days and MaximumLabels to a very high number (e.g. 366 since i want to display one year). Then i can register to the LabelCreated event, and in there check if the label to be created belongs to the last day of the month, and if not setting the LabelContent to an empty string. It works in general this way, but the higher the MaximumLabels number is, the slower zooming becomes (even if i don't handle the event). At 100, zooming is so slow that it's unusable, and i don't get the labels for each month. At 366 it is so slow that there is no response until android asks if i want to close the app since it isn't responding.

So is there a way to do this while still enabling zooming?

7 Replies

YP Yuvaraj Palanisamy Syncfusion Team March 31, 2016 01:08 AM UTC

Hi Rafael,

Thanks for using Syncfusion products.

We have analyzed your query and have prepared a workaround sample using generateVisibleLabels method of ChartAxis. Please find the sample from the below location.

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/SimpleSample-1521569301756241455.zip

Yuvaraj P.

CH CHSOFT April 1, 2016 12:52 PM UTC


Thanks, this helps more or less, but one issue remains: If my chart has a range from 31/12/2014 to 31/12/2015, i won't have a label for 31/12/2015. Your method moves the label back one day, and there is no label for 1/1/2016 because it's outside of the chart's range. Unfortunately the constructor of ChartAxisLabel is protected, so i don't know how to create a new label to add it.
And if i set the Interval to 1 day, increase MaximumLabels and filter out the not needed labels in GenerateVisibleLabels, the zooming is slow again.

Kind regards

YP Yuvaraj Palanisamy Syncfusion Team April 4, 2016 09:12 PM UTC

Hi Rafael,

We have modified the sample based on your requirement and it can be downloaded from the following location. 

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/SimpleSample-AxisLabel-196302069-587413316.zip   


CH CHSOFT April 5, 2016 06:57 AM UTC

Hi Yuvaraj

Unfortunately, while it works for a ColumnSeries, it doesn't work for a LineSeries.

Kind regards

MS Mohamed Samsudeen K S Syncfusion Team April 6, 2016 06:23 AM UTC

Hi Rafael,

Thanks for the update.

We are unable to reproduce the reported issue in the provided sample. Please find the below image.

If you are still facing this issue, you can set the IntervalType property of DateTimeAxis to Month and Interval property to number of required intervals as shown in the below code snippet.

DateTimeAxisExt primaryAxis = new DateTimeAxisExt()


    IntervalType = DateTimeIntervalType.Months,

    Interval = 1

Please check and let us know if you have any queries.

Samsudeen K S

CH CHSOFT April 6, 2016 06:52 AM UTC

HI Samsudeen

Even in your screenshot there is no label for 31/Dec/2015, which is exactly the remaining issue.

Kind regards

MS Mohamed Samsudeen K S Syncfusion Team April 6, 2016 10:34 AM UTC

Hi Rafael,

We have added a new feature in Essential Studio Volume 1, 2016 release called “EdgeLabelsVisibilityMode” for axis which can take values as Default, Visible and AlwaysVisible.

Default – The edge labels will be rounded to nearest value in order to get the nice labels.

Visible - The edge labels will be visible even if it is not a rounded value. But, the edge labels will not be visible while zooming.

AlwaysVisible – Works exactly like “Visible” mode. But, the edge labels will be visible while zooming.

Using this feature, we have achieved your requirement and updated the sample.


Please upgrade to the latest version which is available for download under the following link:
Link: https://www.syncfusion.com/forums/123633/essential-studio-2016-volume-1-release-v14-1-0-41-is-available-for-download

Samsudeen K S

Live Chat Icon For mobile
Up arrow icon