chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
const g = svg.append("g")
.selectAll("g")
.data(bins)
.join("g");
g.append("path")
.attr("stroke", "currentColor")
.attr("d", d => `
M${x(d.key) + x.bandwidth() / 2},${y(d.value.range[1])}
V${y(d.value.range[0])}
`);
g.append("path")
.attr("fill",d => color(d.value.gender))
.attr("opacity", 0.5)
.attr("d", d => `
M${x(d.key) + 1},${y(d.value.quartiles[2])}
H${x(d.key) + x.bandwidth()}
V${y(d.value.quartiles[0])}
H${x(d.key) + 1}
Z
`)
.on('mouseover', function(d, i) {
const t = d3.transition('enlarge').duration(500)
tooltipMouseOver(d, i, t, allInfo)
})
.on('mouseout', function(d, i) {
const t = d3.transition('dwindle').duration(500)
tooltipMouseOut(d, i, t, allInfo)
});
g.append("path")
.attr("stroke", "currentColor")
.attr("stroke-width", 3)
.attr("d", d => `
M${x(d.key) + 1},${y(d.value.quartiles[1])}
H${x(d.key) + x.bandwidth()}
`)
.on('mouseover', function(d, i) {
const t = d3.transition('enlarge').duration(500)
tooltipMouseOver(d, i, t, medianInfo)
})
.on('mouseout', function(d, i) {
const t = d3.transition('dwindle').duration(500)
tooltipMouseOut(d, i, t, medianInfo)
});;
g.append("path")
.attr("stroke", "currentColor")
.attr("stroke-width", 3)
.attr("d", d => `
M${x(d.key) + x.bandwidth() * 0.25},${y(d.value.range[0])}
H${x(d.key) + x.bandwidth() * 0.75}
`)
.on('mouseover', function(d, i) {
const t = d3.transition('enlarge').duration(500)
tooltipMouseOver(d, i, t, minIQRInfo)
})
.on('mouseout', function(d, i) {
const t = d3.transition('dwindle').duration(500)
tooltipMouseOut(d, i, t, minIQRInfo)
});
g.append("path")
.attr("stroke", "currentColor")
.attr("stroke-width", 3)
.attr("d", d => `
M${x(d.key) + x.bandwidth() * 0.25},${y(d.value.range[1])}
H${x(d.key) + x.bandwidth() * 0.75}
`)
.on('mouseover', function(d, i) {
const t = d3.transition('enlarge').duration(500)
tooltipMouseOver(d, i, t, maxIQRInfo)
})
.on('mouseout', function(d, i) {
const t = d3.transition('dwindle').duration(500)
tooltipMouseOut(d, i, t, maxIQRInfo)
});
g.append("g")
.attr("fill", "currentColor")
.attr("fill-opacity", 0.5)
.attr("stroke", "none")
.attr("transform", d => `translate(${x(d.key) + x.bandwidth() / 2},0)`)
.selectAll("circle")
.data(d => d.value.values)
.join("circle")
.attr("r", 8)
.attr("cx", () => (Math.random() - 0.5) * 10)
.attr("cy", d => y(d.y))
.on('mouseover', function(d, i) {
const t = d3.transition('enlarge').duration(500)
tooltipMouseOver(d, i, t, chapterInfo)
})
.on('mouseout', function(d, i) {
const t = d3.transition('dwindle').duration(500)
tooltipMouseOut(d, i, t, chapterInfo)
});
svg.append("g")
.call(xAxis);
svg.append("g")
.call(yAxis);
return svg.node();
}