Stats: fix month-label placement, back to orange
- labels now sit on the week CONTAINING the 1st of the month (old logic labelled the first column starting in that month, so a month beginning mid-week was labelled a whole column late — hovering the cells under 'Aug' showed Jul dates); skip labels that would crowd the previous one - label + grid rows are inline-flex so flexbox shrink can't drift them apart at narrow widths - cell scale back to the orange accent (color-mix of --acc)
This commit is contained in:
1 parent
0afd27d4d2
commit
36be7d0a02
2 files changed
+17
-14
No files matched your search
+9
-6
@@ -491,15 +491,17 @@ function heatMap(byDay, days) {
|
||||
for (const t of ["Mon", "", "Wed", "", "Fri", "", ""]) dcol.append(el("span", null, t));
|
||||
const row = el("div", "heat-row");
|
||||
row.append(dcol, grid);
|
||||
let lastM = -1;
|
||||
let lastCol = -10, colIdx = 0; // month label: week containing the 1st
|
||||
for (let d = new Date(start); d <= today; ) {
|
||||
const col = el("div", "heat-col");
|
||||
const lab = el("span", "heat-lab");
|
||||
const labD = new Date(d);
|
||||
for (let i = 0; i < 7 && labD < win; i++) labD.setDate(labD.getDate() + 1);
|
||||
if (labD <= today && labD.getMonth() !== lastM) {
|
||||
lab.textContent = MN[labD.getMonth()];
|
||||
lastM = labD.getMonth();
|
||||
for (let i = 0; i < 7; i++) {
|
||||
const dd = new Date(d); dd.setDate(dd.getDate() + i);
|
||||
if (dd.getDate() === 1 && dd >= win && dd <= today && colIdx - lastCol >= 2) {
|
||||
lab.textContent = MN[dd.getMonth()];
|
||||
lastCol = colIdx;
|
||||
break; // one label per column, skip if it would crowd the previous
|
||||
}
|
||||
}
|
||||
lbl.append(lab);
|
||||
for (let i = 0; i < 7; i++) {
|
||||
@@ -518,6 +520,7 @@ function heatMap(byDay, days) {
|
||||
col.append(c);
|
||||
}
|
||||
grid.append(col);
|
||||
colIdx++;
|
||||
}
|
||||
const lg = el("div", "heat-lg");
|
||||
lg.append(el("span", "muted", "less"));
|
||||
|
||||
Reference in new issue
Block a user