chart = {
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
svg
.append("g")
.attr("fill", "#ff838e")
.selectAll("rect")
.data(bins)
.join("rect")
.attr("x", d => x(d.x0) + 1)
.attr("width", d => Math.max(0, x(d.x1) - x(d.x0) - 1))
.attr("y", d => y(d.length))
.attr("height", d => y(0) - y(d.length));
svg
.append("g")
.attr('font-size', '10px')
.attr('text-anchor', 'middle')
.selectAll('text')
.data(
bins.filter(
d => d.length > 1 && (d.x0 * 10000000).toString().match(/100+/)
)
)
.join('text')
.attr("x", d => x(d.x0))
.attr("y", d => y(d.length))
.attr('dx', d => (x(d.x1) - x(d.x0)) / 2)
.attr('dy', -2)
.text(d => `${d.x0 / 100000000}~${d.x1 / 100000000}`);
svg.append("g").call(xAxis);
svg.append("g").call(yAxis);
return svg.node();
}