react-native-livechart 4.26.0 → 4.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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 +2 -0
- 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 +7 -0
- package/dist/core/useLiveChartEngine.d.ts.map +1 -1
- package/dist/core/useLiveChartSeriesEngine.d.ts +2 -0
- package/dist/core/useLiveChartSeriesEngine.d.ts.map +1 -1
- package/dist/draw/grid.d.ts +2 -2
- package/dist/draw/line.d.ts +15 -1
- package/dist/draw/line.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 +8 -0
- 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 +4 -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/usePanScroll.d.ts +3 -1
- package/dist/hooks/usePanScroll.d.ts.map +1 -1
- 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/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/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 +202 -32
- 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 +560 -138
- package/src/components/LiveChartSeries.tsx +113 -13
- 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 +37 -0
- package/src/core/resolveConfig.ts +95 -2
- package/src/core/useLiveChartEngine.ts +43 -9
- package/src/core/useLiveChartSeriesEngine.ts +5 -0
- package/src/draw/grid.ts +2 -2
- package/src/draw/line.ts +23 -1
- package/src/hooks/crosshairShared.ts +56 -1
- package/src/hooks/referenceBadgeFont.ts +35 -0
- package/src/hooks/resolveChartLayout.ts +17 -0
- 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 +29 -10
- package/src/hooks/useLatestCallback.ts +15 -0
- package/src/hooks/useMarkers.ts +51 -39
- package/src/hooks/usePanScroll.ts +155 -127
- package/src/hooks/usePinchZoom.ts +84 -63
- package/src/hooks/useReferenceDrag.ts +390 -155
- 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/useYAxisScaleGesture.ts +263 -0
- package/src/index.ts +10 -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/referenceTagStack.ts +112 -0
- package/src/math/scrubMarkers.ts +55 -0
- package/src/types.ts +207 -32
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.
|
|
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;
|
|
@@ -217,15 +231,18 @@ export interface ReferenceLine {
|
|
|
217
231
|
*/
|
|
218
232
|
bounds?: [number, number];
|
|
219
233
|
/**
|
|
220
|
-
* Fired on the JS thread *while* dragging, each time the
|
|
221
|
-
* value
|
|
222
|
-
*
|
|
234
|
+
* Fired on the JS thread *while* dragging, each time the finger moves the line
|
|
235
|
+
* to a new (snapped, clamped) value. De-duplicated to value changes — not every
|
|
236
|
+
* frame. When the range moves under a still finger the line follows it without
|
|
237
|
+
* firing this; on release it fires once more if the line ended elsewhere, with
|
|
238
|
+
* the value {@link onCommit} gets (its first call, if the finger never changed
|
|
239
|
+
* the value). Form-A draggable only.
|
|
223
240
|
*/
|
|
224
241
|
onChange?: (value: number) => void;
|
|
225
242
|
/**
|
|
226
243
|
* Fired once on the JS thread when the drag ends (finger up), with the final
|
|
227
|
-
* (snapped, clamped) value. Pair with a controlled
|
|
228
|
-
* Form-A draggable only.
|
|
244
|
+
* (snapped, clamped) value — the one under the finger. Pair with a controlled
|
|
245
|
+
* `value` to persist the move. Form-A draggable only.
|
|
229
246
|
*/
|
|
230
247
|
onCommit?: (value: number) => void;
|
|
231
248
|
/**
|
|
@@ -305,6 +322,15 @@ export interface ReferenceLineBadgeConfig extends BadgeStyleConfig {
|
|
|
305
322
|
text?: boolean;
|
|
306
323
|
}
|
|
307
324
|
|
|
325
|
+
/** Separate price pill for a horizontal reference line. Style defaults match
|
|
326
|
+
* the reference badge; the font falls back to the chart font. */
|
|
327
|
+
export interface ReferenceLineValueBadgeConfig extends BadgeStyleConfig {
|
|
328
|
+
/** `"right"`: inside the plot; `"axis"`: right price column, even when the live
|
|
329
|
+
* badge is hidden or placed left. A floating axis uses the canvas right edge.
|
|
330
|
+
* Default `"right"`. Placement is independent of the name badge. */
|
|
331
|
+
position?: "right" | "axis";
|
|
332
|
+
}
|
|
333
|
+
|
|
308
334
|
/**
|
|
309
335
|
* Context passed to a custom {@link LiveChartProps.renderReferenceLine} or
|
|
310
336
|
* {@link LiveChartProps.renderOffAxisReferenceLine} (and their
|
|
@@ -329,6 +355,11 @@ export interface ReferenceLineRenderProps {
|
|
|
329
355
|
valueStr: SharedValue<string>;
|
|
330
356
|
/** Canvas Y pixel of the line, recomputed each frame (`-1` when not laid out). */
|
|
331
357
|
y: SharedValue<number>;
|
|
358
|
+
/** Extra vertical displacement from reference-tag stacking, in canvas pixels.
|
|
359
|
+
* The chart applies it to the custom element automatically; `y` keeps its
|
|
360
|
+
* original projection. Use this to draw a connector, not a second transform.
|
|
361
|
+
* Zero when stacking is off (including LiveChartSeries). */
|
|
362
|
+
tagOffsetY: SharedValue<number>;
|
|
332
363
|
/** Whether the value currently sits within the visible plot range. */
|
|
333
364
|
inRange: SharedValue<boolean>;
|
|
334
365
|
/**
|
|
@@ -342,18 +373,23 @@ export interface ReferenceLineRenderProps {
|
|
|
342
373
|
}
|
|
343
374
|
|
|
344
375
|
/**
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
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.
|
|
376
|
+
* Tag collision behavior for single-series reference lines. `true` uses collapse
|
|
377
|
+
* mode, replacing nearby built-in tags with a count pill. Stack mode keeps each
|
|
378
|
+
* built-in or measured custom tag, separating overlapping horizontal columns
|
|
379
|
+
* while price strokes stay at their values. Hidden off-axis lines do not count.
|
|
352
380
|
*/
|
|
353
381
|
export interface ReferenceLineGroupingConfig {
|
|
354
|
-
/**
|
|
355
|
-
*
|
|
356
|
-
*
|
|
382
|
+
/** `"collapse"` merges nearby tags into a count (default). `"stack"` keeps
|
|
383
|
+
* each price line and separates overlapping tags by their measured bounds.
|
|
384
|
+
* Custom tags participate in stack mode; separate horizontal columns pack
|
|
385
|
+
* independently. Single-series only. */
|
|
386
|
+
mode?: "collapse" | "stack";
|
|
387
|
+
/** Stack mode: keep tags clear of the visible live value badge. Default `true`.
|
|
388
|
+
* Best effort when there is insufficient plot height; ignored in collapse mode. */
|
|
389
|
+
avoidValueBadge?: boolean;
|
|
390
|
+
/**
|
|
391
|
+
* Collapse mode: proximity radius. Stack mode: minimum center-to-center gap;
|
|
392
|
+
* measured tag heights plus 2 px take precedence. Default `18`.
|
|
357
393
|
*/
|
|
358
394
|
radius?: number;
|
|
359
395
|
/**
|
|
@@ -426,7 +462,7 @@ export interface ChartSegment {
|
|
|
426
462
|
labelPosition?: "left" | "right";
|
|
427
463
|
}
|
|
428
464
|
|
|
429
|
-
/**
|
|
465
|
+
/** Grid-line styling for the horizontal value axis and optional xAxis.gridLines. */
|
|
430
466
|
export interface GridStyleConfig {
|
|
431
467
|
/** Stroke color. Defaults to palette `gridLine`. */
|
|
432
468
|
color?: string;
|
|
@@ -711,6 +747,19 @@ export interface BadgeConfig extends BadgeStyleConfig {
|
|
|
711
747
|
tail?: boolean;
|
|
712
748
|
/** Which side of the chart the badge appears on. Default `"right"`. */
|
|
713
749
|
position?: "right" | "left";
|
|
750
|
+
/**
|
|
751
|
+
* Where the value sits in the right-gutter pill. `"center"` centers it in the
|
|
752
|
+
* pill body. `"yAxisColumn"` lines it up with a right-anchored Y-axis label
|
|
753
|
+
* column ({@link YAxisConfig.labelRightMargin}): it starts at the labels'
|
|
754
|
+
* shared left X, and a value wider than every axis label ends at the
|
|
755
|
+
* column's right edge. The pill keeps its shape and the value stays within
|
|
756
|
+
* its `padX` padding (a value that doesn't fit there is centered), so the
|
|
757
|
+
* room on each side follows the right inset and `metrics.badge`. The value
|
|
758
|
+
* moves sideways when the column's width changes (a wider label entering or
|
|
759
|
+
* leaving the axis). Centered without that column on the right side, while
|
|
760
|
+
* the axis floats, and for a `"left"` badge. Default `"center"`.
|
|
761
|
+
*/
|
|
762
|
+
textAlign?: "center" | "yAxisColumn";
|
|
714
763
|
/**
|
|
715
764
|
* When the chart is scrolled back (see `timeScroll`), move the live-price
|
|
716
765
|
* indicators — the badge, the value line, and the live dot — to the price at
|
|
@@ -747,8 +796,28 @@ export interface VolumeConfig {
|
|
|
747
796
|
opacity?: number;
|
|
748
797
|
}
|
|
749
798
|
|
|
799
|
+
/** Built-in vertical drag on the price axis. Bounds affect gesture writes only. */
|
|
800
|
+
export interface YAxisScaleGestureConfig {
|
|
801
|
+
/** Smallest multiplier. Positive and finite. Default `0.25`. */
|
|
802
|
+
minScale?: number;
|
|
803
|
+
/** Largest multiplier. Positive and finite, raised to minScale if lower. Default `10`. */
|
|
804
|
+
maxScale?: number;
|
|
805
|
+
/** Vertical points per exponential step (e×). Positive and finite. Default `160`. */
|
|
806
|
+
dragDistance?: number;
|
|
807
|
+
/** Double-tap the axis to animate to `1` (clamped to the bounds). Default `true`. */
|
|
808
|
+
doubleTapReset?: boolean;
|
|
809
|
+
}
|
|
810
|
+
|
|
750
811
|
/** Y-axis grid configuration. */
|
|
751
812
|
export interface YAxisConfig {
|
|
813
|
+
/**
|
|
814
|
+
* Opt into vertical price-axis dragging: down widens the range, up zooms in.
|
|
815
|
+
* Uses the rendered axis gutter/label column on either side. Interactive
|
|
816
|
+
* markers and reference badges retain priority. Plot gestures are unchanged.
|
|
817
|
+
* Writes `yRangeScale` when supplied, otherwise an internal multiplier.
|
|
818
|
+
* `true` uses defaults; an object customizes bounds/reset. Default `false`.
|
|
819
|
+
*/
|
|
820
|
+
scaleGesture?: boolean | YAxisScaleGestureConfig;
|
|
752
821
|
/** Price-label side. For left placement, reserve the label gutter with insets.left.
|
|
753
822
|
* Right-side float/labelRightMargin options do not affect left labels. Default "right". */
|
|
754
823
|
side?: "left" | "right";
|
|
@@ -778,7 +847,8 @@ export interface YAxisConfig {
|
|
|
778
847
|
/**
|
|
779
848
|
* Place price labels in a shared left-aligned column whose right edge sits
|
|
780
849
|
* this many pixels from the canvas edge. When omitted, labels keep the
|
|
781
|
-
* default centered-gutter placement.
|
|
850
|
+
* default centered-gutter placement. To line the live badge's value up with
|
|
851
|
+
* the column, set {@link BadgeConfig.textAlign} to `"yAxisColumn"`.
|
|
782
852
|
*/
|
|
783
853
|
labelRightMargin?: number;
|
|
784
854
|
/**
|
|
@@ -861,8 +931,17 @@ export interface AxisLabelConfig {
|
|
|
861
931
|
|
|
862
932
|
/** X-axis (time) configuration. */
|
|
863
933
|
export interface XAxisConfig {
|
|
864
|
-
/** Minimum pixel gap between time labels. Default `60`. */
|
|
934
|
+
/** Minimum pixel gap between time labels. Changes apply immediately, even while paused. Default `60`. */
|
|
865
935
|
minGap?: number;
|
|
936
|
+
/**
|
|
937
|
+
* Vertical grid lines at the time-axis ticks, drawn behind the series in the
|
|
938
|
+
* same layer as the horizontal grid. Each line sits under a time label and
|
|
939
|
+
* fades with it. `true` = the {@link LiveChartCoreProps.gridStyle} look, or
|
|
940
|
+
* pass a `GridStyleConfig` to override fields of it (omitted fields fall back
|
|
941
|
+
* to `gridStyle`). Strokes stay inside the plot's horizontal bounds, including
|
|
942
|
+
* while a departing label fades into a gutter. Default `false`.
|
|
943
|
+
*/
|
|
944
|
+
gridLines?: boolean | GridStyleConfig;
|
|
866
945
|
}
|
|
867
946
|
|
|
868
947
|
/**
|
|
@@ -966,8 +1045,26 @@ export interface PerSeriesTooltipConfig {
|
|
|
966
1045
|
intersectionDotSize?: number;
|
|
967
1046
|
}
|
|
968
1047
|
|
|
1048
|
+
/** Timestamp matching for marker details while scrubbing. */
|
|
1049
|
+
export interface ScrubMarkerConfig {
|
|
1050
|
+
/**
|
|
1051
|
+
* Horizontal distance in canvas px on either side of the crosshair in line
|
|
1052
|
+
* mode. Default `16`; negative values clamp to `0`. Candle mode instead
|
|
1053
|
+
* selects the hovered bucket's [time, time + candleWidth) interval.
|
|
1054
|
+
*/
|
|
1055
|
+
radius?: number;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
969
1058
|
/** Crosshair scrub configuration. */
|
|
970
1059
|
export interface ScrubConfig {
|
|
1060
|
+
/**
|
|
1061
|
+
* Include matching markers in `onScrub` and `LiveChart.renderTooltip`.
|
|
1062
|
+
* `true` uses a 16 px horizontal tolerance in line mode; an object tunes it.
|
|
1063
|
+
* Candle mode returns all markers in the hovered candle's time bucket.
|
|
1064
|
+
* Matches preserve input order and include stacked/collapsed members,
|
|
1065
|
+
* independent of glyph Y/offsets. Gaps select none. Default `false`.
|
|
1066
|
+
*/
|
|
1067
|
+
markers?: boolean | ScrubMarkerConfig;
|
|
971
1068
|
/** Show the value/time tooltip pill while scrubbing. Default `true`. */
|
|
972
1069
|
tooltip?: boolean;
|
|
973
1070
|
/**
|
|
@@ -1225,6 +1322,12 @@ export interface SelectionDotProps {
|
|
|
1225
1322
|
* for the value/date to update on the UI thread too.
|
|
1226
1323
|
*/
|
|
1227
1324
|
export interface TooltipRenderProps {
|
|
1325
|
+
/**
|
|
1326
|
+
* Markers matched by `scrub.markers`, including their `data`. Empty when
|
|
1327
|
+
* disabled, inactive, in a gap, or without a match. Updated on the UI thread;
|
|
1328
|
+
* bind in an animated component rather than reading during React render.
|
|
1329
|
+
*/
|
|
1330
|
+
markers: SharedValue<Marker[]>;
|
|
1228
1331
|
/**
|
|
1229
1332
|
* Value under the crosshair; `null` when none. In line mode this is the
|
|
1230
1333
|
* interpolated value at the scrub time; in candle mode it's the scrubbed
|
|
@@ -1508,7 +1611,7 @@ export interface Marker {
|
|
|
1508
1611
|
* when `markerCluster: "stacked"` — e.g. buys `"below"`, sells `"above"`.
|
|
1509
1612
|
*/
|
|
1510
1613
|
side?: MarkerSide;
|
|
1511
|
-
/** Pass-through payload surfaced on `onMarkerPress
|
|
1614
|
+
/** Pass-through payload surfaced on `onMarkerPress` and opt-in scrub matches. */
|
|
1512
1615
|
data?: unknown;
|
|
1513
1616
|
}
|
|
1514
1617
|
|
|
@@ -1841,6 +1944,11 @@ export interface ScrubSeriesValue {
|
|
|
1841
1944
|
|
|
1842
1945
|
/** Base fields shared by single and multi-series scrub callback payloads. */
|
|
1843
1946
|
export interface ScrubPointCore {
|
|
1947
|
+
/**
|
|
1948
|
+
* Matching markers (including `data`) when `scrub.markers` is enabled; `[]`
|
|
1949
|
+
* when none match. Omitted when disabled. See {@link ScrubConfig.markers}.
|
|
1950
|
+
*/
|
|
1951
|
+
markers?: Marker[];
|
|
1844
1952
|
/** Unix timestamp in seconds at the scrub position. */
|
|
1845
1953
|
time: number;
|
|
1846
1954
|
/** Interpolated value at the scrub position. */
|
|
@@ -2174,6 +2282,7 @@ export interface LiveChartHandle {
|
|
|
2174
2282
|
/**
|
|
2175
2283
|
* Reset built-in pinch/time-window zoom to the configured `timeWindow` and
|
|
2176
2284
|
* clear the focal-point offset so the chart follows the live edge again.
|
|
2285
|
+
* On LiveChart with viewport, clears the supplied end/window shared values.
|
|
2177
2286
|
* Safe to call when already reset. A paused chart remains paused.
|
|
2178
2287
|
*
|
|
2179
2288
|
* ```tsx
|
|
@@ -2405,13 +2514,29 @@ export interface LiveChartCoreProps {
|
|
|
2405
2514
|
* axes (prices, market caps).
|
|
2406
2515
|
*/
|
|
2407
2516
|
maxValue?: number;
|
|
2517
|
+
/**
|
|
2518
|
+
* Smallest auto-fitted Y span, in data units. A narrower bounded fit widens
|
|
2519
|
+
* around its midpoint, giving near-flat data room for distinct grid labels
|
|
2520
|
+
* (e.g. pass a few multiples of the display precision). `nonNegative` and
|
|
2521
|
+
* `maxValue` shift the span; if both leave less room than the floor, the hard
|
|
2522
|
+
* bounds win. Manual `yRangeScale` zoom applies afterward and may go below
|
|
2523
|
+
* the floor. Usual range easing applies; static charts re-settle on changes.
|
|
2524
|
+
* Positive finite values only; invalid or overflowing floors are ignored.
|
|
2525
|
+
* Omit for no floor.
|
|
2526
|
+
*/
|
|
2527
|
+
minRange?: number;
|
|
2408
2528
|
/**
|
|
2409
2529
|
* Live manual Y-range multiplier around the fitted midpoint (`1` = auto-fit).
|
|
2410
|
-
*
|
|
2530
|
+
* Enable `yAxis.scaleGesture` or drive it from your own gesture to stretch or
|
|
2411
2531
|
* compress the price scale TradingView-style; the auto-fit keeps tracking
|
|
2412
2532
|
* the visible window underneath. Values must be positive and finite; invalid
|
|
2413
2533
|
* values fall back to `1`. Read on the UI thread each frame. Supported by
|
|
2414
|
-
* both `LiveChart` and `LiveChartSeries`.
|
|
2534
|
+
* both `LiveChart` and `LiveChartSeries`. Static single-series charts also
|
|
2535
|
+
* re-settle when this SharedValue changes, without replacing data. Default `1`.
|
|
2536
|
+
* Series drawing is clipped vertically to the price plot; candle volume bars
|
|
2537
|
+
* remain outside that clip. Automatic volume-band reservation respects an
|
|
2538
|
+
* explicit bottom inset. The built-in axis gesture uses an internal multiplier
|
|
2539
|
+
* when this prop is omitted.
|
|
2415
2540
|
*
|
|
2416
2541
|
* @experimental
|
|
2417
2542
|
*/
|
|
@@ -2549,6 +2674,7 @@ export interface LiveChartCoreProps {
|
|
|
2549
2674
|
* no longer passed — **glides** the window back to the live edge (a brief eased
|
|
2550
2675
|
* animation, not an instant jump); it never stays frozen at the previous scroll
|
|
2551
2676
|
* position. Tune or disable that glide with {@link returnToLive}.
|
|
2677
|
+
* On LiveChart with viewport, disabling gestures preserves the supplied state.
|
|
2552
2678
|
*
|
|
2553
2679
|
* `true` uses the default drag-to-scroll gesture (`"holdToScrub"`); pass a
|
|
2554
2680
|
* {@link TimeScrollConfig} to pick the activation (`"holdToScrub"` or
|
|
@@ -2632,8 +2758,42 @@ export interface LiveChartCoreProps {
|
|
|
2632
2758
|
line?: LineConfig;
|
|
2633
2759
|
}
|
|
2634
2760
|
|
|
2761
|
+
/**
|
|
2762
|
+
* UI-thread scroll/zoom state adopted by a single-series {@link LiveChart}.
|
|
2763
|
+
* The app owns leadership and timestamp mapping; gestures write these same values.
|
|
2764
|
+
* @experimental
|
|
2765
|
+
*/
|
|
2766
|
+
export interface ChartViewportControl {
|
|
2767
|
+
/** Right-edge unix timestamp in seconds; null follows this chart's live edge.
|
|
2768
|
+
* Honors times past live. An end before the first retained point falls back to live. */
|
|
2769
|
+
end: SharedValue<number | null>;
|
|
2770
|
+
/** Positive, finite visible width in seconds; null uses the timeWindow prop. */
|
|
2771
|
+
window: SharedValue<number | null>;
|
|
2772
|
+
}
|
|
2773
|
+
|
|
2774
|
+
/** External viewport state and optional behavior settings for {@link LiveChart}.
|
|
2775
|
+
* Pass an object to adopt its shared values; false/omitted uses private state.
|
|
2776
|
+
* @experimental
|
|
2777
|
+
*/
|
|
2778
|
+
export interface ViewportConfig extends ChartViewportControl {
|
|
2779
|
+
/** Ease non-null window overrides using the chart's smoothing. Default true.
|
|
2780
|
+
* Set false on followers copying a leader's drawn width to avoid easing twice.
|
|
2781
|
+
* Null windows still ease back to timeWindow; Y-range/value smoothing is unchanged. */
|
|
2782
|
+
windowSmoothing?: boolean;
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2635
2785
|
/** Props for the single-series `LiveChart` component. */
|
|
2636
2786
|
export interface LiveChartProps extends LiveChartCoreProps {
|
|
2787
|
+
/**
|
|
2788
|
+
* Adopt external UI-thread scroll/zoom state. Pan and pinch write the supplied
|
|
2789
|
+
* values; resetZoom() clears both. Non-null overrides survive timeWindow changes
|
|
2790
|
+
* and timeScroll being disabled. External writes work without enabling gestures
|
|
2791
|
+
* and wake autoSleep charts. Single-series line/candle only.
|
|
2792
|
+
* Pass a ViewportConfig object to enable; false/omitted uses private state.
|
|
2793
|
+
* Both shared values are required, so this prop has no true shorthand.
|
|
2794
|
+
* @experimental
|
|
2795
|
+
*/
|
|
2796
|
+
viewport?: false | ViewportConfig;
|
|
2637
2797
|
/** Area gradient fill under the line. `true` = defaults, or pass `GradientConfig`. Default `true`. */
|
|
2638
2798
|
gradient?: boolean | GradientConfig;
|
|
2639
2799
|
/**
|
|
@@ -2734,7 +2894,10 @@ export interface LiveChartProps extends LiveChartCoreProps {
|
|
|
2734
2894
|
* but `scrub` / `scrubAction` stay available — they're on-demand touch gestures with
|
|
2735
2895
|
* no per-frame cost, so a still chart is still scrubbable. May be toggled at runtime:
|
|
2736
2896
|
* switching back to live restarts the suspended loops and catches up. Frame the data
|
|
2737
|
-
* with `timeWindow` + `nowOverride` (see the historical-data-fill pattern).
|
|
2897
|
+
* with `timeWindow` + `nowOverride` (see the historical-data-fill pattern). Data,
|
|
2898
|
+
* layout, `timeWindow`, and `nowOverride` changes re-settle without restarting the
|
|
2899
|
+
* loop. Entering static mode lands on the new window even when data and framing
|
|
2900
|
+
* change in the same render (for example, a recycled list cell). */
|
|
2738
2901
|
static?: boolean;
|
|
2739
2902
|
/**
|
|
2740
2903
|
* Runtime gate for continuous frame work. Set this SharedValue to `false`
|
|
@@ -2775,8 +2938,20 @@ export interface LiveChartProps extends LiveChartCoreProps {
|
|
|
2775
2938
|
* Single-series only.
|
|
2776
2939
|
*/
|
|
2777
2940
|
renderOverlay?: (ctx: ChartOverlayContext) => ReactElement | null | undefined;
|
|
2778
|
-
/**
|
|
2941
|
+
/**
|
|
2942
|
+
* JS-thread callback while scrubbing; `null` when scrub ends. With
|
|
2943
|
+
* `scrub.markers` enabled, includes matching markers and also sends `null`
|
|
2944
|
+
* when a valid point becomes unavailable (for example an unpriced gap).
|
|
2945
|
+
*/
|
|
2779
2946
|
onScrub?: (point: ScrubPoint | null) => void;
|
|
2947
|
+
/**
|
|
2948
|
+
* Called on the JS thread when the crosshair enters a different candle,
|
|
2949
|
+
* with a snapshot of its OHLC at entry. Re-entering a candle fires again;
|
|
2950
|
+
* ticks within the same candle do not. Called with `null` when the scrub
|
|
2951
|
+
* ends, enters a gap, or leaves candle mode. Idle in line mode. Unlike
|
|
2952
|
+
* {@link onScrub}, it does not stream per-frame candle updates.
|
|
2953
|
+
*/
|
|
2954
|
+
onScrubCandleChange?: (candle: CandlePoint | null) => void;
|
|
2780
2955
|
/**
|
|
2781
2956
|
* Scrub-action ("order ticket") mode: tap to drop a locked crosshair, drag to
|
|
2782
2957
|
* fine-tune a **price level**, then press the right-gutter action badge to fire
|
|
@@ -2829,14 +3004,12 @@ export interface LiveChartProps extends LiveChartCoreProps {
|
|
|
2829
3004
|
ctx: ReferenceLineRenderProps,
|
|
2830
3005
|
) => ReactElement | null | undefined;
|
|
2831
3006
|
/**
|
|
2832
|
-
*
|
|
2833
|
-
*
|
|
2834
|
-
*
|
|
2835
|
-
*
|
|
2836
|
-
*
|
|
2837
|
-
* {@link
|
|
2838
|
-
* custom tag draws itself), so the count reflects only collapsed built-in tags.
|
|
2839
|
-
* Single-series only. Default off.
|
|
3007
|
+
* Resolve nearby Form-A tags. `true` uses the existing count-pill collapse;
|
|
3008
|
+
* `{ mode: "stack" }` separates built-in and custom tags without moving their
|
|
3009
|
+
* price lines. Stacking respects measured tag sizes, separate horizontal
|
|
3010
|
+
* columns, and the visible live value badge (opt out with `avoidValueBadge`).
|
|
3011
|
+
* Count-pill styling/format apply only to collapse mode. Single-series only.
|
|
3012
|
+
* Default off. See {@link ReferenceLineGroupingConfig}.
|
|
2840
3013
|
*/
|
|
2841
3014
|
referenceLineGrouping?: boolean | ReferenceLineGroupingConfig;
|
|
2842
3015
|
/**
|
|
@@ -2911,6 +3084,8 @@ export interface LiveChartSeriesProps extends LiveChartCoreProps {
|
|
|
2911
3084
|
/**
|
|
2912
3085
|
* Worklet callback fired on the UI thread each frame while scrubbing.
|
|
2913
3086
|
* `null` when scrub ends. Update shared values directly — no bridge overhead.
|
|
3087
|
+
* With `scrub.markers` enabled, includes matching markers and also sends
|
|
3088
|
+
* `null` when a previously valid point becomes unavailable.
|
|
2914
3089
|
*
|
|
2915
3090
|
* ```ts
|
|
2916
3091
|
* const scrubData = useSharedValue<ScrubPointMulti | null>(null);
|