JSFiddle - React, Tailwind, and code Playground

by sujay

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: 600px"></div>

JavaScript

$(function() {
    var chart,
        yAxisOptions = [],
        seriesCounter = 0,
        names = ['MSFT', 'AAPL', 'GOOG'],
        colors = Highcharts.getOptions().colors;

    $.each(names, function(i, name) {

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

            // As we're loading the data asynchronously, we don't know what order it will arrive. So
            // we keep a counter and create the chart when all the data is loaded.
            seriesCounter++;

            if (seriesCounter == 1) {
                createChart([{
                   name: name,
                   data: data
                }]);
                chart.showLoading();
            } else {
                chart.addSeries({name: name, data: data, yAxis: seriesCounter - 1, color: colors[seriesCounter - 1]});                        
                if(seriesCounter == names.length){
                    chart.hideLoading();
                }
            }
        });
    });



    // create the chart when all data is loaded
    function createChart(seriesOptions) {

        chart = new Highcharts.StockChart({
            chart: {
                renderTo: 'container'
            },

            rangeSelector: {
                selected: 4
            },

            yAxis: [{
                labels: {
                    formatter: function() {
                        return (this.value > 0 ? '+' : '') + this.value + '%';
                    },
                    align: 'right',
                    x: -8,
                    y: 3
                },
                title: {
                    text: 'Percent',
                    style: {
                        color: colors[0]
                    }
                },
                plotLines: [{
                    value: 0,
                    width: 2,
                    color: 'silver'
                }]
            },{
  ...