diff --git a/frontend/src/utils/helpers/githubHeatmap.ts b/frontend/src/utils/helpers/githubHeatmap.ts index 71748fa1b2..a9630dc4e2 100644 --- a/frontend/src/utils/helpers/githubHeatmap.ts +++ b/frontend/src/utils/helpers/githubHeatmap.ts @@ -83,19 +83,17 @@ export const fetchHeatmapData = async (username: string): Promise { + const rect = ctx.canvas.getBoundingClientRect() + const x = e.clientX - rect.left + const y = e.clientY - rect.top + const hovered = cellPositions.find( + (pos) => x >= pos.x && x <= pos.x + pos.width && y >= pos.y && y <= pos.y + pos.height + ) + if (hovered) { + tooltip.style.left = `${e.clientX}px` + tooltip.style.top = `${e.clientY + 16}px` + tooltip.style.display = 'block' + tooltip.innerText = hovered.text + } else { + tooltip.style.display = 'none' + } + }) + // Draw Month Label let lastCountedMonth = 0 for (let y = 0; y < graphEntries[0].length; y += 1) {