1
我已將我的值存儲在覈心數據中並在BarChart中顯示。 我的類別金額在8.5和420.10。圖表3.0 - 無法在BarChart中顯示小數 - iOS Swift
但條形圖中的顯示爲8和420. 應該如何設置十進制值?
var dataEntries: [BarChartDataEntry] = []
for i in 0..<dataPoints.count {
let value = values[i] as Double
print("value=\(value)")
let dataEntry = BarChartDataEntry(x: Double(i), y:value)
dataEntries.append(dataEntry)
}
let chartDataSet = BarChartDataSet(values: dataEntries, label: "Total Amount")
chartDataSet.colors = [.red, .yellow, .green, .blue, .brown]
chartDataSet.colors = ChartColorTemplates.joyful()
barChartView.xAxis.labelPosition = .bottom
barChartView.chartDescription?.text = ""
barChartView.xAxis.drawGridLinesEnabled = false
barChartView.leftAxis.drawLabelsEnabled = false
barChartView.leftAxis.granularityEnabled = true
let chartData = BarChartData()
chartData.addDataSet(chartDataSet)
barChartView.data = chartData
錯誤:不能指定'NumberFormatter'類型的值來鍵入'IAxisValueFormatter' – user831098
你使用Swift 3嗎? – Tj3n
是的,我正在使用Swift3 – user831098