A Line chart with dynamically updating data

This is a demo of a Line chart that shows constantly updating Line chart. It updates every second with new data. The labels are updated too and are just increasing numbers. There's only one Line chart object and its data is updated (new data added and last data-piece removed from the datasets) every second.

This goes in the documents header:
<script src="RGraph.svg.common.core.js"></script>
<script src="RGraph.svg.line.js"></script>
Put this where you want the chart to show up:
<div style="width: 750px; height: 300px" id="chart-container"></div>
This is the code that generates the chart:
<script>
    iteration = 0;
    data      = [];
    data2     = [];
    labels    = [
        '','','','','','','','','','',
        '','','','','','','','','',''
    ];

    line = new RGraph.SVG.Line({
        id: 'chart-container',
        data: [data, data2],
        options: {
            hmargin: 0,
            title: 'An updating SVG Line chart',
            xaxisLabels: labels,
            xaxisColor: '#aaa',
            yaxis: false,
            backgroundGridColor: '#eee',
            backgroundGridVlines: false,
            backgroundGridBorder: false,
            colors: ['#00c','#c00'],
            linewidth: 1,
            tickmarksStyle: 'filledcircle'
        }
    }).draw();




    function update ()
    {
        if (iteration === 0) {
            line.originalData[0] = RGraph.SVG.arrayFill({
                array:  [],
                length: 20
            });
            
            line.originalData[1] = RGraph.SVG.arrayFill({
                array:  [],
                length: 20
            });
        }

        // A global
        last  = RGraph.SVG.random({min:0, max:100})
        last2 = RGraph.SVG.random({min:0, max:100})

        line.originalData[0].push(last);
        line.originalData[1].push(last2);

        line.originalData[0].shift();
        line.originalData[1].shift();

        line.properties.xaxisLabels.push(iteration + 1)
        line.properties.xaxisLabels.shift();

        RGraph.SVG.redraw();
        
        iteration++;

        setTimeout(function ()
        {
            update()
        }, 1000);
    }

    update();
</script>