iOS Charts ValueFormatter

后端 未结 4 1202
天命终不由人
天命终不由人 2021-02-15 19:04

I am using iOS charts plugin (line chart) and wish to style the chart values (the number above each point) to a decimal number.

The value is a double, but charts by defa

4条回答
  •  日久生厌
    2021-02-15 19:31

    This worked for me:

    Swift 5

    let valFormatter = NumberFormatter()
    valFormatter.numberStyle = .currency
    valFormatter.maximumFractionDigits = 2
    valFormatter.currencySymbol = "$"
    
    lineChartPrice.leftAxis.valueFormatter = DefaultAxisValueFormatter(formatter: valFormatter)
    

提交回复
热议问题