react-native-livechart 4.25.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 +6 -1
- package/dist/core/liveChartEngineTick.d.ts.map +1 -1
- package/dist/core/liveChartSeriesEngineTick.d.ts +4 -1
- 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 +10 -1
- package/dist/core/useLiveChartEngine.d.ts.map +1 -1
- package/dist/core/useLiveChartSeriesEngine.d.ts +5 -1
- 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 +24 -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 +23 -7
- 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/useReferenceLineGrouping.d.ts +19 -0
- package/dist/hooks/useReferenceLineGrouping.d.ts.map +1 -0
- 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/rangeAnimation.d.ts +4 -0
- package/dist/math/rangeAnimation.d.ts.map +1 -0
- package/dist/math/referenceDrag.d.ts +17 -5
- package/dist/math/referenceDrag.d.ts.map +1 -1
- package/dist/math/referenceGroup.d.ts +2 -2
- 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 +240 -30
- 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 +563 -200
- package/src/components/LiveChartSeries.tsx +117 -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 +66 -10
- package/src/core/liveChartSeriesEngineTick.ts +55 -5
- package/src/core/resolveConfig.ts +95 -2
- package/src/core/useLiveChartEngine.ts +53 -11
- package/src/core/useLiveChartSeriesEngine.ts +11 -1
- package/src/draw/grid.ts +2 -2
- package/src/draw/line.ts +23 -1
- package/src/hooks/crosshairShared.ts +85 -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 +446 -300
- 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 +395 -146
- package/src/hooks/useReferenceLine.ts +453 -277
- package/src/hooks/useReferenceLineGrouping.ts +72 -0
- 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 +11 -0
- package/src/math/axisBadgeLayout.ts +37 -0
- package/src/math/markers.ts +28 -3
- package/src/math/range.ts +35 -0
- package/src/math/rangeAnimation.ts +28 -0
- package/src/math/referenceDrag.ts +21 -4
- package/src/math/referenceGroup.ts +2 -2
- package/src/math/referenceTagStack.ts +112 -0
- package/src/math/scrubMarkers.ts +55 -0
- package/src/types.ts +246 -30
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
forwardRef,
|
|
3
|
+
memo,
|
|
4
|
+
useCallback,
|
|
3
5
|
useEffect,
|
|
4
6
|
useImperativeHandle,
|
|
5
7
|
useMemo,
|
|
@@ -67,8 +69,10 @@ import {
|
|
|
67
69
|
resolveTradeStream,
|
|
68
70
|
resolveValueLine,
|
|
69
71
|
resolveVolume,
|
|
72
|
+
resolveViewport,
|
|
70
73
|
resolveZoom,
|
|
71
74
|
resolveXAxis,
|
|
75
|
+
resolveXAxisGridStyle,
|
|
72
76
|
resolveYAxis,
|
|
73
77
|
} from "../core/resolveConfig";
|
|
74
78
|
import type {
|
|
@@ -89,9 +93,13 @@ import {
|
|
|
89
93
|
import {
|
|
90
94
|
dotGlowRadialOutset,
|
|
91
95
|
pulseRadialOutset,
|
|
96
|
+
seriesPlotClip,
|
|
92
97
|
type ChartPadding,
|
|
93
98
|
} from "../draw/line";
|
|
94
|
-
import {
|
|
99
|
+
import {
|
|
100
|
+
resolveChartLayout,
|
|
101
|
+
shouldResampleLayoutValue,
|
|
102
|
+
} from "../hooks/resolveChartLayout";
|
|
95
103
|
import { useBadge } from "../hooks/useBadge";
|
|
96
104
|
import { useCandleGapPaths } from "../hooks/useCandleGapPaths";
|
|
97
105
|
import { useCandlePaths, useCandleWidthLerp } from "../hooks/useCandlePaths";
|
|
@@ -102,6 +110,7 @@ import { useChartPaths } from "../hooks/useChartPaths";
|
|
|
102
110
|
import { useChartReveal } from "../hooks/useChartReveal";
|
|
103
111
|
import { useChartSkiaFont } from "../hooks/useChartSkiaFont";
|
|
104
112
|
import { useCrosshair } from "../hooks/useCrosshair";
|
|
113
|
+
import { resolveScrubMarkerOptions } from "../hooks/useScrubMarkers";
|
|
105
114
|
import { useDegen } from "../hooks/useDegen";
|
|
106
115
|
import { useLiveChartHasData } from "../hooks/useLiveChartHasData";
|
|
107
116
|
import { useLiveDot } from "../hooks/useLiveDot";
|
|
@@ -128,6 +137,10 @@ import {
|
|
|
128
137
|
import { useTradeStream } from "../hooks/useTradeStream";
|
|
129
138
|
import { useXAxis } from "../hooks/useXAxis";
|
|
130
139
|
import { useYAxis } from "../hooks/useYAxis";
|
|
140
|
+
import {
|
|
141
|
+
useYAxisScaleGesture,
|
|
142
|
+
useYAxisScaleValue,
|
|
143
|
+
} from "../hooks/useYAxisScaleGesture";
|
|
131
144
|
import {
|
|
132
145
|
formatTime as defaultFormatTime,
|
|
133
146
|
formatValue as defaultFormatValue,
|
|
@@ -137,11 +150,9 @@ import {
|
|
|
137
150
|
candleGapBucketStartAtTime,
|
|
138
151
|
candleGapDefaultLabel,
|
|
139
152
|
} from "../math/candleGaps";
|
|
140
|
-
import {
|
|
141
|
-
import {
|
|
142
|
-
|
|
143
|
-
type ReferenceGrouping,
|
|
144
|
-
} from "../math/referenceGroup";
|
|
153
|
+
import { useReferenceTagStack, type CustomTagSizes } from "../hooks/useReferenceTagStack";
|
|
154
|
+
import { EMPTY_TAG_STACK, type ReferenceTagStack, type TagRect } from "../math/referenceTagStack";
|
|
155
|
+
import { useReferenceLineGrouping } from "../hooks/useReferenceLineGrouping";
|
|
145
156
|
import {
|
|
146
157
|
collectReferenceValues,
|
|
147
158
|
referenceLineForm,
|
|
@@ -202,13 +213,9 @@ import { SegmentDividerOverlay } from "./SegmentDividerOverlay";
|
|
|
202
213
|
import { SegmentLineGradient } from "./SegmentLineGradient";
|
|
203
214
|
import { TradeStreamOverlay } from "./TradeStreamOverlay";
|
|
204
215
|
import { ValueLineOverlay } from "./ValueLineOverlay";
|
|
205
|
-
import { XAxisOverlay } from "./XAxisOverlay";
|
|
216
|
+
import { XAxisGridLines, XAxisOverlay } from "./XAxisOverlay";
|
|
206
217
|
import { YAxisOverlay } from "./YAxisOverlay";
|
|
207
218
|
|
|
208
|
-
/** Stable empty grouping result (identity-stable so downstream worklets don't
|
|
209
|
-
* re-run) used when reference-line grouping is off. */
|
|
210
|
-
const EMPTY_GROUPING: ReferenceGrouping = { hidden: [], groups: [] };
|
|
211
|
-
|
|
212
219
|
/** Stable empty number array so the live-reference-values worklet stays
|
|
213
220
|
* referentially stable (no engine re-fit) when no line is draggable. */
|
|
214
221
|
const EMPTY_NUMS: number[] = [];
|
|
@@ -283,8 +290,7 @@ function resolveLiveChartFeatureConfig({
|
|
|
283
290
|
scrub,
|
|
284
291
|
scrubAction,
|
|
285
292
|
volume,
|
|
286
|
-
|
|
287
|
-
lineGaps,
|
|
293
|
+
chartGapsCfg,
|
|
288
294
|
gradient,
|
|
289
295
|
areaDots,
|
|
290
296
|
threshold,
|
|
@@ -308,8 +314,6 @@ function resolveLiveChartFeatureConfig({
|
|
|
308
314
|
| "scrub"
|
|
309
315
|
| "scrubAction"
|
|
310
316
|
| "volume"
|
|
311
|
-
| "candleGaps"
|
|
312
|
-
| "lineGaps"
|
|
313
317
|
| "gradient"
|
|
314
318
|
| "areaDots"
|
|
315
319
|
| "threshold"
|
|
@@ -321,26 +325,29 @@ function resolveLiveChartFeatureConfig({
|
|
|
321
325
|
| "degen"
|
|
322
326
|
| "tradeStream"
|
|
323
327
|
| "metrics"
|
|
324
|
-
> & {
|
|
328
|
+
> & {
|
|
329
|
+
isStatic: boolean;
|
|
330
|
+
chartGapsCfg: ResolvedCandleGapsConfig | null;
|
|
331
|
+
}) {
|
|
325
332
|
const isCandle = mode === "candle";
|
|
326
333
|
const badgeCfg = resolveBadge(badge);
|
|
327
|
-
const chartGapsCfg = resolveCandleGaps(isCandle ? candleGaps : lineGaps);
|
|
328
334
|
const thresholdCfg = isCandle ? null : resolveThreshold(threshold);
|
|
329
335
|
const thresholdSeriesSV = thresholdCfg?.series ?? null;
|
|
330
336
|
const dotCfg = resolveDot(dot);
|
|
331
337
|
const volumeCfg = isCandle ? resolveVolume(volume) : null;
|
|
338
|
+
const xAxisCfg = resolveXAxis(xAxis);
|
|
339
|
+
const gridStyleCfg = resolveGridStyle(gridStyle);
|
|
332
340
|
|
|
333
341
|
return {
|
|
334
342
|
isCandle,
|
|
335
343
|
yAxisCfg: resolveYAxis(yAxis),
|
|
336
|
-
xAxisCfg
|
|
344
|
+
xAxisCfg,
|
|
337
345
|
topLabelCfg: resolveAxisLabel(topLabel),
|
|
338
346
|
bottomLabelCfg: resolveAxisLabel(bottomLabel),
|
|
339
347
|
badgeCfg,
|
|
340
348
|
scrubCfg: resolveScrub(scrub),
|
|
341
349
|
scrubActionCfg: resolveScrubAction(scrubAction),
|
|
342
350
|
volumeCfg,
|
|
343
|
-
chartGapsCfg,
|
|
344
351
|
candleGapsCfg: isCandle ? chartGapsCfg : null,
|
|
345
352
|
lineGapsCfg: isCandle ? null : chartGapsCfg,
|
|
346
353
|
volumeBandHeight: volumeCfg?.maxHeight ?? 0,
|
|
@@ -362,29 +369,27 @@ function resolveLiveChartFeatureConfig({
|
|
|
362
369
|
? dotGlowRadialOutset(dotCfg.glow.radius, dotCfg.glow.blur)
|
|
363
370
|
: 0,
|
|
364
371
|
),
|
|
365
|
-
gridStyleCfg
|
|
372
|
+
gridStyleCfg,
|
|
373
|
+
xGridStyleCfg: resolveXAxisGridStyle(
|
|
374
|
+
xAxisCfg?.gridLines ?? null,
|
|
375
|
+
gridStyleCfg,
|
|
376
|
+
),
|
|
366
377
|
degenCfg: isStatic ? null : resolveDegen(degen),
|
|
367
378
|
tradeStreamResolved: resolveTradeStream(tradeStream),
|
|
368
379
|
metricsCfg: resolveMetrics(metrics),
|
|
369
380
|
};
|
|
370
381
|
}
|
|
371
382
|
|
|
372
|
-
function
|
|
383
|
+
function resolveLiveChartReferenceLines({
|
|
373
384
|
chartGapsCfg,
|
|
374
385
|
referenceLines,
|
|
375
386
|
renderReferenceLine,
|
|
376
387
|
renderOffAxisReferenceLine,
|
|
377
|
-
thresholdCfg,
|
|
378
|
-
referenceLineGrouping,
|
|
379
|
-
badgeCfg,
|
|
380
388
|
}: {
|
|
381
389
|
chartGapsCfg: ReturnType<typeof resolveCandleGaps>;
|
|
382
390
|
referenceLines: LiveChartProps["referenceLines"];
|
|
383
391
|
renderReferenceLine: LiveChartProps["renderReferenceLine"];
|
|
384
392
|
renderOffAxisReferenceLine: LiveChartProps["renderOffAxisReferenceLine"];
|
|
385
|
-
thresholdCfg: ReturnType<typeof resolveThreshold>;
|
|
386
|
-
referenceLineGrouping: LiveChartProps["referenceLineGrouping"];
|
|
387
|
-
badgeCfg: ReturnType<typeof resolveBadge>;
|
|
388
393
|
}) {
|
|
389
394
|
const chartGapBands: ReferenceLine[] =
|
|
390
395
|
chartGapsCfg?.gaps.flatMap((gap) => {
|
|
@@ -437,6 +442,26 @@ function resolveLiveChartReferenceConfig({
|
|
|
437
442
|
draggableRefIdx.push(index);
|
|
438
443
|
}
|
|
439
444
|
}
|
|
445
|
+
|
|
446
|
+
return {
|
|
447
|
+
allRefLines,
|
|
448
|
+
refValues: collectReferenceValues(allRefLines),
|
|
449
|
+
refLineCustom,
|
|
450
|
+
refLineOffAxisCustom,
|
|
451
|
+
refLineKeys: referenceLineReactKeys(allRefLines),
|
|
452
|
+
draggableRefIdx,
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
function resolveLiveChartReferenceConfig({
|
|
457
|
+
thresholdCfg,
|
|
458
|
+
referenceLineGrouping,
|
|
459
|
+
badgeCfg,
|
|
460
|
+
}: {
|
|
461
|
+
thresholdCfg: ReturnType<typeof resolveThreshold>;
|
|
462
|
+
referenceLineGrouping: LiveChartProps["referenceLineGrouping"];
|
|
463
|
+
badgeCfg: ReturnType<typeof resolveBadge>;
|
|
464
|
+
}) {
|
|
440
465
|
const thresholdInRange = thresholdCfg?.includeInRange === true;
|
|
441
466
|
const thresholdRangeValueSV =
|
|
442
467
|
thresholdInRange &&
|
|
@@ -450,17 +475,14 @@ function resolveLiveChartReferenceConfig({
|
|
|
450
475
|
: undefined;
|
|
451
476
|
|
|
452
477
|
return {
|
|
453
|
-
chartGapBands,
|
|
454
|
-
allRefLines,
|
|
455
|
-
refValues: collectReferenceValues(allRefLines),
|
|
456
|
-
refLineCustom,
|
|
457
|
-
refLineOffAxisCustom,
|
|
458
|
-
refLineKeys: referenceLineReactKeys(allRefLines),
|
|
459
|
-
draggableRefIdx,
|
|
460
478
|
thresholdInRange,
|
|
461
479
|
thresholdRangeValueSV,
|
|
462
480
|
refGroupingCfg,
|
|
463
|
-
|
|
481
|
+
refStackEnabled: !!referenceLineGrouping && refGroupingCfg?.mode === "stack",
|
|
482
|
+
refStackAvoidValueBadge: refGroupingCfg?.avoidValueBadge !== false,
|
|
483
|
+
refStackRadius: refGroupingCfg?.radius ?? 18,
|
|
484
|
+
refStackReserveBadge: refGroupingCfg?.avoidValueBadge !== false && badgeCfg !== null,
|
|
485
|
+
refGroupingRadius: referenceLineGrouping && refGroupingCfg?.mode !== "stack"
|
|
464
486
|
? (refGroupingCfg?.radius ?? 18)
|
|
465
487
|
: null,
|
|
466
488
|
refGroupBadge: resolveReferenceGroupBadge(refGroupingCfg?.badge),
|
|
@@ -474,6 +496,8 @@ function useLiveReferenceState(
|
|
|
474
496
|
allRefLines: ReferenceLine[],
|
|
475
497
|
draggableRefIdx: number[],
|
|
476
498
|
thresholdRangeValueSV: SharedValue<number> | null,
|
|
499
|
+
stackEnabled: boolean,
|
|
500
|
+
reserveBadge: boolean,
|
|
477
501
|
) {
|
|
478
502
|
const dragValues = useSharedValue<number[]>([]);
|
|
479
503
|
const dragActive = useSharedValue<boolean[]>([]);
|
|
@@ -504,6 +528,23 @@ function useLiveReferenceState(
|
|
|
504
528
|
}, [dragActive, dragValues, propValues]);
|
|
505
529
|
|
|
506
530
|
const refLineCustomTagWidths = useSharedValue<number[]>([]);
|
|
531
|
+
const refTagSizes = useSharedValue<CustomTagSizes>({});
|
|
532
|
+
const refTagStack = useSharedValue<ReferenceTagStack>(EMPTY_TAG_STACK);
|
|
533
|
+
const refLiveBadgeRect = useSharedValue<TagRect | null>(null);
|
|
534
|
+
useEffect(() => {
|
|
535
|
+
const keys = new Set(referenceLineReactKeys(allRefLines));
|
|
536
|
+
scheduleOnUI(() => {
|
|
537
|
+
"worklet";
|
|
538
|
+
const sizes = refTagSizes.get();
|
|
539
|
+
const next: CustomTagSizes = {};
|
|
540
|
+
let removed = false;
|
|
541
|
+
for (const key of Object.keys(sizes)) {
|
|
542
|
+
if (keys.has(key)) next[key] = sizes[key];
|
|
543
|
+
else removed = true;
|
|
544
|
+
}
|
|
545
|
+
if (removed) refTagSizes.set(next);
|
|
546
|
+
});
|
|
547
|
+
}, [allRefLines, refTagSizes]);
|
|
507
548
|
const liveRefValues = useDerivedValue<number[]>(() => {
|
|
508
549
|
if (draggableRefIdx.length === 0 && thresholdRangeValueSV === null) {
|
|
509
550
|
return EMPTY_NUMS;
|
|
@@ -523,7 +564,12 @@ function useLiveReferenceState(
|
|
|
523
564
|
return output;
|
|
524
565
|
});
|
|
525
566
|
|
|
526
|
-
return {
|
|
567
|
+
return {
|
|
568
|
+
dragValues, dragActive, refLineCustomTagWidths, liveRefValues,
|
|
569
|
+
refTagSizes, refTagStack, refLiveBadgeRect,
|
|
570
|
+
activeTagStack: stackEnabled ? refTagStack : undefined,
|
|
571
|
+
stackObstacle: reserveBadge ? refLiveBadgeRect : null,
|
|
572
|
+
};
|
|
527
573
|
}
|
|
528
574
|
|
|
529
575
|
function resolveLiveChartPresentationConfig({
|
|
@@ -537,6 +583,7 @@ function resolveLiveChartPresentationConfig({
|
|
|
537
583
|
refGroupBadge,
|
|
538
584
|
pulseCfg,
|
|
539
585
|
timeScroll,
|
|
586
|
+
viewport,
|
|
540
587
|
isStatic,
|
|
541
588
|
returnToLive,
|
|
542
589
|
zoom,
|
|
@@ -552,6 +599,7 @@ function resolveLiveChartPresentationConfig({
|
|
|
552
599
|
refGroupBadge: ReturnType<typeof resolveReferenceGroupBadge>;
|
|
553
600
|
pulseCfg: ReturnType<typeof resolvePulse>;
|
|
554
601
|
timeScroll: LiveChartProps["timeScroll"];
|
|
602
|
+
viewport: LiveChartProps["viewport"];
|
|
555
603
|
isStatic: boolean;
|
|
556
604
|
returnToLive: LiveChartProps["returnToLive"];
|
|
557
605
|
zoom: LiveChartProps["zoom"];
|
|
@@ -612,6 +660,7 @@ function resolveLiveChartPresentationConfig({
|
|
|
612
660
|
}
|
|
613
661
|
: null,
|
|
614
662
|
timeScrollEnabled,
|
|
663
|
+
viewportCfg: resolveViewport(viewport),
|
|
615
664
|
returnToLiveMs: resolveReturnToLiveMs(returnToLive),
|
|
616
665
|
timeScrollOverscroll: timeScrollEnabled ? resolveOverscroll(timeScroll) : 0,
|
|
617
666
|
timeScrollFling: resolveFling(timeScroll),
|
|
@@ -933,7 +982,8 @@ function resolveLiveChartInteractionConfig({
|
|
|
933
982
|
}
|
|
934
983
|
|
|
935
984
|
function composeLiveChartRootGesture({
|
|
936
|
-
|
|
985
|
+
crosshairGesture,
|
|
986
|
+
crosshairTapGesture,
|
|
937
987
|
markerTapGesture,
|
|
938
988
|
refLineTapGesture,
|
|
939
989
|
refDragGesture,
|
|
@@ -947,7 +997,8 @@ function composeLiveChartRootGesture({
|
|
|
947
997
|
scrollGestureMode,
|
|
948
998
|
zoomEnabled,
|
|
949
999
|
}: {
|
|
950
|
-
|
|
1000
|
+
crosshairGesture: ReturnType<typeof useCrosshair>["gesture"];
|
|
1001
|
+
crosshairTapGesture: ReturnType<typeof useCrosshair>["tapGesture"];
|
|
951
1002
|
markerTapGesture: ReturnType<typeof useMarkers>["tapGesture"];
|
|
952
1003
|
refLineTapGesture: ReturnType<typeof useReferenceLinePress>["tapGesture"];
|
|
953
1004
|
refDragGesture: ReturnType<typeof useReferenceDrag>["gesture"];
|
|
@@ -962,9 +1013,9 @@ function composeLiveChartRootGesture({
|
|
|
962
1013
|
zoomEnabled: boolean;
|
|
963
1014
|
}) {
|
|
964
1015
|
const baseGesture =
|
|
965
|
-
scrubActionActive &&
|
|
966
|
-
? Gesture.Exclusive(
|
|
967
|
-
:
|
|
1016
|
+
scrubActionActive && crosshairTapGesture
|
|
1017
|
+
? Gesture.Exclusive(crosshairTapGesture, crosshairGesture)
|
|
1018
|
+
: crosshairGesture;
|
|
968
1019
|
const overlayTaps = [
|
|
969
1020
|
markersActive ? markerTapGesture : null,
|
|
970
1021
|
refPressActive ? refLineTapGesture : null,
|
|
@@ -997,11 +1048,13 @@ function useAxisAutoHide({
|
|
|
997
1048
|
config,
|
|
998
1049
|
scrollActive,
|
|
999
1050
|
scrubActive,
|
|
1051
|
+
scaleActive,
|
|
1000
1052
|
engine,
|
|
1001
1053
|
}: {
|
|
1002
1054
|
config: LiveChartProps["axisAutoHide"];
|
|
1003
1055
|
scrollActive: SharedValue<boolean>;
|
|
1004
1056
|
scrubActive: SharedValue<boolean>;
|
|
1057
|
+
scaleActive: SharedValue<boolean>;
|
|
1005
1058
|
engine: ReturnType<typeof useLiveChartEngine>;
|
|
1006
1059
|
}) {
|
|
1007
1060
|
const resolved = config === true ? {} : config === false ? null : config;
|
|
@@ -1025,7 +1078,7 @@ function useAxisAutoHide({
|
|
|
1025
1078
|
}, [enabled, idleOpacity, opacity]);
|
|
1026
1079
|
useAnimatedReaction(
|
|
1027
1080
|
() => ({
|
|
1028
|
-
gesture: scrollActive.value || scrubActive.value,
|
|
1081
|
+
gesture: scrollActive.value || scrubActive.value || scaleActive.value,
|
|
1029
1082
|
viewEnd: engine.viewEnd.value,
|
|
1030
1083
|
viewWindow: engine.viewWindow.value,
|
|
1031
1084
|
}),
|
|
@@ -1224,59 +1277,6 @@ function useLiveIndicatorOpacities({
|
|
|
1224
1277
|
};
|
|
1225
1278
|
}
|
|
1226
1279
|
|
|
1227
|
-
function useReferenceLineGrouping({
|
|
1228
|
-
radius,
|
|
1229
|
-
engine,
|
|
1230
|
-
padding,
|
|
1231
|
-
lines,
|
|
1232
|
-
custom,
|
|
1233
|
-
offAxisCustom,
|
|
1234
|
-
dragValues,
|
|
1235
|
-
}: {
|
|
1236
|
-
radius: number | null;
|
|
1237
|
-
engine: ReturnType<typeof useLiveChartEngine>;
|
|
1238
|
-
padding: ChartPadding;
|
|
1239
|
-
lines: ReferenceLine[];
|
|
1240
|
-
custom: boolean[];
|
|
1241
|
-
offAxisCustom: boolean[];
|
|
1242
|
-
dragValues: SharedValue<number[]>;
|
|
1243
|
-
}) {
|
|
1244
|
-
const result = useDerivedValue<ReferenceGrouping>(() => {
|
|
1245
|
-
if (radius == null) return EMPTY_GROUPING;
|
|
1246
|
-
const canvasHeight = engine.canvasHeight.get();
|
|
1247
|
-
const displayMin = engine.displayMin.get();
|
|
1248
|
-
const displayMax = engine.displayMax.get();
|
|
1249
|
-
const top = padding.top;
|
|
1250
|
-
const bottom = canvasHeight - padding.bottom;
|
|
1251
|
-
const yPositions: number[] = [];
|
|
1252
|
-
for (let index = 0; index < lines.length; index++) {
|
|
1253
|
-
const line = lines[index];
|
|
1254
|
-
if (
|
|
1255
|
-
referenceLineForm(line) !== "line" ||
|
|
1256
|
-
line.value === undefined ||
|
|
1257
|
-
custom[index] ||
|
|
1258
|
-
offAxisCustom[index]
|
|
1259
|
-
) {
|
|
1260
|
-
yPositions.push(-1);
|
|
1261
|
-
continue;
|
|
1262
|
-
}
|
|
1263
|
-
const value = dragValues.get()[index] ?? line.value;
|
|
1264
|
-
const y = computeScrubDotY(
|
|
1265
|
-
value,
|
|
1266
|
-
displayMin,
|
|
1267
|
-
displayMax,
|
|
1268
|
-
canvasHeight,
|
|
1269
|
-
top,
|
|
1270
|
-
padding.bottom,
|
|
1271
|
-
);
|
|
1272
|
-
yPositions.push(y < 0 ? -1 : Math.min(bottom, Math.max(top, y)));
|
|
1273
|
-
}
|
|
1274
|
-
return groupReferenceLines(yPositions, radius);
|
|
1275
|
-
});
|
|
1276
|
-
const hidden = useDerivedValue<boolean[]>(() => result.get().hidden);
|
|
1277
|
-
return { refGroupResult: result, groupHidden: hidden };
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
1280
|
function useLiveChartLayoutResources({
|
|
1281
1281
|
value,
|
|
1282
1282
|
fontProp,
|
|
@@ -1293,6 +1293,7 @@ function useLiveChartLayoutResources({
|
|
|
1293
1293
|
badgeCfg,
|
|
1294
1294
|
metricsCfg,
|
|
1295
1295
|
badgeUsesRightGutter,
|
|
1296
|
+
referenceAxisBadge,
|
|
1296
1297
|
xAxisCfg,
|
|
1297
1298
|
formatValue,
|
|
1298
1299
|
pulseConfig,
|
|
@@ -1314,6 +1315,7 @@ function useLiveChartLayoutResources({
|
|
|
1314
1315
|
badgeCfg: ReturnType<typeof resolveBadge>;
|
|
1315
1316
|
metricsCfg: ReturnType<typeof resolveMetrics>;
|
|
1316
1317
|
badgeUsesRightGutter: boolean;
|
|
1318
|
+
referenceAxisBadge: boolean;
|
|
1317
1319
|
xAxisCfg: ReturnType<typeof resolveXAxis>;
|
|
1318
1320
|
formatValue: (value: number) => string;
|
|
1319
1321
|
pulseConfig: { maxRadius: number; strokeWidth: number } | null;
|
|
@@ -1344,19 +1346,19 @@ function useLiveChartLayoutResources({
|
|
|
1344
1346
|
const refGroupBadgeFont = refGroupBadgeHasFont
|
|
1345
1347
|
? refGroupBadgeFontOverride
|
|
1346
1348
|
: skiaFont;
|
|
1347
|
-
const valueLayoutSample =
|
|
1349
|
+
const valueLayoutSample = useLayoutValueSample(value);
|
|
1348
1350
|
const [scrolledBack, setScrolledBack] = useState(false);
|
|
1349
1351
|
const effectiveYAxisFloat =
|
|
1350
1352
|
yAxisFloat && (!timeScrollEnabled || scrolledBack);
|
|
1351
|
-
const layout = resolveChartLayout({
|
|
1353
|
+
const layout = useMemo(() => resolveChartLayout({
|
|
1352
1354
|
palette,
|
|
1353
1355
|
lineWidthOverride: lineProp?.width,
|
|
1354
1356
|
insetsOverride: insets,
|
|
1355
1357
|
yAxis: yAxisCfg !== null,
|
|
1356
1358
|
yAxisFloat: effectiveYAxisFloat,
|
|
1357
|
-
badge: badgeCfg !== null,
|
|
1359
|
+
badge: badgeCfg !== null || referenceAxisBadge,
|
|
1358
1360
|
badgeMetrics: metricsCfg.badge,
|
|
1359
|
-
badgeUsesRightGutter,
|
|
1361
|
+
badgeUsesRightGutter: badgeUsesRightGutter || referenceAxisBadge,
|
|
1360
1362
|
badgeShowTail: badgeCfg?.tail ?? true,
|
|
1361
1363
|
xAxis: xAxisCfg !== null,
|
|
1362
1364
|
font: skiaFont,
|
|
@@ -1365,7 +1367,24 @@ function useLiveChartLayoutResources({
|
|
|
1365
1367
|
pulse: pulseConfig,
|
|
1366
1368
|
dotGlow: dotCfg.glow,
|
|
1367
1369
|
volumeBandHeight,
|
|
1368
|
-
})
|
|
1370
|
+
}), [
|
|
1371
|
+
badgeCfg,
|
|
1372
|
+
badgeUsesRightGutter,
|
|
1373
|
+
referenceAxisBadge,
|
|
1374
|
+
dotCfg.glow,
|
|
1375
|
+
effectiveYAxisFloat,
|
|
1376
|
+
formatValue,
|
|
1377
|
+
insets,
|
|
1378
|
+
lineProp?.width,
|
|
1379
|
+
metricsCfg.badge,
|
|
1380
|
+
palette,
|
|
1381
|
+
pulseConfig,
|
|
1382
|
+
skiaFont,
|
|
1383
|
+
valueLayoutSample,
|
|
1384
|
+
volumeBandHeight,
|
|
1385
|
+
xAxisCfg,
|
|
1386
|
+
yAxisCfg,
|
|
1387
|
+
]);
|
|
1369
1388
|
return {
|
|
1370
1389
|
skiaFont,
|
|
1371
1390
|
valueFont,
|
|
@@ -1377,17 +1396,17 @@ function useLiveChartLayoutResources({
|
|
|
1377
1396
|
};
|
|
1378
1397
|
}
|
|
1379
1398
|
|
|
1380
|
-
function
|
|
1399
|
+
function useLayoutValueSample(value: SharedValue<number>) {
|
|
1381
1400
|
const [sample, setSample] = useState<number | undefined>(undefined);
|
|
1382
|
-
const
|
|
1401
|
+
const sampled = useSharedValue(0);
|
|
1383
1402
|
useAnimatedReaction(
|
|
1384
|
-
() =>
|
|
1403
|
+
() => value.get(),
|
|
1385
1404
|
(current) => {
|
|
1386
|
-
if (current
|
|
1387
|
-
|
|
1405
|
+
if (!shouldResampleLayoutValue(current, sampled.get())) return;
|
|
1406
|
+
sampled.set(current);
|
|
1388
1407
|
scheduleOnRN(setSample, current);
|
|
1389
1408
|
},
|
|
1390
|
-
[
|
|
1409
|
+
[sampled, value],
|
|
1391
1410
|
);
|
|
1392
1411
|
return sample;
|
|
1393
1412
|
}
|
|
@@ -1466,13 +1485,16 @@ function useLiveChartController({
|
|
|
1466
1485
|
autoSleep = false,
|
|
1467
1486
|
snapKey,
|
|
1468
1487
|
smoothing = 0.08,
|
|
1488
|
+
rangeAnimation,
|
|
1469
1489
|
exaggerate = false,
|
|
1470
1490
|
nonNegative = false,
|
|
1471
1491
|
maxValue,
|
|
1492
|
+
minRange,
|
|
1472
1493
|
yRangeScale,
|
|
1473
1494
|
windowBuffer = 0,
|
|
1474
1495
|
nowOverride,
|
|
1475
1496
|
timeScroll = false,
|
|
1497
|
+
viewport,
|
|
1476
1498
|
returnToLive,
|
|
1477
1499
|
zoom = false,
|
|
1478
1500
|
accessibilityLabel,
|
|
@@ -1520,6 +1542,7 @@ function useLiveChartController({
|
|
|
1520
1542
|
|
|
1521
1543
|
// ── Callbacks ───────────────────────────────────────────────────────────
|
|
1522
1544
|
onScrub,
|
|
1545
|
+
onScrubCandleChange,
|
|
1523
1546
|
onScrubAction,
|
|
1524
1547
|
onReferenceLinePress,
|
|
1525
1548
|
onGestureStart,
|
|
@@ -1535,6 +1558,10 @@ function useLiveChartController({
|
|
|
1535
1558
|
// Stand-in threshold value so `useThreshold` can be called unconditionally
|
|
1536
1559
|
// (hooks can't be); the geometry is ignored when no threshold is configured.
|
|
1537
1560
|
const emptyThresholdValue = useSharedValue(0);
|
|
1561
|
+
// Memoized on the gaps prop so the gap bands, the reference lines built from
|
|
1562
|
+
// them and the crosshair's gap list keep their identity across re-renders.
|
|
1563
|
+
const gapsProp = mode === "candle" ? candleGaps : lineGaps;
|
|
1564
|
+
const chartGapsCfg = useMemo(() => resolveCandleGaps(gapsProp), [gapsProp]);
|
|
1538
1565
|
const {
|
|
1539
1566
|
isCandle,
|
|
1540
1567
|
yAxisCfg,
|
|
@@ -1545,7 +1572,6 @@ function useLiveChartController({
|
|
|
1545
1572
|
scrubCfg,
|
|
1546
1573
|
scrubActionCfg,
|
|
1547
1574
|
volumeCfg,
|
|
1548
|
-
chartGapsCfg,
|
|
1549
1575
|
candleGapsCfg,
|
|
1550
1576
|
lineGapsCfg,
|
|
1551
1577
|
volumeBandHeight,
|
|
@@ -1561,10 +1587,11 @@ function useLiveChartController({
|
|
|
1561
1587
|
selectionDotCfg,
|
|
1562
1588
|
dotOuterRadius,
|
|
1563
1589
|
gridStyleCfg,
|
|
1590
|
+
xGridStyleCfg,
|
|
1564
1591
|
degenCfg,
|
|
1565
1592
|
tradeStreamResolved,
|
|
1566
1593
|
metricsCfg,
|
|
1567
|
-
} = resolveLiveChartFeatureConfig({
|
|
1594
|
+
} = useMemo(() => resolveLiveChartFeatureConfig({
|
|
1568
1595
|
mode,
|
|
1569
1596
|
yAxis,
|
|
1570
1597
|
xAxis,
|
|
@@ -1574,8 +1601,7 @@ function useLiveChartController({
|
|
|
1574
1601
|
scrub,
|
|
1575
1602
|
scrubAction,
|
|
1576
1603
|
volume,
|
|
1577
|
-
|
|
1578
|
-
lineGaps,
|
|
1604
|
+
chartGapsCfg,
|
|
1579
1605
|
gradient,
|
|
1580
1606
|
areaDots,
|
|
1581
1607
|
threshold,
|
|
@@ -1588,35 +1614,80 @@ function useLiveChartController({
|
|
|
1588
1614
|
degen,
|
|
1589
1615
|
tradeStream,
|
|
1590
1616
|
metrics,
|
|
1591
|
-
})
|
|
1617
|
+
}), [
|
|
1618
|
+
areaDots,
|
|
1619
|
+
badge,
|
|
1620
|
+
bottomLabel,
|
|
1621
|
+
chartGapsCfg,
|
|
1622
|
+
degen,
|
|
1623
|
+
dot,
|
|
1624
|
+
gradient,
|
|
1625
|
+
gridStyle,
|
|
1626
|
+
isStatic,
|
|
1627
|
+
metrics,
|
|
1628
|
+
mode,
|
|
1629
|
+
pulse,
|
|
1630
|
+
scrub,
|
|
1631
|
+
scrubAction,
|
|
1632
|
+
selectionDot,
|
|
1633
|
+
threshold,
|
|
1634
|
+
topLabel,
|
|
1635
|
+
tradeStream,
|
|
1636
|
+
valueLine,
|
|
1637
|
+
volume,
|
|
1638
|
+
xAxis,
|
|
1639
|
+
yAxis,
|
|
1640
|
+
]);
|
|
1592
1641
|
|
|
1642
|
+
// Probing the custom renderers calls them once per line, so only re-resolve
|
|
1643
|
+
// when the lines or renderers change, not on every parent render.
|
|
1593
1644
|
const {
|
|
1594
|
-
chartGapBands,
|
|
1595
1645
|
allRefLines,
|
|
1596
1646
|
refValues,
|
|
1597
1647
|
refLineCustom,
|
|
1598
1648
|
refLineOffAxisCustom,
|
|
1599
1649
|
refLineKeys,
|
|
1600
1650
|
draggableRefIdx,
|
|
1651
|
+
} = useMemo(
|
|
1652
|
+
() =>
|
|
1653
|
+
resolveLiveChartReferenceLines({
|
|
1654
|
+
chartGapsCfg,
|
|
1655
|
+
referenceLines,
|
|
1656
|
+
renderReferenceLine,
|
|
1657
|
+
renderOffAxisReferenceLine,
|
|
1658
|
+
}),
|
|
1659
|
+
[
|
|
1660
|
+
chartGapsCfg,
|
|
1661
|
+
referenceLines,
|
|
1662
|
+
renderReferenceLine,
|
|
1663
|
+
renderOffAxisReferenceLine,
|
|
1664
|
+
],
|
|
1665
|
+
);
|
|
1666
|
+
|
|
1667
|
+
const {
|
|
1601
1668
|
thresholdInRange,
|
|
1602
1669
|
thresholdRangeValueSV,
|
|
1603
1670
|
refGroupingCfg,
|
|
1671
|
+
refStackEnabled,
|
|
1672
|
+
refStackAvoidValueBadge,
|
|
1673
|
+
refStackRadius,
|
|
1674
|
+
refStackReserveBadge,
|
|
1604
1675
|
refGroupingRadius,
|
|
1605
1676
|
refGroupBadge,
|
|
1606
1677
|
refGroupFormat,
|
|
1607
1678
|
badgeUsesRightGutter,
|
|
1608
|
-
} = resolveLiveChartReferenceConfig({
|
|
1609
|
-
chartGapsCfg,
|
|
1610
|
-
referenceLines,
|
|
1611
|
-
renderReferenceLine,
|
|
1612
|
-
renderOffAxisReferenceLine,
|
|
1679
|
+
} = useMemo(() => resolveLiveChartReferenceConfig({
|
|
1613
1680
|
thresholdCfg,
|
|
1614
1681
|
referenceLineGrouping,
|
|
1615
1682
|
badgeCfg,
|
|
1616
|
-
})
|
|
1683
|
+
}), [
|
|
1684
|
+
badgeCfg,
|
|
1685
|
+
referenceLineGrouping,
|
|
1686
|
+
thresholdCfg,
|
|
1687
|
+
]);
|
|
1617
1688
|
|
|
1618
|
-
const { dragValues, dragActive, refLineCustomTagWidths, liveRefValues } =
|
|
1619
|
-
useLiveReferenceState(allRefLines, draggableRefIdx, thresholdRangeValueSV);
|
|
1689
|
+
const { dragValues, dragActive, refLineCustomTagWidths, liveRefValues, refTagSizes, refTagStack, refLiveBadgeRect, activeTagStack, stackObstacle } =
|
|
1690
|
+
useLiveReferenceState(allRefLines, draggableRefIdx, thresholdRangeValueSV, refStackEnabled, refStackReserveBadge);
|
|
1620
1691
|
|
|
1621
1692
|
const {
|
|
1622
1693
|
palette,
|
|
@@ -1629,13 +1700,14 @@ function useLiveChartController({
|
|
|
1629
1700
|
refGroupBadgeFontConfig,
|
|
1630
1701
|
pulseConfig,
|
|
1631
1702
|
timeScrollEnabled,
|
|
1703
|
+
viewportCfg,
|
|
1632
1704
|
returnToLiveMs,
|
|
1633
1705
|
timeScrollOverscroll,
|
|
1634
1706
|
timeScrollFling,
|
|
1635
1707
|
zoomCfg,
|
|
1636
1708
|
zoomEnabled,
|
|
1637
1709
|
yAxisFloat,
|
|
1638
|
-
} = resolveLiveChartPresentationConfig({
|
|
1710
|
+
} = useMemo(() => resolveLiveChartPresentationConfig({
|
|
1639
1711
|
accentColor,
|
|
1640
1712
|
theme,
|
|
1641
1713
|
paletteOverride,
|
|
@@ -1646,11 +1718,28 @@ function useLiveChartController({
|
|
|
1646
1718
|
refGroupBadge,
|
|
1647
1719
|
pulseCfg,
|
|
1648
1720
|
timeScroll,
|
|
1721
|
+
viewport,
|
|
1649
1722
|
isStatic,
|
|
1650
1723
|
returnToLive,
|
|
1651
1724
|
zoom,
|
|
1652
1725
|
yAxisCfg,
|
|
1653
|
-
})
|
|
1726
|
+
}), [
|
|
1727
|
+
accentColor,
|
|
1728
|
+
badgeCfg,
|
|
1729
|
+
fontProp,
|
|
1730
|
+
isStatic,
|
|
1731
|
+
leftEdgeFade,
|
|
1732
|
+
paletteOverride,
|
|
1733
|
+
pulseCfg,
|
|
1734
|
+
refGroupBadge,
|
|
1735
|
+
returnToLive,
|
|
1736
|
+
segments,
|
|
1737
|
+
theme,
|
|
1738
|
+
timeScroll,
|
|
1739
|
+
viewport,
|
|
1740
|
+
yAxisCfg,
|
|
1741
|
+
zoom,
|
|
1742
|
+
]);
|
|
1654
1743
|
|
|
1655
1744
|
const {
|
|
1656
1745
|
skiaFont,
|
|
@@ -1677,6 +1766,7 @@ function useLiveChartController({
|
|
|
1677
1766
|
badgeCfg,
|
|
1678
1767
|
metricsCfg,
|
|
1679
1768
|
badgeUsesRightGutter,
|
|
1769
|
+
referenceAxisBadge: allRefLines.some(line => typeof line.valueBadge === "object" && line.valueBadge.position === "axis"),
|
|
1680
1770
|
xAxisCfg,
|
|
1681
1771
|
formatValue,
|
|
1682
1772
|
pulseConfig,
|
|
@@ -1684,6 +1774,15 @@ function useLiveChartController({
|
|
|
1684
1774
|
volumeBandHeight,
|
|
1685
1775
|
});
|
|
1686
1776
|
|
|
1777
|
+
const referenceValueAxis = useMemo(() => ({
|
|
1778
|
+
float: effectiveYAxisFloat,
|
|
1779
|
+
showTail: badgeCfg?.tail ?? true,
|
|
1780
|
+
fontSize: badgeFont.getSize(),
|
|
1781
|
+
metrics: metricsCfg.badge,
|
|
1782
|
+
offsetX: badgeCfg?.offsetX ?? 0,
|
|
1783
|
+
alignTextWithYAxis: badgeCfg?.textAlign === "yAxisColumn" && yAxisCfg?.side !== "left",
|
|
1784
|
+
}), [effectiveYAxisFloat, badgeCfg?.tail, badgeCfg?.offsetX, badgeCfg?.textAlign, badgeFont, metricsCfg.badge, yAxisCfg?.side]);
|
|
1785
|
+
|
|
1687
1786
|
// ── Reveal state ────────────────────────────────────────────
|
|
1688
1787
|
// ≥1 line point or ≥1 committed candle; morphT=1 only when !loading && hasData.
|
|
1689
1788
|
const { hasData } = useLiveChartHasData({
|
|
@@ -1746,6 +1845,7 @@ function useLiveChartController({
|
|
|
1746
1845
|
continuousEffects || loadingActive || !hasData.get() || reveal.morphT.get() < 1,
|
|
1747
1846
|
);
|
|
1748
1847
|
const idleWakeSignal = useDerivedValue<unknown>(() => [theme, accentColor, paletteOverride, metrics, reveal.morphT.get()]);
|
|
1848
|
+
const effectiveYRangeScale = useYAxisScaleValue(yRangeScale);
|
|
1749
1849
|
const engine = useLiveChartEngine({
|
|
1750
1850
|
...engineModeInputs,
|
|
1751
1851
|
value,
|
|
@@ -1759,16 +1859,19 @@ function useLiveChartController({
|
|
|
1759
1859
|
wakeSignal: idleWakeSignal,
|
|
1760
1860
|
snapKey,
|
|
1761
1861
|
scrollEnabled: timeScrollEnabled,
|
|
1862
|
+
viewport: viewportCfg,
|
|
1762
1863
|
allowFutureViewEnd: timeScrollOverscroll > 0,
|
|
1763
1864
|
returnToLiveMs,
|
|
1764
1865
|
smoothing,
|
|
1866
|
+
rangeAnimation,
|
|
1765
1867
|
adaptiveSpeedBoost: metricsCfg.motion.adaptiveSpeedBoost,
|
|
1766
1868
|
exaggerate,
|
|
1767
1869
|
referenceValues: refValues,
|
|
1768
1870
|
liveReferenceValues: liveRefValues,
|
|
1769
1871
|
nonNegative,
|
|
1770
1872
|
maxValue,
|
|
1771
|
-
|
|
1873
|
+
minRange,
|
|
1874
|
+
yRangeScale: effectiveYRangeScale,
|
|
1772
1875
|
windowBuffer,
|
|
1773
1876
|
nowOverride,
|
|
1774
1877
|
mode,
|
|
@@ -1801,6 +1904,27 @@ function useLiveChartController({
|
|
|
1801
1904
|
// ── Per-frame derived values ───────────────────────────────────────────
|
|
1802
1905
|
const { layoutWidth, layoutHeight, onLayout } = useCanvasLayout(engine);
|
|
1803
1906
|
|
|
1907
|
+
// Draggable reference lines: a per-line vertical pan that grabs a line near its
|
|
1908
|
+
// value and drags it along the Y-axis (with snap / bounds / callbacks). Built
|
|
1909
|
+
// unconditionally for stable hook order (and before `useCrosshair` so the scrub
|
|
1910
|
+
// can defer to a line under the finger); the gesture self-disables when no line
|
|
1911
|
+
// opts in, and it's only composed into the root when `refDragEnabled`. Its
|
|
1912
|
+
// `drawnValues` (the dragged line kept under the finger) is what the lines'
|
|
1913
|
+
// grouping, press hit-test and overlays read; the range fit reads `dragValues`.
|
|
1914
|
+
const {
|
|
1915
|
+
gesture: refDragGesture,
|
|
1916
|
+
hitTest: refDragHitTest,
|
|
1917
|
+
drawnValues: drawnRefValues,
|
|
1918
|
+
} = useReferenceDrag(
|
|
1919
|
+
engine,
|
|
1920
|
+
effectivePadding,
|
|
1921
|
+
allRefLines,
|
|
1922
|
+
dragValues,
|
|
1923
|
+
dragActive,
|
|
1924
|
+
!isStatic,
|
|
1925
|
+
activeTagStack,
|
|
1926
|
+
);
|
|
1927
|
+
|
|
1804
1928
|
const { refGroupResult, groupHidden } = useReferenceLineGrouping({
|
|
1805
1929
|
radius: refGroupingRadius,
|
|
1806
1930
|
engine,
|
|
@@ -1808,7 +1932,7 @@ function useLiveChartController({
|
|
|
1808
1932
|
lines: allRefLines,
|
|
1809
1933
|
custom: refLineCustom,
|
|
1810
1934
|
offAxisCustom: refLineOffAxisCustom,
|
|
1811
|
-
dragValues,
|
|
1935
|
+
dragValues: drawnRefValues,
|
|
1812
1936
|
});
|
|
1813
1937
|
|
|
1814
1938
|
// Threshold split geometry. Two forms, picked at render by `Array.isArray` (no
|
|
@@ -1871,6 +1995,15 @@ function useLiveChartController({
|
|
|
1871
1995
|
lineProp?.simplify,
|
|
1872
1996
|
lineGapsCfg?.gaps,
|
|
1873
1997
|
);
|
|
1998
|
+
// `effectivePadding.bottom` includes the volume band, so this stops at the
|
|
1999
|
+
// price plot's bottom edge.
|
|
2000
|
+
const seriesClip = useDerivedValue(() =>
|
|
2001
|
+
seriesPlotClip(
|
|
2002
|
+
effectivePadding,
|
|
2003
|
+
engine.canvasWidth.get(),
|
|
2004
|
+
engine.canvasHeight.get(),
|
|
2005
|
+
),
|
|
2006
|
+
);
|
|
1874
2007
|
|
|
1875
2008
|
// Area-dots fill shader color as a vec4 (channels 0..1), with the config
|
|
1876
2009
|
// `opacity` folded into the alpha. Defaults to a faint tint of the line/accent
|
|
@@ -1920,7 +2053,7 @@ function useLiveChartController({
|
|
|
1920
2053
|
refDragEnabled,
|
|
1921
2054
|
scrollGestureMode,
|
|
1922
2055
|
scrubHoldMs,
|
|
1923
|
-
} = resolveLiveChartInteractionConfig({
|
|
2056
|
+
} = useMemo(() => resolveLiveChartInteractionConfig({
|
|
1924
2057
|
isCandle,
|
|
1925
2058
|
mode,
|
|
1926
2059
|
candlesEngine,
|
|
@@ -1936,7 +2069,23 @@ function useLiveChartController({
|
|
|
1936
2069
|
timeScroll,
|
|
1937
2070
|
timeScrollEnabled,
|
|
1938
2071
|
scrubCfg,
|
|
1939
|
-
})
|
|
2072
|
+
}), [
|
|
2073
|
+
allRefLines,
|
|
2074
|
+
candleGapsCfg,
|
|
2075
|
+
candleWidth,
|
|
2076
|
+
candlesEngine,
|
|
2077
|
+
isCandle,
|
|
2078
|
+
isStatic,
|
|
2079
|
+
lineGapsCfg,
|
|
2080
|
+
liveEngine,
|
|
2081
|
+
markerCluster,
|
|
2082
|
+
markers,
|
|
2083
|
+
mode,
|
|
2084
|
+
onReferenceLinePress,
|
|
2085
|
+
scrubCfg,
|
|
2086
|
+
timeScroll,
|
|
2087
|
+
timeScrollEnabled,
|
|
2088
|
+
]);
|
|
1940
2089
|
// `projected` is used internally by the hit-test gesture; the overlay
|
|
1941
2090
|
// self-projects, so we only need the gesture + hit-test here. Built BEFORE
|
|
1942
2091
|
// `useCrosshair` so the scrub-action tap can defer to a marker under the finger.
|
|
@@ -1968,32 +2117,24 @@ function useLiveChartController({
|
|
|
1968
2117
|
!isStatic && refPressActive,
|
|
1969
2118
|
markerHitRadius,
|
|
1970
2119
|
onReferenceLinePress,
|
|
1971
|
-
|
|
2120
|
+
drawnRefValues,
|
|
2121
|
+
referenceValueAxis,
|
|
2122
|
+
fontProp,
|
|
2123
|
+
groupHidden,
|
|
2124
|
+
refLineCustom,
|
|
2125
|
+
refLineOffAxisCustom,
|
|
2126
|
+
activeTagStack,
|
|
1972
2127
|
);
|
|
1973
2128
|
|
|
1974
|
-
// Draggable reference lines: a per-line vertical pan that grabs a line near its
|
|
1975
|
-
// value and drags it along the Y-axis (with snap / bounds / callbacks). Built
|
|
1976
|
-
// unconditionally for stable hook order (and before `useCrosshair` so the scrub
|
|
1977
|
-
// can defer to a line under the finger); the gesture self-disables when no line
|
|
1978
|
-
// opts in, and it's only composed into the root when `refDragEnabled`.
|
|
1979
|
-
const { gesture: refDragGesture, hitTest: refDragHitTest } = useReferenceDrag(
|
|
1980
|
-
engine,
|
|
1981
|
-
effectivePadding,
|
|
1982
|
-
allRefLines,
|
|
1983
|
-
dragValues,
|
|
1984
|
-
dragActive,
|
|
1985
|
-
!isStatic,
|
|
1986
|
-
);
|
|
1987
|
-
|
|
1988
2129
|
// Combined "defer" hit-test: the scrub-action place-tap and the live scrub both
|
|
1989
2130
|
// yield to a marker, a pressable badge, or a draggable line under the finger — so
|
|
1990
2131
|
// a press there is routed to that overlay / drag instead of dropping a reticle or
|
|
1991
2132
|
// crosshair. (Each hit-test returns false when its feature is off.)
|
|
1992
2133
|
/* istanbul ignore next -- worklet runs on the UI thread, not in Jest */
|
|
1993
|
-
const deferTapHit = (x: number, y: number): boolean => {
|
|
2134
|
+
const deferTapHit = useCallback((x: number, y: number): boolean => {
|
|
1994
2135
|
"worklet";
|
|
1995
2136
|
return markerHitTest(x, y) || refLineHitTest(x, y) || refDragHitTest(x, y);
|
|
1996
|
-
};
|
|
2137
|
+
}, [markerHitTest, refLineHitTest, refDragHitTest]);
|
|
1997
2138
|
|
|
1998
2139
|
// Cross-gesture arbitration for the one-finger touch. `Gesture.Race` below is
|
|
1999
2140
|
// NOT arbitration — RNGH's Race adds no relation between its children, so both
|
|
@@ -2002,6 +2143,7 @@ function useLiveChartController({
|
|
|
2002
2143
|
// long-press guard) makes "the scroll already won" a hard fact; `scrubActive`
|
|
2003
2144
|
// (written by the crosshair, read by the scroll pan) is the mirror image.
|
|
2004
2145
|
const scrollActive = useSharedValue(false);
|
|
2146
|
+
const axisScaleActive = useSharedValue(false);
|
|
2005
2147
|
|
|
2006
2148
|
const crosshairSettings = resolveCrosshairControllerSettings({
|
|
2007
2149
|
scrubCfg,
|
|
@@ -2043,6 +2185,9 @@ function useLiveChartController({
|
|
|
2043
2185
|
scrollActive,
|
|
2044
2186
|
crosshairSettings.clampToPlot,
|
|
2045
2187
|
crosshairSettings.snapToCandles,
|
|
2188
|
+
onScrubCandleChange,
|
|
2189
|
+
resolveScrubMarkerOptions(scrubCfg, markersSV),
|
|
2190
|
+
axisScaleActive,
|
|
2046
2191
|
);
|
|
2047
2192
|
|
|
2048
2193
|
// Capture only the shared value in the worklets below. Referencing
|
|
@@ -2066,11 +2211,16 @@ function useLiveChartController({
|
|
|
2066
2211
|
const src = isCandle ? candlesEngine.get() : lineEngineData.get();
|
|
2067
2212
|
return src.length > 0 ? src[0].time : engine.liveEdge.get();
|
|
2068
2213
|
});
|
|
2214
|
+
const clearCrosshair = useCallback(() => {
|
|
2215
|
+
"worklet";
|
|
2216
|
+
crosshairScrubActive.set(false);
|
|
2217
|
+
}, [crosshairScrubActive]);
|
|
2069
2218
|
const panScrollGesture = usePanScroll({
|
|
2070
2219
|
engine,
|
|
2071
2220
|
padding: effectivePadding,
|
|
2072
2221
|
minTime: scrollMinTime,
|
|
2073
2222
|
enabled: timeScrollEnabled,
|
|
2223
|
+
clampOnOverscrollChange: viewportCfg === null,
|
|
2074
2224
|
mode: scrollGestureMode,
|
|
2075
2225
|
overscroll: timeScrollOverscroll,
|
|
2076
2226
|
fling: timeScrollFling,
|
|
@@ -2079,10 +2229,7 @@ function useLiveChartController({
|
|
|
2079
2229
|
// finger only moves the price indicator across a fixed window.
|
|
2080
2230
|
scrubActive: crosshairScrubActive,
|
|
2081
2231
|
// Clear any live crosshair when a scroll drag takes over.
|
|
2082
|
-
onScrollStart:
|
|
2083
|
-
"worklet";
|
|
2084
|
-
crosshairScrubActive.set(false);
|
|
2085
|
-
},
|
|
2232
|
+
onScrollStart: clearCrosshair,
|
|
2086
2233
|
});
|
|
2087
2234
|
|
|
2088
2235
|
// Pinch-to-zoom the visible window (two-finger). Anchors at the focal point and
|
|
@@ -2097,14 +2244,12 @@ function useLiveChartController({
|
|
|
2097
2244
|
minTimeWindow: zoomCfg?.minTimeWindow,
|
|
2098
2245
|
maxTimeWindow: zoomCfg?.maxTimeWindow,
|
|
2099
2246
|
overscroll: timeScrollOverscroll,
|
|
2100
|
-
onZoomStart:
|
|
2101
|
-
"worklet";
|
|
2102
|
-
crosshairScrubActive.set(false);
|
|
2103
|
-
},
|
|
2247
|
+
onZoomStart: clearCrosshair,
|
|
2104
2248
|
});
|
|
2105
2249
|
|
|
2106
2250
|
const axisAutoHideOpacity = useAxisAutoHide({
|
|
2107
2251
|
config: axisAutoHide,
|
|
2252
|
+
scaleActive: axisScaleActive,
|
|
2108
2253
|
scrollActive,
|
|
2109
2254
|
scrubActive: crosshairScrubActive,
|
|
2110
2255
|
engine,
|
|
@@ -2123,8 +2268,11 @@ function useLiveChartController({
|
|
|
2123
2268
|
// ahead of the pan via Exclusive, so a tap is tried first and only becomes a
|
|
2124
2269
|
// drag (live-scrub, or lock-adjust once placed) if the finger moves. `Exclusive`
|
|
2125
2270
|
// (not `Race`) prevents a jittery tap from being swallowed by the pan.
|
|
2126
|
-
const
|
|
2127
|
-
|
|
2271
|
+
const crosshairGesture = crosshair.gesture;
|
|
2272
|
+
const crosshairTapGesture = crosshair.tapGesture;
|
|
2273
|
+
const rootGesture = useMemo(() => composeLiveChartRootGesture({
|
|
2274
|
+
crosshairGesture,
|
|
2275
|
+
crosshairTapGesture,
|
|
2128
2276
|
markerTapGesture,
|
|
2129
2277
|
refLineTapGesture,
|
|
2130
2278
|
refDragGesture,
|
|
@@ -2137,7 +2285,22 @@ function useLiveChartController({
|
|
|
2137
2285
|
timeScrollEnabled,
|
|
2138
2286
|
scrollGestureMode,
|
|
2139
2287
|
zoomEnabled,
|
|
2140
|
-
})
|
|
2288
|
+
}), [
|
|
2289
|
+
crosshairGesture,
|
|
2290
|
+
crosshairTapGesture,
|
|
2291
|
+
markerTapGesture,
|
|
2292
|
+
markersActive,
|
|
2293
|
+
panScrollGesture,
|
|
2294
|
+
pinchZoomGesture,
|
|
2295
|
+
refDragEnabled,
|
|
2296
|
+
refDragGesture,
|
|
2297
|
+
refLineTapGesture,
|
|
2298
|
+
refPressActive,
|
|
2299
|
+
scrollGestureMode,
|
|
2300
|
+
scrubActionCfg,
|
|
2301
|
+
timeScrollEnabled,
|
|
2302
|
+
zoomEnabled,
|
|
2303
|
+
]);
|
|
2141
2304
|
|
|
2142
2305
|
// ── Derived render values ──────────────────────────────────────────────
|
|
2143
2306
|
const {
|
|
@@ -2189,6 +2352,15 @@ function useLiveChartController({
|
|
|
2189
2352
|
viewEnd: engine.viewEnd,
|
|
2190
2353
|
fadeOverlaysOnScrub,
|
|
2191
2354
|
});
|
|
2355
|
+
useReferenceTagStack({
|
|
2356
|
+
enabled: refStackEnabled, radius: refStackRadius,
|
|
2357
|
+
engine, padding: effectivePadding, lines: allRefLines, keys: refLineKeys,
|
|
2358
|
+
custom: refLineCustom, offAxisCustom: refLineOffAxisCustom,
|
|
2359
|
+
customSizes: refTagSizes, font: skiaFont, fontProp, formatValue,
|
|
2360
|
+
dragValues: drawnRefValues, valueAxis: referenceValueAxis,
|
|
2361
|
+
obstacle: stackObstacle,
|
|
2362
|
+
output: refTagStack,
|
|
2363
|
+
});
|
|
2192
2364
|
const modelDefaults = resolveLiveChartModelDefaults({
|
|
2193
2365
|
isCandle,
|
|
2194
2366
|
candleWidth,
|
|
@@ -2199,6 +2371,10 @@ function useLiveChartController({
|
|
|
2199
2371
|
});
|
|
2200
2372
|
|
|
2201
2373
|
return {
|
|
2374
|
+
effectiveYRangeScale,
|
|
2375
|
+
axisScaleActive,
|
|
2376
|
+
deferAxisScaleHit: deferTapHit,
|
|
2377
|
+
clearCrosshair,
|
|
2202
2378
|
// passthrough props the render needs
|
|
2203
2379
|
style,
|
|
2204
2380
|
canvasMode,
|
|
@@ -2218,6 +2394,7 @@ function useLiveChartController({
|
|
|
2218
2394
|
// configs
|
|
2219
2395
|
yAxisCfg,
|
|
2220
2396
|
yAxisFloat: effectiveYAxisFloat,
|
|
2397
|
+
referenceValueAxis,
|
|
2221
2398
|
xAxisCfg,
|
|
2222
2399
|
badgeCfg,
|
|
2223
2400
|
scrubCfg,
|
|
@@ -2231,6 +2408,7 @@ function useLiveChartController({
|
|
|
2231
2408
|
dotTracksParked,
|
|
2232
2409
|
dotOuterRadius,
|
|
2233
2410
|
gridStyleCfg,
|
|
2411
|
+
xGridStyleCfg,
|
|
2234
2412
|
degenCfg,
|
|
2235
2413
|
tradeStreamResolved,
|
|
2236
2414
|
tradeStream,
|
|
@@ -2241,11 +2419,12 @@ function useLiveChartController({
|
|
|
2241
2419
|
refLineCustom,
|
|
2242
2420
|
refLineOffAxisCustom,
|
|
2243
2421
|
refLineCustomTagWidths,
|
|
2244
|
-
dragValues,
|
|
2422
|
+
dragValues: drawnRefValues,
|
|
2245
2423
|
dragActive,
|
|
2246
2424
|
renderReferenceLine,
|
|
2247
2425
|
renderOffAxisReferenceLine,
|
|
2248
2426
|
refGroupingActive: refGroupingRadius != null,
|
|
2427
|
+
refStackEnabled, refStackAvoidValueBadge, refTagSizes, refTagStack, refLiveBadgeRect,
|
|
2249
2428
|
refGroupResult,
|
|
2250
2429
|
groupHidden,
|
|
2251
2430
|
refGroupBadge,
|
|
@@ -2303,6 +2482,7 @@ function useLiveChartController({
|
|
|
2303
2482
|
linePath,
|
|
2304
2483
|
fillPath,
|
|
2305
2484
|
thresholdFillPath,
|
|
2485
|
+
seriesClip,
|
|
2306
2486
|
lineIsLinear,
|
|
2307
2487
|
volumeCfg,
|
|
2308
2488
|
candleGapsCfg,
|
|
@@ -2343,15 +2523,18 @@ function useLiveChartController({
|
|
|
2343
2523
|
type LiveChartModel = ReturnType<typeof useLiveChartController>;
|
|
2344
2524
|
|
|
2345
2525
|
type YAxisEntries = ReturnType<typeof useYAxis>["yAxisEntries"];
|
|
2526
|
+
type XAxisEntries = ReturnType<typeof useXAxis>["xAxisEntries"];
|
|
2346
2527
|
type DegenState = ReturnType<typeof useDegen>;
|
|
2347
2528
|
|
|
2348
2529
|
/** Owns the particle/shake state only while the degen effect is enabled. */
|
|
2349
2530
|
function ChartWithDegen({
|
|
2350
2531
|
model,
|
|
2351
2532
|
yAxisEntries,
|
|
2533
|
+
xAxisEntries,
|
|
2352
2534
|
}: {
|
|
2353
2535
|
model: LiveChartModel;
|
|
2354
2536
|
yAxisEntries: YAxisEntries | null;
|
|
2537
|
+
xAxisEntries: XAxisEntries | null;
|
|
2355
2538
|
}) {
|
|
2356
2539
|
const {
|
|
2357
2540
|
engine,
|
|
@@ -2371,7 +2554,61 @@ function ChartWithDegen({
|
|
|
2371
2554
|
onDegenShake,
|
|
2372
2555
|
isFrameLoopActive,
|
|
2373
2556
|
);
|
|
2374
|
-
return
|
|
2557
|
+
return (
|
|
2558
|
+
<ChartView
|
|
2559
|
+
model={model}
|
|
2560
|
+
yAxisEntries={yAxisEntries}
|
|
2561
|
+
xAxisEntries={xAxisEntries}
|
|
2562
|
+
degen={state}
|
|
2563
|
+
/>
|
|
2564
|
+
);
|
|
2565
|
+
}
|
|
2566
|
+
|
|
2567
|
+
/**
|
|
2568
|
+
* Owns the X-axis worklet, like {@link ChartWithYAxis} for the Y axis: mounted
|
|
2569
|
+
* only while the axis is enabled, and its entries are passed through props so
|
|
2570
|
+
* the vertical grid (behind the series) and the labels (above it) read the
|
|
2571
|
+
* same mapper.
|
|
2572
|
+
*/
|
|
2573
|
+
function ChartWithXAxis({ model }: { model: LiveChartModel }) {
|
|
2574
|
+
const { engine, effectivePadding, formatTime, skiaFont, xAxisCfg } = model;
|
|
2575
|
+
const { xAxisEntries } = useXAxis(
|
|
2576
|
+
engine,
|
|
2577
|
+
effectivePadding,
|
|
2578
|
+
formatTime,
|
|
2579
|
+
skiaFont,
|
|
2580
|
+
xAxisCfg?.minGap,
|
|
2581
|
+
);
|
|
2582
|
+
return <ChartWithYAxisOrDegen model={model} xAxisEntries={xAxisEntries} />;
|
|
2583
|
+
}
|
|
2584
|
+
|
|
2585
|
+
function ChartWithYAxisOrDegen({
|
|
2586
|
+
model,
|
|
2587
|
+
xAxisEntries,
|
|
2588
|
+
}: {
|
|
2589
|
+
model: LiveChartModel;
|
|
2590
|
+
xAxisEntries: XAxisEntries | null;
|
|
2591
|
+
}) {
|
|
2592
|
+
if (model.yAxisCfg) {
|
|
2593
|
+
return <ChartWithYAxis model={model} xAxisEntries={xAxisEntries} />;
|
|
2594
|
+
}
|
|
2595
|
+
if (model.degenCfg) {
|
|
2596
|
+
return (
|
|
2597
|
+
<ChartWithDegen
|
|
2598
|
+
model={model}
|
|
2599
|
+
yAxisEntries={null}
|
|
2600
|
+
xAxisEntries={xAxisEntries}
|
|
2601
|
+
/>
|
|
2602
|
+
);
|
|
2603
|
+
}
|
|
2604
|
+
return (
|
|
2605
|
+
<ChartView
|
|
2606
|
+
model={model}
|
|
2607
|
+
yAxisEntries={null}
|
|
2608
|
+
xAxisEntries={xAxisEntries}
|
|
2609
|
+
degen={null}
|
|
2610
|
+
/>
|
|
2611
|
+
);
|
|
2375
2612
|
}
|
|
2376
2613
|
|
|
2377
2614
|
/**
|
|
@@ -2380,7 +2617,13 @@ function ChartWithDegen({
|
|
|
2380
2617
|
* The entries are passed through ordinary props so both paint-order positions
|
|
2381
2618
|
* receive the same mapper across the React Native → Skia renderer boundary.
|
|
2382
2619
|
*/
|
|
2383
|
-
function ChartWithYAxis({
|
|
2620
|
+
function ChartWithYAxis({
|
|
2621
|
+
model,
|
|
2622
|
+
xAxisEntries,
|
|
2623
|
+
}: {
|
|
2624
|
+
model: LiveChartModel;
|
|
2625
|
+
xAxisEntries: XAxisEntries | null;
|
|
2626
|
+
}) {
|
|
2384
2627
|
const {
|
|
2385
2628
|
engine,
|
|
2386
2629
|
effectivePadding,
|
|
@@ -2400,9 +2643,22 @@ function ChartWithYAxis({ model }: { model: LiveChartModel }) {
|
|
|
2400
2643
|
yAxisCfg?.intervalScale ?? 1,
|
|
2401
2644
|
);
|
|
2402
2645
|
if (model.degenCfg) {
|
|
2403
|
-
return
|
|
2646
|
+
return (
|
|
2647
|
+
<ChartWithDegen
|
|
2648
|
+
model={model}
|
|
2649
|
+
yAxisEntries={yAxisEntries}
|
|
2650
|
+
xAxisEntries={xAxisEntries}
|
|
2651
|
+
/>
|
|
2652
|
+
);
|
|
2404
2653
|
}
|
|
2405
|
-
return
|
|
2654
|
+
return (
|
|
2655
|
+
<ChartView
|
|
2656
|
+
model={model}
|
|
2657
|
+
yAxisEntries={yAxisEntries}
|
|
2658
|
+
xAxisEntries={xAxisEntries}
|
|
2659
|
+
degen={null}
|
|
2660
|
+
/>
|
|
2661
|
+
);
|
|
2406
2662
|
}
|
|
2407
2663
|
|
|
2408
2664
|
function ChartYAxisLayer({
|
|
@@ -2463,27 +2719,21 @@ function ChartYAxisLayer({
|
|
|
2463
2719
|
);
|
|
2464
2720
|
}
|
|
2465
2721
|
|
|
2466
|
-
/**
|
|
2467
|
-
function ChartXAxisLayer({
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
const { xAxisEntries } = useXAxis(
|
|
2477
|
-
engine,
|
|
2478
|
-
effectivePadding,
|
|
2479
|
-
formatTime,
|
|
2480
|
-
skiaFont,
|
|
2481
|
-
);
|
|
2722
|
+
/** The X-axis line, ticks, and labels, drawn above the series. */
|
|
2723
|
+
function ChartXAxisLayer({
|
|
2724
|
+
model,
|
|
2725
|
+
entries,
|
|
2726
|
+
}: {
|
|
2727
|
+
model: LiveChartModel;
|
|
2728
|
+
entries: XAxisEntries;
|
|
2729
|
+
}) {
|
|
2730
|
+
const { engine, effectivePadding, skiaFont, palette, volumeBandHeight } =
|
|
2731
|
+
model;
|
|
2482
2732
|
return (
|
|
2483
2733
|
// Axis auto-hide fade (1 when the feature is off).
|
|
2484
2734
|
<Group opacity={model.axisAutoHideOpacity}>
|
|
2485
2735
|
<XAxisOverlay
|
|
2486
|
-
entries={
|
|
2736
|
+
entries={entries}
|
|
2487
2737
|
engine={engine}
|
|
2488
2738
|
padding={effectivePadding}
|
|
2489
2739
|
palette={palette}
|
|
@@ -2495,22 +2745,30 @@ function ChartXAxisLayer({ model }: { model: LiveChartModel }) {
|
|
|
2495
2745
|
}
|
|
2496
2746
|
|
|
2497
2747
|
/**
|
|
2498
|
-
* Background fills drawn BENEATH the left-edge fade: the
|
|
2499
|
-
* gradient, and the threshold profit/loss band. Split out
|
|
2500
|
-
* the fade's `dstOut` only softens the fills — the line
|
|
2501
|
-
* (drawn in `ChartStack`, after the fade) stay crisp at
|
|
2748
|
+
* Background fills drawn BENEATH the left-edge fade: the grid (both
|
|
2749
|
+
* directions), the area gradient, and the threshold profit/loss band. Split out
|
|
2750
|
+
* from `ChartStack` so the fade's `dstOut` only softens the fills — the line
|
|
2751
|
+
* and everything above it (drawn in `ChartStack`, after the fade) stay crisp at
|
|
2752
|
+
* the left edge.
|
|
2502
2753
|
*/
|
|
2503
2754
|
function ChartFillLayer({
|
|
2504
2755
|
model,
|
|
2505
2756
|
yAxisEntries,
|
|
2757
|
+
xAxisEntries,
|
|
2506
2758
|
degen,
|
|
2507
2759
|
}: {
|
|
2508
2760
|
model: LiveChartModel;
|
|
2509
2761
|
yAxisEntries: YAxisEntries | null;
|
|
2762
|
+
xAxisEntries: XAxisEntries | null;
|
|
2510
2763
|
degen: DegenState | null;
|
|
2511
2764
|
}) {
|
|
2512
2765
|
const {
|
|
2513
2766
|
yAxisCfg,
|
|
2767
|
+
xGridStyleCfg,
|
|
2768
|
+
engine,
|
|
2769
|
+
palette,
|
|
2770
|
+
volumeBandHeight,
|
|
2771
|
+
axisAutoHideOpacity,
|
|
2514
2772
|
yAxisFloat,
|
|
2515
2773
|
reveal,
|
|
2516
2774
|
effectivePadding,
|
|
@@ -2529,6 +2787,7 @@ function ChartFillLayer({
|
|
|
2529
2787
|
thresholdSeriesHasPoints,
|
|
2530
2788
|
thresholdFillUniforms,
|
|
2531
2789
|
seriesOpacity,
|
|
2790
|
+
seriesClip,
|
|
2532
2791
|
} = model;
|
|
2533
2792
|
return (
|
|
2534
2793
|
<Group transform={degen?.shakeTransform}>
|
|
@@ -2543,7 +2802,22 @@ function ChartFillLayer({
|
|
|
2543
2802
|
/>
|
|
2544
2803
|
)}
|
|
2545
2804
|
|
|
2546
|
-
|
|
2805
|
+
{/* Vertical grid at the time ticks (`xAxis.gridLines`). It fades with
|
|
2806
|
+
the X axis under `axisAutoHide`; its labels draw in ChartStack. */}
|
|
2807
|
+
{xGridStyleCfg && xAxisEntries ? (
|
|
2808
|
+
<Group opacity={axisAutoHideOpacity}>
|
|
2809
|
+
<XAxisGridLines
|
|
2810
|
+
entries={xAxisEntries}
|
|
2811
|
+
engine={engine}
|
|
2812
|
+
padding={effectivePadding}
|
|
2813
|
+
palette={palette}
|
|
2814
|
+
gridStyle={xGridStyleCfg}
|
|
2815
|
+
volumeBandHeight={volumeBandHeight}
|
|
2816
|
+
/>
|
|
2817
|
+
</Group>
|
|
2818
|
+
) : null}
|
|
2819
|
+
|
|
2820
|
+
<Group opacity={seriesOpacity} clip={seriesClip}>
|
|
2547
2821
|
{/* Dot-lattice area fill (the under-line `fillPath` painted with a dot
|
|
2548
2822
|
shader). Drawn before the gradient so a gradient (if also enabled)
|
|
2549
2823
|
composites on top. */}
|
|
@@ -2771,6 +3045,7 @@ function ChartCandleLayer({ model }: { model: LiveChartModel }) {
|
|
|
2771
3045
|
candleGapsCfg,
|
|
2772
3046
|
scrubCfg,
|
|
2773
3047
|
crosshair,
|
|
3048
|
+
seriesClip,
|
|
2774
3049
|
} = model;
|
|
2775
3050
|
const paths = useCandlePaths(
|
|
2776
3051
|
engine,
|
|
@@ -2881,7 +3156,7 @@ function ChartCandleLayer({ model }: { model: LiveChartModel }) {
|
|
|
2881
3156
|
|
|
2882
3157
|
return (
|
|
2883
3158
|
<Group opacity={seriesOpacity}>
|
|
2884
|
-
<Group opacity={candleGroupOpacity}>
|
|
3159
|
+
<Group opacity={candleGroupOpacity} clip={seriesClip}>
|
|
2885
3160
|
{candleGapsCfg && (
|
|
2886
3161
|
<ChartCandleGapLayer
|
|
2887
3162
|
model={model}
|
|
@@ -2991,9 +3266,11 @@ function ChartLineStrokeShader({ model }: { model: LiveChartModel }) {
|
|
|
2991
3266
|
function ChartMainPlotLayer({
|
|
2992
3267
|
model,
|
|
2993
3268
|
yAxisEntries,
|
|
3269
|
+
xAxisEntries,
|
|
2994
3270
|
}: {
|
|
2995
3271
|
model: LiveChartModel;
|
|
2996
3272
|
yAxisEntries: YAxisEntries | null;
|
|
3273
|
+
xAxisEntries: XAxisEntries | null;
|
|
2997
3274
|
}) {
|
|
2998
3275
|
const {
|
|
2999
3276
|
engine,
|
|
@@ -3006,14 +3283,14 @@ function ChartMainPlotLayer({
|
|
|
3006
3283
|
strokeWidth,
|
|
3007
3284
|
lineProp,
|
|
3008
3285
|
isCandle,
|
|
3009
|
-
xAxisCfg,
|
|
3010
3286
|
yAxisCfg,
|
|
3011
3287
|
yAxisFloat,
|
|
3288
|
+
seriesClip,
|
|
3012
3289
|
} = model;
|
|
3013
3290
|
|
|
3014
3291
|
return (
|
|
3015
3292
|
<>
|
|
3016
|
-
<Group opacity={seriesOpacity}>
|
|
3293
|
+
<Group opacity={seriesOpacity} clip={seriesClip}>
|
|
3017
3294
|
<Group opacity={lineGroupOpacity}>
|
|
3018
3295
|
<Path
|
|
3019
3296
|
path={linePath}
|
|
@@ -3038,7 +3315,9 @@ function ChartMainPlotLayer({
|
|
|
3038
3315
|
entries={yAxisEntries!}
|
|
3039
3316
|
/>
|
|
3040
3317
|
) : null}
|
|
3041
|
-
{
|
|
3318
|
+
{xAxisEntries ? (
|
|
3319
|
+
<ChartXAxisLayer model={model} entries={xAxisEntries} />
|
|
3320
|
+
) : null}
|
|
3042
3321
|
</>
|
|
3043
3322
|
);
|
|
3044
3323
|
}
|
|
@@ -3050,10 +3329,12 @@ function ChartMainPlotLayer({
|
|
|
3050
3329
|
function ChartStack({
|
|
3051
3330
|
model,
|
|
3052
3331
|
yAxisEntries,
|
|
3332
|
+
xAxisEntries,
|
|
3053
3333
|
degen,
|
|
3054
3334
|
}: {
|
|
3055
3335
|
model: LiveChartModel;
|
|
3056
3336
|
yAxisEntries: YAxisEntries | null;
|
|
3337
|
+
xAxisEntries: XAxisEntries | null;
|
|
3057
3338
|
degen: DegenState | null;
|
|
3058
3339
|
}) {
|
|
3059
3340
|
const {
|
|
@@ -3159,6 +3440,7 @@ function ChartStack({
|
|
|
3159
3440
|
engine={engine}
|
|
3160
3441
|
padding={effectivePadding}
|
|
3161
3442
|
line={rl}
|
|
3443
|
+
valueAxis={model.referenceValueAxis}
|
|
3162
3444
|
palette={palette}
|
|
3163
3445
|
formatValue={formatValue}
|
|
3164
3446
|
font={skiaFont}
|
|
@@ -3189,7 +3471,11 @@ function ChartStack({
|
|
|
3189
3471
|
/>
|
|
3190
3472
|
)}
|
|
3191
3473
|
|
|
3192
|
-
<ChartMainPlotLayer
|
|
3474
|
+
<ChartMainPlotLayer
|
|
3475
|
+
model={model}
|
|
3476
|
+
yAxisEntries={yAxisEntries}
|
|
3477
|
+
xAxisEntries={xAxisEntries}
|
|
3478
|
+
/>
|
|
3193
3479
|
|
|
3194
3480
|
{/* Live dot — the badge is drawn later (after the scrub layer) so the
|
|
3195
3481
|
scrub dim never clips the live-price badge's left edge. Hidden while
|
|
@@ -3501,9 +3787,11 @@ function ChartValueOverlay({
|
|
|
3501
3787
|
function ChartBadgeLayer({
|
|
3502
3788
|
model,
|
|
3503
3789
|
degen,
|
|
3790
|
+
yAxisEntries,
|
|
3504
3791
|
}: {
|
|
3505
3792
|
model: LiveChartModel;
|
|
3506
3793
|
degen: DegenState | null;
|
|
3794
|
+
yAxisEntries: YAxisEntries | null;
|
|
3507
3795
|
}) {
|
|
3508
3796
|
const {
|
|
3509
3797
|
badgeFont,
|
|
@@ -3515,8 +3803,27 @@ function ChartBadgeLayer({
|
|
|
3515
3803
|
metricsCfg,
|
|
3516
3804
|
yAxisFloat,
|
|
3517
3805
|
liveBadgeOpacity,
|
|
3806
|
+
skiaFont,
|
|
3807
|
+
yAxisCfg,
|
|
3808
|
+
badgeUsesRightGutter,
|
|
3518
3809
|
} = model;
|
|
3519
3810
|
const badgeCfg = model.badgeCfg!;
|
|
3811
|
+
// textAlign "yAxisColumn": hand the right-gutter badge the label column only
|
|
3812
|
+
// while YAxisOverlay draws one (right side + labelRightMargin, axis not
|
|
3813
|
+
// floating), so other charts' badges get no extra mapper input.
|
|
3814
|
+
const labelColumn =
|
|
3815
|
+
badgeCfg.textAlign === "yAxisColumn" &&
|
|
3816
|
+
badgeUsesRightGutter &&
|
|
3817
|
+
!yAxisFloat &&
|
|
3818
|
+
yAxisEntries &&
|
|
3819
|
+
yAxisCfg?.side !== "left" &&
|
|
3820
|
+
yAxisCfg?.labelRightMargin !== undefined
|
|
3821
|
+
? {
|
|
3822
|
+
entries: yAxisEntries,
|
|
3823
|
+
labelRightMargin: yAxisCfg.labelRightMargin,
|
|
3824
|
+
font: skiaFont,
|
|
3825
|
+
}
|
|
3826
|
+
: null;
|
|
3520
3827
|
const badgeData = useBadge(
|
|
3521
3828
|
engine,
|
|
3522
3829
|
effectivePadding,
|
|
@@ -3535,7 +3842,18 @@ function ChartBadgeLayer({
|
|
|
3535
3842
|
badgeCfg.followViewEdge,
|
|
3536
3843
|
badgeCfg.radius,
|
|
3537
3844
|
badgeCfg.textColor,
|
|
3845
|
+
labelColumn?.entries,
|
|
3846
|
+
labelColumn?.labelRightMargin,
|
|
3847
|
+
labelColumn?.font,
|
|
3538
3848
|
);
|
|
3849
|
+
const { refStackEnabled, refStackAvoidValueBadge, refLiveBadgeRect } = model;
|
|
3850
|
+
useAnimatedReaction(() => {
|
|
3851
|
+
if (!refStackEnabled || !refStackAvoidValueBadge || liveBadgeOpacity.get() <= 0) return null;
|
|
3852
|
+
const rect = badgeData.get().path.getBounds();
|
|
3853
|
+
return { x: rect.x + (badgeCfg.offsetX ?? 0), y: rect.y + (badgeCfg.offsetY ?? 0), w: rect.width, h: rect.height };
|
|
3854
|
+
}, (next, prev) => {
|
|
3855
|
+
if (next?.x !== prev?.x || next?.y !== prev?.y || next?.w !== prev?.w || next?.h !== prev?.h) refLiveBadgeRect.set(next);
|
|
3856
|
+
});
|
|
3539
3857
|
return (
|
|
3540
3858
|
<Group transform={degen?.shakeTransform}>
|
|
3541
3859
|
<Group opacity={liveBadgeOpacity}>
|
|
@@ -3596,6 +3914,7 @@ function ChartRefBadgeLayer({
|
|
|
3596
3914
|
engine={engine}
|
|
3597
3915
|
padding={effectivePadding}
|
|
3598
3916
|
line={rl}
|
|
3917
|
+
valueAxis={model.referenceValueAxis}
|
|
3599
3918
|
palette={palette}
|
|
3600
3919
|
formatValue={formatValue}
|
|
3601
3920
|
font={skiaFont}
|
|
@@ -3606,6 +3925,7 @@ function ChartRefBadgeLayer({
|
|
|
3606
3925
|
suppressTag={refLineCustom[i]}
|
|
3607
3926
|
suppressTagWhenOffAxis={refLineOffAxisCustom[i]}
|
|
3608
3927
|
customTagWidths={refLineCustomTagWidths}
|
|
3928
|
+
tagStack={model.refStackEnabled ? model.refTagStack : undefined}
|
|
3609
3929
|
groupHidden={refGroupingActive ? groupHidden : undefined}
|
|
3610
3930
|
yAxisEntries={yAxisEntries}
|
|
3611
3931
|
labelRightMargin={yAxisCfg?.labelRightMargin}
|
|
@@ -3723,6 +4043,8 @@ function ChartCustomAnnotations({ model }: { model: LiveChartModel }) {
|
|
|
3723
4043
|
dragValues={dragValues}
|
|
3724
4044
|
dragActive={dragActive}
|
|
3725
4045
|
tagWidths={refLineCustomTagWidths}
|
|
4046
|
+
tagSizes={model.refStackEnabled ? model.refTagSizes : undefined}
|
|
4047
|
+
tagStack={model.refStackEnabled ? model.refTagStack : undefined}
|
|
3726
4048
|
/>
|
|
3727
4049
|
)}
|
|
3728
4050
|
{renderOffAxisReferenceLine && allRefLines.length > 0 && (
|
|
@@ -3736,6 +4058,8 @@ function ChartCustomAnnotations({ model }: { model: LiveChartModel }) {
|
|
|
3736
4058
|
dragValues={dragValues}
|
|
3737
4059
|
dragActive={dragActive}
|
|
3738
4060
|
tagWidths={refLineCustomTagWidths}
|
|
4061
|
+
tagSizes={model.refStackEnabled ? model.refTagSizes : undefined}
|
|
4062
|
+
tagStack={model.refStackEnabled ? model.refTagStack : undefined}
|
|
3739
4063
|
offAxisOnly
|
|
3740
4064
|
/>
|
|
3741
4065
|
)}
|
|
@@ -3753,10 +4077,12 @@ function ChartCustomConsumerOverlay({ model }: { model: LiveChartModel }) {
|
|
|
3753
4077
|
function ChartCanvas({
|
|
3754
4078
|
model,
|
|
3755
4079
|
yAxisEntries,
|
|
4080
|
+
xAxisEntries,
|
|
3756
4081
|
degen,
|
|
3757
4082
|
}: {
|
|
3758
4083
|
model: LiveChartModel;
|
|
3759
4084
|
yAxisEntries: YAxisEntries | null;
|
|
4085
|
+
xAxisEntries: XAxisEntries | null;
|
|
3760
4086
|
degen: DegenState | null;
|
|
3761
4087
|
}) {
|
|
3762
4088
|
const {
|
|
@@ -3787,7 +4113,12 @@ function ChartCanvas({
|
|
|
3787
4113
|
color={backgroundColor}
|
|
3788
4114
|
/>
|
|
3789
4115
|
) : null}
|
|
3790
|
-
<ChartFillLayer
|
|
4116
|
+
<ChartFillLayer
|
|
4117
|
+
model={model}
|
|
4118
|
+
yAxisEntries={yAxisEntries}
|
|
4119
|
+
xAxisEntries={xAxisEntries}
|
|
4120
|
+
degen={degen}
|
|
4121
|
+
/>
|
|
3791
4122
|
{leftEdgeFadeCfg ? (
|
|
3792
4123
|
<LeftEdgeFade
|
|
3793
4124
|
paddingLeft={effectivePadding.left}
|
|
@@ -3800,7 +4131,12 @@ function ChartCanvas({
|
|
|
3800
4131
|
}
|
|
3801
4132
|
/>
|
|
3802
4133
|
) : null}
|
|
3803
|
-
<ChartStack
|
|
4134
|
+
<ChartStack
|
|
4135
|
+
model={model}
|
|
4136
|
+
yAxisEntries={yAxisEntries}
|
|
4137
|
+
xAxisEntries={xAxisEntries}
|
|
4138
|
+
degen={degen}
|
|
4139
|
+
/>
|
|
3804
4140
|
{topConnector || bottomConnector ? (
|
|
3805
4141
|
<ExtremaConnectorOverlay
|
|
3806
4142
|
engine={engine}
|
|
@@ -3825,7 +4161,13 @@ function ChartCanvas({
|
|
|
3825
4161
|
<ChartTradeStreamLayer model={model} degen={degen} />
|
|
3826
4162
|
) : null}
|
|
3827
4163
|
<ChartScrubLayer model={model} degen={degen} />
|
|
3828
|
-
{model.badgeCfg ?
|
|
4164
|
+
{model.badgeCfg ? (
|
|
4165
|
+
<ChartBadgeLayer
|
|
4166
|
+
model={model}
|
|
4167
|
+
degen={degen}
|
|
4168
|
+
yAxisEntries={yAxisEntries}
|
|
4169
|
+
/>
|
|
4170
|
+
) : null}
|
|
3829
4171
|
<ChartScrubActionLayer model={model} />
|
|
3830
4172
|
</Canvas>
|
|
3831
4173
|
);
|
|
@@ -3895,6 +4237,7 @@ function ChartNativeOverlays({ model }: { model: LiveChartModel }) {
|
|
|
3895
4237
|
scrubActive={crosshair.scrubActive}
|
|
3896
4238
|
scrubCandle={crosshair.scrubCandle}
|
|
3897
4239
|
scrubGap={crosshair.scrubGap}
|
|
4240
|
+
scrubMarkers={crosshair.scrubMarkers}
|
|
3898
4241
|
tooltipLayout={crosshair.tooltipLayout}
|
|
3899
4242
|
engine={engine}
|
|
3900
4243
|
padding={effectivePadding}
|
|
@@ -3914,10 +4257,12 @@ function ChartNativeOverlays({ model }: { model: LiveChartModel }) {
|
|
|
3914
4257
|
function ChartView({
|
|
3915
4258
|
model,
|
|
3916
4259
|
yAxisEntries,
|
|
4260
|
+
xAxisEntries,
|
|
3917
4261
|
degen,
|
|
3918
4262
|
}: {
|
|
3919
4263
|
model: LiveChartModel;
|
|
3920
4264
|
yAxisEntries: YAxisEntries | null;
|
|
4265
|
+
xAxisEntries: XAxisEntries | null;
|
|
3921
4266
|
degen: DegenState | null;
|
|
3922
4267
|
}) {
|
|
3923
4268
|
const {
|
|
@@ -3929,8 +4274,22 @@ function ChartView({
|
|
|
3929
4274
|
accessibilityRole,
|
|
3930
4275
|
} = model;
|
|
3931
4276
|
|
|
4277
|
+
const gesture = useYAxisScaleGesture({
|
|
4278
|
+
engine: model.engine,
|
|
4279
|
+
padding: model.effectivePadding,
|
|
4280
|
+
axis: model.yAxisCfg,
|
|
4281
|
+
floating: model.yAxisFloat,
|
|
4282
|
+
entries: yAxisEntries,
|
|
4283
|
+
font: model.skiaFont,
|
|
4284
|
+
scale: model.effectiveYRangeScale,
|
|
4285
|
+
active: model.axisScaleActive,
|
|
4286
|
+
deferHit: model.deferAxisScaleHit,
|
|
4287
|
+
onStart: model.clearCrosshair,
|
|
4288
|
+
gesture: rootGesture,
|
|
4289
|
+
});
|
|
4290
|
+
|
|
3932
4291
|
return (
|
|
3933
|
-
<GestureDetector gesture={
|
|
4292
|
+
<GestureDetector gesture={gesture}>
|
|
3934
4293
|
<View
|
|
3935
4294
|
style={[{ flex: 1, backgroundColor }, style]}
|
|
3936
4295
|
onLayout={onLayout}
|
|
@@ -3938,15 +4297,22 @@ function ChartView({
|
|
|
3938
4297
|
accessibilityLabel={accessibilityLabel}
|
|
3939
4298
|
accessibilityRole={accessibilityRole}
|
|
3940
4299
|
>
|
|
3941
|
-
<ChartCanvas
|
|
4300
|
+
<ChartCanvas
|
|
4301
|
+
model={model}
|
|
4302
|
+
yAxisEntries={yAxisEntries}
|
|
4303
|
+
xAxisEntries={xAxisEntries}
|
|
4304
|
+
degen={degen}
|
|
4305
|
+
/>
|
|
3942
4306
|
<ChartNativeOverlays model={model} />
|
|
3943
4307
|
</View>
|
|
3944
4308
|
</GestureDetector>
|
|
3945
4309
|
);
|
|
3946
4310
|
}
|
|
3947
4311
|
|
|
3948
|
-
|
|
3949
|
-
|
|
4312
|
+
// Memoized so a parent render with unchanged props skips the controller; the
|
|
4313
|
+
// chart's live data flows through SharedValues, not props.
|
|
4314
|
+
export const LiveChart = memo(
|
|
4315
|
+
forwardRef<LiveChartHandle, LiveChartProps>(function LiveChart(props, ref) {
|
|
3950
4316
|
const model = useLiveChartController(props);
|
|
3951
4317
|
const { viewEnd, viewWindow } = model.engine;
|
|
3952
4318
|
useImperativeHandle(
|
|
@@ -3956,12 +4322,9 @@ export const LiveChart = forwardRef<LiveChartHandle, LiveChartProps>(
|
|
|
3956
4322
|
}),
|
|
3957
4323
|
[viewEnd, viewWindow],
|
|
3958
4324
|
);
|
|
3959
|
-
if (model.
|
|
3960
|
-
return <
|
|
3961
|
-
}
|
|
3962
|
-
if (model.degenCfg) {
|
|
3963
|
-
return <ChartWithDegen model={model} yAxisEntries={null} />;
|
|
4325
|
+
if (model.xAxisCfg) {
|
|
4326
|
+
return <ChartWithXAxis model={model} />;
|
|
3964
4327
|
}
|
|
3965
|
-
return <
|
|
3966
|
-
},
|
|
4328
|
+
return <ChartWithYAxisOrDegen model={model} xAxisEntries={null} />;
|
|
4329
|
+
}),
|
|
3967
4330
|
);
|