如何使用Google表格数据在Google图表中添加/删除行

时间:2019-05-28 12:04:37

标签: google-apps-script google-sheets google-visualization

我找不到一种创建类似https://developers.google.com/chart/interactive/docs/animation#adding-and-removing-rows之类的方法的方法,其中根据Google表格中的数据添加或删除行

这是我的代码

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
      google.charts.load('current', {'packages':['corechart', 'calendar', 'table']});

      google.charts.setOnLoadCallback(drawSheetName5);
               //First Map



    //fourth Map
            function drawSheetName5() {
      var queryString5 = encodeURIComponent('SELECT A, B');

      var query5 = new google.visualization.Query(
          'https://docs.google.com/spreadsheets/d/13H-qqA427mPnphFG3agU735f9N5mdM3odhRynKzXnI8/gviz/tq?sheet=Sheet3&range=A13:B24&headers=1&tq=' + queryString5);
      query5.send(handleQueryResponse5);
    }

    function handleQueryResponse5(response) {
      if (response.isError()) {
        alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
        return;
      }

      var data = response.getDataTable();
      var chart = new google.visualization.AreaChart(document.getElementById('chart_div5'));
      chart.draw(data, { backgroundColor: 'transparent', height: 400, width: 370, legend: { position: 'none', maxLines: 3 }, series:{ 1: {color: '#F400A1' }, 0: {color: '#5218FA' }} });
    }


    </script>

0 个答案:

没有答案