chart = {
const height = 800;
const svg = d3
.create("svg")
.attr("viewBox", [0, 0, width, height])
.attr("width", width)
.attr("height", height)
.attr("style", "max-width: 100%; height: auto;")
.attr("transform", "rotate(20deg)");
var squareSize = 6;
var padding = 2;
const puzzles = svg
.selectAll(".row")
.data(data)
.enter()
.append("g")
.attr("class", "row")
.attr("transform", (d, i) => `translate(0, ${i * (squareSize + padding)})`);
const squares = puzzles
.selectAll(".square")
.data((d) => Object.values(d))
.enter()
.append("rect")
.attr("class", (d) => `square ${d}`)
.attr("x", (d, i) => i * (squareSize + padding))
.attr("width", squareSize)
.attr("height", squareSize)
.attr("cell-index", (d) => d)
.attr("grid-section", (d) => getSudokuSection(d))
.attr("fill", "#d3d3d3")
.attr("display", (d) => (d === null ? "none" : "block"))
.on("mousemove", function (event, d) {
var activeCellIndex = d3.select(this).attr("cell-index");
var activeGridSection = getSudokuSection(activeCellIndex);
d3.selectAll("rect[grid-section='" + `${activeGridSection}` + "'").attr(
"fill",
"#40C6F9"
);
d3.selectAll("rect[cell-index='" + `${activeCellIndex}` + "'").attr(
"fill",
"#08759E"
);
})
.on("mouseout", function (event, d) {
var activeCellIndex = d3.select(this).attr("cell-index");
var activeGridSection = getSudokuSection(activeCellIndex);
d3.selectAll("rect[cell-index='" + `${activeCellIndex}` + "'").attr(
"fill",
"#d3d3d3"
);
d3.selectAll("rect[grid-section='" + `${activeGridSection}` + "'").attr(
"fill",
"#d3d3d3"
);
});
return svg.node();
}