這裏我使用Charts Library 對於水平條形圖, 我已經設置代碼如下水平條形圖:如何添加X-酒吧軸標籤
var dataEntries: [BarChartDataEntry] = []
for i in 0..<dataPoints.count {
let dataEntry = BarChartDataEntry(x: Double(i), yValues: [values[i]])
dataEntries.append(dataEntry)
}
let chartDataSet = BarChartDataSet(values: dataEntries, label: "Units Sold")
let chartData = BarChartData(dataSet: chartDataSet)
barChartView.data = chartData
//Horizontal
HbarChartView.animate(yAxisDuration: 0.2)
HbarChartView.data = chartData
HbarChartView.xAxis.labelPosition = .bottom
HbarChartView.xAxis.labelTextColor = UIColor.blue
HbarChartView.animate(xAxisDuration: 2.0, yAxisDuration: 2.0, easingOption: .easeInBounce)
HbarChartView.rightAxis.addLimitLine(ll)
HbarChartView.setVisibleYRange(minYRange: 0, maxYRange: 10, axis: .left)
x軸數據顯示爲藍色。
我想在X軸上設置字符串。我怎樣才能做到這一點?
任何幫助表示讚賞
否則, 推薦任何其他圖表庫單槓包括酒吧價值和動畫
添加一個鏈接到圖表庫 – muescha
鏈接: ** https://github.com/danielgindi/Charts** 我從那裏下載圖表庫 –
我認爲你需要編寫自己的[IAxisValueFormatter](https://github.com/danielgindi/Charts/search? utf8 =%E2%9C%93&q = IAxisValueFormatter) – muescha