Attributes of text above specific bar with ios-charts Attributes of text above specific bar with ios-charts swift swift

Attributes of text above specific bar with ios-charts


To set your own colors/font you can use properties valueColors and 'valueFont' of BarChartDataSet class

So it'll be something like this

...var valueColors = [UIColor]()// dataEntries and barChartDataSetvar dataEntries = [ChartDataEntry]()for i in 0..<dataPoints.count{    let dataEntry = BarChartDataEntry(value: values[i], xIndex: i)    dataEntries.append(dataEntry)    if values[i] < 0 {        valueColors.append(UIColor.redColor())    }    else {        valueColors.append(UIColor.greenColor())    }}let barChartDataSet = BarChartDataSet(yVals: dataEntries, label: "")barChartDataSet.colors = colorsbarChartDataSet.valueColors = valueColorsbarChartDataSet.valueFont = *font you want*


If you want to change the text attributes of labels below bars you can use:

barChartView.xAxis.labelFont = UIFont.systemFont(ofSize: 5)

barChartView.xAxis.labelTextColor = UIColor.red