2

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?

Connor Neville
  • 7,291
  • 4
  • 28
  • 44

2 Answers2

7

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.

Sulthan
  • 128,090
  • 22
  • 218
  • 270
  • some color is getting mixed into the color. As I am setting it as yellow and it is giving me parrot-green color – Shubham Ojha Apr 20 '20 at 04:36
  • @sulthan as you can see I am setting higlightedColor but its not showing on tap of touch bar var set1: BarChartDataSet! = nil set1 = BarChartDataSet(entries: yVals, label: title) set1.drawValuesEnabled = false set1.highlightColor = AppColors.themeBlue.withAlphaComponent(1.0) set1.highlightAlpha = 1.0 – jayant rawat Nov 25 '21 at 12:06
1

You can change highlightColor and highlightAlpha on the chart data set.

kianoosh
  • 610
  • 6
  • 22