svg= {
const svg= d3.create("svg").attr("viewBox", [0, 0, width, height]);
const grouping= svg.append("g")
.attr("transform", `translate( ${margin.left}, ${margin.top})`);
grouping.append("g")
.call(d3.axisBottom(x).tickFormat(dateFmt))
.attr("transform", `translate(0, ${height - margin.top - margin.bottom})`)
.call((axis) =>
axis
.append("text")
.text(x_attr)
.style("fill", "black")
.attr("transform", `translate( ${x.range()[1]}, +30)`)
.style("text-anchor", "end")
.style("font-size", 20)
)
.call((axis) => axis.selectAll("line").remove())
.call((axis) => axis.selectAll("path").remove());
grouping.append("g")
.call(d3.axisLeft(y))
.call((axis) =>
axis
.append("text")
.text(y_attr)
.style("fill", "black")
.style("text-anchor", "middle")
.attr("y", -15)
.style("font-size", 20)
)
.call((axis) => axis.selectAll("line").remove())
.call((axis) => axis.selectAll("path").remove());
grouping.selectAll(".cell")
.data(grouped)
.join("rect")
.attr("class", "cell")
.attr("x", d=> x(d.day))
.attr("y", d=> y(d.hour))
.attr("width", x.bandwidth())
.attr("height", y.bandwidth())
.attr("fill", d=> color(d.value))
return svg.node();
}