如何更改Google图表中列的颜色。我有drawGraph
函数:
function drawGraph(){
var data = new google.visualization.DataTable();
data.addColumn('date', 'Date');
data.addColumn('number', 'House 1')
data.addColumn('number', 'House 2')
data.addColumn('number', 'House 3')
data.addColumn('number', 'House 4')
data.addRows([
[new Date(2016, 01, 20),
180,
150,
186,
176,
],
[new Date(2016, 01, 19),
100,
150,
200,
175,
],
[new Date(2016, 01, 11),
10,
11,
20,
17,
],
[new Date(2016, 01, 07),
55,
51,
123,
100,
],
])
var options = {
title: 'House Points',
hAxis: {
title: 'Date'
},
vAxis: {
title: 'Points'
}
}
var material = new google.charts.Bar(document.getElementById('edhp_housepoints'));
material.draw(data, options);
}
我想为House 1到4设置颜色,我该怎么做?
我尝试过一些东西,但没有一个能奏效。
答案 0 :(得分:0)
每列的颜色可以在选项哈希中设置,如下所示:
var options = {
title: 'House Points',
hAxis: {
title: 'Date'
},
vAxis: {
title: 'Points'
},
colors: [
"#f0c514",
"#eb7f25",
"#eb4b33",
"#22b05a"
]
}