I'm using the fabulous iOS Charts library (https://github.com/danielgindi/ios-charts) and I'm having a hard time finding anything to support this behavior in the documentation. I'd like to force the y-axis to always display a range from 0-35. Currently, if I only have one data entry in at say (0, 9) the y-axis will display its range as 0-9. However when I add another entry at (1, 32) suddenly I can see the top of the graph at 35.
There are three methods that look promising (because they're related) but they aren't quite providing the type of behavior that I'm looking for.
1: Chart.setVisibleYRangeMaximum
(if only it were Minimum
...)
2: Chart.setVisibleXRangeMaximum
(useless again...)
3: Chart.setVisibleXRangeMinimum
(now where's your YRange
cousin?!)
So anyways, that's where I'm at. I've read documentation but to no avail. Help me SO?
For Charts 3 (tried on Charts 3.0.2), this works:
chartView.leftAxis.axisMinimum = 0
By default there is a rightAxis as well (at least for bar charts) and the grid won't be aligned if you don't also set:
chartView.rightAxis.axisMinimum = 0
Note: I wrote this as a comment initially but I think it should be an answer to be easier to find for people who end up here from Google.