title: javascript dynamic array in google.visualization.arrayToDataTable?
body: <p>I am trying to build pie chart of google visualization, but I can't input dynamic array of models and cars.</p>
  
  <pre><code>var i;
  /*****************TRY******************************/
  // Load google charts
  google.charts.load('current', {'packages':['corechart']});
  google.charts.setOnLoadCallback(drawChart);
  
  // Draw the chart and set the chart values
  function drawChart() {
    var data = google.visualization.arrayToDataTable([
    ['Task', 'Hours per Day'],
    for(i=0;i&lt;cars.length;i++){
        [models[i],cars[i]]
    }
  ]);
  
    // Optional; add a title and set the width and height of the chart
    var options = {'title':'My Average Day', 'width':400, 'height':300};
  
    // Display the chart inside the &lt;div&gt; element with id="piechart"
    var chart = new google.visualization.PieChart(document.getElementById('piechart'));
    chart.draw(data, options);
  }
  </code></pre>