react-native-livechart 4.28.1 → 4.29.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/SeriesToggleChips.d.ts +7 -5
- package/dist/components/SeriesToggleChips.d.ts.map +1 -1
- package/dist/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/core/liveChartEngineTick.d.ts +3 -1
- package/dist/core/liveChartEngineTick.d.ts.map +1 -1
- package/dist/core/resolveConfig.d.ts +4 -1
- package/dist/core/resolveConfig.d.ts.map +1 -1
- package/dist/core/useLiveChartEngine.d.ts +2 -0
- package/dist/core/useLiveChartEngine.d.ts.map +1 -1
- package/dist/core/useLiveChartSeriesEngine.d.ts +20 -15
- package/dist/core/useLiveChartSeriesEngine.d.ts.map +1 -1
- package/dist/draw/line.d.ts.map +1 -1
- 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/useMultiSeriesDegen.d.ts +7 -1
- package/dist/hooks/useMultiSeriesDegen.d.ts.map +1 -1
- package/dist/hooks/useReferenceLine.d.ts.map +1 -1
- package/dist/hooks/useSeriesPresentation.d.ts +13 -0
- package/dist/hooks/useSeriesPresentation.d.ts.map +1 -0
- package/dist/math/squiggly.d.ts +12 -0
- package/dist/math/squiggly.d.ts.map +1 -1
- package/dist/types.d.ts +48 -12
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/LiveChart.tsx +14 -2
- package/src/components/LiveChartSeries.tsx +48 -103
- package/src/components/LoadingOverlay.tsx +44 -6
- package/src/components/SeriesToggleChips.tsx +14 -37
- package/src/constants.ts +7 -0
- package/src/core/liveChartEngineTick.ts +23 -2
- package/src/core/resolveConfig.ts +12 -2
- package/src/core/useLiveChartEngine.ts +8 -2
- package/src/core/useLiveChartSeriesEngine.ts +56 -37
- package/src/draw/line.ts +13 -5
- 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/useMultiSeriesDegen.ts +17 -8
- package/src/hooks/useReferenceLine.ts +4 -1
- package/src/hooks/useSeriesPresentation.ts +133 -0
- package/src/math/squiggly.ts +27 -0
- package/src/types.ts +48 -12
package/src/hooks/useLiveDot.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { ChartPadding } from "../draw/line";
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Derive the live dot position (right edge of the chart, mapped to current value).
|
|
10
|
-
* Returns `{ dotX, dotY }` as shared values. Coordinates are set to `-100`
|
|
10
|
+
* Returns `{ dotX, dotY, indicatorValue }` as shared values. Coordinates are set to `-100`
|
|
11
11
|
* (off-screen sentinel) when canvas dimensions are unavailable.
|
|
12
12
|
*
|
|
13
13
|
* With `followViewEdge` + `edgeValue`, the dot (and the value line that shares
|
|
@@ -26,15 +26,34 @@ export function useLiveDot(
|
|
|
26
26
|
edgeValue?: SharedValue<number>,
|
|
27
27
|
followViewEdge = false,
|
|
28
28
|
trackWhileParked = false,
|
|
29
|
+
/** Keep the dot on recorded geometry when the viewport includes future space. */
|
|
30
|
+
shouldOmitTipBeyondData = false,
|
|
29
31
|
) {
|
|
32
|
+
// A line with no synthetic tip ends at its recorded price. Share that value
|
|
33
|
+
// with the badge so its text, the value line, and the dot stay aligned even
|
|
34
|
+
// while the engine's live value is still easing toward a new tick.
|
|
35
|
+
const indicatorValue = useDerivedValue(() => {
|
|
36
|
+
if (followViewEdge && edgeValue) return edgeValue.value;
|
|
37
|
+
if (shouldOmitTipBeyondData) {
|
|
38
|
+
const data = engine.data.value;
|
|
39
|
+
const last = data[data.length - 1];
|
|
40
|
+
if (last && last.time <= engine.timestamp.value) return last.value;
|
|
41
|
+
}
|
|
42
|
+
return engine.displayValue.value;
|
|
43
|
+
});
|
|
44
|
+
|
|
30
45
|
const dotX = useDerivedValue(() => {
|
|
31
46
|
const w = engine.canvasWidth.value;
|
|
32
47
|
if (w === 0) return -100;
|
|
33
48
|
const right = w - padding.right;
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
if (
|
|
49
|
+
// Buffered or parked windows can put the last point before the plot edge.
|
|
50
|
+
// Track its real x so a pan doesn't lose the dot, and hide it only once
|
|
51
|
+
// the point leaves the window.
|
|
52
|
+
if (
|
|
53
|
+
!followViewEdge &&
|
|
54
|
+
(shouldOmitTipBeyondData ||
|
|
55
|
+
(trackWhileParked && engine.viewEnd.value != null))
|
|
56
|
+
) {
|
|
38
57
|
const data = engine.data.value;
|
|
39
58
|
const last = data[data.length - 1];
|
|
40
59
|
const win = engine.displayWindow.value;
|
|
@@ -56,12 +75,8 @@ export function useLiveDot(
|
|
|
56
75
|
const dMax = engine.displayMax.value;
|
|
57
76
|
const valRange = dMax - dMin;
|
|
58
77
|
if (valRange === 0) return padding.top + chartH / 2;
|
|
59
|
-
|
|
60
|
-
followViewEdge && edgeValue
|
|
61
|
-
? edgeValue.value
|
|
62
|
-
: engine.displayValue.value;
|
|
63
|
-
return padding.top + ((dMax - v) / valRange) * chartH;
|
|
78
|
+
return padding.top + ((dMax - indicatorValue.value) / valRange) * chartH;
|
|
64
79
|
});
|
|
65
80
|
|
|
66
|
-
return { dotX, dotY } as const;
|
|
81
|
+
return { dotX, dotY, indicatorValue } as const;
|
|
67
82
|
}
|
|
@@ -27,6 +27,8 @@ export function useMultiSeriesDegen(
|
|
|
27
27
|
padding: ChartPadding,
|
|
28
28
|
cfg: ResolvedDegenConfig | null,
|
|
29
29
|
onShake?: (payload: DegenShakePayload) => void,
|
|
30
|
+
/** Optional stable transform owned by a chart whose particle layer mounts lazily. */
|
|
31
|
+
shakeOutput?: SharedValue<[{ translateX: number }, { translateY: number }]>,
|
|
30
32
|
): {
|
|
31
33
|
pack: SharedValue<Float64Array<ArrayBuffer>>;
|
|
32
34
|
packRevision: SharedValue<number>;
|
|
@@ -152,6 +154,7 @@ export function useMultiSeriesDegen(
|
|
|
152
154
|
shakeStart.set(0);
|
|
153
155
|
shakeX.set(0);
|
|
154
156
|
shakeY.set(0);
|
|
157
|
+
shakeOutput?.set([{ translateX: 0 }, { translateY: 0 }]);
|
|
155
158
|
return;
|
|
156
159
|
}
|
|
157
160
|
|
|
@@ -240,6 +243,8 @@ export function useMultiSeriesDegen(
|
|
|
240
243
|
shakeY.set(0);
|
|
241
244
|
}
|
|
242
245
|
|
|
246
|
+
shakeOutput?.set([{ translateX: shakeX.get() }, { translateY: shakeY.get() }]);
|
|
247
|
+
|
|
243
248
|
const activeCount = tickParticles(
|
|
244
249
|
buf,
|
|
245
250
|
slots,
|
|
@@ -257,13 +262,17 @@ export function useMultiSeriesDegen(
|
|
|
257
262
|
},
|
|
258
263
|
);
|
|
259
264
|
|
|
260
|
-
const shakeTransform = useDerivedValue(
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
265
|
+
const shakeTransform = useDerivedValue(
|
|
266
|
+
shakeOutput
|
|
267
|
+
? () => {
|
|
268
|
+
"worklet";
|
|
269
|
+
return [{ translateX: 0 }, { translateY: 0 }] as [{ translateX: number }, { translateY: number }];
|
|
270
|
+
}
|
|
271
|
+
: () => {
|
|
272
|
+
"worklet";
|
|
273
|
+
return [{ translateX: shakeX.get() }, { translateY: shakeY.get() }] as [{ translateX: number }, { translateY: number }];
|
|
274
|
+
},
|
|
275
|
+
);
|
|
267
276
|
|
|
268
|
-
return { pack, packRevision, particleTimestamp, shakeTransform };
|
|
277
|
+
return { pack, packRevision, particleTimestamp, shakeTransform: shakeOutput ?? shakeTransform };
|
|
269
278
|
}
|
|
@@ -613,7 +613,10 @@ export function computeReferenceLineLayout(
|
|
|
613
613
|
const x = bounds.left + (cfg.offsetX ?? 0);
|
|
614
614
|
const y = base.y + (cfg.offsetY ?? 0);
|
|
615
615
|
let textX = x + (pillW - contentW) / 2 + chevronW;
|
|
616
|
-
// Match live-badge text alignment when its column mode is enabled.
|
|
616
|
+
// Match live-badge text alignment when its column mode is enabled. The
|
|
617
|
+
// price pill has no tail to give its left padding to, so it keeps both
|
|
618
|
+
// paddings and centers a value that doesn't fit them (a tight live badge
|
|
619
|
+
// aligns instead).
|
|
617
620
|
if (
|
|
618
621
|
cfg.position === "axis" &&
|
|
619
622
|
valueAxis?.alignTextWithYAxis &&
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { useCallback, useLayoutEffect, useRef, useState } from "react";
|
|
2
|
+
import { Platform } from "react-native";
|
|
3
|
+
import { useAnimatedReaction, useSharedValue, type SharedValue } from "react-native-reanimated";
|
|
4
|
+
import { executeOnUIRuntimeSync, scheduleOnRN } from "react-native-worklets";
|
|
5
|
+
import { lineColorsSignatureFromArray, lineStyleSignatureFromArray } from "../core/multiSeriesLayout";
|
|
6
|
+
import type { SeriesConfig } from "../types";
|
|
7
|
+
import { shouldResampleLayoutValue } from "./resolveChartLayout";
|
|
8
|
+
|
|
9
|
+
/** React only needs presentation fields; point histories stay on the UI runtime. */
|
|
10
|
+
export function seriesPresentationSignature(series: SeriesConfig[]): string {
|
|
11
|
+
"worklet";
|
|
12
|
+
let signature = lineColorsSignatureFromArray(series) + "\x1d" + lineStyleSignatureFromArray(series);
|
|
13
|
+
for (let i = 0; i < series.length; i++) {
|
|
14
|
+
const s = series[i];
|
|
15
|
+
signature += `\x1d${s.label ?? s.id}\x1f${s.visible === false ? 0 : 1}\x1f${s.kind ?? ""}\x1f${s.valueLabel ?? ""}`;
|
|
16
|
+
}
|
|
17
|
+
return signature;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function seriesPresentationValue(series: SeriesConfig[]): number {
|
|
21
|
+
"worklet";
|
|
22
|
+
let sample = 0;
|
|
23
|
+
for (let i = 0; i < series.length; i++) {
|
|
24
|
+
const value = series[i].value;
|
|
25
|
+
if (Number.isFinite(value) && Math.abs(value) > Math.abs(sample)) sample = value;
|
|
26
|
+
}
|
|
27
|
+
return sample;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function projectSeriesPresentation(series: SeriesConfig[]): SeriesConfig[] {
|
|
31
|
+
"worklet";
|
|
32
|
+
const snapshot: SeriesConfig[] = [];
|
|
33
|
+
for (let i = 0; i < series.length; i++) {
|
|
34
|
+
const s = series[i];
|
|
35
|
+
snapshot.push({
|
|
36
|
+
id: s.id, label: s.label, color: s.color, visible: s.visible,
|
|
37
|
+
style: s.style, intervals: s.intervals, strokeWidth: s.strokeWidth,
|
|
38
|
+
glow: s.glow, kind: s.kind, valueLabel: s.valueLabel,
|
|
39
|
+
value: s.value, data: [],
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return snapshot;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface Presentation {
|
|
46
|
+
epoch: number;
|
|
47
|
+
revision: number;
|
|
48
|
+
signature: string;
|
|
49
|
+
series: SeriesConfig[];
|
|
50
|
+
sample: number | undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Bootstrap before paint, then publish config/layout changes together. */
|
|
54
|
+
export function useSeriesPresentation(series: SharedValue<SeriesConfig[]>) {
|
|
55
|
+
const currentSource = useRef<SharedValue<SeriesConfig[]> | null>(null);
|
|
56
|
+
const epochCounter = useRef(0);
|
|
57
|
+
const acceptedRevision = useRef(0);
|
|
58
|
+
const activeEpoch = useSharedValue(0);
|
|
59
|
+
const revision = useSharedValue(0);
|
|
60
|
+
const published = useSharedValue({ signature: "", sample: 0 });
|
|
61
|
+
// Read only compact metadata during lazy state initialization. This worklet
|
|
62
|
+
// has no writes or subscriptions, so an abandoned render has no UI effects.
|
|
63
|
+
const [presentation, setPresentation] = useState<Presentation>(() => {
|
|
64
|
+
const readInitial = () => {
|
|
65
|
+
"worklet";
|
|
66
|
+
const arr = series.get();
|
|
67
|
+
const value = seriesPresentationValue(arr);
|
|
68
|
+
return {
|
|
69
|
+
epoch: 1, revision: 0, signature: seriesPresentationSignature(arr),
|
|
70
|
+
series: projectSeriesPresentation(arr), sample: value !== 0 ? value : undefined,
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
return Platform.OS === "web" ? readInitial() : executeOnUIRuntimeSync(readInitial)();
|
|
74
|
+
});
|
|
75
|
+
const apply = useCallback((next: Presentation) => {
|
|
76
|
+
if (currentSource.current !== series || next.epoch !== epochCounter.current ||
|
|
77
|
+
next.revision <= acceptedRevision.current) return;
|
|
78
|
+
acceptedRevision.current = next.revision;
|
|
79
|
+
setPresentation(previous => previous.epoch === next.epoch &&
|
|
80
|
+
previous.signature === next.signature && previous.sample === next.sample ? previous : next);
|
|
81
|
+
}, [series]);
|
|
82
|
+
|
|
83
|
+
const refresh = useCallback(() => {
|
|
84
|
+
const epoch = epochCounter.current;
|
|
85
|
+
const read = () => {
|
|
86
|
+
"worklet";
|
|
87
|
+
const arr = series.get();
|
|
88
|
+
const signature = seriesPresentationSignature(arr);
|
|
89
|
+
const value = seriesPresentationValue(arr);
|
|
90
|
+
activeEpoch.set(epoch);
|
|
91
|
+
revision.set(revision.get() + 1);
|
|
92
|
+
published.set({ signature, sample: value });
|
|
93
|
+
return {
|
|
94
|
+
epoch, revision: revision.get(), signature,
|
|
95
|
+
series: projectSeriesPresentation(arr), sample: value !== 0 ? value : undefined,
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
// Web has one runtime and does not support executeOnUIRuntimeSync.
|
|
99
|
+
apply(Platform.OS === "web" ? read() : executeOnUIRuntimeSync(read)());
|
|
100
|
+
}, [series, activeEpoch, revision, published, apply]);
|
|
101
|
+
|
|
102
|
+
useLayoutEffect(() => {
|
|
103
|
+
currentSource.current = series;
|
|
104
|
+
epochCounter.current += 1;
|
|
105
|
+
refresh();
|
|
106
|
+
return () => { currentSource.current = null; };
|
|
107
|
+
}, [series, refresh]);
|
|
108
|
+
|
|
109
|
+
const epoch = presentation.epoch;
|
|
110
|
+
useAnimatedReaction(
|
|
111
|
+
() => {
|
|
112
|
+
const arr = series.get();
|
|
113
|
+
return { signature: seriesPresentationSignature(arr), value: seriesPresentationValue(arr) };
|
|
114
|
+
},
|
|
115
|
+
(current) => {
|
|
116
|
+
// Old mappers can finish after a prop change; neither their sample nor
|
|
117
|
+
// an already queued JS publication may overwrite the new source.
|
|
118
|
+
if (epoch !== activeEpoch.get()) return;
|
|
119
|
+
const previous = published.get();
|
|
120
|
+
const resample = shouldResampleLayoutValue(current.value, previous.sample);
|
|
121
|
+
if (current.signature === previous.signature && !resample) return;
|
|
122
|
+
const sample = resample ? current.value : previous.sample;
|
|
123
|
+
published.set({ signature: current.signature, sample });
|
|
124
|
+
revision.set(revision.get() + 1);
|
|
125
|
+
scheduleOnRN(apply, {
|
|
126
|
+
epoch, revision: revision.get(), signature: current.signature,
|
|
127
|
+
series: projectSeriesPresentation(series.get()), sample: sample !== 0 ? sample : undefined,
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
[series, epoch, activeEpoch, revision, published, apply],
|
|
131
|
+
);
|
|
132
|
+
return { snapshot: presentation.series, valueLayoutSample: presentation.sample, refresh };
|
|
133
|
+
}
|
package/src/math/squiggly.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MAX_FRAME_DELTA_MS } from "../constants";
|
|
1
2
|
import type { ChartPadding } from "../draw/line";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -39,6 +40,32 @@ export function squiggleClockSeconds(): number {
|
|
|
39
40
|
return Date.now() / 1000;
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
/**
|
|
44
|
+
* The squiggle's animated time (ms) after one more frame, toward
|
|
45
|
+
* `LoadingConfig.freezeAfterMs`. A frame counts its delta clamped to
|
|
46
|
+
* 0–{@link MAX_FRAME_DELTA_MS}, so the first frame back from the background (or
|
|
47
|
+
* after a stall) counts as one frame, not as the time away.
|
|
48
|
+
*/
|
|
49
|
+
export function squiggleShownMsAfterFrame(
|
|
50
|
+
shownMs: number,
|
|
51
|
+
frameMs: number,
|
|
52
|
+
): number {
|
|
53
|
+
"worklet";
|
|
54
|
+
return shownMs + Math.min(Math.max(frameMs, 0), MAX_FRAME_DELTA_MS);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Whether the squiggle has used up `freezeAfterMs` and is frozen. `undefined`
|
|
59
|
+
* never freezes; `0` or less freezes from the start.
|
|
60
|
+
*/
|
|
61
|
+
export function squiggleFrozen(
|
|
62
|
+
shownMs: number,
|
|
63
|
+
freezeAfterMs: number | undefined,
|
|
64
|
+
): boolean {
|
|
65
|
+
"worklet";
|
|
66
|
+
return freezeAfterMs !== undefined && shownMs >= freezeAfterMs;
|
|
67
|
+
}
|
|
68
|
+
|
|
42
69
|
/**
|
|
43
70
|
* Build a flat [x0,y0,x1,y1,...] point array for a standalone squiggly line
|
|
44
71
|
* spanning the full chart area (used in loading / empty state).
|
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
|
*/
|
|
@@ -2394,6 +2402,13 @@ export interface LoadingConfig {
|
|
|
2394
2402
|
* squiggle with no placeholder ticks. Default `true`.
|
|
2395
2403
|
*/
|
|
2396
2404
|
axisLabels?: boolean;
|
|
2405
|
+
/**
|
|
2406
|
+
* Freezes the squiggle once it has animated this long (ms) each time the
|
|
2407
|
+
* loading or empty shell appears; it moves again when the shell next appears.
|
|
2408
|
+
* Counted in frames drawn, so time in the background doesn't count. `0` or
|
|
2409
|
+
* less freezes it from the start. Default `undefined`: no limit.
|
|
2410
|
+
*/
|
|
2411
|
+
freezeAfterMs?: number;
|
|
2397
2412
|
}
|
|
2398
2413
|
|
|
2399
2414
|
/** Y-range easing shared by both charts, independent of value/window tracking. */
|
|
@@ -2415,7 +2430,10 @@ export interface RangeAnimationConfig {
|
|
|
2415
2430
|
contractionSmoothing?: number;
|
|
2416
2431
|
}
|
|
2417
2432
|
|
|
2418
|
-
/**
|
|
2433
|
+
/**
|
|
2434
|
+
* Y-range easing and optional presentation transform for {@link LiveChartSeries}.
|
|
2435
|
+
* The first measured, visible data fits immediately; easing applies afterward.
|
|
2436
|
+
*/
|
|
2419
2437
|
export interface SeriesRangeAnimationConfig extends RangeAnimationConfig {
|
|
2420
2438
|
/**
|
|
2421
2439
|
* UI-thread worklet applied after normal fitting/easing. Receives untransformed
|
|
@@ -2484,7 +2502,8 @@ export interface LiveChartCoreProps {
|
|
|
2484
2502
|
* `true` shows the shell with the defaults; pass a {@link LoadingConfig} to
|
|
2485
2503
|
* restyle it — `color` / `strokeWidth` for the squiggle + skeleton, `amplitude`
|
|
2486
2504
|
* / `speed` for the breathing wave, `axisLabels` to toggle the skeleton
|
|
2487
|
-
* placeholders
|
|
2505
|
+
* placeholders, `freezeAfterMs` to freeze the wave after a while.
|
|
2506
|
+
* `false` / omitted is "not loading". Toggle between the config
|
|
2488
2507
|
* and `false` as data loads (e.g. `loading={isLoading && cfg}`). The loading→live
|
|
2489
2508
|
* reveal duration is governed separately by {@link TransitionConfig.reveal} (the
|
|
2490
2509
|
* `transitions` prop).
|
|
@@ -2689,7 +2708,10 @@ export interface LiveChartCoreProps {
|
|
|
2689
2708
|
/**
|
|
2690
2709
|
* Right-edge buffer as a fraction of `timeWindow`. Pushes the live edge past the
|
|
2691
2710
|
* current time so the latest point has breathing room; pass `0` to land the latest
|
|
2692
|
-
* point exactly at the right edge.
|
|
2711
|
+
* point exactly at the right edge. In line-mode LiveChart, a positive buffer
|
|
2712
|
+
* stops the line/dot at the last recorded point; the badge and value line use
|
|
2713
|
+
* that recorded price. badge.followViewEdge retains its edge-pinned indicators.
|
|
2714
|
+
* Default `0`.
|
|
2693
2715
|
*/
|
|
2694
2716
|
windowBuffer?: number;
|
|
2695
2717
|
/**
|
|
@@ -2794,15 +2816,25 @@ export interface LiveChartCoreProps {
|
|
|
2794
2816
|
|
|
2795
2817
|
/**
|
|
2796
2818
|
* UI-thread scroll/zoom state adopted by a single-series {@link LiveChart}.
|
|
2797
|
-
* The app owns leadership and timestamp mapping; gestures write
|
|
2819
|
+
* The app owns leadership and timestamp mapping; gestures write end/window.
|
|
2798
2820
|
* @experimental
|
|
2799
2821
|
*/
|
|
2800
2822
|
export interface ChartViewportControl {
|
|
2801
2823
|
/** Right-edge unix timestamp in seconds; null follows this chart's live edge.
|
|
2802
|
-
* Honors times past live.
|
|
2824
|
+
* Honors times past live. Before the first retained point, falls back to live
|
|
2825
|
+
* unless a valid explicit range is supplied. */
|
|
2803
2826
|
end: SharedValue<number | null>;
|
|
2804
2827
|
/** Positive, finite visible width in seconds; null uses the timeWindow prop. */
|
|
2805
2828
|
window: SharedValue<number | null>;
|
|
2829
|
+
/**
|
|
2830
|
+
* Exact price bounds while end is finite and non-null, including empty past or
|
|
2831
|
+
* future space. Both bounds and their difference must be finite, with min < max.
|
|
2832
|
+
* Applied immediately, overriding automatic fitting, range easing, nonNegative,
|
|
2833
|
+
* maxValue, minRange, and yRangeScale. Invalid/null/omitted bounds use auto-fit.
|
|
2834
|
+
* Ignored while end is null (including after resetZoom()); gestures and resets
|
|
2835
|
+
* do not write this optional shared value.
|
|
2836
|
+
*/
|
|
2837
|
+
range?: SharedValue<Pick<ChartScale, "min" | "max"> | null>;
|
|
2806
2838
|
}
|
|
2807
2839
|
|
|
2808
2840
|
/** External viewport state and optional behavior settings for {@link LiveChart}.
|
|
@@ -2812,7 +2844,8 @@ export interface ChartViewportControl {
|
|
|
2812
2844
|
export interface ViewportConfig extends ChartViewportControl {
|
|
2813
2845
|
/** Ease non-null window overrides using the chart's smoothing. Default true.
|
|
2814
2846
|
* Set false on followers copying a leader's drawn width to avoid easing twice.
|
|
2815
|
-
* Null windows still ease back to timeWindow;
|
|
2847
|
+
* Null windows still ease back to timeWindow; value and automatic Y-range
|
|
2848
|
+
* smoothing are unchanged. Explicit range bounds always apply immediately. */
|
|
2816
2849
|
windowSmoothing?: boolean;
|
|
2817
2850
|
}
|
|
2818
2851
|
|
|
@@ -2825,6 +2858,9 @@ export interface LiveChartProps extends LiveChartCoreProps {
|
|
|
2825
2858
|
* and wake autoSleep charts. Single-series line/candle only.
|
|
2826
2859
|
* Pass a ViewportConfig object to enable; false/omitted uses private state.
|
|
2827
2860
|
* Both shared values are required, so this prop has no true shorthand.
|
|
2861
|
+
* Optional range supplies exact price bounds while end is non-null. In line
|
|
2862
|
+
* mode the line/dot stop at the last recorded point, with badge/value line at
|
|
2863
|
+
* that price; badge.followViewEdge keeps its edge-pinned indicators.
|
|
2828
2864
|
* @experimental
|
|
2829
2865
|
*/
|
|
2830
2866
|
viewport?: false | ViewportConfig;
|