[英]Google Charts change color on side box
So I'm using Google Charts and using the Column charts ( https://developers.google.com/chart/interactive/docs/gallery/columnchart ) specifically and I have a question regarding colors on charts.所以我正在使用谷歌图表并使用柱形图( https://developers.google.com/chart/interactive/docs/gallery/columnchart ),我对图表上的 colors 有疑问。
Here are two questions :这里有两个问题:
'Aug', 7283, 'color: #ff8a73'
to define the hex colors on each bar, does anyone know a better way to define colors or is this the proper way?'Aug', 7283, 'color: #ff8a73'
在每个条上定义十六进制 colors,有谁知道定义 colors 的更好方法还是这是正确的方法? Here is the JS code:这是JS代码:
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(sle_interactions);
function sle_interactions() {
var data = google.visualization.arrayToDataTable([
['Year', 'Interactions', { role: 'style' }],
['Aug', 7283, 'color: #ff8a73'],
['Sep', 8263, 'color: #ff8a73'],
['Oct', 9827, 'color: #ff8a73'],
['Nov', 9362, 'color: #ff8a73'],
['Dec', 10625, 'color: #ff8a73']
]);
var options = {
title: 'Interactions',
is3D: true,
backgroundColor: 'transparent',
hAxis: {
title: 'Timeframe',
}
};
var chart = new google.visualization.ColumnChart(document.getElementById('sle_interactions'));
chart.draw(data, options);
}
document.addEventListener('DOMContentLoaded', sle_interactions);
Both of the questions have been resolved using this:这两个问题都已使用以下方法解决:
var options = {
title: 'Age Range',
is3D: true,
backgroundColor: 'transparent',
hAxis: {
title: 'Followers',
},
vAxis: {
minValue: 0,
maxValue: 100,
format: "#.#'%'",
},
colors: ['#ff8a73'],
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.