In ios diagrams, the colors of the bars are set in an array. For example, if your dataset is called barChartDataset, you should set the colors as follows
barChartDataset.colors = [UIColor.red,UIColor.orange,UIColor.green,UIColor.black,UIColor.blue]
Bars will have these colors in this order and will be repeated. So if you have 10 bars, you will have 2 red bars, etc.
. .
func setColor(value: Double) -> UIColor{
if(value < 30){
return UIColor.red
}
else if(value <= 70 && value >= 30){
return UIColor.orange
}
else if(value > 70){
return UIColor.green
}
else {
return UIColor.black
}
}
, ,
barChartDataset.colors = [setColor(barOneValue),setColor(barTwoValue),setColor(barThreeValue),setColor(barFourValue),setColor(barFiveValue)]
, !