随着ios-chart上的新版本,一些功能已经改变,现在我无法将Xvals(例如,每个月)放在每个值下。有人可以帮帮我吗?
您如何使用新版本更新此代码?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
let unitsSold = [20.0, 4.0, 6.0, 3.0, 12.0, 16.0]
setChart(months, values: unitsSold)
}
func setChart(dataPoints: [String], values: [Double]) {
var dataEntries: [ChartDataEntry] = []
for i in 0..<dataPoints.count {
let dataEntry = ChartDataEntry(value: values[i], xIndex: i)
dataEntries.append(dataEntry)
}
let chartDataSet = BarChartDataSet(yVals: dataEntries, label: "Units Sold")
let chartData = BarChartData(xVals: dataPoints, dataSet: chartDataSet)
horChart.data = chartData
}
答案 0 :(得分:0)
如果您正在讨论v3版本,则需要查看ChartsDemo如何使用它。 v3重新设计了x轴以支持类似日期的轴,因此某些功能会发生变化。