@@ -174,55 +174,48 @@ export function LineChart({
174174 ref = { containerRef }
175175 className = 'w-full overflow-hidden rounded-[11px] border bg-card p-4 shadow-sm'
176176 >
177- < div className = 'mb-3 flex items-center justify-between' >
178- < div className = 'flex items-center gap-3' >
179- < h4 className = 'font-medium text-foreground text-sm' > { label } </ h4 >
180- { allSeries . length > 1 && (
181- < div className = 'flex items-center gap-2' >
182- { scaledSeries . slice ( 1 ) . map ( ( s ) => {
183- const isActive = activeSeriesId ? activeSeriesId === s . id : true
184- const isHovered = hoverSeriesId === s . id
185- const dimmed = activeSeriesId ? ! isActive : false
186- return (
187- < button
188- key = { `legend-${ s . id } ` }
189- type = 'button'
190- aria-pressed = { activeSeriesId === s . id }
191- aria-label = { `Toggle ${ s . label } ` }
192- className = 'inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px]'
193- style = { {
194- color : s . color ,
195- opacity : dimmed ? 0.4 : isHovered ? 1 : 0.9 ,
196- border : '1px solid hsl(var(--border))' ,
197- background : 'transparent' ,
198- } }
199- onMouseEnter = { ( ) => setHoverSeriesId ( s . id || null ) }
200- onMouseLeave = { ( ) => setHoverSeriesId ( ( prev ) => ( prev === s . id ? null : prev ) ) }
201- onKeyDown = { ( e ) => {
202- if ( e . key === 'Enter' || e . key === ' ' ) {
203- e . preventDefault ( )
204- setActiveSeriesId ( ( prev ) => ( prev === s . id ? null : s . id || null ) )
205- }
206- } }
207- onClick = { ( ) =>
177+ < div className = 'mb-3 flex items-center gap-3' >
178+ < h4 className = 'font-medium text-foreground text-sm' > { label } </ h4 >
179+ { allSeries . length > 1 && (
180+ < div className = 'flex items-center gap-2' >
181+ { scaledSeries . slice ( 1 ) . map ( ( s ) => {
182+ const isActive = activeSeriesId ? activeSeriesId === s . id : true
183+ const isHovered = hoverSeriesId === s . id
184+ const dimmed = activeSeriesId ? ! isActive : false
185+ return (
186+ < button
187+ key = { `legend-${ s . id } ` }
188+ type = 'button'
189+ aria-pressed = { activeSeriesId === s . id }
190+ aria-label = { `Toggle ${ s . label } ` }
191+ className = 'inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px]'
192+ style = { {
193+ color : s . color ,
194+ opacity : dimmed ? 0.4 : isHovered ? 1 : 0.9 ,
195+ border : '1px solid hsl(var(--border))' ,
196+ background : 'transparent' ,
197+ } }
198+ onMouseEnter = { ( ) => setHoverSeriesId ( s . id || null ) }
199+ onMouseLeave = { ( ) => setHoverSeriesId ( ( prev ) => ( prev === s . id ? null : prev ) ) }
200+ onKeyDown = { ( e ) => {
201+ if ( e . key === 'Enter' || e . key === ' ' ) {
202+ e . preventDefault ( )
208203 setActiveSeriesId ( ( prev ) => ( prev === s . id ? null : s . id || null ) )
209204 }
210- >
211- < span
212- aria-hidden = 'true'
213- className = 'inline-block h-[6px] w-[6px] rounded-full'
214- style = { { backgroundColor : s . color } }
215- />
216- < span style = { { color : 'hsl(var(--muted-foreground))' } } > { s . label } </ span >
217- </ button >
218- )
219- } ) }
220- </ div >
221- ) }
222- </ div >
223- { currentHoverDate ? (
224- < div className = 'text-[10px] text-muted-foreground' > { currentHoverDate } </ div >
225- ) : null }
205+ } }
206+ onClick = { ( ) => setActiveSeriesId ( ( prev ) => ( prev === s . id ? null : s . id || null ) ) }
207+ >
208+ < span
209+ aria-hidden = 'true'
210+ className = 'inline-block h-[6px] w-[6px] rounded-full'
211+ style = { { backgroundColor : s . color } }
212+ />
213+ < span style = { { color : 'hsl(var(--muted-foreground))' } } > { s . label } </ span >
214+ </ button >
215+ )
216+ } ) }
217+ </ div >
218+ ) }
226219 </ div >
227220 < div className = 'relative' style = { { width, height } } >
228221 < svg
@@ -556,6 +549,9 @@ export function LineChart({
556549 className = 'pointer-events-none absolute rounded-md bg-background/80 px-2 py-1 font-medium text-[11px] shadow-sm ring-1 ring-border backdrop-blur'
557550 style = { { left, top } }
558551 >
552+ { currentHoverDate && (
553+ < div className = 'mb-1 text-[10px] text-muted-foreground' > { currentHoverDate } </ div >
554+ ) }
559555 { toDisplay . map ( ( s ) => {
560556 const seriesIndex = allSeries . findIndex ( ( x ) => x . id === s . id )
561557 const val = allSeries [ seriesIndex ] ?. data ?. [ hoverIndex ] ?. value
0 commit comments