11

我正在尝试使用 Google Charts 在我的图表背景中设置网格线的颜色。

我有这个代码来设置图表的选项:

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

但是,我不知道如何使用配置选项页面hAxis.gridlines.color中出现的代码中的选项。

如果我简单地说hAxis.gridlines.color,它会在控制台中出现错误:

Uncaught SyntaxError: Unexpected token 。

使用包含句点的选项的正确语法是什么?

4

2 回答 2

11

这是您作为draw()的第二个参数传递的对象文字,所以我想它应该是:

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

于 2012-06-06T15:29:33.780 回答
5

gridlineColor: '#f0f'也可以,这就是你的做法。

{vAxis: {gridlineColor: '#f0f'}}
于 2018-10-12T12:11:06.180 回答