Issue with SChartCategoryAxis


I recently upgraded to version 2.2 of ShinobiCharts and am running into an issue with the dataRange of a SChartCategoryAxis.  It seems the dataRange property of the axis is now out of range of my current categories count and is allowing the user to pan past the top categories on the y-axis and go completely out of range.

In previous version (v2.1), I had the following output when the sChartRenderFinished: delegate is called.  All works well.

axisRange { 0.000000, 9.000000 }
defaultRange { 0.000000, 9.000000 }
dataRange { -0.500000, 10.500000 }

In new version (v2.2), I have the following output.  You can see that the dataRange is way out of bounds.  This version is not working as expected with the same data input

axisRange { 0.000000, 9.000000 }
defaultRange { 0.000000, 9.000000 }
dataRange { -0.500000, 3261.500000 }

I am inserting 11 total categories on the y-axis, but want to show only 9 with the user allowed to pan to see the remaining 2 categories.  I have tried setting various combinations of allowPanningOutOfDefaultRange and allowPanningOutOfMaxRange but no combination seems to work.  I think the issue is that the dataRange is out of bounds.

I’m initializing my graph as follows:

SChartNumberRange *r = [[SChartNumberRange alloc] initWithMinimum:[NSNumber numberWithInt:0] andMaximum:[NSNumber numberWithInt:9]];
        chart.yAxis = [[SChartCategoryAxis alloc] initWithRange:r];
        chart.yAxis.enableGestureZooming = NO;
        chart.yAxis.enableMomentumZooming = NO;
        chart.gestureDoubleTapEnabled = NO;

Is there a way to fix this?


I get the same thing here. Hopefully something that can be easily fixed.


I got a solution, at least for my case. In the sChartRenderFinisheddelegate method you should set again the defaultRange and axis range.

This is what I use:

- (void)sChartRenderFinished:(ShinobiChart *)chart {
 if (firstChartRender) {
firstChartRender = NO;
 NSDate *max = {my max date};
 NSDate *first = {my first date};
 SChartDateRange *r = [[SChartDateRangealloc] initWithDateMinimum:first andDateMaximum:max];
 chart.xAxis.defaultRange = r;
 NSDate *min = {my min date};
 [chart.xAxissetRangeWithMinimum:min andMaximum:max];


Has anyone had confirmation that this is a bug? I’m seeing the same thing — my dataRanges are being set to ridiculously high numbers, well outside the dataset I’ve provided.


Hi All,

Thanks for the feedback, we have had a look into this issue and it has been confirmed to be a bug with ShinobiCharts. We have since fixed this issue and plan to make it publicly available with the next minor release of ShinobiCharts (version 2.2.1).

Kind regards,

Daniel Allsop


Thanks for the update, Daniel. What’s the planned release date for ShinobiCharts 2.2.1?


Hi Tonyarnold,

There is no fixed release date for ShinobiCharts 2.2.1 as of this moment. However, we do expect it to be in the next few weeks or so.

Kind regards,

Daniel Allsop


Is there a proper/recommended workaround in the meantime? I have an app scheduled for submission next week, and this bug is a showstopper for me. Cassio’s suggestions above did not work for me.


Hi Tonyarnold,

The recommended work around is to use the isPanning delegate method and limit the default data range to prevent being able to pan too far. For example if the default range is 0 to 8 then in the delegate method you could restrict the panning outside of 0 to 10.

Kind regards,

Daniel Allsop


Hi Daniel — how would this work? Are you suggesting I call setDefaultRange:… inside the isPanning delegate method every time it’s called?


Hi all,

Just wanted to help out a little since there doesn’t seem to be a blanket workaround that’s been found yet. I stress that this is fixed now and will work again in our next release - but for now, here’s a little workaround that I hope will keep you all going in the meantime:

-(void)sChartRenderStarted:(ShinobiChart *)chart withFullRedraw:(BOOL)fullRedraw {
    [self restrictXAxisRangeOnChart: chart];    

-(void)restrictXAxisRangeOnChart:(ShinobiChart *)chart {
    double min = 5000., max = 10000.; // Restrict the axisRange to within these limits
    double newMin, newMax, span;
    BOOL limitAxisRange = NO; // Whether we need to set the range to limit it.
    SChartRange *xAxisRange = chart.xAxis.axisRange;
    newMin = [xAxisRange.minimum doubleValue];
    newMax = [xAxisRange.maximum doubleValue];
    span = newMax - newMin;
    if (newMin < min) {
        newMin = min;
        newMax = min + span; // Preserve zoom level
        limitAxisRange = YES;
    if (newMax > max) {
        newMax = max;
        newMin = ((newMax - span) > min)? // Preserve zoom level if possible
        (newMax - span):min;
        limitAxisRange = YES;
    if (limitAxisRange) {
        [chart.xAxis setRangeWithMinimum: @(newMin) andMaximum: @(newMax)];

This will check the range of your xAxis to make sure that it’s within your bounds (in this case 5k - 10k) at any time when the chart is about to render and, if necessary, alter the range such that it remains within these bounds. This should prevent any zooming or panning, or anything else from causing the axis to escape the set bounds.

Hope this helps!

Simon  :laughing:

EDIT: I should probably point out that you need to drop this into your chart’s delegate!