react-native-livechart 4.26.0 → 4.28.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 (142) hide show
  1. package/dist/components/CustomReferenceLineOverlay.d.ts +8 -1
  2. package/dist/components/CustomReferenceLineOverlay.d.ts.map +1 -1
  3. package/dist/components/CustomTooltipOverlay.d.ts +3 -2
  4. package/dist/components/CustomTooltipOverlay.d.ts.map +1 -1
  5. package/dist/components/LiveChart.d.ts +1 -1
  6. package/dist/components/LiveChart.d.ts.map +1 -1
  7. package/dist/components/LiveChartSeries.d.ts.map +1 -1
  8. package/dist/components/MultiSeriesDots.d.ts +1 -1
  9. package/dist/components/MultiSeriesDots.d.ts.map +1 -1
  10. package/dist/components/MultiSeriesValueLabels.d.ts +1 -1
  11. package/dist/components/MultiSeriesValueLabels.d.ts.map +1 -1
  12. package/dist/components/MultiSeriesValueLines.d.ts +1 -1
  13. package/dist/components/MultiSeriesValueLines.d.ts.map +1 -1
  14. package/dist/components/ReferenceLineOverlay.d.ts +4 -0
  15. package/dist/components/ReferenceLineOverlay.d.ts.map +1 -1
  16. package/dist/components/ReferenceValueBadge.d.ts +15 -0
  17. package/dist/components/ReferenceValueBadge.d.ts.map +1 -0
  18. package/dist/components/XAxisOverlay.d.ts +17 -0
  19. package/dist/components/XAxisOverlay.d.ts.map +1 -1
  20. package/dist/core/liveChartEngineTick.d.ts +4 -0
  21. package/dist/core/liveChartEngineTick.d.ts.map +1 -1
  22. package/dist/core/liveChartSeriesEngineTick.d.ts +15 -2
  23. package/dist/core/liveChartSeriesEngineTick.d.ts.map +1 -1
  24. package/dist/core/resolveConfig.d.ts +28 -1
  25. package/dist/core/resolveConfig.d.ts.map +1 -1
  26. package/dist/core/useLiveChartEngine.d.ts +9 -0
  27. package/dist/core/useLiveChartEngine.d.ts.map +1 -1
  28. package/dist/core/useLiveChartSeriesEngine.d.ts +18 -4
  29. package/dist/core/useLiveChartSeriesEngine.d.ts.map +1 -1
  30. package/dist/draw/grid.d.ts +6 -4
  31. package/dist/draw/grid.d.ts.map +1 -1
  32. package/dist/draw/line.d.ts +21 -3
  33. package/dist/draw/line.d.ts.map +1 -1
  34. package/dist/hooks/crosshairSeries.d.ts +2 -2
  35. package/dist/hooks/crosshairSeries.d.ts.map +1 -1
  36. package/dist/hooks/crosshairShared.d.ts +16 -1
  37. package/dist/hooks/crosshairShared.d.ts.map +1 -1
  38. package/dist/hooks/referenceBadgeFont.d.ts +5 -0
  39. package/dist/hooks/referenceBadgeFont.d.ts.map +1 -0
  40. package/dist/hooks/resolveChartLayout.d.ts +18 -2
  41. package/dist/hooks/resolveChartLayout.d.ts.map +1 -1
  42. package/dist/hooks/useBadge.d.ts +16 -1
  43. package/dist/hooks/useBadge.d.ts.map +1 -1
  44. package/dist/hooks/useChartSkiaFont.d.ts +1 -0
  45. package/dist/hooks/useChartSkiaFont.d.ts.map +1 -1
  46. package/dist/hooks/useCrosshair.d.ts +7 -2
  47. package/dist/hooks/useCrosshair.d.ts.map +1 -1
  48. package/dist/hooks/useCrosshairSeries.d.ts +6 -1
  49. package/dist/hooks/useCrosshairSeries.d.ts.map +1 -1
  50. package/dist/hooks/useLatestCallback.d.ts +6 -0
  51. package/dist/hooks/useLatestCallback.d.ts.map +1 -0
  52. package/dist/hooks/useMarkers.d.ts.map +1 -1
  53. package/dist/hooks/useMultiSeriesDegen.d.ts +1 -1
  54. package/dist/hooks/useMultiSeriesDegen.d.ts.map +1 -1
  55. package/dist/hooks/useMultiSeriesLinePaths.d.ts.map +1 -1
  56. package/dist/hooks/usePanScroll.d.ts +3 -1
  57. package/dist/hooks/usePanScroll.d.ts.map +1 -1
  58. package/dist/hooks/usePinchZoom.d.ts +7 -4
  59. package/dist/hooks/usePinchZoom.d.ts.map +1 -1
  60. package/dist/hooks/useReferenceDrag.d.ts +20 -5
  61. package/dist/hooks/useReferenceDrag.d.ts.map +1 -1
  62. package/dist/hooks/useReferenceLine.d.ts +24 -12
  63. package/dist/hooks/useReferenceLine.d.ts.map +1 -1
  64. package/dist/hooks/useReferenceLinePress.d.ts +4 -2
  65. package/dist/hooks/useReferenceLinePress.d.ts.map +1 -1
  66. package/dist/hooks/useReferenceTagStack.d.ts +31 -0
  67. package/dist/hooks/useReferenceTagStack.d.ts.map +1 -0
  68. package/dist/hooks/useScrubMarkers.d.ts +12 -0
  69. package/dist/hooks/useScrubMarkers.d.ts.map +1 -0
  70. package/dist/hooks/useXAxis.d.ts +1 -1
  71. package/dist/hooks/useXAxis.d.ts.map +1 -1
  72. package/dist/hooks/useYAxis.d.ts +1 -1
  73. package/dist/hooks/useYAxis.d.ts.map +1 -1
  74. package/dist/hooks/useYAxisLabelWidth.d.ts +6 -0
  75. package/dist/hooks/useYAxisLabelWidth.d.ts.map +1 -0
  76. package/dist/hooks/useYAxisScaleGesture.d.ts +34 -0
  77. package/dist/hooks/useYAxisScaleGesture.d.ts.map +1 -0
  78. package/dist/index.d.ts +1 -1
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/math/axisBadgeLayout.d.ts +16 -0
  81. package/dist/math/axisBadgeLayout.d.ts.map +1 -0
  82. package/dist/math/markers.d.ts +3 -0
  83. package/dist/math/markers.d.ts.map +1 -1
  84. package/dist/math/range.d.ts +1 -1
  85. package/dist/math/range.d.ts.map +1 -1
  86. package/dist/math/referenceLines.d.ts.map +1 -1
  87. package/dist/math/referenceTagStack.d.ts +36 -0
  88. package/dist/math/referenceTagStack.d.ts.map +1 -0
  89. package/dist/math/scrubMarkers.d.ts +12 -0
  90. package/dist/math/scrubMarkers.d.ts.map +1 -0
  91. package/dist/types.d.ts +262 -37
  92. package/dist/types.d.ts.map +1 -1
  93. package/package.json +1 -1
  94. package/src/components/CustomReferenceLineOverlay.tsx +50 -8
  95. package/src/components/CustomTooltipOverlay.tsx +5 -1
  96. package/src/components/LiveChart.tsx +580 -138
  97. package/src/components/LiveChartSeries.tsx +139 -19
  98. package/src/components/MultiSeriesDots.tsx +4 -2
  99. package/src/components/MultiSeriesValueLabels.tsx +4 -2
  100. package/src/components/MultiSeriesValueLines.tsx +4 -2
  101. package/src/components/ReferenceLineOverlay.tsx +62 -26
  102. package/src/components/ReferenceValueBadge.tsx +102 -0
  103. package/src/components/XAxisOverlay.tsx +104 -1
  104. package/src/core/liveChartEngineTick.ts +49 -4
  105. package/src/core/liveChartSeriesEngineTick.ts +107 -14
  106. package/src/core/resolveConfig.ts +103 -7
  107. package/src/core/useLiveChartEngine.ts +45 -9
  108. package/src/core/useLiveChartSeriesEngine.ts +47 -6
  109. package/src/draw/grid.ts +17 -13
  110. package/src/draw/line.ts +46 -5
  111. package/src/hooks/crosshairSeries.ts +37 -5
  112. package/src/hooks/crosshairShared.ts +56 -1
  113. package/src/hooks/referenceBadgeFont.ts +35 -0
  114. package/src/hooks/resolveChartLayout.ts +51 -3
  115. package/src/hooks/useBadge.ts +44 -5
  116. package/src/hooks/useChartSkiaFont.ts +1 -1
  117. package/src/hooks/useCrosshair.ts +444 -310
  118. package/src/hooks/useCrosshairSeries.ts +57 -20
  119. package/src/hooks/useLatestCallback.ts +15 -0
  120. package/src/hooks/useMarkers.ts +51 -39
  121. package/src/hooks/useMultiSeriesDegen.ts +10 -5
  122. package/src/hooks/useMultiSeriesLinePaths.ts +2 -0
  123. package/src/hooks/usePanScroll.ts +155 -127
  124. package/src/hooks/usePinchZoom.ts +94 -66
  125. package/src/hooks/useReferenceDrag.ts +409 -156
  126. package/src/hooks/useReferenceLine.ts +453 -277
  127. package/src/hooks/useReferenceLineGrouping.ts +1 -1
  128. package/src/hooks/useReferenceLinePress.ts +121 -53
  129. package/src/hooks/useReferenceTagStack.ts +81 -0
  130. package/src/hooks/useScrubMarkers.ts +79 -0
  131. package/src/hooks/useXAxis.ts +11 -2
  132. package/src/hooks/useYAxis.ts +1 -1
  133. package/src/hooks/useYAxisLabelWidth.ts +26 -0
  134. package/src/hooks/useYAxisScaleGesture.ts +263 -0
  135. package/src/index.ts +11 -0
  136. package/src/math/axisBadgeLayout.ts +37 -0
  137. package/src/math/markers.ts +28 -3
  138. package/src/math/range.ts +35 -0
  139. package/src/math/referenceLines.ts +5 -0
  140. package/src/math/referenceTagStack.ts +112 -0
  141. package/src/math/scrubMarkers.ts +55 -0
  142. package/src/types.ts +263 -37
@@ -10,7 +10,7 @@ import {
10
10
  import { scheduleOnRN } from "react-native-worklets";
11
11
  import type { ResolvedPerSeriesTooltipConfig } from "../core/resolveConfig";
12
12
  import type { MultiEngineState } from "../core/useLiveChartEngine";
13
- import { type ChartPadding } from "../draw/line";
13
+ import { lineTipX, type ChartPadding } from "../draw/line";
14
14
  import type { ScrubPointMulti } from "../types";
15
15
  import {
16
16
  computePerSeriesTooltipLayout,
@@ -37,6 +37,7 @@ import {
37
37
  resetDelayedPanGuard,
38
38
  shouldStartDelayedPan,
39
39
  } from "./delayedPanGuard";
40
+ import { useScrubMarkers, type ScrubMarkerOptions } from "./useScrubMarkers";
40
41
 
41
42
  /**
42
43
  * LiveChartSeries crosshair + scrub. The optional per-series tooltip is
@@ -73,9 +74,23 @@ export function useCrosshairSeries(
73
74
  * drags to those bounds. Default `false`.
74
75
  */
75
76
  clampToPlot = false,
77
+ markerOptions?: ScrubMarkerOptions,
78
+ /** Price-axis ownership also guards against stale native long-press events. */
79
+ axisScaleActive?: SharedValue<boolean>,
80
+ /** Bottom strip reserved for the time-axis drag gesture, in layout points. */
81
+ scrubBottomExclude = 0,
76
82
  ): CrosshairState {
77
- const scrubX = useSharedValue(-1);
83
+ const pointerX = useSharedValue(-1);
78
84
  const scrubActive = useSharedValue(false);
85
+ const scrubX = useDerivedValue(() => {
86
+ const x = pointerX.get();
87
+ const head = engine.tipTime?.get();
88
+ if (x < 0 || head === undefined) return x;
89
+ const end = engine.timestamp.get();
90
+ const window = engine.displayWindow.get();
91
+ if (head < end - window) return -1;
92
+ return Math.min(x, lineTipX(end, window, head, engine.canvasWidth.get(), padding));
93
+ });
79
94
  // Tracks whether the active scrub phase actually began, so a tap that never
80
95
  // activates doesn't emit a spurious onGestureEnd.
81
96
  const gestureStarted = useSharedValue(false);
@@ -96,22 +111,26 @@ export function useCrosshairSeries(
96
111
  const noScrollActive = useSharedValue(false);
97
112
  const scrollActiveSV = scrollActive ?? noScrollActive;
98
113
 
99
- const scrubTime = useDerivedValue(() =>
100
- computeScrubTime(
114
+ const scrubTime = useDerivedValue(() => {
115
+ const head = engine.tipTime?.get();
116
+ if (head !== undefined && head < engine.timestamp.get() - engine.displayWindow.get()) return -1;
117
+ return Math.min(head ?? Infinity, computeScrubTime(
101
118
  scrubActive.get(),
102
119
  scrubX.get(),
103
120
  padding,
104
121
  engine.canvasWidth.get(),
105
122
  engine.timestamp.get(),
106
123
  engine.displayWindow.get(),
107
- ),
108
- );
124
+ ));
125
+ });
109
126
 
110
127
  const scrubValue = useDerivedValue(() =>
111
128
  deriveScrubValueSeries(
112
129
  scrubActive.get(),
113
130
  scrubTime.get(),
114
131
  engine.series.get(),
132
+ engine.tipTime?.get(),
133
+ engine.displaySeriesValues.get(),
115
134
  ),
116
135
  );
117
136
 
@@ -169,6 +188,10 @@ export function useCrosshairSeries(
169
188
  onGestureEnd?.();
170
189
  }
171
190
 
191
+ const scrubMarkers = useScrubMarkers(
192
+ markerOptions, scrubActive, scrubTime, engine.timestamp, engine.displayWindow,
193
+ engine.canvasWidth, padding.left + padding.right,
194
+ );
172
195
  const hasOnScrub = onScrub != null;
173
196
  const hasOnGestureStart = onGestureStart != null;
174
197
  const hasOnGestureEnd = onGestureEnd != null;
@@ -182,7 +205,10 @@ export function useCrosshairSeries(
182
205
  const x = scrubX.get();
183
206
  const chartW = engine.canvasWidth.get() - padding.left - padding.right;
184
207
  if (chartW <= 0) return "__pending__";
185
- const r = interpolateSeriesAtTime(engine.series.get(), time);
208
+ if (time < 0) return "__pending__";
209
+ const r = interpolateSeriesAtTime(
210
+ engine.series.get(), time, engine.tipTime?.get(), engine.displaySeriesValues.get(),
211
+ );
186
212
  if (r.primary === null) return "__pending__";
187
213
  const dotY = computeScrubDotY(
188
214
  r.primary,
@@ -192,26 +218,33 @@ export function useCrosshairSeries(
192
218
  padding.top,
193
219
  padding.bottom,
194
220
  );
195
- return JSON.stringify({
196
- time,
197
- x,
198
- y: dotY,
199
- primary: r.primary,
200
- series: r.seriesValues,
201
- });
221
+ return {
222
+ point: JSON.stringify({
223
+ time,
224
+ x,
225
+ y: dotY,
226
+ primary: r.primary,
227
+ series: r.seriesValues,
228
+ }),
229
+ markers: markerOptions ? scrubMarkers.get() : undefined,
230
+ };
202
231
  },
203
232
  (curr, prev) => {
204
233
  "worklet";
205
234
  if (!hasOnScrub) return;
206
235
  if (curr === "__inactive__") {
207
- onScrub!(null);
236
+ if (curr !== prev) onScrub!(null);
208
237
  return;
209
238
  }
210
239
  if (curr === "__idle__" || curr === "__pending__") {
240
+ if (markerOptions && curr === "__pending__" && prev && typeof prev === "object") {
241
+ onScrub!(null);
242
+ }
211
243
  return;
212
244
  }
213
- if (curr === prev) return;
214
- const p = JSON.parse(curr) as {
245
+ const previous = typeof prev === "object" ? prev : null;
246
+ if (curr.point === previous?.point && curr.markers === previous?.markers) return;
247
+ const p = JSON.parse(curr.point) as {
215
248
  time: number;
216
249
  x: number;
217
250
  y: number;
@@ -224,6 +257,7 @@ export function useCrosshairSeries(
224
257
  x: p.x,
225
258
  y: p.y,
226
259
  seriesValues: p.series,
260
+ ...(markerOptions ? { markers: curr.markers } : {}),
227
261
  });
228
262
  },
229
263
  );
@@ -286,6 +320,7 @@ export function useCrosshairSeries(
286
320
  .onStart(
287
321
  /* istanbul ignore next */ (e) => {
288
322
  "worklet";
323
+ if (axisScaleActive?.get()) return;
289
324
  if (
290
325
  !shouldStartDelayedPan(
291
326
  panGestureDelay,
@@ -303,7 +338,7 @@ export function useCrosshairSeries(
303
338
  padding,
304
339
  engine.canvasWidth.get(),
305
340
  clampToPlot,
306
- scrubX,
341
+ pointerX,
307
342
  scrubActive,
308
343
  gestureStarted,
309
344
  );
@@ -313,13 +348,14 @@ export function useCrosshairSeries(
313
348
  .onUpdate(
314
349
  /* istanbul ignore next */ (e) => {
315
350
  "worklet";
351
+ if (axisScaleActive?.get()) return;
316
352
  if (!enabled) return;
317
353
  updatePlainScrub(
318
354
  e.x,
319
355
  padding,
320
356
  engine.canvasWidth.get(),
321
357
  clampToPlot,
322
- scrubX,
358
+ pointerX,
323
359
  scrubActive,
324
360
  );
325
361
  },
@@ -350,10 +386,11 @@ export function useCrosshairSeries(
350
386
  // Gate by touch-down position so outside starts fail before activation and
351
387
  // remain available to competing/parent gestures. Accepted pans keep tracking
352
388
  // outside because `shouldCancelWhenOutside(false)` is set above.
353
- const scrubHitSlop = resolveScrubHitSlop(padding, clampToPlot);
389
+ const scrubHitSlop = resolveScrubHitSlop(padding, clampToPlot, scrubBottomExclude);
354
390
  if (scrubHitSlop) gesture = gesture.hitSlop(scrubHitSlop);
355
391
 
356
392
  return {
393
+ scrubMarkers,
357
394
  scrubX,
358
395
  scrubActive,
359
396
  scrubTime,
@@ -0,0 +1,15 @@
1
+ import { useCallback, useLayoutEffect, useRef } from "react";
2
+
3
+ /** Stable JS-thread dispatcher for callbacks scheduled by gesture worklets.
4
+ * Commit the new callback in an effect; an abandoned render must not replace it.
5
+ * Never call this dispatcher directly from the UI thread — use scheduleOnRN.
6
+ */
7
+ export function useLatestCallback<Args extends unknown[], Result>(
8
+ callback: (...args: Args) => Result,
9
+ ): (...args: Args) => Result {
10
+ const latest = useRef(callback);
11
+ useLayoutEffect(() => {
12
+ latest.current = callback;
13
+ }, [callback]);
14
+ return useCallback((...args: Args) => latest.current(...args), []);
15
+ }
@@ -1,4 +1,4 @@
1
- import { useEffect, useRef } from "react";
1
+ import { useEffect, useMemo, useRef } from "react";
2
2
  import { Gesture } from "react-native-gesture-handler";
3
3
  import {
4
4
  useAnimatedReaction,
@@ -23,6 +23,8 @@ import type {
23
23
  SeriesConfig,
24
24
  } from "../types";
25
25
 
26
+ import { useLatestCallback } from "./useLatestCallback";
27
+
26
28
  const ANCHORED_CLUSTER: ResolvedMarkerCluster = {
27
29
  mode: "anchored",
28
30
  direction: "horizontal",
@@ -76,11 +78,12 @@ export function useMarkers(
76
78
  cacheRef.current = { a: [] as ProjectedMarker[], b: [] as ProjectedMarker[], tick: false };
77
79
  }
78
80
 
79
- const emitPress =
81
+ const emitPress = useLatestCallback(
80
82
  /* istanbul ignore next -- invoked only from the UI-thread tap worklet */
81
83
  (event: MarkerPressEvent | null) => {
82
84
  onMarkerPress?.(event);
83
- };
85
+ },
86
+ );
84
87
 
85
88
  const project =
86
89
  /* istanbul ignore next -- worklet runs on UI thread, not in Jest */ () => {
@@ -133,43 +136,52 @@ export function useMarkers(
133
136
  markerFrameCallback.setActive(legacyActive);
134
137
  }, [legacyActive, markerFrameCallback]);
135
138
 
136
- const tapGesture = Gesture.Tap().onEnd(
137
- /* istanbul ignore next -- gesture worklet runs on UI thread, not in Jest */ (
138
- e,
139
- ) => {
140
- "worklet";
141
- const proj = projected.get();
142
- const idx = nearestMarkerIndex(proj, e.x, e.y, hitRadius);
143
- if (idx < 0) {
144
- runOnJS(emitPress)(null);
145
- return;
146
- }
147
- const ms = markers.get();
148
- const m = ms[idx];
149
- const p = proj[idx];
150
- const isGrouped = p.isGrouped;
151
- // Collapsed cluster: surface the whole bucket so the consumer can list it.
152
- const members = isGrouped ? clusterMembers(ms, proj, idx) : undefined;
153
- runOnJS(emitPress)({
154
- marker: m,
155
- point: { x: p.x, y: p.y },
156
- index: idx,
157
- isGrouped,
158
- members,
159
- });
160
- },
161
- );
139
+ const { tapGesture, hitTest } = useMemo(() => {
140
+ const tapGesture = Gesture.Tap().onEnd(
141
+ /* istanbul ignore next -- gesture worklet runs on UI thread, not in Jest */ (
142
+ e,
143
+ ) => {
144
+ "worklet";
145
+ const proj = projected.get();
146
+ const idx = nearestMarkerIndex(proj, e.x, e.y, hitRadius);
147
+ if (idx < 0) {
148
+ runOnJS(emitPress)(null);
149
+ return;
150
+ }
151
+ const ms = markers.get();
152
+ const m = ms[idx];
153
+ const p = proj[idx];
154
+ const isGrouped = p.isGrouped;
155
+ // Collapsed cluster: surface the whole bucket so the consumer can list it.
156
+ const members = isGrouped ? clusterMembers(ms, proj, idx) : undefined;
157
+ runOnJS(emitPress)({
158
+ marker: m,
159
+ point: { x: p.x, y: p.y },
160
+ index: idx,
161
+ isGrouped,
162
+ members,
163
+ });
164
+ },
165
+ );
162
166
 
163
- // Lets a coexisting gesture (e.g. the scrub-action tap) defer to a marker
164
- // under the finger instead of acting on it.
165
- const hitTest =
166
- /* istanbul ignore next -- worklet, runs on the UI thread, not in Jest */ (
167
- x: number,
168
- y: number,
169
- ) => {
170
- "worklet";
171
- return nearestMarkerIndex(projected.get(), x, y, hitRadius) >= 0;
172
- };
167
+ // Lets a coexisting gesture (e.g. the scrub-action tap) defer to a marker
168
+ // under the finger instead of acting on it.
169
+ const hitTest =
170
+ /* istanbul ignore next -- worklet, runs on the UI thread, not in Jest */ (
171
+ x: number,
172
+ y: number,
173
+ ) => {
174
+ "worklet";
175
+ return nearestMarkerIndex(projected.get(), x, y, hitRadius) >= 0;
176
+ };
177
+
178
+ return { tapGesture, hitTest };
179
+ }, [
180
+ emitPress,
181
+ hitRadius,
182
+ markers,
183
+ projected,
184
+ ]);
173
185
 
174
186
  return { projected, tapGesture, hitTest };
175
187
  }
@@ -10,7 +10,7 @@ import { runOnJS } from "react-native-worklets";
10
10
  import { DEGEN_STRIDE } from "../constants";
11
11
  import type { ResolvedDegenConfig } from "../core/resolveConfig";
12
12
  import type { MultiEngineState } from "../core/useLiveChartEngine";
13
- import type { ChartPadding } from "../draw/line";
13
+ import { lineTipX, type ChartPadding } from "../draw/line";
14
14
  import { computeShake, spawnBurst, tickParticles } from "../math/degenTick";
15
15
  import { detectMomentum } from "../math/momentum";
16
16
  import type { DegenShakePayload } from "../types";
@@ -164,19 +164,24 @@ export function useMultiSeriesDegen(
164
164
 
165
165
  const cw = engine.canvasWidth.get();
166
166
  const ch = engine.canvasHeight.get();
167
- const canSpawn = cw >= 1 && ch >= 1;
167
+ const end = engine.timestamp.get();
168
+ const window = engine.displayWindow.get();
169
+ const head = engine.tipTime?.get() ?? end;
170
+ const ox = lineTipX(end, window, head, cw, padding);
171
+ const canSpawn = cw >= 1 && ch >= 1 && window > 0 &&
172
+ ox >= padding.left && ox <= cw - padding.right;
168
173
  const dMin = engine.displayMin.get();
169
174
  const dMax = engine.displayMax.get();
170
175
  const valRange = dMax - dMin;
171
176
  const chartH = ch - padding.top - padding.bottom;
172
- const ox = cw - padding.right;
173
177
  const allowDown = downSV.get() > 0.5;
174
178
 
175
179
  // Each visible series fires a burst off its own dot on a fresh swing.
176
180
  let firedDir = 0; // 0 none, 1 up, 2 down
177
181
  for (let i = 0; i < n; i++) {
178
- const visible = (ops[i] ?? 0) >= 0.5;
179
- const m = visible ? detectMomentum(s[i].data) : "flat";
182
+ const visible = (ops[i] ?? 0) >= 0.5 &&
183
+ s[i].data.length > 0 && s[i].data[0].time <= head;
184
+ const m = visible ? detectMomentum(s[i].data, 20, 0.12, head) : "flat";
180
185
  const code = m === "up" ? 1 : m === "down" ? 2 : 0;
181
186
  const prev = moms[i];
182
187
  moms[i] = code;
@@ -80,6 +80,8 @@ export function useMultiSeriesLinePaths(
80
80
  engine.canvasHeight.get(),
81
81
  padding,
82
82
  pool.ptsBuf,
83
+ false,
84
+ engine.tipTime?.get(),
83
85
  );
84
86
  const seriesTolerance = s[i].simplify ?? simplifyTolerance;
85
87
  const pts =