我正在尝试添加不同的颜色条,但是当我在选项中使用colors
时,似乎是所有条形图的第一个选项为红色。有帮助吗?我正在使用datatable
请找到以下代码:
graphData = data;
var arr = Object.keys(graphData).map(function (k) { return graphData[k] });
var tdata = new google.visualization.DataTable();
tdata.addColumn('string', 'Testing');
tdata.addColumn('number', 'Amount');
var col1 = Object.keys(graphData[0])[0];
col1 = col1.replace("_", " ");
var col2 = Object.keys(graphData[0])[1];
col2 = col2.replace("_", " ");
var col3 = Object.keys(graphData[0])[2];
col3 = col3.replace("_", " ");
if (col3 == "TM Automation") {
col3 = col3.replace("Auto", "T")
}
tdata.addRow([col1, arr[0].Manual])
tdata.addRow([col2, arr[0].OCB_Auto]);
tdata.addRow([col3, arr[0].Amount]);
options = {
fontSize: 12,
height: 430,
width: 380,
chartArea: { left: "25%", top: "20%", right: "5%", bottom: "10%" },
title: 'Project',
pieSliceText: 'value',
colors: ['red', 'green', 'blue'],
'is3D': true
};
var chart = new google.visualization.ColumnChart(document.getElementById('drilldown_div'));
chart.draw(tdata, options);
return false;