Charts: How to remove background gridlines from Bar Chart

Created on 28 Nov 2015  路  9Comments  路  Source: danielgindi/Charts

I am struggling to remove the background gridlines and X and Y axis from my Bar Graph/Chart. Can you help me with that.

Most helpful comment

I believe what you are looking for is:

- drawAxisLineEnabled
- drawGridLinesEnabled

If you're using Objective-C just set these on the desired axis:

yAxis.drawAxisLineEnabled = NO;
yAxis.drawGridLinesEnabled = NO;

or if you're using Swift:

yAxis.drawAxisLineEnabled = false
yAxis.drawGridLinesEnabled = false

Hope it helps.

All 9 comments

I believe what you are looking for is:

- drawAxisLineEnabled
- drawGridLinesEnabled

If you're using Objective-C just set these on the desired axis:

yAxis.drawAxisLineEnabled = NO;
yAxis.drawGridLinesEnabled = NO;

or if you're using Swift:

yAxis.drawAxisLineEnabled = false
yAxis.drawGridLinesEnabled = false

Hope it helps.

thanks

Awesome Thanks

How to change grid line color?

Thanks

what about javafx ? plz

I'm using Swift 4 and I can't get rid of any of the grid lines.

I'm creating a LineChartView and customizing it as so:

let lineChart: LineChartView = {
let chart = LineChartView()
chart.leftAxis.drawAxisLineEnabled = false
chart.leftAxis.drawGridLinesEnabled = false
chart.leftAxis.gridColor = NSUIColor.clear
chart.xAxis.drawGridLinesEnabled = false
chart.backgroundColor = .white
chart.translatesAutoresizingMaskIntoConstraints = false
return chart
}

The chart the appears looks exactly like the default line chart without any customization.

Here is how I did that

lineChart.leftAxis.enabled = false
lineChart.rightAxis.enabled = false
lineChart.xAxis.enabled = false

It seems you can't directly disable grid lines in swift 4. Workaround is just setting the grid color to clear so they won't be visible

lineChart.xAxis.gridColor = .clear
lineChart.leftAxis.gridColor = .clear
lineChart.rightAxis.gridColor = .clear
Was this page helpful?
0 / 5 - 0 ratings

Related issues

brytnvmg picture brytnvmg  路  4Comments

Shunshine07 picture Shunshine07  路  3Comments

coop44483 picture coop44483  路  3Comments

valeIT picture valeIT  路  3Comments

sjdevlin picture sjdevlin  路  3Comments