JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<div id="chartContainer" style="height: 360px; width: 100%;"></div>
JavaScript
window.chart = new CanvasJS.Chart("chartContainer",
{
title: {
text: "Histogram using Column Chart"
},
axisX: {
interval: 1
},
data: [
{
type: "column",
dataPoints: [
{ x: 1, y: 71 },
{ x: 2, y: 55},
{ x: 3, y: 50 },
{ x: 4, y: 65 },
{ x: 5, y: 95 },
{ x: 6, y: 68 },
{ x: 7, y: 28 },
{ x: 8, y: 34 },
{ x: 9, y: 14},
{ x: 10, y: 44},
{ x: 11, y: 38},
{ x: 12, y: 64}
]
}
]
});
chart.render();
//get("propertyName");
//set("propertyName", value, updateChart);
//updateChart = false
chart.set("dataPointWidth",Math.ceil(chart.axisX[0].bounds.width/chart.data[0].dataPoints.length),true);
//On Resize chart width changes so as the plotArea, so dataPointWidth will vary according to width
$( window ).resize(function() {
chart.set("dataPointWidth",Math.ceil(chart.axisX[0].bounds.width/chart.data[0].dataPoints.length),true);
});