Google PieChart - 在创作时添加动画

时间:2015-09-28 19:40:03

标签: javascript charts google-chartwrapper

我想创建一个Google Pie Chart

我想要的是在页面首次加载时创建图表时有一个奇特的动画。我试过的是:

<html>
<head>
  <script type="text/javascript" src="https://www.google.com/jsapi"></script>

  <script type="text/javascript">
    google.load("visualization", "1", {packages:["corechart"]});
    google.setOnLoadCallback(drawChart);
    function drawChart()
    {
      var data = google.visualization.arrayToDataTable([
      ['Task', 'Hours per Day'],
      ['Work',     11],
      ['Eat',      2],
      ['Commute',  2],
      ['Watch TV', 2],
      ['Sleep',    7]
      ]);

      var options = {
        title: 'My Daily Activities',
        is3D: true,
        animation:
          {
            duration: 1000,
            easing: 'in',
          }
      };

      var chart = new google.visualization.PieChart(document.getElementById('piechart_3d'));
      chart.draw(data, options);
    }
  </script>
</head>
<body>
<div id="piechart_3d" style="width: 900px; height: 500px;"></div>
</body>
</html>

更具体地说,它是:

animation: {
  duration: 1000,
  easing: 'in',
}

但它没有用。

有人可以帮我吗?

1 个答案:

答案 0 :(得分:2)

饼图不支持

动画

请参阅supported-modifications

下表格中的有效图表类型