Search code examples
iosswiftdelegatesios-charts

Swift ios-charts Set Bar Color on Highlight


Within the ios-charts delegate method:

@objc func chartValueSelected(chartView: ChartViewBase, entry: ChartDataEntry, dataSetIndex: Int, highlight: ChartHighlight) { }

I would like to change the color of the bar that was selected. Is this possible?


Solution

  • You can change the color for highlights using:

    highlightColor
    

    on the chart data set.

    The problem with ios-charts is that they don't have a good documentation and they link only to the Android documentation and some of the variables/methods are not very programmer friendly because they were translated from the Android version and don't really follow Swift naming conventions.

    If you are looking for something, just open the source code for the given chart or its renderer.