Highcharts Stock Demo

author(s): Torstein Hønsi

by Rajesh Danabal

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/data.js"></script>
<script src="https://code.highcharts.com/stock/modules/exporting.js"></script>

JavaScript

Highcharts.getJSON('https://demo-live-data.highcharts.com/aapl-c.json', function (data) {
    // Create the chart
    Highcharts.stockChart('container', {

        chart: {
            height: 300
        },

        rangeSelector: {
            allButtonsEnabled: true,
            buttons: [{
                type: 'month',
                count: 3,
                text: 'Day'
            }, {
                type: 'year',
                count: 1,
                text: 'Week'
            }, {
                type: 'all',
                text: 'Month'
            }],
            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: null, // auto
                radius: 3,
                lineWidth: 1,
                lineColor: '#FFFFFF'
            },
            tooltip: {
                valueDecimals: 2
            }
        }]
    });
});