BEMSimpleLineGraph
BEMSimpleLineGraph copied to clipboard
Set custom y-axis range
Is it even possible to set the y range?
I have set baseValueForYAxisOnLineGraph and incrementValueForYAxisOnLineGraph, after looking into the code I found out that autoScaleYAxis has to be activated too, so I did. But now it seems to ignore numberOfYAxisLabelsOnLineGraph, also the layout seems to be a bit off and the labels disappear.
Is there a way to set the y-axis labels to 0,10,20,..,100 no matter what the values are?
Here is an example, exactly the same values and configuration. The only thing that changes is autoScaleYAxis.
autoScaleYAxis=NO:
autoScaleYAxis=YES:
Tested on iPhone 6+ and Simulator for iPhone 6, iOS 8.4
Hi @dkk,
As mentioned in the documentation, implementing baseValueForYAxisOnLineGraph:
and incrementValueForYAxisOnLineGraph:
will indeed ignore numberOfYAxisLabelsOnLineGraph
.
/** Starting value to begin drawing Y-Axis labels MUST ALSO IMPLEMENT incrementValueForYAxisOnLineGraph FOR THIS TO TAKE EFFECT
@discussion This allows you to finally hone the granularity of the data label. Instead of drawing values like 11.24,
you can lock these values to draw 11.20 to make it more user friendly. When this is set, `numberOfYAxisLabelsOnLineGraph` is ignored.
@param graph The graph object which is requesting the number of gaps between the labels.
@return The base value to draw the first Y-Axis label */
- (CGFloat)baseValueForYAxisOnLineGraph:(BEMSimpleLineGraphView *)graph;
You should be able to set the Y-Axis labels to 0, 10, 20, ... 100 using these two delegate methods.
The fact that the labels are not displayed is a serious bug though. I'll try to work on it tonight. Thank you for your contribution!
Is this bug fixed? I wanted to set the Y-Axis labels to be 0,20,40,60,80,100, and I set the delegate method baseValueForYAxisOnLineGraph: return 0 and incrementValueForYAxisOnLineGraph: return 20 but Y-Axis sometimes display normally but sometimes not, as the values changes