react-native-livechart 4.26.0 → 4.28.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/MultiSeriesDots.d.ts +1 -1
- package/dist/components/MultiSeriesDots.d.ts.map +1 -1
- package/dist/components/MultiSeriesValueLabels.d.ts +1 -1
- package/dist/components/MultiSeriesValueLabels.d.ts.map +1 -1
- package/dist/components/MultiSeriesValueLines.d.ts +1 -1
- package/dist/components/MultiSeriesValueLines.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 +15 -2
- 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 +9 -0
- package/dist/core/useLiveChartEngine.d.ts.map +1 -1
- package/dist/core/useLiveChartSeriesEngine.d.ts +18 -4
- package/dist/core/useLiveChartSeriesEngine.d.ts.map +1 -1
- package/dist/draw/grid.d.ts +6 -4
- package/dist/draw/grid.d.ts.map +1 -1
- package/dist/draw/line.d.ts +21 -3
- package/dist/draw/line.d.ts.map +1 -1
- package/dist/hooks/crosshairSeries.d.ts +2 -2
- package/dist/hooks/crosshairSeries.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 +18 -2
- 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 +6 -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/useMultiSeriesDegen.d.ts +1 -1
- package/dist/hooks/useMultiSeriesDegen.d.ts.map +1 -1
- package/dist/hooks/useMultiSeriesLinePaths.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 +7 -4
- 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/useYAxis.d.ts +1 -1
- package/dist/hooks/useYAxis.d.ts.map +1 -1
- package/dist/hooks/useYAxisLabelWidth.d.ts +6 -0
- package/dist/hooks/useYAxisLabelWidth.d.ts.map +1 -0
- 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/referenceLines.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 +262 -37
- 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 +580 -138
- package/src/components/LiveChartSeries.tsx +139 -19
- package/src/components/MultiSeriesDots.tsx +4 -2
- package/src/components/MultiSeriesValueLabels.tsx +4 -2
- package/src/components/MultiSeriesValueLines.tsx +4 -2
- 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 +107 -14
- package/src/core/resolveConfig.ts +103 -7
- package/src/core/useLiveChartEngine.ts +45 -9
- package/src/core/useLiveChartSeriesEngine.ts +47 -6
- package/src/draw/grid.ts +17 -13
- package/src/draw/line.ts +46 -5
- package/src/hooks/crosshairSeries.ts +37 -5
- package/src/hooks/crosshairShared.ts +56 -1
- package/src/hooks/referenceBadgeFont.ts +35 -0
- package/src/hooks/resolveChartLayout.ts +51 -3
- 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 +57 -20
- package/src/hooks/useLatestCallback.ts +15 -0
- package/src/hooks/useMarkers.ts +51 -39
- package/src/hooks/useMultiSeriesDegen.ts +10 -5
- package/src/hooks/useMultiSeriesLinePaths.ts +2 -0
- package/src/hooks/usePanScroll.ts +155 -127
- package/src/hooks/usePinchZoom.ts +94 -66
- package/src/hooks/useReferenceDrag.ts +409 -156
- 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/useYAxis.ts +1 -1
- package/src/hooks/useYAxisLabelWidth.ts +26 -0
- 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/referenceLines.ts +5 -0
- package/src/math/referenceTagStack.ts +112 -0
- package/src/math/scrubMarkers.ts +55 -0
- package/src/types.ts +263 -37
|
@@ -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,14 @@ 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
|
+
shouldMeasureYAxisLabels,
|
|
102
|
+
shouldResampleLayoutValue,
|
|
103
|
+
} from "../hooks/resolveChartLayout";
|
|
95
104
|
import { useBadge } from "../hooks/useBadge";
|
|
96
105
|
import { useCandleGapPaths } from "../hooks/useCandleGapPaths";
|
|
97
106
|
import { useCandlePaths, useCandleWidthLerp } from "../hooks/useCandlePaths";
|
|
@@ -102,6 +111,7 @@ import { useChartPaths } from "../hooks/useChartPaths";
|
|
|
102
111
|
import { useChartReveal } from "../hooks/useChartReveal";
|
|
103
112
|
import { useChartSkiaFont } from "../hooks/useChartSkiaFont";
|
|
104
113
|
import { useCrosshair } from "../hooks/useCrosshair";
|
|
114
|
+
import { resolveScrubMarkerOptions } from "../hooks/useScrubMarkers";
|
|
105
115
|
import { useDegen } from "../hooks/useDegen";
|
|
106
116
|
import { useLiveChartHasData } from "../hooks/useLiveChartHasData";
|
|
107
117
|
import { useLiveDot } from "../hooks/useLiveDot";
|
|
@@ -127,7 +137,12 @@ import {
|
|
|
127
137
|
} from "../hooks/useThreshold";
|
|
128
138
|
import { useTradeStream } from "../hooks/useTradeStream";
|
|
129
139
|
import { useXAxis } from "../hooks/useXAxis";
|
|
140
|
+
import { useYAxisLabelWidth } from "../hooks/useYAxisLabelWidth";
|
|
130
141
|
import { useYAxis } from "../hooks/useYAxis";
|
|
142
|
+
import {
|
|
143
|
+
useYAxisScaleGesture,
|
|
144
|
+
useYAxisScaleValue,
|
|
145
|
+
} from "../hooks/useYAxisScaleGesture";
|
|
131
146
|
import {
|
|
132
147
|
formatTime as defaultFormatTime,
|
|
133
148
|
formatValue as defaultFormatValue,
|
|
@@ -137,6 +152,8 @@ import {
|
|
|
137
152
|
candleGapBucketStartAtTime,
|
|
138
153
|
candleGapDefaultLabel,
|
|
139
154
|
} from "../math/candleGaps";
|
|
155
|
+
import { useReferenceTagStack, type CustomTagSizes } from "../hooks/useReferenceTagStack";
|
|
156
|
+
import { EMPTY_TAG_STACK, type ReferenceTagStack, type TagRect } from "../math/referenceTagStack";
|
|
140
157
|
import { useReferenceLineGrouping } from "../hooks/useReferenceLineGrouping";
|
|
141
158
|
import {
|
|
142
159
|
collectReferenceValues,
|
|
@@ -198,7 +215,7 @@ import { SegmentDividerOverlay } from "./SegmentDividerOverlay";
|
|
|
198
215
|
import { SegmentLineGradient } from "./SegmentLineGradient";
|
|
199
216
|
import { TradeStreamOverlay } from "./TradeStreamOverlay";
|
|
200
217
|
import { ValueLineOverlay } from "./ValueLineOverlay";
|
|
201
|
-
import { XAxisOverlay } from "./XAxisOverlay";
|
|
218
|
+
import { XAxisGridLines, XAxisOverlay } from "./XAxisOverlay";
|
|
202
219
|
import { YAxisOverlay } from "./YAxisOverlay";
|
|
203
220
|
|
|
204
221
|
/** Stable empty number array so the live-reference-values worklet stays
|
|
@@ -275,8 +292,7 @@ function resolveLiveChartFeatureConfig({
|
|
|
275
292
|
scrub,
|
|
276
293
|
scrubAction,
|
|
277
294
|
volume,
|
|
278
|
-
|
|
279
|
-
lineGaps,
|
|
295
|
+
chartGapsCfg,
|
|
280
296
|
gradient,
|
|
281
297
|
areaDots,
|
|
282
298
|
threshold,
|
|
@@ -300,8 +316,6 @@ function resolveLiveChartFeatureConfig({
|
|
|
300
316
|
| "scrub"
|
|
301
317
|
| "scrubAction"
|
|
302
318
|
| "volume"
|
|
303
|
-
| "candleGaps"
|
|
304
|
-
| "lineGaps"
|
|
305
319
|
| "gradient"
|
|
306
320
|
| "areaDots"
|
|
307
321
|
| "threshold"
|
|
@@ -313,26 +327,29 @@ function resolveLiveChartFeatureConfig({
|
|
|
313
327
|
| "degen"
|
|
314
328
|
| "tradeStream"
|
|
315
329
|
| "metrics"
|
|
316
|
-
> & {
|
|
330
|
+
> & {
|
|
331
|
+
isStatic: boolean;
|
|
332
|
+
chartGapsCfg: ResolvedCandleGapsConfig | null;
|
|
333
|
+
}) {
|
|
317
334
|
const isCandle = mode === "candle";
|
|
318
335
|
const badgeCfg = resolveBadge(badge);
|
|
319
|
-
const chartGapsCfg = resolveCandleGaps(isCandle ? candleGaps : lineGaps);
|
|
320
336
|
const thresholdCfg = isCandle ? null : resolveThreshold(threshold);
|
|
321
337
|
const thresholdSeriesSV = thresholdCfg?.series ?? null;
|
|
322
338
|
const dotCfg = resolveDot(dot);
|
|
323
339
|
const volumeCfg = isCandle ? resolveVolume(volume) : null;
|
|
340
|
+
const xAxisCfg = resolveXAxis(xAxis);
|
|
341
|
+
const gridStyleCfg = resolveGridStyle(gridStyle);
|
|
324
342
|
|
|
325
343
|
return {
|
|
326
344
|
isCandle,
|
|
327
345
|
yAxisCfg: resolveYAxis(yAxis),
|
|
328
|
-
xAxisCfg
|
|
346
|
+
xAxisCfg,
|
|
329
347
|
topLabelCfg: resolveAxisLabel(topLabel),
|
|
330
348
|
bottomLabelCfg: resolveAxisLabel(bottomLabel),
|
|
331
349
|
badgeCfg,
|
|
332
350
|
scrubCfg: resolveScrub(scrub),
|
|
333
351
|
scrubActionCfg: resolveScrubAction(scrubAction),
|
|
334
352
|
volumeCfg,
|
|
335
|
-
chartGapsCfg,
|
|
336
353
|
candleGapsCfg: isCandle ? chartGapsCfg : null,
|
|
337
354
|
lineGapsCfg: isCandle ? null : chartGapsCfg,
|
|
338
355
|
volumeBandHeight: volumeCfg?.maxHeight ?? 0,
|
|
@@ -354,29 +371,27 @@ function resolveLiveChartFeatureConfig({
|
|
|
354
371
|
? dotGlowRadialOutset(dotCfg.glow.radius, dotCfg.glow.blur)
|
|
355
372
|
: 0,
|
|
356
373
|
),
|
|
357
|
-
gridStyleCfg
|
|
374
|
+
gridStyleCfg,
|
|
375
|
+
xGridStyleCfg: resolveXAxisGridStyle(
|
|
376
|
+
xAxisCfg?.gridLines ?? null,
|
|
377
|
+
gridStyleCfg,
|
|
378
|
+
),
|
|
358
379
|
degenCfg: isStatic ? null : resolveDegen(degen),
|
|
359
380
|
tradeStreamResolved: resolveTradeStream(tradeStream),
|
|
360
381
|
metricsCfg: resolveMetrics(metrics),
|
|
361
382
|
};
|
|
362
383
|
}
|
|
363
384
|
|
|
364
|
-
function
|
|
385
|
+
function resolveLiveChartReferenceLines({
|
|
365
386
|
chartGapsCfg,
|
|
366
387
|
referenceLines,
|
|
367
388
|
renderReferenceLine,
|
|
368
389
|
renderOffAxisReferenceLine,
|
|
369
|
-
thresholdCfg,
|
|
370
|
-
referenceLineGrouping,
|
|
371
|
-
badgeCfg,
|
|
372
390
|
}: {
|
|
373
391
|
chartGapsCfg: ReturnType<typeof resolveCandleGaps>;
|
|
374
392
|
referenceLines: LiveChartProps["referenceLines"];
|
|
375
393
|
renderReferenceLine: LiveChartProps["renderReferenceLine"];
|
|
376
394
|
renderOffAxisReferenceLine: LiveChartProps["renderOffAxisReferenceLine"];
|
|
377
|
-
thresholdCfg: ReturnType<typeof resolveThreshold>;
|
|
378
|
-
referenceLineGrouping: LiveChartProps["referenceLineGrouping"];
|
|
379
|
-
badgeCfg: ReturnType<typeof resolveBadge>;
|
|
380
395
|
}) {
|
|
381
396
|
const chartGapBands: ReferenceLine[] =
|
|
382
397
|
chartGapsCfg?.gaps.flatMap((gap) => {
|
|
@@ -429,6 +444,26 @@ function resolveLiveChartReferenceConfig({
|
|
|
429
444
|
draggableRefIdx.push(index);
|
|
430
445
|
}
|
|
431
446
|
}
|
|
447
|
+
|
|
448
|
+
return {
|
|
449
|
+
allRefLines,
|
|
450
|
+
refValues: collectReferenceValues(allRefLines),
|
|
451
|
+
refLineCustom,
|
|
452
|
+
refLineOffAxisCustom,
|
|
453
|
+
refLineKeys: referenceLineReactKeys(allRefLines),
|
|
454
|
+
draggableRefIdx,
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
function resolveLiveChartReferenceConfig({
|
|
459
|
+
thresholdCfg,
|
|
460
|
+
referenceLineGrouping,
|
|
461
|
+
badgeCfg,
|
|
462
|
+
}: {
|
|
463
|
+
thresholdCfg: ReturnType<typeof resolveThreshold>;
|
|
464
|
+
referenceLineGrouping: LiveChartProps["referenceLineGrouping"];
|
|
465
|
+
badgeCfg: ReturnType<typeof resolveBadge>;
|
|
466
|
+
}) {
|
|
432
467
|
const thresholdInRange = thresholdCfg?.includeInRange === true;
|
|
433
468
|
const thresholdRangeValueSV =
|
|
434
469
|
thresholdInRange &&
|
|
@@ -442,17 +477,14 @@ function resolveLiveChartReferenceConfig({
|
|
|
442
477
|
: undefined;
|
|
443
478
|
|
|
444
479
|
return {
|
|
445
|
-
chartGapBands,
|
|
446
|
-
allRefLines,
|
|
447
|
-
refValues: collectReferenceValues(allRefLines),
|
|
448
|
-
refLineCustom,
|
|
449
|
-
refLineOffAxisCustom,
|
|
450
|
-
refLineKeys: referenceLineReactKeys(allRefLines),
|
|
451
|
-
draggableRefIdx,
|
|
452
480
|
thresholdInRange,
|
|
453
481
|
thresholdRangeValueSV,
|
|
454
482
|
refGroupingCfg,
|
|
455
|
-
|
|
483
|
+
refStackEnabled: !!referenceLineGrouping && refGroupingCfg?.mode === "stack",
|
|
484
|
+
refStackAvoidValueBadge: refGroupingCfg?.avoidValueBadge !== false,
|
|
485
|
+
refStackRadius: refGroupingCfg?.radius ?? 18,
|
|
486
|
+
refStackReserveBadge: refGroupingCfg?.avoidValueBadge !== false && badgeCfg !== null,
|
|
487
|
+
refGroupingRadius: referenceLineGrouping && refGroupingCfg?.mode !== "stack"
|
|
456
488
|
? (refGroupingCfg?.radius ?? 18)
|
|
457
489
|
: null,
|
|
458
490
|
refGroupBadge: resolveReferenceGroupBadge(refGroupingCfg?.badge),
|
|
@@ -466,6 +498,8 @@ function useLiveReferenceState(
|
|
|
466
498
|
allRefLines: ReferenceLine[],
|
|
467
499
|
draggableRefIdx: number[],
|
|
468
500
|
thresholdRangeValueSV: SharedValue<number> | null,
|
|
501
|
+
stackEnabled: boolean,
|
|
502
|
+
reserveBadge: boolean,
|
|
469
503
|
) {
|
|
470
504
|
const dragValues = useSharedValue<number[]>([]);
|
|
471
505
|
const dragActive = useSharedValue<boolean[]>([]);
|
|
@@ -496,6 +530,23 @@ function useLiveReferenceState(
|
|
|
496
530
|
}, [dragActive, dragValues, propValues]);
|
|
497
531
|
|
|
498
532
|
const refLineCustomTagWidths = useSharedValue<number[]>([]);
|
|
533
|
+
const refTagSizes = useSharedValue<CustomTagSizes>({});
|
|
534
|
+
const refTagStack = useSharedValue<ReferenceTagStack>(EMPTY_TAG_STACK);
|
|
535
|
+
const refLiveBadgeRect = useSharedValue<TagRect | null>(null);
|
|
536
|
+
useEffect(() => {
|
|
537
|
+
const keys = new Set(referenceLineReactKeys(allRefLines));
|
|
538
|
+
scheduleOnUI(() => {
|
|
539
|
+
"worklet";
|
|
540
|
+
const sizes = refTagSizes.get();
|
|
541
|
+
const next: CustomTagSizes = {};
|
|
542
|
+
let removed = false;
|
|
543
|
+
for (const key of Object.keys(sizes)) {
|
|
544
|
+
if (keys.has(key)) next[key] = sizes[key];
|
|
545
|
+
else removed = true;
|
|
546
|
+
}
|
|
547
|
+
if (removed) refTagSizes.set(next);
|
|
548
|
+
});
|
|
549
|
+
}, [allRefLines, refTagSizes]);
|
|
499
550
|
const liveRefValues = useDerivedValue<number[]>(() => {
|
|
500
551
|
if (draggableRefIdx.length === 0 && thresholdRangeValueSV === null) {
|
|
501
552
|
return EMPTY_NUMS;
|
|
@@ -515,7 +566,12 @@ function useLiveReferenceState(
|
|
|
515
566
|
return output;
|
|
516
567
|
});
|
|
517
568
|
|
|
518
|
-
return {
|
|
569
|
+
return {
|
|
570
|
+
dragValues, dragActive, refLineCustomTagWidths, liveRefValues,
|
|
571
|
+
refTagSizes, refTagStack, refLiveBadgeRect,
|
|
572
|
+
activeTagStack: stackEnabled ? refTagStack : undefined,
|
|
573
|
+
stackObstacle: reserveBadge ? refLiveBadgeRect : null,
|
|
574
|
+
};
|
|
519
575
|
}
|
|
520
576
|
|
|
521
577
|
function resolveLiveChartPresentationConfig({
|
|
@@ -529,6 +585,7 @@ function resolveLiveChartPresentationConfig({
|
|
|
529
585
|
refGroupBadge,
|
|
530
586
|
pulseCfg,
|
|
531
587
|
timeScroll,
|
|
588
|
+
viewport,
|
|
532
589
|
isStatic,
|
|
533
590
|
returnToLive,
|
|
534
591
|
zoom,
|
|
@@ -544,6 +601,7 @@ function resolveLiveChartPresentationConfig({
|
|
|
544
601
|
refGroupBadge: ReturnType<typeof resolveReferenceGroupBadge>;
|
|
545
602
|
pulseCfg: ReturnType<typeof resolvePulse>;
|
|
546
603
|
timeScroll: LiveChartProps["timeScroll"];
|
|
604
|
+
viewport: LiveChartProps["viewport"];
|
|
547
605
|
isStatic: boolean;
|
|
548
606
|
returnToLive: LiveChartProps["returnToLive"];
|
|
549
607
|
zoom: LiveChartProps["zoom"];
|
|
@@ -604,6 +662,7 @@ function resolveLiveChartPresentationConfig({
|
|
|
604
662
|
}
|
|
605
663
|
: null,
|
|
606
664
|
timeScrollEnabled,
|
|
665
|
+
viewportCfg: resolveViewport(viewport),
|
|
607
666
|
returnToLiveMs: resolveReturnToLiveMs(returnToLive),
|
|
608
667
|
timeScrollOverscroll: timeScrollEnabled ? resolveOverscroll(timeScroll) : 0,
|
|
609
668
|
timeScrollFling: resolveFling(timeScroll),
|
|
@@ -925,7 +984,8 @@ function resolveLiveChartInteractionConfig({
|
|
|
925
984
|
}
|
|
926
985
|
|
|
927
986
|
function composeLiveChartRootGesture({
|
|
928
|
-
|
|
987
|
+
crosshairGesture,
|
|
988
|
+
crosshairTapGesture,
|
|
929
989
|
markerTapGesture,
|
|
930
990
|
refLineTapGesture,
|
|
931
991
|
refDragGesture,
|
|
@@ -939,7 +999,8 @@ function composeLiveChartRootGesture({
|
|
|
939
999
|
scrollGestureMode,
|
|
940
1000
|
zoomEnabled,
|
|
941
1001
|
}: {
|
|
942
|
-
|
|
1002
|
+
crosshairGesture: ReturnType<typeof useCrosshair>["gesture"];
|
|
1003
|
+
crosshairTapGesture: ReturnType<typeof useCrosshair>["tapGesture"];
|
|
943
1004
|
markerTapGesture: ReturnType<typeof useMarkers>["tapGesture"];
|
|
944
1005
|
refLineTapGesture: ReturnType<typeof useReferenceLinePress>["tapGesture"];
|
|
945
1006
|
refDragGesture: ReturnType<typeof useReferenceDrag>["gesture"];
|
|
@@ -954,9 +1015,9 @@ function composeLiveChartRootGesture({
|
|
|
954
1015
|
zoomEnabled: boolean;
|
|
955
1016
|
}) {
|
|
956
1017
|
const baseGesture =
|
|
957
|
-
scrubActionActive &&
|
|
958
|
-
? Gesture.Exclusive(
|
|
959
|
-
:
|
|
1018
|
+
scrubActionActive && crosshairTapGesture
|
|
1019
|
+
? Gesture.Exclusive(crosshairTapGesture, crosshairGesture)
|
|
1020
|
+
: crosshairGesture;
|
|
960
1021
|
const overlayTaps = [
|
|
961
1022
|
markersActive ? markerTapGesture : null,
|
|
962
1023
|
refPressActive ? refLineTapGesture : null,
|
|
@@ -989,11 +1050,13 @@ function useAxisAutoHide({
|
|
|
989
1050
|
config,
|
|
990
1051
|
scrollActive,
|
|
991
1052
|
scrubActive,
|
|
1053
|
+
scaleActive,
|
|
992
1054
|
engine,
|
|
993
1055
|
}: {
|
|
994
1056
|
config: LiveChartProps["axisAutoHide"];
|
|
995
1057
|
scrollActive: SharedValue<boolean>;
|
|
996
1058
|
scrubActive: SharedValue<boolean>;
|
|
1059
|
+
scaleActive: SharedValue<boolean>;
|
|
997
1060
|
engine: ReturnType<typeof useLiveChartEngine>;
|
|
998
1061
|
}) {
|
|
999
1062
|
const resolved = config === true ? {} : config === false ? null : config;
|
|
@@ -1017,7 +1080,7 @@ function useAxisAutoHide({
|
|
|
1017
1080
|
}, [enabled, idleOpacity, opacity]);
|
|
1018
1081
|
useAnimatedReaction(
|
|
1019
1082
|
() => ({
|
|
1020
|
-
gesture: scrollActive.value || scrubActive.value,
|
|
1083
|
+
gesture: scrollActive.value || scrubActive.value || scaleActive.value,
|
|
1021
1084
|
viewEnd: engine.viewEnd.value,
|
|
1022
1085
|
viewWindow: engine.viewWindow.value,
|
|
1023
1086
|
}),
|
|
@@ -1232,10 +1295,12 @@ function useLiveChartLayoutResources({
|
|
|
1232
1295
|
badgeCfg,
|
|
1233
1296
|
metricsCfg,
|
|
1234
1297
|
badgeUsesRightGutter,
|
|
1298
|
+
referenceAxisBadge,
|
|
1235
1299
|
xAxisCfg,
|
|
1236
1300
|
formatValue,
|
|
1237
1301
|
pulseConfig,
|
|
1238
1302
|
dotCfg,
|
|
1303
|
+
dotOuterRadius,
|
|
1239
1304
|
volumeBandHeight,
|
|
1240
1305
|
}: {
|
|
1241
1306
|
value: LiveChartProps["value"];
|
|
@@ -1253,10 +1318,12 @@ function useLiveChartLayoutResources({
|
|
|
1253
1318
|
badgeCfg: ReturnType<typeof resolveBadge>;
|
|
1254
1319
|
metricsCfg: ReturnType<typeof resolveMetrics>;
|
|
1255
1320
|
badgeUsesRightGutter: boolean;
|
|
1321
|
+
referenceAxisBadge: boolean;
|
|
1256
1322
|
xAxisCfg: ReturnType<typeof resolveXAxis>;
|
|
1257
1323
|
formatValue: (value: number) => string;
|
|
1258
1324
|
pulseConfig: { maxRadius: number; strokeWidth: number } | null;
|
|
1259
1325
|
dotCfg: ReturnType<typeof resolveDot>;
|
|
1326
|
+
dotOuterRadius: number;
|
|
1260
1327
|
volumeBandHeight: number;
|
|
1261
1328
|
}) {
|
|
1262
1329
|
const skiaFont = useChartSkiaFont(
|
|
@@ -1283,19 +1350,24 @@ function useLiveChartLayoutResources({
|
|
|
1283
1350
|
const refGroupBadgeFont = refGroupBadgeHasFont
|
|
1284
1351
|
? refGroupBadgeFontOverride
|
|
1285
1352
|
: skiaFont;
|
|
1286
|
-
const valueLayoutSample =
|
|
1353
|
+
const valueLayoutSample = useLayoutValueSample(value);
|
|
1287
1354
|
const [scrolledBack, setScrolledBack] = useState(false);
|
|
1355
|
+
const [yAxisLabelWidth, setYAxisLabelWidth] = useState<number | undefined>();
|
|
1288
1356
|
const effectiveYAxisFloat =
|
|
1289
1357
|
yAxisFloat && (!timeScrollEnabled || scrolledBack);
|
|
1290
|
-
const
|
|
1358
|
+
const measureYAxisLabels = shouldMeasureYAxisLabels(yAxisCfg, insets?.right, effectiveYAxisFloat);
|
|
1359
|
+
const layout = useMemo(() => resolveChartLayout({
|
|
1291
1360
|
palette,
|
|
1292
1361
|
lineWidthOverride: lineProp?.width,
|
|
1293
1362
|
insetsOverride: insets,
|
|
1294
1363
|
yAxis: yAxisCfg !== null,
|
|
1295
1364
|
yAxisFloat: effectiveYAxisFloat,
|
|
1296
|
-
|
|
1365
|
+
labelRightMargin: measureYAxisLabels ? yAxisCfg?.labelRightMargin : undefined,
|
|
1366
|
+
yAxisLabelWidth,
|
|
1367
|
+
dotRadius: dotOuterRadius,
|
|
1368
|
+
badge: badgeCfg !== null || referenceAxisBadge,
|
|
1297
1369
|
badgeMetrics: metricsCfg.badge,
|
|
1298
|
-
badgeUsesRightGutter,
|
|
1370
|
+
badgeUsesRightGutter: badgeUsesRightGutter || referenceAxisBadge,
|
|
1299
1371
|
badgeShowTail: badgeCfg?.tail ?? true,
|
|
1300
1372
|
xAxis: xAxisCfg !== null,
|
|
1301
1373
|
font: skiaFont,
|
|
@@ -1304,7 +1376,27 @@ function useLiveChartLayoutResources({
|
|
|
1304
1376
|
pulse: pulseConfig,
|
|
1305
1377
|
dotGlow: dotCfg.glow,
|
|
1306
1378
|
volumeBandHeight,
|
|
1307
|
-
})
|
|
1379
|
+
}), [
|
|
1380
|
+
badgeCfg,
|
|
1381
|
+
badgeUsesRightGutter,
|
|
1382
|
+
referenceAxisBadge,
|
|
1383
|
+
dotCfg.glow,
|
|
1384
|
+
dotOuterRadius,
|
|
1385
|
+
measureYAxisLabels,
|
|
1386
|
+
yAxisLabelWidth,
|
|
1387
|
+
effectiveYAxisFloat,
|
|
1388
|
+
formatValue,
|
|
1389
|
+
insets,
|
|
1390
|
+
lineProp?.width,
|
|
1391
|
+
metricsCfg.badge,
|
|
1392
|
+
palette,
|
|
1393
|
+
pulseConfig,
|
|
1394
|
+
skiaFont,
|
|
1395
|
+
valueLayoutSample,
|
|
1396
|
+
volumeBandHeight,
|
|
1397
|
+
xAxisCfg,
|
|
1398
|
+
yAxisCfg,
|
|
1399
|
+
]);
|
|
1308
1400
|
return {
|
|
1309
1401
|
skiaFont,
|
|
1310
1402
|
valueFont,
|
|
@@ -1312,21 +1404,23 @@ function useLiveChartLayoutResources({
|
|
|
1312
1404
|
refGroupBadgeFont,
|
|
1313
1405
|
effectiveYAxisFloat,
|
|
1314
1406
|
setScrolledBack,
|
|
1407
|
+
setYAxisLabelWidth,
|
|
1408
|
+
measureYAxisLabels,
|
|
1315
1409
|
...layout,
|
|
1316
1410
|
};
|
|
1317
1411
|
}
|
|
1318
1412
|
|
|
1319
|
-
function
|
|
1413
|
+
function useLayoutValueSample(value: SharedValue<number>) {
|
|
1320
1414
|
const [sample, setSample] = useState<number | undefined>(undefined);
|
|
1321
|
-
const
|
|
1415
|
+
const sampled = useSharedValue(0);
|
|
1322
1416
|
useAnimatedReaction(
|
|
1323
|
-
() =>
|
|
1417
|
+
() => value.get(),
|
|
1324
1418
|
(current) => {
|
|
1325
|
-
if (current
|
|
1326
|
-
|
|
1419
|
+
if (!shouldResampleLayoutValue(current, sampled.get())) return;
|
|
1420
|
+
sampled.set(current);
|
|
1327
1421
|
scheduleOnRN(setSample, current);
|
|
1328
1422
|
},
|
|
1329
|
-
[
|
|
1423
|
+
[sampled, value],
|
|
1330
1424
|
);
|
|
1331
1425
|
return sample;
|
|
1332
1426
|
}
|
|
@@ -1409,10 +1503,12 @@ function useLiveChartController({
|
|
|
1409
1503
|
exaggerate = false,
|
|
1410
1504
|
nonNegative = false,
|
|
1411
1505
|
maxValue,
|
|
1506
|
+
minRange,
|
|
1412
1507
|
yRangeScale,
|
|
1413
1508
|
windowBuffer = 0,
|
|
1414
1509
|
nowOverride,
|
|
1415
1510
|
timeScroll = false,
|
|
1511
|
+
viewport,
|
|
1416
1512
|
returnToLive,
|
|
1417
1513
|
zoom = false,
|
|
1418
1514
|
accessibilityLabel,
|
|
@@ -1460,6 +1556,7 @@ function useLiveChartController({
|
|
|
1460
1556
|
|
|
1461
1557
|
// ── Callbacks ───────────────────────────────────────────────────────────
|
|
1462
1558
|
onScrub,
|
|
1559
|
+
onScrubCandleChange,
|
|
1463
1560
|
onScrubAction,
|
|
1464
1561
|
onReferenceLinePress,
|
|
1465
1562
|
onGestureStart,
|
|
@@ -1475,6 +1572,10 @@ function useLiveChartController({
|
|
|
1475
1572
|
// Stand-in threshold value so `useThreshold` can be called unconditionally
|
|
1476
1573
|
// (hooks can't be); the geometry is ignored when no threshold is configured.
|
|
1477
1574
|
const emptyThresholdValue = useSharedValue(0);
|
|
1575
|
+
// Memoized on the gaps prop so the gap bands, the reference lines built from
|
|
1576
|
+
// them and the crosshair's gap list keep their identity across re-renders.
|
|
1577
|
+
const gapsProp = mode === "candle" ? candleGaps : lineGaps;
|
|
1578
|
+
const chartGapsCfg = useMemo(() => resolveCandleGaps(gapsProp), [gapsProp]);
|
|
1478
1579
|
const {
|
|
1479
1580
|
isCandle,
|
|
1480
1581
|
yAxisCfg,
|
|
@@ -1485,7 +1586,6 @@ function useLiveChartController({
|
|
|
1485
1586
|
scrubCfg,
|
|
1486
1587
|
scrubActionCfg,
|
|
1487
1588
|
volumeCfg,
|
|
1488
|
-
chartGapsCfg,
|
|
1489
1589
|
candleGapsCfg,
|
|
1490
1590
|
lineGapsCfg,
|
|
1491
1591
|
volumeBandHeight,
|
|
@@ -1501,10 +1601,11 @@ function useLiveChartController({
|
|
|
1501
1601
|
selectionDotCfg,
|
|
1502
1602
|
dotOuterRadius,
|
|
1503
1603
|
gridStyleCfg,
|
|
1604
|
+
xGridStyleCfg,
|
|
1504
1605
|
degenCfg,
|
|
1505
1606
|
tradeStreamResolved,
|
|
1506
1607
|
metricsCfg,
|
|
1507
|
-
} = resolveLiveChartFeatureConfig({
|
|
1608
|
+
} = useMemo(() => resolveLiveChartFeatureConfig({
|
|
1508
1609
|
mode,
|
|
1509
1610
|
yAxis,
|
|
1510
1611
|
xAxis,
|
|
@@ -1514,8 +1615,7 @@ function useLiveChartController({
|
|
|
1514
1615
|
scrub,
|
|
1515
1616
|
scrubAction,
|
|
1516
1617
|
volume,
|
|
1517
|
-
|
|
1518
|
-
lineGaps,
|
|
1618
|
+
chartGapsCfg,
|
|
1519
1619
|
gradient,
|
|
1520
1620
|
areaDots,
|
|
1521
1621
|
threshold,
|
|
@@ -1528,35 +1628,80 @@ function useLiveChartController({
|
|
|
1528
1628
|
degen,
|
|
1529
1629
|
tradeStream,
|
|
1530
1630
|
metrics,
|
|
1531
|
-
})
|
|
1631
|
+
}), [
|
|
1632
|
+
areaDots,
|
|
1633
|
+
badge,
|
|
1634
|
+
bottomLabel,
|
|
1635
|
+
chartGapsCfg,
|
|
1636
|
+
degen,
|
|
1637
|
+
dot,
|
|
1638
|
+
gradient,
|
|
1639
|
+
gridStyle,
|
|
1640
|
+
isStatic,
|
|
1641
|
+
metrics,
|
|
1642
|
+
mode,
|
|
1643
|
+
pulse,
|
|
1644
|
+
scrub,
|
|
1645
|
+
scrubAction,
|
|
1646
|
+
selectionDot,
|
|
1647
|
+
threshold,
|
|
1648
|
+
topLabel,
|
|
1649
|
+
tradeStream,
|
|
1650
|
+
valueLine,
|
|
1651
|
+
volume,
|
|
1652
|
+
xAxis,
|
|
1653
|
+
yAxis,
|
|
1654
|
+
]);
|
|
1532
1655
|
|
|
1656
|
+
// Probing the custom renderers calls them once per line, so only re-resolve
|
|
1657
|
+
// when the lines or renderers change, not on every parent render.
|
|
1533
1658
|
const {
|
|
1534
|
-
chartGapBands,
|
|
1535
1659
|
allRefLines,
|
|
1536
1660
|
refValues,
|
|
1537
1661
|
refLineCustom,
|
|
1538
1662
|
refLineOffAxisCustom,
|
|
1539
1663
|
refLineKeys,
|
|
1540
1664
|
draggableRefIdx,
|
|
1665
|
+
} = useMemo(
|
|
1666
|
+
() =>
|
|
1667
|
+
resolveLiveChartReferenceLines({
|
|
1668
|
+
chartGapsCfg,
|
|
1669
|
+
referenceLines,
|
|
1670
|
+
renderReferenceLine,
|
|
1671
|
+
renderOffAxisReferenceLine,
|
|
1672
|
+
}),
|
|
1673
|
+
[
|
|
1674
|
+
chartGapsCfg,
|
|
1675
|
+
referenceLines,
|
|
1676
|
+
renderReferenceLine,
|
|
1677
|
+
renderOffAxisReferenceLine,
|
|
1678
|
+
],
|
|
1679
|
+
);
|
|
1680
|
+
|
|
1681
|
+
const {
|
|
1541
1682
|
thresholdInRange,
|
|
1542
1683
|
thresholdRangeValueSV,
|
|
1543
1684
|
refGroupingCfg,
|
|
1685
|
+
refStackEnabled,
|
|
1686
|
+
refStackAvoidValueBadge,
|
|
1687
|
+
refStackRadius,
|
|
1688
|
+
refStackReserveBadge,
|
|
1544
1689
|
refGroupingRadius,
|
|
1545
1690
|
refGroupBadge,
|
|
1546
1691
|
refGroupFormat,
|
|
1547
1692
|
badgeUsesRightGutter,
|
|
1548
|
-
} = resolveLiveChartReferenceConfig({
|
|
1549
|
-
chartGapsCfg,
|
|
1550
|
-
referenceLines,
|
|
1551
|
-
renderReferenceLine,
|
|
1552
|
-
renderOffAxisReferenceLine,
|
|
1693
|
+
} = useMemo(() => resolveLiveChartReferenceConfig({
|
|
1553
1694
|
thresholdCfg,
|
|
1554
1695
|
referenceLineGrouping,
|
|
1555
1696
|
badgeCfg,
|
|
1556
|
-
})
|
|
1697
|
+
}), [
|
|
1698
|
+
badgeCfg,
|
|
1699
|
+
referenceLineGrouping,
|
|
1700
|
+
thresholdCfg,
|
|
1701
|
+
]);
|
|
1557
1702
|
|
|
1558
|
-
const { dragValues, dragActive, refLineCustomTagWidths, liveRefValues } =
|
|
1559
|
-
useLiveReferenceState(allRefLines, draggableRefIdx, thresholdRangeValueSV);
|
|
1703
|
+
const { dragValues, dragActive, refLineCustomTagWidths, liveRefValues, refTagSizes, refTagStack, refLiveBadgeRect, activeTagStack, stackObstacle } =
|
|
1704
|
+
useLiveReferenceState(allRefLines, draggableRefIdx, thresholdRangeValueSV, refStackEnabled, refStackReserveBadge);
|
|
1560
1705
|
|
|
1561
1706
|
const {
|
|
1562
1707
|
palette,
|
|
@@ -1569,13 +1714,14 @@ function useLiveChartController({
|
|
|
1569
1714
|
refGroupBadgeFontConfig,
|
|
1570
1715
|
pulseConfig,
|
|
1571
1716
|
timeScrollEnabled,
|
|
1717
|
+
viewportCfg,
|
|
1572
1718
|
returnToLiveMs,
|
|
1573
1719
|
timeScrollOverscroll,
|
|
1574
1720
|
timeScrollFling,
|
|
1575
1721
|
zoomCfg,
|
|
1576
1722
|
zoomEnabled,
|
|
1577
1723
|
yAxisFloat,
|
|
1578
|
-
} = resolveLiveChartPresentationConfig({
|
|
1724
|
+
} = useMemo(() => resolveLiveChartPresentationConfig({
|
|
1579
1725
|
accentColor,
|
|
1580
1726
|
theme,
|
|
1581
1727
|
paletteOverride,
|
|
@@ -1586,11 +1732,28 @@ function useLiveChartController({
|
|
|
1586
1732
|
refGroupBadge,
|
|
1587
1733
|
pulseCfg,
|
|
1588
1734
|
timeScroll,
|
|
1735
|
+
viewport,
|
|
1589
1736
|
isStatic,
|
|
1590
1737
|
returnToLive,
|
|
1591
1738
|
zoom,
|
|
1592
1739
|
yAxisCfg,
|
|
1593
|
-
})
|
|
1740
|
+
}), [
|
|
1741
|
+
accentColor,
|
|
1742
|
+
badgeCfg,
|
|
1743
|
+
fontProp,
|
|
1744
|
+
isStatic,
|
|
1745
|
+
leftEdgeFade,
|
|
1746
|
+
paletteOverride,
|
|
1747
|
+
pulseCfg,
|
|
1748
|
+
refGroupBadge,
|
|
1749
|
+
returnToLive,
|
|
1750
|
+
segments,
|
|
1751
|
+
theme,
|
|
1752
|
+
timeScroll,
|
|
1753
|
+
viewport,
|
|
1754
|
+
yAxisCfg,
|
|
1755
|
+
zoom,
|
|
1756
|
+
]);
|
|
1594
1757
|
|
|
1595
1758
|
const {
|
|
1596
1759
|
skiaFont,
|
|
@@ -1599,6 +1762,8 @@ function useLiveChartController({
|
|
|
1599
1762
|
refGroupBadgeFont,
|
|
1600
1763
|
effectiveYAxisFloat,
|
|
1601
1764
|
setScrolledBack,
|
|
1765
|
+
setYAxisLabelWidth,
|
|
1766
|
+
measureYAxisLabels,
|
|
1602
1767
|
strokeWidth,
|
|
1603
1768
|
padding: effectivePadding,
|
|
1604
1769
|
} = useLiveChartLayoutResources({
|
|
@@ -1617,13 +1782,24 @@ function useLiveChartController({
|
|
|
1617
1782
|
badgeCfg,
|
|
1618
1783
|
metricsCfg,
|
|
1619
1784
|
badgeUsesRightGutter,
|
|
1785
|
+
referenceAxisBadge: allRefLines.some(line => typeof line.valueBadge === "object" && line.valueBadge.position === "axis"),
|
|
1620
1786
|
xAxisCfg,
|
|
1621
1787
|
formatValue,
|
|
1622
1788
|
pulseConfig,
|
|
1623
1789
|
dotCfg,
|
|
1790
|
+
dotOuterRadius,
|
|
1624
1791
|
volumeBandHeight,
|
|
1625
1792
|
});
|
|
1626
1793
|
|
|
1794
|
+
const referenceValueAxis = useMemo(() => ({
|
|
1795
|
+
float: effectiveYAxisFloat,
|
|
1796
|
+
showTail: badgeCfg?.tail ?? true,
|
|
1797
|
+
fontSize: badgeFont.getSize(),
|
|
1798
|
+
metrics: metricsCfg.badge,
|
|
1799
|
+
offsetX: badgeCfg?.offsetX ?? 0,
|
|
1800
|
+
alignTextWithYAxis: badgeCfg?.textAlign === "yAxisColumn" && yAxisCfg?.side !== "left",
|
|
1801
|
+
}), [effectiveYAxisFloat, badgeCfg?.tail, badgeCfg?.offsetX, badgeCfg?.textAlign, badgeFont, metricsCfg.badge, yAxisCfg?.side]);
|
|
1802
|
+
|
|
1627
1803
|
// ── Reveal state ────────────────────────────────────────────
|
|
1628
1804
|
// ≥1 line point or ≥1 committed candle; morphT=1 only when !loading && hasData.
|
|
1629
1805
|
const { hasData } = useLiveChartHasData({
|
|
@@ -1686,6 +1862,7 @@ function useLiveChartController({
|
|
|
1686
1862
|
continuousEffects || loadingActive || !hasData.get() || reveal.morphT.get() < 1,
|
|
1687
1863
|
);
|
|
1688
1864
|
const idleWakeSignal = useDerivedValue<unknown>(() => [theme, accentColor, paletteOverride, metrics, reveal.morphT.get()]);
|
|
1865
|
+
const effectiveYRangeScale = useYAxisScaleValue(yRangeScale);
|
|
1689
1866
|
const engine = useLiveChartEngine({
|
|
1690
1867
|
...engineModeInputs,
|
|
1691
1868
|
value,
|
|
@@ -1699,6 +1876,7 @@ function useLiveChartController({
|
|
|
1699
1876
|
wakeSignal: idleWakeSignal,
|
|
1700
1877
|
snapKey,
|
|
1701
1878
|
scrollEnabled: timeScrollEnabled,
|
|
1879
|
+
viewport: viewportCfg,
|
|
1702
1880
|
allowFutureViewEnd: timeScrollOverscroll > 0,
|
|
1703
1881
|
returnToLiveMs,
|
|
1704
1882
|
smoothing,
|
|
@@ -1709,7 +1887,8 @@ function useLiveChartController({
|
|
|
1709
1887
|
liveReferenceValues: liveRefValues,
|
|
1710
1888
|
nonNegative,
|
|
1711
1889
|
maxValue,
|
|
1712
|
-
|
|
1890
|
+
minRange,
|
|
1891
|
+
yRangeScale: effectiveYRangeScale,
|
|
1713
1892
|
windowBuffer,
|
|
1714
1893
|
nowOverride,
|
|
1715
1894
|
mode,
|
|
@@ -1742,6 +1921,27 @@ function useLiveChartController({
|
|
|
1742
1921
|
// ── Per-frame derived values ───────────────────────────────────────────
|
|
1743
1922
|
const { layoutWidth, layoutHeight, onLayout } = useCanvasLayout(engine);
|
|
1744
1923
|
|
|
1924
|
+
// Draggable reference lines: a per-line vertical pan that grabs a line near its
|
|
1925
|
+
// value and drags it along the Y-axis (with snap / bounds / callbacks). Built
|
|
1926
|
+
// unconditionally for stable hook order (and before `useCrosshair` so the scrub
|
|
1927
|
+
// can defer to a line under the finger); the gesture self-disables when no line
|
|
1928
|
+
// opts in, and it's only composed into the root when `refDragEnabled`. Its
|
|
1929
|
+
// `drawnValues` (the dragged line kept under the finger) is what the lines'
|
|
1930
|
+
// grouping, press hit-test and overlays read; the range fit reads `dragValues`.
|
|
1931
|
+
const {
|
|
1932
|
+
gesture: refDragGesture,
|
|
1933
|
+
hitTest: refDragHitTest,
|
|
1934
|
+
drawnValues: drawnRefValues,
|
|
1935
|
+
} = useReferenceDrag(
|
|
1936
|
+
engine,
|
|
1937
|
+
effectivePadding,
|
|
1938
|
+
allRefLines,
|
|
1939
|
+
dragValues,
|
|
1940
|
+
dragActive,
|
|
1941
|
+
!isStatic,
|
|
1942
|
+
activeTagStack,
|
|
1943
|
+
);
|
|
1944
|
+
|
|
1745
1945
|
const { refGroupResult, groupHidden } = useReferenceLineGrouping({
|
|
1746
1946
|
radius: refGroupingRadius,
|
|
1747
1947
|
engine,
|
|
@@ -1749,7 +1949,7 @@ function useLiveChartController({
|
|
|
1749
1949
|
lines: allRefLines,
|
|
1750
1950
|
custom: refLineCustom,
|
|
1751
1951
|
offAxisCustom: refLineOffAxisCustom,
|
|
1752
|
-
dragValues,
|
|
1952
|
+
dragValues: drawnRefValues,
|
|
1753
1953
|
});
|
|
1754
1954
|
|
|
1755
1955
|
// Threshold split geometry. Two forms, picked at render by `Array.isArray` (no
|
|
@@ -1812,6 +2012,15 @@ function useLiveChartController({
|
|
|
1812
2012
|
lineProp?.simplify,
|
|
1813
2013
|
lineGapsCfg?.gaps,
|
|
1814
2014
|
);
|
|
2015
|
+
// `effectivePadding.bottom` includes the volume band, so this stops at the
|
|
2016
|
+
// price plot's bottom edge.
|
|
2017
|
+
const seriesClip = useDerivedValue(() =>
|
|
2018
|
+
seriesPlotClip(
|
|
2019
|
+
effectivePadding,
|
|
2020
|
+
engine.canvasWidth.get(),
|
|
2021
|
+
engine.canvasHeight.get(),
|
|
2022
|
+
),
|
|
2023
|
+
);
|
|
1815
2024
|
|
|
1816
2025
|
// Area-dots fill shader color as a vec4 (channels 0..1), with the config
|
|
1817
2026
|
// `opacity` folded into the alpha. Defaults to a faint tint of the line/accent
|
|
@@ -1861,7 +2070,7 @@ function useLiveChartController({
|
|
|
1861
2070
|
refDragEnabled,
|
|
1862
2071
|
scrollGestureMode,
|
|
1863
2072
|
scrubHoldMs,
|
|
1864
|
-
} = resolveLiveChartInteractionConfig({
|
|
2073
|
+
} = useMemo(() => resolveLiveChartInteractionConfig({
|
|
1865
2074
|
isCandle,
|
|
1866
2075
|
mode,
|
|
1867
2076
|
candlesEngine,
|
|
@@ -1877,7 +2086,23 @@ function useLiveChartController({
|
|
|
1877
2086
|
timeScroll,
|
|
1878
2087
|
timeScrollEnabled,
|
|
1879
2088
|
scrubCfg,
|
|
1880
|
-
})
|
|
2089
|
+
}), [
|
|
2090
|
+
allRefLines,
|
|
2091
|
+
candleGapsCfg,
|
|
2092
|
+
candleWidth,
|
|
2093
|
+
candlesEngine,
|
|
2094
|
+
isCandle,
|
|
2095
|
+
isStatic,
|
|
2096
|
+
lineGapsCfg,
|
|
2097
|
+
liveEngine,
|
|
2098
|
+
markerCluster,
|
|
2099
|
+
markers,
|
|
2100
|
+
mode,
|
|
2101
|
+
onReferenceLinePress,
|
|
2102
|
+
scrubCfg,
|
|
2103
|
+
timeScroll,
|
|
2104
|
+
timeScrollEnabled,
|
|
2105
|
+
]);
|
|
1881
2106
|
// `projected` is used internally by the hit-test gesture; the overlay
|
|
1882
2107
|
// self-projects, so we only need the gesture + hit-test here. Built BEFORE
|
|
1883
2108
|
// `useCrosshair` so the scrub-action tap can defer to a marker under the finger.
|
|
@@ -1909,32 +2134,24 @@ function useLiveChartController({
|
|
|
1909
2134
|
!isStatic && refPressActive,
|
|
1910
2135
|
markerHitRadius,
|
|
1911
2136
|
onReferenceLinePress,
|
|
1912
|
-
|
|
2137
|
+
drawnRefValues,
|
|
2138
|
+
referenceValueAxis,
|
|
2139
|
+
fontProp,
|
|
2140
|
+
groupHidden,
|
|
2141
|
+
refLineCustom,
|
|
2142
|
+
refLineOffAxisCustom,
|
|
2143
|
+
activeTagStack,
|
|
1913
2144
|
);
|
|
1914
2145
|
|
|
1915
|
-
// Draggable reference lines: a per-line vertical pan that grabs a line near its
|
|
1916
|
-
// value and drags it along the Y-axis (with snap / bounds / callbacks). Built
|
|
1917
|
-
// unconditionally for stable hook order (and before `useCrosshair` so the scrub
|
|
1918
|
-
// can defer to a line under the finger); the gesture self-disables when no line
|
|
1919
|
-
// opts in, and it's only composed into the root when `refDragEnabled`.
|
|
1920
|
-
const { gesture: refDragGesture, hitTest: refDragHitTest } = useReferenceDrag(
|
|
1921
|
-
engine,
|
|
1922
|
-
effectivePadding,
|
|
1923
|
-
allRefLines,
|
|
1924
|
-
dragValues,
|
|
1925
|
-
dragActive,
|
|
1926
|
-
!isStatic,
|
|
1927
|
-
);
|
|
1928
|
-
|
|
1929
2146
|
// Combined "defer" hit-test: the scrub-action place-tap and the live scrub both
|
|
1930
2147
|
// yield to a marker, a pressable badge, or a draggable line under the finger — so
|
|
1931
2148
|
// a press there is routed to that overlay / drag instead of dropping a reticle or
|
|
1932
2149
|
// crosshair. (Each hit-test returns false when its feature is off.)
|
|
1933
2150
|
/* istanbul ignore next -- worklet runs on the UI thread, not in Jest */
|
|
1934
|
-
const deferTapHit = (x: number, y: number): boolean => {
|
|
2151
|
+
const deferTapHit = useCallback((x: number, y: number): boolean => {
|
|
1935
2152
|
"worklet";
|
|
1936
2153
|
return markerHitTest(x, y) || refLineHitTest(x, y) || refDragHitTest(x, y);
|
|
1937
|
-
};
|
|
2154
|
+
}, [markerHitTest, refLineHitTest, refDragHitTest]);
|
|
1938
2155
|
|
|
1939
2156
|
// Cross-gesture arbitration for the one-finger touch. `Gesture.Race` below is
|
|
1940
2157
|
// NOT arbitration — RNGH's Race adds no relation between its children, so both
|
|
@@ -1943,6 +2160,7 @@ function useLiveChartController({
|
|
|
1943
2160
|
// long-press guard) makes "the scroll already won" a hard fact; `scrubActive`
|
|
1944
2161
|
// (written by the crosshair, read by the scroll pan) is the mirror image.
|
|
1945
2162
|
const scrollActive = useSharedValue(false);
|
|
2163
|
+
const axisScaleActive = useSharedValue(false);
|
|
1946
2164
|
|
|
1947
2165
|
const crosshairSettings = resolveCrosshairControllerSettings({
|
|
1948
2166
|
scrubCfg,
|
|
@@ -1984,6 +2202,9 @@ function useLiveChartController({
|
|
|
1984
2202
|
scrollActive,
|
|
1985
2203
|
crosshairSettings.clampToPlot,
|
|
1986
2204
|
crosshairSettings.snapToCandles,
|
|
2205
|
+
onScrubCandleChange,
|
|
2206
|
+
resolveScrubMarkerOptions(scrubCfg, markersSV),
|
|
2207
|
+
axisScaleActive,
|
|
1987
2208
|
);
|
|
1988
2209
|
|
|
1989
2210
|
// Capture only the shared value in the worklets below. Referencing
|
|
@@ -2007,11 +2228,16 @@ function useLiveChartController({
|
|
|
2007
2228
|
const src = isCandle ? candlesEngine.get() : lineEngineData.get();
|
|
2008
2229
|
return src.length > 0 ? src[0].time : engine.liveEdge.get();
|
|
2009
2230
|
});
|
|
2231
|
+
const clearCrosshair = useCallback(() => {
|
|
2232
|
+
"worklet";
|
|
2233
|
+
crosshairScrubActive.set(false);
|
|
2234
|
+
}, [crosshairScrubActive]);
|
|
2010
2235
|
const panScrollGesture = usePanScroll({
|
|
2011
2236
|
engine,
|
|
2012
2237
|
padding: effectivePadding,
|
|
2013
2238
|
minTime: scrollMinTime,
|
|
2014
2239
|
enabled: timeScrollEnabled,
|
|
2240
|
+
clampOnOverscrollChange: viewportCfg === null,
|
|
2015
2241
|
mode: scrollGestureMode,
|
|
2016
2242
|
overscroll: timeScrollOverscroll,
|
|
2017
2243
|
fling: timeScrollFling,
|
|
@@ -2020,10 +2246,7 @@ function useLiveChartController({
|
|
|
2020
2246
|
// finger only moves the price indicator across a fixed window.
|
|
2021
2247
|
scrubActive: crosshairScrubActive,
|
|
2022
2248
|
// Clear any live crosshair when a scroll drag takes over.
|
|
2023
|
-
onScrollStart:
|
|
2024
|
-
"worklet";
|
|
2025
|
-
crosshairScrubActive.set(false);
|
|
2026
|
-
},
|
|
2249
|
+
onScrollStart: clearCrosshair,
|
|
2027
2250
|
});
|
|
2028
2251
|
|
|
2029
2252
|
// Pinch-to-zoom the visible window (two-finger). Anchors at the focal point and
|
|
@@ -2038,14 +2261,12 @@ function useLiveChartController({
|
|
|
2038
2261
|
minTimeWindow: zoomCfg?.minTimeWindow,
|
|
2039
2262
|
maxTimeWindow: zoomCfg?.maxTimeWindow,
|
|
2040
2263
|
overscroll: timeScrollOverscroll,
|
|
2041
|
-
onZoomStart:
|
|
2042
|
-
"worklet";
|
|
2043
|
-
crosshairScrubActive.set(false);
|
|
2044
|
-
},
|
|
2264
|
+
onZoomStart: clearCrosshair,
|
|
2045
2265
|
});
|
|
2046
2266
|
|
|
2047
2267
|
const axisAutoHideOpacity = useAxisAutoHide({
|
|
2048
2268
|
config: axisAutoHide,
|
|
2269
|
+
scaleActive: axisScaleActive,
|
|
2049
2270
|
scrollActive,
|
|
2050
2271
|
scrubActive: crosshairScrubActive,
|
|
2051
2272
|
engine,
|
|
@@ -2064,8 +2285,11 @@ function useLiveChartController({
|
|
|
2064
2285
|
// ahead of the pan via Exclusive, so a tap is tried first and only becomes a
|
|
2065
2286
|
// drag (live-scrub, or lock-adjust once placed) if the finger moves. `Exclusive`
|
|
2066
2287
|
// (not `Race`) prevents a jittery tap from being swallowed by the pan.
|
|
2067
|
-
const
|
|
2068
|
-
|
|
2288
|
+
const crosshairGesture = crosshair.gesture;
|
|
2289
|
+
const crosshairTapGesture = crosshair.tapGesture;
|
|
2290
|
+
const rootGesture = useMemo(() => composeLiveChartRootGesture({
|
|
2291
|
+
crosshairGesture,
|
|
2292
|
+
crosshairTapGesture,
|
|
2069
2293
|
markerTapGesture,
|
|
2070
2294
|
refLineTapGesture,
|
|
2071
2295
|
refDragGesture,
|
|
@@ -2078,7 +2302,22 @@ function useLiveChartController({
|
|
|
2078
2302
|
timeScrollEnabled,
|
|
2079
2303
|
scrollGestureMode,
|
|
2080
2304
|
zoomEnabled,
|
|
2081
|
-
})
|
|
2305
|
+
}), [
|
|
2306
|
+
crosshairGesture,
|
|
2307
|
+
crosshairTapGesture,
|
|
2308
|
+
markerTapGesture,
|
|
2309
|
+
markersActive,
|
|
2310
|
+
panScrollGesture,
|
|
2311
|
+
pinchZoomGesture,
|
|
2312
|
+
refDragEnabled,
|
|
2313
|
+
refDragGesture,
|
|
2314
|
+
refLineTapGesture,
|
|
2315
|
+
refPressActive,
|
|
2316
|
+
scrollGestureMode,
|
|
2317
|
+
scrubActionCfg,
|
|
2318
|
+
timeScrollEnabled,
|
|
2319
|
+
zoomEnabled,
|
|
2320
|
+
]);
|
|
2082
2321
|
|
|
2083
2322
|
// ── Derived render values ──────────────────────────────────────────────
|
|
2084
2323
|
const {
|
|
@@ -2130,6 +2369,15 @@ function useLiveChartController({
|
|
|
2130
2369
|
viewEnd: engine.viewEnd,
|
|
2131
2370
|
fadeOverlaysOnScrub,
|
|
2132
2371
|
});
|
|
2372
|
+
useReferenceTagStack({
|
|
2373
|
+
enabled: refStackEnabled, radius: refStackRadius,
|
|
2374
|
+
engine, padding: effectivePadding, lines: allRefLines, keys: refLineKeys,
|
|
2375
|
+
custom: refLineCustom, offAxisCustom: refLineOffAxisCustom,
|
|
2376
|
+
customSizes: refTagSizes, font: skiaFont, fontProp, formatValue,
|
|
2377
|
+
dragValues: drawnRefValues, valueAxis: referenceValueAxis,
|
|
2378
|
+
obstacle: stackObstacle,
|
|
2379
|
+
output: refTagStack,
|
|
2380
|
+
});
|
|
2133
2381
|
const modelDefaults = resolveLiveChartModelDefaults({
|
|
2134
2382
|
isCandle,
|
|
2135
2383
|
candleWidth,
|
|
@@ -2140,6 +2388,10 @@ function useLiveChartController({
|
|
|
2140
2388
|
});
|
|
2141
2389
|
|
|
2142
2390
|
return {
|
|
2391
|
+
effectiveYRangeScale,
|
|
2392
|
+
axisScaleActive,
|
|
2393
|
+
deferAxisScaleHit: deferTapHit,
|
|
2394
|
+
clearCrosshair,
|
|
2143
2395
|
// passthrough props the render needs
|
|
2144
2396
|
style,
|
|
2145
2397
|
canvasMode,
|
|
@@ -2159,6 +2411,9 @@ function useLiveChartController({
|
|
|
2159
2411
|
// configs
|
|
2160
2412
|
yAxisCfg,
|
|
2161
2413
|
yAxisFloat: effectiveYAxisFloat,
|
|
2414
|
+
setYAxisLabelWidth,
|
|
2415
|
+
measureYAxisLabels,
|
|
2416
|
+
referenceValueAxis,
|
|
2162
2417
|
xAxisCfg,
|
|
2163
2418
|
badgeCfg,
|
|
2164
2419
|
scrubCfg,
|
|
@@ -2172,6 +2427,7 @@ function useLiveChartController({
|
|
|
2172
2427
|
dotTracksParked,
|
|
2173
2428
|
dotOuterRadius,
|
|
2174
2429
|
gridStyleCfg,
|
|
2430
|
+
xGridStyleCfg,
|
|
2175
2431
|
degenCfg,
|
|
2176
2432
|
tradeStreamResolved,
|
|
2177
2433
|
tradeStream,
|
|
@@ -2182,11 +2438,12 @@ function useLiveChartController({
|
|
|
2182
2438
|
refLineCustom,
|
|
2183
2439
|
refLineOffAxisCustom,
|
|
2184
2440
|
refLineCustomTagWidths,
|
|
2185
|
-
dragValues,
|
|
2441
|
+
dragValues: drawnRefValues,
|
|
2186
2442
|
dragActive,
|
|
2187
2443
|
renderReferenceLine,
|
|
2188
2444
|
renderOffAxisReferenceLine,
|
|
2189
2445
|
refGroupingActive: refGroupingRadius != null,
|
|
2446
|
+
refStackEnabled, refStackAvoidValueBadge, refTagSizes, refTagStack, refLiveBadgeRect,
|
|
2190
2447
|
refGroupResult,
|
|
2191
2448
|
groupHidden,
|
|
2192
2449
|
refGroupBadge,
|
|
@@ -2244,6 +2501,7 @@ function useLiveChartController({
|
|
|
2244
2501
|
linePath,
|
|
2245
2502
|
fillPath,
|
|
2246
2503
|
thresholdFillPath,
|
|
2504
|
+
seriesClip,
|
|
2247
2505
|
lineIsLinear,
|
|
2248
2506
|
volumeCfg,
|
|
2249
2507
|
candleGapsCfg,
|
|
@@ -2284,15 +2542,18 @@ function useLiveChartController({
|
|
|
2284
2542
|
type LiveChartModel = ReturnType<typeof useLiveChartController>;
|
|
2285
2543
|
|
|
2286
2544
|
type YAxisEntries = ReturnType<typeof useYAxis>["yAxisEntries"];
|
|
2545
|
+
type XAxisEntries = ReturnType<typeof useXAxis>["xAxisEntries"];
|
|
2287
2546
|
type DegenState = ReturnType<typeof useDegen>;
|
|
2288
2547
|
|
|
2289
2548
|
/** Owns the particle/shake state only while the degen effect is enabled. */
|
|
2290
2549
|
function ChartWithDegen({
|
|
2291
2550
|
model,
|
|
2292
2551
|
yAxisEntries,
|
|
2552
|
+
xAxisEntries,
|
|
2293
2553
|
}: {
|
|
2294
2554
|
model: LiveChartModel;
|
|
2295
2555
|
yAxisEntries: YAxisEntries | null;
|
|
2556
|
+
xAxisEntries: XAxisEntries | null;
|
|
2296
2557
|
}) {
|
|
2297
2558
|
const {
|
|
2298
2559
|
engine,
|
|
@@ -2312,7 +2573,61 @@ function ChartWithDegen({
|
|
|
2312
2573
|
onDegenShake,
|
|
2313
2574
|
isFrameLoopActive,
|
|
2314
2575
|
);
|
|
2315
|
-
return
|
|
2576
|
+
return (
|
|
2577
|
+
<ChartView
|
|
2578
|
+
model={model}
|
|
2579
|
+
yAxisEntries={yAxisEntries}
|
|
2580
|
+
xAxisEntries={xAxisEntries}
|
|
2581
|
+
degen={state}
|
|
2582
|
+
/>
|
|
2583
|
+
);
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
/**
|
|
2587
|
+
* Owns the X-axis worklet, like {@link ChartWithYAxis} for the Y axis: mounted
|
|
2588
|
+
* only while the axis is enabled, and its entries are passed through props so
|
|
2589
|
+
* the vertical grid (behind the series) and the labels (above it) read the
|
|
2590
|
+
* same mapper.
|
|
2591
|
+
*/
|
|
2592
|
+
function ChartWithXAxis({ model }: { model: LiveChartModel }) {
|
|
2593
|
+
const { engine, effectivePadding, formatTime, skiaFont, xAxisCfg } = model;
|
|
2594
|
+
const { xAxisEntries } = useXAxis(
|
|
2595
|
+
engine,
|
|
2596
|
+
effectivePadding,
|
|
2597
|
+
formatTime,
|
|
2598
|
+
skiaFont,
|
|
2599
|
+
xAxisCfg?.minGap,
|
|
2600
|
+
);
|
|
2601
|
+
return <ChartWithYAxisOrDegen model={model} xAxisEntries={xAxisEntries} />;
|
|
2602
|
+
}
|
|
2603
|
+
|
|
2604
|
+
function ChartWithYAxisOrDegen({
|
|
2605
|
+
model,
|
|
2606
|
+
xAxisEntries,
|
|
2607
|
+
}: {
|
|
2608
|
+
model: LiveChartModel;
|
|
2609
|
+
xAxisEntries: XAxisEntries | null;
|
|
2610
|
+
}) {
|
|
2611
|
+
if (model.yAxisCfg) {
|
|
2612
|
+
return <ChartWithYAxis model={model} xAxisEntries={xAxisEntries} />;
|
|
2613
|
+
}
|
|
2614
|
+
if (model.degenCfg) {
|
|
2615
|
+
return (
|
|
2616
|
+
<ChartWithDegen
|
|
2617
|
+
model={model}
|
|
2618
|
+
yAxisEntries={null}
|
|
2619
|
+
xAxisEntries={xAxisEntries}
|
|
2620
|
+
/>
|
|
2621
|
+
);
|
|
2622
|
+
}
|
|
2623
|
+
return (
|
|
2624
|
+
<ChartView
|
|
2625
|
+
model={model}
|
|
2626
|
+
yAxisEntries={null}
|
|
2627
|
+
xAxisEntries={xAxisEntries}
|
|
2628
|
+
degen={null}
|
|
2629
|
+
/>
|
|
2630
|
+
);
|
|
2316
2631
|
}
|
|
2317
2632
|
|
|
2318
2633
|
/**
|
|
@@ -2321,7 +2636,13 @@ function ChartWithDegen({
|
|
|
2321
2636
|
* The entries are passed through ordinary props so both paint-order positions
|
|
2322
2637
|
* receive the same mapper across the React Native → Skia renderer boundary.
|
|
2323
2638
|
*/
|
|
2324
|
-
function ChartWithYAxis({
|
|
2639
|
+
function ChartWithYAxis({
|
|
2640
|
+
model,
|
|
2641
|
+
xAxisEntries,
|
|
2642
|
+
}: {
|
|
2643
|
+
model: LiveChartModel;
|
|
2644
|
+
xAxisEntries: XAxisEntries | null;
|
|
2645
|
+
}) {
|
|
2325
2646
|
const {
|
|
2326
2647
|
engine,
|
|
2327
2648
|
effectivePadding,
|
|
@@ -2340,10 +2661,24 @@ function ChartWithYAxis({ model }: { model: LiveChartModel }) {
|
|
|
2340
2661
|
yAxisCfg?.count ?? 0,
|
|
2341
2662
|
yAxisCfg?.intervalScale ?? 1,
|
|
2342
2663
|
);
|
|
2664
|
+
useYAxisLabelWidth(yAxisEntries, skiaFont, model.measureYAxisLabels, model.setYAxisLabelWidth);
|
|
2343
2665
|
if (model.degenCfg) {
|
|
2344
|
-
return
|
|
2666
|
+
return (
|
|
2667
|
+
<ChartWithDegen
|
|
2668
|
+
model={model}
|
|
2669
|
+
yAxisEntries={yAxisEntries}
|
|
2670
|
+
xAxisEntries={xAxisEntries}
|
|
2671
|
+
/>
|
|
2672
|
+
);
|
|
2345
2673
|
}
|
|
2346
|
-
return
|
|
2674
|
+
return (
|
|
2675
|
+
<ChartView
|
|
2676
|
+
model={model}
|
|
2677
|
+
yAxisEntries={yAxisEntries}
|
|
2678
|
+
xAxisEntries={xAxisEntries}
|
|
2679
|
+
degen={null}
|
|
2680
|
+
/>
|
|
2681
|
+
);
|
|
2347
2682
|
}
|
|
2348
2683
|
|
|
2349
2684
|
function ChartYAxisLayer({
|
|
@@ -2404,27 +2739,21 @@ function ChartYAxisLayer({
|
|
|
2404
2739
|
);
|
|
2405
2740
|
}
|
|
2406
2741
|
|
|
2407
|
-
/**
|
|
2408
|
-
function ChartXAxisLayer({
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
const { xAxisEntries } = useXAxis(
|
|
2418
|
-
engine,
|
|
2419
|
-
effectivePadding,
|
|
2420
|
-
formatTime,
|
|
2421
|
-
skiaFont,
|
|
2422
|
-
);
|
|
2742
|
+
/** The X-axis line, ticks, and labels, drawn above the series. */
|
|
2743
|
+
function ChartXAxisLayer({
|
|
2744
|
+
model,
|
|
2745
|
+
entries,
|
|
2746
|
+
}: {
|
|
2747
|
+
model: LiveChartModel;
|
|
2748
|
+
entries: XAxisEntries;
|
|
2749
|
+
}) {
|
|
2750
|
+
const { engine, effectivePadding, skiaFont, palette, volumeBandHeight } =
|
|
2751
|
+
model;
|
|
2423
2752
|
return (
|
|
2424
2753
|
// Axis auto-hide fade (1 when the feature is off).
|
|
2425
2754
|
<Group opacity={model.axisAutoHideOpacity}>
|
|
2426
2755
|
<XAxisOverlay
|
|
2427
|
-
entries={
|
|
2756
|
+
entries={entries}
|
|
2428
2757
|
engine={engine}
|
|
2429
2758
|
padding={effectivePadding}
|
|
2430
2759
|
palette={palette}
|
|
@@ -2436,22 +2765,30 @@ function ChartXAxisLayer({ model }: { model: LiveChartModel }) {
|
|
|
2436
2765
|
}
|
|
2437
2766
|
|
|
2438
2767
|
/**
|
|
2439
|
-
* Background fills drawn BENEATH the left-edge fade: the
|
|
2440
|
-
* gradient, and the threshold profit/loss band. Split out
|
|
2441
|
-
* the fade's `dstOut` only softens the fills — the line
|
|
2442
|
-
* (drawn in `ChartStack`, after the fade) stay crisp at
|
|
2768
|
+
* Background fills drawn BENEATH the left-edge fade: the grid (both
|
|
2769
|
+
* directions), the area gradient, and the threshold profit/loss band. Split out
|
|
2770
|
+
* from `ChartStack` so the fade's `dstOut` only softens the fills — the line
|
|
2771
|
+
* and everything above it (drawn in `ChartStack`, after the fade) stay crisp at
|
|
2772
|
+
* the left edge.
|
|
2443
2773
|
*/
|
|
2444
2774
|
function ChartFillLayer({
|
|
2445
2775
|
model,
|
|
2446
2776
|
yAxisEntries,
|
|
2777
|
+
xAxisEntries,
|
|
2447
2778
|
degen,
|
|
2448
2779
|
}: {
|
|
2449
2780
|
model: LiveChartModel;
|
|
2450
2781
|
yAxisEntries: YAxisEntries | null;
|
|
2782
|
+
xAxisEntries: XAxisEntries | null;
|
|
2451
2783
|
degen: DegenState | null;
|
|
2452
2784
|
}) {
|
|
2453
2785
|
const {
|
|
2454
2786
|
yAxisCfg,
|
|
2787
|
+
xGridStyleCfg,
|
|
2788
|
+
engine,
|
|
2789
|
+
palette,
|
|
2790
|
+
volumeBandHeight,
|
|
2791
|
+
axisAutoHideOpacity,
|
|
2455
2792
|
yAxisFloat,
|
|
2456
2793
|
reveal,
|
|
2457
2794
|
effectivePadding,
|
|
@@ -2470,6 +2807,7 @@ function ChartFillLayer({
|
|
|
2470
2807
|
thresholdSeriesHasPoints,
|
|
2471
2808
|
thresholdFillUniforms,
|
|
2472
2809
|
seriesOpacity,
|
|
2810
|
+
seriesClip,
|
|
2473
2811
|
} = model;
|
|
2474
2812
|
return (
|
|
2475
2813
|
<Group transform={degen?.shakeTransform}>
|
|
@@ -2484,7 +2822,22 @@ function ChartFillLayer({
|
|
|
2484
2822
|
/>
|
|
2485
2823
|
)}
|
|
2486
2824
|
|
|
2487
|
-
|
|
2825
|
+
{/* Vertical grid at the time ticks (`xAxis.gridLines`). It fades with
|
|
2826
|
+
the X axis under `axisAutoHide`; its labels draw in ChartStack. */}
|
|
2827
|
+
{xGridStyleCfg && xAxisEntries ? (
|
|
2828
|
+
<Group opacity={axisAutoHideOpacity}>
|
|
2829
|
+
<XAxisGridLines
|
|
2830
|
+
entries={xAxisEntries}
|
|
2831
|
+
engine={engine}
|
|
2832
|
+
padding={effectivePadding}
|
|
2833
|
+
palette={palette}
|
|
2834
|
+
gridStyle={xGridStyleCfg}
|
|
2835
|
+
volumeBandHeight={volumeBandHeight}
|
|
2836
|
+
/>
|
|
2837
|
+
</Group>
|
|
2838
|
+
) : null}
|
|
2839
|
+
|
|
2840
|
+
<Group opacity={seriesOpacity} clip={seriesClip}>
|
|
2488
2841
|
{/* Dot-lattice area fill (the under-line `fillPath` painted with a dot
|
|
2489
2842
|
shader). Drawn before the gradient so a gradient (if also enabled)
|
|
2490
2843
|
composites on top. */}
|
|
@@ -2712,6 +3065,7 @@ function ChartCandleLayer({ model }: { model: LiveChartModel }) {
|
|
|
2712
3065
|
candleGapsCfg,
|
|
2713
3066
|
scrubCfg,
|
|
2714
3067
|
crosshair,
|
|
3068
|
+
seriesClip,
|
|
2715
3069
|
} = model;
|
|
2716
3070
|
const paths = useCandlePaths(
|
|
2717
3071
|
engine,
|
|
@@ -2822,7 +3176,7 @@ function ChartCandleLayer({ model }: { model: LiveChartModel }) {
|
|
|
2822
3176
|
|
|
2823
3177
|
return (
|
|
2824
3178
|
<Group opacity={seriesOpacity}>
|
|
2825
|
-
<Group opacity={candleGroupOpacity}>
|
|
3179
|
+
<Group opacity={candleGroupOpacity} clip={seriesClip}>
|
|
2826
3180
|
{candleGapsCfg && (
|
|
2827
3181
|
<ChartCandleGapLayer
|
|
2828
3182
|
model={model}
|
|
@@ -2932,9 +3286,11 @@ function ChartLineStrokeShader({ model }: { model: LiveChartModel }) {
|
|
|
2932
3286
|
function ChartMainPlotLayer({
|
|
2933
3287
|
model,
|
|
2934
3288
|
yAxisEntries,
|
|
3289
|
+
xAxisEntries,
|
|
2935
3290
|
}: {
|
|
2936
3291
|
model: LiveChartModel;
|
|
2937
3292
|
yAxisEntries: YAxisEntries | null;
|
|
3293
|
+
xAxisEntries: XAxisEntries | null;
|
|
2938
3294
|
}) {
|
|
2939
3295
|
const {
|
|
2940
3296
|
engine,
|
|
@@ -2947,14 +3303,14 @@ function ChartMainPlotLayer({
|
|
|
2947
3303
|
strokeWidth,
|
|
2948
3304
|
lineProp,
|
|
2949
3305
|
isCandle,
|
|
2950
|
-
xAxisCfg,
|
|
2951
3306
|
yAxisCfg,
|
|
2952
3307
|
yAxisFloat,
|
|
3308
|
+
seriesClip,
|
|
2953
3309
|
} = model;
|
|
2954
3310
|
|
|
2955
3311
|
return (
|
|
2956
3312
|
<>
|
|
2957
|
-
<Group opacity={seriesOpacity}>
|
|
3313
|
+
<Group opacity={seriesOpacity} clip={seriesClip}>
|
|
2958
3314
|
<Group opacity={lineGroupOpacity}>
|
|
2959
3315
|
<Path
|
|
2960
3316
|
path={linePath}
|
|
@@ -2979,7 +3335,9 @@ function ChartMainPlotLayer({
|
|
|
2979
3335
|
entries={yAxisEntries!}
|
|
2980
3336
|
/>
|
|
2981
3337
|
) : null}
|
|
2982
|
-
{
|
|
3338
|
+
{xAxisEntries ? (
|
|
3339
|
+
<ChartXAxisLayer model={model} entries={xAxisEntries} />
|
|
3340
|
+
) : null}
|
|
2983
3341
|
</>
|
|
2984
3342
|
);
|
|
2985
3343
|
}
|
|
@@ -2991,10 +3349,12 @@ function ChartMainPlotLayer({
|
|
|
2991
3349
|
function ChartStack({
|
|
2992
3350
|
model,
|
|
2993
3351
|
yAxisEntries,
|
|
3352
|
+
xAxisEntries,
|
|
2994
3353
|
degen,
|
|
2995
3354
|
}: {
|
|
2996
3355
|
model: LiveChartModel;
|
|
2997
3356
|
yAxisEntries: YAxisEntries | null;
|
|
3357
|
+
xAxisEntries: XAxisEntries | null;
|
|
2998
3358
|
degen: DegenState | null;
|
|
2999
3359
|
}) {
|
|
3000
3360
|
const {
|
|
@@ -3100,6 +3460,7 @@ function ChartStack({
|
|
|
3100
3460
|
engine={engine}
|
|
3101
3461
|
padding={effectivePadding}
|
|
3102
3462
|
line={rl}
|
|
3463
|
+
valueAxis={model.referenceValueAxis}
|
|
3103
3464
|
palette={palette}
|
|
3104
3465
|
formatValue={formatValue}
|
|
3105
3466
|
font={skiaFont}
|
|
@@ -3130,7 +3491,11 @@ function ChartStack({
|
|
|
3130
3491
|
/>
|
|
3131
3492
|
)}
|
|
3132
3493
|
|
|
3133
|
-
<ChartMainPlotLayer
|
|
3494
|
+
<ChartMainPlotLayer
|
|
3495
|
+
model={model}
|
|
3496
|
+
yAxisEntries={yAxisEntries}
|
|
3497
|
+
xAxisEntries={xAxisEntries}
|
|
3498
|
+
/>
|
|
3134
3499
|
|
|
3135
3500
|
{/* Live dot — the badge is drawn later (after the scrub layer) so the
|
|
3136
3501
|
scrub dim never clips the live-price badge's left edge. Hidden while
|
|
@@ -3442,9 +3807,11 @@ function ChartValueOverlay({
|
|
|
3442
3807
|
function ChartBadgeLayer({
|
|
3443
3808
|
model,
|
|
3444
3809
|
degen,
|
|
3810
|
+
yAxisEntries,
|
|
3445
3811
|
}: {
|
|
3446
3812
|
model: LiveChartModel;
|
|
3447
3813
|
degen: DegenState | null;
|
|
3814
|
+
yAxisEntries: YAxisEntries | null;
|
|
3448
3815
|
}) {
|
|
3449
3816
|
const {
|
|
3450
3817
|
badgeFont,
|
|
@@ -3456,8 +3823,27 @@ function ChartBadgeLayer({
|
|
|
3456
3823
|
metricsCfg,
|
|
3457
3824
|
yAxisFloat,
|
|
3458
3825
|
liveBadgeOpacity,
|
|
3826
|
+
skiaFont,
|
|
3827
|
+
yAxisCfg,
|
|
3828
|
+
badgeUsesRightGutter,
|
|
3459
3829
|
} = model;
|
|
3460
3830
|
const badgeCfg = model.badgeCfg!;
|
|
3831
|
+
// textAlign "yAxisColumn": hand the right-gutter badge the label column only
|
|
3832
|
+
// while YAxisOverlay draws one (right side + labelRightMargin, axis not
|
|
3833
|
+
// floating), so other charts' badges get no extra mapper input.
|
|
3834
|
+
const labelColumn =
|
|
3835
|
+
badgeCfg.textAlign === "yAxisColumn" &&
|
|
3836
|
+
badgeUsesRightGutter &&
|
|
3837
|
+
!yAxisFloat &&
|
|
3838
|
+
yAxisEntries &&
|
|
3839
|
+
yAxisCfg?.side !== "left" &&
|
|
3840
|
+
yAxisCfg?.labelRightMargin !== undefined
|
|
3841
|
+
? {
|
|
3842
|
+
entries: yAxisEntries,
|
|
3843
|
+
labelRightMargin: yAxisCfg.labelRightMargin,
|
|
3844
|
+
font: skiaFont,
|
|
3845
|
+
}
|
|
3846
|
+
: null;
|
|
3461
3847
|
const badgeData = useBadge(
|
|
3462
3848
|
engine,
|
|
3463
3849
|
effectivePadding,
|
|
@@ -3476,7 +3862,18 @@ function ChartBadgeLayer({
|
|
|
3476
3862
|
badgeCfg.followViewEdge,
|
|
3477
3863
|
badgeCfg.radius,
|
|
3478
3864
|
badgeCfg.textColor,
|
|
3865
|
+
labelColumn?.entries,
|
|
3866
|
+
labelColumn?.labelRightMargin,
|
|
3867
|
+
labelColumn?.font,
|
|
3479
3868
|
);
|
|
3869
|
+
const { refStackEnabled, refStackAvoidValueBadge, refLiveBadgeRect } = model;
|
|
3870
|
+
useAnimatedReaction(() => {
|
|
3871
|
+
if (!refStackEnabled || !refStackAvoidValueBadge || liveBadgeOpacity.get() <= 0) return null;
|
|
3872
|
+
const rect = badgeData.get().path.getBounds();
|
|
3873
|
+
return { x: rect.x + (badgeCfg.offsetX ?? 0), y: rect.y + (badgeCfg.offsetY ?? 0), w: rect.width, h: rect.height };
|
|
3874
|
+
}, (next, prev) => {
|
|
3875
|
+
if (next?.x !== prev?.x || next?.y !== prev?.y || next?.w !== prev?.w || next?.h !== prev?.h) refLiveBadgeRect.set(next);
|
|
3876
|
+
});
|
|
3480
3877
|
return (
|
|
3481
3878
|
<Group transform={degen?.shakeTransform}>
|
|
3482
3879
|
<Group opacity={liveBadgeOpacity}>
|
|
@@ -3537,6 +3934,7 @@ function ChartRefBadgeLayer({
|
|
|
3537
3934
|
engine={engine}
|
|
3538
3935
|
padding={effectivePadding}
|
|
3539
3936
|
line={rl}
|
|
3937
|
+
valueAxis={model.referenceValueAxis}
|
|
3540
3938
|
palette={palette}
|
|
3541
3939
|
formatValue={formatValue}
|
|
3542
3940
|
font={skiaFont}
|
|
@@ -3547,6 +3945,7 @@ function ChartRefBadgeLayer({
|
|
|
3547
3945
|
suppressTag={refLineCustom[i]}
|
|
3548
3946
|
suppressTagWhenOffAxis={refLineOffAxisCustom[i]}
|
|
3549
3947
|
customTagWidths={refLineCustomTagWidths}
|
|
3948
|
+
tagStack={model.refStackEnabled ? model.refTagStack : undefined}
|
|
3550
3949
|
groupHidden={refGroupingActive ? groupHidden : undefined}
|
|
3551
3950
|
yAxisEntries={yAxisEntries}
|
|
3552
3951
|
labelRightMargin={yAxisCfg?.labelRightMargin}
|
|
@@ -3664,6 +4063,8 @@ function ChartCustomAnnotations({ model }: { model: LiveChartModel }) {
|
|
|
3664
4063
|
dragValues={dragValues}
|
|
3665
4064
|
dragActive={dragActive}
|
|
3666
4065
|
tagWidths={refLineCustomTagWidths}
|
|
4066
|
+
tagSizes={model.refStackEnabled ? model.refTagSizes : undefined}
|
|
4067
|
+
tagStack={model.refStackEnabled ? model.refTagStack : undefined}
|
|
3667
4068
|
/>
|
|
3668
4069
|
)}
|
|
3669
4070
|
{renderOffAxisReferenceLine && allRefLines.length > 0 && (
|
|
@@ -3677,6 +4078,8 @@ function ChartCustomAnnotations({ model }: { model: LiveChartModel }) {
|
|
|
3677
4078
|
dragValues={dragValues}
|
|
3678
4079
|
dragActive={dragActive}
|
|
3679
4080
|
tagWidths={refLineCustomTagWidths}
|
|
4081
|
+
tagSizes={model.refStackEnabled ? model.refTagSizes : undefined}
|
|
4082
|
+
tagStack={model.refStackEnabled ? model.refTagStack : undefined}
|
|
3680
4083
|
offAxisOnly
|
|
3681
4084
|
/>
|
|
3682
4085
|
)}
|
|
@@ -3694,10 +4097,12 @@ function ChartCustomConsumerOverlay({ model }: { model: LiveChartModel }) {
|
|
|
3694
4097
|
function ChartCanvas({
|
|
3695
4098
|
model,
|
|
3696
4099
|
yAxisEntries,
|
|
4100
|
+
xAxisEntries,
|
|
3697
4101
|
degen,
|
|
3698
4102
|
}: {
|
|
3699
4103
|
model: LiveChartModel;
|
|
3700
4104
|
yAxisEntries: YAxisEntries | null;
|
|
4105
|
+
xAxisEntries: XAxisEntries | null;
|
|
3701
4106
|
degen: DegenState | null;
|
|
3702
4107
|
}) {
|
|
3703
4108
|
const {
|
|
@@ -3728,7 +4133,12 @@ function ChartCanvas({
|
|
|
3728
4133
|
color={backgroundColor}
|
|
3729
4134
|
/>
|
|
3730
4135
|
) : null}
|
|
3731
|
-
<ChartFillLayer
|
|
4136
|
+
<ChartFillLayer
|
|
4137
|
+
model={model}
|
|
4138
|
+
yAxisEntries={yAxisEntries}
|
|
4139
|
+
xAxisEntries={xAxisEntries}
|
|
4140
|
+
degen={degen}
|
|
4141
|
+
/>
|
|
3732
4142
|
{leftEdgeFadeCfg ? (
|
|
3733
4143
|
<LeftEdgeFade
|
|
3734
4144
|
paddingLeft={effectivePadding.left}
|
|
@@ -3741,7 +4151,12 @@ function ChartCanvas({
|
|
|
3741
4151
|
}
|
|
3742
4152
|
/>
|
|
3743
4153
|
) : null}
|
|
3744
|
-
<ChartStack
|
|
4154
|
+
<ChartStack
|
|
4155
|
+
model={model}
|
|
4156
|
+
yAxisEntries={yAxisEntries}
|
|
4157
|
+
xAxisEntries={xAxisEntries}
|
|
4158
|
+
degen={degen}
|
|
4159
|
+
/>
|
|
3745
4160
|
{topConnector || bottomConnector ? (
|
|
3746
4161
|
<ExtremaConnectorOverlay
|
|
3747
4162
|
engine={engine}
|
|
@@ -3766,7 +4181,13 @@ function ChartCanvas({
|
|
|
3766
4181
|
<ChartTradeStreamLayer model={model} degen={degen} />
|
|
3767
4182
|
) : null}
|
|
3768
4183
|
<ChartScrubLayer model={model} degen={degen} />
|
|
3769
|
-
{model.badgeCfg ?
|
|
4184
|
+
{model.badgeCfg ? (
|
|
4185
|
+
<ChartBadgeLayer
|
|
4186
|
+
model={model}
|
|
4187
|
+
degen={degen}
|
|
4188
|
+
yAxisEntries={yAxisEntries}
|
|
4189
|
+
/>
|
|
4190
|
+
) : null}
|
|
3770
4191
|
<ChartScrubActionLayer model={model} />
|
|
3771
4192
|
</Canvas>
|
|
3772
4193
|
);
|
|
@@ -3836,6 +4257,7 @@ function ChartNativeOverlays({ model }: { model: LiveChartModel }) {
|
|
|
3836
4257
|
scrubActive={crosshair.scrubActive}
|
|
3837
4258
|
scrubCandle={crosshair.scrubCandle}
|
|
3838
4259
|
scrubGap={crosshair.scrubGap}
|
|
4260
|
+
scrubMarkers={crosshair.scrubMarkers}
|
|
3839
4261
|
tooltipLayout={crosshair.tooltipLayout}
|
|
3840
4262
|
engine={engine}
|
|
3841
4263
|
padding={effectivePadding}
|
|
@@ -3855,10 +4277,12 @@ function ChartNativeOverlays({ model }: { model: LiveChartModel }) {
|
|
|
3855
4277
|
function ChartView({
|
|
3856
4278
|
model,
|
|
3857
4279
|
yAxisEntries,
|
|
4280
|
+
xAxisEntries,
|
|
3858
4281
|
degen,
|
|
3859
4282
|
}: {
|
|
3860
4283
|
model: LiveChartModel;
|
|
3861
4284
|
yAxisEntries: YAxisEntries | null;
|
|
4285
|
+
xAxisEntries: XAxisEntries | null;
|
|
3862
4286
|
degen: DegenState | null;
|
|
3863
4287
|
}) {
|
|
3864
4288
|
const {
|
|
@@ -3870,8 +4294,22 @@ function ChartView({
|
|
|
3870
4294
|
accessibilityRole,
|
|
3871
4295
|
} = model;
|
|
3872
4296
|
|
|
4297
|
+
const gesture = useYAxisScaleGesture({
|
|
4298
|
+
engine: model.engine,
|
|
4299
|
+
padding: model.effectivePadding,
|
|
4300
|
+
axis: model.yAxisCfg,
|
|
4301
|
+
floating: model.yAxisFloat,
|
|
4302
|
+
entries: yAxisEntries,
|
|
4303
|
+
font: model.skiaFont,
|
|
4304
|
+
scale: model.effectiveYRangeScale,
|
|
4305
|
+
active: model.axisScaleActive,
|
|
4306
|
+
deferHit: model.deferAxisScaleHit,
|
|
4307
|
+
onStart: model.clearCrosshair,
|
|
4308
|
+
gesture: rootGesture,
|
|
4309
|
+
});
|
|
4310
|
+
|
|
3873
4311
|
return (
|
|
3874
|
-
<GestureDetector gesture={
|
|
4312
|
+
<GestureDetector gesture={gesture}>
|
|
3875
4313
|
<View
|
|
3876
4314
|
style={[{ flex: 1, backgroundColor }, style]}
|
|
3877
4315
|
onLayout={onLayout}
|
|
@@ -3879,15 +4317,22 @@ function ChartView({
|
|
|
3879
4317
|
accessibilityLabel={accessibilityLabel}
|
|
3880
4318
|
accessibilityRole={accessibilityRole}
|
|
3881
4319
|
>
|
|
3882
|
-
<ChartCanvas
|
|
4320
|
+
<ChartCanvas
|
|
4321
|
+
model={model}
|
|
4322
|
+
yAxisEntries={yAxisEntries}
|
|
4323
|
+
xAxisEntries={xAxisEntries}
|
|
4324
|
+
degen={degen}
|
|
4325
|
+
/>
|
|
3883
4326
|
<ChartNativeOverlays model={model} />
|
|
3884
4327
|
</View>
|
|
3885
4328
|
</GestureDetector>
|
|
3886
4329
|
);
|
|
3887
4330
|
}
|
|
3888
4331
|
|
|
3889
|
-
|
|
3890
|
-
|
|
4332
|
+
// Memoized so a parent render with unchanged props skips the controller; the
|
|
4333
|
+
// chart's live data flows through SharedValues, not props.
|
|
4334
|
+
export const LiveChart = memo(
|
|
4335
|
+
forwardRef<LiveChartHandle, LiveChartProps>(function LiveChart(props, ref) {
|
|
3891
4336
|
const model = useLiveChartController(props);
|
|
3892
4337
|
const { viewEnd, viewWindow } = model.engine;
|
|
3893
4338
|
useImperativeHandle(
|
|
@@ -3897,12 +4342,9 @@ export const LiveChart = forwardRef<LiveChartHandle, LiveChartProps>(
|
|
|
3897
4342
|
}),
|
|
3898
4343
|
[viewEnd, viewWindow],
|
|
3899
4344
|
);
|
|
3900
|
-
if (model.
|
|
3901
|
-
return <
|
|
3902
|
-
}
|
|
3903
|
-
if (model.degenCfg) {
|
|
3904
|
-
return <ChartWithDegen model={model} yAxisEntries={null} />;
|
|
4345
|
+
if (model.xAxisCfg) {
|
|
4346
|
+
return <ChartWithXAxis model={model} />;
|
|
3905
4347
|
}
|
|
3906
|
-
return <
|
|
3907
|
-
},
|
|
4348
|
+
return <ChartWithYAxisOrDegen model={model} xAxisEntries={null} />;
|
|
4349
|
+
}),
|
|
3908
4350
|
);
|