diff --git a/site/src/components/ActivityCharts.svelte b/site/src/components/ActivityCharts.svelte index a251c5b..7e82b63 100644 --- a/site/src/components/ActivityCharts.svelte +++ b/site/src/components/ActivityCharts.svelte @@ -355,11 +355,15 @@ ); if (isSlope) { + const nearTop = (d: any) => { + const range = lineDomainMax - lineDomainMin; + return range > 0 && (d[yKey] - lineDomainMin) / range > 0.85; + }; marks.push( Plot.text(lineData, Plot.pointerX({ x, y: yKey, text: (d: any) => d.slope != null ? `${d.slope > 0.05 ? '+' : ''}${(+d.slope).toFixed(1)}%` : '', - dy: -22, + dy: (d: any) => nearTop(d) ? 22 : -22, fill: (d: any) => slopeColor(d.slope ?? 0), stroke: tc.tooltipBg, strokeWidth: 3, fontSize: 11, fontWeight: '700', @@ -367,7 +371,7 @@ Plot.text(lineData, Plot.pointerX({ x, y: yKey, text: (d: any) => d[yKey] != null ? `${Math.round(d[yKey])}m` : '', - dy: -10, + dy: (d: any) => nearTop(d) ? 10 : -10, fill: tc.axis, stroke: tc.tooltipBg, strokeWidth: 3, fontSize: 10, })),