ElementStacks

by Bhesh Gurung

HTML

<script type="text/javascript" src="http://highcharts.com/js/highcharts.js"></script>
<div id="container" style="height: 400px"></div>

JavaScript

CHART = new Highcharts.Chart({
    chart: {
        renderTo: 'container',
        defaultSeriesType: 'spline',
        animation: true
    },
    xAxis: {
        type: 'datetime',
        labels: {
            formatter: function() {
                return Highcharts.dateFormat("%M:%S", this.value);
            }
        },
        tickInterval: 500
    },
    series: [{
        name: "chart01",
        data: [],
        pointStart: new Date().getTime(),
        pointInterval: 500
    }]
});

function on() {
    jQuery("#container").css("border", "1px solid red");
}


function off() {
    jQuery("#container").css("border", "0");
}

setInterval(function() {
    var time = new Date().getTime();
    CHART.series[0].addPoint({x: time, y: Math.random()}, true, true);
}, 500);