Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ios-charts background color

Hi would like to change the background color of my iOS-chart.

I tried:

barChartView.backgroundColor = UIColor.redcolor()

But it changed the color around my bargraph, not the color inside, ie. behind the vertical bars.

Any Idea?

like image 527
Eric Avatar asked Nov 29 '22 23:11

Eric


2 Answers

barChartView.backgroundColor references the UIView of which your BarChartView is a subview. You need to reference the base class of the BarChart itself to change the properties of the bars or the grid behind the bars. To change the color of the space behind the bars try:

barChartView.gridBackgroundColor = UIColor.redcolor()
like image 159
Japes Avatar answered Dec 10 '22 16:12

Japes


If Japes answer still does not work, make sure it's enabled.

barChartView.drawGridBackgroundEnabled = true
like image 27
Eric Hodgins Avatar answered Dec 10 '22 14:12

Eric Hodgins