JSFiddle - React, Tailwind, and code Playground

by Aditya Shrivastava

HTML

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

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

JavaScript

$(function () {
    $(document).ready(function () {
        Highcharts.setOptions({
            global: {
                useUTC: false
            }
        });

        $('#container').highcharts({
            chart: {
                type: 'line',
                animation: Highcharts.svg,
                marginRight: 10,
                events: {
                    load: function () {
                    var series = this.series[0];
                        setInterval(function () {
                            var x = (new Date()).getTime(),
                                y = Math.random();
                            series.addPoint([x, y], true, true);
                        }, 5000);
                    }
                }
            },
            title: {
                text: 'Live Temprature'
            },
            xAxis: { title: {
                text: 'Time'
            },
                type: 'datetime',
                tickPixelInterval: 100
            },
            yAxis: {
            title: {
                text: 'Temperature (°C)'
            },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
            tooltip: {
                formatter: function () {
                    return '<b>' + this.series.name + '</b><br/>' +
                        Highcharts.dateFormat('%H:%M:%S', this.x) + '<br/>' +
                        Highcharts.numberFormat(this.y, 2) + '°C';
                }
            },
            legend: {
                enabled: false
            },
            exporting: {
                enabled: false
            },
            series: [{
                name: 'Random data',
                data: (function () {
                   
                    var data = [],
                        time = (new Date()).getTime(),
                        i;

                    for (i =-19; i<= 0; i += 5) {
         ...