chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height])
.style("font", "10px sans-serif");
const xScale = d3.scaleLinear()
.domain([bins[0].x0, bins[bins.length - 1].x1])
.range([0, width - margin.left - margin.right]);
const yScale = d3.scaleLinear()
.domain([0, d3.max(bins, d => d.length)])
.range([height - margin.bottom, margin.top]);
const g = svg.append("g")
.attr("fill", "pink")
.selectAll('rect')
.data(bins)
.join("rect")
.attr('x', d => xScale(d.x0 + 1))
.attr('y', d => yScale(d.length))
.attr('width', d => Math.max(0, xScale(d.x1) - xScale(d.x0) - 1))
.attr('height', d => yScale(0) - yScale(d.length));
return svg.node();
}