Skip to content

Add activeTime prop for synced crosshairs#8

Open
lndgalante wants to merge 5 commits intobenjitaylor:mainfrom
lndgalante:feat/active-point
Open

Add activeTime prop for synced crosshairs#8
lndgalante wants to merge 5 commits intobenjitaylor:mainfrom
lndgalante:feat/active-point

Conversation

@lndgalante
Copy link

@lndgalante lndgalante commented Mar 24, 2026

Summary

Adds an activeTime prop that renders a crosshair at a given timestamp on any chart — the chart interpolates the Y value(s) internally. Designed for syncing crosshairs across multiple charts via onHover + activeTime.

  • Works live or paused, single-series or multi-series
  • Interpolates Y from chart data — caller only provides a timestamp
  • User hover takes precedence over activeTime
  • Includes interactive synced-charts demo (3 charts with shared crosshair)

Usage

const [syncTime, setSyncTime] = useState<number | null>(null)

<Liveline data={dataA} onHover={p => setSyncTime(p?.time ?? null)} activeTime={syncTime} />
<Liveline data={dataB} onHover={p => setSyncTime(p?.time ?? null)} activeTime={syncTime} />

Changed files

File Change
src/types.ts Add activeTime to LivelineProps
src/Liveline.tsx Thread prop through to engine
src/useLivelineEngine.ts Interpolate Y at given time, compute screen position
src/draw/index.ts Draw programmatic crosshair, suppress hover when active
dev/main.tsx Synced charts demo with onHover + activeTime

Demo

CleanShot.2026-03-25.at.00.54.21.mp4

@lndgalante
Copy link
Author

cc @benjitaylor amazing lib! Let me know if this implementation looks good to you, needs to be think differently, or needs some improvements.

@lndgalante lndgalante changed the title Add activePoint prop for programmatic crosshair Add activePoint, and activeTime props for programmatic crosshair Mar 25, 2026
@lndgalante lndgalante changed the title Add activePoint, and activeTime props for programmatic crosshair Add activePoint prop for programmatic crosshair Mar 25, 2026
@lndgalante lndgalante changed the title Add activePoint prop for programmatic crosshair Add activeTime prop for synced crosshairs Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant