ShinobiCharts Percentage based y axis with multiple ChartSeries


Hey guys, is there any way to implement a percentage based y axis in case multiple chart series need to be compared directly?

For reference, take a look at the Yahoo finance chart with a comparison symbol: click me

As you can see, both series share the same y value on the current ranges minimum, which always remains that way during panning and zooming.

Naturally, this requires to contantly adjust both series’ datapoints to be re-calculated on the fly during range manipulation.

I just couldn’t find a way to implement this with the ShinobiCharts version we’ve got now (2.7.3). Is there a way to achieve this?



HI Maximilian,

Could I ask what approaches you’ve tried so far? To get this effect you’d need to alter the data that’s on the chart, and that would call for a reloadData & redrawChart. Note that this may incur an overhead with a large number of datapoints.

Jan Akerman


Thanks for your response Jan.

What I’ve tried to do thus far is to modify the dataPoints on the fly using dataPointAtIndex on the datasource. That, however, wouldn’t work as the axes etc. won’t  adapt to these new values. It just seems overly complicated in terms of resources to have the chart reload on each and every update, which is why I was asking.

Anyway, I’m currently in the process of writing a method in my datasource that re-calculates each series’ y values based on the percentages using a deep copy of the original series and then returning that copy in “dataPointsForSeriesAtIndex” instead of the original one. Hopefully the performance hit won’t be that big.


Hi Jan,

There are still some questions regarding the implementation of this feature. My pinch gesture recognizer works fine with reloading and redrawing the chart on the fly using the following (pseudo) code;

-(void) pinchGestureRecognizer {

    [mainChart reloadData];


-(void) sChartDidFinishLoadingData:(ShinobiChart *)chart {
    [mainChart.xAxis setZoom:savedZoomValue fromPosition:&savedInterval withAnimation:NO andBounceLimits:YES];


Again, that works as expected. The gesture recognizer recalulcates the data, forces a reload and sets the chart’s zoom once the data has been reloaded.

Things are totally different with panning, though. I’ve tried it in the same way as with the pinch. Apparently, the [reloadData] causes the chart to get set back to the maximum range, so I somehow need to set the current range before setting the pan, i.e. using chart.xAxis setRange. However, I couldn’t figure out a way to make this work yet. The chart just won’t pan properly, instead it’ll jitter around its current range during panning.

Did you guys ever came across this requirement and worked it out? 


HI Maximilian,

As you’ve mentiooned, by default the chart resets it’s range to the default range on a reload. You can disable this by setting the property autoCalculateAxisRanges to NO. When you reload, the axis range should stay as it was. Please let me know if that helps!



Thanks for your response Jan.

That does the trick. Still, performance is far from good, even for only 500 datapoints for each series (currently only showing 2 series). The calculation of the datapoints itself isn’t the issue, I’ve tested it both on the main thread and threaded (using NSOperationQueue and GCD). Interestingly, just doing it on the main thread performed the best. 

However, given that I call redraw every time, the performance should get much better with the upcoming release that addresses the performance issue of the tickmark calculations. Well, at least I hope it does. :wink:


Your welcome Maximilian. I’m not sure how much the tick mark improvements will affect your use case - I suppose we’ll find out soon! If you’re still having trouble after our release let us know and we’ll look into why you’re seeing performance problems and see what we can do about it. Maybe it’s another optimisation area we can put on our road map!