ShinobiChart ignoring MajorTickFrequency


#1

I set the yAxis MajorTickFrequency to a certain value, but it is ignoring this setting and choosing its own frequency. This happens with every value I set.

Here an example with a frequency of 10:

SChartNumberAxis*yAxis =[[SChartNumberAxis alloc] init];
sChart.yAxis = yAxis; yAxis.style.majorGridLineStyle.lineWidth =@1;
yAxis.style.majorGridLineStyle.lineColor =[UIColor lightGrayColor];
yAxis.style.majorGridLineStyle.showMajorGridLines = YES;
[yAxis setMajorTickFrequency:[NSNumber numberWithFloat:10.0f]];

Is resulting in:

This didn’t happen in very old versions of ShinobiCharts, Im using the newest version (2.8.2.1-ALPHA) and was hoping it would be fixed soon, but Im waiting a few months now.

Related:

http://stackoverflow.com/questions/31182143/shinobicharts-ignoring-majortickfrequency


#2

Hi there,

We changed how the frequencies are calculated for major and minor ticks in version 2.8 of shinobicharts.

Pre-version 2.8, if there wasn’t enough space for the desired majorTickFrequency, we would continue to multiply the value by 2 until there was enough space for the tick labels (10, 20, 40, e.t.c).

Now however, if there is not enough space for tick labels at your desired tick frequency, the chart automatically calculates a frequency that will fit along the axis. In your case, a major frequency of 10 will cause tick labels to overlap, the chart then falls back to a tick frequency of 50. 

To workaround this, you should be able to set your majorTickFrequency to something slightly higher, e.g. 20, although the required value depends on the height of your chart. You could also take a look at the sChart:majorTickValuesForAxis: datasource method.

It was a bit of an oversight on our part to change the old behaviour without adding a way to get it back. However, we are planning on making this more customisable in the near future - I’ll make sure we update this ticket when it’s released.

Kind regards,

Sam


#3

Hey,

thanks for the resopnse, but sChart:majorTickValuesForAxis: datasource isnt quite doing the trick. I got the majorTickMarks to show every 20, instead of every 10.

Is it possible to show the majorTickLines every 10 without the Labels? So that the Labels would be at 0, 20, 40, 60, 80 and 100, but the gridlines would be every 10?


#4

Hi,

You would have to set the majorTickFrequency to 10 and implement the SChartDelegate method “sChart:alterTickMark:beforeAddingToAxis:” to set the tickLabel & tickMarkView’s hidden property to YES on tick mark’s you don’t want to see the labels of (In your case: 10, 30, 50). Below is some sample code of setting these mentioned properties.

tickMark.tickMarkView.hidden =
tickMark.tickLabel.hidden =YES;

Now to get your chart to use the 10 majorTickFrequency you can try the following:

  • Give your chart a bigger width or height depending on if your editing the X or Y axis.
  • Implement the SChartDelegate method “sChart:longestLabelStringOnAxis:” to return an emptry string.
  • Set the “minimumFreeAxisSpace” property on your axis to 0.

Let me know if you have any questions.

Kind regards,
Andrew Polkinghorn