JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<button id="addChart">Add chart</button>
<table id="chartTable" border="1px sold blue"></table>
CSS
table {
height: 100%;
width: 100%;
}
JavaScript
var options = {
axisX: {
valueFormatString: " ",
tickLength: 0
},
axisY: {
valueFormatString: " ",
tickLength: 0
},
data: [
{
type: "column",
dataPoints: [
{ x: 10, y: 71 },
{ x: 20, y: 55 },
{ x: 30, y: 50 },
{ x: 40, y: 65 },
{ x: 50, y: 95 },
{ x: 60, y: 68 },
{ x: 70, y: 28 },
{ x: 80, y: 34 },
{ x: 90, y: 14 }
]
}
]
};
var table = document.getElementById("chartTable")
var row1 = table.insertRow(0);
var row2 = table.insertRow(1);
document.getElementById("addChart").addEventListener("click", function()
{
var cell1 = row1.insertCell(0);
cell1.setAttribute("width", "100%");
cell1.setAttribute("height", "100%");
cell1.innerHTML = "<div id='chartContainer' style='height:100%; width:100%;'></div>";
var chart = new CanvasJS.Chart("chartContainer", options);
chart.render();
var cell2_1 = row2.insertCell(0);
cell2_1.setAttribute("width", "50%");
cell2_1.setAttribute("height", "100%");
cell2_1.innerHTML = "<div id='chartContainer2' style='height:100%; width:100%;'></div>";
var chart2 = new CanvasJS.Chart("chartContainer2", options);
chart2.render();
var cell2_2 = row2.insertCell(1);
cell2_2.setAttribute("width", "50%");
cell2_2.setAttribute("height", "100%");
cell2_2.innerHTML = "<div id='chartContainer3' style='height:100%; width:100%;'></div>";
var chart3 = new CanvasJS.Chart("chartContainer3", options);
chart3.render();
});