JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<br/><!-- Just so that JSFiddle's Result label doesn't overlap the Chart -->
<div id="chartContainer" style="height: 360px; width: 100%;"></div>
<div id="chartContainer2" style="height: 360px; width: 100%;"></div>

JavaScript

var chart = new CanvasJS.Chart("chartContainer", {
  title:{
    text: "Basic Column Chart"
  },
  legend: {
    cursor: 'pointer',
    fontSize: 20,
    horizontalAlign: 'center',
    itemclick: e => toogleDataSeries(e, e.chart)
  },
  data: [{
    showInLegend: true,
    dataPoints: [
      { x: 10, y: 71 },
      { x: 20, y: 55},
      { x: 30, y: 50 },
      { x: 40, y: 65 },
      { x: 60, y: 68 },
      { x: 70, y: 28 },
      { x: 80, y: 34 }
    ]
  },
  {
    showInLegend: true,
    dataPoints: [
      { x: 10, y: 7111 },
      { x: 20, y: 55},
      { x: 30, y: 50 },
      { x: 40, y: 65 },
      { x: 60, y: 68 },
      { x: 70, y: 28 },
      { x: 80, y: 34 }
    ]
  }]
});

var chart2 = new CanvasJS.Chart("chartContainer2", {
  title:{
    text: "Basic Column Chart"
  },
  data: [{				
    dataPoints: [
      { x: 10, y: 71 },
      { x: 20, y: 15},
      { x: 30, y: 10 },
      { x: 40, y: 15 },
      { x: 50, y: 95 },
      { x: 60, y: 18 },
      { x: 70, y: 18 },
      { x: 80, y: 11 }
    ]
  }]
});

chart.render();
chart2.render();

function toogleDataSeries(e, chart){
  if (typeof(e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
    e.dataSeries.visible = false;
  } else{
    e.dataSeries.visible = true;
  }
  chart.render();
  test();
}

function test() {
  var charts = [chart, chart2];
  var axisYBoundMax = 0;
  
  for(var i = 0; i < charts.length; i++) {
    charts[i].axisY[0].set("margin", 0);
  } 

  for (var i=0; i<charts.length; i++) {
    axisYBoundMax = Math.max(axisYBoundMax, charts[i].axisY[0].bounds.x2);
  }

  for(var i = 0; i < charts.length; i++) {
    charts[i].axisY[0].set("margin", axisYBoundMax - (charts[i].axisY[0].bounds.x2 - charts[i].axisY[0].bounds.x1));
  } 
}