chart = {
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
svg.selectAll(".text-decades")
.data(y.ticks().slice(0, -1))
.join("text")
.attr("x", 0)
.attr("y", d => y(d))
.attr("transform", `translate(0, ${tickDist / 2})`)
.attr("font-size", 11)
.attr("alignment-baseline", "middle")
.text(d => `${formatYear(d)}s`);
svg.selectAll(".grid-line")
.data(y.ticks())
.join("line")
.attr("class", "grid-line")
.attr("x1", margin.left)
.attr("x2", width)
.attr("y1", d => y(d))
.attr("y2", d => y(d))
.attr("stroke-width", 2)
.attr("stroke-dasharray", 4)
.attr("stroke", "whitesmoke");
svg.selectAll(".label-family")
.data(families)
.join("text")
.attr("class", "label-family")
.attr("x", d => x(d))
.attr("y", 0)
.attr("text-anchor", "middle")
.attr("alignment-baseline", "hanging")
.text(d => (d ? d : "other"));
svg.selectAll(".line-beeswarm")
.data(families)
.join("line")
.attr("class", "line-beeswarm")
.attr("x1", d => x(d))
.attr("x2", d => x(d))
.attr("y1", margin.top - 20)
.attr("y2", height - margin.bottom + 20)
.attr("stroke-width", 0.2)
.attr("stroke", d => color(d));
const pair = svg.selectAll(".beeswarm-pair")
.data(nested)
.join("g")
.attr("class", d => "beeswarm-pair")
.attr("fill", d => color(d.key))
.attr("stroke", d => color(d.key));
pair.selectAll(".circle-left")
.data(d => dodge(d.values.filter(e => e.currentShare), radius * 2 + padding))
.join("circle")
.attr("class", "circle-left")
.attr("cx", e => x(e.data.family) - radius - padding - e.x)
.attr("cy", e => e.y);
pair.selectAll(".circle-right")
.data(d => dodge(d.values.filter(e => !e.currentShare), radius * 2 + padding))
.join("circle")
.attr("class", 'circle-right')
.attr("cx", e => x(e.data.family) + radius + padding + e.x)
.attr("cy", e => e.y)
.attr("stroke-width", 1)
.attr('fill', "transparent");
const circle = pair.selectAll("circle")
.attr("r", radius)
.append("title")
.text(d => `${d.data.party} / ${d.data.partyOrig} (${d.data.partyAbbr}) winning ${d.data.share}% of votes in ${formatYear(d.data.date)} (${d.data.country}) - now, ${d.data.currentShare}%`);
return svg.node();
}