Ios-charts background color

Hi, I need to change the background color of my iOS chart.

I tried:

barChartView.backgroundColor = UIColor.redcolor()

But he changed the color around my bargraph, not the color inside, i.e. behind the vertical stripes.

Any idea?

+4
source share
3 answers

barChartView.backgroundColor refers to a UIView from which your BarChartView is a preview. You need to turn to the base class of BarChart itself to change the properties of bars or grids behind bars. To change the color of the space behind the bars, try:

barChartView.gridBackgroundColor = UIColor.redcolor()
+7
source

If Japes responding still does not work, make sure it is turned on.

barChartView.drawGridBackgroundEnabled = true
+4
source
// Set grid background color
barChartView.gridBackgroundColor = UIColor.orange

// It is required to enable 'drawGridBackgroundColor' to see effect of gridBackground color 
barChartView.drawGridBackgroundEnabled = true
0
source

Source: https://habr.com/ru/post/1609619/


All Articles