chart = {
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
svg.append("g")
.attr("transform", `translate(0,${height-20})`)
.attr("opacity", 0)
.call(d3.axisBottom(x))
.transition()
.delay(1800+1800/2)
.duration(1800/2)
.attr("opacity", 1);
const g = svg.append("g")
.attr("fill", "#B8BFC6")
.selectAll("rect")
.data(dataPos)
.join("rect")
.attr("x", d => d.x1)
.attr("y", d => d.y1)
.attr("width", squareSize)
.attr("height", squareSize)
.attr("fill", d => color(d.party))
.attr("stroke-width", 0.5)
.attr("stroke", "white")
if (play) {
g.transition()
.delay(100)
.duration(1800)
.attr("fill", d => d3.interpolateBlues(1 - d.ministryIndex / sortedMinistries.length))
.transition()
.delay(100)
.duration(1800)
.attr("x", d => x(d.bins.x0))
.attr("y", d => height - 30 - d.bins.pos * squareSize)
}
return svg.node();
}