JSFiddle - React, Tailwind, and code Playground

by klsakthi

HTML

<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/series-label.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>

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


<input type="checkbox" id="rainfall"> <label for="rainfall">Rainfall Chart</label>

<br/>

<input type="checkbox" id="sealevel"> <label for="sealevel">Sea Level Pressure Chart</label>

JavaScript

$("#sealevel").click(function(e, parameters) {
  var $this = $(this);
  // $this will contain a reference to the checkbox   
  if ($this.is(':checked')) {
    // the checkbox was checked 
     window.chart.addAxis({ // Secondary yAxis
				id:'sealevel-yaxis',
        gridLineWidth: 0,
        title: {
            text: 'Sea-Level Pressure',
            style: {
                color: '#c44abc'
            }
        },
        labels: {
            format: '{value} mb',
            style: {
                color: '#c44abc'
            }
        },
        opposite: true,
        lineColor: '#c44abc',
        lineWidth: 1
    });
    window.chart.addSeries({
        name: 'Sea-Level Pressure',
        id: 'sealevel',
        type: 'spline',
        data: [1016, 1016, 1015.9, 1015.5, 1012.3, 1009.5, 1009.6, 1010.2, 1013.1, 1016.9, 1018.2, 1016.7],
        marker: {
            enabled: false
        },
        dashStyle: 'shortdot',
        yAxis: 'sealevel-yaxis',
        tooltip: {
            valueSuffix: ' mb'
        },
      	color: '#c44abc'
    });
  } else {
    // the checkbox was unchecked
    window.chart.get('sealevel-yaxis').remove();
  }
});

$("#rainfall").click(function(e, parameters) {
  var $this = $(this);
  // $this will contain a reference to the checkbox   
  if ($this.is(':checked')) {
    // the checkbox was checked 
    window.chart.addAxis({ // Secondary yAxis
      id:'rainfall-yaxis',
      gridLineWidth: 0,
      title: {
        text: 'Rainfall',
        style: {
          color: '#7cb5ec'
        }
      },
      labels: {
        format: '{value} mm',
        style: {
          color: '#7cb5ec'
        }
      },
      lineColor: '#7cb5ec',
      lineWidth: 1
    });
    window.chart.addSeries({
      name: 'Rainfall',
      id: 'rainfall',
      type: 'column',
      yAxis: 'rainfall-yaxis',
      data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
      tooltip: {
        valueSuffix: ' mm'
     ...