Eric
Eric

Reputation: 672

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?

Upvotes: 4

Views: 7002

Answers (3)

Krunal
Krunal

Reputation: 79636

// Set grid background color
barChartView.gridBackgroundColor = UIColor.orange

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

Upvotes: 2

Eric Hodgins
Eric Hodgins

Reputation: 554

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

barChartView.drawGridBackgroundEnabled = true

Upvotes: 8

Japes
Japes

Reputation: 433

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()

Upvotes: 10

Related Questions