X Axis with Formatted Dates


#1

I am trying to format the X axis to follow a specific pattern with dates.  I have been able to get the date to show as MM/DD easily, but the pattern I wish to implement eludes me.  The pattern is:

Month Day  Day  Day Month Day etc, where “Month” will show the month, once and only once for the first day plotted on the chart.  Each subsequent day will simply show the day number without the month until the month rolls to the next month.

Another example:  Jan 1 8 15 22 29 Feb 5 12 … etc …

Is this possible with the chart control, and if so, can anyone provide some insight on how this may be done?

Thanks!


#2

Hello EIG,

Thanks for getting in touch. Could you please tell us - are you using our iOS or Android charts product?

Thanks,

Kai.


#3

Kai:

We are using the iOS charts product.


#4

Hi EIG,

If you want to do this, you’ll need to create a custom date formatter, assign it as your axes label formatter:

self.chart.xAxis.labelFormatter.formatter = myCustomDateFormatter;

You’ll then have to implement this formatter so it understands which tick mark is the first tick mark in the month, and return the month, and then any subsequent tickmarks, it can return the day.

Best regards,
Jan