JSFiddle - React, Tailwind, and code Playground
CSS
div {
background: black;
height: 20px;
margin: 5px;
}
JavaScript
function update(data) {
var selection = d3.select('body').selectAll('div');
var binding = selection.data(data);
binding
.transition().duration(1000)
.style('width', function(d) { return d + 'px'; });
binding.enter()
.append('div')
.style('width', function(d) { return d + 'px'; });
binding.exit()
.transition().duration(1000)
.style('opacity', 0)
.remove();
}
function twoRow() {
update([100, 150]);
setTimeout(threeRow, 2000);
}
function threeRow() {
update([50, 100, 150]);
setTimeout(twoRow, 3000);
}
twoRow();