Highcharts Stock Demo

author(s): Torstein Hønsi

by lizozomi

HTML

<div id="container"></div>
<div class="info">Weekends should appear as gaps in the graph.</div>

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

CSS

#container {
    height: 400px;
    min-width: 600px;
}

.info {
    font: 0.7em sans-serif;
    padding: 0.5em;
    margin: 0.5em;
    background: #fcffc5;
    border-radius: 0.5em;
    border: 1px solid gray;
}

.info::before {
    content: "i";
    margin: 0.5em;
    font: 1.5em serif bold;
    font-style: italic;
    color: green;
}

JavaScript

(async () => {

    const usdeur = await fetch(
        'https://www.highcharts.com/samples/data/usdeur.json'
    ).then(response => response.json());

    Highcharts.stockChart('container', {

        chart: {
            type: 'area'
        },

        rangeSelector: {
            selected: 1
        },

        plotOptions: {
            series: {
                gapSize: 1
            }
        },

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