Highcharts Demo

author(s): Torstein Hønsi

HTML

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

JavaScript

$(function() {
    function newRandomColor() {
        var color = [];
        color.push((Math.random() * 255).toFixed());
        color.push((Math.random() * 255).toFixed());
        color.push((Math.random() * 255).toFixed());
        color.push((Math.random()).toFixed(2));
        var text = 'rgba(' + color.join(',') + ')';
        console.log(text);
        return text;
    }
    
    function newRandomData(n) {
        // generate an array of random data
        var data = [],
            time = (new Date()).getTime(),
            i;

        for (i = -1 * n; i <= 0; i++) {
            var color = newRandomColor();
            data.push({
                y:Math.random() * 200 - 100,
                color: color,
                fillColor: color
                      });
        }
        return data;
    }
    var chart = new Highcharts.Chart({
        chart: {
            renderTo: 'container',
            type: 'line'
        },
        yAxis: {},
        turboThreshold:100,
        legend: {
            layout: 'vertical',
            floating: true,
            backgroundColor: '#FFFFFF',
            align: 'right',
            verticalAlign: 'top',
            y: 60,
            x: -60
        },
        tooltip: {
            formatter: function() {
                return '<b>' + this.series.name + '</b><br/>' + this.x + ': ' + this.y;
            }
        },
        plotOptions: {},
        series: [{
            data: newRandomData(1400)},
               threshold: null,
                turboThreshold: 20]
    });
});