react-native-livechart 4.25.0 → 4.27.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 (125) 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/ReferenceLineOverlay.d.ts +4 -0
  9. package/dist/components/ReferenceLineOverlay.d.ts.map +1 -1
  10. package/dist/components/ReferenceValueBadge.d.ts +15 -0
  11. package/dist/components/ReferenceValueBadge.d.ts.map +1 -0
  12. package/dist/components/XAxisOverlay.d.ts +17 -0
  13. package/dist/components/XAxisOverlay.d.ts.map +1 -1
  14. package/dist/core/liveChartEngineTick.d.ts +6 -1
  15. package/dist/core/liveChartEngineTick.d.ts.map +1 -1
  16. package/dist/core/liveChartSeriesEngineTick.d.ts +4 -1
  17. package/dist/core/liveChartSeriesEngineTick.d.ts.map +1 -1
  18. package/dist/core/resolveConfig.d.ts +28 -1
  19. package/dist/core/resolveConfig.d.ts.map +1 -1
  20. package/dist/core/useLiveChartEngine.d.ts +10 -1
  21. package/dist/core/useLiveChartEngine.d.ts.map +1 -1
  22. package/dist/core/useLiveChartSeriesEngine.d.ts +5 -1
  23. package/dist/core/useLiveChartSeriesEngine.d.ts.map +1 -1
  24. package/dist/draw/grid.d.ts +2 -2
  25. package/dist/draw/line.d.ts +15 -1
  26. package/dist/draw/line.d.ts.map +1 -1
  27. package/dist/hooks/crosshairShared.d.ts +24 -1
  28. package/dist/hooks/crosshairShared.d.ts.map +1 -1
  29. package/dist/hooks/referenceBadgeFont.d.ts +5 -0
  30. package/dist/hooks/referenceBadgeFont.d.ts.map +1 -0
  31. package/dist/hooks/resolveChartLayout.d.ts +8 -0
  32. package/dist/hooks/resolveChartLayout.d.ts.map +1 -1
  33. package/dist/hooks/useBadge.d.ts +16 -1
  34. package/dist/hooks/useBadge.d.ts.map +1 -1
  35. package/dist/hooks/useChartSkiaFont.d.ts +1 -0
  36. package/dist/hooks/useChartSkiaFont.d.ts.map +1 -1
  37. package/dist/hooks/useCrosshair.d.ts +7 -2
  38. package/dist/hooks/useCrosshair.d.ts.map +1 -1
  39. package/dist/hooks/useCrosshairSeries.d.ts +4 -1
  40. package/dist/hooks/useCrosshairSeries.d.ts.map +1 -1
  41. package/dist/hooks/useLatestCallback.d.ts +6 -0
  42. package/dist/hooks/useLatestCallback.d.ts.map +1 -0
  43. package/dist/hooks/useMarkers.d.ts.map +1 -1
  44. package/dist/hooks/usePanScroll.d.ts +3 -1
  45. package/dist/hooks/usePanScroll.d.ts.map +1 -1
  46. package/dist/hooks/usePinchZoom.d.ts.map +1 -1
  47. package/dist/hooks/useReferenceDrag.d.ts +23 -7
  48. package/dist/hooks/useReferenceDrag.d.ts.map +1 -1
  49. package/dist/hooks/useReferenceLine.d.ts +24 -12
  50. package/dist/hooks/useReferenceLine.d.ts.map +1 -1
  51. package/dist/hooks/useReferenceLineGrouping.d.ts +19 -0
  52. package/dist/hooks/useReferenceLineGrouping.d.ts.map +1 -0
  53. package/dist/hooks/useReferenceLinePress.d.ts +4 -2
  54. package/dist/hooks/useReferenceLinePress.d.ts.map +1 -1
  55. package/dist/hooks/useReferenceTagStack.d.ts +31 -0
  56. package/dist/hooks/useReferenceTagStack.d.ts.map +1 -0
  57. package/dist/hooks/useScrubMarkers.d.ts +12 -0
  58. package/dist/hooks/useScrubMarkers.d.ts.map +1 -0
  59. package/dist/hooks/useXAxis.d.ts +1 -1
  60. package/dist/hooks/useXAxis.d.ts.map +1 -1
  61. package/dist/hooks/useYAxisScaleGesture.d.ts +34 -0
  62. package/dist/hooks/useYAxisScaleGesture.d.ts.map +1 -0
  63. package/dist/index.d.ts +1 -1
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/math/axisBadgeLayout.d.ts +16 -0
  66. package/dist/math/axisBadgeLayout.d.ts.map +1 -0
  67. package/dist/math/markers.d.ts +3 -0
  68. package/dist/math/markers.d.ts.map +1 -1
  69. package/dist/math/range.d.ts +1 -1
  70. package/dist/math/range.d.ts.map +1 -1
  71. package/dist/math/rangeAnimation.d.ts +4 -0
  72. package/dist/math/rangeAnimation.d.ts.map +1 -0
  73. package/dist/math/referenceDrag.d.ts +17 -5
  74. package/dist/math/referenceDrag.d.ts.map +1 -1
  75. package/dist/math/referenceGroup.d.ts +2 -2
  76. package/dist/math/referenceTagStack.d.ts +36 -0
  77. package/dist/math/referenceTagStack.d.ts.map +1 -0
  78. package/dist/math/scrubMarkers.d.ts +12 -0
  79. package/dist/math/scrubMarkers.d.ts.map +1 -0
  80. package/dist/types.d.ts +240 -30
  81. package/dist/types.d.ts.map +1 -1
  82. package/package.json +1 -1
  83. package/src/components/CustomReferenceLineOverlay.tsx +50 -8
  84. package/src/components/CustomTooltipOverlay.tsx +5 -1
  85. package/src/components/LiveChart.tsx +563 -200
  86. package/src/components/LiveChartSeries.tsx +117 -13
  87. package/src/components/ReferenceLineOverlay.tsx +62 -26
  88. package/src/components/ReferenceValueBadge.tsx +102 -0
  89. package/src/components/XAxisOverlay.tsx +104 -1
  90. package/src/core/liveChartEngineTick.ts +66 -10
  91. package/src/core/liveChartSeriesEngineTick.ts +55 -5
  92. package/src/core/resolveConfig.ts +95 -2
  93. package/src/core/useLiveChartEngine.ts +53 -11
  94. package/src/core/useLiveChartSeriesEngine.ts +11 -1
  95. package/src/draw/grid.ts +2 -2
  96. package/src/draw/line.ts +23 -1
  97. package/src/hooks/crosshairShared.ts +85 -1
  98. package/src/hooks/referenceBadgeFont.ts +35 -0
  99. package/src/hooks/resolveChartLayout.ts +17 -0
  100. package/src/hooks/useBadge.ts +44 -5
  101. package/src/hooks/useChartSkiaFont.ts +1 -1
  102. package/src/hooks/useCrosshair.ts +446 -300
  103. package/src/hooks/useCrosshairSeries.ts +29 -10
  104. package/src/hooks/useLatestCallback.ts +15 -0
  105. package/src/hooks/useMarkers.ts +51 -39
  106. package/src/hooks/usePanScroll.ts +155 -127
  107. package/src/hooks/usePinchZoom.ts +84 -63
  108. package/src/hooks/useReferenceDrag.ts +395 -146
  109. package/src/hooks/useReferenceLine.ts +453 -277
  110. package/src/hooks/useReferenceLineGrouping.ts +72 -0
  111. package/src/hooks/useReferenceLinePress.ts +121 -53
  112. package/src/hooks/useReferenceTagStack.ts +81 -0
  113. package/src/hooks/useScrubMarkers.ts +79 -0
  114. package/src/hooks/useXAxis.ts +11 -2
  115. package/src/hooks/useYAxisScaleGesture.ts +263 -0
  116. package/src/index.ts +11 -0
  117. package/src/math/axisBadgeLayout.ts +37 -0
  118. package/src/math/markers.ts +28 -3
  119. package/src/math/range.ts +35 -0
  120. package/src/math/rangeAnimation.ts +28 -0
  121. package/src/math/referenceDrag.ts +21 -4
  122. package/src/math/referenceGroup.ts +2 -2
  123. package/src/math/referenceTagStack.ts +112 -0
  124. package/src/math/scrubMarkers.ts +55 -0
  125. package/src/types.ts +246 -30
@@ -0,0 +1,55 @@
1
+ import type { Marker } from "../types";
2
+
3
+ export interface ScrubMarkerRange {
4
+ from: number;
5
+ to: number;
6
+ /** Candle buckets are [start, end); line proximity includes both edges. */
7
+ exclusiveEnd: boolean;
8
+ }
9
+
10
+ /** Timestamp matching deliberately ignores glyph offsets, Y, and clustering. */
11
+ export function matchScrubMarkers(
12
+ markers: Marker[],
13
+ range: ScrubMarkerRange | null,
14
+ ): Marker[] {
15
+ "worklet";
16
+ if (!range) return [];
17
+ return markers.filter(
18
+ (marker) => marker.time >= range.from &&
19
+ (range.exclusiveEnd ? marker.time < range.to : marker.time <= range.to),
20
+ );
21
+ }
22
+
23
+ /** Convert a horizontal touch tolerance to time using the drawn viewport. */
24
+ export function scrubMarkerRange(
25
+ time: number,
26
+ now: number,
27
+ window: number,
28
+ plotWidth: number,
29
+ radius: number,
30
+ candleMode: boolean,
31
+ candleTime: number | null,
32
+ candleWidth: number,
33
+ ): ScrubMarkerRange | null {
34
+ "worklet";
35
+ if (
36
+ !Number.isFinite(time) || time < 0 || !Number.isFinite(now) ||
37
+ !Number.isFinite(window) || window <= 0 ||
38
+ !Number.isFinite(plotWidth) || plotWidth <= 0
39
+ ) return null;
40
+ if (candleMode) {
41
+ if (
42
+ candleTime === null || !Number.isFinite(candleTime) ||
43
+ !Number.isFinite(candleWidth) || candleWidth <= 0
44
+ ) return null;
45
+ return { from: candleTime, to: candleTime + candleWidth, exclusiveEnd: true };
46
+ }
47
+ const start = now - window;
48
+ if (time < start || time > now) return null;
49
+ const tolerance = radius * window / plotWidth;
50
+ return {
51
+ from: Math.max(start, time - tolerance),
52
+ to: Math.min(now, time + tolerance),
53
+ exclusiveEnd: false,
54
+ };
55
+ }
package/src/types.ts CHANGED
@@ -77,6 +77,8 @@ export interface ReferenceLine {
77
77
  /**
78
78
  * Stable identifier for this line. Supply a unique value when `referenceLines`
79
79
  * may be reordered so the chart preserves the line's rendered identity.
80
+ * If this line is removed or moves to another index during a drag, that touch
81
+ * is cancelled without committing, even if the line later returns.
80
82
  */
81
83
  id?: string;
82
84
  /** Form A — the Y-axis value where the horizontal line is drawn. */
@@ -165,6 +167,15 @@ export interface ReferenceLine {
165
167
  * `position`. Supersedes the legacy `offAxisBadge`. Default off.
166
168
  */
167
169
  badge?: boolean | ReferenceLineBadgeConfig;
170
+ /**
171
+ * A separate Form-A price pill displaying `formatValue(value)` on the UI
172
+ * thread, including during a drag. `true` pins it inside the plot's right
173
+ * edge; `{ position: "axis" }` aligns it with the right price gutter (or the
174
+ * floating axis). Works without a name badge. Both tags pin off-screen and
175
+ * collapse together when grouped. Custom tag renderers replace both pills.
176
+ * Has no effect on series or bands. Default `false`.
177
+ */
178
+ valueBadge?: boolean | ReferenceLineValueBadgeConfig;
168
179
  /**
169
180
  * Legacy: when a Form-A `value` falls outside the visible plot, render a pinned
170
181
  * edge badge with a directional chevron instead of culling the off-screen line.
@@ -191,9 +202,24 @@ export interface ReferenceLine {
191
202
  * it controlled. No effect on bands / time bands. Default `false`.
192
203
  */
193
204
  draggable?: boolean;
205
+ /**
206
+ * Where along a draggable line a press may grab it: a canvas x-range in px,
207
+ * `[from, to]`, ends included — typically the span of a custom tag drawn with
208
+ * `renderReferenceLine` (measure it with `onLayout`; a left-pinned tag starts 2 px
209
+ * inside the plot's left edge). Omit to grab the line anywhere along it (the
210
+ * default). With a range, a pan, scrub or page scroll that merely starts near the
211
+ * line no longer moves it; a press inside the range grabs it as before (same Y
212
+ * reach). `from > to` makes the line ungrabbable. A JS value: leave a little
213
+ * slack for a tag that changes width (off-axis, a live price). Applies only to
214
+ * draggable Form-A lines.
215
+ */
216
+ grabRange?: [number, number];
194
217
  /**
195
218
  * Snap the dragged value to this increment (e.g. `0.01` for cents, `0.5` for a
196
- * tick size) so drops land on round levels. Omit for free dragging. Applies only
219
+ * tick size) so drops land on round levels. At the plot's edge the line is drawn
220
+ * and dropped on the nearest increment inside the visible range; dragged past
221
+ * the edge, the value the finger sets (and {@link onChange} reports) rounds
222
+ * outward, so the range can widen to it. Omit for free dragging. Applies only
197
223
  * while {@link draggable}.
198
224
  */
199
225
  snap?: number;
@@ -205,15 +231,18 @@ export interface ReferenceLine {
205
231
  */
206
232
  bounds?: [number, number];
207
233
  /**
208
- * Fired on the JS thread *while* dragging, each time the (snapped, clamped)
209
- * value changes. De-duplicated to value changes — not every frame. Form-A
210
- * draggable only.
234
+ * Fired on the JS thread *while* dragging, each time the finger moves the line
235
+ * to a new (snapped, clamped) value. De-duplicated to value changes — not every
236
+ * frame. When the range moves under a still finger the line follows it without
237
+ * firing this; on release it fires once more if the line ended elsewhere, with
238
+ * the value {@link onCommit} gets (its first call, if the finger never changed
239
+ * the value). Form-A draggable only.
211
240
  */
212
241
  onChange?: (value: number) => void;
213
242
  /**
214
243
  * Fired once on the JS thread when the drag ends (finger up), with the final
215
- * (snapped, clamped) value. Pair with a controlled `value` to persist the move.
216
- * Form-A draggable only.
244
+ * (snapped, clamped) value — the one under the finger. Pair with a controlled
245
+ * `value` to persist the move. Form-A draggable only.
217
246
  */
218
247
  onCommit?: (value: number) => void;
219
248
  /**
@@ -293,6 +322,15 @@ export interface ReferenceLineBadgeConfig extends BadgeStyleConfig {
293
322
  text?: boolean;
294
323
  }
295
324
 
325
+ /** Separate price pill for a horizontal reference line. Style defaults match
326
+ * the reference badge; the font falls back to the chart font. */
327
+ export interface ReferenceLineValueBadgeConfig extends BadgeStyleConfig {
328
+ /** `"right"`: inside the plot; `"axis"`: right price column, even when the live
329
+ * badge is hidden or placed left. A floating axis uses the canvas right edge.
330
+ * Default `"right"`. Placement is independent of the name badge. */
331
+ position?: "right" | "axis";
332
+ }
333
+
296
334
  /**
297
335
  * Context passed to a custom {@link LiveChartProps.renderReferenceLine} or
298
336
  * {@link LiveChartProps.renderOffAxisReferenceLine} (and their
@@ -317,6 +355,11 @@ export interface ReferenceLineRenderProps {
317
355
  valueStr: SharedValue<string>;
318
356
  /** Canvas Y pixel of the line, recomputed each frame (`-1` when not laid out). */
319
357
  y: SharedValue<number>;
358
+ /** Extra vertical displacement from reference-tag stacking, in canvas pixels.
359
+ * The chart applies it to the custom element automatically; `y` keeps its
360
+ * original projection. Use this to draw a connector, not a second transform.
361
+ * Zero when stacking is off (including LiveChartSeries). */
362
+ tagOffsetY: SharedValue<number>;
320
363
  /** Whether the value currently sits within the visible plot range. */
321
364
  inRange: SharedValue<boolean>;
322
365
  /**
@@ -330,16 +373,23 @@ export interface ReferenceLineRenderProps {
330
373
  }
331
374
 
332
375
  /**
333
- * Grouping behavior for reference lines (single-series). When enabled, Form-A
334
- * lines whose handles fall within {@link ReferenceLineGroupingConfig.radius} px of
335
- * each other collapse into a single count handle, so a cluster of nearby orders /
336
- * alerts reads as one tag instead of an unreadable pile. Pass `true` for defaults
337
- * or an object to tune the proximity radius.
376
+ * Tag collision behavior for single-series reference lines. `true` uses collapse
377
+ * mode, replacing nearby built-in tags with a count pill. Stack mode keeps each
378
+ * built-in or measured custom tag, separating overlapping horizontal columns
379
+ * while price strokes stay at their values. Hidden off-axis lines do not count.
338
380
  */
339
381
  export interface ReferenceLineGroupingConfig {
340
- /**
341
- * Collapse lines whose value-Y positions are within this many px of each other.
342
- * Default `18`.
382
+ /** `"collapse"` merges nearby tags into a count (default). `"stack"` keeps
383
+ * each price line and separates overlapping tags by their measured bounds.
384
+ * Custom tags participate in stack mode; separate horizontal columns pack
385
+ * independently. Single-series only. */
386
+ mode?: "collapse" | "stack";
387
+ /** Stack mode: keep tags clear of the visible live value badge. Default `true`.
388
+ * Best effort when there is insufficient plot height; ignored in collapse mode. */
389
+ avoidValueBadge?: boolean;
390
+ /**
391
+ * Collapse mode: proximity radius. Stack mode: minimum center-to-center gap;
392
+ * measured tag heights plus 2 px take precedence. Default `18`.
343
393
  */
344
394
  radius?: number;
345
395
  /**
@@ -412,7 +462,7 @@ export interface ChartSegment {
412
462
  labelPosition?: "left" | "right";
413
463
  }
414
464
 
415
- /** Per-instance grid-line styling for the horizontal value-axis grid. */
465
+ /** Grid-line styling for the horizontal value axis and optional xAxis.gridLines. */
416
466
  export interface GridStyleConfig {
417
467
  /** Stroke color. Defaults to palette `gridLine`. */
418
468
  color?: string;
@@ -697,6 +747,19 @@ export interface BadgeConfig extends BadgeStyleConfig {
697
747
  tail?: boolean;
698
748
  /** Which side of the chart the badge appears on. Default `"right"`. */
699
749
  position?: "right" | "left";
750
+ /**
751
+ * Where the value sits in the right-gutter pill. `"center"` centers it in the
752
+ * pill body. `"yAxisColumn"` lines it up with a right-anchored Y-axis label
753
+ * column ({@link YAxisConfig.labelRightMargin}): it starts at the labels'
754
+ * shared left X, and a value wider than every axis label ends at the
755
+ * column's right edge. The pill keeps its shape and the value stays within
756
+ * its `padX` padding (a value that doesn't fit there is centered), so the
757
+ * room on each side follows the right inset and `metrics.badge`. The value
758
+ * moves sideways when the column's width changes (a wider label entering or
759
+ * leaving the axis). Centered without that column on the right side, while
760
+ * the axis floats, and for a `"left"` badge. Default `"center"`.
761
+ */
762
+ textAlign?: "center" | "yAxisColumn";
700
763
  /**
701
764
  * When the chart is scrolled back (see `timeScroll`), move the live-price
702
765
  * indicators — the badge, the value line, and the live dot — to the price at
@@ -733,8 +796,28 @@ export interface VolumeConfig {
733
796
  opacity?: number;
734
797
  }
735
798
 
799
+ /** Built-in vertical drag on the price axis. Bounds affect gesture writes only. */
800
+ export interface YAxisScaleGestureConfig {
801
+ /** Smallest multiplier. Positive and finite. Default `0.25`. */
802
+ minScale?: number;
803
+ /** Largest multiplier. Positive and finite, raised to minScale if lower. Default `10`. */
804
+ maxScale?: number;
805
+ /** Vertical points per exponential step (e×). Positive and finite. Default `160`. */
806
+ dragDistance?: number;
807
+ /** Double-tap the axis to animate to `1` (clamped to the bounds). Default `true`. */
808
+ doubleTapReset?: boolean;
809
+ }
810
+
736
811
  /** Y-axis grid configuration. */
737
812
  export interface YAxisConfig {
813
+ /**
814
+ * Opt into vertical price-axis dragging: down widens the range, up zooms in.
815
+ * Uses the rendered axis gutter/label column on either side. Interactive
816
+ * markers and reference badges retain priority. Plot gestures are unchanged.
817
+ * Writes `yRangeScale` when supplied, otherwise an internal multiplier.
818
+ * `true` uses defaults; an object customizes bounds/reset. Default `false`.
819
+ */
820
+ scaleGesture?: boolean | YAxisScaleGestureConfig;
738
821
  /** Price-label side. For left placement, reserve the label gutter with insets.left.
739
822
  * Right-side float/labelRightMargin options do not affect left labels. Default "right". */
740
823
  side?: "left" | "right";
@@ -764,7 +847,8 @@ export interface YAxisConfig {
764
847
  /**
765
848
  * Place price labels in a shared left-aligned column whose right edge sits
766
849
  * this many pixels from the canvas edge. When omitted, labels keep the
767
- * default centered-gutter placement.
850
+ * default centered-gutter placement. To line the live badge's value up with
851
+ * the column, set {@link BadgeConfig.textAlign} to `"yAxisColumn"`.
768
852
  */
769
853
  labelRightMargin?: number;
770
854
  /**
@@ -847,8 +931,17 @@ export interface AxisLabelConfig {
847
931
 
848
932
  /** X-axis (time) configuration. */
849
933
  export interface XAxisConfig {
850
- /** Minimum pixel gap between time labels. Default `60`. */
934
+ /** Minimum pixel gap between time labels. Changes apply immediately, even while paused. Default `60`. */
851
935
  minGap?: number;
936
+ /**
937
+ * Vertical grid lines at the time-axis ticks, drawn behind the series in the
938
+ * same layer as the horizontal grid. Each line sits under a time label and
939
+ * fades with it. `true` = the {@link LiveChartCoreProps.gridStyle} look, or
940
+ * pass a `GridStyleConfig` to override fields of it (omitted fields fall back
941
+ * to `gridStyle`). Strokes stay inside the plot's horizontal bounds, including
942
+ * while a departing label fades into a gutter. Default `false`.
943
+ */
944
+ gridLines?: boolean | GridStyleConfig;
852
945
  }
853
946
 
854
947
  /**
@@ -952,8 +1045,26 @@ export interface PerSeriesTooltipConfig {
952
1045
  intersectionDotSize?: number;
953
1046
  }
954
1047
 
1048
+ /** Timestamp matching for marker details while scrubbing. */
1049
+ export interface ScrubMarkerConfig {
1050
+ /**
1051
+ * Horizontal distance in canvas px on either side of the crosshair in line
1052
+ * mode. Default `16`; negative values clamp to `0`. Candle mode instead
1053
+ * selects the hovered bucket's [time, time + candleWidth) interval.
1054
+ */
1055
+ radius?: number;
1056
+ }
1057
+
955
1058
  /** Crosshair scrub configuration. */
956
1059
  export interface ScrubConfig {
1060
+ /**
1061
+ * Include matching markers in `onScrub` and `LiveChart.renderTooltip`.
1062
+ * `true` uses a 16 px horizontal tolerance in line mode; an object tunes it.
1063
+ * Candle mode returns all markers in the hovered candle's time bucket.
1064
+ * Matches preserve input order and include stacked/collapsed members,
1065
+ * independent of glyph Y/offsets. Gaps select none. Default `false`.
1066
+ */
1067
+ markers?: boolean | ScrubMarkerConfig;
957
1068
  /** Show the value/time tooltip pill while scrubbing. Default `true`. */
958
1069
  tooltip?: boolean;
959
1070
  /**
@@ -1211,6 +1322,12 @@ export interface SelectionDotProps {
1211
1322
  * for the value/date to update on the UI thread too.
1212
1323
  */
1213
1324
  export interface TooltipRenderProps {
1325
+ /**
1326
+ * Markers matched by `scrub.markers`, including their `data`. Empty when
1327
+ * disabled, inactive, in a gap, or without a match. Updated on the UI thread;
1328
+ * bind in an animated component rather than reading during React render.
1329
+ */
1330
+ markers: SharedValue<Marker[]>;
1214
1331
  /**
1215
1332
  * Value under the crosshair; `null` when none. In line mode this is the
1216
1333
  * interpolated value at the scrub time; in candle mode it's the scrubbed
@@ -1494,7 +1611,7 @@ export interface Marker {
1494
1611
  * when `markerCluster: "stacked"` — e.g. buys `"below"`, sells `"above"`.
1495
1612
  */
1496
1613
  side?: MarkerSide;
1497
- /** Pass-through payload surfaced on `onMarkerPress`. */
1614
+ /** Pass-through payload surfaced on `onMarkerPress` and opt-in scrub matches. */
1498
1615
  data?: unknown;
1499
1616
  }
1500
1617
 
@@ -1827,6 +1944,11 @@ export interface ScrubSeriesValue {
1827
1944
 
1828
1945
  /** Base fields shared by single and multi-series scrub callback payloads. */
1829
1946
  export interface ScrubPointCore {
1947
+ /**
1948
+ * Matching markers (including `data`) when `scrub.markers` is enabled; `[]`
1949
+ * when none match. Omitted when disabled. See {@link ScrubConfig.markers}.
1950
+ */
1951
+ markers?: Marker[];
1830
1952
  /** Unix timestamp in seconds at the scrub position. */
1831
1953
  time: number;
1832
1954
  /** Interpolated value at the scrub position. */
@@ -2160,6 +2282,7 @@ export interface LiveChartHandle {
2160
2282
  /**
2161
2283
  * Reset built-in pinch/time-window zoom to the configured `timeWindow` and
2162
2284
  * clear the focal-point offset so the chart follows the live edge again.
2285
+ * On LiveChart with viewport, clears the supplied end/window shared values.
2163
2286
  * Safe to call when already reset. A paused chart remains paused.
2164
2287
  *
2165
2288
  * ```tsx
@@ -2258,6 +2381,25 @@ export interface LoadingConfig {
2258
2381
  axisLabels?: boolean;
2259
2382
  }
2260
2383
 
2384
+ /** Y-range easing shared by both charts, independent of value/window tracking. */
2385
+ export interface RangeAnimationConfig {
2386
+ /** Ease outward bounds instead of snapping. Default `false`. */
2387
+ animateExpansion?: boolean;
2388
+ /**
2389
+ * Fraction of the remaining gap closed per 60fps frame when a bound expands.
2390
+ * Inherits `smoothing`; only used with `animateExpansion: true`. Finite values
2391
+ * are clamped to 0..1; non-finite values inherit `smoothing`.
2392
+ */
2393
+ expansionSmoothing?: number;
2394
+ /**
2395
+ * Fraction of the remaining gap closed per 60fps frame when a bound contracts.
2396
+ * Inherits `smoothing`. Finite values are clamped to 0..1; non-finite values
2397
+ * inherit `smoothing`. While animated expansion moves toward a disjoint fit,
2398
+ * contraction is limited to the expansion speed so bounds cannot cross.
2399
+ */
2400
+ contractionSmoothing?: number;
2401
+ }
2402
+
2261
2403
  /** Props shared between `LiveChart` and `LiveChartSeries`. */
2262
2404
  export interface LiveChartCoreProps {
2263
2405
  /** Color scheme. Default `"dark"`. */
@@ -2324,6 +2466,14 @@ export interface LiveChartCoreProps {
2324
2466
  * `lerpSpeed`. Default `0.08`.
2325
2467
  */
2326
2468
  smoothing?: number;
2469
+ /**
2470
+ * Control Y-range expansion and contraction independently of `smoothing` for
2471
+ * value/window tracking. Omission preserves instant expansion and eased
2472
+ * contraction. Uses frame-rate-independent exponential easing, not a fixed
2473
+ * duration. `smoothing: 1`, explicit `snapKey` changes, static charts, and active
2474
+ * manual Y-scale dragging remain immediate. Axis-label fades use `metrics.grid`.
2475
+ */
2476
+ rangeAnimation?: RangeAnimationConfig;
2327
2477
  /**
2328
2478
  * Snap the framing to its target in a single frame whenever this key changes —
2329
2479
  * without giving up smooth live ticks. On a timeframe / dataset switch, the
@@ -2364,13 +2514,29 @@ export interface LiveChartCoreProps {
2364
2514
  * axes (prices, market caps).
2365
2515
  */
2366
2516
  maxValue?: number;
2517
+ /**
2518
+ * Smallest auto-fitted Y span, in data units. A narrower bounded fit widens
2519
+ * around its midpoint, giving near-flat data room for distinct grid labels
2520
+ * (e.g. pass a few multiples of the display precision). `nonNegative` and
2521
+ * `maxValue` shift the span; if both leave less room than the floor, the hard
2522
+ * bounds win. Manual `yRangeScale` zoom applies afterward and may go below
2523
+ * the floor. Usual range easing applies; static charts re-settle on changes.
2524
+ * Positive finite values only; invalid or overflowing floors are ignored.
2525
+ * Omit for no floor.
2526
+ */
2527
+ minRange?: number;
2367
2528
  /**
2368
2529
  * Live manual Y-range multiplier around the fitted midpoint (`1` = auto-fit).
2369
- * Drive it from a gesture (e.g. dragging the price axis) to stretch or
2530
+ * Enable `yAxis.scaleGesture` or drive it from your own gesture to stretch or
2370
2531
  * compress the price scale TradingView-style; the auto-fit keeps tracking
2371
2532
  * the visible window underneath. Values must be positive and finite; invalid
2372
2533
  * values fall back to `1`. Read on the UI thread each frame. Supported by
2373
- * both `LiveChart` and `LiveChartSeries`. Default `1`.
2534
+ * both `LiveChart` and `LiveChartSeries`. Static single-series charts also
2535
+ * re-settle when this SharedValue changes, without replacing data. Default `1`.
2536
+ * Series drawing is clipped vertically to the price plot; candle volume bars
2537
+ * remain outside that clip. Automatic volume-band reservation respects an
2538
+ * explicit bottom inset. The built-in axis gesture uses an internal multiplier
2539
+ * when this prop is omitted.
2374
2540
  *
2375
2541
  * @experimental
2376
2542
  */
@@ -2508,6 +2674,7 @@ export interface LiveChartCoreProps {
2508
2674
  * no longer passed — **glides** the window back to the live edge (a brief eased
2509
2675
  * animation, not an instant jump); it never stays frozen at the previous scroll
2510
2676
  * position. Tune or disable that glide with {@link returnToLive}.
2677
+ * On LiveChart with viewport, disabling gestures preserves the supplied state.
2511
2678
  *
2512
2679
  * `true` uses the default drag-to-scroll gesture (`"holdToScrub"`); pass a
2513
2680
  * {@link TimeScrollConfig} to pick the activation (`"holdToScrub"` or
@@ -2591,8 +2758,42 @@ export interface LiveChartCoreProps {
2591
2758
  line?: LineConfig;
2592
2759
  }
2593
2760
 
2761
+ /**
2762
+ * UI-thread scroll/zoom state adopted by a single-series {@link LiveChart}.
2763
+ * The app owns leadership and timestamp mapping; gestures write these same values.
2764
+ * @experimental
2765
+ */
2766
+ export interface ChartViewportControl {
2767
+ /** Right-edge unix timestamp in seconds; null follows this chart's live edge.
2768
+ * Honors times past live. An end before the first retained point falls back to live. */
2769
+ end: SharedValue<number | null>;
2770
+ /** Positive, finite visible width in seconds; null uses the timeWindow prop. */
2771
+ window: SharedValue<number | null>;
2772
+ }
2773
+
2774
+ /** External viewport state and optional behavior settings for {@link LiveChart}.
2775
+ * Pass an object to adopt its shared values; false/omitted uses private state.
2776
+ * @experimental
2777
+ */
2778
+ export interface ViewportConfig extends ChartViewportControl {
2779
+ /** Ease non-null window overrides using the chart's smoothing. Default true.
2780
+ * Set false on followers copying a leader's drawn width to avoid easing twice.
2781
+ * Null windows still ease back to timeWindow; Y-range/value smoothing is unchanged. */
2782
+ windowSmoothing?: boolean;
2783
+ }
2784
+
2594
2785
  /** Props for the single-series `LiveChart` component. */
2595
2786
  export interface LiveChartProps extends LiveChartCoreProps {
2787
+ /**
2788
+ * Adopt external UI-thread scroll/zoom state. Pan and pinch write the supplied
2789
+ * values; resetZoom() clears both. Non-null overrides survive timeWindow changes
2790
+ * and timeScroll being disabled. External writes work without enabling gestures
2791
+ * and wake autoSleep charts. Single-series line/candle only.
2792
+ * Pass a ViewportConfig object to enable; false/omitted uses private state.
2793
+ * Both shared values are required, so this prop has no true shorthand.
2794
+ * @experimental
2795
+ */
2796
+ viewport?: false | ViewportConfig;
2596
2797
  /** Area gradient fill under the line. `true` = defaults, or pass `GradientConfig`. Default `true`. */
2597
2798
  gradient?: boolean | GradientConfig;
2598
2799
  /**
@@ -2693,7 +2894,10 @@ export interface LiveChartProps extends LiveChartCoreProps {
2693
2894
  * but `scrub` / `scrubAction` stay available — they're on-demand touch gestures with
2694
2895
  * no per-frame cost, so a still chart is still scrubbable. May be toggled at runtime:
2695
2896
  * switching back to live restarts the suspended loops and catches up. Frame the data
2696
- * with `timeWindow` + `nowOverride` (see the historical-data-fill pattern). */
2897
+ * with `timeWindow` + `nowOverride` (see the historical-data-fill pattern). Data,
2898
+ * layout, `timeWindow`, and `nowOverride` changes re-settle without restarting the
2899
+ * loop. Entering static mode lands on the new window even when data and framing
2900
+ * change in the same render (for example, a recycled list cell). */
2697
2901
  static?: boolean;
2698
2902
  /**
2699
2903
  * Runtime gate for continuous frame work. Set this SharedValue to `false`
@@ -2734,8 +2938,20 @@ export interface LiveChartProps extends LiveChartCoreProps {
2734
2938
  * Single-series only.
2735
2939
  */
2736
2940
  renderOverlay?: (ctx: ChartOverlayContext) => ReactElement | null | undefined;
2737
- /** Called when the user scrubs the crosshair. `null` when scrub ends. */
2941
+ /**
2942
+ * JS-thread callback while scrubbing; `null` when scrub ends. With
2943
+ * `scrub.markers` enabled, includes matching markers and also sends `null`
2944
+ * when a valid point becomes unavailable (for example an unpriced gap).
2945
+ */
2738
2946
  onScrub?: (point: ScrubPoint | null) => void;
2947
+ /**
2948
+ * Called on the JS thread when the crosshair enters a different candle,
2949
+ * with a snapshot of its OHLC at entry. Re-entering a candle fires again;
2950
+ * ticks within the same candle do not. Called with `null` when the scrub
2951
+ * ends, enters a gap, or leaves candle mode. Idle in line mode. Unlike
2952
+ * {@link onScrub}, it does not stream per-frame candle updates.
2953
+ */
2954
+ onScrubCandleChange?: (candle: CandlePoint | null) => void;
2739
2955
  /**
2740
2956
  * Scrub-action ("order ticket") mode: tap to drop a locked crosshair, drag to
2741
2957
  * fine-tune a **price level**, then press the right-gutter action badge to fire
@@ -2788,14 +3004,12 @@ export interface LiveChartProps extends LiveChartCoreProps {
2788
3004
  ctx: ReferenceLineRenderProps,
2789
3005
  ) => ReactElement | null | undefined;
2790
3006
  /**
2791
- * Collapse Form-A reference lines whose handles sit near the same value into a
2792
- * single count handle (e.g. a stack of working orders at adjacent prices reads
2793
- * as one "×3" tag). `true` = defaults, `false`/omitted = off, or pass a
2794
- * {@link ReferenceLineGroupingConfig} to tune the proximity radius. Lines a
2795
- * {@link LiveChartProps.renderReferenceLine} or
2796
- * {@link LiveChartProps.renderOffAxisReferenceLine} owns are excluded (their
2797
- * custom tag draws itself), so the count reflects only collapsed built-in tags.
2798
- * Single-series only. Default off.
3007
+ * Resolve nearby Form-A tags. `true` uses the existing count-pill collapse;
3008
+ * `{ mode: "stack" }` separates built-in and custom tags without moving their
3009
+ * price lines. Stacking respects measured tag sizes, separate horizontal
3010
+ * columns, and the visible live value badge (opt out with `avoidValueBadge`).
3011
+ * Count-pill styling/format apply only to collapse mode. Single-series only.
3012
+ * Default off. See {@link ReferenceLineGroupingConfig}.
2799
3013
  */
2800
3014
  referenceLineGrouping?: boolean | ReferenceLineGroupingConfig;
2801
3015
  /**
@@ -2870,6 +3084,8 @@ export interface LiveChartSeriesProps extends LiveChartCoreProps {
2870
3084
  /**
2871
3085
  * Worklet callback fired on the UI thread each frame while scrubbing.
2872
3086
  * `null` when scrub ends. Update shared values directly — no bridge overhead.
3087
+ * With `scrub.markers` enabled, includes matching markers and also sends
3088
+ * `null` when a previously valid point becomes unavailable.
2873
3089
  *
2874
3090
  * ```ts
2875
3091
  * const scrubData = useSharedValue<ScrubPointMulti | null>(null);