谷歌堆积区域图表不起作用

时间:2016-05-21 17:11:28

标签: javascript charts google-visualization stacked-area-chart

我想要完成谷歌堆积区域图表。

这是js小提琴: Js Fiddle

我还尝试添加堆积区域的选项:

var options_fullStacked = {
          isStacked: 'relative',
          height: 300,
          legend: {position: 'top', maxLines: 3},
          vAxis: {
            minValue: 0,
            ticks: [0, .3, .6, .9, 1]
          }
        };

可在Google图表的文档中找到:stacked area

我想显示它,如下图所示: enter image description here

除了折线图和地图之间显示的堆积区域图表外,请忽略此图中的其他所有内容

1 个答案:

答案 0 :(得分:1)

似乎在这里工作,你可以分享更多吗?

参见以下示例...

<强> isStacked: true

google.charts.load('current', {
  callback: function () {
    new google.visualization.AreaChart(document.getElementById('chart_div')).draw(
      google.visualization.arrayToDataTable([
        ['Year', 'Sales', 'Expenses'],
        ['2013',  1000,      400],
        ['2014',  1170,      460],
        ['2015',  660,       1120],
        ['2016',  1030,      540]
      ]),
      {
        title: 'Company Performance',
        isStacked: true,
        hAxis: {title: 'Year',  titleTextStyle: {color: '#333'}},
        vAxis: {minValue: 0}
      }
    );
  },
  packages:['corechart']
});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>

<强> isStacked: false

google.charts.load('current', {
  callback: function () {
    new google.visualization.AreaChart(document.getElementById('chart_div')).draw(
      google.visualization.arrayToDataTable([
        ['Year', 'Sales', 'Expenses'],
        ['2013',  1000,      400],
        ['2014',  1170,      460],
        ['2015',  660,       1120],
        ['2016',  1030,      540]
      ]),
      {
        title: 'Company Performance',
        isStacked: false,
        hAxis: {title: 'Year',  titleTextStyle: {color: '#333'}},
        vAxis: {minValue: 0}
      }
    );
  },
  packages:['corechart']
});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>