JSFiddle - React, Tailwind, and code Playground

by Gerardo Furtado

HTML

<div>This is my chart</div>

CSS

.divchart {
  font: 10px sans-serif;
  background-color: steelblue;
  text-align: right;
  padding: 3px;
  margin: 1px;
  color: white;
}

JavaScript

var data = [40, 80, 150, 160, 230, 260];

var body = d3.select("body");
  
var divs = body.selectAll(null)
    .data(data)
  .enter().append("div");
	
 divs.style("width", function(d) { return d + "px"; })
 	.attr("class", "divchart")
    .text(function(d) { return d; });