JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<div id="chartContainer" style="height: 300px; width: 100%;"></div>
JavaScript
window.onload = function () {
var maxY = 0;
var chart = new CanvasJS.Chart("chartContainer", {
title:{
text: "Column Chart"
},
axisY: {
labelFormatter: function(e) {
return (e.value/maxY*100)+"%";
}
},
toolTip: {
contentFormatter: function(e) {
var content = " ";
for (var i = 0; i < e.entries.length; i++) {
content += e.entries[i].dataPoint.x + " : " + (CanvasJS.formatNumber((e.entries[i].dataPoint.y/maxY)*100, "##.##")+"%");
content += "<br/>";
}
return content;
}
},
data: [
{
// Change type to "doughnut", "line", "splineArea", etc.
type: "column",
dataPoints: [
{ x: 10, y: 150 },
{ x: 20, y: 400},
{ x: 30, y: 500 },
{ x: 40, y: 2000 },
{ x: 50, y: 814 },
{ x: 60, y: 68 },
{ x: 70, y: 28 },
{ x: 80, y: 34 },
{ x: 90, y: 14}
]
}
]
});
for (var i=0; i<chart.options.data[0].dataPoints.length; i++) {
maxY = Math.max(chart.options.data[0].dataPoints[i].y, maxY);
}
chart.options.axisY.maximum = maxY;
chart.render();
}