Highcharts Stock Demo

author(s): Torstein Hønsi

by andrei

HTML

<div id="container" style="height: 400px; min-width: 600px; max-width: 800px; margin: 0 auto"></div>

<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script src="https://code.highcharts.com/stock/modules/exporting.js"></script>

JavaScript

$(function () {

    $.getJSON('https://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function (data) {
        // Create the chart
        $('#container').highcharts('StockChart', {

            chart: {
                height: 300
            },

            rangeSelector : {
                allButtonsEnabled: true,
                buttons: [{
                    type: 'month',
                    count: 3,
                    text: 'Day',
                    dataGrouping: {
                        forced: true,
                        units: [['day', [1]]]
                    }
                }, {
                    type: 'year',
                    count: 1,
                    text: 'Week',
                    dataGrouping: {
                        forced: true,
                        units: [['week', [1]]]
                    }
                }, {
                    type: 'all',
                    text: 'Month',
                    dataGrouping: {
                        forced: true,
                        units: [['month', [1]]]
                    }
                }],
                buttonTheme: {
                    width: 60
                },
                selected: 2
            },

            title : {
                text : 'AAPL Stock Price'
            },

            subtitle: {
                text: 'Custom data grouping tied to range selector'
            },

            navigator: {
                enabled: false
            },

            series : [{
                name : 'AAPL',
                data : data,
                marker: {
                    enabled: false
                },
                tooltip: {
                    valueDecimals: 2
                }
            }]
        });
    });

});