简体   繁体   English

条形图与新的ios-charts框架新版本

[英]Bar chart with new ios-charts framework new release

With the new release on ios-charts, some functions have changed, and now i am unable to put the Xvals (for example, each month) under each value. 随着ios-chart上的新版本,一些功能已经改变,现在我无法将Xvals(例如,每个月)放在每个值下。 Anyone could help me? 有人可以帮帮我吗?

How would u update this code with the new release? 您将如何使用新版本更新此代码?

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

} }

If you are talking about the v3 release, you need to take a look at ChartsDemo how to use it. 如果您正在讨论v3版本,则需要查看ChartsDemo如何使用它。 v3 has redesigned the x axis to support date-like axis, so some functions are changed. v3重新设计了x轴以支持类似日期的轴,因此某些功能已更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM