Combochart with stacked bars

时间:2015-12-24 18:46:03

标签: google-visualization

我目前正在使用谷歌可视化库(谷歌图表)来可视化我的一些数据。我正在绘制带有累积数据的堆积条形图,但我想打印一个额外的条形图/线条,显示每天的增加量,而不是每天的总量。我已经阅读了Combo Charts,但我似乎无法找到将堆积条形图与折线图相结合的方法。

这有可能吗?

1 个答案:

答案 0 :(得分:0)

它可能,您可以分享更多吗?特别是数据样本?



google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
  var data = google.visualization.arrayToDataTable([
    ['Month', 'Bolivia', 'Ecuador', 'Madagascar', 'Papua New Guinea', 'Rwanda', 'Diff'],
    ['2004/05',  165,      938,         522,             998,           450,      614.6],
    ['2005/06',  135,      1120,        599,             1268,          288,      682],
    ['2006/07',  157,      1167,        587,             807,           397,      623],
    ['2007/08',  139,      1110,        615,             968,           215,      609.4],
    ['2008/09',  136,      691,         629,             1026,          366,      569.6]
  ]);

  var options = {
    title : 'Monthly Coffee Production by Country',
    vAxis: {title: 'Cups'},
    hAxis: {title: 'Month'},
    seriesType: 'bars',
    isStacked: true,
    series: {5: {type: 'line'}}
  };

  var chart = new google.visualization.BarChart(document.getElementById("barchart_values"));
  chart.draw(data, options);
}

<script src="https://www.google.com/jsapi"></script>
<div id="barchart_values" style="width: 900px; height: 300px;"></div>
&#13;
&#13;
&#13;