react-native-livechart 3.11.0 → 4.0.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 (138) hide show
  1. package/dist/components/BadgeOverlay.d.ts +9 -1
  2. package/dist/components/BadgeOverlay.d.ts.map +1 -1
  3. package/dist/components/ChartOverlayLayer.d.ts +19 -0
  4. package/dist/components/ChartOverlayLayer.d.ts.map +1 -0
  5. package/dist/components/CustomMarkerOverlay.d.ts +18 -6
  6. package/dist/components/CustomMarkerOverlay.d.ts.map +1 -1
  7. package/dist/components/CustomReferenceLineOverlay.d.ts +36 -0
  8. package/dist/components/CustomReferenceLineOverlay.d.ts.map +1 -0
  9. package/dist/components/CustomTooltipOverlay.d.ts +5 -2
  10. package/dist/components/CustomTooltipOverlay.d.ts.map +1 -1
  11. package/dist/components/DotOverlay.d.ts +7 -1
  12. package/dist/components/DotOverlay.d.ts.map +1 -1
  13. package/dist/components/LiveChart.d.ts.map +1 -1
  14. package/dist/components/LiveChartSeries.d.ts.map +1 -1
  15. package/dist/components/MarkerOverlay.d.ts +8 -3
  16. package/dist/components/MarkerOverlay.d.ts.map +1 -1
  17. package/dist/components/MultiSeriesDots.d.ts +4 -1
  18. package/dist/components/MultiSeriesDots.d.ts.map +1 -1
  19. package/dist/components/ReferenceLineGroupOverlay.d.ts +27 -0
  20. package/dist/components/ReferenceLineGroupOverlay.d.ts.map +1 -0
  21. package/dist/components/ReferenceLineOverlay.d.ts +25 -2
  22. package/dist/components/ReferenceLineOverlay.d.ts.map +1 -1
  23. package/dist/components/XAxisOverlay.d.ts +7 -1
  24. package/dist/components/XAxisOverlay.d.ts.map +1 -1
  25. package/dist/components/YAxisOverlay.d.ts +12 -1
  26. package/dist/components/YAxisOverlay.d.ts.map +1 -1
  27. package/dist/constants.d.ts +7 -0
  28. package/dist/constants.d.ts.map +1 -1
  29. package/dist/core/liveChartEngineTick.d.ts +29 -0
  30. package/dist/core/liveChartEngineTick.d.ts.map +1 -1
  31. package/dist/core/liveChartSeriesEngineTick.d.ts +18 -0
  32. package/dist/core/liveChartSeriesEngineTick.d.ts.map +1 -1
  33. package/dist/core/resolveConfig.d.ts +56 -2
  34. package/dist/core/resolveConfig.d.ts.map +1 -1
  35. package/dist/core/useLiveChartEngine.d.ts +58 -7
  36. package/dist/core/useLiveChartEngine.d.ts.map +1 -1
  37. package/dist/core/useLiveChartSeriesEngine.d.ts +8 -2
  38. package/dist/core/useLiveChartSeriesEngine.d.ts.map +1 -1
  39. package/dist/draw/grid.d.ts.map +1 -1
  40. package/dist/draw/markerAtlas.d.ts +20 -2
  41. package/dist/draw/markerAtlas.d.ts.map +1 -1
  42. package/dist/draw/volume.d.ts +25 -0
  43. package/dist/draw/volume.d.ts.map +1 -0
  44. package/dist/hooks/crosshairShared.d.ts +12 -6
  45. package/dist/hooks/crosshairShared.d.ts.map +1 -1
  46. package/dist/hooks/overlayScale.d.ts +22 -0
  47. package/dist/hooks/overlayScale.d.ts.map +1 -0
  48. package/dist/hooks/resolveChartLayout.d.ts +9 -0
  49. package/dist/hooks/resolveChartLayout.d.ts.map +1 -1
  50. package/dist/hooks/useBadge.d.ts +22 -1
  51. package/dist/hooks/useBadge.d.ts.map +1 -1
  52. package/dist/hooks/useCandlePaths.d.ts +6 -0
  53. package/dist/hooks/useCandlePaths.d.ts.map +1 -1
  54. package/dist/hooks/useChartOverlayContext.d.ts +45 -0
  55. package/dist/hooks/useChartOverlayContext.d.ts.map +1 -0
  56. package/dist/hooks/useChartPaths.d.ts +8 -1
  57. package/dist/hooks/useChartPaths.d.ts.map +1 -1
  58. package/dist/hooks/useCrosshair.d.ts +9 -2
  59. package/dist/hooks/useCrosshair.d.ts.map +1 -1
  60. package/dist/hooks/useLiveDot.d.ts +6 -1
  61. package/dist/hooks/useLiveDot.d.ts.map +1 -1
  62. package/dist/hooks/useMarkers.d.ts +12 -4
  63. package/dist/hooks/useMarkers.d.ts.map +1 -1
  64. package/dist/hooks/useMultiSeriesLinePaths.d.ts.map +1 -1
  65. package/dist/hooks/usePanScroll.d.ts +82 -0
  66. package/dist/hooks/usePanScroll.d.ts.map +1 -0
  67. package/dist/hooks/usePinchZoom.d.ts +74 -0
  68. package/dist/hooks/usePinchZoom.d.ts.map +1 -0
  69. package/dist/hooks/useReferenceDrag.d.ts +24 -0
  70. package/dist/hooks/useReferenceDrag.d.ts.map +1 -0
  71. package/dist/hooks/useReferenceLine.d.ts +23 -4
  72. package/dist/hooks/useReferenceLine.d.ts.map +1 -1
  73. package/dist/hooks/useReferenceLinePress.d.ts +5 -1
  74. package/dist/hooks/useReferenceLinePress.d.ts.map +1 -1
  75. package/dist/hooks/useVisibleRange.d.ts +39 -0
  76. package/dist/hooks/useVisibleRange.d.ts.map +1 -0
  77. package/dist/index.d.ts +2 -1
  78. package/dist/index.d.ts.map +1 -1
  79. package/dist/math/markerCluster.d.ts +47 -0
  80. package/dist/math/markerCluster.d.ts.map +1 -0
  81. package/dist/math/markers.d.ts +15 -0
  82. package/dist/math/markers.d.ts.map +1 -1
  83. package/dist/math/referenceDrag.d.ts +24 -0
  84. package/dist/math/referenceDrag.d.ts.map +1 -0
  85. package/dist/math/referenceGroup.d.ts +31 -0
  86. package/dist/math/referenceGroup.d.ts.map +1 -0
  87. package/dist/math/referenceLines.d.ts +33 -7
  88. package/dist/math/referenceLines.d.ts.map +1 -1
  89. package/dist/types.d.ts +512 -21
  90. package/dist/types.d.ts.map +1 -1
  91. package/package.json +1 -1
  92. package/src/components/BadgeOverlay.tsx +26 -1
  93. package/src/components/ChartOverlayLayer.tsx +32 -0
  94. package/src/components/CustomMarkerOverlay.tsx +153 -53
  95. package/src/components/CustomReferenceLineOverlay.tsx +250 -0
  96. package/src/components/CustomTooltipOverlay.tsx +27 -7
  97. package/src/components/DotOverlay.tsx +9 -0
  98. package/src/components/LiveChart.tsx +561 -34
  99. package/src/components/LiveChartSeries.tsx +110 -5
  100. package/src/components/MarkerOverlay.tsx +100 -6
  101. package/src/components/MultiSeriesDots.tsx +12 -3
  102. package/src/components/ReferenceLineGroupOverlay.tsx +207 -0
  103. package/src/components/ReferenceLineOverlay.tsx +105 -32
  104. package/src/components/XAxisOverlay.tsx +9 -2
  105. package/src/components/YAxisOverlay.tsx +48 -26
  106. package/src/constants.ts +10 -0
  107. package/src/core/liveChartEngineTick.ts +81 -8
  108. package/src/core/liveChartSeriesEngineTick.ts +50 -9
  109. package/src/core/resolveConfig.ts +122 -1
  110. package/src/core/useLiveChartEngine.ts +103 -10
  111. package/src/core/useLiveChartSeriesEngine.ts +26 -3
  112. package/src/draw/grid.ts +13 -1
  113. package/src/draw/markerAtlas.ts +117 -3
  114. package/src/draw/volume.ts +190 -0
  115. package/src/hooks/crosshairShared.ts +37 -9
  116. package/src/hooks/overlayScale.ts +59 -0
  117. package/src/hooks/resolveChartLayout.ts +33 -0
  118. package/src/hooks/useBadge.ts +89 -21
  119. package/src/hooks/useCandlePaths.ts +104 -7
  120. package/src/hooks/useChartOverlayContext.ts +93 -0
  121. package/src/hooks/useChartPaths.ts +14 -1
  122. package/src/hooks/useCrosshair.ts +29 -2
  123. package/src/hooks/useLiveDot.ts +16 -5
  124. package/src/hooks/useMarkers.ts +43 -11
  125. package/src/hooks/useMultiSeriesLinePaths.ts +2 -1
  126. package/src/hooks/usePanScroll.ts +253 -0
  127. package/src/hooks/usePinchZoom.ts +189 -0
  128. package/src/hooks/useReferenceDrag.ts +254 -0
  129. package/src/hooks/useReferenceLine.ts +56 -9
  130. package/src/hooks/useReferenceLinePress.ts +16 -2
  131. package/src/hooks/useVisibleRange.ts +119 -0
  132. package/src/index.ts +17 -1
  133. package/src/math/markerCluster.ts +214 -0
  134. package/src/math/markers.ts +54 -9
  135. package/src/math/referenceDrag.ts +66 -0
  136. package/src/math/referenceGroup.ts +65 -0
  137. package/src/math/referenceLines.ts +76 -19
  138. package/src/types.ts +532 -21
package/dist/types.d.ts CHANGED
@@ -56,6 +56,15 @@ export interface ReferenceLine {
56
56
  strokeWidth?: number;
57
57
  /** Dash pattern as `[dashLength, gapLength]` in pixels (line stroke + band border). */
58
58
  intervals?: [number, number];
59
+ /**
60
+ * Span the **full chart width** — edge to edge through the Y-axis gutter, not
61
+ * clipped at the plot's right edge — so the line/band visually connects to its
62
+ * value on the axis (like a price tag). Only the line/band extends; any
63
+ * `label`/`badge` stays anchored inside the plot. For a Form-A line with a
64
+ * `badge`, the full-width line replaces the dashed connector. No effect on a
65
+ * vertical time band. Default `false` (stops at the plot edge). Form A / B.
66
+ */
67
+ fullWidth?: boolean;
59
68
  /** Line / band color override. Defaults to palette `refLine`. */
60
69
  color?: string;
61
70
  /** Fill opacity for a value / time band (0–1). Default `0.16`. */
@@ -103,16 +112,103 @@ export interface ReferenceLine {
103
112
  badgeBorderColor?: string;
104
113
  /** Badge pill corner radius in pixels. Default `5`. (Fallback for `badge.radius`.) */
105
114
  badgeRadius?: number;
115
+ /**
116
+ * Make this Form-A line **draggable** along the Y-axis — grab its handle / badge
117
+ * and drag to set a new value (a working-order price, alert level, or target).
118
+ * The line tracks the finger on the UI thread; {@link onChange} / {@link onCommit}
119
+ * report the value to JS. The line is *uncontrolled* by default (it stays where
120
+ * you drop it); pair `onCommit` with writing the value back into `value` to make
121
+ * it controlled. No effect on bands / time bands. Default `false`.
122
+ */
123
+ draggable?: boolean;
124
+ /**
125
+ * Snap the dragged value to this increment (e.g. `0.01` for cents, `0.5` for a
126
+ * tick size) so drops land on round levels. Omit for free dragging. Applies only
127
+ * while {@link draggable}.
128
+ */
129
+ snap?: number;
130
+ /**
131
+ * Hard-clamp the draggable value to `[min, max]` in Y-axis units — the line
132
+ * can't be dragged past either end. Omit for unbounded (clamped only to the
133
+ * visible range). Reaching a bound fires {@link onDragOut}. Applies only while
134
+ * {@link draggable}.
135
+ */
136
+ bounds?: [number, number];
137
+ /**
138
+ * Fired on the JS thread *while* dragging, each time the (snapped, clamped)
139
+ * value changes. De-duplicated to value changes — not every frame. Form-A
140
+ * draggable only.
141
+ */
142
+ onChange?: (value: number) => void;
143
+ /**
144
+ * Fired once on the JS thread when the drag ends (finger up), with the final
145
+ * (snapped, clamped) value. Pair with a controlled `value` to persist the move.
146
+ * Form-A draggable only.
147
+ */
148
+ onCommit?: (value: number) => void;
149
+ /**
150
+ * Fired on the JS thread when the line's value crosses **into** its watched
151
+ * interval — the visible Y-range, or {@link bounds} when set. Triggers from
152
+ * dragging *or* the axis rescaling under a fixed value (e.g. a target scrolling
153
+ * back into view). Edge-triggered: once per crossing. Form-A only.
154
+ */
155
+ onDragIn?: (value: number) => void;
156
+ /**
157
+ * Fired on the JS thread when the line's value crosses **out of** its watched
158
+ * interval (the visible Y-range, or {@link bounds}) — dragged/scrolled off-screen
159
+ * or pinned at a bound. Edge-triggered: once per crossing. Form-A only.
160
+ */
161
+ onDragOut?: (value: number) => void;
162
+ }
163
+ /**
164
+ * Shared **style & shape** knobs for every badge pill — the value `badge`
165
+ * ({@link BadgeConfig}), reference-line badges ({@link ReferenceLineBadgeConfig}),
166
+ * and the grouping count pill. Each badge interface extends this and adds its own
167
+ * anchor (`position`) / content fields. Unset values fall back to that badge's own
168
+ * defaults (documented on each interface). One source of truth so every badge is
169
+ * configured identically.
170
+ */
171
+ export interface BadgeStyleConfig {
172
+ /** Pill background color. */
173
+ background?: string;
174
+ /** Pill border color. */
175
+ borderColor?: string;
176
+ /** Border stroke width in pixels. Default `1`. */
177
+ borderWidth?: number;
178
+ /** Pill corner radius in pixels. */
179
+ radius?: number;
180
+ /** Label / icon text color override. */
181
+ textColor?: string;
182
+ /** Badge font size in pixels. Falls back to the chart `font`. */
183
+ fontSize?: number;
184
+ /** Badge font family. Falls back to the chart `font`. */
185
+ fontFamily?: string;
186
+ /** Badge font weight. Falls back to the chart `font`. */
187
+ fontWeight?: FontWeight;
188
+ /** Nudge the whole badge horizontally from its anchor, in pixels. Default `0`. */
189
+ offsetX?: number;
190
+ /** Nudge the whole badge vertically from its anchor, in pixels. Default `0`. */
191
+ offsetY?: number;
106
192
  }
107
193
  /**
108
194
  * Pill-badge presentation for a Form-A {@link ReferenceLine} — a working order,
109
195
  * price alert, or target tag. The badge sits at the line's value (pinned to
110
196
  * `position`) with a dashed connector to the opposite edge, and pins to the
111
197
  * nearest edge with a chevron once the value scrolls off-screen.
198
+ *
199
+ * Extends {@link BadgeStyleConfig} for the style/shape knobs. Their reference-line
200
+ * fallbacks: `background` → `badgeBackground` → theme `tooltipBg`; `borderColor` →
201
+ * `badgeBorderColor` → the line `color`; `radius` → `badgeRadius` → `5`; `textColor`
202
+ * → `labelColor` → the line `color` → theme `refLabel`; the `font*` knobs → the
203
+ * chart `font`.
112
204
  */
113
- export interface ReferenceLineBadgeConfig {
114
- /** Which plot edge the badge pins to. Default `"left"`. */
115
- position?: "left" | "right";
205
+ export interface ReferenceLineBadgeConfig extends BadgeStyleConfig {
206
+ /**
207
+ * Where the badge pins horizontally. `"left"` / `"right"` pin to that plot edge
208
+ * with a dashed connector running to the opposite edge; `"center"` floats the
209
+ * pill centered in the plot at the line's value (no connector). Default `"left"`.
210
+ */
211
+ position?: "left" | "center" | "right";
116
212
  /**
117
213
  * Leading glyph drawn in the badge — rendered with the chart font, so pass an
118
214
  * emoji-capable font (via the chart `font` prop) for emoji. Like `Marker.icon`.
@@ -123,12 +219,69 @@ export interface ReferenceLineBadgeConfig {
123
219
  * Default `true`. Set `false` for an **icon-only** badge.
124
220
  */
125
221
  text?: boolean;
126
- /** Pill background. Falls back to `badgeBackground`, then theme `tooltipBg`. */
127
- background?: string;
128
- /** Pill border color. Falls back to `badgeBorderColor`, then the line `color`. */
129
- borderColor?: string;
130
- /** Pill corner radius in pixels. Falls back to `badgeRadius`, then `5`. */
222
+ }
223
+ /**
224
+ * Context passed to a custom {@link LiveChartProps.renderReferenceLine}. The chart
225
+ * floats the element you return over the canvas and pins it to the line's value on
226
+ * the UI thread (vertically centered on the line, horizontally at the badge /
227
+ * label position) — so it tracks the rescaling axis and any drag smoothly without
228
+ * JS re-renders, just like {@link TooltipRenderProps}. Replaces the built-in pill
229
+ * badge / gutter label for that line; return `null`/`undefined` to keep the
230
+ * built-in. Bind the SharedValues to animated text (e.g. an animated `TextInput`)
231
+ * for the value to update on the UI thread too.
232
+ */
233
+ export interface ReferenceLineRenderProps {
234
+ /** The reference line being rendered. */
235
+ line: ReferenceLine;
236
+ /** Its index in the `referenceLines` array. */
237
+ index: number;
238
+ /** Live Y-axis value of the line — tracks dragging when {@link ReferenceLine.draggable}. */
239
+ value: SharedValue<number>;
240
+ /** The value formatted with the chart's `formatValue` (computed UI-side). */
241
+ valueStr: SharedValue<string>;
242
+ /** Canvas Y pixel of the line, recomputed each frame (`-1` when not laid out). */
243
+ y: SharedValue<number>;
244
+ /** Whether the value currently sits within the visible plot range. */
245
+ inRange: SharedValue<boolean>;
246
+ /**
247
+ * Which visible edge the value is pinned to when off-screen: `"above"` (past the
248
+ * top), `"below"` (past the bottom), or `"in"`. Use it to flip a directional
249
+ * chevron on a custom off-axis handle.
250
+ */
251
+ edge: SharedValue<"above" | "in" | "below">;
252
+ /** Whether this line is currently being dragged. */
253
+ dragging: SharedValue<boolean>;
254
+ }
255
+ /**
256
+ * Grouping behavior for reference lines (single-series). When enabled, Form-A
257
+ * lines whose handles fall within {@link ReferenceLineGroupingConfig.radius} px of
258
+ * each other collapse into a single count handle, so a cluster of nearby orders /
259
+ * alerts reads as one tag instead of an unreadable pile. Pass `true` for defaults
260
+ * or an object to tune the proximity radius.
261
+ */
262
+ export interface ReferenceLineGroupingConfig {
263
+ /**
264
+ * Collapse lines whose value-Y positions are within this many px of each other.
265
+ * Default `18`.
266
+ */
131
267
  radius?: number;
268
+ /**
269
+ * Styling for the collapsed **count pill** — the same style/shape config as a
270
+ * reference-line badge ({@link ReferenceLineBadgeConfig}): `position`
271
+ * (`"left"` / `"center"` / `"right"`), `icon` (a leading glyph before the count),
272
+ * `background`, `borderColor`, `borderWidth`, `radius` (corner radius),
273
+ * `textColor`, `fontSize` / `fontFamily` / `fontWeight`, and `offsetX` / `offsetY`.
274
+ * Omit for the theme defaults (left-pinned, `tooltipBg` fill, `refLine` border,
275
+ * `refLabel` text). The badge's `text: false` hides the count for an icon-only pill.
276
+ */
277
+ badge?: ReferenceLineBadgeConfig;
278
+ /**
279
+ * Format the collapsed count for the pill label, e.g. `n => \`×${n}\`` or
280
+ * `n => \`${n} orders\``. Default `String(n)` (the bare count). **Must be a
281
+ * worklet** (add the `"worklet"` directive) — it runs on the UI thread each
282
+ * frame, like the chart's `formatValue`. A plain JS closure throws.
283
+ */
284
+ format?: (count: number) => string;
132
285
  }
133
286
  /**
134
287
  * A time-range segment of the chart — e.g. a pre-market / regular / after-hours
@@ -318,21 +471,65 @@ export interface AreaDotsConfig {
318
471
  /** Overall opacity (0..1) applied to the whole field. Default `1`. */
319
472
  opacity?: number;
320
473
  }
321
- /** Value badge pill configuration. */
322
- export interface BadgeConfig {
474
+ /**
475
+ * Value badge pill configuration. Extends {@link BadgeStyleConfig} for the
476
+ * style/shape knobs (`background`, `borderColor` / `borderWidth`, `radius`,
477
+ * `textColor`, `font*`, `offsetX/Y`). Value-badge specifics: `radius` defaults to a
478
+ * full capsule (clamped to `[0, pillHeight / 2]`); `borderColor` unset → no border;
479
+ * `textColor` unset → the `variant` / theme rule.
480
+ */
481
+ export interface BadgeConfig extends BadgeStyleConfig {
323
482
  /** Visual style of the badge pill. Default `"default"`. */
324
483
  variant?: BadgeVariant;
325
484
  /** Show the pointed tail toward the live dot. Default `true`. */
326
485
  tail?: boolean;
327
- /** Badge background color override. */
328
- background?: string;
329
486
  /** Which side of the chart the badge appears on. Default `"right"`. */
330
487
  position?: "right" | "left";
488
+ /**
489
+ * When the chart is scrolled back (see `timeScroll`), move the live-price
490
+ * indicators — the badge, the value line, and the live dot — to the price at
491
+ * the visible window's right edge instead of the live price, so they track the
492
+ * last visible price as you pan. Default `false`.
493
+ *
494
+ * @experimental
495
+ */
496
+ followViewEdge?: boolean;
497
+ }
498
+ /**
499
+ * Volume-bar configuration (candle mode only — see {@link LiveChartProps.volume}).
500
+ * Bars are drawn in a reserved band below the candles; the candle/price plot
501
+ * shrinks by {@link maxHeight} to make room (the x-axis stays at the bottom).
502
+ * Each bar's height is its candle's `volume` normalized to the largest visible
503
+ * volume, so the tallest visible bar fills the band.
504
+ */
505
+ export interface VolumeConfig {
506
+ /** Bar color for up (close ≥ open) candles. Default: `palette.candleUp`. */
507
+ upColor?: string;
508
+ /** Bar color for down (close < open) candles. Default: `palette.candleDown`. */
509
+ downColor?: string;
510
+ /**
511
+ * Height (px) of the reserved band — the tallest a bar can be. Reserved out of
512
+ * the plot below the candles. Default `48`.
513
+ */
514
+ maxHeight?: number;
515
+ /** Corner radius (px) of bar tops. `0` = sharp. Default `2`. */
516
+ radius?: number;
517
+ /** Opacity (0..1) applied to the whole band. Default `0.6`. */
518
+ opacity?: number;
331
519
  }
332
520
  /** Y-axis grid configuration. */
333
521
  export interface YAxisConfig {
334
522
  /** Minimum pixel gap between grid lines. Default `36`. */
335
523
  minGap?: number;
524
+ /**
525
+ * Float the price axis over a full-width plot instead of reserving a right
526
+ * gutter for it. The line/candles run all the way to the right edge, and the
527
+ * price labels (and the live-value badge) float on top — so the chart isn't
528
+ * cut off short of the edge, especially while time-scrolling. Default `false`.
529
+ *
530
+ * @experimental
531
+ */
532
+ float?: boolean;
336
533
  }
337
534
  /**
338
535
  * Axis edge label — the value floated at the plot's top or bottom edge
@@ -438,11 +635,13 @@ export interface ScrubConfig {
438
635
  * Where the tooltip pill sits relative to the vertical scrub line.
439
636
  * `"side"` (default) offsets it to the right of the line and flips left near
440
637
  * the right edge. `"top"` / `"bottom"` center it horizontally over the line,
441
- * clamped into the plot and pinned to the plot's top or bottom. This also
442
- * drives a custom {@link LiveChartProps.renderTooltip} so it gets the same
443
- * placement for free.
638
+ * clamped into the plot and pinned to the plot's top or bottom. `"point"`
639
+ * centers it over the line and floats it just above the scrub dot, flipping
640
+ * below the dot when there isn't room above (single-series line mode; candle
641
+ * mode keeps its top-pinned OHLC stack). This also drives a custom
642
+ * {@link LiveChartProps.renderTooltip} so it gets the same placement for free.
444
643
  */
445
- tooltipPlacement?: "side" | "top" | "bottom";
644
+ tooltipPlacement?: "side" | "top" | "bottom" | "point";
446
645
  /**
447
646
  * Gap in px between the tooltip and the plot edge it's pinned to — the top for
448
647
  * `"side"`/`"top"`, the bottom for `"bottom"`. Applies to the built-in pill and
@@ -579,6 +778,89 @@ export interface TooltipRenderProps {
579
778
  */
580
779
  candle: SharedValue<CandlePoint | null>;
581
780
  }
781
+ /** Inner plot rectangle in canvas pixels (a snapshot field of {@link ChartScale}). */
782
+ export interface ChartPlotRect {
783
+ /** Inner plot left edge (`padding.left`). */
784
+ left: number;
785
+ /** Inner plot top edge (`padding.top`). */
786
+ top: number;
787
+ /** Inner plot right edge (`canvasWidth - padding.right`). */
788
+ right: number;
789
+ /** Inner plot bottom edge (`canvasHeight - padding.bottom`). */
790
+ bottom: number;
791
+ /** Full canvas width. */
792
+ width: number;
793
+ /** Full canvas height. */
794
+ height: number;
795
+ }
796
+ /**
797
+ * A snapshot of the chart's live scale — the value range, time window, and plot
798
+ * rect at one frame. Carried by {@link ChartOverlayContext.scale} (a `SharedValue`
799
+ * recomputed each frame) and consumed by the pure mapping functions. Reading
800
+ * `scale.get()` inside your worklet is what subscribes the overlay to per-frame
801
+ * updates, so it tracks the chart as it scrolls and rescales.
802
+ */
803
+ export interface ChartScale {
804
+ /** Live Y-axis lower bound (price at the plot bottom). */
805
+ min: number;
806
+ /** Live Y-axis upper bound (price at the plot top). */
807
+ max: number;
808
+ /** Visible time window in seconds. */
809
+ window: number;
810
+ /** Right-edge timestamp (unix seconds) — "now". */
811
+ now: number;
812
+ /** Inner plot rectangle in canvas px. */
813
+ plot: ChartPlotRect;
814
+ }
815
+ /**
816
+ * The price↔pixel / time↔pixel bridge handed to a custom
817
+ * {@link LiveChartProps.renderOverlay}.
818
+ *
819
+ * **Easiest path — the `usePriceY` / `useTimeX` hooks.** They project a price / time
820
+ * to a `SharedValue<number>` that tracks the live axis for you; just read it in
821
+ * your `useAnimatedStyle` like any SharedValue:
822
+ *
823
+ * ```tsx
824
+ * function PriceLevel({ ctx, price }) {
825
+ * const y = usePriceY(ctx, price); // reactive — tracks the rescaling axis
826
+ * const style = useAnimatedStyle(() => ({ transform: [{ translateY: y.get() }] }));
827
+ * return <Animated.View style={style} />;
828
+ * }
829
+ * ```
830
+ *
831
+ * **Manual path — {@link scale} + the pure mappings.** For one-off math (e.g. a
832
+ * gesture handler) or when you want everything in one worklet, read `scale.get()`
833
+ * inside your worklet — that read subscribes it to the per-frame scale — then pass
834
+ * the snapshot to the pure mappings (`priceToY` / `yToPrice` / `timeToX` /
835
+ * `xToTime`). The mappings do **not** read `scale` themselves, so they only reflect
836
+ * the chart live when you feed them `scale.get()`:
837
+ *
838
+ * ```tsx
839
+ * const style = useAnimatedStyle(() => {
840
+ * const s = scale.get(); // subscribe to the live scale
841
+ * const y = priceToY(142.5, s); // project a price to its pixel
842
+ * return { transform: [{ translateY: y }] };
843
+ * });
844
+ * ```
845
+ */
846
+ export interface ChartOverlayContext {
847
+ /**
848
+ * The live {@link ChartScale} snapshot, recomputed each frame. Read `.get()`
849
+ * inside your worklet to subscribe it to chart updates.
850
+ */
851
+ scale: SharedValue<ChartScale>;
852
+ /** Maps a price (Y-axis value) → canvas Y px for a {@link ChartScale}. Worklet. -1 when not laid out. */
853
+ priceToY: (price: number, scale: ChartScale) => number;
854
+ /**
855
+ * Inverse of {@link priceToY}: canvas Y px → price. Worklet. Clamps to the
856
+ * visible range; `null` when not laid out.
857
+ */
858
+ yToPrice: (y: number, scale: ChartScale) => number | null;
859
+ /** Maps a unix-seconds timestamp → canvas X px for a {@link ChartScale}. Worklet. -1 when not laid out. */
860
+ timeToX: (time: number, scale: ChartScale) => number;
861
+ /** Inverse of {@link timeToX}: canvas X px → unix-seconds timestamp. Worklet. */
862
+ xToTime: (x: number, scale: ChartScale) => number;
863
+ }
582
864
  /** Outer ring drawn around the built-in selection dot (the subtle halo). */
583
865
  export interface SelectionDotRingConfig {
584
866
  /** Ring color. Defaults to the dot color. */
@@ -728,16 +1010,59 @@ export interface Marker {
728
1010
  pill?: boolean;
729
1011
  /** Icon / image box size in px (icon font size or image width+height). Default `16`. */
730
1012
  size?: number;
731
- /** Pass-through payload surfaced on `onMarkerHover`. */
1013
+ /**
1014
+ * Sit the glyph above / below its anchor instead of centered on it. Default
1015
+ * `"center"` (on the line/value, today's behavior). Also the stack direction
1016
+ * when `markerCluster: "stacked"` — e.g. buys `"below"`, sells `"above"`.
1017
+ */
1018
+ side?: MarkerSide;
1019
+ /** Pass-through payload surfaced on `onMarkerPress`. */
732
1020
  data?: unknown;
733
1021
  }
734
- /** Payload for `onMarkerHover` the marker and its screen position. */
735
- export interface MarkerHoverEvent {
1022
+ /** Where a marker glyph sits relative to its anchor (and the stack direction). */
1023
+ export type MarkerSide = "above" | "below" | "center";
1024
+ /**
1025
+ * Object form of {@link LiveChartProps.markerCluster} for tuning the stacked
1026
+ * collision behavior. Passing this object implies `mode: "stacked"` unless you
1027
+ * set `mode` explicitly.
1028
+ */
1029
+ export interface MarkerClusterConfig {
1030
+ /** Defaults to `"stacked"` when this object form is used. */
1031
+ mode?: "anchored" | "stacked";
1032
+ /**
1033
+ * How much adjacent co-located glyphs overlap when fanned, `0` (just touching)
1034
+ * to `1` (fully stacked). Default `0.75`. The on-screen overlap is approximate
1035
+ * (the fan step is estimated from the glyph size, not its exact pixels).
1036
+ */
1037
+ overlap?: number;
1038
+ /** Collapse a co-located run to a single count badge once it exceeds this many.
1039
+ * Default `5`. */
1040
+ maxBeforeGroup?: number;
1041
+ }
1042
+ /** Context passed to `renderMarker` alongside the marker (cluster / position state). */
1043
+ export interface MarkerRenderContext {
1044
+ /** Index of the marker in the `markers` array. */
1045
+ index: number;
1046
+ /** `true` when this marker is the representative of a collapsed cluster. */
1047
+ isGrouped: boolean;
1048
+ /** Number of markers in the collapsed cluster (`0` when not grouped). */
1049
+ groupCount: number;
1050
+ /** Resolved side the glyph is drawn on. */
1051
+ side: MarkerSide;
1052
+ }
1053
+ /** Payload for `onMarkerPress` — the marker and its screen position. */
1054
+ export interface MarkerPressEvent {
736
1055
  marker: Marker;
737
1056
  point: {
738
1057
  x: number;
739
1058
  y: number;
740
1059
  };
1060
+ /** Index of the pressed marker in the `markers` array. */
1061
+ index: number;
1062
+ /** `true` when the press landed on a collapsed cluster (count badge). */
1063
+ isGrouped: boolean;
1064
+ /** The cluster's markers when `isGrouped`, so the consumer can list them. */
1065
+ members?: Marker[];
741
1066
  }
742
1067
  /** Particle burst + screen shake on momentum swings ("degen mode"). */
743
1068
  export interface DegenOptions {
@@ -874,6 +1199,13 @@ export interface SeriesConfig {
874
1199
  style?: "solid" | "dashed";
875
1200
  /** Dash pattern as `[dashLength, gapLength]` when `style` is `"dashed"`. Default `[6, 4]`. */
876
1201
  intervals?: [number, number];
1202
+ /**
1203
+ * Interpolation for this series' line, mirroring {@link LineConfig.curve}.
1204
+ * - `"monotone"` (default): Fritsch-Carlson monotone cubic spline.
1205
+ * - `"linear"`: straight segments between samples (sharp vertices). Markers
1206
+ * anchored to this series snap to the straight chord to match.
1207
+ */
1208
+ curve?: "monotone" | "linear";
877
1209
  /** Per-series stroke width override (px). Falls back to the chart line width. */
878
1210
  strokeWidth?: number;
879
1211
  /** Render a soft glow behind this series' line. Default `false`. */
@@ -928,6 +1260,13 @@ export interface CandlePoint {
928
1260
  low: number;
929
1261
  /** Closing price. */
930
1262
  close: number;
1263
+ /**
1264
+ * Traded volume in the bucket. Drives the optional volume bars
1265
+ * (see {@link LiveChartProps.volume}); bar heights are normalized to the
1266
+ * largest visible volume, so only relative values matter. Omitted candles
1267
+ * contribute no bar. Ignored when `volume` is off or in line mode.
1268
+ */
1269
+ volume?: number;
931
1270
  }
932
1271
  /**
933
1272
  * Spatial sizing & motion tokens — the geometry/timing analogue of
@@ -970,6 +1309,10 @@ export interface CandleMetrics {
970
1309
  maxBodyPx: number;
971
1310
  /** Body width as a fraction of the per-candle slot width (0–1). Default `0.8`. */
972
1311
  bodyWidthRatio: number;
1312
+ /** Corner radius (px) of candle bodies. `0` = sharp corners. Default `0`. */
1313
+ bodyRadius: number;
1314
+ /** Wick (high–low line) stroke width in px. Default `1`. */
1315
+ wickWidth: number;
973
1316
  }
974
1317
  /** Grid-line and axis-label fade animation speeds. */
975
1318
  export interface GridMetrics {
@@ -1006,6 +1349,58 @@ export interface LiveChartMetricsOverride {
1006
1349
  motion?: Partial<MotionMetrics>;
1007
1350
  emptyState?: Partial<EmptyStateMetrics>;
1008
1351
  }
1352
+ /**
1353
+ * Time-scroll activation (see {@link LiveChartCoreProps.timeScroll}).
1354
+ *
1355
+ * @experimental Prototype — gesture model and API may change.
1356
+ */
1357
+ export interface TimeScrollConfig {
1358
+ /**
1359
+ * Which gesture pans the timeline:
1360
+ * - `"holdToScrub"` (default) — a one-finger drag anywhere scrolls; scrub
1361
+ * moves to press-and-hold (Rainbow-style). See {@link scrubHoldMs} for the
1362
+ * hold duration.
1363
+ * - `"axisDrag"` — a one-finger drag starting in the bottom X-axis band
1364
+ * ("grab the time ruler"); the plot area stays free for one-finger scrub.
1365
+ */
1366
+ gesture?: "holdToScrub" | "axisDrag";
1367
+ /**
1368
+ * `holdToScrub` only: press-and-hold duration (ms) before scrub engages, so a
1369
+ * quicker one-finger drag scrolls instead. Higher = more deliberate scrub and
1370
+ * fewer accidental scrubs while scrolling. Falls back to `scrub.panGestureDelay`
1371
+ * if set, otherwise `500`.
1372
+ */
1373
+ scrubHoldMs?: number;
1374
+ }
1375
+ /**
1376
+ * Pinch-to-zoom the visible time window (see {@link LiveChartCoreProps.zoom}).
1377
+ *
1378
+ * @experimental Prototype — gesture model and API may change.
1379
+ */
1380
+ export interface ZoomConfig {
1381
+ /**
1382
+ * Tightest visible window in seconds (max zoom-in). Default `timeWindow / 8`.
1383
+ */
1384
+ minTimeWindow?: number;
1385
+ /**
1386
+ * Widest visible window in seconds (max zoom-out). Defaults to the full data
1387
+ * span (you can zoom out to all retained history), never below `timeWindow`.
1388
+ */
1389
+ maxTimeWindow?: number;
1390
+ }
1391
+ /**
1392
+ * The visible time range reported by {@link LiveChartCoreProps.onVisibleRangeChange}.
1393
+ *
1394
+ * @experimental
1395
+ */
1396
+ export interface VisibleRange {
1397
+ /** Left-edge time of the visible window (unix seconds). */
1398
+ startSec: number;
1399
+ /** Right-edge time of the visible window (unix seconds). */
1400
+ endSec: number;
1401
+ /** True when the window is at the live edge (not scrolled back / paused). */
1402
+ following: boolean;
1403
+ }
1009
1404
  /** Props shared between `LiveChart` and `LiveChartSeries`. */
1010
1405
  export interface LiveChartCoreProps {
1011
1406
  /** Color scheme. Default `"dark"`. */
@@ -1083,9 +1478,19 @@ export interface LiveChartCoreProps {
1083
1478
  */
1084
1479
  markers?: SharedValue<Marker[]>;
1085
1480
  /** Fires when a marker is tapped; `null` when a tap misses every marker. */
1086
- onMarkerHover?: (event: MarkerHoverEvent | null) => void;
1481
+ onMarkerPress?: (event: MarkerPressEvent | null) => void;
1087
1482
  /** Tap hit-test radius in px. Default `16` (≈ 44px touch target with the glyph). */
1088
1483
  markerHitRadius?: number;
1484
+ /**
1485
+ * Collision handling for co-located markers. `"anchored"` (default) keeps
1486
+ * today's behavior — glyphs draw at their anchor and overlap. `"stacked"` fans
1487
+ * co-located markers apart horizontally (overlapping, left-over-right) along
1488
+ * their {@link Marker.side}, collapsing a cluster into a single count-badge
1489
+ * marker once it exceeds {@link MarkerClusterConfig.maxBeforeGroup}. Grouping is
1490
+ * recomputed per frame, so a cluster fans back out as you zoom/scroll in. Pass a
1491
+ * {@link MarkerClusterConfig} object to tune the `overlap` and group threshold.
1492
+ */
1493
+ markerCluster?: "anchored" | "stacked" | MarkerClusterConfig;
1089
1494
  /**
1090
1495
  * Render a marker as a custom **React Native** element instead of a built-in
1091
1496
  * Skia glyph — e.g. an `expo-blur` glass badge or any non-Skia view that the
@@ -1098,8 +1503,12 @@ export interface LiveChartCoreProps {
1098
1503
  * each custom marker is its own animated view + projection, whereas built-in
1099
1504
  * glyphs batch into a single draw call. Custom-rendered markers skip the atlas
1100
1505
  * glyph entirely (no double-draw).
1506
+ *
1507
+ * The second argument carries cluster / position state (see
1508
+ * {@link MarkerRenderContext}) — e.g. render a distinct collapsed look when
1509
+ * `ctx.isGrouped` (showing `ctx.groupCount`).
1101
1510
  */
1102
- renderMarker?: (marker: Marker) => ReactElement | null | undefined;
1511
+ renderMarker?: (marker: Marker, ctx: MarkerRenderContext) => ReactElement | null | undefined;
1103
1512
  /**
1104
1513
  * Render a fully custom scrub tooltip as a **React Native** element instead of
1105
1514
  * the built-in pill — the same idea as `renderMarker`. The chart floats the
@@ -1141,6 +1550,31 @@ export interface LiveChartCoreProps {
1141
1550
  * and `timeWindow = maxT - minT` to fill the canvas edge-to-edge with historical data.
1142
1551
  */
1143
1552
  nowOverride?: number;
1553
+ /**
1554
+ * Enable horizontal time-scrolling: drag (or fling) to pan back through history.
1555
+ * The chart stops auto-scrolling while panned and resumes once you reach the
1556
+ * live edge again. One-finger plot-area scrub is unchanged. Requires retained
1557
+ * history in `data` / `candles` to scroll into.
1558
+ *
1559
+ * `true` uses the default drag-to-scroll gesture (`"holdToScrub"`); pass a
1560
+ * {@link TimeScrollConfig} to pick the activation (`"holdToScrub"` or
1561
+ * `"axisDrag"`). Default `false`.
1562
+ *
1563
+ * @experimental Prototype — gesture model and API may change.
1564
+ */
1565
+ timeScroll?: boolean | TimeScrollConfig;
1566
+ /**
1567
+ * Pinch-to-zoom the visible time window. Two-finger pinch in/out narrows or
1568
+ * widens the window, anchored at the focal point between your fingers. Composes
1569
+ * with `timeScroll` (zoom level and scroll position are independent). Seed extra
1570
+ * history in `data` / `candles` to have room to zoom out into.
1571
+ *
1572
+ * `true` uses sensible default bounds; pass a {@link ZoomConfig} to set
1573
+ * `minTimeWindow` / `maxTimeWindow`. Default `false`.
1574
+ *
1575
+ * @experimental Prototype — gesture model and API may change.
1576
+ */
1577
+ zoom?: boolean | ZoomConfig;
1144
1578
  /** Accessibility label for the chart container. */
1145
1579
  accessibilityLabel?: string;
1146
1580
  /** Accessibility role for the chart container. Default `"image"`. */
@@ -1157,6 +1591,22 @@ export interface LiveChartCoreProps {
1157
1591
  onGestureStart?: () => void;
1158
1592
  /** Called once when the user stops scrubbing/panning the chart. */
1159
1593
  onGestureEnd?: () => void;
1594
+ /**
1595
+ * Called as the visible time window changes (throttled to ~1 Hz), with the
1596
+ * window's edges in unix seconds and whether the chart is at the live edge.
1597
+ * Useful for paging data sources alongside `timeScroll` / `zoom`.
1598
+ *
1599
+ * @experimental
1600
+ */
1601
+ onVisibleRangeChange?: (range: VisibleRange) => void;
1602
+ /**
1603
+ * Called once when the visible window's left edge comes within one
1604
+ * window-width of the earliest retained data — the cue to lazily load older
1605
+ * history. Re-arms after the edge moves back out.
1606
+ *
1607
+ * @experimental
1608
+ */
1609
+ onReachStart?: () => void;
1160
1610
  /**
1161
1611
  * Fade out chart content on the left (destination-out style). `true` = defaults, `false` = off,
1162
1612
  * or pass `LeftEdgeFadeConfig`. Default `true`.
@@ -1234,6 +1684,19 @@ export interface LiveChartProps extends LiveChartCoreProps {
1234
1684
  * in a list. Pulse/scrub/degen and the entry animation are disabled. Frame the data
1235
1685
  * with `timeWindow` + `nowOverride` (see the historical-data-fill pattern). */
1236
1686
  static?: boolean;
1687
+ /**
1688
+ * Render a custom overlay floated over the chart canvas, handed a price↔pixel /
1689
+ * time↔pixel {@link ChartOverlayContext} so it can track the auto-rescaling axis
1690
+ * on the UI thread. Return any React Native view tree (e.g. order / avg-entry /
1691
+ * liquidation price tags) and position its pieces with the context's worklet
1692
+ * mappings inside `useAnimatedStyle`; return `null`/`undefined` for no overlay.
1693
+ *
1694
+ * The returned tree is mounted as an RN sibling of the `<Canvas>` (like
1695
+ * `renderMarker` / `renderTooltip`), full-bleed with `pointerEvents="box-none"`
1696
+ * so empty areas still scrub while an interactive leaf can receive touches.
1697
+ * Single-series only.
1698
+ */
1699
+ renderOverlay?: (ctx: ChartOverlayContext) => ReactElement | null | undefined;
1237
1700
  /** Called when the user scrubs the crosshair. `null` when scrub ends. */
1238
1701
  onScrub?: (point: ScrubPoint | null) => void;
1239
1702
  /**
@@ -1259,6 +1722,34 @@ export interface LiveChartProps extends LiveChartCoreProps {
1259
1722
  * routed here, not to reticle placement). Single-series only.
1260
1723
  */
1261
1724
  onReferenceLinePress?: (line: ReferenceLine, index: number) => void;
1725
+ /**
1726
+ * Render a reference line's tag as a custom **React Native** element instead of
1727
+ * the built-in Skia pill / gutter label — the same model as `renderMarker` /
1728
+ * `renderTooltip`. The chart floats the returned element over the canvas and
1729
+ * pins it to the line's value on the UI thread (see {@link ReferenceLineRenderProps}),
1730
+ * so it tracks the rescaling axis and any drag without JS re-renders. Called per
1731
+ * Form-A line; return `null`/`undefined` to keep that line's built-in tag. Works
1732
+ * with `badge: false` too (replace the plain gutter label). Single-series only.
1733
+ */
1734
+ renderReferenceLine?: (ctx: ReferenceLineRenderProps) => ReactElement | null | undefined;
1735
+ /**
1736
+ * Collapse Form-A reference lines whose handles sit near the same value into a
1737
+ * single count handle (e.g. a stack of working orders at adjacent prices reads
1738
+ * as one "×3" tag). `true` = defaults, `false`/omitted = off, or pass a
1739
+ * {@link ReferenceLineGroupingConfig} to tune the proximity radius. Lines a
1740
+ * {@link LiveChartProps.renderReferenceLine} owns are excluded (their custom tag
1741
+ * draws itself), so the count reflects only collapsed built-in tags. Single-series
1742
+ * only. Default off.
1743
+ */
1744
+ referenceLineGrouping?: boolean | ReferenceLineGroupingConfig;
1745
+ /**
1746
+ * Volume bars below the candles (candle mode only). `true` = defaults,
1747
+ * `false`/omitted = off, or pass a {@link VolumeConfig} for colors, band
1748
+ * height, rounding, and opacity. The candle/price plot shrinks by the band
1749
+ * height to make room; the x-axis stays pinned to the bottom. Reads each
1750
+ * candle's `CandlePoint.volume`. Ignored in line mode. Default off.
1751
+ */
1752
+ volume?: boolean | VolumeConfig;
1262
1753
  /**
1263
1754
  * Called on the JS thread when degen chart shake starts (momentum swing with shake enabled).
1264
1755
  * Not called when `degen` is off or `DegenOptions.shake` is `false`.