Charts 谷歌图表-如何改变颜色的一列只有在ComboChart?
我不知道在使用ComboChart时如何更改特定列的颜色(在下面的示例中称为“这里的不同颜色”)?玩Charts 谷歌图表-如何改变颜色的一列只有在ComboChart?,charts,google-api,google-visualization,Charts,Google Api,Google Visualization,我不知道在使用ComboChart时如何更改特定列的颜色(在下面的示例中称为“这里的不同颜色”)?玩{role:'style'}并没有给我想要的结果 HTML: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
{role:'style'}
并没有给我想要的结果
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>
Google Visualization API Sample
</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {
packages: ['corechart']
});
</script>
<script type="text/javascript">
function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
['Month', 'Test', 'Avg.'],
['1', 165, 145],
['2', 135, 145],
['Different color here', 157, 145],
['4', 139, 145],
['5', 136, 145]
]);
// Create and draw the visualization.
var ac = new google.visualization.ComboChart(document.getElementById('visualization'));
ac.draw(data, {
title: 'TITLE',
width: 600,
height: 400,
vAxis: {
title: "AAA"
},
hAxis: {
title: "BBB"
},
seriesType: "bars",
series: {
0: {
color: "yellow"
},
1: {
type: "line",
color: "green"
},
},
});
}
google.setOnLoadCallback(drawVisualization);
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="visualization" style="width: 600px; height: 400px;"></div>
</body>
</html>
谷歌可视化API示例
load('visualization','1','{
软件包:['corechart']
});
函数drawVisualization(){
//创建并填充数据表。
var data=google.visualization.arrayToDataTable([
[“月”、“测试”、“平均值],
['1', 165, 145],
['2', 135, 145],
[“这里的颜色不同”,157,145],
['4', 139, 145],
['5', 136, 145]
]);
//创建并绘制可视化。
var ac=新的google.visualization.ComboChart(document.getElementById('visualization');
ac.draw(数据、{
标题:“标题”,
宽度:600,
身高:400,
言辞:{
标题:“AAA”
},
哈克斯:{
标题:“BBB”
},
序列类型:“条”,
系列:{
0: {
颜色:“黄色”
},
1: {
键入:“行”,
颜色:“绿色”
},
},
});
}
setOnLoadCallback(drawVisualization);
JSFIDDLE:
样式角色应遵循应用样式的系列
var data = google.visualization.arrayToDataTable([
['Month', 'Test', {role: 'style', type: 'string'}, 'Avg.'],
['1', 165, null, 145],
['2', 135, null, 145],
['Different color here', 157, 'magenta', 145],
['4', 139, null, 145],
['5', 136, null, 145]
]);
请参阅以下工作片段
谷歌可视化API示例
google.charts.load('current'{
软件包:['corechart']
});
函数drawVisualization(){
//创建并填充数据表。
var data=google.visualization.arrayToDataTable([
['Month','Test',{role:'style',type:'string'},'Avg.],
[1',165,null,145],
[2',135,null,145],
[“这里的不同颜色”,157,“洋红色”,145],
[4',139,null,145],
[5',136,空,145]
]);
//创建并绘制可视化。
var ac=新的google.visualization.ComboChart(document.getElementById('visualization');
ac.draw(数据、{
标题:“标题”,
宽度:600,
身高:400,
言辞:{
标题:“AAA”
},
哈克斯:{
标题:“BBB”
},
序列类型:“条”,
系列:{
0: {
颜色:“黄色”
},
1: {
键入:“行”,
颜色:“绿色”
},
},
});
}
google.charts.setOnLoadCallback(drawVisualization);
样式角色应遵循应用样式的系列
var data = google.visualization.arrayToDataTable([
['Month', 'Test', {role: 'style', type: 'string'}, 'Avg.'],
['1', 165, null, 145],
['2', 135, null, 145],
['Different color here', 157, 'magenta', 145],
['4', 139, null, 145],
['5', 136, null, 145]
]);
请参阅以下工作片段
谷歌可视化API示例
google.charts.load('current'{
软件包:['corechart']
});
函数drawVisualization(){
//创建并填充数据表。
var data=google.visualization.arrayToDataTable([
['Month','Test',{role:'style',type:'string'},'Avg.],
[1',165,null,145],
[2',135,null,145],
[“这里的不同颜色”,157,“洋红色”,145],
[4',139,null,145],
[5',136,空,145]
]);
//创建并绘制可视化。
var ac=新的google.visualization.ComboChart(document.getElementById('visualization');
ac.draw(数据、{
标题:“标题”,
宽度:600,
身高:400,
言辞:{
标题:“AAA”
},
哈克斯:{
标题:“BBB”
},
序列类型:“条”,
系列:{
0: {
颜色:“黄色”
},
1: {
键入:“行”,
颜色:“绿色”
},
},
});
}
google.charts.setOnLoadCallback(drawVisualization);