我正在使用这种Google图表: https://google-developers.appspot.com/chart/interactive/docs/gallery/combochart
折线图的值非常高,而条形图的值非常低。我希望以两种类型都可读的方式组合它们。
这是我的剧本:
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['corechart']});
function drawVisualization() {
var chart = new google.visualization.ComboChart(document.getElementById('chart_incoming_actions'));
chart.draw(google.visualization.arrayToDataTable([
['Month', 'Votes', 'Views'],
['2012-12-03', 3, 9912],
['2012-12-02', 41, 85776],
['2012-12-01', 43, 85483],
['2012-11-30', 36, 77738],
['2012-11-29', 50, 84000],
['2012-11-28', 72, 102089],
['2012-11-27', 74, 89701]
]), {
vAxis: {title: "Views / Votes"},
hAxis: {title: "Month"},
seriesType: "bars",
series: {1: {type: "line"}}
});
}
google.setOnLoadCallback(drawVisualization);
</script>
正如您所看到的,这些数字相距很远。是否可以显示当前数字,但是假设条形的高度,例如它会乘以1000?
提前致谢, 柳
答案 0 :(得分:1)
没关系,我自己弄清楚了。 :)
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['corechart']});
function drawVisualization() {
var chart = new google.visualization.ComboChart(document.getElementById('chart_incoming_actions'));
chart.draw(google.visualization.arrayToDataTable([
['Month', 'Votes', 'Views'],
['2012-12-03', 7, 19393],
['2012-12-02', 41, 85776],
['2012-12-01', 43, 85483],
['2012-11-30', 36, 77738],
['2012-11-29', 50, 84000],
['2012-11-28', 72, 102089],
['2012-11-27', 74, 89701]
]), {
vAxis: {
0: {logScale: false, title: "Votes"},
1: {logScale: false, title: "Views"}
},
hAxis: {title: "Month"},
seriesType: "bars",
series: {
0:{type: 'bar', targetAxisIndex:0},
1:{type: 'line', targetAxisIndex:1}
}
});
}
google.setOnLoadCallback(drawVisualization);
</script>