How to remove horizontal grid line in Google Column Chart?
Asked Answered
M

2

9

How can I remove the horizontal grid line in my google column chart? I tried some of the solutions but can't still remove it. Thanks.

function drawVisualization() {
    // Create and populate the data table.
    var data = google.visualization.arrayToDataTable([
        ['Year', 'Austria', 'Belgium', 'Czech Republic', 'Finland', 'France', 'Germany'],
        ['2003',  1336060,   3817614,       974066,       1104797,   6651824,  15727003],
        ['2004',  1538156,   3968305,       928875,       1151983,   5940129,  17356071],
        ['2005',  1576579,   4063225,       1063414,      1156441,   5714009,  16716049],
        ['2006',  1600652,   4604684,       940478,       1167979,   6190532,  18542843],
        ['2007',  1968113,   4013653,       1037079,      1207029,   6420270,  19564053],
        ['2008',  1901067,   6792087,       1037327,      1284795,   6240921,  19830493]
    ]);

    // Create and draw the visualization.
    new google.visualization.ColumnChart(document.getElementById('visualization')).
    draw(
        data,
        {
            title:"Yearly Coffee Consumption by Country",
            width:600, height:400,
            hAxis: {title: "Years", minorGridlines: { color: 'red' } }
        }
    );
}​
Miniaturize answered 28/10, 2013 at 5:16 Comment(0)
A
16

The horizontal grid lines are controlled by the vAxis.gridlines option. Set the vAxis.gridlines.color option to "transparent" to make them disappear:

vAxis: {
    gridlines: {
        color: 'transparent'
    }
}
Amling answered 28/10, 2013 at 5:54 Comment(3)
Thanks asgallant. It worked. But I don't get it why the vAxis option should used to make it transparent. I keep on using the hAxis option a while ago but it didn't work.Miniaturize
The API links the horizontal gridlines with the vAxis labels (every label has a major gridline, and the way it is set up, you actually set a count of gridlines to determine how many labels you will get). Also, you can have two y-axes in most charts, each with its own set of gridlines, which you may want to control separately, so it becomes necessary to put control under the vAxis option.Amling
You are a genius, sir!Righteousness
A
2

Something else worth trying for your chart options (if you don't want the lines there at all):

var options = {
    ...
    vAxis : {
        gridlines : {
            count : 0
        }
    }
};
Adopted answered 27/5, 2017 at 11:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.