diff --git a/web/src/lib/components/profile/ProfileActivityChart.svelte b/web/src/lib/components/profile/ProfileActivityChart.svelte index 676be5438..c895b1668 100644 --- a/web/src/lib/components/profile/ProfileActivityChart.svelte +++ b/web/src/lib/components/profile/ProfileActivityChart.svelte @@ -64,22 +64,10 @@ ); let availableWidth = $state(988); - let armed = $state(false); - let revealed = $state(false); const layout = $derived(layoutActivityChart(values, availableWidth)); const viewport: Action = (node) => { let followsCurrent = true; let frame = 0; - armed = true; - const inView = new IntersectionObserver( - (entries) => { - if (!entries.some((entry) => entry.isIntersecting)) return; - revealed = true; - inView.disconnect(); - }, - { threshold: 0.4 } - ); - inView.observe(node); const alignCurrent = () => { cancelAnimationFrame(frame); frame = requestAnimationFrame(() => { @@ -100,7 +88,6 @@ destroy() { cancelAnimationFrame(frame); observer.disconnect(); - inView.disconnect(); node.removeEventListener("scroll", onScroll); } }; @@ -116,15 +103,13 @@
= previous.value} {@const current = monthIndex === 5}
@@ -211,71 +196,3 @@ {/if} {/if} - - diff --git a/web/src/lib/components/profile/profileActivityChart.test.ts b/web/src/lib/components/profile/profileActivityChart.test.ts index d3a9eb2c5..e984a60c7 100644 --- a/web/src/lib/components/profile/profileActivityChart.test.ts +++ b/web/src/lib/components/profile/profileActivityChart.test.ts @@ -86,17 +86,16 @@ describe("layoutActivityChart", () => { } }); - it("ranks each column's metrics from top to bottom", () => { + it("separates each column's metrics from top to bottom", () => { const layout = layoutActivityChart(values, 988); for (let month = 0; month < 6; month += 1) { - const byRank = ACTIVITY_METRICS.toSorted( - (a, b) => layout.points[a][month].rank - layout.points[b][month].rank + const byY = ACTIVITY_METRICS.toSorted( + (a, b) => layout.points[a][month].y - layout.points[b][month].y ); - expect(byRank.map((metric) => layout.points[metric][month].rank)).toEqual([0, 1, 2, 3]); - for (const [index, metric] of byRank.slice(1).entries()) { + for (const [index, metric] of byY.slice(1).entries()) { expect(layout.points[metric][month].y).toBeGreaterThan( - layout.points[byRank[index]][month].y + layout.points[byY[index]][month].y ); } } diff --git a/web/src/lib/components/profile/profileActivityChart.ts b/web/src/lib/components/profile/profileActivityChart.ts index fce767d96..bca5df369 100644 --- a/web/src/lib/components/profile/profileActivityChart.ts +++ b/web/src/lib/components/profile/profileActivityChart.ts @@ -12,7 +12,6 @@ export interface ActivityChartPoint { x: number; y: number; value: number; - rank: number; } export interface ActivityChartSegment { @@ -109,13 +108,11 @@ export const layoutActivityChart = ( const resolved = resolvePointCollisions( ACTIVITY_METRICS.map((metric) => ({ metric, y: rawY[metric][monthIndex] })) ); - const ordered = ACTIVITY_METRICS.toSorted((a, b) => resolved.get(a)! - resolved.get(b)!); for (const metric of ACTIVITY_METRICS) { points[metric].push({ x: column.left + POINT_INSET, y: resolved.get(metric)!, - value: values[metric][monthIndex], - rank: ordered.indexOf(metric) + value: values[metric][monthIndex] }); } }