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
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.
@@ -205,7 +216,10 @@ export interface ReferenceLine {
205
216
  grabRange?: [number, number];
206
217
  /**
207
218
  * Snap the dragged value to this increment (e.g. `0.01` for cents, `0.5` for a
208
- * 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
209
223
  * while {@link draggable}.
210
224
  */
211
225
  snap?: number;
@@ -214,18 +228,26 @@ export interface ReferenceLine {
214
228
  * can't be dragged past either end. Omit for unbounded (clamped only to the
215
229
  * visible range). Reaching a bound fires {@link onDragOut}. Applies only while
216
230
  * {@link draggable}.
231
+ *
232
+ * Pass a `SharedValue<[number, number]>` for a bound that follows a live value
233
+ * (e.g. a stop that can't cross the current price): the clamp and
234
+ * {@link onDragIn} / {@link onDragOut} read it on the UI thread, so moving it
235
+ * doesn't need a new `referenceLines` array or a re-render.
217
236
  */
218
- bounds?: [number, number];
237
+ bounds?: [number, number] | SharedValue<[number, number]>;
219
238
  /**
220
- * Fired on the JS thread *while* dragging, each time the (snapped, clamped)
221
- * value changes. De-duplicated to value changes — not every frame. Form-A
222
- * draggable only.
239
+ * Fired on the JS thread *while* dragging, each time the finger moves the line
240
+ * to a new (snapped, clamped) value. De-duplicated to value changes — not every
241
+ * frame. When the range moves under a still finger the line follows it without
242
+ * firing this; on release it fires once more if the line ended elsewhere, with
243
+ * the value {@link onCommit} gets (its first call, if the finger never changed
244
+ * the value). Form-A draggable only.
223
245
  */
224
246
  onChange?: (value: number) => void;
225
247
  /**
226
248
  * Fired once on the JS thread when the drag ends (finger up), with the final
227
- * (snapped, clamped) value. Pair with a controlled `value` to persist the move.
228
- * Form-A draggable only.
249
+ * (snapped, clamped) value — the one under the finger. Pair with a controlled
250
+ * `value` to persist the move. Form-A draggable only.
229
251
  */
230
252
  onCommit?: (value: number) => void;
231
253
  /**
@@ -305,6 +327,15 @@ export interface ReferenceLineBadgeConfig extends BadgeStyleConfig {
305
327
  text?: boolean;
306
328
  }
307
329
 
330
+ /** Separate price pill for a horizontal reference line. Style defaults match
331
+ * the reference badge; the font falls back to the chart font. */
332
+ export interface ReferenceLineValueBadgeConfig extends BadgeStyleConfig {
333
+ /** `"right"`: inside the plot; `"axis"`: right price column, even when the live
334
+ * badge is hidden or placed left. A floating axis uses the canvas right edge.
335
+ * Default `"right"`. Placement is independent of the name badge. */
336
+ position?: "right" | "axis";
337
+ }
338
+
308
339
  /**
309
340
  * Context passed to a custom {@link LiveChartProps.renderReferenceLine} or
310
341
  * {@link LiveChartProps.renderOffAxisReferenceLine} (and their
@@ -329,6 +360,11 @@ export interface ReferenceLineRenderProps {
329
360
  valueStr: SharedValue<string>;
330
361
  /** Canvas Y pixel of the line, recomputed each frame (`-1` when not laid out). */
331
362
  y: SharedValue<number>;
363
+ /** Extra vertical displacement from reference-tag stacking, in canvas pixels.
364
+ * The chart applies it to the custom element automatically; `y` keeps its
365
+ * original projection. Use this to draw a connector, not a second transform.
366
+ * Zero when stacking is off (including LiveChartSeries). */
367
+ tagOffsetY: SharedValue<number>;
332
368
  /** Whether the value currently sits within the visible plot range. */
333
369
  inRange: SharedValue<boolean>;
334
370
  /**
@@ -342,18 +378,23 @@ export interface ReferenceLineRenderProps {
342
378
  }
343
379
 
344
380
  /**
345
- * Grouping behavior for reference lines (single-series). When enabled, Form-A
346
- * lines whose handles fall within {@link ReferenceLineGroupingConfig.radius} px of
347
- * each other collapse into a single count handle, so a cluster of nearby orders /
348
- * alerts reads as one tag instead of an unreadable pile. Pass `true` for defaults
349
- * or an object to tune the proximity radius. Badged off-axis lines group at either
350
- * plot edge; off-axis lines with no badge are hidden and do not count. Custom tags
351
- * are excluded.
381
+ * Tag collision behavior for single-series reference lines. `true` uses collapse
382
+ * mode, replacing nearby built-in tags with a count pill. Stack mode keeps each
383
+ * built-in or measured custom tag, separating overlapping horizontal columns
384
+ * while price strokes stay at their values. Hidden off-axis lines do not count.
352
385
  */
353
386
  export interface ReferenceLineGroupingConfig {
354
- /**
355
- * Collapse lines whose value-Y positions are within this many px of each other.
356
- * Default `18`.
387
+ /** `"collapse"` merges nearby tags into a count (default). `"stack"` keeps
388
+ * each price line and separates overlapping tags by their measured bounds.
389
+ * Custom tags participate in stack mode; separate horizontal columns pack
390
+ * independently. Single-series only. */
391
+ mode?: "collapse" | "stack";
392
+ /** Stack mode: keep tags clear of the visible live value badge. Default `true`.
393
+ * Best effort when there is insufficient plot height; ignored in collapse mode. */
394
+ avoidValueBadge?: boolean;
395
+ /**
396
+ * Collapse mode: proximity radius. Stack mode: minimum center-to-center gap;
397
+ * measured tag heights plus 2 px take precedence. Default `18`.
357
398
  */
358
399
  radius?: number;
359
400
  /**
@@ -426,7 +467,7 @@ export interface ChartSegment {
426
467
  labelPosition?: "left" | "right";
427
468
  }
428
469
 
429
- /** Per-instance grid-line styling for the horizontal value-axis grid. */
470
+ /** Grid-line styling for the horizontal value axis and optional xAxis.gridLines. */
430
471
  export interface GridStyleConfig {
431
472
  /** Stroke color. Defaults to palette `gridLine`. */
432
473
  color?: string;
@@ -711,6 +752,19 @@ export interface BadgeConfig extends BadgeStyleConfig {
711
752
  tail?: boolean;
712
753
  /** Which side of the chart the badge appears on. Default `"right"`. */
713
754
  position?: "right" | "left";
755
+ /**
756
+ * Where the value sits in the right-gutter pill. `"center"` centers it in the
757
+ * pill body. `"yAxisColumn"` lines it up with a right-anchored Y-axis label
758
+ * column ({@link YAxisConfig.labelRightMargin}): it starts at the labels'
759
+ * shared left X, and a value wider than every axis label ends at the
760
+ * column's right edge. The pill keeps its shape and the value stays within
761
+ * its `padX` padding (a value that doesn't fit there is centered), so the
762
+ * room on each side follows the right inset and `metrics.badge`. The value
763
+ * moves sideways when the column's width changes (a wider label entering or
764
+ * leaving the axis). Centered without that column on the right side, while
765
+ * the axis floats, and for a `"left"` badge. Default `"center"`.
766
+ */
767
+ textAlign?: "center" | "yAxisColumn";
714
768
  /**
715
769
  * When the chart is scrolled back (see `timeScroll`), move the live-price
716
770
  * indicators — the badge, the value line, and the live dot — to the price at
@@ -747,8 +801,28 @@ export interface VolumeConfig {
747
801
  opacity?: number;
748
802
  }
749
803
 
804
+ /** Built-in vertical drag on the price axis. Bounds affect gesture writes only. */
805
+ export interface YAxisScaleGestureConfig {
806
+ /** Smallest multiplier. Positive and finite. Default `0.25`. */
807
+ minScale?: number;
808
+ /** Largest multiplier. Positive and finite, raised to minScale if lower. Default `10`. */
809
+ maxScale?: number;
810
+ /** Vertical points per exponential step (e×). Positive and finite. Default `160`. */
811
+ dragDistance?: number;
812
+ /** Double-tap the axis to animate to `1` (clamped to the bounds). Default `true`. */
813
+ doubleTapReset?: boolean;
814
+ }
815
+
750
816
  /** Y-axis grid configuration. */
751
817
  export interface YAxisConfig {
818
+ /**
819
+ * Opt into vertical price-axis dragging: down widens the range, up zooms in.
820
+ * Uses the rendered axis gutter/label column on either side. Interactive
821
+ * markers and reference badges retain priority. Plot gestures are unchanged.
822
+ * Writes `yRangeScale` when supplied, otherwise an internal multiplier.
823
+ * `true` uses defaults; an object customizes bounds/reset. Default `false`.
824
+ */
825
+ scaleGesture?: boolean | YAxisScaleGestureConfig;
752
826
  /** Price-label side. For left placement, reserve the label gutter with insets.left.
753
827
  * Right-side float/labelRightMargin options do not affect left labels. Default "right". */
754
828
  side?: "left" | "right";
@@ -778,7 +852,10 @@ export interface YAxisConfig {
778
852
  /**
779
853
  * Place price labels in a shared left-aligned column whose right edge sits
780
854
  * this many pixels from the canvas edge. When omitted, labels keep the
781
- * default centered-gutter placement.
855
+ * default centered-gutter placement. To line the live badge's value up with
856
+ * the column, set {@link BadgeConfig.textAlign} to `"yAxisColumn"`. Automatic
857
+ * gutters use actual tick widths, this margin, dot-effect outset and 6px
858
+ * clearance. Explicit right insets and badge reservations retain priority.
782
859
  */
783
860
  labelRightMargin?: number;
784
861
  /**
@@ -861,8 +938,17 @@ export interface AxisLabelConfig {
861
938
 
862
939
  /** X-axis (time) configuration. */
863
940
  export interface XAxisConfig {
864
- /** Minimum pixel gap between time labels. Default `60`. */
941
+ /** Minimum pixel gap between time labels. Changes apply immediately, even while paused. Default `60`. */
865
942
  minGap?: number;
943
+ /**
944
+ * Vertical grid lines at the time-axis ticks, drawn behind the series in the
945
+ * same layer as the horizontal grid. Each line sits under a time label and
946
+ * fades with it. `true` = the {@link LiveChartCoreProps.gridStyle} look, or
947
+ * pass a `GridStyleConfig` to override fields of it (omitted fields fall back
948
+ * to `gridStyle`). Strokes stay inside the plot's horizontal bounds, including
949
+ * while a departing label fades into a gutter. Default `false`.
950
+ */
951
+ gridLines?: boolean | GridStyleConfig;
866
952
  }
867
953
 
868
954
  /**
@@ -966,8 +1052,26 @@ export interface PerSeriesTooltipConfig {
966
1052
  intersectionDotSize?: number;
967
1053
  }
968
1054
 
1055
+ /** Timestamp matching for marker details while scrubbing. */
1056
+ export interface ScrubMarkerConfig {
1057
+ /**
1058
+ * Horizontal distance in canvas px on either side of the crosshair in line
1059
+ * mode. Default `16`; negative values clamp to `0`. Candle mode instead
1060
+ * selects the hovered bucket's [time, time + candleWidth) interval.
1061
+ */
1062
+ radius?: number;
1063
+ }
1064
+
969
1065
  /** Crosshair scrub configuration. */
970
1066
  export interface ScrubConfig {
1067
+ /**
1068
+ * Include matching markers in `onScrub` and `LiveChart.renderTooltip`.
1069
+ * `true` uses a 16 px horizontal tolerance in line mode; an object tunes it.
1070
+ * Candle mode returns all markers in the hovered candle's time bucket.
1071
+ * Matches preserve input order and include stacked/collapsed members,
1072
+ * independent of glyph Y/offsets. Gaps select none. Default `false`.
1073
+ */
1074
+ markers?: boolean | ScrubMarkerConfig;
971
1075
  /** Show the value/time tooltip pill while scrubbing. Default `true`. */
972
1076
  tooltip?: boolean;
973
1077
  /**
@@ -1225,6 +1329,12 @@ export interface SelectionDotProps {
1225
1329
  * for the value/date to update on the UI thread too.
1226
1330
  */
1227
1331
  export interface TooltipRenderProps {
1332
+ /**
1333
+ * Markers matched by `scrub.markers`, including their `data`. Empty when
1334
+ * disabled, inactive, in a gap, or without a match. Updated on the UI thread;
1335
+ * bind in an animated component rather than reading during React render.
1336
+ */
1337
+ markers: SharedValue<Marker[]>;
1228
1338
  /**
1229
1339
  * Value under the crosshair; `null` when none. In line mode this is the
1230
1340
  * interpolated value at the scrub time; in candle mode it's the scrubbed
@@ -1508,7 +1618,7 @@ export interface Marker {
1508
1618
  * when `markerCluster: "stacked"` — e.g. buys `"below"`, sells `"above"`.
1509
1619
  */
1510
1620
  side?: MarkerSide;
1511
- /** Pass-through payload surfaced on `onMarkerPress`. */
1621
+ /** Pass-through payload surfaced on `onMarkerPress` and opt-in scrub matches. */
1512
1622
  data?: unknown;
1513
1623
  }
1514
1624
 
@@ -1841,6 +1951,11 @@ export interface ScrubSeriesValue {
1841
1951
 
1842
1952
  /** Base fields shared by single and multi-series scrub callback payloads. */
1843
1953
  export interface ScrubPointCore {
1954
+ /**
1955
+ * Matching markers (including `data`) when `scrub.markers` is enabled; `[]`
1956
+ * when none match. Omitted when disabled. See {@link ScrubConfig.markers}.
1957
+ */
1958
+ markers?: Marker[];
1844
1959
  /** Unix timestamp in seconds at the scrub position. */
1845
1960
  time: number;
1846
1961
  /** Interpolated value at the scrub position. */
@@ -2164,7 +2279,9 @@ export interface ZoomConfig {
2164
2279
  minTimeWindow?: number;
2165
2280
  /**
2166
2281
  * Widest visible window in seconds (max zoom-out). Defaults to the full data
2167
- * span (you can zoom out to all retained history), never below `timeWindow`.
2282
+ * span (you can zoom out to all retained history), never below `timeWindow`
2283
+ * unless explicitly set. LiveChartSeries also includes
2284
+ * its anchored full-history span when historyStartTime is supplied.
2168
2285
  */
2169
2286
  maxTimeWindow?: number;
2170
2287
  }
@@ -2172,8 +2289,10 @@ export interface ZoomConfig {
2172
2289
  /** Imperative methods exposed by `LiveChart` and `LiveChartSeries`. */
2173
2290
  export interface LiveChartHandle {
2174
2291
  /**
2175
- * Reset built-in pinch/time-window zoom to the configured `timeWindow` and
2292
+ * Reset built-in pinch/time-window zoom to the configured `timeWindow`
2293
+ * (or LiveChartSeries historyStartTime span) and
2176
2294
  * clear the focal-point offset so the chart follows the live edge again.
2295
+ * On LiveChart with viewport, clears the supplied end/window shared values.
2177
2296
  * Safe to call when already reset. A paused chart remains paused.
2178
2297
  *
2179
2298
  * ```tsx
@@ -2291,6 +2410,21 @@ export interface RangeAnimationConfig {
2291
2410
  contractionSmoothing?: number;
2292
2411
  }
2293
2412
 
2413
+ /** Y-range easing and optional presentation transform for {@link LiveChartSeries}. */
2414
+ export interface SeriesRangeAnimationConfig extends RangeAnimationConfig {
2415
+ /**
2416
+ * UI-thread worklet applied after normal fitting/easing. Receives untransformed
2417
+ * display bounds and the visible Unix-second interval; may read SharedValues.
2418
+ * Returned finite, increasing bounds affect presentation only and never feed
2419
+ * back into fitting. Invalid results are ignored. Removing it restores the
2420
+ * untransformed range. Hard bounds are applied to the fit before this transform.
2421
+ */
2422
+ transform?: (range: { min: number; max: number; from: number; to: number }) => {
2423
+ min: number;
2424
+ max: number;
2425
+ };
2426
+ }
2427
+
2294
2428
  /** Props shared between `LiveChart` and `LiveChartSeries`. */
2295
2429
  export interface LiveChartCoreProps {
2296
2430
  /** Color scheme. Default `"dark"`. */
@@ -2405,13 +2539,29 @@ export interface LiveChartCoreProps {
2405
2539
  * axes (prices, market caps).
2406
2540
  */
2407
2541
  maxValue?: number;
2542
+ /**
2543
+ * Smallest auto-fitted Y span, in data units. A narrower bounded fit widens
2544
+ * around its midpoint, giving near-flat data room for distinct grid labels
2545
+ * (e.g. pass a few multiples of the display precision). `nonNegative` and
2546
+ * `maxValue` shift the span; if both leave less room than the floor, the hard
2547
+ * bounds win. Manual `yRangeScale` zoom applies afterward and may go below
2548
+ * the floor. Usual range easing applies; static charts re-settle on changes.
2549
+ * Positive finite values only; invalid or overflowing floors are ignored.
2550
+ * Omit for no floor.
2551
+ */
2552
+ minRange?: number;
2408
2553
  /**
2409
2554
  * Live manual Y-range multiplier around the fitted midpoint (`1` = auto-fit).
2410
- * Drive it from a gesture (e.g. dragging the price axis) to stretch or
2555
+ * Enable `yAxis.scaleGesture` or drive it from your own gesture to stretch or
2411
2556
  * compress the price scale TradingView-style; the auto-fit keeps tracking
2412
2557
  * the visible window underneath. Values must be positive and finite; invalid
2413
2558
  * values fall back to `1`. Read on the UI thread each frame. Supported by
2414
- * both `LiveChart` and `LiveChartSeries`. Default `1`.
2559
+ * both `LiveChart` and `LiveChartSeries`. Static single-series charts also
2560
+ * re-settle when this SharedValue changes, without replacing data. Default `1`.
2561
+ * Series drawing is clipped vertically to the price plot; candle volume bars
2562
+ * remain outside that clip. Automatic volume-band reservation respects an
2563
+ * explicit bottom inset. The built-in axis gesture uses an internal multiplier
2564
+ * when this prop is omitted.
2415
2565
  *
2416
2566
  * @experimental
2417
2567
  */
@@ -2421,8 +2571,12 @@ export interface LiveChartCoreProps {
2421
2571
  * points or committed candles. Default `"No data"`.
2422
2572
  */
2423
2573
  emptyText?: string;
2424
- /** Custom formatter for value labels (axes, badge, tooltips). Default `v => v.toFixed(2)`. */
2425
- formatValue?: (v: number) => string;
2574
+ /**
2575
+ * Worklet formatter for value labels. Y-axis ticks pass their interval in
2576
+ * source units as `tickStep`; badges, tooltips and layout samples omit it.
2577
+ * Existing one-argument formatters remain valid. Default `v => v.toFixed(2)`.
2578
+ */
2579
+ formatValue?: (v: number, tickStep?: number) => string;
2426
2580
  /** Custom formatter for time labels. Default renders `HH:MM:SS`. */
2427
2581
  formatTime?: (t: number) => string;
2428
2582
  /** Y-axis grid lines + labels. `true` = defaults, `false` = hidden, or pass `YAxisConfig`. Default `true`. */
@@ -2549,6 +2703,7 @@ export interface LiveChartCoreProps {
2549
2703
  * no longer passed — **glides** the window back to the live edge (a brief eased
2550
2704
  * animation, not an instant jump); it never stays frozen at the previous scroll
2551
2705
  * position. Tune or disable that glide with {@link returnToLive}.
2706
+ * On LiveChart with viewport, disabling gestures preserves the supplied state.
2552
2707
  *
2553
2708
  * `true` uses the default drag-to-scroll gesture (`"holdToScrub"`); pass a
2554
2709
  * {@link TimeScrollConfig} to pick the activation (`"holdToScrub"` or
@@ -2632,8 +2787,42 @@ export interface LiveChartCoreProps {
2632
2787
  line?: LineConfig;
2633
2788
  }
2634
2789
 
2790
+ /**
2791
+ * UI-thread scroll/zoom state adopted by a single-series {@link LiveChart}.
2792
+ * The app owns leadership and timestamp mapping; gestures write these same values.
2793
+ * @experimental
2794
+ */
2795
+ export interface ChartViewportControl {
2796
+ /** Right-edge unix timestamp in seconds; null follows this chart's live edge.
2797
+ * Honors times past live. An end before the first retained point falls back to live. */
2798
+ end: SharedValue<number | null>;
2799
+ /** Positive, finite visible width in seconds; null uses the timeWindow prop. */
2800
+ window: SharedValue<number | null>;
2801
+ }
2802
+
2803
+ /** External viewport state and optional behavior settings for {@link LiveChart}.
2804
+ * Pass an object to adopt its shared values; false/omitted uses private state.
2805
+ * @experimental
2806
+ */
2807
+ export interface ViewportConfig extends ChartViewportControl {
2808
+ /** Ease non-null window overrides using the chart's smoothing. Default true.
2809
+ * Set false on followers copying a leader's drawn width to avoid easing twice.
2810
+ * Null windows still ease back to timeWindow; Y-range/value smoothing is unchanged. */
2811
+ windowSmoothing?: boolean;
2812
+ }
2813
+
2635
2814
  /** Props for the single-series `LiveChart` component. */
2636
2815
  export interface LiveChartProps extends LiveChartCoreProps {
2816
+ /**
2817
+ * Adopt external UI-thread scroll/zoom state. Pan and pinch write the supplied
2818
+ * values; resetZoom() clears both. Non-null overrides survive timeWindow changes
2819
+ * and timeScroll being disabled. External writes work without enabling gestures
2820
+ * and wake autoSleep charts. Single-series line/candle only.
2821
+ * Pass a ViewportConfig object to enable; false/omitted uses private state.
2822
+ * Both shared values are required, so this prop has no true shorthand.
2823
+ * @experimental
2824
+ */
2825
+ viewport?: false | ViewportConfig;
2637
2826
  /** Area gradient fill under the line. `true` = defaults, or pass `GradientConfig`. Default `true`. */
2638
2827
  gradient?: boolean | GradientConfig;
2639
2828
  /**
@@ -2734,7 +2923,10 @@ export interface LiveChartProps extends LiveChartCoreProps {
2734
2923
  * but `scrub` / `scrubAction` stay available — they're on-demand touch gestures with
2735
2924
  * no per-frame cost, so a still chart is still scrubbable. May be toggled at runtime:
2736
2925
  * switching back to live restarts the suspended loops and catches up. Frame the data
2737
- * with `timeWindow` + `nowOverride` (see the historical-data-fill pattern). */
2926
+ * with `timeWindow` + `nowOverride` (see the historical-data-fill pattern). Data,
2927
+ * layout, `timeWindow`, and `nowOverride` changes re-settle without restarting the
2928
+ * loop. Entering static mode lands on the new window even when data and framing
2929
+ * change in the same render (for example, a recycled list cell). */
2738
2930
  static?: boolean;
2739
2931
  /**
2740
2932
  * Runtime gate for continuous frame work. Set this SharedValue to `false`
@@ -2775,8 +2967,20 @@ export interface LiveChartProps extends LiveChartCoreProps {
2775
2967
  * Single-series only.
2776
2968
  */
2777
2969
  renderOverlay?: (ctx: ChartOverlayContext) => ReactElement | null | undefined;
2778
- /** Called when the user scrubs the crosshair. `null` when scrub ends. */
2970
+ /**
2971
+ * JS-thread callback while scrubbing; `null` when scrub ends. With
2972
+ * `scrub.markers` enabled, includes matching markers and also sends `null`
2973
+ * when a valid point becomes unavailable (for example an unpriced gap).
2974
+ */
2779
2975
  onScrub?: (point: ScrubPoint | null) => void;
2976
+ /**
2977
+ * Called on the JS thread when the crosshair enters a different candle,
2978
+ * with a snapshot of its OHLC at entry. Re-entering a candle fires again;
2979
+ * ticks within the same candle do not. Called with `null` when the scrub
2980
+ * ends, enters a gap, or leaves candle mode. Idle in line mode. Unlike
2981
+ * {@link onScrub}, it does not stream per-frame candle updates.
2982
+ */
2983
+ onScrubCandleChange?: (candle: CandlePoint | null) => void;
2780
2984
  /**
2781
2985
  * Scrub-action ("order ticket") mode: tap to drop a locked crosshair, drag to
2782
2986
  * fine-tune a **price level**, then press the right-gutter action badge to fire
@@ -2829,14 +3033,12 @@ export interface LiveChartProps extends LiveChartCoreProps {
2829
3033
  ctx: ReferenceLineRenderProps,
2830
3034
  ) => ReactElement | null | undefined;
2831
3035
  /**
2832
- * Collapse Form-A reference lines whose handles sit near the same value into a
2833
- * single count handle (e.g. a stack of working orders at adjacent prices reads
2834
- * as one "×3" tag). `true` = defaults, `false`/omitted = off, or pass a
2835
- * {@link ReferenceLineGroupingConfig} to tune the proximity radius. Lines a
2836
- * {@link LiveChartProps.renderReferenceLine} or
2837
- * {@link LiveChartProps.renderOffAxisReferenceLine} owns are excluded (their
2838
- * custom tag draws itself), so the count reflects only collapsed built-in tags.
2839
- * Single-series only. Default off.
3036
+ * Resolve nearby Form-A tags. `true` uses the existing count-pill collapse;
3037
+ * `{ mode: "stack" }` separates built-in and custom tags without moving their
3038
+ * price lines. Stacking respects measured tag sizes, separate horizontal
3039
+ * columns, and the visible live value badge (opt out with `avoidValueBadge`).
3040
+ * Count-pill styling/format apply only to collapse mode. Single-series only.
3041
+ * Default off. See {@link ReferenceLineGroupingConfig}.
2840
3042
  */
2841
3043
  referenceLineGrouping?: boolean | ReferenceLineGroupingConfig;
2842
3044
  /**
@@ -2856,6 +3058,28 @@ export interface LiveChartProps extends LiveChartCoreProps {
2856
3058
 
2857
3059
  /** Props for the multi-series `LiveChartSeries` component. */
2858
3060
  export interface LiveChartSeriesProps extends LiveChartCoreProps {
3061
+ /**
3062
+ * UI-thread presentation clock in Unix seconds. Each frame reads this head;
3063
+ * undefined falls back to nowOverride or wall time. Paths/dots end at the
3064
+ * earlier of the viewport edge and head, leaving windowBuffer empty. Samples
3065
+ * after this head are excluded from paths and range fitting. Scrub time limits
3066
+ * and values use the same cutoff, including callback payloads and tooltip
3067
+ * interpolation. Degen bursts originate at the presented dot. No React
3068
+ * render is required for clock updates.
3069
+ */
3070
+ presentationTime?: SharedValue<number | undefined>;
3071
+ /**
3072
+ * Authoritative history start (Unix seconds). While following without a zoom
3073
+ * override, grows the window to keep this time at the left edge, including
3074
+ * `windowBuffer` (must be < 1). Pan/zoom overrides remain usable; resetZoom()
3075
+ * restores following. A non-finite or future start falls back to timeWindow.
3076
+ */
3077
+ historyStartTime?: number;
3078
+ /**
3079
+ * Shared-range easing plus an optional reversible UI-thread presentation
3080
+ * transform. See {@link SeriesRangeAnimationConfig}; recorded values remain unchanged.
3081
+ */
3082
+ rangeAnimation?: SeriesRangeAnimationConfig;
2859
3083
  /** Array of series definitions. Must be a SharedValue for UI-thread reads. */
2860
3084
  series: SharedValue<SeriesConfig[]>;
2861
3085
  /**
@@ -2911,6 +3135,8 @@ export interface LiveChartSeriesProps extends LiveChartCoreProps {
2911
3135
  /**
2912
3136
  * Worklet callback fired on the UI thread each frame while scrubbing.
2913
3137
  * `null` when scrub ends. Update shared values directly — no bridge overhead.
3138
+ * With `scrub.markers` enabled, includes matching markers and also sends
3139
+ * `null` when a previously valid point becomes unavailable.
2914
3140
  *
2915
3141
  * ```ts
2916
3142
  * const scrubData = useSharedValue<ScrubPointMulti | null>(null);