diff --git a/frontend/src/components/Sparkline.css b/frontend/src/components/Sparkline.css index 2aece7ca..189567a2 100644 --- a/frontend/src/components/Sparkline.css +++ b/frontend/src/components/Sparkline.css @@ -2,3 +2,33 @@ display: block; width: 100%; } + +.sparkline-container { + position: relative; + width: 100%; +} + +.sparkline-extrema { + position: absolute; + top: 2px; + right: 8px; + display: inline-flex; + align-items: center; + gap: 12px; + padding: 2px 8px; + background: color-mix(in srgb, var(--ant-color-bg-elevated) 88%, transparent); + border: 1px solid var(--ant-color-border-secondary); + border-radius: 999px; + font-size: 11px; + font-weight: 600; + line-height: 16px; + pointer-events: none; + z-index: 1; +} + +.sparkline-extrema .extrema-item { + display: inline-flex; + align-items: center; + gap: 4px; + white-space: nowrap; +} diff --git a/frontend/src/components/Sparkline.tsx b/frontend/src/components/Sparkline.tsx index dfb27775..11bf1ecf 100644 --- a/frontend/src/components/Sparkline.tsx +++ b/frontend/src/components/Sparkline.tsx @@ -137,7 +137,7 @@ export default function Sparkline({ if (points[i].value > points[maxIdx].value) maxIdx = i; } if (minIdx === maxIdx) return null; - return { min: points[minIdx], max: points[maxIdx] }; + return { min: points[minIdx], max: points[maxIdx], minIdx, maxIdx }; }, [points, extrema?.show]); const fmtExtrema = extrema?.formatter ?? yFormatter; @@ -145,120 +145,126 @@ export default function Sparkline({ const maxColor = extrema?.maxColor ?? DEFAULT_MAX_COLOR; return ( - - - - - - - - - {showGrid && ( - - )} - points[i]?.label).filter(Boolean) as string[] | undefined} - /> - - {showTooltip && ( - [fmtTooltip(Number(v) || 0), '']} - labelFormatter={(label) => (tooltipLabelFormatter ? tooltipLabelFormatter(String(label)) : String(label))} - separator="" +
+ {extremaPoints && ( + + )} + + + + + + + + + {showGrid && ( + + )} + points[i]?.label).filter(Boolean) as string[] | undefined} /> - )} - {referenceLines?.map((rl, idx) => ( - - ))} - {extremaPoints && ( - <> - [fmtTooltip(Number(v) || 0), '']} + labelFormatter={(label) => (tooltipLabelFormatter ? tooltipLabelFormatter(String(label)) : String(label))} + separator="" + /> + )} + {referenceLines?.map((rl, idx) => ( + - - - )} - - - + ))} + {extremaPoints && ( + <> + + + + )} + + + +
); }