How to reverse order on yAxis?



Does anyone know how I can make the yAxis in reverse order so that its goes from 300 to 0 instead of 0 to 300?




Hi, I’m not sure there is an easy way to do it. Only way I see (but I don’t have a deep knowledge of Shinobicharts yet)  could be to make all your data negative (so you have from -300 to 0), then customize the label formatter subclassing it and showing the labels in their absolute value (so that -300 is shown as 300). Then if you use tooltips customize it too and show there also the absolute values.



Thanks for the response Paolo! Very clever idea, I think that might just work. Thanks for your time :slight_smile:




My pleasure

Let me know :slight_smile:


It did work! Thanks again :slight_smile:


revg, can you post the code you used to override the label formatter? :blush:


Sorry I took so long to reply. I haven’t been here in a while. Here is the custom label formatter source and how to use it. So basically I just pass in my data for the series as negative values and the custom formatter just multiplies all values by -1 before displaying them so that they appear positive. This allows us to have a graph that can start at a higher number at the bottom of the chart and decrease to a lower number as we go up to the top in the chart.

//usage (not I am not using ARC)
SChartNumberAxis *yAxis = [[SChartNumberAxis alloc] init];
yAxis.enableGesturePanning = YES;
yAxis.enableGestureZooming = YES;
yAxis.enableMomentumPanning = YES;
yAxis.enableMomentumZooming = YES;
yAxis.rangePaddingHigh = [NSNumber numberWithInt:10];
yAxis.rangePaddingLow = [NSNumber numberWithInt:25]; = [UIColor lightGrayColor]; = YES;

yAxis.labelFormatter = [[[CustomLabelFormatter alloc] init] autorelease];

// CustomLabelFormatter.h
// apprankchecker

#import <ShinobiCharts/ShinobiChart.h>

@interface CustomLabelFormatter : SChartTickLabelFormatter


// CustomLabelFormatter.m
// apprankchecker

#import "CustomLabelFormatter.h"

@implementation CustomLabelFormatter

-(NSString *)stringForObjectValue:(id)obj onAxis:(SChartAxis *)axis{
    return [NSString stringWithFormat:@"%d", [obj intValue]*-1];