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?
This worked for me. However, the y-axis labels will round when displaying small numbers, so if you are charting, say 1 or 2, the chart will display 0 twice. (See here: Force BarChart Y axis labels to be integers?)
For Swift 3.0 and Charts 3.0 you need to enable and set granularity for the axis.
Example:
You can try this one, it worked nicely for me
You just need to adjust the
NSNumberFormatter
...Example:
NSNumberFormatter
is a very powerful class, you can do much much more with it. :-)Swift4.2 ; Xcode 10.0 :