Skip to content Skip to sidebar Skip to footer

Looping In Google Charts Javascript

I am looking to 'perform a loop' in Google Charts Javascript in the arrayToDataTable. Can anyone suggest how to do this ? Also it it ok to use a php variable in the dataset like th

Solution 1:

something like this work for you?

<?php
  $Total = array(0,1,2,3,4,5,6,7,8,9);
?>

<html lang="en">
<head>
  <script src="https://www.google.com/jsapi"></script>
  <script>
    google.load('visualization', '1', {packages: ['corechart'], callback: drawChart});

    function drawChart() {
      var data = google.visualization.arrayToDataTable([
        ['Month', 'Movie'],

<?php
    foreach($Total as $row){
      echo "['" . $row . "', " . $row . "],";
    }
?>

      ]);
      document.getElementById('chart').innerHTML = data.getNumberOfRows();
    }
  </script>
</head>
<body>
  <div id="chart"></div>
</body>
</html>

Post a Comment for "Looping In Google Charts Javascript"