Add rows to google chart from array?
<p>I'm having trouble adding rows to a google chart from an array.  Right now I have the code below and it works fine.  I want to use a for loop to add the rows instead of having to manually add in each one like I have it now when I was testing it out.  How can I do that?  The array has 30 elements in total.    </p>

<pre><code>function drawChart(array1) {

// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Day');
data.addColumn('number', 'Temperature');

data.addRows([

    [array1[29], array1[28]],
    [array1[27], array1[26]],
    [array1[25], array1[24]],
    [array1[23], array1[22]],
    [array1[21], array1[20]],

    ["Today", array1[0]]

]);


var options = {'title':'Historical Temperatures',

    hAxis: {
    title: 'Time',
    logScale: true
},
    vAxis: {
        title: 'Popularity',
        logScale: false
    },
    'width':700,
    'height':300};


var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</code></pre>

<p>Would replacing the data.addRows block with the following work?</p>

<pre><code>for (var i = 20; i &lt; array1.length; i+2)
{
    data.addRows([
        [array1[i+1], array1[i]]
    ])
}
</code></pre>