chart = {
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
svg.append("g").call(yGrid);
svg
.append("g")
.attr("fill", "steelblue")
.selectAll("rect")
.data(bins)
.join("rect")
.attr("x", d => xScale(d.x0) + barPadding)
.attr("y", d => yScale(d.length))
.attr("width", d => d3.max([0, xScale(d.x1) - xScale(d.x0) - barPadding]))
.attr("height", d => yScale(0) - yScale(d.length));
svg.append("g").call(xAxis);
svg.append("g").call(yAxis);
return svg.node();
}