You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this is my setting for bar chart :
func setBarChartData(chartData : BarChartData, key:[String]){
// Y - Axis Setup
let yaxis = barChartView.leftAxis
yaxis.spaceTop = 0.35
yaxis.axisMinimum = 0
yaxis.drawGridLinesEnabled = false
and this is method that calling setBarChartData:
func getBarData(data : NSMutableDictionary) -> BarChartData{
let key = data.value(forKey: "key") as! [String]
let current = data.value(forKey: "current") as! NSMutableDictionary
let prev = data.value(forKey: "previous") as! NSMutableDictionary
let prevTwo = data.value(forKey: "previous_two") as! NSMutableDictionary
let prevThree = data.value(forKey: "previous_three") as! NSMutableDictionary
let currentRevenue = current.value(forKey: "revenue") as! [Int]
let prevRevenue = prev.value(forKey: "revenue") as! [Int]
let prevTwoRevenue = prevTwo.value(forKey: "revenue") as! [Int]
let prevThreeRevenue = prevThree.value(forKey: "revenue") as! [Int]
var currentEntry = [BarChartDataEntry]()
var prevEntry = [BarChartDataEntry]()
var prevTwoEntry = [BarChartDataEntry]()
var prevThreeEntry = [BarChartDataEntry]()
for i in 0..<key.count{
let current = BarChartDataEntry(x:Double(i), y:Double(currentRevenue[i]))
let prev = BarChartDataEntry(x:Double(i), y:Double(prevRevenue[i]))
let prevTwo = BarChartDataEntry(x:Double(i), y:Double(prevTwoRevenue[i]))
let prevThree = BarChartDataEntry(x:Double(i), y:Double(prevThreeRevenue[i]))
currentEntry.append(current)
prevEntry.append(prev)
prevTwoEntry.append(prevTwo)
prevThreeEntry.append( prevThree)
}
let dataSet1 = BarChartDataSet(values: prevThreeEntry, label: "2015")
dataSet1.setColor(NSUIColor.red)
dataSet1.drawValuesEnabled = false
let dataSet2 = BarChartDataSet(values: prevTwoEntry, label: "2016")
dataSet2.setColor(NSUIColor.green)
dataSet2.drawValuesEnabled = false
let dataSet3 = BarChartDataSet(values: prevEntry, label: "2017")
dataSet3.setColor(NSUIColor.blue)
dataSet3.drawValuesEnabled = false
let dataSet4 = BarChartDataSet(values: currentEntry, label: "2018")
dataSet4.setColor(NSUIColor.orange)
dataSet4.drawValuesEnabled = false
var dataSets : [BarChartDataSet] = []
if isShowCurrent{
dataSets.append(dataSet4)
}
if isShowPrev{
dataSets.append(dataSet3)
}
if isShowPrev2{
dataSets.append(dataSet2)
}
if isShowPrev3{
dataSets.append(dataSet1)
}
return dataSets.count == 1 ? BarChartData(dataSet: dataSets.first) : BarChartData(dataSets: dataSets)
// return BarChartData(dataSet: dataSets.first)
}
The text was updated successfully, but these errors were encountered:
this is my setting for bar chart :
func setBarChartData(chartData : BarChartData, key:[String]){
// Y - Axis Setup
let yaxis = barChartView.leftAxis
yaxis.spaceTop = 0.35
yaxis.axisMinimum = 0
yaxis.drawGridLinesEnabled = false
}
and this is method that calling setBarChartData:
func getBarData(data : NSMutableDictionary) -> BarChartData{
let key = data.value(forKey: "key") as! [String]
let current = data.value(forKey: "current") as! NSMutableDictionary
let prev = data.value(forKey: "previous") as! NSMutableDictionary
let prevTwo = data.value(forKey: "previous_two") as! NSMutableDictionary
let prevThree = data.value(forKey: "previous_three") as! NSMutableDictionary
// return BarChartData(dataSet: dataSets.first)
}
The text was updated successfully, but these errors were encountered: