我已經使用了盒子裏的所有技巧。閱讀完所有幫助文章後,我發現我認爲這段代碼實際上應該可以工作。但它從不爲我的酒吧彩色編碼。我究竟做錯了什麼?谷歌圖表顏色個別酒吧
google.charts.load('current', {
packages: ['corechart', 'bar']
});
google.charts.setOnLoadCallback(drawDualX);
function drawDualX() {
var data = google.visualization.arrayToDataTable([
['Date', 'Elevation', {
role: 'style'
}],
['2016-08-06T08:09:47Z', 1977.4, 'color: yellow'],
['2016-08-06T08:13:29Z', 1981, 'color: green'],
['2016-08-06T08:14:08Z', 1986.9, 'color: yellow'],
['2016-08-06T08:14:22Z', 1988.9, 'color: green'],
['2016-08-06T08:14:25Z', 1989.2, 'color: green'],
['2016-08-06T08:14:29Z', 1989.7, 'color: yellow'],
['2016-08-06T08:14:32Z', 1990.1, 'color: green'],
]);
var options = {
chart: {
title: 'Elevation Chart',
},
bars: 'vertical'
};
\t
\t
var material = new google.charts.Bar(document.getElementById('chart_div'));
material.draw(data, options);
}
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>
[這裏是你的選擇一個更好的解釋(http://stackoverflow.com/a/36452554/5090771) - 如果你需要一個_actual的材料chart_('.Bar') - 見圖4 - 只需要將行轉換爲列,然後使用'colors'配置選項... – WhiteHat