Google Charts列着色?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Google Charts列着色?相关的知识,希望对你有一定的参考价值。
如何更改google的材料柱形图两列的颜色?
这是我的选项代码:
var options = {
chart: {
title: 'Event Posting',
subtitle: 'Kairos event posting and student registration',
colors: ['#b0120a', '#ffab91'],
}
};
colors属性不起作用。
答案
看起来颜色对我有用,但为什么你的选项数组options.chart?看起来colors属性应该是您选项的根,例如:
google.charts.load('current', {packages: ['corechart', 'bar']});
google.charts.setOnLoadCallback(drawMaterial);
function drawMaterial() {
var data = new google.visualization.DataTable();
data.addColumn('timeofday', 'Time of Day');
data.addColumn('number', 'Motivation Level');
data.addColumn('number', 'Energy Level');
data.addRows([
[{v: [8, 0, 0], f: '8 am'}, 1, .25],
[{v: [9, 0, 0], f: '9 am'}, 2, .5],
[{v: [10, 0, 0], f:'10 am'}, 3, 1],
[{v: [11, 0, 0], f: '11 am'}, 4, 2.25],
[{v: [12, 0, 0], f: '12 pm'}, 5, 2.25],
[{v: [13, 0, 0], f: '1 pm'}, 6, 3],
[{v: [14, 0, 0], f: '2 pm'}, 7, 4],
[{v: [15, 0, 0], f: '3 pm'}, 8, 5.25],
[{v: [16, 0, 0], f: '4 pm'}, 9, 7.5],
[{v: [17, 0, 0], f: '5 pm'}, 10, 10],
]);
var options = {
title: 'Motivation and Energy Level Throughout the Day',
hAxis: {
title: 'Time of Day',
format: 'h:mm a',
viewWindow: {
min: [7, 30, 0],
max: [17, 30, 0]
}
},
vAxis: {
title: 'Rating (scale of 1-10)'
},
colors: [
'#00f',
'#ff0'
]
};
var materialChart = new google.charts.Bar(document.getElementById('chart_div'));
materialChart.draw(data, options);
}
<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
</head>
<body>
<!--Div that will hold the pie chart-->
<div id="chart_div"></div>
</body>
</html>
以上是关于Google Charts列着色?的主要内容,如果未能解决你的问题,请参考以下文章
Google Charts API 面积图仅在注释中显示最大值和最小值