Stacked bar chart with charts in Swift

拜拜、爱过 提交于 2019-12-04 18:54:58

prepare BarchartDataEntry with two values in yAxis like

let months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]

let unitsSold = [20.0, 4.0, 6.0, 3.0, 12.0, 16.0, 4.0, 18.0, 2.0, 4.0, 5.0, 4.0]

let unitsBought = [10.0, 14.0, 60.0, 13.0, 2.0, 1.0, 5.0, 1.0, 12.0, 14.0, 15.0, 14.0]

let dataEntry = BarChartDataEntry(x: Double(i), yValues:  [self.unitsSold[i],self.unitsBought[i]], label: "groupChart")


 var dataEntries: [BarChartDataEntry] = []
 for i in 0..<self.months.count {
            let dataEntry = BarChartDataEntry(x: Double(i) , y: self.unitsSold[i])
            dataEntries.append(dataEntry)
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!