function makeSquares(initialData) {
const updateBtn = document.getElementById("update-btn");
var squareSize = 20;
const nudgeDown = 20;
const nudgeRight = 20;
const titleGap = 5;
const gapBetween = 5;
var halfSquare = squareSize / 2;
var maxCol = 10;
var cur = 0;
var height = 500;
var rows = 28;
const svg = d3.select(DOM.svg(width, height));
const t = svg.transition().duration(750);
var squareGap = squareSize + gapBetween;
const drawGraph = (data) => {
const squareUpdate = svg
.selectAll("circle")
.data(data, (d) => d.id)
.call((update) =>
update
.transition()
.duration(750)
.style("fill", (d) => colorScaleDemToRep(d.color))
.attr("cx", (d) => d.row * squareGap + nudgeDown)
.attr("cy", (d) => d.col * squareGap + nudgeDown)
);
const squareEnter = squareUpdate
.enter()
.append("circle")
.attr("class", "grid-object")
.attr("r", squareSize / 2)
.style("fill", (d) => colorScaleDemToRep(d.color))
.style("stroke", "black")
.style("stroke-width", 0)
.attr("cx", (d) => randomIntFromInterval(nudgeRight, width / 2 - 20))
.attr("cy", (d) => randomIntFromInterval(nudgeDown, height / 2 - 20))
.call((enter) =>
enter
.transition(t)
.attr("cx", (d) => d.row * squareGap + nudgeDown)
.attr("cy", (d) => d.col * squareGap + nudgeDown)
);
const squareExit = squareUpdate
.exit()
.call((exit) => exit.transition(t).attr("y", -30).remove());
};
drawGraph(initialData);
updateBtn.addEventListener("click", () => {
cur = notCurrentRand(8, rows, cur);
drawGraph(updateRowCol(initialData, cur));
});
return svg.node();
}