{
const svg = d3.create("svg")
.attr("width", width)
.attr("height", height);
const margin = {
left: 20,
right: 20
}
const xScale = d3.scaleLinear()
.domain([0, numCircles - 1])
.range([margin.left, width - margin.right])
while (true) {
svg.selectAll("circle")
.data(updateData(),(d,i) => i)
.join(
enter => enter.append("circle")
.attr("cx", (d,i) => xScale(i))
.attr("cy", height / 2)
.attr("r", (width - margin.left - margin.right) / numCircles / 2)
.attr("stroke", "black")
.attr("fill", d => d.status == "occupied" ? "black" : "white"),
update => update
.transition().duration(1000)
.attr("fill", d => d.status == "occupied" ? "black" : "white")
)
yield svg.node();
await Promises.tick(3000);
}
}