var chartdataentries = [ChartDataEntry]()
for i in 0..<days.count{
chartdataentries.append(ChartDataEntry(x: Double(data[i]), y: 1.0, data: data[i]))
}
let set = PieChartDataSet(entries: chartdataentries)
set.sliceSpace = 1
for i in 0..<data.count{
if (chartdataentries[i].x >= 30){
set.colors = setcolor()
}
}
let data = PieChartData(dataSet: set)
data.setDrawValues(false)
pieChart.data = data
}
如果条件为真,我尝试为特定切片设置颜色,但它设置了整个图表的颜色
如果条件为真,则设置特定颜色.......
1条答案
按热度按时间tp5buhyn1#
为颜色创建一个数组,如
而且状况良好
然后设置图表的颜色
确保
colors
计数必须等于数据计数。