BEMSimpleLineGraph icon indicating copy to clipboard operation
BEMSimpleLineGraph copied to clipboard

Rounding y-axis values

Open sahil263 opened this issue 10 years ago • 1 comments

I am using the following delegate methods for setting the base value and incremental value.

- (CGFloat)baseValueForYAxisOnLineGraph:(BEMSimpleLineGraphView *)graph{

    return [graph.calculateMinimumPointValue intValue];

}
- (CGFloat)incrementValueForYAxisOnLineGraph:(BEMSimpleLineGraphView *)graph{

int num = [graph.calculatePointValueAverage intValue] - [graph.calculateMinimumPointValue intValue]; // your number
    int len = log10(num);
    float div = pow(10, len);
    int rounded = ceil(num / div) * div;

    return rounded;

}

Using the above code, I get the following output:

screen shot 2015-06-12 at 11 28 28 am

Where as, I want the Y-Axis value to be as follows. Because the data displayed on the chart is dynamic:

53 comes out as 60.. 197 comes out as 200.. 4937 comes out as 5000..

sahil263 avatar Jun 12 '15 06:06 sahil263

Problems come bigger if you have data like from 0.112 to 1.0112 then y-axis labels are rounded to 0 and 1 and you have problem with y-axis labels(they are only 0 and 1). And the problem grow bigger if you turn pop up on to be always on screen, text on pop up is always 0. As work around for popups i see the adding suffix with needed number as text after dot. If we have 0 we are adding ".112" like a suffix string

RomaSafin avatar May 17 '16 16:05 RomaSafin