Updating axis range dynamically?


#1

Here is the code I’m trying,

//Will get all the y-axis's here....

NSArray *allYAxes = [_performanceDetailsChartallYAxes];

    [allYAxes enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        SChartAxis *currentAxis = obj;
        NSLog(@"%@",currentAxis.title);
        if ([currentAxis.titlecaseInsensitiveCompare:GROWTH] == NSOrderedSame) {
            NSArray *growth = [totalSalesGrowthPercent allValues];
            growth = [growth sortedArrayUsingSelector:@selector(compare:)];
            float maxGrowth = [[growth objectAtIndex:(growth.count/2-1)] floatValue];
            float minGrowth = [[growth objectAtIndex:0] floatValue];
//Trying to update axis range to new values...

            [currentAxis setRangeWithMinimum:[NSNumber numberWithFloat:minGrowth] andMaximum:[NSNumbernumberWithFloat:maxGrowth] withAnimation:YES];
//This returns YES, but values wont update in graph !
        }
 
        elseif ([currentAxis.titlecaseInsensitiveCompare:@"UNITS"]== NSOrderedSame||[currentAxis.titlecaseInsensitiveCompare:@"DOLLARS"]==NSOrderedSame){
            NSArray *sales = [totalSalesData allValues];
            sales = [sales sortedArrayUsingSelector:@selector(compare:)];
            int maxSales = [[sales lastObject] intValue];
            if (maxSales != 0);
            else maxSales = 100;
            [currentAxis setRangeWithMinimum:[NSNumber numberWithFloat:0.f] andMaximum:[NSNumber numberWithFloat:maxSales]];
//Returns success, but range doesn't update in graph !

        }
        axisConfigured = YES;
    }];