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 obviously a problem with my setup. Using the same code in the iOSChartsDemo project works as you would expect. But in my project it results in the bars being red and the legend being turquoise.
Really sorry waisting peoples time with this issue, but I don't see an obvious fix.
heightChart.noDataText = "You need to provide data for the chart."
heightChart.descriptionText = ""
var dataEntries: [BarChartDataEntry] = []
for i in 0..<dataPoints.count {
let dataEntry = BarChartDataEntry(value: values[i], xIndex: i)
dataEntries.append(dataEntry)
}
let chartDataSet = BarChartDataSet(yVals: dataEntries, label: "Units Sold")
let chartData = BarChartData(xVals: months, dataSet: chartDataSet)
heightChart.data = chartData
chartDataSet.colors = [UIColor(red: 230/255, green: 0/255, blue: 0/255, alpha: 1)]
heightChart.xAxis.labelPosition = .Bottom
heightChart.backgroundColor = UIColor.clearColor()
heightChart.animate(xAxisDuration: 2.0, yAxisDuration: 2.0, easingOption: .EaseInBounce)
The text was updated successfully, but these errors were encountered:
I guess you need to put heightChart.data = chartData at the last line. or call notifyDataSetChanged
It's a limitation that you have to first configure chart view's property, and then setup the data set, and the call heightChart.data = chartData. Otherwise some calculation will be wrong. Or you remember to call notifyDataSetChanged.
computeLegend is called in notifyDataSetChanged, and notifyDataSetChanged is called once you call chart data setter. notifyDataSetChanged is a very important func, if you changed anything that needs to be recalculated.
Take a look at notifyDataSetChanged and related functions will help you avoid some strange issue :)
This is obviously a problem with my setup. Using the same code in the iOSChartsDemo project works as you would expect. But in my project it results in the bars being red and the legend being turquoise.
Really sorry waisting peoples time with this issue, but I don't see an obvious fix.
The text was updated successfully, but these errors were encountered: