将背景设置为 google-图表,图表。什么都不做
Setting the background to the google-charts, chart. Doesn't do anything
我使用 google-图表 API 绘制柱形图。当我将背景设置为图表时,它没有任何作用。
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable(<?php echo $str ?>);
var options = {
title: 'Business Optimization Per Predicted Conversion Rate',
bar: {groupWidth: "70%"},
backgroundColor: 'red',
colors: ['purple','red'],
fontSize:20,
legend: { position: "none" },
width: 900,
};
var chart = new google.charts.Bar(document.getElementById('chart_div_1'));
chart.draw(data, options);
}
发生了什么事我在选项标签中写了特定的背景需要是红色的?
而不是:
chart.draw(data, options);
尝试做:
chart.draw(data, google.charts.Bar.convertOptions(options));
此处发生的情况是您可能正在使用 material 图表,并且选项的定义方式已更改。
请参阅来自 google charts documentation regarding this, here 的注释:
The Material Charts are in beta. The appearance and interactivity are
largely final, but the way options are declared is not. If you are
converting a Classic Column Chart to a Material Column Chart, you'll
want to replace this line:
chart.draw(data, options);
...with this:
chart.draw(data, google.charts.Column.convertOptions(options));
我使用 google-图表 API 绘制柱形图。当我将背景设置为图表时,它没有任何作用。
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable(<?php echo $str ?>);
var options = {
title: 'Business Optimization Per Predicted Conversion Rate',
bar: {groupWidth: "70%"},
backgroundColor: 'red',
colors: ['purple','red'],
fontSize:20,
legend: { position: "none" },
width: 900,
};
var chart = new google.charts.Bar(document.getElementById('chart_div_1'));
chart.draw(data, options);
}
发生了什么事我在选项标签中写了特定的背景需要是红色的?
而不是:
chart.draw(data, options);
尝试做:
chart.draw(data, google.charts.Bar.convertOptions(options));
此处发生的情况是您可能正在使用 material 图表,并且选项的定义方式已更改。
请参阅来自 google charts documentation regarding this, here 的注释:
The Material Charts are in beta. The appearance and interactivity are largely final, but the way options are declared is not. If you are converting a Classic Column Chart to a Material Column Chart, you'll want to replace this line:
chart.draw(data, options);
...with this:
chart.draw(data, google.charts.Column.convertOptions(options));