ios diagrams have been updated to a basic protocol approach to display various types of labels like xAxis, yAxis, etc. Thus, to achieve the desired results, you need to implement the protocol IValueFormatter. I created a class for the same, so I use it directly, as shown below, and you can achieve the desired results.
Create a class with a name DigitValueFormatterand assign it to an object LineChartDataaslineChartData.setValueFormatter(DigitValueFormatter())
import Foundation
import Charts
class DigitValueFormatter : NSObject, IValueFormatter {
func stringForValue(_ value: Double,
entry: ChartDataEntry,
dataSetIndex: Int,
viewPortHandler: ViewPortHandler?) -> String {
let valueWithoutDecimalPart = String(format: "%.0f", value)
return "\(valueWithoutDecimalPart)"
}
}
source
share