我无法在Google图表栏中生成不同的颜色。数据来自变量data.addRows([[${golLog}]]);
,我意识到该变量内部有一个数组。看来他只把两个条的第一个颜色扔了。
以下是用于理解的代码:
google.charts.load('current', {
'packages' : [ 'corechart','bar' ]
});
google.charts.setOnLoadCallback(golLog);
function golLog() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Qtd');
data.addColumn('number');
data.addRows([[${golLog}]]);
var options = {
chart: {
left:0,
top:40,
width:'100%',
height:'100%'
},
title: 'GOL',
legend: { position: 'none' },
theme: 'material',
fontSize: 20,
colors:['#fc1700','#212e84']
};
var chart = new
google.charts.Bar(document.getElementById('chart_golLog'));
chart.draw(data, google.charts.Bar.convertOptions(options));
}
<div id="chart_golLog"></div>