{
var bars = svg.selectAll("rect.bars")
.data(chartValues)
.join("rect")
.transition().duration(500)
.attr("class", "bars")
.attr("x", d => xscale(d.x))
.attr("y", d => yscale(d.y))
.attr("width", xscale.bandwidth())
.attr("height", d => 300 - yscale(d.y))
.style("fill", d => cscale(d.x))
.style("stroke", "white");
var text = svg.selectAll("text")
.data(chartValues)
.join("text")
.transition().duration(500)
.attr("x", d => xscale(d.x))
.attr("y", d => yscale(d.y))
.attr("dx", "1.5em")
.attr("dy", 20)
.attr("fill", "white")
.style("font-size", "small")
.text(d => d.y);
return svg.node();
}