I'm building a chart using iOS-charts
I'm trying to convert the floats into int, but iOS-charts only allows for Floats in the data entry:
let result = ChartDataEntry(value: Float(month), xIndex: i)
Does anyone know the method for making sure only ints are used?
For Swift 3.0 and Charts 3.0 you need to enable and set granularity for the axis.
Example:
barChart.leftAxis.granularityEnabled = true
barChart.leftAxis.granularity = 1.0
You just need to adjust the NSNumberFormatter
...
Example:
yAxis.valueFormatter = NSNumberFormatter()
yAxis.valueFormatter.minimumFractionDigits = 0
NSNumberFormatter
is a very powerful class, you can do much much more with it. :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With