Locally DataTable google charts

24 views
Skip to first unread message

Tommi Tomat

unread,
Apr 22, 2020, 5:50:24 PM4/22/20
to Google Visualization API

need help. How to create a table locally in google charts? Viewed the entire site, nothing works.

The bottom line is that I need to make a local table that I could edit in each individual script. I will have two graphs with my own tables, which should work from the local one.

Example code, maybe I do not understand somethin


<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type='text/javascript'>
            google.charts.load('current');


      // Load the Visualization API and the corechart package.
      google.charts.load('current', {'packages':['corechart']});

      // Set a callback to run when the Google Visualization API is loaded.
      google.charts.setOnLoadCallback(drawChart);
  function drawVisualization() {
    var dataTable = [
      ["Country", "Population Density"],
      ["Indonesia", 117],
      ["China", 137],
      ["Nigeria", 142],
      ["Pakistan", 198],
      ["India", 336],
      ["Japan", 339],
      ["Bangladesh", 1045]
    ];
    google.visualization.drawChart({
      "containerId": "visualization_div",
      "dataTable": dataTable,
      "refreshInterval": 5,
      "chartType": "Table",
      "options": {
        "alternatingRowStyle": true,
        "showRowNumber" : true,
      }
    });
  }
  google.charts.setOnLoadCallback(drawVisualization);


    function drawChart() {

        var columnchart_options = {title:'Barchart: How Much Pizza I Ate Last Night',
                       width:700,
                       height:600,
                       legend: { position: 'top', maxLines: 0 },
        bar: { groupWidth: '75%' },
        isStacked: true,};
        var columnchart = new google.visualization.ColumnChart(document.getElementById('columnchart_div'));
        columnchart.draw(dataTable, columnchart_options);
      }

</script>
  </head>

  <body>

        <table class="columns">
      <tr>

        <td><div id="columnchart_div" style="border: 1px solid #ccc"></div></td>


      </tr>
    </table>

  </body>
Reply all
Reply to author
Forward
0 new messages