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
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
DashPathEffect,
|
|
3
|
+
Group,
|
|
4
|
+
Path,
|
|
5
|
+
type SkFont,
|
|
6
|
+
type SkPath,
|
|
7
|
+
} from "@shopify/react-native-skia";
|
|
2
8
|
import { useDerivedValue, type SharedValue } from "react-native-reanimated";
|
|
3
9
|
import { X_AXIS_LABEL_OFFSET_Y } from "../constants";
|
|
10
|
+
import type { ResolvedGridStyleConfig } from "../core/resolveConfig";
|
|
4
11
|
import type { ChartEngineLayout } from "../core/useLiveChartEngine";
|
|
5
12
|
import type { ChartPadding } from "../draw/line";
|
|
6
13
|
import type { XAxisEntry } from "../hooks/useXAxis";
|
|
@@ -95,3 +102,99 @@ export function XAxisOverlay({
|
|
|
95
102
|
</Group>
|
|
96
103
|
);
|
|
97
104
|
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Vertical grid lines at the time-axis ticks (`xAxis.gridLines`). The chart
|
|
108
|
+
* draws this behind the series, in the horizontal grid's layer; the axis line,
|
|
109
|
+
* ticks, and labels stay in {@link XAxisOverlay} above it. One pooled line per
|
|
110
|
+
* label slot, so each line fades with its label instead of popping in at the
|
|
111
|
+
* plot edges.
|
|
112
|
+
*/
|
|
113
|
+
export function XAxisGridLines({
|
|
114
|
+
entries,
|
|
115
|
+
engine,
|
|
116
|
+
padding,
|
|
117
|
+
palette,
|
|
118
|
+
gridStyle,
|
|
119
|
+
volumeBandHeight = 0,
|
|
120
|
+
}: {
|
|
121
|
+
entries: SharedValue<XAxisEntry[]>;
|
|
122
|
+
engine: ChartEngineLayout;
|
|
123
|
+
padding: ChartPadding;
|
|
124
|
+
palette: LiveChartPalette;
|
|
125
|
+
gridStyle: ResolvedGridStyleConfig;
|
|
126
|
+
/** Reserved volume-band height (px); the lines run through it to the axis line. */
|
|
127
|
+
volumeBandHeight?: number;
|
|
128
|
+
}) {
|
|
129
|
+
const segmentBuilder = usePathBuilder();
|
|
130
|
+
// Capturing the whole engine subscribes this immutable segment to its live
|
|
131
|
+
// clock/range too. Only layout changes should allocate a new segment path.
|
|
132
|
+
const { canvasWidth, canvasHeight } = engine;
|
|
133
|
+
const { left, right, top, bottom } = padding;
|
|
134
|
+
|
|
135
|
+
// One vertical segment, from the plot top down to the axis line, shared by
|
|
136
|
+
// the whole pool: each line only translates it to its tick.
|
|
137
|
+
const segment = useDerivedValue(() => {
|
|
138
|
+
"worklet";
|
|
139
|
+
const b = segmentBuilder.value;
|
|
140
|
+
b.moveTo(0, top);
|
|
141
|
+
b.lineTo(
|
|
142
|
+
0,
|
|
143
|
+
canvasHeight.get() - bottom + volumeBandHeight,
|
|
144
|
+
);
|
|
145
|
+
return b.detach();
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// Fading ticks can remain just outside the plot. Keep their strokes out of
|
|
149
|
+
// the axis gutters while retaining the full candle volume-band height.
|
|
150
|
+
const clip = useDerivedValue(() => ({
|
|
151
|
+
x: left,
|
|
152
|
+
y: top,
|
|
153
|
+
width: Math.max(0, canvasWidth.get() - left - right),
|
|
154
|
+
height: Math.max(0, canvasHeight.get() - bottom + volumeBandHeight - top),
|
|
155
|
+
}));
|
|
156
|
+
|
|
157
|
+
return (
|
|
158
|
+
<Group opacity={gridStyle.opacity} clip={clip}>
|
|
159
|
+
{Array.from({ length: MAX_X_LABELS }, (_, i) => (
|
|
160
|
+
<XAxisGridLine
|
|
161
|
+
key={i}
|
|
162
|
+
entries={entries}
|
|
163
|
+
index={i}
|
|
164
|
+
segment={segment}
|
|
165
|
+
color={gridStyle.color ?? palette.gridLine}
|
|
166
|
+
strokeWidth={gridStyle.strokeWidth}
|
|
167
|
+
intervals={gridStyle.intervals}
|
|
168
|
+
/>
|
|
169
|
+
))}
|
|
170
|
+
</Group>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function XAxisGridLine({
|
|
175
|
+
entries,
|
|
176
|
+
index,
|
|
177
|
+
segment,
|
|
178
|
+
color,
|
|
179
|
+
strokeWidth,
|
|
180
|
+
intervals,
|
|
181
|
+
}: {
|
|
182
|
+
entries: SharedValue<XAxisEntry[]>;
|
|
183
|
+
index: number;
|
|
184
|
+
segment: SharedValue<SkPath>;
|
|
185
|
+
color: string;
|
|
186
|
+
strokeWidth: number;
|
|
187
|
+
intervals: number[];
|
|
188
|
+
}) {
|
|
189
|
+
const transform = useDerivedValue(() => [
|
|
190
|
+
{ translateX: entries.get()[index]?.x ?? -200 },
|
|
191
|
+
]);
|
|
192
|
+
const opacity = useDerivedValue(() => entries.get()[index]?.alpha ?? 0);
|
|
193
|
+
return (
|
|
194
|
+
<Group transform={transform} opacity={opacity}>
|
|
195
|
+
<Path path={segment} style="stroke" strokeWidth={strokeWidth} color={color}>
|
|
196
|
+
{intervals.length > 0 && <DashPathEffect intervals={intervals} />}
|
|
197
|
+
</Path>
|
|
198
|
+
</Group>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
@@ -88,6 +88,8 @@ export interface EngineTickInput {
|
|
|
88
88
|
nonNegative?: boolean;
|
|
89
89
|
/** Hard cap for the computed upper bound. */
|
|
90
90
|
maxValue?: number;
|
|
91
|
+
/** Smallest fitted span, in data units; widened around the data. */
|
|
92
|
+
minRange?: number;
|
|
91
93
|
/** Positive, finite Y-range multiplier around the fitted midpoint (1 = auto-fit). */
|
|
92
94
|
yRangeScale?: number;
|
|
93
95
|
targetValue: number;
|
|
@@ -148,6 +150,8 @@ export interface EngineTickInput {
|
|
|
148
150
|
* overrides its width. `displayWindow` eases toward this when set.
|
|
149
151
|
*/
|
|
150
152
|
viewWindow?: number | null;
|
|
153
|
+
/** Ease a non-null viewWindow override. False adopts a leader's drawn width exactly. Default true. */
|
|
154
|
+
viewWindowSmoothing?: boolean;
|
|
151
155
|
/** Chart mode — `"candle"` uses OHLC bars for Y range instead of line points. */
|
|
152
156
|
mode?: "line" | "candle";
|
|
153
157
|
/** Committed OHLC bars (sorted by time). Used when mode is `"candle"`. */
|
|
@@ -207,6 +211,12 @@ export function tickLiveChartEngineFrame(
|
|
|
207
211
|
"worklet";
|
|
208
212
|
const baseNow = input.nowOverride ?? input.nowSeconds ?? Date.now() / 1000;
|
|
209
213
|
const liveEdge = baseNow + (input.windowBuffer ?? 0) * input.timeWindow;
|
|
214
|
+
const targetWindow = input.viewWindow ?? input.timeWindow;
|
|
215
|
+
// Keep clock rounding below half a pixel of the displayed window as it
|
|
216
|
+
// changes. Using only the target window during expansion can leave "now"
|
|
217
|
+
// several visible pixels past the edge and hide a live marker.
|
|
218
|
+
const timestampSecondsPerPixel =
|
|
219
|
+
Math.min(state.displayWindow, targetWindow) / input.canvasWidth;
|
|
210
220
|
const viewEnd = input.viewEnd;
|
|
211
221
|
// First time of the visible series' data — the floor a frozen edge must stay
|
|
212
222
|
// at or above. `-Infinity` when there's no data to bound against, so the freeze
|
|
@@ -238,7 +248,7 @@ export function tickLiveChartEngineFrame(
|
|
|
238
248
|
? advanceTimestampByPixel(
|
|
239
249
|
state.liveEdge,
|
|
240
250
|
liveEdge,
|
|
241
|
-
|
|
251
|
+
timestampSecondsPerPixel,
|
|
242
252
|
)
|
|
243
253
|
: liveEdge;
|
|
244
254
|
if (scrolledBack) {
|
|
@@ -260,7 +270,7 @@ export function tickLiveChartEngineFrame(
|
|
|
260
270
|
state.timestamp = advanceTimestampByPixel(
|
|
261
271
|
state.timestamp,
|
|
262
272
|
liveEdge,
|
|
263
|
-
|
|
273
|
+
timestampSecondsPerPixel,
|
|
264
274
|
);
|
|
265
275
|
} else {
|
|
266
276
|
state.timestamp = liveEdge;
|
|
@@ -304,8 +314,8 @@ export function tickLiveChartEngineFrame(
|
|
|
304
314
|
|
|
305
315
|
// Pinch-zoom: ease toward the zoom override when set, else the configured
|
|
306
316
|
// window. Mirrors the viewEnd freeze above (width vs. right edge).
|
|
307
|
-
|
|
308
|
-
|
|
317
|
+
state.displayWindow = snap ||
|
|
318
|
+
(input.viewWindow != null && input.viewWindowSmoothing === false)
|
|
309
319
|
? targetWindow
|
|
310
320
|
: lerpAndSettle(
|
|
311
321
|
state.displayWindow,
|
|
@@ -445,6 +455,41 @@ export function tickLiveChartEngineFrame(
|
|
|
445
455
|
tMax += margin;
|
|
446
456
|
}
|
|
447
457
|
|
|
458
|
+
const floorRange = input.minRange;
|
|
459
|
+
// Compare the bounded fit: a clamp can shrink an otherwise wider range.
|
|
460
|
+
// Slide a widened fit off either bound; both hard bounds win if the floor
|
|
461
|
+
// cannot fit between them. Resolve this before the optional manual zoom.
|
|
462
|
+
if (floorRange !== undefined && floorRange > 0 && Number.isFinite(floorRange)) {
|
|
463
|
+
const boundedMin = input.nonNegative && tMin < 0 ? 0 : tMin;
|
|
464
|
+
const boundedMax =
|
|
465
|
+
input.maxValue !== undefined && tMax > input.maxValue ? input.maxValue : tMax;
|
|
466
|
+
if (floorRange > boundedMax - boundedMin) {
|
|
467
|
+
// Halve before adding so large finite prices cannot overflow the midpoint.
|
|
468
|
+
const mid = tMin / 2 + tMax / 2;
|
|
469
|
+
let nextMin = mid - floorRange / 2;
|
|
470
|
+
let nextMax = mid + floorRange / 2;
|
|
471
|
+
if (input.nonNegative && nextMin < 0) {
|
|
472
|
+
nextMax -= nextMin;
|
|
473
|
+
nextMin = 0;
|
|
474
|
+
}
|
|
475
|
+
if (input.maxValue !== undefined && nextMax > input.maxValue) {
|
|
476
|
+
nextMin -= nextMax - input.maxValue;
|
|
477
|
+
nextMax = input.maxValue;
|
|
478
|
+
}
|
|
479
|
+
if (input.nonNegative && nextMin < 0) nextMin = 0;
|
|
480
|
+
// Ignore a floor that would overflow or round the bounds onto each other.
|
|
481
|
+
if (
|
|
482
|
+
Number.isFinite(nextMin) &&
|
|
483
|
+
Number.isFinite(nextMax) &&
|
|
484
|
+
nextMin < nextMax &&
|
|
485
|
+
Number.isFinite(nextMax - nextMin)
|
|
486
|
+
) {
|
|
487
|
+
tMin = nextMin;
|
|
488
|
+
tMax = nextMax;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
448
493
|
// Treat malformed gesture output as auto-fit. A zero/negative multiplier
|
|
449
494
|
// collapses or inverts the range; a non-finite/overflowing one poisons every
|
|
450
495
|
// downstream price-to-Y projection. Keep the guard here on the UI thread so
|
|
@@ -47,6 +47,8 @@ export interface MultiEngineTickInput {
|
|
|
47
47
|
nonNegative?: boolean;
|
|
48
48
|
/** Hard cap for the computed upper bound. */
|
|
49
49
|
maxValue?: number;
|
|
50
|
+
/** Smallest fitted span, in data units; widened around the data. */
|
|
51
|
+
minRange?: number;
|
|
50
52
|
/** Positive, finite Y-range multiplier around the fitted midpoint (1 = auto-fit). */
|
|
51
53
|
yRangeScale?: number;
|
|
52
54
|
series: SeriesConfig[];
|
|
@@ -298,6 +300,41 @@ export function tickLiveChartSeriesEngineFrame(
|
|
|
298
300
|
tMax += margin;
|
|
299
301
|
}
|
|
300
302
|
|
|
303
|
+
const floorRange = input.minRange;
|
|
304
|
+
// Compare the bounded fit: a clamp can shrink an otherwise wider range.
|
|
305
|
+
// Slide a widened fit off either bound; both hard bounds win if the floor
|
|
306
|
+
// cannot fit between them. Resolve this before the optional manual zoom.
|
|
307
|
+
if (floorRange !== undefined && floorRange > 0 && Number.isFinite(floorRange)) {
|
|
308
|
+
const boundedMin = input.nonNegative && tMin < 0 ? 0 : tMin;
|
|
309
|
+
const boundedMax =
|
|
310
|
+
input.maxValue !== undefined && tMax > input.maxValue ? input.maxValue : tMax;
|
|
311
|
+
if (floorRange > boundedMax - boundedMin) {
|
|
312
|
+
// Halve before adding so large finite prices cannot overflow the midpoint.
|
|
313
|
+
const mid = tMin / 2 + tMax / 2;
|
|
314
|
+
let nextMin = mid - floorRange / 2;
|
|
315
|
+
let nextMax = mid + floorRange / 2;
|
|
316
|
+
if (input.nonNegative && nextMin < 0) {
|
|
317
|
+
nextMax -= nextMin;
|
|
318
|
+
nextMin = 0;
|
|
319
|
+
}
|
|
320
|
+
if (input.maxValue !== undefined && nextMax > input.maxValue) {
|
|
321
|
+
nextMin -= nextMax - input.maxValue;
|
|
322
|
+
nextMax = input.maxValue;
|
|
323
|
+
}
|
|
324
|
+
if (input.nonNegative && nextMin < 0) nextMin = 0;
|
|
325
|
+
// Ignore a floor that would overflow or round the bounds onto each other.
|
|
326
|
+
if (
|
|
327
|
+
Number.isFinite(nextMin) &&
|
|
328
|
+
Number.isFinite(nextMax) &&
|
|
329
|
+
nextMin < nextMax &&
|
|
330
|
+
Number.isFinite(nextMax - nextMin)
|
|
331
|
+
) {
|
|
332
|
+
tMin = nextMin;
|
|
333
|
+
tMax = nextMax;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
301
338
|
// Keep this behavior in parity with the single-series engine: malformed
|
|
302
339
|
// gesture output must never collapse, invert, or poison the shared axis.
|
|
303
340
|
const requestedYScale = input.yRangeScale ?? 1;
|
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
CandleGapKind,
|
|
10
10
|
CandleGapLabelStyle,
|
|
11
11
|
CandleGapsConfig,
|
|
12
|
+
ChartViewportControl,
|
|
12
13
|
DegenOptions,
|
|
13
14
|
FontConfig,
|
|
14
15
|
FontWeight,
|
|
@@ -42,9 +43,11 @@ import type {
|
|
|
42
43
|
TradeEvent,
|
|
43
44
|
TransitionConfig,
|
|
44
45
|
ValueLineConfig,
|
|
46
|
+
ViewportConfig,
|
|
45
47
|
VolumeConfig,
|
|
46
48
|
XAxisConfig,
|
|
47
49
|
YAxisConfig,
|
|
50
|
+
YAxisScaleGestureConfig,
|
|
48
51
|
ZoomConfig,
|
|
49
52
|
} from "../types";
|
|
50
53
|
import type { ComponentType, ReactElement } from "react";
|
|
@@ -76,6 +79,8 @@ export interface ResolvedBadgeConfig {
|
|
|
76
79
|
variant: BadgeVariant;
|
|
77
80
|
tail: boolean;
|
|
78
81
|
position: "right" | "left";
|
|
82
|
+
/** "yAxisColumn" → value in the right-anchored Y-axis label column. */
|
|
83
|
+
textAlign: "center" | "yAxisColumn";
|
|
79
84
|
background: string | undefined;
|
|
80
85
|
/** undefined → capsule (pillHeight / 2) at render time */
|
|
81
86
|
radius: number | undefined;
|
|
@@ -93,7 +98,10 @@ export interface ResolvedBadgeConfig {
|
|
|
93
98
|
followViewEdge: boolean;
|
|
94
99
|
}
|
|
95
100
|
|
|
101
|
+
export type ResolvedYAxisScaleGestureConfig = Required<YAxisScaleGestureConfig>;
|
|
102
|
+
|
|
96
103
|
export interface ResolvedYAxisConfig {
|
|
104
|
+
scaleGesture: ResolvedYAxisScaleGestureConfig | null;
|
|
97
105
|
side: "left" | "right";
|
|
98
106
|
minGap: number;
|
|
99
107
|
/** Multiplier used to choose and align representable dynamic nice intervals. */
|
|
@@ -188,9 +196,12 @@ export interface ResolvedAxisLabelConfig {
|
|
|
188
196
|
|
|
189
197
|
export interface ResolvedXAxisConfig {
|
|
190
198
|
minGap: number;
|
|
199
|
+
/** Vertical grid-line overrides over `gridStyle`; null → no vertical grid. */
|
|
200
|
+
gridLines: GridStyleConfig | null;
|
|
191
201
|
}
|
|
192
202
|
|
|
193
203
|
export interface ResolvedScrubConfig {
|
|
204
|
+
markers: { radius: number } | null;
|
|
194
205
|
tooltip: boolean;
|
|
195
206
|
/** Opt-in per-series pill tooltip for LiveChartSeries; null keeps guide-only behavior. */
|
|
196
207
|
seriesTooltip: ResolvedPerSeriesTooltipConfig | null;
|
|
@@ -508,6 +519,7 @@ const BADGE_DEFAULTS: ResolvedBadgeConfig = {
|
|
|
508
519
|
variant: "default",
|
|
509
520
|
tail: true,
|
|
510
521
|
position: "right",
|
|
522
|
+
textAlign: "center",
|
|
511
523
|
background: undefined,
|
|
512
524
|
radius: undefined,
|
|
513
525
|
borderColor: undefined,
|
|
@@ -531,7 +543,7 @@ export function resolveBadge(
|
|
|
531
543
|
return resolveToggle(prop, BADGE_DEFAULTS, false);
|
|
532
544
|
}
|
|
533
545
|
|
|
534
|
-
const Y_AXIS_DEFAULTS: ResolvedYAxisConfig = {
|
|
546
|
+
const Y_AXIS_DEFAULTS: Omit<ResolvedYAxisConfig, "scaleGesture"> = {
|
|
535
547
|
side: "right",
|
|
536
548
|
minGap: 36,
|
|
537
549
|
intervalScale: 1,
|
|
@@ -541,6 +553,23 @@ const Y_AXIS_DEFAULTS: ResolvedYAxisConfig = {
|
|
|
541
553
|
float: false,
|
|
542
554
|
};
|
|
543
555
|
|
|
556
|
+
/** Normalize the opt-in axis gesture; bounds only constrain gesture writes. */
|
|
557
|
+
export function resolveYAxisScaleGesture(
|
|
558
|
+
prop: boolean | YAxisScaleGestureConfig | undefined,
|
|
559
|
+
): ResolvedYAxisScaleGestureConfig | null {
|
|
560
|
+
if (!prop) return null;
|
|
561
|
+
const config = prop === true ? {} : prop;
|
|
562
|
+
const positive = (value: number | undefined, fallback: number) =>
|
|
563
|
+
value !== undefined && Number.isFinite(value) && value > 0 ? value : fallback;
|
|
564
|
+
const minScale = positive(config.minScale, 0.25);
|
|
565
|
+
return {
|
|
566
|
+
minScale,
|
|
567
|
+
maxScale: Math.max(minScale, positive(config.maxScale, 10)),
|
|
568
|
+
dragDistance: positive(config.dragDistance, 160),
|
|
569
|
+
doubleTapReset: config.doubleTapReset ?? true,
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
|
|
544
573
|
/**
|
|
545
574
|
* Resolves `yAxis` prop to a fully-typed config or null (disabled).
|
|
546
575
|
* `true` → defaults, object → merged with defaults, falsy → null.
|
|
@@ -554,6 +583,9 @@ export function resolveYAxis(
|
|
|
554
583
|
if (resolved === null) return null;
|
|
555
584
|
return {
|
|
556
585
|
...resolved,
|
|
586
|
+
scaleGesture: resolveYAxisScaleGesture(
|
|
587
|
+
typeof prop === "object" ? prop.scaleGesture : undefined,
|
|
588
|
+
),
|
|
557
589
|
count: Math.max(0, Math.floor(resolved.count)),
|
|
558
590
|
intervalScale:
|
|
559
591
|
Number.isFinite(resolved.intervalScale) && resolved.intervalScale > 0
|
|
@@ -726,6 +758,31 @@ export function resolveCandleGaps(
|
|
|
726
758
|
};
|
|
727
759
|
}
|
|
728
760
|
|
|
761
|
+
export interface ResolvedViewportConfig extends ChartViewportControl {
|
|
762
|
+
/** Fully resolved render-time option; shared values are kept by reference. */
|
|
763
|
+
windowSmoothing: boolean;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
const VIEWPORT_DEFAULTS: Pick<ResolvedViewportConfig, "windowSmoothing"> = {
|
|
767
|
+
windowSmoothing: true,
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* Resolves the external viewport prop at render time: false/omitted → private
|
|
772
|
+
* state; an object → required shared values plus defaulted behavior options.
|
|
773
|
+
* Never reads or clones the shared values; they remain UI-thread inputs.
|
|
774
|
+
*/
|
|
775
|
+
export function resolveViewport(
|
|
776
|
+
prop: false | ViewportConfig | undefined,
|
|
777
|
+
): ResolvedViewportConfig | null {
|
|
778
|
+
if (prop === undefined || prop === false) return null;
|
|
779
|
+
return {
|
|
780
|
+
end: prop.end,
|
|
781
|
+
window: prop.window,
|
|
782
|
+
windowSmoothing: prop.windowSmoothing ?? VIEWPORT_DEFAULTS.windowSmoothing,
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
|
|
729
786
|
export interface ResolvedZoomConfig {
|
|
730
787
|
/** Tightest window (max zoom-in), seconds. `undefined` → `timeWindow / 8`. */
|
|
731
788
|
minTimeWindow: number | undefined;
|
|
@@ -904,8 +961,12 @@ export function resolveAxisLabel(
|
|
|
904
961
|
|
|
905
962
|
const X_AXIS_DEFAULTS: ResolvedXAxisConfig = {
|
|
906
963
|
minGap: 60,
|
|
964
|
+
gridLines: null,
|
|
907
965
|
};
|
|
908
966
|
|
|
967
|
+
/** `gridLines: true` overrides nothing, so the lines take the `gridStyle` look. */
|
|
968
|
+
const NO_GRID_STYLE_OVERRIDES: GridStyleConfig = {};
|
|
969
|
+
|
|
909
970
|
/**
|
|
910
971
|
* Resolves `xAxis` prop to a fully-typed config or null (disabled).
|
|
911
972
|
* Defaults to enabled (`true`) so a bare `undefined` also returns the defaults.
|
|
@@ -913,10 +974,37 @@ const X_AXIS_DEFAULTS: ResolvedXAxisConfig = {
|
|
|
913
974
|
export function resolveXAxis(
|
|
914
975
|
prop: boolean | XAxisConfig | undefined,
|
|
915
976
|
): ResolvedXAxisConfig | null {
|
|
916
|
-
|
|
977
|
+
if (prop === false) return null;
|
|
978
|
+
if (prop == null || prop === true) return X_AXIS_DEFAULTS;
|
|
979
|
+
const { gridLines } = prop;
|
|
980
|
+
return {
|
|
981
|
+
minGap: prop.minGap ?? X_AXIS_DEFAULTS.minGap,
|
|
982
|
+
gridLines:
|
|
983
|
+
gridLines === true ? NO_GRID_STYLE_OVERRIDES : gridLines || null,
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
/**
|
|
988
|
+
* Resolves the vertical grid's style: `xAxis.gridLines` fields over the
|
|
989
|
+
* resolved `gridStyle`. Returns `base` itself when nothing is overridden, and
|
|
990
|
+
* null when the vertical grid is off.
|
|
991
|
+
*/
|
|
992
|
+
export function resolveXAxisGridStyle(
|
|
993
|
+
gridLines: GridStyleConfig | null,
|
|
994
|
+
base: ResolvedGridStyleConfig,
|
|
995
|
+
): ResolvedGridStyleConfig | null {
|
|
996
|
+
if (!gridLines) return null;
|
|
997
|
+
if (gridLines === NO_GRID_STYLE_OVERRIDES) return base;
|
|
998
|
+
return {
|
|
999
|
+
color: gridLines.color ?? base.color,
|
|
1000
|
+
strokeWidth: gridLines.strokeWidth ?? base.strokeWidth,
|
|
1001
|
+
intervals: gridLines.intervals ?? base.intervals,
|
|
1002
|
+
opacity: gridLines.opacity ?? base.opacity,
|
|
1003
|
+
};
|
|
917
1004
|
}
|
|
918
1005
|
|
|
919
1006
|
const SCRUB_DEFAULTS: ResolvedScrubConfig = {
|
|
1007
|
+
markers: null,
|
|
920
1008
|
tooltip: true,
|
|
921
1009
|
seriesTooltip: null,
|
|
922
1010
|
dimTarget: "future",
|
|
@@ -1005,6 +1093,11 @@ export function resolveScrub(
|
|
|
1005
1093
|
const seriesTooltip =
|
|
1006
1094
|
typeof prop === "object" ? prop.seriesTooltip : undefined;
|
|
1007
1095
|
resolved.seriesTooltip = resolvePerSeriesTooltip(seriesTooltip);
|
|
1096
|
+
const markers = typeof prop === "object" ? prop.markers : undefined;
|
|
1097
|
+
const radius = typeof markers === "object" ? markers.radius : undefined;
|
|
1098
|
+
resolved.markers = markers
|
|
1099
|
+
? { radius: radius !== undefined && Number.isFinite(radius) ? Math.max(0, radius) : 16 }
|
|
1100
|
+
: null;
|
|
1008
1101
|
// `resolveToggle` shallow-merges object props, so an explicitly undefined
|
|
1009
1102
|
// optional field replaces its default. Restore the public defaults before
|
|
1010
1103
|
// normalizing; otherwise the numeric clamps produce NaN and an undefined
|
|
@@ -39,8 +39,11 @@ import {
|
|
|
39
39
|
} from "./historyRangeCache";
|
|
40
40
|
|
|
41
41
|
import { useHistoryRevision } from "./useHistoryRevision";
|
|
42
|
+
import type { ResolvedViewportConfig } from "./resolveConfig";
|
|
42
43
|
|
|
43
44
|
export interface EngineConfig {
|
|
45
|
+
/** External scroll/zoom values adopted in place of private gesture state. */
|
|
46
|
+
viewport?: ResolvedViewportConfig | null;
|
|
44
47
|
/** Original inputs before a reveal/stash bridge that may suppress same-array notifications. */
|
|
45
48
|
dataChangeSource?: SharedValue<LiveChartPoint[]>;
|
|
46
49
|
candlesChangeSource?: SharedValue<CandlePoint[]>;
|
|
@@ -77,6 +80,7 @@ export interface EngineConfig {
|
|
|
77
80
|
thresholdRangeExtendToNow?: boolean;
|
|
78
81
|
nonNegative?: boolean;
|
|
79
82
|
maxValue?: number;
|
|
83
|
+
minRange?: number;
|
|
80
84
|
/** Positive, finite live Y-range multiplier (1 = auto-fit); read each frame. */
|
|
81
85
|
yRangeScale?: SharedValue<number>;
|
|
82
86
|
nowOverride?: number;
|
|
@@ -257,6 +261,7 @@ export interface EngineFrameRefs {
|
|
|
257
261
|
thresholdRangeExtendToNow?: SharedValue<boolean>;
|
|
258
262
|
nonNegativeSV?: SharedValue<boolean>;
|
|
259
263
|
maxValueSV?: SharedValue<number | undefined>;
|
|
264
|
+
minRangeSV?: SharedValue<number | undefined>;
|
|
260
265
|
yRangeScaleSV?: SharedValue<number>;
|
|
261
266
|
nowOverrideSV?: SharedValue<number | undefined>;
|
|
262
267
|
windowBufferSV?: SharedValue<number>;
|
|
@@ -271,6 +276,8 @@ export interface EngineFrameRefs {
|
|
|
271
276
|
returnFromSV?: SharedValue<number>;
|
|
272
277
|
/** Pinch-zoom window-width override (null = follow timeWindow). Optional for callers/tests. */
|
|
273
278
|
viewWindowSV?: SharedValue<number | null>;
|
|
279
|
+
/** Whether a non-null window override eases (false copies a drawn width exactly). */
|
|
280
|
+
viewWindowSmoothingSV?: SharedValue<boolean>;
|
|
274
281
|
/** Receives the computed live edge each frame. Optional for callers/tests. */
|
|
275
282
|
liveEdgeSV?: SharedValue<number>;
|
|
276
283
|
/** Receives the smoothed right-edge value each frame. Optional for callers/tests. */
|
|
@@ -402,6 +409,7 @@ export function applyLiveChartEngineFrame(
|
|
|
402
409
|
input.thresholdRangeExtendToNow = sv.thresholdRangeExtendToNow?.value ?? true;
|
|
403
410
|
input.nonNegative = sv.nonNegativeSV?.value ?? false;
|
|
404
411
|
input.maxValue = sv.maxValueSV?.value;
|
|
412
|
+
input.minRange = sv.minRangeSV?.value;
|
|
405
413
|
input.yRangeScale = sv.yRangeScaleSV?.value ?? 1;
|
|
406
414
|
input.nowOverride = sv.nowOverrideSV?.value;
|
|
407
415
|
input.windowBuffer = sv.windowBufferSV?.value ?? 0;
|
|
@@ -417,6 +425,7 @@ export function applyLiveChartEngineFrame(
|
|
|
417
425
|
input.returnT = sv.returnTSV?.value;
|
|
418
426
|
input.returnFrom = sv.returnFromSV?.value;
|
|
419
427
|
input.viewWindow = sv.viewWindowSV?.value;
|
|
428
|
+
input.viewWindowSmoothing = sv.viewWindowSmoothingSV?.value ?? true;
|
|
420
429
|
input.mode = sv.modeSV.value;
|
|
421
430
|
input.candles = candleHistory?.data ?? sv.candles?.value;
|
|
422
431
|
input.historyRevision =
|
|
@@ -457,6 +466,7 @@ export function useLiveChartEngine(
|
|
|
457
466
|
config: EngineConfig,
|
|
458
467
|
): SingleEngineState & ChartEngineScroll & ChartEngineEdge & { wake: () => void } {
|
|
459
468
|
const {
|
|
469
|
+
viewport,
|
|
460
470
|
data,
|
|
461
471
|
dataChangeSource = data,
|
|
462
472
|
value,
|
|
@@ -473,6 +483,7 @@ export function useLiveChartEngine(
|
|
|
473
483
|
thresholdRangeExtendToStart: configuredThresholdRangeExtendToStart,
|
|
474
484
|
nonNegative,
|
|
475
485
|
maxValue,
|
|
486
|
+
minRange,
|
|
476
487
|
yRangeScale,
|
|
477
488
|
nowOverride,
|
|
478
489
|
windowBuffer,
|
|
@@ -499,14 +510,20 @@ export function useLiveChartEngine(
|
|
|
499
510
|
// Pinch-zoom window-width override (null = follow the configured window).
|
|
500
511
|
// Declared first so `timeWindow` below can fold it in. Defaults to null so
|
|
501
512
|
// charts without `zoom` behave exactly as before.
|
|
502
|
-
const
|
|
513
|
+
const internalViewWindow = useSharedValue<number | null>(null);
|
|
514
|
+
const viewWindow = viewport?.window ?? internalViewWindow;
|
|
515
|
+
const hasViewport = viewport != null;
|
|
516
|
+
const windowSmoothing = viewport?.windowSmoothing ?? true;
|
|
517
|
+
const viewWindowSmoothingSV = useDerivedValue(() => windowSmoothing);
|
|
503
518
|
// A change to the `timeWindow` prop (a range / timeframe selector) is an explicit
|
|
504
519
|
// request to set the window, so it clears any active pinch-zoom override —
|
|
505
520
|
// otherwise the override below (`viewWindow ?? config.timeWindow`) would shadow
|
|
506
521
|
// the new prop forever, and prop-driven window changes would silently no-op.
|
|
522
|
+
// An app-owned viewport keeps its override until the app/handle clears it.
|
|
507
523
|
useEffect(() => {
|
|
524
|
+
if (hasViewport) return;
|
|
508
525
|
viewWindow.set(null);
|
|
509
|
-
}, [configuredTimeWindow, viewWindow]);
|
|
526
|
+
}, [configuredTimeWindow, viewWindow, hasViewport]);
|
|
510
527
|
|
|
511
528
|
// Low-frequency config → UI thread via useDerivedValue. `timeWindow` is the
|
|
512
529
|
// *effective* target window: the zoom override when set, else the prop. Both
|
|
@@ -553,6 +570,7 @@ export function useLiveChartEngine(
|
|
|
553
570
|
);
|
|
554
571
|
const nonNegativeSV = useDerivedValue(() => nonNegative ?? false);
|
|
555
572
|
const maxValueSV = useDerivedValue(() => maxValue);
|
|
573
|
+
const minRangeSV = useDerivedValue(() => minRange);
|
|
556
574
|
const nowOverrideSV = useDerivedValue(() => nowOverride);
|
|
557
575
|
const windowBufferSV = useDerivedValue(() => windowBuffer ?? 0);
|
|
558
576
|
const pausedSV = useDerivedValue(() => paused ?? false);
|
|
@@ -560,9 +578,9 @@ export function useLiveChartEngine(
|
|
|
560
578
|
// (the tick no longer reads it — clearing `viewEnd` is what makes it follow).
|
|
561
579
|
// Defaults to enabled so a caller that omits it behaves as before.
|
|
562
580
|
const scrollEnabledSV = useDerivedValue(() => scrollEnabled ?? true);
|
|
563
|
-
//
|
|
581
|
+
// External viewports can follow a pane whose forming bar ends past our live edge.
|
|
564
582
|
const allowFutureViewEndSV = useDerivedValue(
|
|
565
|
-
() => allowFutureViewEnd ?? false,
|
|
583
|
+
() => hasViewport || (allowFutureViewEnd ?? false),
|
|
566
584
|
);
|
|
567
585
|
// Return-to-live glide duration (ms); 0 = instant snap. Read by the reaction.
|
|
568
586
|
const returnToLiveMsSV = useDerivedValue(
|
|
@@ -595,7 +613,8 @@ export function useLiveChartEngine(
|
|
|
595
613
|
// edge at that absolute time. `liveEdge` mirrors the would-be-live timestamp
|
|
596
614
|
// each frame so the gesture can clamp / detect catch-up. Both default to
|
|
597
615
|
// "following" so charts without `timeScroll` behave exactly as before.
|
|
598
|
-
const
|
|
616
|
+
const internalViewEnd = useSharedValue<number | null>(null);
|
|
617
|
+
const viewEnd = viewport?.end ?? internalViewEnd;
|
|
599
618
|
const liveEdge = useSharedValue(initialTimestamp);
|
|
600
619
|
const edgeValue = useSharedValue(0);
|
|
601
620
|
// "Return to live" glide (see #164). When time-scroll is disabled while scrolled
|
|
@@ -670,6 +689,7 @@ export function useLiveChartEngine(
|
|
|
670
689
|
thresholdRangeExtendToNow,
|
|
671
690
|
nonNegativeSV,
|
|
672
691
|
maxValueSV,
|
|
692
|
+
minRangeSV,
|
|
673
693
|
yRangeScaleSV: yRangeScale,
|
|
674
694
|
nowOverrideSV,
|
|
675
695
|
windowBufferSV,
|
|
@@ -679,6 +699,7 @@ export function useLiveChartEngine(
|
|
|
679
699
|
returnTSV: returnT,
|
|
680
700
|
returnFromSV: returnFrom,
|
|
681
701
|
viewWindowSV: viewWindow,
|
|
702
|
+
viewWindowSmoothingSV,
|
|
682
703
|
liveEdgeSV: liveEdge,
|
|
683
704
|
edgeValueSV: edgeValue,
|
|
684
705
|
snapSV,
|
|
@@ -720,6 +741,7 @@ export function useLiveChartEngine(
|
|
|
720
741
|
liveCandle,
|
|
721
742
|
liveEdge,
|
|
722
743
|
maxValueSV,
|
|
744
|
+
minRangeSV,
|
|
723
745
|
modeSV,
|
|
724
746
|
nonNegativeSV,
|
|
725
747
|
nowOverrideSV,
|
|
@@ -739,6 +761,7 @@ export function useLiveChartEngine(
|
|
|
739
761
|
value,
|
|
740
762
|
viewEnd,
|
|
741
763
|
viewWindow,
|
|
764
|
+
viewWindowSmoothingSV,
|
|
742
765
|
windowBufferSV,
|
|
743
766
|
yRangeScale,
|
|
744
767
|
],
|
|
@@ -791,15 +814,15 @@ export function useLiveChartEngine(
|
|
|
791
814
|
canvasHeight.get(), timeWindow.get(), smoothing.get(), rangeAnimationSV.get(), adaptiveSpeedBoostSV.get(),
|
|
792
815
|
exaggerateSV.get(), referenceValue.get(), referenceValues.get(), thresholdRangePoints.get(),
|
|
793
816
|
thresholdRangeExtendToStart.get(), thresholdRangeExtendToNow.get(), nonNegativeSV.get(),
|
|
794
|
-
maxValueSV.get(), yRangeScale?.get(), nowOverrideSV.get(), windowBufferSV.get(), pausedSV.get(),
|
|
795
|
-
viewEnd.get(), viewWindow.get(), allowFutureViewEndSV.get(), returnT.get(), returnFrom.get(),
|
|
817
|
+
maxValueSV.get(), minRangeSV.get(), yRangeScale?.get(), nowOverrideSV.get(), windowBufferSV.get(), pausedSV.get(),
|
|
818
|
+
viewEnd.get(), viewWindow.get(), viewWindowSmoothingSV.get(), allowFutureViewEndSV.get(), returnT.get(), returnFrom.get(),
|
|
796
819
|
snapSV.get(), modeSV.get(), candleGapsSV.get(), candleGapBridgeNoTradesSV.get(),
|
|
797
820
|
candleGapBridgeUnavailableSV.get(), candleGapBridgeUnknownSV.get(), isFrameLoopActive?.get(),
|
|
798
821
|
keepAwake?.get(), wakeSignal?.get()];
|
|
799
822
|
}, [pointHistory, candleHistory, data, value, candles, liveCandle, canvasWidth, canvasHeight, timeWindow, smoothing, rangeAnimationSV,
|
|
800
823
|
adaptiveSpeedBoostSV, exaggerateSV, referenceValue, referenceValues, thresholdRangePoints,
|
|
801
|
-
thresholdRangeExtendToStart, thresholdRangeExtendToNow, nonNegativeSV, maxValueSV, yRangeScale,
|
|
802
|
-
nowOverrideSV, windowBufferSV, pausedSV, viewEnd, viewWindow, allowFutureViewEndSV, returnT,
|
|
824
|
+
thresholdRangeExtendToStart, thresholdRangeExtendToNow, nonNegativeSV, maxValueSV, minRangeSV, yRangeScale,
|
|
825
|
+
nowOverrideSV, windowBufferSV, pausedSV, viewEnd, viewWindow, viewWindowSmoothingSV, allowFutureViewEndSV, returnT,
|
|
803
826
|
returnFrom, snapSV, modeSV, candleGapsSV, candleGapBridgeNoTradesSV, candleGapBridgeUnavailableSV,
|
|
804
827
|
candleGapBridgeUnknownSV, isFrameLoopActive, keepAwake, wakeSignal]);
|
|
805
828
|
|
|
@@ -835,6 +858,7 @@ export function useLiveChartEngine(
|
|
|
835
858
|
() => scrollEnabledSV.value,
|
|
836
859
|
/* istanbul ignore next -- Reanimated reaction driven by a prop→derived change; not exercised under the SharedValue mock (see the viewWindow-reset test note), verified in-app */
|
|
837
860
|
(enabled, prev) => {
|
|
861
|
+
if (hasViewport) return;
|
|
838
862
|
if (prev === true && !enabled && viewEnd.value != null) {
|
|
839
863
|
const ms = returnToLiveMsSV.value;
|
|
840
864
|
if (ms > 0) {
|
|
@@ -869,10 +893,20 @@ export function useLiveChartEngine(
|
|
|
869
893
|
canvasWidth.get(),
|
|
870
894
|
canvasHeight.get(),
|
|
871
895
|
timeWindow.get(),
|
|
896
|
+
viewEnd.get(),
|
|
897
|
+
viewWindowSmoothingSV.get(),
|
|
898
|
+
// `nowOverride` sets the right edge and `smoothing` changes when
|
|
899
|
+
// `static` flips. Reading them here makes them inputs of this mapper,
|
|
900
|
+
// so a same-render prop change can't settle on their previous values.
|
|
901
|
+
nowOverrideSV.get(),
|
|
902
|
+
smoothing.get(),
|
|
872
903
|
// Range props can arrive after the data shared value. Re-settle when
|
|
873
904
|
// those bounds change too, rather than retaining the previous scale
|
|
874
905
|
// until another data/layout update (static charts have no frame loop).
|
|
875
906
|
maxValueSV.get(),
|
|
907
|
+
minRangeSV.get(),
|
|
908
|
+
nonNegativeSV.get(),
|
|
909
|
+
yRangeScale?.get(),
|
|
876
910
|
referenceValue.get(),
|
|
877
911
|
...(referenceValues.get() ?? []),
|
|
878
912
|
].join(","),
|