无法在Google图表表格代码中添加额外的行或列。(表格消失)

时间:2018-11-27 15:52:51

标签: javascript google-visualization

我正在使用Google的Javascript代码-https://developers.google.com/chart/interactive/docs/gallery/table

我试图添加更多的行和列,但是每次添加一些内容时,表就会消失。

data.addColumn('boolean', 'Full Time Employee'); 

['Bob', {v: 7000, f: '$7,000'}, true]

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

      function drawTable() {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Name');
        data.addColumn('number', 'Salary');
        data.addColumn('boolean', 'Full Time Employee');
        data.addRows([
          ['Mike',  {v: 10000, f: '$10,000'}, true],
          ['Jim',   {v:8000,   f: '$8,000'},  false],
          ['Alice', {v: 12500, f: '$12,500'}, true],
          ['Bob',   {v: 7000,  f: '$7,000'},  true]
        ]);

        var table = new google.visualization.Table(document.getElementById('table_div'));

        table.draw(data, {showRowNumber: true, width: '100%', height: '100%'});
      }
    </script>
  </head>
  <body>
    <div id="table_div"></div>
  </body>
</html>

0 个答案:

没有答案