JSFiddle - React, Tailwind, and code Playground

by ricardolohmann

HTML

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


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

JavaScript

$(function() {
    $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-ohlcv.json&callback=?', function(data) {

        // split the data set into ohlc and volume
        var ohlc = [],
            volume = [],
            band = [],
            dataLength = data.length;
            
        for (i = 0; i < dataLength; i++) {
            ohlc.push([
                data[i][0], // the date
                data[i][1], // open
                data[i][2], // high
                data[i][3], // low
                data[i][4] // close
            ]);
            
            volume.push([
                data[i][0], // the date
                data[i][5] // the volume
            ]);
        }
        
        // an example how to set the plot band data, probably you won't do this way
        for(i = 0; i < (dataLength > 500 ? 500 : dataLength); i++) {
            band.push([
                data[i][0],
                800 // it have to be equal to the yAxis max value
            ]);
        }

        
        // create the chart
        chart = new Highcharts.StockChart({
            chart: {
                renderTo: 'container',
                alignTicks: false
            },

            rangeSelector: {
                selected: 5
            },

            title: {
                text: 'AAPL Historical'
            },

            yAxis: [{
                title: {
                    text: 'OHLC'
                },
                height: 200,
                lineWidth: 2,
                max: 800
            }, {
                title: {
                    text: 'Volume'
                },
                top: 300,
                height: 100,
                offset: 0,
                lineWidth: 2
            }],
            
            series: [{
                    type: 'candlestick',
                    name: 'AAPL',
                    data: ohlc,
                    yAxis: 0,
                    dataGrouping: {
              ...