}
const heatmapData = heatmapElement.dataset.heatmap ? JSON.parse(heatmapElement.dataset.heatmap) : [];
+ const displayName = heatmapElement.dataset.displayName;
const colorScheme = document.documentElement.getAttribute("data-bs-theme") ?? "auto";
const rangeColors = ["#14432a", "#166b34", "#37a446", "#4dd05a"];
const startDate = new Date(Date.now() - (365 * 24 * 60 * 60 * 1000));
type: "month",
gutter: 4,
label: {
- text: (timestamp) => monthNames[new Date(timestamp).getMonth() + 1],
+ text: (timestamp) => monthNames[new Date(timestamp).getUTCMonth() + 1],
position: "top",
textAlign: "middle"
},
text: (date, value) => getTooltipText(date, value)
}]
]);
+
+ cal.on("mouseover", (event, _timestamp, value) => {
+ if (value) event.target.style.cursor = "pointer";
+ });
+
+ cal.on("click", (_event, timestamp) => {
+ if (!displayName) return;
+ for (const { date, max_id } of heatmapData) {
+ if (!max_id) continue;
+ if (timestamp !== Date.parse(date)) continue;
+ const params = new URLSearchParams([["before", max_id + 1]]);
+ location = `/user/${encodeURIComponent(displayName)}/history?${params}`;
+ }
+ });
}
function getTooltipText(date, value) {