Add text labels to heat map

This commit is contained in:
Alex Selimov 2026-05-11 21:06:21 -04:00
parent e250019862
commit 7b9b9bdcd3
2 changed files with 16 additions and 0 deletions

View file

@ -46,6 +46,18 @@ export function render(weeks, counts) {
svg.setAttribute("width", weeks.length * SHIFT + 30);
svg.setAttribute("height", SHIFT * 7 + 20);
// Place the labels first
["Mon", "Wed", "Fri"].forEach((label, i) => {
const dayLabel = document.createElementNS(svgNS, "text");
dayLabel.setAttribute("x", 0);
dayLabel.setAttribute("y", (2 * i + 1) * SHIFT + 0.75 * CELL);
dayLabel.setAttribute("font-size", 12);
const text = document.createTextNode(label);
dayLabel.appendChild(text);
svg.appendChild(dayLabel);
});
weeks.forEach((week, col) => {
week.forEach((day, row) => {
if (day === null) {