Duplicate labels on the axis


#1

How do I avoid having duplicate labels on my axis especially when user has zoomed in a lot.

I’m not setting any major or minor tick internal on my axies, they automatically adjust to the data that is being displayed.

As seen in screenshot, I specifically wants x-axis format to be in mmm yyyy format, and y axis to be integer % format.

I prefer not to calculate and set the major/minor tick interval manually because the axis range changes when user interact with the chart.

Screenshot: http://take.ms/YewUv


#2

Hi.

Are you using iOS or Android charts please?

Thanks,

Kai.


#3

Sorry, i forgot to mention I’m using both iOS and Android. Both having this issue.


#4

any update?


#5

Hi torringuyen,

For iOS, have you tried setting the majorTickFrequency? If you know that you want to display labels no more frequently than 1 month then you should be able to something like:

_chart.xAxis = [SChartDateTimeAxis new];
_chart.xAxis.majorTickFrequency = [SChartDateFrequency dateFrequencyWithMonth:1];
_chart.xAxis.labelFormat = @"YOUR FORMAT";

I hope that helps,

Kind regards,

Sam


#6

Hi torinnguyen,

You’re not actually getting duplicate tick marks here (although yes, the labels are the same!). As you are applying a format to the tick mark labels, at certain zoom levels more than one value will be formatted to the same string.

For example, say you have a formatter on an axis that removes an decimal places then when your ticks have a frequency of 1 that’s ok:
{ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 } are formatted as { 0, 1, 2, 3, 4, 5, 6 }.

If the axis however has a frequency of 0.5 (say, because someone has zoomed in) then:
{ 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0 } are formatted as { 0, 0, 1, 1, 2, 2, 3 }

Obviously the same applies for DateTimeAxes as well.

Unfortunately this means if you do want to apply a formatter to your tick mark labels then you will also need to change the tick mark frequency (or the formatter) depending on the current axis display range if you want to avoid this kind of behaviour.

In  shinobicharts for Android we provide the ShinobiChart.OnAxisRangeChangeListener to allow you to react to changes in the axis display range (from things like user interaction etc.)

For more info see https://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.8.0/Premium/Normal/apidocs/reference/com/shinobicontrols/charts/ShinobiChart.OnAxisRangeChangeListener.html

Kind regards,

Patrick