Highcharts Stock Demo

author(s): Torstein Hønsi

by dpnminh

HTML

<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<div id="container" style="height: 400px; min-width: 600px"></div>

<div id="report" style="font: 0.8em sans-serif"></div>

<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

var $report = $('#report');

Highcharts.stockChart('container', {

    chart: {
        zoomType: 'x',
        events: {
            selection: function (event) {
                if (event.xAxis) {
                    $report.html('Last selection:<br/>min: ' + Highcharts.dateFormat('%Y-%m-%d', event.xAxis[0].min) +
                        ', max: ' + Highcharts.dateFormat('%Y-%m-%d', event.xAxis[0].max));
                } else {
                    $report.html('Selection reset');
                }
            }
        }
    },

    rangeSelector: {
        selected: 1
    },

    series: [{
        name: 'USD to EUR',
        data: usdeur
    }]
});