react-native-livechart 4.31.0 → 4.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +3 -0
  2. package/dist/components/ChartOverlayLayer.d.ts +3 -1
  3. package/dist/components/ChartOverlayLayer.d.ts.map +1 -1
  4. package/dist/components/CrosshairOverlay.d.ts +3 -1
  5. package/dist/components/CrosshairOverlay.d.ts.map +1 -1
  6. package/dist/components/CustomMarkerOverlay.d.ts +2 -2
  7. package/dist/components/CustomMarkerOverlay.d.ts.map +1 -1
  8. package/dist/components/FreeCrosshairOverlay.d.ts +25 -0
  9. package/dist/components/FreeCrosshairOverlay.d.ts.map +1 -0
  10. package/dist/components/LiveChart.d.ts.map +1 -1
  11. package/dist/components/LiveChartSeries.d.ts.map +1 -1
  12. package/dist/components/MarkerOverlay.d.ts +2 -2
  13. package/dist/components/MarkerOverlay.d.ts.map +1 -1
  14. package/dist/components/ScrubActionOverlay.d.ts +7 -1
  15. package/dist/components/ScrubActionOverlay.d.ts.map +1 -1
  16. package/dist/core/liveChartEngineTick.d.ts +2 -0
  17. package/dist/core/liveChartEngineTick.d.ts.map +1 -1
  18. package/dist/core/liveChartSeriesEngineTick.d.ts +6 -0
  19. package/dist/core/liveChartSeriesEngineTick.d.ts.map +1 -1
  20. package/dist/core/resolveConfig.d.ts +4 -0
  21. package/dist/core/resolveConfig.d.ts.map +1 -1
  22. package/dist/core/useLiveChartEngine.d.ts +7 -2
  23. package/dist/core/useLiveChartEngine.d.ts.map +1 -1
  24. package/dist/core/useLiveChartSeriesEngine.d.ts +9 -1
  25. package/dist/core/useLiveChartSeriesEngine.d.ts.map +1 -1
  26. package/dist/hooks/crosshairSeries.d.ts +1 -1
  27. package/dist/hooks/crosshairSeries.d.ts.map +1 -1
  28. package/dist/hooks/crosshairShared.d.ts +4 -2
  29. package/dist/hooks/crosshairShared.d.ts.map +1 -1
  30. package/dist/hooks/useCrosshair.d.ts +5 -1
  31. package/dist/hooks/useCrosshair.d.ts.map +1 -1
  32. package/dist/hooks/useCrosshairSeries.d.ts.map +1 -1
  33. package/dist/hooks/useMarkers.d.ts +2 -2
  34. package/dist/hooks/useMarkers.d.ts.map +1 -1
  35. package/dist/hooks/usePanScroll.d.ts +2 -0
  36. package/dist/hooks/usePanScroll.d.ts.map +1 -1
  37. package/dist/hooks/usePinchZoom.d.ts +2 -0
  38. package/dist/hooks/usePinchZoom.d.ts.map +1 -1
  39. package/dist/hooks/useReferenceLineSeries.d.ts +1 -1
  40. package/dist/hooks/useReferenceLineSeries.d.ts.map +1 -1
  41. package/dist/hooks/useScrubMarkers.d.ts +2 -1
  42. package/dist/hooks/useScrubMarkers.d.ts.map +1 -1
  43. package/dist/hooks/useVisibleRange.d.ts +8 -17
  44. package/dist/hooks/useVisibleRange.d.ts.map +1 -1
  45. package/dist/index.d.ts +1 -1
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/math/markers.d.ts +6 -0
  48. package/dist/math/markers.d.ts.map +1 -1
  49. package/dist/math/referenceLineSeries.d.ts +1 -1
  50. package/dist/math/referenceLineSeries.d.ts.map +1 -1
  51. package/dist/math/scrubMarkers.d.ts +1 -1
  52. package/dist/math/scrubMarkers.d.ts.map +1 -1
  53. package/dist/math/spline.d.ts +3 -2
  54. package/dist/math/spline.d.ts.map +1 -1
  55. package/dist/types.d.ts +51 -7
  56. package/dist/types.d.ts.map +1 -1
  57. package/package.json +1 -1
  58. package/src/components/ChartOverlayLayer.tsx +9 -3
  59. package/src/components/CrosshairOverlay.tsx +7 -0
  60. package/src/components/CustomMarkerOverlay.tsx +5 -2
  61. package/src/components/FreeCrosshairOverlay.tsx +87 -0
  62. package/src/components/LiveChart.tsx +105 -75
  63. package/src/components/LiveChartSeries.tsx +41 -22
  64. package/src/components/MarkerOverlay.tsx +24 -14
  65. package/src/components/ScrubActionOverlay.tsx +24 -5
  66. package/src/core/liveChartEngineTick.ts +3 -0
  67. package/src/core/liveChartSeriesEngineTick.ts +25 -4
  68. package/src/core/resolveConfig.ts +13 -0
  69. package/src/core/useLiveChartEngine.ts +14 -2
  70. package/src/core/useLiveChartSeriesEngine.ts +44 -7
  71. package/src/hooks/crosshairSeries.ts +4 -4
  72. package/src/hooks/crosshairShared.ts +18 -12
  73. package/src/hooks/useCrosshair.ts +29 -5
  74. package/src/hooks/useCrosshairSeries.ts +10 -4
  75. package/src/hooks/useMarkers.ts +7 -4
  76. package/src/hooks/usePanScroll.ts +3 -1
  77. package/src/hooks/usePinchZoom.ts +8 -5
  78. package/src/hooks/useReferenceLineSeries.ts +8 -4
  79. package/src/hooks/useScrubMarkers.ts +5 -2
  80. package/src/hooks/useVisibleRange.ts +96 -66
  81. package/src/index.ts +1 -0
  82. package/src/math/markers.ts +25 -8
  83. package/src/math/referenceLineSeries.ts +4 -3
  84. package/src/math/scrubMarkers.ts +4 -1
  85. package/src/math/spline.ts +41 -25
  86. package/src/types.ts +49 -7
@@ -392,6 +392,30 @@ function composeSeriesRootGesture(
392
392
  : gesture;
393
393
  }
394
394
 
395
+ function useSeriesHistoryBounds(
396
+ renderedSeries: SharedValue<SeriesConfig[]>,
397
+ liveEdge: SharedValue<number>,
398
+ historyStartTime: number | undefined,
399
+ ) {
400
+ const historyFloor = historyStartTime != null && Number.isFinite(historyStartTime)
401
+ ? historyStartTime : null;
402
+ // The engine publishes retained samples and their viewport on the same measured frame.
403
+ const retainedMinTime = useDerivedValue(() => {
404
+ const s = renderedSeries.get();
405
+ let min = Infinity;
406
+ for (let i = 0; i < s.length; i++) {
407
+ const d = s[i].data;
408
+ if (d.length > 0 && d[0].time < min) min = d[0].time;
409
+ }
410
+ return min === Infinity ? null : Math.min(min, historyFloor ?? Infinity);
411
+ });
412
+ // Gestures still need a clamp while the chart has no rendered samples.
413
+ const scrollMinTime = useDerivedValue(() =>
414
+ retainedMinTime.get() ?? historyFloor ?? liveEdge.get(),
415
+ );
416
+ return { retainedMinTime, scrollMinTime };
417
+ }
418
+
395
419
  function useLiveChartSeriesController(props: LiveChartSeriesProps) {
396
420
  const {
397
421
  series,
@@ -581,6 +605,7 @@ function useLiveChartSeriesController(props: LiveChartSeriesProps) {
581
605
  nowOverride,
582
606
  presentationTime,
583
607
  historyStartTime,
608
+ timeHorizon: props.timeHorizon,
584
609
  });
585
610
  const { layoutHeight, onLayout } = useCanvasLayout(engine);
586
611
  const linePaths = useMultiSeriesLinePaths(
@@ -657,7 +682,7 @@ function useLiveChartSeriesController(props: LiveChartSeriesProps) {
657
682
  }
658
683
  : undefined,
659
684
  scrubCfg?.clampToPlot ?? false,
660
- resolveScrubMarkerOptions(scrubCfg, markersSV),
685
+ resolveScrubMarkerOptions(scrubCfg, markersSV, engine.tipTime),
661
686
  axisScaleActive,
662
687
  timeScrollEnabled && scrollGestureMode === "axisDrag"
663
688
  ? Math.max(effectivePadding.bottom, AXIS_GRAB_MIN_PX)
@@ -679,26 +704,16 @@ function useLiveChartSeriesController(props: LiveChartSeriesProps) {
679
704
  markersActive,
680
705
  markerHitRadius,
681
706
  onMarkerPress,
682
- series,
707
+ engine.series,
683
708
  undefined, // lineData — multi-series anchors by seriesId
684
709
  true, // autostart
685
710
  false, // lineLinear — per-series curve handled in projection
686
711
  markerClusterCfg,
687
712
  );
688
713
 
689
- // Earliest retained time across all series — clamps how far the window pans
690
- // back, and the `onReachStart` reference. Falls back to the live edge (no
691
- // scrollable history) so panning is a no-op.
692
- const scrollMinTime = useDerivedValue(() => {
693
- const s = engine.series.get();
694
- let min = historyStartTime != null && Number.isFinite(historyStartTime)
695
- ? historyStartTime : Infinity;
696
- for (let i = 0; i < s.length; i++) {
697
- const d = s[i].data;
698
- if (d.length > 0 && d[0].time < min) min = d[0].time;
699
- }
700
- return min === Infinity ? engine.liveEdge.get() : min;
701
- });
714
+ const { retainedMinTime, scrollMinTime } = useSeriesHistoryBounds(
715
+ engine.series, engine.liveEdge, historyStartTime,
716
+ );
702
717
 
703
718
  const panScrollGesture = usePanScroll({
704
719
  engine,
@@ -736,7 +751,7 @@ function useLiveChartSeriesController(props: LiveChartSeriesProps) {
736
751
 
737
752
  useVisibleRange({
738
753
  engine,
739
- minTime: scrollMinTime,
754
+ minTime: retainedMinTime,
740
755
  onVisibleRangeChange,
741
756
  onReachStart,
742
757
  });
@@ -948,7 +963,6 @@ function SeriesChartStack({ model }: { model: LiveChartSeriesModel }) {
948
963
  markerGroupOpacity,
949
964
  overlayScrubFade,
950
965
  renderMarker,
951
- series,
952
966
  seriesOpacity,
953
967
  seriesIndicatorOpacity,
954
968
  emptyText,
@@ -1077,7 +1091,7 @@ function SeriesChartStack({ model }: { model: LiveChartSeriesModel }) {
1077
1091
  padding={effectivePadding}
1078
1092
  palette={palette}
1079
1093
  font={skiaFont}
1080
- series={series}
1094
+ series={engine.series}
1081
1095
  renderMarker={renderMarker}
1082
1096
  cluster={markerClusterCfg}
1083
1097
  />
@@ -1221,9 +1235,15 @@ function SeriesCustomConsumerOverlay({
1221
1235
  }: {
1222
1236
  model: LiveChartSeriesModel;
1223
1237
  }) {
1224
- const { engine, effectivePadding, renderOverlay } = model;
1238
+ const { engine, effectivePadding, renderOverlay, reveal } = model;
1225
1239
  const overlayContext = useChartOverlayContext(engine, effectivePadding);
1226
- return <ChartOverlayLayer render={renderOverlay!} context={overlayContext} />;
1240
+ return (
1241
+ <ChartOverlayLayer
1242
+ render={renderOverlay!}
1243
+ context={overlayContext}
1244
+ opacity={reveal.dotOpacity}
1245
+ />
1246
+ );
1227
1247
  }
1228
1248
 
1229
1249
  /** Keeps the extra fade mapper opt-in with the per-series tooltip itself. */
@@ -1420,7 +1440,6 @@ function SeriesNativeOverlays({ model }: { model: LiveChartSeriesModel }) {
1420
1440
  overlayScrubFade,
1421
1441
  engine,
1422
1442
  effectivePadding,
1423
- series,
1424
1443
  formatValue,
1425
1444
  seriesTooltipCfg,
1426
1445
  } = model;
@@ -1445,7 +1464,7 @@ function SeriesNativeOverlays({ model }: { model: LiveChartSeriesModel }) {
1445
1464
  renderMarker={renderMarker}
1446
1465
  engine={engine}
1447
1466
  padding={effectivePadding}
1448
- series={series}
1467
+ series={engine.series}
1449
1468
  cluster={markerClusterCfg}
1450
1469
  />
1451
1470
  ) : null}
@@ -15,7 +15,7 @@ import {
15
15
  type SharedValue,
16
16
  } from "react-native-reanimated";
17
17
  import { scheduleOnRN } from "react-native-worklets";
18
- import type { ChartEngineLayout } from "../core/useLiveChartEngine";
18
+ import type { MarkerEngineLayout } from "../core/useLiveChartEngine";
19
19
  import type { ChartPadding } from "../draw/line";
20
20
  import { usePathBuilder } from "../hooks/usePathBuilder";
21
21
  import {
@@ -129,6 +129,7 @@ function pushGroupCountBadge(
129
129
  */
130
130
  function ConnectorGlyph({
131
131
  marker,
132
+ markers,
132
133
  color,
133
134
  engine,
134
135
  padding,
@@ -138,21 +139,23 @@ function ConnectorGlyph({
138
139
  axisY,
139
140
  }: {
140
141
  marker: Marker;
142
+ markers: SharedValue<Marker[]>;
141
143
  color: string;
142
- engine: ChartEngineLayout;
144
+ engine: MarkerEngineLayout;
143
145
  padding: ChartPadding;
144
146
  seriesSV?: SharedValue<SeriesConfig[]>;
145
147
  lineDataSV?: SharedValue<LiveChartPoint[]>;
146
148
  lineLinear?: boolean;
147
149
  axisY: SharedValue<number>;
148
150
  }) {
149
- const { kind } = marker;
150
- const time = marker.time;
151
- const value = marker.value;
152
- const seriesId = marker.seriesId;
153
-
154
- const layout = useDerivedValue(() =>
155
- projectPoint(time, value, seriesId, {
151
+ const { id, kind } = marker;
152
+ // Snapshot identity controls the React tree. Read the current anchor on the
153
+ // UI thread, including same-ID edits and in-place SharedValue.modify updates.
154
+ const index = useDerivedValue(() => markers.get().findIndex(item => item.id === id));
155
+ const layout = useDerivedValue(() => {
156
+ const current = markers.get()[index.get()];
157
+ if (current?.id !== id || current.kind !== kind || !isConnectorMarker(current)) return null;
158
+ return projectPoint(current.time, current.value, current.seriesId, {
156
159
  canvasWidth: engine.canvasWidth.get(),
157
160
  canvasHeight: engine.canvasHeight.get(),
158
161
  padTop: padding.top,
@@ -160,23 +163,26 @@ function ConnectorGlyph({
160
163
  padLeft: padding.left,
161
164
  padRight: padding.right,
162
165
  timestamp: engine.timestamp.get(),
166
+ tipTime: engine.tipTime?.get(),
167
+ displaySeriesValues: engine.displaySeriesValues?.get(),
168
+ smoothRecordedTail: engine.smoothRecordedTail?.get(),
163
169
  displayWindow: engine.displayWindow.get(),
164
170
  displayMin: engine.displayMin.get(),
165
171
  displayMax: engine.displayMax.get(),
166
172
  series: seriesSV?.get(),
167
173
  lineData: lineDataSV?.get(),
168
174
  lineLinear,
169
- }),
170
- );
175
+ });
176
+ });
171
177
 
172
- const opacity = useDerivedValue(() => (layout.get().visible ? 1 : 0));
178
+ const opacity = useDerivedValue(() => (layout.get()?.visible ? 1 : 0));
173
179
 
174
180
  const glyphBuilder = usePathBuilder();
175
181
 
176
182
  const glyphPath = useDerivedValue(() => {
177
183
  const b = glyphBuilder.value;
178
184
  const l = layout.get();
179
- if (l.visible) {
185
+ if (l?.visible) {
180
186
  const x = l.x;
181
187
  const y = l.y;
182
188
  if (kind === "graduation") {
@@ -228,7 +234,7 @@ function ConnectorGlyph({
228
234
  */
229
235
  type MarkerOverlayProps = {
230
236
  markers: SharedValue<Marker[]>;
231
- engine: ChartEngineLayout;
237
+ engine: MarkerEngineLayout;
232
238
  padding: ChartPadding;
233
239
  palette: LiveChartPalette;
234
240
  font: SkFont;
@@ -432,6 +438,9 @@ function useMarkerOverlayModel({
432
438
  padLeft: padding.left,
433
439
  padRight: padding.right,
434
440
  timestamp: engine.timestamp.get(),
441
+ tipTime: engine.tipTime?.get(),
442
+ displaySeriesValues: engine.displaySeriesValues?.get(),
443
+ smoothRecordedTail: engine.smoothRecordedTail?.get(),
435
444
  displayWindow: engine.displayWindow.get(),
436
445
  displayMin: engine.displayMin.get(),
437
446
  displayMax: engine.displayMax.get(),
@@ -570,6 +579,7 @@ export function MarkerOverlay(props: MarkerOverlayProps) {
570
579
  <ConnectorGlyph
571
580
  key={m.id}
572
581
  marker={m}
582
+ markers={props.markers}
573
583
  color={m.color ?? defaultMarkerColor(m.kind, palette)}
574
584
  engine={engine}
575
585
  padding={padding}
@@ -17,6 +17,9 @@ import type {
17
17
  } from "../hooks/crosshairShared";
18
18
  import type { LiveChartPalette } from "../types";
19
19
 
20
+ /** Default dash for the horizontal level line. */
21
+ const LEVEL_DASH = [4, 4];
22
+
20
23
  /**
21
24
  * Scrub-action ("order ticket") overlay: the locked reticle (a horizontal price
22
25
  * level line + a faint vertical line crossing at the reticle) and the right-gutter
@@ -41,6 +44,9 @@ export function ScrubActionOverlay({
41
44
  lineColor,
42
45
  background,
43
46
  iconColor,
47
+ showVerticalLine = true,
48
+ levelDash = LEVEL_DASH,
49
+ levelStrokeWidth = 1,
44
50
  }: {
45
51
  lockActive: SharedValue<boolean>;
46
52
  lockX: SharedValue<number>;
@@ -55,6 +61,12 @@ export function ScrubActionOverlay({
55
61
  lineColor?: string;
56
62
  background?: string;
57
63
  iconColor?: string;
64
+ /** Draw the faint vertical line. Off when another crosshair already draws it. Default true. */
65
+ showVerticalLine?: boolean;
66
+ /** Dash intervals for the horizontal level line; omit for `[4, 4]`. */
67
+ levelDash?: number[];
68
+ /** Horizontal level line width in px. Default 1. */
69
+ levelStrokeWidth?: number;
58
70
  }) {
59
71
  const opacity = useDerivedValue(() => (lockActive.value ? 1 : 0), [lockActive]);
60
72
 
@@ -126,12 +138,19 @@ export function ScrubActionOverlay({
126
138
 
127
139
  return (
128
140
  <Group opacity={opacity}>
129
- <Line p1={hLeft} p2={hRight} color={levelColor} strokeWidth={1}>
130
- <DashPathEffect intervals={[4, 4]} />
131
- </Line>
132
- <Line p1={vTop} p2={vBottom} color={levelColor} strokeWidth={1}>
133
- <DashPathEffect intervals={[2, 4]} />
141
+ <Line
142
+ p1={hLeft}
143
+ p2={hRight}
144
+ color={levelColor}
145
+ strokeWidth={levelStrokeWidth}
146
+ >
147
+ {levelDash.length > 0 ? <DashPathEffect intervals={levelDash} /> : null}
134
148
  </Line>
149
+ {showVerticalLine ? (
150
+ <Line p1={vTop} p2={vBottom} color={levelColor} strokeWidth={1}>
151
+ <DashPathEffect intervals={[2, 4]} />
152
+ </Line>
153
+ ) : null}
135
154
 
136
155
  {/* Circular icon button (the action). */}
137
156
  <Group opacity={iconOpacity}>
@@ -35,6 +35,8 @@ export interface EngineTickMutable {
35
35
  * can clamp against the live edge and detect catch-up.
36
36
  */
37
37
  liveEdge: number;
38
+ /** Whether the viewport actually follows live after resolving navigation. */
39
+ following?: boolean;
38
40
  /**
39
41
  * Smoothed value at the visible window's right edge: the live value while
40
42
  * following, or the price at `viewEnd` while scrolled back. Lets a badge track
@@ -321,6 +323,7 @@ export function tickLiveChartEngineFrame(
321
323
  viewEnd != null &&
322
324
  (viewRange !== undefined || viewEnd >= firstDataTime) &&
323
325
  (viewEnd < liveEdge || input.allowFutureViewEnd === true);
326
+ state.following = !scrolledBack && !input.paused && (input.returnT == null || input.returnT >= 1);
324
327
  const canvasChanged =
325
328
  state.lastCanvasWidth !== input.canvasWidth ||
326
329
  state.lastCanvasHeight !== input.canvasHeight;
@@ -1,6 +1,7 @@
1
1
  import { MOTION_METRICS_DEFAULTS } from "../constants";
2
2
  import { lerp } from "../math/lerp";
3
3
  import { rangeAnimationSpeed } from "../math/rangeAnimation";
4
+ import { smoothstep } from "../math/squiggly";
4
5
  import type { SeriesRangeAnimationConfig, SeriesConfig } from "../types";
5
6
 
6
7
  export interface MultiEngineTickMutable {
@@ -10,6 +11,8 @@ export interface MultiEngineTickMutable {
10
11
  currentTime?: number;
11
12
  /** Unzoomed authoritative-history span, including buffer. */
12
13
  fullHistoryWindow?: number | null;
14
+ /** Presentation-only seconds added to the ordinary edge and width when drawing. */
15
+ horizonExtension?: number;
13
16
  /** Untransformed eased bounds, kept separate from presentation output. */
14
17
  fittedMin?: number;
15
18
  fittedMax?: number;
@@ -21,6 +24,8 @@ export interface MultiEngineTickMutable {
21
24
  * stays frozen when scrolled back (see {@link MultiEngineTickInput.viewEnd}).
22
25
  */
23
26
  liveEdge: number;
27
+ /** Whether the viewport actually follows live after resolving navigation. */
28
+ following?: boolean;
24
29
  displayValues: number[];
25
30
  /** Ease the newest recorded sample with its live tip, without editing history. */
26
31
  smoothRecordedTail?: boolean;
@@ -68,6 +73,8 @@ export interface MultiEngineTickInput {
68
73
  nowOverride?: number;
69
74
  /** UI-thread presentation head, with precedence over nowOverride/wall time. */
70
75
  presentationTime?: number;
76
+ timeHorizonAt?: number;
77
+ timeHorizonProgress?: number;
71
78
  /** Right-edge buffer as a fraction of the time window. */
72
79
  windowBuffer?: number;
73
80
  /** Right-edge buffer in seconds. Does not scale with the visible window. */
@@ -137,6 +144,7 @@ export function tickLiveChartSeriesEngineFrame(
137
144
  state.fullHistoryWindow = fullWindow;
138
145
  const liveWindow = input.viewWindow ?? fullWindow ?? input.timeWindow;
139
146
  const liveEdge = baseNow + buffer * liveWindow + bufferSeconds;
147
+ state.horizonExtension = 0;
140
148
  state.liveEdge = liveEdge;
141
149
  const viewEnd = input.viewEnd;
142
150
  // Earliest first-point time across visible series — the floor a frozen edge
@@ -160,6 +168,7 @@ export function tickLiveChartSeriesEngineFrame(
160
168
  viewEnd != null &&
161
169
  viewEnd >= firstDataTime &&
162
170
  (viewEnd < liveEdge || input.allowFutureViewEnd === true);
171
+ state.following = !scrolledBack && !input.paused && (input.returnT == null || input.returnT >= 1);
163
172
  state.smoothRecordedTail = !scrolledBack && input.presentationTime == null;
164
173
  if (scrolledBack) {
165
174
  state.timestamp = viewEnd;
@@ -202,8 +211,8 @@ export function tickLiveChartSeriesEngineFrame(
202
211
 
203
212
  // Pinch-zoom: ease toward the zoom override when set, else the configured
204
213
  // window (mirrors the single-series tick).
205
- const anchoredFollowing = fullWindow != null && input.viewWindow == null &&
206
- !scrolledBack && !input.paused && (input.returnT == null || input.returnT >= 1);
214
+ const unzoomedFollowing = state.following && input.viewWindow == null;
215
+ const anchoredFollowing = fullWindow != null && unzoomedFollowing;
207
216
  // Park the unzoomed width with a frozen edge. Resuming live restores the exact
208
217
  // anchored span; easing a growing target would continuously lose the start.
209
218
  const targetWindow = input.viewWindow ??
@@ -212,7 +221,16 @@ export function tickLiveChartSeriesEngineFrame(
212
221
  ? targetWindow
213
222
  : lerp(state.displayWindow, targetWindow, speed, input.dt);
214
223
 
215
- const winStart = state.timestamp - state.displayWindow;
224
+ const at = input.timeHorizonAt;
225
+ const progress = input.timeHorizonProgress ?? 0;
226
+ if (at != null && Number.isFinite(at) && at > liveEdge && Number.isFinite(progress) &&
227
+ progress > 0 && unzoomedFollowing) {
228
+ state.horizonExtension = (at - liveEdge) * smoothstep(progress);
229
+ }
230
+
231
+ // Fit against the ordinary left edge. Reconstructing it from the extended
232
+ // edge and width can round past a sample sitting exactly on the boundary.
233
+ const winStart = anchoredFollowing ? start! : state.timestamp - state.displayWindow;
216
234
  const range = state.displayMax - state.displayMin;
217
235
 
218
236
  // Historical edges use recorded values. An edge parked in or beyond the
@@ -263,6 +281,7 @@ export function tickLiveChartSeriesEngineFrame(
263
281
  // into the Y range are snapshotted out before that).
264
282
  let minTime = 0;
265
283
  let maxTime = 0;
284
+ const tipTime = Math.min(state.timestamp, baseNow);
266
285
  let dataMin = Infinity;
267
286
  let dataMax = -Infinity;
268
287
 
@@ -289,6 +308,8 @@ export function tickLiveChartSeriesEngineFrame(
289
308
  if (v < tMin) tMin = v;
290
309
  /* istanbul ignore next -- trivial min/max */
291
310
  if (v > tMax) tMax = v;
311
+ // Keep feed-clock tolerance for fitting, but label only samples the path can draw.
312
+ if (points[j].time > tipTime) continue;
292
313
  if (v < dataMin) {
293
314
  dataMin = v;
294
315
  minTime = points[j].time;
@@ -447,7 +468,7 @@ export function tickLiveChartSeriesEngineFrame(
447
468
  min: state.fittedMin,
448
469
  max: state.fittedMax,
449
470
  from: winStart,
450
- to: state.timestamp,
471
+ to: state.timestamp + state.horizonExtension,
451
472
  });
452
473
  if (
453
474
  result &&
@@ -253,6 +253,8 @@ export interface ResolvedScrubConfig {
253
253
  clampToPlot: boolean;
254
254
  /** Candle mode: quantize the scrub X to the hovered candle's center. */
255
255
  snapToCandles: boolean;
256
+ /** Free X/Y crosshair; null keeps the vertical-only crosshair. */
257
+ freeCrosshair: { formatTime: ((time: number) => string) | undefined } | null;
256
258
  }
257
259
 
258
260
  export interface ResolvedPerSeriesTooltipConfig {
@@ -1107,6 +1109,7 @@ const SCRUB_DEFAULTS: ResolvedScrubConfig = {
1107
1109
  hideOverlaysOnScrub: false,
1108
1110
  clampToPlot: false,
1109
1111
  snapToCandles: false,
1112
+ freeCrosshair: null,
1110
1113
  };
1111
1114
 
1112
1115
  const PER_SERIES_TOOLTIP_DEFAULTS: ResolvedPerSeriesTooltipConfig = {
@@ -1196,6 +1199,16 @@ export function resolveScrub(
1196
1199
  0,
1197
1200
  resolved.crosshairFadeDistance,
1198
1201
  );
1202
+ const freeCrosshair =
1203
+ typeof prop === "object" ? prop.freeCrosshair : undefined;
1204
+ resolved.freeCrosshair = freeCrosshair
1205
+ ? {
1206
+ formatTime:
1207
+ typeof freeCrosshair === "object"
1208
+ ? freeCrosshair.formatTime
1209
+ : undefined,
1210
+ }
1211
+ : null;
1199
1212
  }
1200
1213
  return resolved;
1201
1214
  }
@@ -163,6 +163,8 @@ export interface ChartEngineLayout {
163
163
  canvasWidth: SharedValue<number>;
164
164
  canvasHeight: SharedValue<number>;
165
165
  timestamp: SharedValue<number>;
166
+ /** Presented tip time, clamped to the viewport edge; absent uses timestamp. */
167
+ tipTime?: SharedValue<number>;
166
168
  }
167
169
 
168
170
  /**
@@ -190,6 +192,8 @@ export interface ChartEngineScroll {
190
192
  * the live edge. Written by the pan-scroll gesture; read by the engine tick.
191
193
  */
192
194
  viewEnd: SharedValue<number | null>;
195
+ /** Resolved live-follow state of the drawn frame. */
196
+ following: SharedValue<boolean>;
193
197
  /**
194
198
  * The right-edge time the engine would use if following live — advances each
195
199
  * frame even while {@link ChartEngineLayout.timestamp} is frozen by a pan.
@@ -256,10 +260,12 @@ export interface MultiEngineState
256
260
  /** Live-tail presentation only; source history and explicit replay stay exact. */
257
261
  smoothRecordedTail?: SharedValue<boolean>;
258
262
  seriesOpacities: SharedValue<number[]>;
259
- /** Presented tip time, clamped to the viewport edge; absent uses timestamp. */
260
- tipTime?: SharedValue<number>;
261
263
  }
262
264
 
265
+ /** Marker projections share the presented vertices used by multi-series paths. */
266
+ export type MarkerEngineLayout = ChartEngineLayout &
267
+ Partial<Pick<MultiEngineState, "displaySeriesValues" | "smoothRecordedTail">>;
268
+
263
269
  export type EngineState = SingleEngineState | MultiEngineState;
264
270
 
265
271
  /** Canvas, range, and animated live value (badge / value line). */
@@ -320,6 +326,7 @@ export interface EngineFrameRefs {
320
326
  viewWindowSmoothingSV?: SharedValue<boolean>;
321
327
  /** Receives the computed live edge each frame. Optional for callers/tests. */
322
328
  liveEdgeSV?: SharedValue<number>;
329
+ followingSV?: SharedValue<boolean>;
323
330
  /** Receives the smoothed right-edge value each frame. Optional for callers/tests. */
324
331
  edgeValueSV?: SharedValue<number>;
325
332
  /**
@@ -511,6 +518,7 @@ export function applyLiveChartEngineFrame(
511
518
  sv.displayWindow.value = state.displayWindow;
512
519
  sv.timestamp.value = state.timestamp;
513
520
  if (sv.liveEdgeSV) sv.liveEdgeSV.value = state.liveEdge;
521
+ if (sv.followingSV) sv.followingSV.value = state.following!;
514
522
  if (sv.edgeValueSV) sv.edgeValueSV.value = state.edgeValue;
515
523
  sv.extremaMinValue.value = state.extremaMinValue;
516
524
  sv.extremaMaxValue.value = state.extremaMaxValue;
@@ -729,6 +737,7 @@ export function useLiveChartEngine(
729
737
  const internalViewEnd = useSharedValue<number | null>(null);
730
738
  const viewEnd = viewport?.end ?? internalViewEnd;
731
739
  const liveEdge = useSharedValue(initialTimestamp);
740
+ const following = useSharedValue(!paused);
732
741
  const edgeValue = useSharedValue(0);
733
742
  // "Return to live" glide (see #164). When time-scroll is disabled while scrolled
734
743
  // back, the reaction below clears `viewEnd`, snapshots the frozen edge into
@@ -812,6 +821,7 @@ export function useLiveChartEngine(
812
821
  viewWindowSV: viewWindow,
813
822
  viewWindowSmoothingSV,
814
823
  liveEdgeSV: liveEdge,
824
+ followingSV: following,
815
825
  edgeValueSV: edgeValue,
816
826
  snapSV,
817
827
  modeSV,
@@ -871,6 +881,7 @@ export function useLiveChartEngine(
871
881
  timestamp,
872
882
  value,
873
883
  viewEnd,
884
+ following,
874
885
  viewWindow,
875
886
  viewWindowSmoothingSV,
876
887
  viewRange,
@@ -1139,6 +1150,7 @@ export function useLiveChartEngine(
1139
1150
  fitMax,
1140
1151
  returnT,
1141
1152
  returnFrom,
1153
+ following,
1142
1154
  liveEdge,
1143
1155
  edgeValue,
1144
1156
  extremaMinValue,