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.
- package/dist/components/CustomReferenceLineOverlay.d.ts +8 -1
- package/dist/components/CustomReferenceLineOverlay.d.ts.map +1 -1
- package/dist/components/CustomTooltipOverlay.d.ts +3 -2
- package/dist/components/CustomTooltipOverlay.d.ts.map +1 -1
- package/dist/components/LiveChart.d.ts +1 -1
- package/dist/components/LiveChart.d.ts.map +1 -1
- package/dist/components/LiveChartSeries.d.ts.map +1 -1
- package/dist/components/MultiSeriesDots.d.ts +1 -1
- package/dist/components/MultiSeriesDots.d.ts.map +1 -1
- package/dist/components/MultiSeriesValueLabels.d.ts +1 -1
- package/dist/components/MultiSeriesValueLabels.d.ts.map +1 -1
- package/dist/components/MultiSeriesValueLines.d.ts +1 -1
- package/dist/components/MultiSeriesValueLines.d.ts.map +1 -1
- package/dist/components/ReferenceLineOverlay.d.ts +4 -0
- package/dist/components/ReferenceLineOverlay.d.ts.map +1 -1
- package/dist/components/ReferenceValueBadge.d.ts +15 -0
- package/dist/components/ReferenceValueBadge.d.ts.map +1 -0
- package/dist/components/XAxisOverlay.d.ts +17 -0
- package/dist/components/XAxisOverlay.d.ts.map +1 -1
- package/dist/core/liveChartEngineTick.d.ts +4 -0
- package/dist/core/liveChartEngineTick.d.ts.map +1 -1
- package/dist/core/liveChartSeriesEngineTick.d.ts +15 -2
- package/dist/core/liveChartSeriesEngineTick.d.ts.map +1 -1
- package/dist/core/resolveConfig.d.ts +28 -1
- package/dist/core/resolveConfig.d.ts.map +1 -1
- package/dist/core/useLiveChartEngine.d.ts +9 -0
- package/dist/core/useLiveChartEngine.d.ts.map +1 -1
- package/dist/core/useLiveChartSeriesEngine.d.ts +18 -4
- package/dist/core/useLiveChartSeriesEngine.d.ts.map +1 -1
- package/dist/draw/grid.d.ts +6 -4
- package/dist/draw/grid.d.ts.map +1 -1
- package/dist/draw/line.d.ts +21 -3
- package/dist/draw/line.d.ts.map +1 -1
- package/dist/hooks/crosshairSeries.d.ts +2 -2
- package/dist/hooks/crosshairSeries.d.ts.map +1 -1
- package/dist/hooks/crosshairShared.d.ts +16 -1
- package/dist/hooks/crosshairShared.d.ts.map +1 -1
- package/dist/hooks/referenceBadgeFont.d.ts +5 -0
- package/dist/hooks/referenceBadgeFont.d.ts.map +1 -0
- package/dist/hooks/resolveChartLayout.d.ts +18 -2
- package/dist/hooks/resolveChartLayout.d.ts.map +1 -1
- package/dist/hooks/useBadge.d.ts +16 -1
- package/dist/hooks/useBadge.d.ts.map +1 -1
- package/dist/hooks/useChartSkiaFont.d.ts +1 -0
- package/dist/hooks/useChartSkiaFont.d.ts.map +1 -1
- package/dist/hooks/useCrosshair.d.ts +7 -2
- package/dist/hooks/useCrosshair.d.ts.map +1 -1
- package/dist/hooks/useCrosshairSeries.d.ts +6 -1
- package/dist/hooks/useCrosshairSeries.d.ts.map +1 -1
- package/dist/hooks/useLatestCallback.d.ts +6 -0
- package/dist/hooks/useLatestCallback.d.ts.map +1 -0
- package/dist/hooks/useMarkers.d.ts.map +1 -1
- package/dist/hooks/useMultiSeriesDegen.d.ts +1 -1
- package/dist/hooks/useMultiSeriesDegen.d.ts.map +1 -1
- package/dist/hooks/useMultiSeriesLinePaths.d.ts.map +1 -1
- package/dist/hooks/usePanScroll.d.ts +3 -1
- package/dist/hooks/usePanScroll.d.ts.map +1 -1
- package/dist/hooks/usePinchZoom.d.ts +7 -4
- package/dist/hooks/usePinchZoom.d.ts.map +1 -1
- package/dist/hooks/useReferenceDrag.d.ts +20 -5
- package/dist/hooks/useReferenceDrag.d.ts.map +1 -1
- package/dist/hooks/useReferenceLine.d.ts +24 -12
- package/dist/hooks/useReferenceLine.d.ts.map +1 -1
- package/dist/hooks/useReferenceLinePress.d.ts +4 -2
- package/dist/hooks/useReferenceLinePress.d.ts.map +1 -1
- package/dist/hooks/useReferenceTagStack.d.ts +31 -0
- package/dist/hooks/useReferenceTagStack.d.ts.map +1 -0
- package/dist/hooks/useScrubMarkers.d.ts +12 -0
- package/dist/hooks/useScrubMarkers.d.ts.map +1 -0
- package/dist/hooks/useXAxis.d.ts +1 -1
- package/dist/hooks/useXAxis.d.ts.map +1 -1
- package/dist/hooks/useYAxis.d.ts +1 -1
- package/dist/hooks/useYAxis.d.ts.map +1 -1
- package/dist/hooks/useYAxisLabelWidth.d.ts +6 -0
- package/dist/hooks/useYAxisLabelWidth.d.ts.map +1 -0
- package/dist/hooks/useYAxisScaleGesture.d.ts +34 -0
- package/dist/hooks/useYAxisScaleGesture.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/math/axisBadgeLayout.d.ts +16 -0
- package/dist/math/axisBadgeLayout.d.ts.map +1 -0
- package/dist/math/markers.d.ts +3 -0
- package/dist/math/markers.d.ts.map +1 -1
- package/dist/math/range.d.ts +1 -1
- package/dist/math/range.d.ts.map +1 -1
- package/dist/math/referenceLines.d.ts.map +1 -1
- package/dist/math/referenceTagStack.d.ts +36 -0
- package/dist/math/referenceTagStack.d.ts.map +1 -0
- package/dist/math/scrubMarkers.d.ts +12 -0
- package/dist/math/scrubMarkers.d.ts.map +1 -0
- package/dist/types.d.ts +262 -37
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/CustomReferenceLineOverlay.tsx +50 -8
- package/src/components/CustomTooltipOverlay.tsx +5 -1
- package/src/components/LiveChart.tsx +580 -138
- package/src/components/LiveChartSeries.tsx +139 -19
- package/src/components/MultiSeriesDots.tsx +4 -2
- package/src/components/MultiSeriesValueLabels.tsx +4 -2
- package/src/components/MultiSeriesValueLines.tsx +4 -2
- package/src/components/ReferenceLineOverlay.tsx +62 -26
- package/src/components/ReferenceValueBadge.tsx +102 -0
- package/src/components/XAxisOverlay.tsx +104 -1
- package/src/core/liveChartEngineTick.ts +49 -4
- package/src/core/liveChartSeriesEngineTick.ts +107 -14
- package/src/core/resolveConfig.ts +103 -7
- package/src/core/useLiveChartEngine.ts +45 -9
- package/src/core/useLiveChartSeriesEngine.ts +47 -6
- package/src/draw/grid.ts +17 -13
- package/src/draw/line.ts +46 -5
- package/src/hooks/crosshairSeries.ts +37 -5
- package/src/hooks/crosshairShared.ts +56 -1
- package/src/hooks/referenceBadgeFont.ts +35 -0
- package/src/hooks/resolveChartLayout.ts +51 -3
- package/src/hooks/useBadge.ts +44 -5
- package/src/hooks/useChartSkiaFont.ts +1 -1
- package/src/hooks/useCrosshair.ts +444 -310
- package/src/hooks/useCrosshairSeries.ts +57 -20
- package/src/hooks/useLatestCallback.ts +15 -0
- package/src/hooks/useMarkers.ts +51 -39
- package/src/hooks/useMultiSeriesDegen.ts +10 -5
- package/src/hooks/useMultiSeriesLinePaths.ts +2 -0
- package/src/hooks/usePanScroll.ts +155 -127
- package/src/hooks/usePinchZoom.ts +94 -66
- package/src/hooks/useReferenceDrag.ts +409 -156
- package/src/hooks/useReferenceLine.ts +453 -277
- package/src/hooks/useReferenceLineGrouping.ts +1 -1
- package/src/hooks/useReferenceLinePress.ts +121 -53
- package/src/hooks/useReferenceTagStack.ts +81 -0
- package/src/hooks/useScrubMarkers.ts +79 -0
- package/src/hooks/useXAxis.ts +11 -2
- package/src/hooks/useYAxis.ts +1 -1
- package/src/hooks/useYAxisLabelWidth.ts +26 -0
- package/src/hooks/useYAxisScaleGesture.ts +263 -0
- package/src/index.ts +11 -0
- package/src/math/axisBadgeLayout.ts +37 -0
- package/src/math/markers.ts +28 -3
- package/src/math/range.ts +35 -0
- package/src/math/referenceLines.ts +5 -0
- package/src/math/referenceTagStack.ts +112 -0
- package/src/math/scrubMarkers.ts +55 -0
- package/src/types.ts +263 -37
package/dist/types.d.ts
CHANGED
|
@@ -52,6 +52,8 @@ export interface ReferenceLine {
|
|
|
52
52
|
/**
|
|
53
53
|
* Stable identifier for this line. Supply a unique value when `referenceLines`
|
|
54
54
|
* may be reordered so the chart preserves the line's rendered identity.
|
|
55
|
+
* If this line is removed or moves to another index during a drag, that touch
|
|
56
|
+
* is cancelled without committing, even if the line later returns.
|
|
55
57
|
*/
|
|
56
58
|
id?: string;
|
|
57
59
|
/** Form A — the Y-axis value where the horizontal line is drawn. */
|
|
@@ -140,6 +142,15 @@ export interface ReferenceLine {
|
|
|
140
142
|
* `position`. Supersedes the legacy `offAxisBadge`. Default off.
|
|
141
143
|
*/
|
|
142
144
|
badge?: boolean | ReferenceLineBadgeConfig;
|
|
145
|
+
/**
|
|
146
|
+
* A separate Form-A price pill displaying `formatValue(value)` on the UI
|
|
147
|
+
* thread, including during a drag. `true` pins it inside the plot's right
|
|
148
|
+
* edge; `{ position: "axis" }` aligns it with the right price gutter (or the
|
|
149
|
+
* floating axis). Works without a name badge. Both tags pin off-screen and
|
|
150
|
+
* collapse together when grouped. Custom tag renderers replace both pills.
|
|
151
|
+
* Has no effect on series or bands. Default `false`.
|
|
152
|
+
*/
|
|
153
|
+
valueBadge?: boolean | ReferenceLineValueBadgeConfig;
|
|
143
154
|
/**
|
|
144
155
|
* Legacy: when a Form-A `value` falls outside the visible plot, render a pinned
|
|
145
156
|
* edge badge with a directional chevron instead of culling the off-screen line.
|
|
@@ -178,7 +189,10 @@ export interface ReferenceLine {
|
|
|
178
189
|
grabRange?: [number, number];
|
|
179
190
|
/**
|
|
180
191
|
* Snap the dragged value to this increment (e.g. `0.01` for cents, `0.5` for a
|
|
181
|
-
* tick size) so drops land on round levels.
|
|
192
|
+
* tick size) so drops land on round levels. At the plot's edge the line is drawn
|
|
193
|
+
* and dropped on the nearest increment inside the visible range; dragged past
|
|
194
|
+
* the edge, the value the finger sets (and {@link onChange} reports) rounds
|
|
195
|
+
* outward, so the range can widen to it. Omit for free dragging. Applies only
|
|
182
196
|
* while {@link draggable}.
|
|
183
197
|
*/
|
|
184
198
|
snap?: number;
|
|
@@ -187,18 +201,26 @@ export interface ReferenceLine {
|
|
|
187
201
|
* can't be dragged past either end. Omit for unbounded (clamped only to the
|
|
188
202
|
* visible range). Reaching a bound fires {@link onDragOut}. Applies only while
|
|
189
203
|
* {@link draggable}.
|
|
204
|
+
*
|
|
205
|
+
* Pass a `SharedValue<[number, number]>` for a bound that follows a live value
|
|
206
|
+
* (e.g. a stop that can't cross the current price): the clamp and
|
|
207
|
+
* {@link onDragIn} / {@link onDragOut} read it on the UI thread, so moving it
|
|
208
|
+
* doesn't need a new `referenceLines` array or a re-render.
|
|
190
209
|
*/
|
|
191
|
-
bounds?: [number, number]
|
|
210
|
+
bounds?: [number, number] | SharedValue<[number, number]>;
|
|
192
211
|
/**
|
|
193
|
-
* Fired on the JS thread *while* dragging, each time the
|
|
194
|
-
* value
|
|
195
|
-
*
|
|
212
|
+
* Fired on the JS thread *while* dragging, each time the finger moves the line
|
|
213
|
+
* to a new (snapped, clamped) value. De-duplicated to value changes — not every
|
|
214
|
+
* frame. When the range moves under a still finger the line follows it without
|
|
215
|
+
* firing this; on release it fires once more if the line ended elsewhere, with
|
|
216
|
+
* the value {@link onCommit} gets (its first call, if the finger never changed
|
|
217
|
+
* the value). Form-A draggable only.
|
|
196
218
|
*/
|
|
197
219
|
onChange?: (value: number) => void;
|
|
198
220
|
/**
|
|
199
221
|
* Fired once on the JS thread when the drag ends (finger up), with the final
|
|
200
|
-
* (snapped, clamped) value. Pair with a controlled
|
|
201
|
-
* Form-A draggable only.
|
|
222
|
+
* (snapped, clamped) value — the one under the finger. Pair with a controlled
|
|
223
|
+
* `value` to persist the move. Form-A draggable only.
|
|
202
224
|
*/
|
|
203
225
|
onCommit?: (value: number) => void;
|
|
204
226
|
/**
|
|
@@ -275,6 +297,14 @@ export interface ReferenceLineBadgeConfig extends BadgeStyleConfig {
|
|
|
275
297
|
*/
|
|
276
298
|
text?: boolean;
|
|
277
299
|
}
|
|
300
|
+
/** Separate price pill for a horizontal reference line. Style defaults match
|
|
301
|
+
* the reference badge; the font falls back to the chart font. */
|
|
302
|
+
export interface ReferenceLineValueBadgeConfig extends BadgeStyleConfig {
|
|
303
|
+
/** `"right"`: inside the plot; `"axis"`: right price column, even when the live
|
|
304
|
+
* badge is hidden or placed left. A floating axis uses the canvas right edge.
|
|
305
|
+
* Default `"right"`. Placement is independent of the name badge. */
|
|
306
|
+
position?: "right" | "axis";
|
|
307
|
+
}
|
|
278
308
|
/**
|
|
279
309
|
* Context passed to a custom {@link LiveChartProps.renderReferenceLine} or
|
|
280
310
|
* {@link LiveChartProps.renderOffAxisReferenceLine} (and their
|
|
@@ -299,6 +329,11 @@ export interface ReferenceLineRenderProps {
|
|
|
299
329
|
valueStr: SharedValue<string>;
|
|
300
330
|
/** Canvas Y pixel of the line, recomputed each frame (`-1` when not laid out). */
|
|
301
331
|
y: SharedValue<number>;
|
|
332
|
+
/** Extra vertical displacement from reference-tag stacking, in canvas pixels.
|
|
333
|
+
* The chart applies it to the custom element automatically; `y` keeps its
|
|
334
|
+
* original projection. Use this to draw a connector, not a second transform.
|
|
335
|
+
* Zero when stacking is off (including LiveChartSeries). */
|
|
336
|
+
tagOffsetY: SharedValue<number>;
|
|
302
337
|
/** Whether the value currently sits within the visible plot range. */
|
|
303
338
|
inRange: SharedValue<boolean>;
|
|
304
339
|
/**
|
|
@@ -311,18 +346,23 @@ export interface ReferenceLineRenderProps {
|
|
|
311
346
|
dragging: SharedValue<boolean>;
|
|
312
347
|
}
|
|
313
348
|
/**
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
* or an object to tune the proximity radius. Badged off-axis lines group at either
|
|
319
|
-
* plot edge; off-axis lines with no badge are hidden and do not count. Custom tags
|
|
320
|
-
* are excluded.
|
|
349
|
+
* Tag collision behavior for single-series reference lines. `true` uses collapse
|
|
350
|
+
* mode, replacing nearby built-in tags with a count pill. Stack mode keeps each
|
|
351
|
+
* built-in or measured custom tag, separating overlapping horizontal columns
|
|
352
|
+
* while price strokes stay at their values. Hidden off-axis lines do not count.
|
|
321
353
|
*/
|
|
322
354
|
export interface ReferenceLineGroupingConfig {
|
|
323
|
-
/**
|
|
324
|
-
*
|
|
325
|
-
*
|
|
355
|
+
/** `"collapse"` merges nearby tags into a count (default). `"stack"` keeps
|
|
356
|
+
* each price line and separates overlapping tags by their measured bounds.
|
|
357
|
+
* Custom tags participate in stack mode; separate horizontal columns pack
|
|
358
|
+
* independently. Single-series only. */
|
|
359
|
+
mode?: "collapse" | "stack";
|
|
360
|
+
/** Stack mode: keep tags clear of the visible live value badge. Default `true`.
|
|
361
|
+
* Best effort when there is insufficient plot height; ignored in collapse mode. */
|
|
362
|
+
avoidValueBadge?: boolean;
|
|
363
|
+
/**
|
|
364
|
+
* Collapse mode: proximity radius. Stack mode: minimum center-to-center gap;
|
|
365
|
+
* measured tag heights plus 2 px take precedence. Default `18`.
|
|
326
366
|
*/
|
|
327
367
|
radius?: number;
|
|
328
368
|
/**
|
|
@@ -389,7 +429,7 @@ export interface ChartSegment {
|
|
|
389
429
|
/** Label horizontal anchor within the segment. Default `"left"`. */
|
|
390
430
|
labelPosition?: "left" | "right";
|
|
391
431
|
}
|
|
392
|
-
/**
|
|
432
|
+
/** Grid-line styling for the horizontal value axis and optional xAxis.gridLines. */
|
|
393
433
|
export interface GridStyleConfig {
|
|
394
434
|
/** Stroke color. Defaults to palette `gridLine`. */
|
|
395
435
|
color?: string;
|
|
@@ -664,6 +704,19 @@ export interface BadgeConfig extends BadgeStyleConfig {
|
|
|
664
704
|
tail?: boolean;
|
|
665
705
|
/** Which side of the chart the badge appears on. Default `"right"`. */
|
|
666
706
|
position?: "right" | "left";
|
|
707
|
+
/**
|
|
708
|
+
* Where the value sits in the right-gutter pill. `"center"` centers it in the
|
|
709
|
+
* pill body. `"yAxisColumn"` lines it up with a right-anchored Y-axis label
|
|
710
|
+
* column ({@link YAxisConfig.labelRightMargin}): it starts at the labels'
|
|
711
|
+
* shared left X, and a value wider than every axis label ends at the
|
|
712
|
+
* column's right edge. The pill keeps its shape and the value stays within
|
|
713
|
+
* its `padX` padding (a value that doesn't fit there is centered), so the
|
|
714
|
+
* room on each side follows the right inset and `metrics.badge`. The value
|
|
715
|
+
* moves sideways when the column's width changes (a wider label entering or
|
|
716
|
+
* leaving the axis). Centered without that column on the right side, while
|
|
717
|
+
* the axis floats, and for a `"left"` badge. Default `"center"`.
|
|
718
|
+
*/
|
|
719
|
+
textAlign?: "center" | "yAxisColumn";
|
|
667
720
|
/**
|
|
668
721
|
* When the chart is scrolled back (see `timeScroll`), move the live-price
|
|
669
722
|
* indicators — the badge, the value line, and the live dot — to the price at
|
|
@@ -698,8 +751,27 @@ export interface VolumeConfig {
|
|
|
698
751
|
/** Opacity (0..1) applied to the whole band. Default `0.6`. */
|
|
699
752
|
opacity?: number;
|
|
700
753
|
}
|
|
754
|
+
/** Built-in vertical drag on the price axis. Bounds affect gesture writes only. */
|
|
755
|
+
export interface YAxisScaleGestureConfig {
|
|
756
|
+
/** Smallest multiplier. Positive and finite. Default `0.25`. */
|
|
757
|
+
minScale?: number;
|
|
758
|
+
/** Largest multiplier. Positive and finite, raised to minScale if lower. Default `10`. */
|
|
759
|
+
maxScale?: number;
|
|
760
|
+
/** Vertical points per exponential step (e×). Positive and finite. Default `160`. */
|
|
761
|
+
dragDistance?: number;
|
|
762
|
+
/** Double-tap the axis to animate to `1` (clamped to the bounds). Default `true`. */
|
|
763
|
+
doubleTapReset?: boolean;
|
|
764
|
+
}
|
|
701
765
|
/** Y-axis grid configuration. */
|
|
702
766
|
export interface YAxisConfig {
|
|
767
|
+
/**
|
|
768
|
+
* Opt into vertical price-axis dragging: down widens the range, up zooms in.
|
|
769
|
+
* Uses the rendered axis gutter/label column on either side. Interactive
|
|
770
|
+
* markers and reference badges retain priority. Plot gestures are unchanged.
|
|
771
|
+
* Writes `yRangeScale` when supplied, otherwise an internal multiplier.
|
|
772
|
+
* `true` uses defaults; an object customizes bounds/reset. Default `false`.
|
|
773
|
+
*/
|
|
774
|
+
scaleGesture?: boolean | YAxisScaleGestureConfig;
|
|
703
775
|
/** Price-label side. For left placement, reserve the label gutter with insets.left.
|
|
704
776
|
* Right-side float/labelRightMargin options do not affect left labels. Default "right". */
|
|
705
777
|
side?: "left" | "right";
|
|
@@ -729,7 +801,10 @@ export interface YAxisConfig {
|
|
|
729
801
|
/**
|
|
730
802
|
* Place price labels in a shared left-aligned column whose right edge sits
|
|
731
803
|
* this many pixels from the canvas edge. When omitted, labels keep the
|
|
732
|
-
* default centered-gutter placement.
|
|
804
|
+
* default centered-gutter placement. To line the live badge's value up with
|
|
805
|
+
* the column, set {@link BadgeConfig.textAlign} to `"yAxisColumn"`. Automatic
|
|
806
|
+
* gutters use actual tick widths, this margin, dot-effect outset and 6px
|
|
807
|
+
* clearance. Explicit right insets and badge reservations retain priority.
|
|
733
808
|
*/
|
|
734
809
|
labelRightMargin?: number;
|
|
735
810
|
/**
|
|
@@ -810,8 +885,17 @@ export interface AxisLabelConfig {
|
|
|
810
885
|
}
|
|
811
886
|
/** X-axis (time) configuration. */
|
|
812
887
|
export interface XAxisConfig {
|
|
813
|
-
/** Minimum pixel gap between time labels. Default `60`. */
|
|
888
|
+
/** Minimum pixel gap between time labels. Changes apply immediately, even while paused. Default `60`. */
|
|
814
889
|
minGap?: number;
|
|
890
|
+
/**
|
|
891
|
+
* Vertical grid lines at the time-axis ticks, drawn behind the series in the
|
|
892
|
+
* same layer as the horizontal grid. Each line sits under a time label and
|
|
893
|
+
* fades with it. `true` = the {@link LiveChartCoreProps.gridStyle} look, or
|
|
894
|
+
* pass a `GridStyleConfig` to override fields of it (omitted fields fall back
|
|
895
|
+
* to `gridStyle`). Strokes stay inside the plot's horizontal bounds, including
|
|
896
|
+
* while a departing label fades into a gutter. Default `false`.
|
|
897
|
+
*/
|
|
898
|
+
gridLines?: boolean | GridStyleConfig;
|
|
815
899
|
}
|
|
816
900
|
/**
|
|
817
901
|
* Auto-hide both axes while idle (see {@link LiveChartCoreProps.axisAutoHide}).
|
|
@@ -909,8 +993,25 @@ export interface PerSeriesTooltipConfig {
|
|
|
909
993
|
/** Diameter of the dot drawn at each line/guide intersection. Default `8`. */
|
|
910
994
|
intersectionDotSize?: number;
|
|
911
995
|
}
|
|
996
|
+
/** Timestamp matching for marker details while scrubbing. */
|
|
997
|
+
export interface ScrubMarkerConfig {
|
|
998
|
+
/**
|
|
999
|
+
* Horizontal distance in canvas px on either side of the crosshair in line
|
|
1000
|
+
* mode. Default `16`; negative values clamp to `0`. Candle mode instead
|
|
1001
|
+
* selects the hovered bucket's [time, time + candleWidth) interval.
|
|
1002
|
+
*/
|
|
1003
|
+
radius?: number;
|
|
1004
|
+
}
|
|
912
1005
|
/** Crosshair scrub configuration. */
|
|
913
1006
|
export interface ScrubConfig {
|
|
1007
|
+
/**
|
|
1008
|
+
* Include matching markers in `onScrub` and `LiveChart.renderTooltip`.
|
|
1009
|
+
* `true` uses a 16 px horizontal tolerance in line mode; an object tunes it.
|
|
1010
|
+
* Candle mode returns all markers in the hovered candle's time bucket.
|
|
1011
|
+
* Matches preserve input order and include stacked/collapsed members,
|
|
1012
|
+
* independent of glyph Y/offsets. Gaps select none. Default `false`.
|
|
1013
|
+
*/
|
|
1014
|
+
markers?: boolean | ScrubMarkerConfig;
|
|
914
1015
|
/** Show the value/time tooltip pill while scrubbing. Default `true`. */
|
|
915
1016
|
tooltip?: boolean;
|
|
916
1017
|
/**
|
|
@@ -1164,6 +1265,12 @@ export interface SelectionDotProps {
|
|
|
1164
1265
|
* for the value/date to update on the UI thread too.
|
|
1165
1266
|
*/
|
|
1166
1267
|
export interface TooltipRenderProps {
|
|
1268
|
+
/**
|
|
1269
|
+
* Markers matched by `scrub.markers`, including their `data`. Empty when
|
|
1270
|
+
* disabled, inactive, in a gap, or without a match. Updated on the UI thread;
|
|
1271
|
+
* bind in an animated component rather than reading during React render.
|
|
1272
|
+
*/
|
|
1273
|
+
markers: SharedValue<Marker[]>;
|
|
1167
1274
|
/**
|
|
1168
1275
|
* Value under the crosshair; `null` when none. In line mode this is the
|
|
1169
1276
|
* interpolated value at the scrub time; in candle mode it's the scrubbed
|
|
@@ -1434,7 +1541,7 @@ export interface Marker {
|
|
|
1434
1541
|
* when `markerCluster: "stacked"` — e.g. buys `"below"`, sells `"above"`.
|
|
1435
1542
|
*/
|
|
1436
1543
|
side?: MarkerSide;
|
|
1437
|
-
/** Pass-through payload surfaced on `onMarkerPress
|
|
1544
|
+
/** Pass-through payload surfaced on `onMarkerPress` and opt-in scrub matches. */
|
|
1438
1545
|
data?: unknown;
|
|
1439
1546
|
}
|
|
1440
1547
|
/** Where a marker glyph sits relative to its anchor (and the stack direction). */
|
|
@@ -1754,6 +1861,11 @@ export interface ScrubSeriesValue {
|
|
|
1754
1861
|
}
|
|
1755
1862
|
/** Base fields shared by single and multi-series scrub callback payloads. */
|
|
1756
1863
|
export interface ScrubPointCore {
|
|
1864
|
+
/**
|
|
1865
|
+
* Matching markers (including `data`) when `scrub.markers` is enabled; `[]`
|
|
1866
|
+
* when none match. Omitted when disabled. See {@link ScrubConfig.markers}.
|
|
1867
|
+
*/
|
|
1868
|
+
markers?: Marker[];
|
|
1757
1869
|
/** Unix timestamp in seconds at the scrub position. */
|
|
1758
1870
|
time: number;
|
|
1759
1871
|
/** Interpolated value at the scrub position. */
|
|
@@ -2052,15 +2164,19 @@ export interface ZoomConfig {
|
|
|
2052
2164
|
minTimeWindow?: number;
|
|
2053
2165
|
/**
|
|
2054
2166
|
* Widest visible window in seconds (max zoom-out). Defaults to the full data
|
|
2055
|
-
* span (you can zoom out to all retained history), never below `timeWindow
|
|
2167
|
+
* span (you can zoom out to all retained history), never below `timeWindow`
|
|
2168
|
+
* unless explicitly set. LiveChartSeries also includes
|
|
2169
|
+
* its anchored full-history span when historyStartTime is supplied.
|
|
2056
2170
|
*/
|
|
2057
2171
|
maxTimeWindow?: number;
|
|
2058
2172
|
}
|
|
2059
2173
|
/** Imperative methods exposed by `LiveChart` and `LiveChartSeries`. */
|
|
2060
2174
|
export interface LiveChartHandle {
|
|
2061
2175
|
/**
|
|
2062
|
-
* Reset built-in pinch/time-window zoom to the configured `timeWindow`
|
|
2176
|
+
* Reset built-in pinch/time-window zoom to the configured `timeWindow`
|
|
2177
|
+
* (or LiveChartSeries historyStartTime span) and
|
|
2063
2178
|
* clear the focal-point offset so the chart follows the live edge again.
|
|
2179
|
+
* On LiveChart with viewport, clears the supplied end/window shared values.
|
|
2064
2180
|
* Safe to call when already reset. A paused chart remains paused.
|
|
2065
2181
|
*
|
|
2066
2182
|
* ```tsx
|
|
@@ -2173,6 +2289,25 @@ export interface RangeAnimationConfig {
|
|
|
2173
2289
|
*/
|
|
2174
2290
|
contractionSmoothing?: number;
|
|
2175
2291
|
}
|
|
2292
|
+
/** Y-range easing and optional presentation transform for {@link LiveChartSeries}. */
|
|
2293
|
+
export interface SeriesRangeAnimationConfig extends RangeAnimationConfig {
|
|
2294
|
+
/**
|
|
2295
|
+
* UI-thread worklet applied after normal fitting/easing. Receives untransformed
|
|
2296
|
+
* display bounds and the visible Unix-second interval; may read SharedValues.
|
|
2297
|
+
* Returned finite, increasing bounds affect presentation only and never feed
|
|
2298
|
+
* back into fitting. Invalid results are ignored. Removing it restores the
|
|
2299
|
+
* untransformed range. Hard bounds are applied to the fit before this transform.
|
|
2300
|
+
*/
|
|
2301
|
+
transform?: (range: {
|
|
2302
|
+
min: number;
|
|
2303
|
+
max: number;
|
|
2304
|
+
from: number;
|
|
2305
|
+
to: number;
|
|
2306
|
+
}) => {
|
|
2307
|
+
min: number;
|
|
2308
|
+
max: number;
|
|
2309
|
+
};
|
|
2310
|
+
}
|
|
2176
2311
|
/** Props shared between `LiveChart` and `LiveChartSeries`. */
|
|
2177
2312
|
export interface LiveChartCoreProps {
|
|
2178
2313
|
/** Color scheme. Default `"dark"`. */
|
|
@@ -2287,13 +2422,29 @@ export interface LiveChartCoreProps {
|
|
|
2287
2422
|
* axes (prices, market caps).
|
|
2288
2423
|
*/
|
|
2289
2424
|
maxValue?: number;
|
|
2425
|
+
/**
|
|
2426
|
+
* Smallest auto-fitted Y span, in data units. A narrower bounded fit widens
|
|
2427
|
+
* around its midpoint, giving near-flat data room for distinct grid labels
|
|
2428
|
+
* (e.g. pass a few multiples of the display precision). `nonNegative` and
|
|
2429
|
+
* `maxValue` shift the span; if both leave less room than the floor, the hard
|
|
2430
|
+
* bounds win. Manual `yRangeScale` zoom applies afterward and may go below
|
|
2431
|
+
* the floor. Usual range easing applies; static charts re-settle on changes.
|
|
2432
|
+
* Positive finite values only; invalid or overflowing floors are ignored.
|
|
2433
|
+
* Omit for no floor.
|
|
2434
|
+
*/
|
|
2435
|
+
minRange?: number;
|
|
2290
2436
|
/**
|
|
2291
2437
|
* Live manual Y-range multiplier around the fitted midpoint (`1` = auto-fit).
|
|
2292
|
-
*
|
|
2438
|
+
* Enable `yAxis.scaleGesture` or drive it from your own gesture to stretch or
|
|
2293
2439
|
* compress the price scale TradingView-style; the auto-fit keeps tracking
|
|
2294
2440
|
* the visible window underneath. Values must be positive and finite; invalid
|
|
2295
2441
|
* values fall back to `1`. Read on the UI thread each frame. Supported by
|
|
2296
|
-
* both `LiveChart` and `LiveChartSeries`.
|
|
2442
|
+
* both `LiveChart` and `LiveChartSeries`. Static single-series charts also
|
|
2443
|
+
* re-settle when this SharedValue changes, without replacing data. Default `1`.
|
|
2444
|
+
* Series drawing is clipped vertically to the price plot; candle volume bars
|
|
2445
|
+
* remain outside that clip. Automatic volume-band reservation respects an
|
|
2446
|
+
* explicit bottom inset. The built-in axis gesture uses an internal multiplier
|
|
2447
|
+
* when this prop is omitted.
|
|
2297
2448
|
*
|
|
2298
2449
|
* @experimental
|
|
2299
2450
|
*/
|
|
@@ -2303,8 +2454,12 @@ export interface LiveChartCoreProps {
|
|
|
2303
2454
|
* points or committed candles. Default `"No data"`.
|
|
2304
2455
|
*/
|
|
2305
2456
|
emptyText?: string;
|
|
2306
|
-
/**
|
|
2307
|
-
|
|
2457
|
+
/**
|
|
2458
|
+
* Worklet formatter for value labels. Y-axis ticks pass their interval in
|
|
2459
|
+
* source units as `tickStep`; badges, tooltips and layout samples omit it.
|
|
2460
|
+
* Existing one-argument formatters remain valid. Default `v => v.toFixed(2)`.
|
|
2461
|
+
*/
|
|
2462
|
+
formatValue?: (v: number, tickStep?: number) => string;
|
|
2308
2463
|
/** Custom formatter for time labels. Default renders `HH:MM:SS`. */
|
|
2309
2464
|
formatTime?: (t: number) => string;
|
|
2310
2465
|
/** Y-axis grid lines + labels. `true` = defaults, `false` = hidden, or pass `YAxisConfig`. Default `true`. */
|
|
@@ -2428,6 +2583,7 @@ export interface LiveChartCoreProps {
|
|
|
2428
2583
|
* no longer passed — **glides** the window back to the live edge (a brief eased
|
|
2429
2584
|
* animation, not an instant jump); it never stays frozen at the previous scroll
|
|
2430
2585
|
* position. Tune or disable that glide with {@link returnToLive}.
|
|
2586
|
+
* On LiveChart with viewport, disabling gestures preserves the supplied state.
|
|
2431
2587
|
*
|
|
2432
2588
|
* `true` uses the default drag-to-scroll gesture (`"holdToScrub"`); pass a
|
|
2433
2589
|
* {@link TimeScrollConfig} to pick the activation (`"holdToScrub"` or
|
|
@@ -2510,8 +2666,40 @@ export interface LiveChartCoreProps {
|
|
|
2510
2666
|
/** Main chart line styling. */
|
|
2511
2667
|
line?: LineConfig;
|
|
2512
2668
|
}
|
|
2669
|
+
/**
|
|
2670
|
+
* UI-thread scroll/zoom state adopted by a single-series {@link LiveChart}.
|
|
2671
|
+
* The app owns leadership and timestamp mapping; gestures write these same values.
|
|
2672
|
+
* @experimental
|
|
2673
|
+
*/
|
|
2674
|
+
export interface ChartViewportControl {
|
|
2675
|
+
/** Right-edge unix timestamp in seconds; null follows this chart's live edge.
|
|
2676
|
+
* Honors times past live. An end before the first retained point falls back to live. */
|
|
2677
|
+
end: SharedValue<number | null>;
|
|
2678
|
+
/** Positive, finite visible width in seconds; null uses the timeWindow prop. */
|
|
2679
|
+
window: SharedValue<number | null>;
|
|
2680
|
+
}
|
|
2681
|
+
/** External viewport state and optional behavior settings for {@link LiveChart}.
|
|
2682
|
+
* Pass an object to adopt its shared values; false/omitted uses private state.
|
|
2683
|
+
* @experimental
|
|
2684
|
+
*/
|
|
2685
|
+
export interface ViewportConfig extends ChartViewportControl {
|
|
2686
|
+
/** Ease non-null window overrides using the chart's smoothing. Default true.
|
|
2687
|
+
* Set false on followers copying a leader's drawn width to avoid easing twice.
|
|
2688
|
+
* Null windows still ease back to timeWindow; Y-range/value smoothing is unchanged. */
|
|
2689
|
+
windowSmoothing?: boolean;
|
|
2690
|
+
}
|
|
2513
2691
|
/** Props for the single-series `LiveChart` component. */
|
|
2514
2692
|
export interface LiveChartProps extends LiveChartCoreProps {
|
|
2693
|
+
/**
|
|
2694
|
+
* Adopt external UI-thread scroll/zoom state. Pan and pinch write the supplied
|
|
2695
|
+
* values; resetZoom() clears both. Non-null overrides survive timeWindow changes
|
|
2696
|
+
* and timeScroll being disabled. External writes work without enabling gestures
|
|
2697
|
+
* and wake autoSleep charts. Single-series line/candle only.
|
|
2698
|
+
* Pass a ViewportConfig object to enable; false/omitted uses private state.
|
|
2699
|
+
* Both shared values are required, so this prop has no true shorthand.
|
|
2700
|
+
* @experimental
|
|
2701
|
+
*/
|
|
2702
|
+
viewport?: false | ViewportConfig;
|
|
2515
2703
|
/** Area gradient fill under the line. `true` = defaults, or pass `GradientConfig`. Default `true`. */
|
|
2516
2704
|
gradient?: boolean | GradientConfig;
|
|
2517
2705
|
/**
|
|
@@ -2606,7 +2794,10 @@ export interface LiveChartProps extends LiveChartCoreProps {
|
|
|
2606
2794
|
* but `scrub` / `scrubAction` stay available — they're on-demand touch gestures with
|
|
2607
2795
|
* no per-frame cost, so a still chart is still scrubbable. May be toggled at runtime:
|
|
2608
2796
|
* switching back to live restarts the suspended loops and catches up. Frame the data
|
|
2609
|
-
* with `timeWindow` + `nowOverride` (see the historical-data-fill pattern).
|
|
2797
|
+
* with `timeWindow` + `nowOverride` (see the historical-data-fill pattern). Data,
|
|
2798
|
+
* layout, `timeWindow`, and `nowOverride` changes re-settle without restarting the
|
|
2799
|
+
* loop. Entering static mode lands on the new window even when data and framing
|
|
2800
|
+
* change in the same render (for example, a recycled list cell). */
|
|
2610
2801
|
static?: boolean;
|
|
2611
2802
|
/**
|
|
2612
2803
|
* Runtime gate for continuous frame work. Set this SharedValue to `false`
|
|
@@ -2647,8 +2838,20 @@ export interface LiveChartProps extends LiveChartCoreProps {
|
|
|
2647
2838
|
* Single-series only.
|
|
2648
2839
|
*/
|
|
2649
2840
|
renderOverlay?: (ctx: ChartOverlayContext) => ReactElement | null | undefined;
|
|
2650
|
-
/**
|
|
2841
|
+
/**
|
|
2842
|
+
* JS-thread callback while scrubbing; `null` when scrub ends. With
|
|
2843
|
+
* `scrub.markers` enabled, includes matching markers and also sends `null`
|
|
2844
|
+
* when a valid point becomes unavailable (for example an unpriced gap).
|
|
2845
|
+
*/
|
|
2651
2846
|
onScrub?: (point: ScrubPoint | null) => void;
|
|
2847
|
+
/**
|
|
2848
|
+
* Called on the JS thread when the crosshair enters a different candle,
|
|
2849
|
+
* with a snapshot of its OHLC at entry. Re-entering a candle fires again;
|
|
2850
|
+
* ticks within the same candle do not. Called with `null` when the scrub
|
|
2851
|
+
* ends, enters a gap, or leaves candle mode. Idle in line mode. Unlike
|
|
2852
|
+
* {@link onScrub}, it does not stream per-frame candle updates.
|
|
2853
|
+
*/
|
|
2854
|
+
onScrubCandleChange?: (candle: CandlePoint | null) => void;
|
|
2652
2855
|
/**
|
|
2653
2856
|
* Scrub-action ("order ticket") mode: tap to drop a locked crosshair, drag to
|
|
2654
2857
|
* fine-tune a **price level**, then press the right-gutter action badge to fire
|
|
@@ -2697,14 +2900,12 @@ export interface LiveChartProps extends LiveChartCoreProps {
|
|
|
2697
2900
|
*/
|
|
2698
2901
|
renderOffAxisReferenceLine?: (ctx: ReferenceLineRenderProps) => ReactElement | null | undefined;
|
|
2699
2902
|
/**
|
|
2700
|
-
*
|
|
2701
|
-
*
|
|
2702
|
-
*
|
|
2703
|
-
*
|
|
2704
|
-
*
|
|
2705
|
-
* {@link
|
|
2706
|
-
* custom tag draws itself), so the count reflects only collapsed built-in tags.
|
|
2707
|
-
* Single-series only. Default off.
|
|
2903
|
+
* Resolve nearby Form-A tags. `true` uses the existing count-pill collapse;
|
|
2904
|
+
* `{ mode: "stack" }` separates built-in and custom tags without moving their
|
|
2905
|
+
* price lines. Stacking respects measured tag sizes, separate horizontal
|
|
2906
|
+
* columns, and the visible live value badge (opt out with `avoidValueBadge`).
|
|
2907
|
+
* Count-pill styling/format apply only to collapse mode. Single-series only.
|
|
2908
|
+
* Default off. See {@link ReferenceLineGroupingConfig}.
|
|
2708
2909
|
*/
|
|
2709
2910
|
referenceLineGrouping?: boolean | ReferenceLineGroupingConfig;
|
|
2710
2911
|
/**
|
|
@@ -2723,6 +2924,28 @@ export interface LiveChartProps extends LiveChartCoreProps {
|
|
|
2723
2924
|
}
|
|
2724
2925
|
/** Props for the multi-series `LiveChartSeries` component. */
|
|
2725
2926
|
export interface LiveChartSeriesProps extends LiveChartCoreProps {
|
|
2927
|
+
/**
|
|
2928
|
+
* UI-thread presentation clock in Unix seconds. Each frame reads this head;
|
|
2929
|
+
* undefined falls back to nowOverride or wall time. Paths/dots end at the
|
|
2930
|
+
* earlier of the viewport edge and head, leaving windowBuffer empty. Samples
|
|
2931
|
+
* after this head are excluded from paths and range fitting. Scrub time limits
|
|
2932
|
+
* and values use the same cutoff, including callback payloads and tooltip
|
|
2933
|
+
* interpolation. Degen bursts originate at the presented dot. No React
|
|
2934
|
+
* render is required for clock updates.
|
|
2935
|
+
*/
|
|
2936
|
+
presentationTime?: SharedValue<number | undefined>;
|
|
2937
|
+
/**
|
|
2938
|
+
* Authoritative history start (Unix seconds). While following without a zoom
|
|
2939
|
+
* override, grows the window to keep this time at the left edge, including
|
|
2940
|
+
* `windowBuffer` (must be < 1). Pan/zoom overrides remain usable; resetZoom()
|
|
2941
|
+
* restores following. A non-finite or future start falls back to timeWindow.
|
|
2942
|
+
*/
|
|
2943
|
+
historyStartTime?: number;
|
|
2944
|
+
/**
|
|
2945
|
+
* Shared-range easing plus an optional reversible UI-thread presentation
|
|
2946
|
+
* transform. See {@link SeriesRangeAnimationConfig}; recorded values remain unchanged.
|
|
2947
|
+
*/
|
|
2948
|
+
rangeAnimation?: SeriesRangeAnimationConfig;
|
|
2726
2949
|
/** Array of series definitions. Must be a SharedValue for UI-thread reads. */
|
|
2727
2950
|
series: SharedValue<SeriesConfig[]>;
|
|
2728
2951
|
/**
|
|
@@ -2774,6 +2997,8 @@ export interface LiveChartSeriesProps extends LiveChartCoreProps {
|
|
|
2774
2997
|
/**
|
|
2775
2998
|
* Worklet callback fired on the UI thread each frame while scrubbing.
|
|
2776
2999
|
* `null` when scrub ends. Update shared values directly — no bridge overhead.
|
|
3000
|
+
* With `scrub.markers` enabled, includes matching markers and also sends
|
|
3001
|
+
* `null` when a previously valid point becomes unavailable.
|
|
2777
3002
|
*
|
|
2778
3003
|
* ```ts
|
|
2779
3004
|
* const scrubData = useSharedValue<ScrubPointMulti | null>(null);
|