我正在使用 google Material Charts 静态 api 库,但我无法弄清楚为什么我输入的背景颜色没有反射(reflect)页面加载时的变化。
以下是我的选择:
var options = {
backgroundColor: '#E8E4D8',
chart: {
title: 'Coaches by Service',
subtitle: 'Coaches by Services: From 2016-09-10 until Today'
}
};
这是我实例化图表的方式:
var chart = new google.charts.Bar(document.getElementById('chart_div'));
chart.draw(data, google.charts.Bar.convertOptions(options));
图表标题和副标题正确显示,任何有关背景颜色为何保持默认白色的建议将不胜感激。
最佳答案
还有更多可以分享的吗?似乎在这里工作...
也许,请检查您正在加载的版本。
在这里,我使用卡住版本 '44'
,而不是 'current'
。
已有recent issues 。
google.charts.load('44', {
callback: drawChart,
packages: ['bar']
});
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses', 'Profit'],
['2014', 1000, 400, 200],
['2015', 1170, 460, 250],
['2016', 660, 1120, 300],
['2017', 1030, 540, 350]
]);
var options = {
backgroundColor: '#E8E4D8',
chart: {
title: 'Coaches by Service',
subtitle: 'Coaches by Services: From 2016-09-10 until Today'
}
};
var chart = new google.charts.Bar(document.getElementById('chart_div'));
chart.draw(data, google.charts.Bar.convertOptions(options));
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
关于javascript - 谷歌条形图不改变背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35925057/