iOS changing Chart Axis Crash


In our application, we allow the user to change the scale of the Y Axis from Linear to Logrithmic.  When the user changes the scale, we use the [chart replaceYAxis:oldAxis withAxis:newAxis] method to change out the axis.  However, shortly after that, we get a crash because the series on the chart reference the old axis which is now deallocated.  

How do you suggest we accomplish this change of axis scale?


So, I tried the following steps to get arround the issue…

  1. The controller is retaining instances of the number axis and the logrithmic axis so that they don’t get deallocated and we don’t have to create new axis if the user is changing it back and forth.  This solved the messages to deallocated objects.

  2. I replace axis now tells me that the axis already belongs to the chart even thought he debugger clearly shows that it is not in the yAxes array.

  3. I tried using addYAxis for the new axis and then removeYAxis for the old axis (in that order) but I still get the same message “ShinobiCharts: SChartAxis at 0x1fd04e60 already belongs to this chart”


Hey Jmonroe,

I made a very crude test application and I couldn’t replicate your issue. I loaded up a simple chart, added a button, and added the following method as a target.

BOOL logAxis = YES;

-(void)buttonTouched {
    if (logAxis) {
        [_chart replaceYAxis:_chart.yAxis withAxis:[SChartLogarithmicAxis new]];
        logAxis = NO;
    } else {
        [_chart replaceYAxis:_chart.yAxis withAxis:[SChartNumberAxis new]];
        logAxis = YES;

I managed to swap between the different axes types without any crashes. Is there something more that you’re trying to do? I’m asking about your original implementation, we’ll get onto your workarounds when we’ve managed to identify the problem!  :grin:



I’m having a similar problem.  The example code below triggers the problem.

Error: “ShinobiCharts: SChartAxis at 0x128846ce0 already belongs to this chart From: ShinobiChart at 0x1288d5f20”

Any idea why this occurs?  

My goal is to sort the allYAxes array.  How can this be achieved without removing all first then adding them all back in a sorted order?

Thanks in advance.

for (int i = 0; i < [self.chart.allYAxes count]; i++) {
		SChartAxis *axis = [self.chart.allYAxes objectAtIndex:i];
		[self.chart removeYAxis:axis];
		[self.chart addYAxis:axis];


Hi cbartel,

Thanks for getting in touch!

This is an issue in our chart’s where we haven’t cleared the chart property on the SChartAxis when removing it from it’s old chart.

I have added this as a bug to our backlog where a member of the development team will investigate further.

A work around solution would be to set the “chart” property on your “axis” variable to nil before adding it to the chart again.

Let me know if you have any questions.

Kind Regards,
Andrew Polkinghorn



axis.chart =nil;

between remove and add resolves the issue. Thanks!


This issue has been fixed in version 2.7.2.



SChartDiscontinuousDateTimeAxis with addExcludedRepeatedTimePeriod: method won’t get correct datarange


Hi Jiaren - sorry to hear about that. Could you create a new forum thread explaining your problem? Try to include as much information about your axis set up and what you’ve tried to debug the problem, we’ll try to take a look as soon as possible.

Jan Akerman