Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Chart Setting Gridline Color

I'm trying to set the color of the gridlines in the background of my Graph using Google Charts.

I've got this code for setting the options of the chart:

ac.draw(activityData, {
    title : 'Monthly Coffee Production by Country',
    isStacked: true,
    width: 600,
    height: 400,
    fontSize: 0,
    backgroundColor: '#1E4D6B',
        hAxis.gridlines.color: '#1E4D6B'
});

However, I don't know how to use the options like hAxis.gridlines.color within my code that appear in the configuration options page.

If I simply put hAxis.gridlines.color, it comes up with an error in the console of:

Uncaught SyntaxError: Unexpected token .

What is the correct syntax to make use of the options that contain periods?

like image 882
Luke Avatar asked Jun 06 '12 15:06

Luke


People also ask

How do you change the color of a chart on Google?

Select a chart and then on the right, open the STYLE tab. Data coloring options appear in the Color by section.

How do I change the color of text in a Google chart?

Changing the Color You can change the color of the lines that connect data points in Google Charts in two subtly different ways: with the colors option to change the chart palette, or with the series option to specify the color for particular series. In the following chart, we set the color of each series explicitly.

How do I change the theme on a Google chart?

To apply a preset theme, select Format > Theme and choose an option, or to create a custom theme, select Customize in the top right.


2 Answers

It's an object litteral you're passing as second parameter of draw(), so I guess it should instead be :

hAxis: {gridlines: {color: '#1E4D6B'}}

like image 109
Romain Valeri Avatar answered Sep 22 '22 13:09

Romain Valeri


gridlineColor: '#f0f' also works, and this is how you do it.

{vAxis: {gridlineColor: '#f0f'}}
like image 43
alexeevyci Avatar answered Sep 23 '22 13:09

alexeevyci