JSFiddle - React, Tailwind, and code Playground
HTML
<div id="barchart"></div>
CSS
#barchart {
width: 100px;
height: 100px;
position: relative;
}
.bar {
bottom: 0;
width: 10px;
position: absolute;
background: #666666;
}
JavaScript
// Les données et le container:
var data = [12, 3, 189, 134, 56],
barchart = document.getElementById('barchart'),
width = barchart.offsetWidth,
height = barchart.offsetHeight,
barWidth = Math.floor(width / data.length) - 1;
// On trouve le maximum:
var max = Math.max.apply(Math, data);
// On trace le graphique:
data.forEach(function(value, i) {
var bar = document.createElement('DIV');
barchart.appendChild(bar);
bar.setAttribute('class', 'bar');
bar.style.width = barWidth + 'px';
bar.style.left = (i * (barWidth + 1)) + 'px';
bar.style.top = (width - value * width / max) + 'px';
});