Highcharts Stock Demo

author(s): Torstein Hønsi

HTML

<script type="text/javascript" src="http://www.highcharts.com/js/testing-stock.js"></script>

<div id="container" style="height: 500px; min-width: 500px"></div>

JavaScript

$(function() {

    $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=large-dataset.json&callback=?', function(data) {
    
        // Create a timer
        var start = + new Date();
    
        // Create the chart
        var chart = new Highcharts.StockChart({
            chart: {
                renderTo: 'container',
                events: {
                    load: function(chart) {
                        this.setTitle(null, {
                            text: 'Built chart at '+ (new Date() - start) +'ms'
                        });
                    }
                },
                zoomType: 'x'
            },
    
            xAxis: {
                type: 'linear',
                labels: {
                    formatter: function(){
                        return this.value;
                    }
                }
            },
    
            yAxis: {
                title: {
                    text: 'Temperature (°C)'
                }
            },
    
            title: {
                text: 'Hourly temperatures in Vik i Sogn, Norway, 2004-2010'
            },
    
            subtitle: {
                text: 'Built chart at...' // dummy text to reserve space for dynamic subtitle
            },
            
            series: [{
                name: 'Temperature',
                data: data,
                pointStart: 1,
                pointInterval: 1,
                tooltip: {
                    yDecimals: 1,
                    ySuffix: '°C'
                }
            }]
    
        });
    });
});