Highcharts Stock Demo

author(s): Torstein Hønsi

by rcugut

HTML

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

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script src="https://code.highcharts.com/stock/modules/exporting.js"></script>
<script type="text/javascript" src="https://www.highcharts.com/samples/data/usdeur.js"></script>

JavaScript

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

        chart: {
            spacingRight: 0
        },

        rangeSelector: {
            selected: 1
        },

        navigator: {
            enabled: false
        },

        scrollbar: {
            enabled: false
        },

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

        yAxis: [{
            opposite: false,
            offset: 30,
            tickWidth: 1,
            tickLength: 5,
            lineWidth: 1
        }, {
            offset: 20,
            tickWidth: 1,
            tickLength: 5,
            lineWidth: 1,
            labels: {
                align: 'left'
            },
            linkedTo: 0
        }],

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