Google 图表:折线图上的点未显示
Google charts: points on line graph not showing
这应该是一个非常快速的答案,但我已经玩了一个小时了,无法修复它。我的折线图上的点没有显示,当我检查开发工具中的点时,我可以看到填充不透明度设置为 0。如果我手动将它设置为 1,它是可见的,但我找不到设置它的选项剧本。这是代码,我错过了什么?
<script type="text/javascript">
google.load('visualization', '1.1', {packages: ['line']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Month');
data.addColumn('number', 'New York');
data.addColumn('number', 'London');
data.addRows([
["Jan", 10, 12],
["Feb", 19, 31],
["Mar", 80, 20],
["Apr", 43, 56],
["May", 18, 42],
["Jun", 62, 81],
]);
var options = {
height: 400,
colors: ["#2980b9", "ffa22c"],
pointSize: 10,
dataOpacity: 1.0,
};
var chart = new google.charts.Line(document.getElementById('linechart_material'));
chart.draw(data, options);
}
</script>
google.charts.Line
是对较新的 Google Material 图表的引用。来自 docs:
The Material Charts are in beta. The appearance and interactivity are largely final, but the way options are declared is not.
很遗憾,您还不能设置某些选项,请参阅此 open issue:
The pointSize option is not yet supported for Material Charts.
这应该是一个非常快速的答案,但我已经玩了一个小时了,无法修复它。我的折线图上的点没有显示,当我检查开发工具中的点时,我可以看到填充不透明度设置为 0。如果我手动将它设置为 1,它是可见的,但我找不到设置它的选项剧本。这是代码,我错过了什么?
<script type="text/javascript">
google.load('visualization', '1.1', {packages: ['line']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Month');
data.addColumn('number', 'New York');
data.addColumn('number', 'London');
data.addRows([
["Jan", 10, 12],
["Feb", 19, 31],
["Mar", 80, 20],
["Apr", 43, 56],
["May", 18, 42],
["Jun", 62, 81],
]);
var options = {
height: 400,
colors: ["#2980b9", "ffa22c"],
pointSize: 10,
dataOpacity: 1.0,
};
var chart = new google.charts.Line(document.getElementById('linechart_material'));
chart.draw(data, options);
}
</script>
google.charts.Line
是对较新的 Google Material 图表的引用。来自 docs:
The Material Charts are in beta. The appearance and interactivity are largely final, but the way options are declared is not.
很遗憾,您还不能设置某些选项,请参阅此 open issue:
The pointSize option is not yet supported for Material Charts.