react-native-livechart 4.28.2 → 4.30.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/README.md +1 -1
- package/dist/components/LiveChart.d.ts.map +1 -1
- package/dist/components/LiveChartSeries.d.ts.map +1 -1
- package/dist/components/LoadingOverlay.d.ts +6 -1
- package/dist/components/LoadingOverlay.d.ts.map +1 -1
- package/dist/components/ResetButtonOverlay.d.ts +25 -0
- package/dist/components/ResetButtonOverlay.d.ts.map +1 -0
- package/dist/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/core/gestureRangeOwnership.d.ts +13 -0
- package/dist/core/gestureRangeOwnership.d.ts.map +1 -0
- package/dist/core/liveChartEngineTick.d.ts +33 -1
- package/dist/core/liveChartEngineTick.d.ts.map +1 -1
- package/dist/core/resolveConfig.d.ts +39 -2
- package/dist/core/resolveConfig.d.ts.map +1 -1
- package/dist/core/useLiveChartEngine.d.ts +35 -2
- package/dist/core/useLiveChartEngine.d.ts.map +1 -1
- package/dist/draw/line.d.ts.map +1 -1
- package/dist/hooks/resetButtonLayout.d.ts +24 -0
- package/dist/hooks/resetButtonLayout.d.ts.map +1 -0
- package/dist/hooks/resetView.d.ts +31 -0
- package/dist/hooks/resetView.d.ts.map +1 -0
- package/dist/hooks/useBadge.d.ts.map +1 -1
- package/dist/hooks/useChartPaths.d.ts +3 -1
- package/dist/hooks/useChartPaths.d.ts.map +1 -1
- package/dist/hooks/useDemandFrameLoop.d.ts.map +1 -1
- package/dist/hooks/useLiveDot.d.ts +5 -2
- package/dist/hooks/useLiveDot.d.ts.map +1 -1
- package/dist/hooks/usePanScroll.d.ts +39 -3
- package/dist/hooks/usePanScroll.d.ts.map +1 -1
- package/dist/hooks/useReferenceLine.d.ts.map +1 -1
- package/dist/hooks/useResetButton.d.ts +41 -0
- package/dist/hooks/useResetButton.d.ts.map +1 -0
- package/dist/hooks/useYAxisScaleGesture.d.ts +14 -1
- package/dist/hooks/useYAxisScaleGesture.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/math/squiggly.d.ts +12 -0
- package/dist/math/squiggly.d.ts.map +1 -1
- package/dist/types.d.ts +167 -11
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/LiveChart.tsx +75 -4
- package/src/components/LiveChartSeries.tsx +9 -1
- package/src/components/LoadingOverlay.tsx +44 -6
- package/src/components/ResetButtonOverlay.tsx +129 -0
- package/src/constants.ts +7 -0
- package/src/core/gestureRangeOwnership.ts +46 -0
- package/src/core/liveChartEngineTick.ts +103 -2
- package/src/core/resolveConfig.ts +88 -2
- package/src/core/useLiveChartEngine.ts +122 -4
- package/src/draw/line.ts +13 -5
- package/src/hooks/resetButtonLayout.ts +80 -0
- package/src/hooks/resetView.ts +92 -0
- package/src/hooks/useBadge.ts +18 -5
- package/src/hooks/useChartPaths.ts +6 -4
- package/src/hooks/useDemandFrameLoop.ts +7 -2
- package/src/hooks/useLiveDot.ts +26 -11
- package/src/hooks/usePanScroll.ts +177 -5
- package/src/hooks/useReferenceLine.ts +4 -1
- package/src/hooks/useResetButton.ts +181 -0
- package/src/hooks/useYAxisScaleGesture.ts +70 -13
- package/src/index.ts +3 -0
- package/src/math/squiggly.ts +27 -0
- package/src/types.ts +170 -11
package/src/types.ts
CHANGED
|
@@ -758,11 +758,17 @@ export interface BadgeConfig extends BadgeStyleConfig {
|
|
|
758
758
|
* column ({@link YAxisConfig.labelRightMargin}): it starts at the labels'
|
|
759
759
|
* shared left X, and a value wider than every axis label ends at the
|
|
760
760
|
* column's right edge. The pill keeps its shape and the value stays within
|
|
761
|
-
* its `padX` padding
|
|
762
|
-
*
|
|
763
|
-
*
|
|
764
|
-
*
|
|
765
|
-
*
|
|
761
|
+
* its `padX` padding, so the room on each side follows the right inset and
|
|
762
|
+
* `metrics.badge`. Next to the tail, whose taper keeps the value off the
|
|
763
|
+
* outline, a pill too narrow for both paddings gives up the left one first,
|
|
764
|
+
* then the right one, so the value moves continuously as the pill narrows:
|
|
765
|
+
* with room for its right padding it ends `padX` from the pill's end (the
|
|
766
|
+
* column's right edge when `marginEdge + padX` equals `labelRightMargin`).
|
|
767
|
+
* A value wider than a tailed pill's body, or one that doesn't fit both
|
|
768
|
+
* paddings of a pill without a tail, is centered. The value moves sideways
|
|
769
|
+
* when the column's width changes (a wider label entering or leaving the
|
|
770
|
+
* axis). Centered without that column on the right side, while the axis
|
|
771
|
+
* floats, and for a `"left"` badge. Default `"center"`.
|
|
766
772
|
*/
|
|
767
773
|
textAlign?: "center" | "yAxisColumn";
|
|
768
774
|
/**
|
|
@@ -1847,7 +1853,9 @@ export interface DotConfig {
|
|
|
1847
1853
|
* dot must stay aligned with its badge. Single-series `LiveChart` only
|
|
1848
1854
|
* (multi-series dots already ride each line's end while scrolled). Default
|
|
1849
1855
|
* `false` (the dot stays pinned to the right edge with its pulse suppressed
|
|
1850
|
-
* while scrolled back).
|
|
1856
|
+
* while scrolled back). With an external viewport or positive windowBuffer,
|
|
1857
|
+
* a line dot already tracks the recorded endpoint; this option still controls
|
|
1858
|
+
* its scroll-back visibility and pulse.
|
|
1851
1859
|
*
|
|
1852
1860
|
* @experimental
|
|
1853
1861
|
*/
|
|
@@ -2307,6 +2315,16 @@ export interface LiveChartHandle {
|
|
|
2307
2315
|
* ```
|
|
2308
2316
|
*/
|
|
2309
2317
|
resetZoom(): void;
|
|
2318
|
+
/**
|
|
2319
|
+
* Return to the fitted live view: {@link resetZoom} plus `yRangeScale` → 1 and
|
|
2320
|
+
* a gesture-owned price range cleared, gliding the right edge back to live
|
|
2321
|
+
* with the `timeScroll.returnToLive` timing. What the `resetButton` runs.
|
|
2322
|
+
* Safe to call when already fitted. On LiveChartSeries, which has no price
|
|
2323
|
+
* pan, it is `resetZoom()` plus `yRangeScale` → 1.
|
|
2324
|
+
*
|
|
2325
|
+
* @experimental
|
|
2326
|
+
*/
|
|
2327
|
+
resetView(): void;
|
|
2310
2328
|
}
|
|
2311
2329
|
|
|
2312
2330
|
/**
|
|
@@ -2394,6 +2412,13 @@ export interface LoadingConfig {
|
|
|
2394
2412
|
* squiggle with no placeholder ticks. Default `true`.
|
|
2395
2413
|
*/
|
|
2396
2414
|
axisLabels?: boolean;
|
|
2415
|
+
/**
|
|
2416
|
+
* Freezes the squiggle once it has animated this long (ms) each time the
|
|
2417
|
+
* loading or empty shell appears; it moves again when the shell next appears.
|
|
2418
|
+
* Counted in frames drawn, so time in the background doesn't count. `0` or
|
|
2419
|
+
* less freezes it from the start. Default `undefined`: no limit.
|
|
2420
|
+
*/
|
|
2421
|
+
freezeAfterMs?: number;
|
|
2397
2422
|
}
|
|
2398
2423
|
|
|
2399
2424
|
/** Y-range easing shared by both charts, independent of value/window tracking. */
|
|
@@ -2487,7 +2512,8 @@ export interface LiveChartCoreProps {
|
|
|
2487
2512
|
* `true` shows the shell with the defaults; pass a {@link LoadingConfig} to
|
|
2488
2513
|
* restyle it — `color` / `strokeWidth` for the squiggle + skeleton, `amplitude`
|
|
2489
2514
|
* / `speed` for the breathing wave, `axisLabels` to toggle the skeleton
|
|
2490
|
-
* placeholders
|
|
2515
|
+
* placeholders, `freezeAfterMs` to freeze the wave after a while.
|
|
2516
|
+
* `false` / omitted is "not loading". Toggle between the config
|
|
2491
2517
|
* and `false` as data loads (e.g. `loading={isLoading && cfg}`). The loading→live
|
|
2492
2518
|
* reveal duration is governed separately by {@link TransitionConfig.reveal} (the
|
|
2493
2519
|
* `transitions` prop).
|
|
@@ -2692,7 +2718,10 @@ export interface LiveChartCoreProps {
|
|
|
2692
2718
|
/**
|
|
2693
2719
|
* Right-edge buffer as a fraction of `timeWindow`. Pushes the live edge past the
|
|
2694
2720
|
* current time so the latest point has breathing room; pass `0` to land the latest
|
|
2695
|
-
* point exactly at the right edge.
|
|
2721
|
+
* point exactly at the right edge. In line-mode LiveChart, a positive buffer
|
|
2722
|
+
* stops the line/dot at the last recorded point; the badge and value line use
|
|
2723
|
+
* that recorded price. badge.followViewEdge retains its edge-pinned indicators.
|
|
2724
|
+
* Default `0`.
|
|
2696
2725
|
*/
|
|
2697
2726
|
windowBuffer?: number;
|
|
2698
2727
|
/**
|
|
@@ -2797,15 +2826,28 @@ export interface LiveChartCoreProps {
|
|
|
2797
2826
|
|
|
2798
2827
|
/**
|
|
2799
2828
|
* UI-thread scroll/zoom state adopted by a single-series {@link LiveChart}.
|
|
2800
|
-
* The app owns leadership and timestamp mapping; gestures write
|
|
2829
|
+
* The app owns leadership and timestamp mapping; gestures write end/window.
|
|
2801
2830
|
* @experimental
|
|
2802
2831
|
*/
|
|
2803
2832
|
export interface ChartViewportControl {
|
|
2804
2833
|
/** Right-edge unix timestamp in seconds; null follows this chart's live edge.
|
|
2805
|
-
* Honors times past live.
|
|
2834
|
+
* Honors times past live. Before the first retained point, falls back to live
|
|
2835
|
+
* unless a valid explicit range is supplied. */
|
|
2806
2836
|
end: SharedValue<number | null>;
|
|
2807
2837
|
/** Positive, finite visible width in seconds; null uses the timeWindow prop. */
|
|
2808
2838
|
window: SharedValue<number | null>;
|
|
2839
|
+
/**
|
|
2840
|
+
* Exact price bounds while end is finite and non-null, including empty past or
|
|
2841
|
+
* future space. Both bounds and their difference must be finite, with min < max.
|
|
2842
|
+
* Applied immediately, overriding automatic fitting, range easing, nonNegative,
|
|
2843
|
+
* maxValue, minRange, and yRangeScale. Invalid/null/omitted bounds use auto-fit.
|
|
2844
|
+
* App-written bounds are ignored while end is null (including after resetZoom()).
|
|
2845
|
+
* With priceScroll, gestures write this range too: gesture-owned bounds stay
|
|
2846
|
+
* active while following live and obey the chart's hard bounds. A later app
|
|
2847
|
+
* write or replacement range SharedValue restores the app-owned contract;
|
|
2848
|
+
* resetView(), axis double-tap and framing changes preserve app-written bounds.
|
|
2849
|
+
*/
|
|
2850
|
+
range?: SharedValue<Pick<ChartScale, "min" | "max"> | null>;
|
|
2809
2851
|
}
|
|
2810
2852
|
|
|
2811
2853
|
/** External viewport state and optional behavior settings for {@link LiveChart}.
|
|
@@ -2815,10 +2857,88 @@ export interface ChartViewportControl {
|
|
|
2815
2857
|
export interface ViewportConfig extends ChartViewportControl {
|
|
2816
2858
|
/** Ease non-null window overrides using the chart's smoothing. Default true.
|
|
2817
2859
|
* Set false on followers copying a leader's drawn width to avoid easing twice.
|
|
2818
|
-
* Null windows still ease back to timeWindow;
|
|
2860
|
+
* Null windows still ease back to timeWindow; value and automatic Y-range
|
|
2861
|
+
* smoothing are unchanged. Explicit range bounds always apply immediately. */
|
|
2819
2862
|
windowSmoothing?: boolean;
|
|
2820
2863
|
}
|
|
2821
2864
|
|
|
2865
|
+
/**
|
|
2866
|
+
* Vertical price panning (see {@link LiveChartProps.priceScroll}).
|
|
2867
|
+
*
|
|
2868
|
+
* @experimental Prototype — gesture model and API may change.
|
|
2869
|
+
*/
|
|
2870
|
+
export interface PriceScrollConfig {
|
|
2871
|
+
/**
|
|
2872
|
+
* When a vertical drag on the plot pans the price window:
|
|
2873
|
+
* - `"afterScale"` (default) — only once the range was manually changed (a
|
|
2874
|
+
* price-axis drag, a pinch, or an earlier price pan), so an untouched chart
|
|
2875
|
+
* still lets a parent ScrollView scroll.
|
|
2876
|
+
* - `"always"` — every vertical drag pans price.
|
|
2877
|
+
*/
|
|
2878
|
+
activation?: "always" | "afterScale";
|
|
2879
|
+
/**
|
|
2880
|
+
* How far the window may travel past the fitted range, as a multiple of the
|
|
2881
|
+
* visible price span. Default `1`.
|
|
2882
|
+
*/
|
|
2883
|
+
maxOvershoot?: number;
|
|
2884
|
+
}
|
|
2885
|
+
|
|
2886
|
+
/**
|
|
2887
|
+
* Floating reset-view button (see {@link LiveChartProps.resetButton}).
|
|
2888
|
+
*
|
|
2889
|
+
* @experimental
|
|
2890
|
+
*/
|
|
2891
|
+
export interface ResetButtonConfig {
|
|
2892
|
+
/** Where the button sits inside the plot rect. Default `"bottom-center"`. */
|
|
2893
|
+
placement?: "bottom-center" | "bottom-right";
|
|
2894
|
+
/**
|
|
2895
|
+
* Which manual states show the button. Each defaults to `true`; set one to
|
|
2896
|
+
* `false` to ignore that state.
|
|
2897
|
+
*/
|
|
2898
|
+
showFor?: {
|
|
2899
|
+
/** A scaled price axis (`yRangeScale !== 1`). */
|
|
2900
|
+
yScale?: boolean;
|
|
2901
|
+
/** A vertically panned price window (`priceScroll`). */
|
|
2902
|
+
priceScroll?: boolean;
|
|
2903
|
+
/** A window scrolled back from the live edge (`timeScroll`). */
|
|
2904
|
+
timeScroll?: boolean;
|
|
2905
|
+
/** A pinched window width (`zoom`). */
|
|
2906
|
+
zoom?: boolean;
|
|
2907
|
+
};
|
|
2908
|
+
/** Distance from the plot's bottom (and right) edge, in px. Default `12`. */
|
|
2909
|
+
margin?: number;
|
|
2910
|
+
/** Fade duration in ms when the button appears or hides. Default `160`. */
|
|
2911
|
+
fadeMs?: number;
|
|
2912
|
+
/**
|
|
2913
|
+
* Built-in button only: glyph rendered in the chart's font family, like
|
|
2914
|
+
* {@link ScrubActionConfig.icon}. Default `"↺"`.
|
|
2915
|
+
*/
|
|
2916
|
+
icon?: string;
|
|
2917
|
+
/** Built-in button only: diameter in px. Default `36`. */
|
|
2918
|
+
size?: number;
|
|
2919
|
+
/** Built-in button only: fill color. Defaults to `palette.badgeBg`. */
|
|
2920
|
+
color?: string;
|
|
2921
|
+
/** Built-in button only: glyph color. Defaults to `palette.badgeText`. */
|
|
2922
|
+
iconColor?: string;
|
|
2923
|
+
/** Built-in button only: screen-reader label. The library ships no text of its own. */
|
|
2924
|
+
accessibilityLabel?: string;
|
|
2925
|
+
}
|
|
2926
|
+
|
|
2927
|
+
/**
|
|
2928
|
+
* Handed to {@link LiveChartProps.renderResetButton}.
|
|
2929
|
+
*
|
|
2930
|
+
* @experimental
|
|
2931
|
+
*/
|
|
2932
|
+
export interface ResetButtonRenderProps {
|
|
2933
|
+
/** True while the view differs from the fitted live view. */
|
|
2934
|
+
visible: SharedValue<boolean>;
|
|
2935
|
+
/**
|
|
2936
|
+
* Runs `resetView()`. Wire to `onAccessibilityTap` on iOS and the `activate`
|
|
2937
|
+
* action through `accessibilityActions` / `onAccessibilityAction` on Android.
|
|
2938
|
+
*/
|
|
2939
|
+
reset: () => void;
|
|
2940
|
+
}
|
|
2941
|
+
|
|
2822
2942
|
/** Props for the single-series `LiveChart` component. */
|
|
2823
2943
|
export interface LiveChartProps extends LiveChartCoreProps {
|
|
2824
2944
|
/**
|
|
@@ -2828,9 +2948,48 @@ export interface LiveChartProps extends LiveChartCoreProps {
|
|
|
2828
2948
|
* and wake autoSleep charts. Single-series line/candle only.
|
|
2829
2949
|
* Pass a ViewportConfig object to enable; false/omitted uses private state.
|
|
2830
2950
|
* Both shared values are required, so this prop has no true shorthand.
|
|
2951
|
+
* Optional range supplies exact price bounds while end is non-null. In line
|
|
2952
|
+
* mode the line/dot stop at the last recorded point, with badge/value line at
|
|
2953
|
+
* that price; badge.followViewEdge keeps its edge-pinned indicators.
|
|
2831
2954
|
* @experimental
|
|
2832
2955
|
*/
|
|
2833
2956
|
viewport?: false | ViewportConfig;
|
|
2957
|
+
/**
|
|
2958
|
+
* Drag the plot vertically to move the price window — with `timeScroll` this
|
|
2959
|
+
* gives free X/Y panning. The pan writes the viewport's price `range` (the
|
|
2960
|
+
* supplied `viewport.range` shared value when one is given, private state
|
|
2961
|
+
* otherwise), which then holds while new data streams in. A later app write
|
|
2962
|
+
* or replacement range SharedValue relinquishes gesture ownership. A price-axis drag
|
|
2963
|
+
* scales that range, and a double-tap on the axis, `resetView()` or a
|
|
2964
|
+
* `snapKey` / mode change clears it. Rides on the `timeScroll` pan, so it
|
|
2965
|
+
* requires `timeScroll`. `true` = defaults, or pass a {@link PriceScrollConfig}.
|
|
2966
|
+
* Default `false`.
|
|
2967
|
+
*
|
|
2968
|
+
* @experimental Prototype — gesture model and API may change.
|
|
2969
|
+
*/
|
|
2970
|
+
priceScroll?: boolean | PriceScrollConfig;
|
|
2971
|
+
/**
|
|
2972
|
+
* Floating button that appears once the user has left the fitted live view
|
|
2973
|
+
* (time pan, pinch, price-axis scale or price pan) and returns to it in one
|
|
2974
|
+
* tap (see {@link LiveChartHandle.resetView}). `true` = the built-in round
|
|
2975
|
+
* glyph button, or pass a {@link ResetButtonConfig}. Default `false`.
|
|
2976
|
+
*
|
|
2977
|
+
* @experimental
|
|
2978
|
+
*/
|
|
2979
|
+
resetButton?: boolean | ResetButtonConfig;
|
|
2980
|
+
/**
|
|
2981
|
+
* Custom visual for `resetButton`. The chart owns placement, visibility, fade
|
|
2982
|
+
* and the tap, so return a plain view rather than a pressable; the wrapper is
|
|
2983
|
+
* measured, so any size works. Called on the JS thread once per render.
|
|
2984
|
+
*
|
|
2985
|
+
* @experimental
|
|
2986
|
+
*/
|
|
2987
|
+
renderResetButton?: (props: ResetButtonRenderProps) => ReactElement;
|
|
2988
|
+
/**
|
|
2989
|
+
* Called on the JS thread after the reset overrides are applied on the UI
|
|
2990
|
+
* thread (button tap or `resetView()`). Return animations may still be running.
|
|
2991
|
+
*/
|
|
2992
|
+
onResetView?: () => void;
|
|
2834
2993
|
/** Area gradient fill under the line. `true` = defaults, or pass `GradientConfig`. Default `true`. */
|
|
2835
2994
|
gradient?: boolean | GradientConfig;
|
|
2836
2995
|
/**
|