react-native-livechart 4.26.0 → 4.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CustomReferenceLineOverlay.d.ts +8 -1
- package/dist/components/CustomReferenceLineOverlay.d.ts.map +1 -1
- package/dist/components/CustomTooltipOverlay.d.ts +3 -2
- package/dist/components/CustomTooltipOverlay.d.ts.map +1 -1
- package/dist/components/LiveChart.d.ts +1 -1
- package/dist/components/LiveChart.d.ts.map +1 -1
- package/dist/components/LiveChartSeries.d.ts.map +1 -1
- package/dist/components/ReferenceLineOverlay.d.ts +4 -0
- package/dist/components/ReferenceLineOverlay.d.ts.map +1 -1
- package/dist/components/ReferenceValueBadge.d.ts +15 -0
- package/dist/components/ReferenceValueBadge.d.ts.map +1 -0
- package/dist/components/XAxisOverlay.d.ts +17 -0
- package/dist/components/XAxisOverlay.d.ts.map +1 -1
- package/dist/core/liveChartEngineTick.d.ts +4 -0
- package/dist/core/liveChartEngineTick.d.ts.map +1 -1
- package/dist/core/liveChartSeriesEngineTick.d.ts +2 -0
- package/dist/core/liveChartSeriesEngineTick.d.ts.map +1 -1
- package/dist/core/resolveConfig.d.ts +28 -1
- package/dist/core/resolveConfig.d.ts.map +1 -1
- package/dist/core/useLiveChartEngine.d.ts +7 -0
- package/dist/core/useLiveChartEngine.d.ts.map +1 -1
- package/dist/core/useLiveChartSeriesEngine.d.ts +2 -0
- package/dist/core/useLiveChartSeriesEngine.d.ts.map +1 -1
- package/dist/draw/grid.d.ts +2 -2
- package/dist/draw/line.d.ts +15 -1
- package/dist/draw/line.d.ts.map +1 -1
- package/dist/hooks/crosshairShared.d.ts +16 -1
- package/dist/hooks/crosshairShared.d.ts.map +1 -1
- package/dist/hooks/referenceBadgeFont.d.ts +5 -0
- package/dist/hooks/referenceBadgeFont.d.ts.map +1 -0
- package/dist/hooks/resolveChartLayout.d.ts +8 -0
- package/dist/hooks/resolveChartLayout.d.ts.map +1 -1
- package/dist/hooks/useBadge.d.ts +16 -1
- package/dist/hooks/useBadge.d.ts.map +1 -1
- package/dist/hooks/useChartSkiaFont.d.ts +1 -0
- package/dist/hooks/useChartSkiaFont.d.ts.map +1 -1
- package/dist/hooks/useCrosshair.d.ts +7 -2
- package/dist/hooks/useCrosshair.d.ts.map +1 -1
- package/dist/hooks/useCrosshairSeries.d.ts +4 -1
- package/dist/hooks/useCrosshairSeries.d.ts.map +1 -1
- package/dist/hooks/useLatestCallback.d.ts +6 -0
- package/dist/hooks/useLatestCallback.d.ts.map +1 -0
- package/dist/hooks/useMarkers.d.ts.map +1 -1
- package/dist/hooks/usePanScroll.d.ts +3 -1
- package/dist/hooks/usePanScroll.d.ts.map +1 -1
- package/dist/hooks/usePinchZoom.d.ts.map +1 -1
- package/dist/hooks/useReferenceDrag.d.ts +20 -5
- package/dist/hooks/useReferenceDrag.d.ts.map +1 -1
- package/dist/hooks/useReferenceLine.d.ts +24 -12
- package/dist/hooks/useReferenceLine.d.ts.map +1 -1
- package/dist/hooks/useReferenceLinePress.d.ts +4 -2
- package/dist/hooks/useReferenceLinePress.d.ts.map +1 -1
- package/dist/hooks/useReferenceTagStack.d.ts +31 -0
- package/dist/hooks/useReferenceTagStack.d.ts.map +1 -0
- package/dist/hooks/useScrubMarkers.d.ts +12 -0
- package/dist/hooks/useScrubMarkers.d.ts.map +1 -0
- package/dist/hooks/useXAxis.d.ts +1 -1
- package/dist/hooks/useXAxis.d.ts.map +1 -1
- package/dist/hooks/useYAxisScaleGesture.d.ts +34 -0
- package/dist/hooks/useYAxisScaleGesture.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/math/axisBadgeLayout.d.ts +16 -0
- package/dist/math/axisBadgeLayout.d.ts.map +1 -0
- package/dist/math/markers.d.ts +3 -0
- package/dist/math/markers.d.ts.map +1 -1
- package/dist/math/range.d.ts +1 -1
- package/dist/math/range.d.ts.map +1 -1
- package/dist/math/referenceTagStack.d.ts +36 -0
- package/dist/math/referenceTagStack.d.ts.map +1 -0
- package/dist/math/scrubMarkers.d.ts +12 -0
- package/dist/math/scrubMarkers.d.ts.map +1 -0
- package/dist/types.d.ts +202 -32
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/CustomReferenceLineOverlay.tsx +50 -8
- package/src/components/CustomTooltipOverlay.tsx +5 -1
- package/src/components/LiveChart.tsx +560 -138
- package/src/components/LiveChartSeries.tsx +113 -13
- package/src/components/ReferenceLineOverlay.tsx +62 -26
- package/src/components/ReferenceValueBadge.tsx +102 -0
- package/src/components/XAxisOverlay.tsx +104 -1
- package/src/core/liveChartEngineTick.ts +49 -4
- package/src/core/liveChartSeriesEngineTick.ts +37 -0
- package/src/core/resolveConfig.ts +95 -2
- package/src/core/useLiveChartEngine.ts +43 -9
- package/src/core/useLiveChartSeriesEngine.ts +5 -0
- package/src/draw/grid.ts +2 -2
- package/src/draw/line.ts +23 -1
- package/src/hooks/crosshairShared.ts +56 -1
- package/src/hooks/referenceBadgeFont.ts +35 -0
- package/src/hooks/resolveChartLayout.ts +17 -0
- package/src/hooks/useBadge.ts +44 -5
- package/src/hooks/useChartSkiaFont.ts +1 -1
- package/src/hooks/useCrosshair.ts +444 -310
- package/src/hooks/useCrosshairSeries.ts +29 -10
- package/src/hooks/useLatestCallback.ts +15 -0
- package/src/hooks/useMarkers.ts +51 -39
- package/src/hooks/usePanScroll.ts +155 -127
- package/src/hooks/usePinchZoom.ts +84 -63
- package/src/hooks/useReferenceDrag.ts +390 -155
- package/src/hooks/useReferenceLine.ts +453 -277
- package/src/hooks/useReferenceLineGrouping.ts +1 -1
- package/src/hooks/useReferenceLinePress.ts +121 -53
- package/src/hooks/useReferenceTagStack.ts +81 -0
- package/src/hooks/useScrubMarkers.ts +79 -0
- package/src/hooks/useXAxis.ts +11 -2
- package/src/hooks/useYAxisScaleGesture.ts +263 -0
- package/src/index.ts +10 -0
- package/src/math/axisBadgeLayout.ts +37 -0
- package/src/math/markers.ts +28 -3
- package/src/math/range.ts +35 -0
- package/src/math/referenceTagStack.ts +112 -0
- package/src/math/scrubMarkers.ts +55 -0
- package/src/types.ts +207 -32
|
@@ -1,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,6 +150,8 @@ import {
|
|
|
137
150
|
candleGapBucketStartAtTime,
|
|
138
151
|
candleGapDefaultLabel,
|
|
139
152
|
} from "../math/candleGaps";
|
|
153
|
+
import { useReferenceTagStack, type CustomTagSizes } from "../hooks/useReferenceTagStack";
|
|
154
|
+
import { EMPTY_TAG_STACK, type ReferenceTagStack, type TagRect } from "../math/referenceTagStack";
|
|
140
155
|
import { useReferenceLineGrouping } from "../hooks/useReferenceLineGrouping";
|
|
141
156
|
import {
|
|
142
157
|
collectReferenceValues,
|
|
@@ -198,7 +213,7 @@ import { SegmentDividerOverlay } from "./SegmentDividerOverlay";
|
|
|
198
213
|
import { SegmentLineGradient } from "./SegmentLineGradient";
|
|
199
214
|
import { TradeStreamOverlay } from "./TradeStreamOverlay";
|
|
200
215
|
import { ValueLineOverlay } from "./ValueLineOverlay";
|
|
201
|
-
import { XAxisOverlay } from "./XAxisOverlay";
|
|
216
|
+
import { XAxisGridLines, XAxisOverlay } from "./XAxisOverlay";
|
|
202
217
|
import { YAxisOverlay } from "./YAxisOverlay";
|
|
203
218
|
|
|
204
219
|
/** Stable empty number array so the live-reference-values worklet stays
|
|
@@ -275,8 +290,7 @@ function resolveLiveChartFeatureConfig({
|
|
|
275
290
|
scrub,
|
|
276
291
|
scrubAction,
|
|
277
292
|
volume,
|
|
278
|
-
|
|
279
|
-
lineGaps,
|
|
293
|
+
chartGapsCfg,
|
|
280
294
|
gradient,
|
|
281
295
|
areaDots,
|
|
282
296
|
threshold,
|
|
@@ -300,8 +314,6 @@ function resolveLiveChartFeatureConfig({
|
|
|
300
314
|
| "scrub"
|
|
301
315
|
| "scrubAction"
|
|
302
316
|
| "volume"
|
|
303
|
-
| "candleGaps"
|
|
304
|
-
| "lineGaps"
|
|
305
317
|
| "gradient"
|
|
306
318
|
| "areaDots"
|
|
307
319
|
| "threshold"
|
|
@@ -313,26 +325,29 @@ function resolveLiveChartFeatureConfig({
|
|
|
313
325
|
| "degen"
|
|
314
326
|
| "tradeStream"
|
|
315
327
|
| "metrics"
|
|
316
|
-
> & {
|
|
328
|
+
> & {
|
|
329
|
+
isStatic: boolean;
|
|
330
|
+
chartGapsCfg: ResolvedCandleGapsConfig | null;
|
|
331
|
+
}) {
|
|
317
332
|
const isCandle = mode === "candle";
|
|
318
333
|
const badgeCfg = resolveBadge(badge);
|
|
319
|
-
const chartGapsCfg = resolveCandleGaps(isCandle ? candleGaps : lineGaps);
|
|
320
334
|
const thresholdCfg = isCandle ? null : resolveThreshold(threshold);
|
|
321
335
|
const thresholdSeriesSV = thresholdCfg?.series ?? null;
|
|
322
336
|
const dotCfg = resolveDot(dot);
|
|
323
337
|
const volumeCfg = isCandle ? resolveVolume(volume) : null;
|
|
338
|
+
const xAxisCfg = resolveXAxis(xAxis);
|
|
339
|
+
const gridStyleCfg = resolveGridStyle(gridStyle);
|
|
324
340
|
|
|
325
341
|
return {
|
|
326
342
|
isCandle,
|
|
327
343
|
yAxisCfg: resolveYAxis(yAxis),
|
|
328
|
-
xAxisCfg
|
|
344
|
+
xAxisCfg,
|
|
329
345
|
topLabelCfg: resolveAxisLabel(topLabel),
|
|
330
346
|
bottomLabelCfg: resolveAxisLabel(bottomLabel),
|
|
331
347
|
badgeCfg,
|
|
332
348
|
scrubCfg: resolveScrub(scrub),
|
|
333
349
|
scrubActionCfg: resolveScrubAction(scrubAction),
|
|
334
350
|
volumeCfg,
|
|
335
|
-
chartGapsCfg,
|
|
336
351
|
candleGapsCfg: isCandle ? chartGapsCfg : null,
|
|
337
352
|
lineGapsCfg: isCandle ? null : chartGapsCfg,
|
|
338
353
|
volumeBandHeight: volumeCfg?.maxHeight ?? 0,
|
|
@@ -354,29 +369,27 @@ function resolveLiveChartFeatureConfig({
|
|
|
354
369
|
? dotGlowRadialOutset(dotCfg.glow.radius, dotCfg.glow.blur)
|
|
355
370
|
: 0,
|
|
356
371
|
),
|
|
357
|
-
gridStyleCfg
|
|
372
|
+
gridStyleCfg,
|
|
373
|
+
xGridStyleCfg: resolveXAxisGridStyle(
|
|
374
|
+
xAxisCfg?.gridLines ?? null,
|
|
375
|
+
gridStyleCfg,
|
|
376
|
+
),
|
|
358
377
|
degenCfg: isStatic ? null : resolveDegen(degen),
|
|
359
378
|
tradeStreamResolved: resolveTradeStream(tradeStream),
|
|
360
379
|
metricsCfg: resolveMetrics(metrics),
|
|
361
380
|
};
|
|
362
381
|
}
|
|
363
382
|
|
|
364
|
-
function
|
|
383
|
+
function resolveLiveChartReferenceLines({
|
|
365
384
|
chartGapsCfg,
|
|
366
385
|
referenceLines,
|
|
367
386
|
renderReferenceLine,
|
|
368
387
|
renderOffAxisReferenceLine,
|
|
369
|
-
thresholdCfg,
|
|
370
|
-
referenceLineGrouping,
|
|
371
|
-
badgeCfg,
|
|
372
388
|
}: {
|
|
373
389
|
chartGapsCfg: ReturnType<typeof resolveCandleGaps>;
|
|
374
390
|
referenceLines: LiveChartProps["referenceLines"];
|
|
375
391
|
renderReferenceLine: LiveChartProps["renderReferenceLine"];
|
|
376
392
|
renderOffAxisReferenceLine: LiveChartProps["renderOffAxisReferenceLine"];
|
|
377
|
-
thresholdCfg: ReturnType<typeof resolveThreshold>;
|
|
378
|
-
referenceLineGrouping: LiveChartProps["referenceLineGrouping"];
|
|
379
|
-
badgeCfg: ReturnType<typeof resolveBadge>;
|
|
380
393
|
}) {
|
|
381
394
|
const chartGapBands: ReferenceLine[] =
|
|
382
395
|
chartGapsCfg?.gaps.flatMap((gap) => {
|
|
@@ -429,6 +442,26 @@ function resolveLiveChartReferenceConfig({
|
|
|
429
442
|
draggableRefIdx.push(index);
|
|
430
443
|
}
|
|
431
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
|
+
}) {
|
|
432
465
|
const thresholdInRange = thresholdCfg?.includeInRange === true;
|
|
433
466
|
const thresholdRangeValueSV =
|
|
434
467
|
thresholdInRange &&
|
|
@@ -442,17 +475,14 @@ function resolveLiveChartReferenceConfig({
|
|
|
442
475
|
: undefined;
|
|
443
476
|
|
|
444
477
|
return {
|
|
445
|
-
chartGapBands,
|
|
446
|
-
allRefLines,
|
|
447
|
-
refValues: collectReferenceValues(allRefLines),
|
|
448
|
-
refLineCustom,
|
|
449
|
-
refLineOffAxisCustom,
|
|
450
|
-
refLineKeys: referenceLineReactKeys(allRefLines),
|
|
451
|
-
draggableRefIdx,
|
|
452
478
|
thresholdInRange,
|
|
453
479
|
thresholdRangeValueSV,
|
|
454
480
|
refGroupingCfg,
|
|
455
|
-
|
|
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"
|
|
456
486
|
? (refGroupingCfg?.radius ?? 18)
|
|
457
487
|
: null,
|
|
458
488
|
refGroupBadge: resolveReferenceGroupBadge(refGroupingCfg?.badge),
|
|
@@ -466,6 +496,8 @@ function useLiveReferenceState(
|
|
|
466
496
|
allRefLines: ReferenceLine[],
|
|
467
497
|
draggableRefIdx: number[],
|
|
468
498
|
thresholdRangeValueSV: SharedValue<number> | null,
|
|
499
|
+
stackEnabled: boolean,
|
|
500
|
+
reserveBadge: boolean,
|
|
469
501
|
) {
|
|
470
502
|
const dragValues = useSharedValue<number[]>([]);
|
|
471
503
|
const dragActive = useSharedValue<boolean[]>([]);
|
|
@@ -496,6 +528,23 @@ function useLiveReferenceState(
|
|
|
496
528
|
}, [dragActive, dragValues, propValues]);
|
|
497
529
|
|
|
498
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]);
|
|
499
548
|
const liveRefValues = useDerivedValue<number[]>(() => {
|
|
500
549
|
if (draggableRefIdx.length === 0 && thresholdRangeValueSV === null) {
|
|
501
550
|
return EMPTY_NUMS;
|
|
@@ -515,7 +564,12 @@ function useLiveReferenceState(
|
|
|
515
564
|
return output;
|
|
516
565
|
});
|
|
517
566
|
|
|
518
|
-
return {
|
|
567
|
+
return {
|
|
568
|
+
dragValues, dragActive, refLineCustomTagWidths, liveRefValues,
|
|
569
|
+
refTagSizes, refTagStack, refLiveBadgeRect,
|
|
570
|
+
activeTagStack: stackEnabled ? refTagStack : undefined,
|
|
571
|
+
stackObstacle: reserveBadge ? refLiveBadgeRect : null,
|
|
572
|
+
};
|
|
519
573
|
}
|
|
520
574
|
|
|
521
575
|
function resolveLiveChartPresentationConfig({
|
|
@@ -529,6 +583,7 @@ function resolveLiveChartPresentationConfig({
|
|
|
529
583
|
refGroupBadge,
|
|
530
584
|
pulseCfg,
|
|
531
585
|
timeScroll,
|
|
586
|
+
viewport,
|
|
532
587
|
isStatic,
|
|
533
588
|
returnToLive,
|
|
534
589
|
zoom,
|
|
@@ -544,6 +599,7 @@ function resolveLiveChartPresentationConfig({
|
|
|
544
599
|
refGroupBadge: ReturnType<typeof resolveReferenceGroupBadge>;
|
|
545
600
|
pulseCfg: ReturnType<typeof resolvePulse>;
|
|
546
601
|
timeScroll: LiveChartProps["timeScroll"];
|
|
602
|
+
viewport: LiveChartProps["viewport"];
|
|
547
603
|
isStatic: boolean;
|
|
548
604
|
returnToLive: LiveChartProps["returnToLive"];
|
|
549
605
|
zoom: LiveChartProps["zoom"];
|
|
@@ -604,6 +660,7 @@ function resolveLiveChartPresentationConfig({
|
|
|
604
660
|
}
|
|
605
661
|
: null,
|
|
606
662
|
timeScrollEnabled,
|
|
663
|
+
viewportCfg: resolveViewport(viewport),
|
|
607
664
|
returnToLiveMs: resolveReturnToLiveMs(returnToLive),
|
|
608
665
|
timeScrollOverscroll: timeScrollEnabled ? resolveOverscroll(timeScroll) : 0,
|
|
609
666
|
timeScrollFling: resolveFling(timeScroll),
|
|
@@ -925,7 +982,8 @@ function resolveLiveChartInteractionConfig({
|
|
|
925
982
|
}
|
|
926
983
|
|
|
927
984
|
function composeLiveChartRootGesture({
|
|
928
|
-
|
|
985
|
+
crosshairGesture,
|
|
986
|
+
crosshairTapGesture,
|
|
929
987
|
markerTapGesture,
|
|
930
988
|
refLineTapGesture,
|
|
931
989
|
refDragGesture,
|
|
@@ -939,7 +997,8 @@ function composeLiveChartRootGesture({
|
|
|
939
997
|
scrollGestureMode,
|
|
940
998
|
zoomEnabled,
|
|
941
999
|
}: {
|
|
942
|
-
|
|
1000
|
+
crosshairGesture: ReturnType<typeof useCrosshair>["gesture"];
|
|
1001
|
+
crosshairTapGesture: ReturnType<typeof useCrosshair>["tapGesture"];
|
|
943
1002
|
markerTapGesture: ReturnType<typeof useMarkers>["tapGesture"];
|
|
944
1003
|
refLineTapGesture: ReturnType<typeof useReferenceLinePress>["tapGesture"];
|
|
945
1004
|
refDragGesture: ReturnType<typeof useReferenceDrag>["gesture"];
|
|
@@ -954,9 +1013,9 @@ function composeLiveChartRootGesture({
|
|
|
954
1013
|
zoomEnabled: boolean;
|
|
955
1014
|
}) {
|
|
956
1015
|
const baseGesture =
|
|
957
|
-
scrubActionActive &&
|
|
958
|
-
? Gesture.Exclusive(
|
|
959
|
-
:
|
|
1016
|
+
scrubActionActive && crosshairTapGesture
|
|
1017
|
+
? Gesture.Exclusive(crosshairTapGesture, crosshairGesture)
|
|
1018
|
+
: crosshairGesture;
|
|
960
1019
|
const overlayTaps = [
|
|
961
1020
|
markersActive ? markerTapGesture : null,
|
|
962
1021
|
refPressActive ? refLineTapGesture : null,
|
|
@@ -989,11 +1048,13 @@ function useAxisAutoHide({
|
|
|
989
1048
|
config,
|
|
990
1049
|
scrollActive,
|
|
991
1050
|
scrubActive,
|
|
1051
|
+
scaleActive,
|
|
992
1052
|
engine,
|
|
993
1053
|
}: {
|
|
994
1054
|
config: LiveChartProps["axisAutoHide"];
|
|
995
1055
|
scrollActive: SharedValue<boolean>;
|
|
996
1056
|
scrubActive: SharedValue<boolean>;
|
|
1057
|
+
scaleActive: SharedValue<boolean>;
|
|
997
1058
|
engine: ReturnType<typeof useLiveChartEngine>;
|
|
998
1059
|
}) {
|
|
999
1060
|
const resolved = config === true ? {} : config === false ? null : config;
|
|
@@ -1017,7 +1078,7 @@ function useAxisAutoHide({
|
|
|
1017
1078
|
}, [enabled, idleOpacity, opacity]);
|
|
1018
1079
|
useAnimatedReaction(
|
|
1019
1080
|
() => ({
|
|
1020
|
-
gesture: scrollActive.value || scrubActive.value,
|
|
1081
|
+
gesture: scrollActive.value || scrubActive.value || scaleActive.value,
|
|
1021
1082
|
viewEnd: engine.viewEnd.value,
|
|
1022
1083
|
viewWindow: engine.viewWindow.value,
|
|
1023
1084
|
}),
|
|
@@ -1232,6 +1293,7 @@ function useLiveChartLayoutResources({
|
|
|
1232
1293
|
badgeCfg,
|
|
1233
1294
|
metricsCfg,
|
|
1234
1295
|
badgeUsesRightGutter,
|
|
1296
|
+
referenceAxisBadge,
|
|
1235
1297
|
xAxisCfg,
|
|
1236
1298
|
formatValue,
|
|
1237
1299
|
pulseConfig,
|
|
@@ -1253,6 +1315,7 @@ function useLiveChartLayoutResources({
|
|
|
1253
1315
|
badgeCfg: ReturnType<typeof resolveBadge>;
|
|
1254
1316
|
metricsCfg: ReturnType<typeof resolveMetrics>;
|
|
1255
1317
|
badgeUsesRightGutter: boolean;
|
|
1318
|
+
referenceAxisBadge: boolean;
|
|
1256
1319
|
xAxisCfg: ReturnType<typeof resolveXAxis>;
|
|
1257
1320
|
formatValue: (value: number) => string;
|
|
1258
1321
|
pulseConfig: { maxRadius: number; strokeWidth: number } | null;
|
|
@@ -1283,19 +1346,19 @@ function useLiveChartLayoutResources({
|
|
|
1283
1346
|
const refGroupBadgeFont = refGroupBadgeHasFont
|
|
1284
1347
|
? refGroupBadgeFontOverride
|
|
1285
1348
|
: skiaFont;
|
|
1286
|
-
const valueLayoutSample =
|
|
1349
|
+
const valueLayoutSample = useLayoutValueSample(value);
|
|
1287
1350
|
const [scrolledBack, setScrolledBack] = useState(false);
|
|
1288
1351
|
const effectiveYAxisFloat =
|
|
1289
1352
|
yAxisFloat && (!timeScrollEnabled || scrolledBack);
|
|
1290
|
-
const layout = resolveChartLayout({
|
|
1353
|
+
const layout = useMemo(() => resolveChartLayout({
|
|
1291
1354
|
palette,
|
|
1292
1355
|
lineWidthOverride: lineProp?.width,
|
|
1293
1356
|
insetsOverride: insets,
|
|
1294
1357
|
yAxis: yAxisCfg !== null,
|
|
1295
1358
|
yAxisFloat: effectiveYAxisFloat,
|
|
1296
|
-
badge: badgeCfg !== null,
|
|
1359
|
+
badge: badgeCfg !== null || referenceAxisBadge,
|
|
1297
1360
|
badgeMetrics: metricsCfg.badge,
|
|
1298
|
-
badgeUsesRightGutter,
|
|
1361
|
+
badgeUsesRightGutter: badgeUsesRightGutter || referenceAxisBadge,
|
|
1299
1362
|
badgeShowTail: badgeCfg?.tail ?? true,
|
|
1300
1363
|
xAxis: xAxisCfg !== null,
|
|
1301
1364
|
font: skiaFont,
|
|
@@ -1304,7 +1367,24 @@ function useLiveChartLayoutResources({
|
|
|
1304
1367
|
pulse: pulseConfig,
|
|
1305
1368
|
dotGlow: dotCfg.glow,
|
|
1306
1369
|
volumeBandHeight,
|
|
1307
|
-
})
|
|
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
|
+
]);
|
|
1308
1388
|
return {
|
|
1309
1389
|
skiaFont,
|
|
1310
1390
|
valueFont,
|
|
@@ -1316,17 +1396,17 @@ function useLiveChartLayoutResources({
|
|
|
1316
1396
|
};
|
|
1317
1397
|
}
|
|
1318
1398
|
|
|
1319
|
-
function
|
|
1399
|
+
function useLayoutValueSample(value: SharedValue<number>) {
|
|
1320
1400
|
const [sample, setSample] = useState<number | undefined>(undefined);
|
|
1321
|
-
const
|
|
1401
|
+
const sampled = useSharedValue(0);
|
|
1322
1402
|
useAnimatedReaction(
|
|
1323
|
-
() =>
|
|
1403
|
+
() => value.get(),
|
|
1324
1404
|
(current) => {
|
|
1325
|
-
if (current
|
|
1326
|
-
|
|
1405
|
+
if (!shouldResampleLayoutValue(current, sampled.get())) return;
|
|
1406
|
+
sampled.set(current);
|
|
1327
1407
|
scheduleOnRN(setSample, current);
|
|
1328
1408
|
},
|
|
1329
|
-
[
|
|
1409
|
+
[sampled, value],
|
|
1330
1410
|
);
|
|
1331
1411
|
return sample;
|
|
1332
1412
|
}
|
|
@@ -1409,10 +1489,12 @@ function useLiveChartController({
|
|
|
1409
1489
|
exaggerate = false,
|
|
1410
1490
|
nonNegative = false,
|
|
1411
1491
|
maxValue,
|
|
1492
|
+
minRange,
|
|
1412
1493
|
yRangeScale,
|
|
1413
1494
|
windowBuffer = 0,
|
|
1414
1495
|
nowOverride,
|
|
1415
1496
|
timeScroll = false,
|
|
1497
|
+
viewport,
|
|
1416
1498
|
returnToLive,
|
|
1417
1499
|
zoom = false,
|
|
1418
1500
|
accessibilityLabel,
|
|
@@ -1460,6 +1542,7 @@ function useLiveChartController({
|
|
|
1460
1542
|
|
|
1461
1543
|
// ── Callbacks ───────────────────────────────────────────────────────────
|
|
1462
1544
|
onScrub,
|
|
1545
|
+
onScrubCandleChange,
|
|
1463
1546
|
onScrubAction,
|
|
1464
1547
|
onReferenceLinePress,
|
|
1465
1548
|
onGestureStart,
|
|
@@ -1475,6 +1558,10 @@ function useLiveChartController({
|
|
|
1475
1558
|
// Stand-in threshold value so `useThreshold` can be called unconditionally
|
|
1476
1559
|
// (hooks can't be); the geometry is ignored when no threshold is configured.
|
|
1477
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]);
|
|
1478
1565
|
const {
|
|
1479
1566
|
isCandle,
|
|
1480
1567
|
yAxisCfg,
|
|
@@ -1485,7 +1572,6 @@ function useLiveChartController({
|
|
|
1485
1572
|
scrubCfg,
|
|
1486
1573
|
scrubActionCfg,
|
|
1487
1574
|
volumeCfg,
|
|
1488
|
-
chartGapsCfg,
|
|
1489
1575
|
candleGapsCfg,
|
|
1490
1576
|
lineGapsCfg,
|
|
1491
1577
|
volumeBandHeight,
|
|
@@ -1501,10 +1587,11 @@ function useLiveChartController({
|
|
|
1501
1587
|
selectionDotCfg,
|
|
1502
1588
|
dotOuterRadius,
|
|
1503
1589
|
gridStyleCfg,
|
|
1590
|
+
xGridStyleCfg,
|
|
1504
1591
|
degenCfg,
|
|
1505
1592
|
tradeStreamResolved,
|
|
1506
1593
|
metricsCfg,
|
|
1507
|
-
} = resolveLiveChartFeatureConfig({
|
|
1594
|
+
} = useMemo(() => resolveLiveChartFeatureConfig({
|
|
1508
1595
|
mode,
|
|
1509
1596
|
yAxis,
|
|
1510
1597
|
xAxis,
|
|
@@ -1514,8 +1601,7 @@ function useLiveChartController({
|
|
|
1514
1601
|
scrub,
|
|
1515
1602
|
scrubAction,
|
|
1516
1603
|
volume,
|
|
1517
|
-
|
|
1518
|
-
lineGaps,
|
|
1604
|
+
chartGapsCfg,
|
|
1519
1605
|
gradient,
|
|
1520
1606
|
areaDots,
|
|
1521
1607
|
threshold,
|
|
@@ -1528,35 +1614,80 @@ function useLiveChartController({
|
|
|
1528
1614
|
degen,
|
|
1529
1615
|
tradeStream,
|
|
1530
1616
|
metrics,
|
|
1531
|
-
})
|
|
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
|
+
]);
|
|
1532
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.
|
|
1533
1644
|
const {
|
|
1534
|
-
chartGapBands,
|
|
1535
1645
|
allRefLines,
|
|
1536
1646
|
refValues,
|
|
1537
1647
|
refLineCustom,
|
|
1538
1648
|
refLineOffAxisCustom,
|
|
1539
1649
|
refLineKeys,
|
|
1540
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 {
|
|
1541
1668
|
thresholdInRange,
|
|
1542
1669
|
thresholdRangeValueSV,
|
|
1543
1670
|
refGroupingCfg,
|
|
1671
|
+
refStackEnabled,
|
|
1672
|
+
refStackAvoidValueBadge,
|
|
1673
|
+
refStackRadius,
|
|
1674
|
+
refStackReserveBadge,
|
|
1544
1675
|
refGroupingRadius,
|
|
1545
1676
|
refGroupBadge,
|
|
1546
1677
|
refGroupFormat,
|
|
1547
1678
|
badgeUsesRightGutter,
|
|
1548
|
-
} = resolveLiveChartReferenceConfig({
|
|
1549
|
-
chartGapsCfg,
|
|
1550
|
-
referenceLines,
|
|
1551
|
-
renderReferenceLine,
|
|
1552
|
-
renderOffAxisReferenceLine,
|
|
1679
|
+
} = useMemo(() => resolveLiveChartReferenceConfig({
|
|
1553
1680
|
thresholdCfg,
|
|
1554
1681
|
referenceLineGrouping,
|
|
1555
1682
|
badgeCfg,
|
|
1556
|
-
})
|
|
1683
|
+
}), [
|
|
1684
|
+
badgeCfg,
|
|
1685
|
+
referenceLineGrouping,
|
|
1686
|
+
thresholdCfg,
|
|
1687
|
+
]);
|
|
1557
1688
|
|
|
1558
|
-
const { dragValues, dragActive, refLineCustomTagWidths, liveRefValues } =
|
|
1559
|
-
useLiveReferenceState(allRefLines, draggableRefIdx, thresholdRangeValueSV);
|
|
1689
|
+
const { dragValues, dragActive, refLineCustomTagWidths, liveRefValues, refTagSizes, refTagStack, refLiveBadgeRect, activeTagStack, stackObstacle } =
|
|
1690
|
+
useLiveReferenceState(allRefLines, draggableRefIdx, thresholdRangeValueSV, refStackEnabled, refStackReserveBadge);
|
|
1560
1691
|
|
|
1561
1692
|
const {
|
|
1562
1693
|
palette,
|
|
@@ -1569,13 +1700,14 @@ function useLiveChartController({
|
|
|
1569
1700
|
refGroupBadgeFontConfig,
|
|
1570
1701
|
pulseConfig,
|
|
1571
1702
|
timeScrollEnabled,
|
|
1703
|
+
viewportCfg,
|
|
1572
1704
|
returnToLiveMs,
|
|
1573
1705
|
timeScrollOverscroll,
|
|
1574
1706
|
timeScrollFling,
|
|
1575
1707
|
zoomCfg,
|
|
1576
1708
|
zoomEnabled,
|
|
1577
1709
|
yAxisFloat,
|
|
1578
|
-
} = resolveLiveChartPresentationConfig({
|
|
1710
|
+
} = useMemo(() => resolveLiveChartPresentationConfig({
|
|
1579
1711
|
accentColor,
|
|
1580
1712
|
theme,
|
|
1581
1713
|
paletteOverride,
|
|
@@ -1586,11 +1718,28 @@ function useLiveChartController({
|
|
|
1586
1718
|
refGroupBadge,
|
|
1587
1719
|
pulseCfg,
|
|
1588
1720
|
timeScroll,
|
|
1721
|
+
viewport,
|
|
1589
1722
|
isStatic,
|
|
1590
1723
|
returnToLive,
|
|
1591
1724
|
zoom,
|
|
1592
1725
|
yAxisCfg,
|
|
1593
|
-
})
|
|
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
|
+
]);
|
|
1594
1743
|
|
|
1595
1744
|
const {
|
|
1596
1745
|
skiaFont,
|
|
@@ -1617,6 +1766,7 @@ function useLiveChartController({
|
|
|
1617
1766
|
badgeCfg,
|
|
1618
1767
|
metricsCfg,
|
|
1619
1768
|
badgeUsesRightGutter,
|
|
1769
|
+
referenceAxisBadge: allRefLines.some(line => typeof line.valueBadge === "object" && line.valueBadge.position === "axis"),
|
|
1620
1770
|
xAxisCfg,
|
|
1621
1771
|
formatValue,
|
|
1622
1772
|
pulseConfig,
|
|
@@ -1624,6 +1774,15 @@ function useLiveChartController({
|
|
|
1624
1774
|
volumeBandHeight,
|
|
1625
1775
|
});
|
|
1626
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
|
+
|
|
1627
1786
|
// ── Reveal state ────────────────────────────────────────────
|
|
1628
1787
|
// ≥1 line point or ≥1 committed candle; morphT=1 only when !loading && hasData.
|
|
1629
1788
|
const { hasData } = useLiveChartHasData({
|
|
@@ -1686,6 +1845,7 @@ function useLiveChartController({
|
|
|
1686
1845
|
continuousEffects || loadingActive || !hasData.get() || reveal.morphT.get() < 1,
|
|
1687
1846
|
);
|
|
1688
1847
|
const idleWakeSignal = useDerivedValue<unknown>(() => [theme, accentColor, paletteOverride, metrics, reveal.morphT.get()]);
|
|
1848
|
+
const effectiveYRangeScale = useYAxisScaleValue(yRangeScale);
|
|
1689
1849
|
const engine = useLiveChartEngine({
|
|
1690
1850
|
...engineModeInputs,
|
|
1691
1851
|
value,
|
|
@@ -1699,6 +1859,7 @@ function useLiveChartController({
|
|
|
1699
1859
|
wakeSignal: idleWakeSignal,
|
|
1700
1860
|
snapKey,
|
|
1701
1861
|
scrollEnabled: timeScrollEnabled,
|
|
1862
|
+
viewport: viewportCfg,
|
|
1702
1863
|
allowFutureViewEnd: timeScrollOverscroll > 0,
|
|
1703
1864
|
returnToLiveMs,
|
|
1704
1865
|
smoothing,
|
|
@@ -1709,7 +1870,8 @@ function useLiveChartController({
|
|
|
1709
1870
|
liveReferenceValues: liveRefValues,
|
|
1710
1871
|
nonNegative,
|
|
1711
1872
|
maxValue,
|
|
1712
|
-
|
|
1873
|
+
minRange,
|
|
1874
|
+
yRangeScale: effectiveYRangeScale,
|
|
1713
1875
|
windowBuffer,
|
|
1714
1876
|
nowOverride,
|
|
1715
1877
|
mode,
|
|
@@ -1742,6 +1904,27 @@ function useLiveChartController({
|
|
|
1742
1904
|
// ── Per-frame derived values ───────────────────────────────────────────
|
|
1743
1905
|
const { layoutWidth, layoutHeight, onLayout } = useCanvasLayout(engine);
|
|
1744
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
|
+
|
|
1745
1928
|
const { refGroupResult, groupHidden } = useReferenceLineGrouping({
|
|
1746
1929
|
radius: refGroupingRadius,
|
|
1747
1930
|
engine,
|
|
@@ -1749,7 +1932,7 @@ function useLiveChartController({
|
|
|
1749
1932
|
lines: allRefLines,
|
|
1750
1933
|
custom: refLineCustom,
|
|
1751
1934
|
offAxisCustom: refLineOffAxisCustom,
|
|
1752
|
-
dragValues,
|
|
1935
|
+
dragValues: drawnRefValues,
|
|
1753
1936
|
});
|
|
1754
1937
|
|
|
1755
1938
|
// Threshold split geometry. Two forms, picked at render by `Array.isArray` (no
|
|
@@ -1812,6 +1995,15 @@ function useLiveChartController({
|
|
|
1812
1995
|
lineProp?.simplify,
|
|
1813
1996
|
lineGapsCfg?.gaps,
|
|
1814
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
|
+
);
|
|
1815
2007
|
|
|
1816
2008
|
// Area-dots fill shader color as a vec4 (channels 0..1), with the config
|
|
1817
2009
|
// `opacity` folded into the alpha. Defaults to a faint tint of the line/accent
|
|
@@ -1861,7 +2053,7 @@ function useLiveChartController({
|
|
|
1861
2053
|
refDragEnabled,
|
|
1862
2054
|
scrollGestureMode,
|
|
1863
2055
|
scrubHoldMs,
|
|
1864
|
-
} = resolveLiveChartInteractionConfig({
|
|
2056
|
+
} = useMemo(() => resolveLiveChartInteractionConfig({
|
|
1865
2057
|
isCandle,
|
|
1866
2058
|
mode,
|
|
1867
2059
|
candlesEngine,
|
|
@@ -1877,7 +2069,23 @@ function useLiveChartController({
|
|
|
1877
2069
|
timeScroll,
|
|
1878
2070
|
timeScrollEnabled,
|
|
1879
2071
|
scrubCfg,
|
|
1880
|
-
})
|
|
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
|
+
]);
|
|
1881
2089
|
// `projected` is used internally by the hit-test gesture; the overlay
|
|
1882
2090
|
// self-projects, so we only need the gesture + hit-test here. Built BEFORE
|
|
1883
2091
|
// `useCrosshair` so the scrub-action tap can defer to a marker under the finger.
|
|
@@ -1909,32 +2117,24 @@ function useLiveChartController({
|
|
|
1909
2117
|
!isStatic && refPressActive,
|
|
1910
2118
|
markerHitRadius,
|
|
1911
2119
|
onReferenceLinePress,
|
|
1912
|
-
|
|
2120
|
+
drawnRefValues,
|
|
2121
|
+
referenceValueAxis,
|
|
2122
|
+
fontProp,
|
|
2123
|
+
groupHidden,
|
|
2124
|
+
refLineCustom,
|
|
2125
|
+
refLineOffAxisCustom,
|
|
2126
|
+
activeTagStack,
|
|
1913
2127
|
);
|
|
1914
2128
|
|
|
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
2129
|
// Combined "defer" hit-test: the scrub-action place-tap and the live scrub both
|
|
1930
2130
|
// yield to a marker, a pressable badge, or a draggable line under the finger — so
|
|
1931
2131
|
// a press there is routed to that overlay / drag instead of dropping a reticle or
|
|
1932
2132
|
// crosshair. (Each hit-test returns false when its feature is off.)
|
|
1933
2133
|
/* istanbul ignore next -- worklet runs on the UI thread, not in Jest */
|
|
1934
|
-
const deferTapHit = (x: number, y: number): boolean => {
|
|
2134
|
+
const deferTapHit = useCallback((x: number, y: number): boolean => {
|
|
1935
2135
|
"worklet";
|
|
1936
2136
|
return markerHitTest(x, y) || refLineHitTest(x, y) || refDragHitTest(x, y);
|
|
1937
|
-
};
|
|
2137
|
+
}, [markerHitTest, refLineHitTest, refDragHitTest]);
|
|
1938
2138
|
|
|
1939
2139
|
// Cross-gesture arbitration for the one-finger touch. `Gesture.Race` below is
|
|
1940
2140
|
// NOT arbitration — RNGH's Race adds no relation between its children, so both
|
|
@@ -1943,6 +2143,7 @@ function useLiveChartController({
|
|
|
1943
2143
|
// long-press guard) makes "the scroll already won" a hard fact; `scrubActive`
|
|
1944
2144
|
// (written by the crosshair, read by the scroll pan) is the mirror image.
|
|
1945
2145
|
const scrollActive = useSharedValue(false);
|
|
2146
|
+
const axisScaleActive = useSharedValue(false);
|
|
1946
2147
|
|
|
1947
2148
|
const crosshairSettings = resolveCrosshairControllerSettings({
|
|
1948
2149
|
scrubCfg,
|
|
@@ -1984,6 +2185,9 @@ function useLiveChartController({
|
|
|
1984
2185
|
scrollActive,
|
|
1985
2186
|
crosshairSettings.clampToPlot,
|
|
1986
2187
|
crosshairSettings.snapToCandles,
|
|
2188
|
+
onScrubCandleChange,
|
|
2189
|
+
resolveScrubMarkerOptions(scrubCfg, markersSV),
|
|
2190
|
+
axisScaleActive,
|
|
1987
2191
|
);
|
|
1988
2192
|
|
|
1989
2193
|
// Capture only the shared value in the worklets below. Referencing
|
|
@@ -2007,11 +2211,16 @@ function useLiveChartController({
|
|
|
2007
2211
|
const src = isCandle ? candlesEngine.get() : lineEngineData.get();
|
|
2008
2212
|
return src.length > 0 ? src[0].time : engine.liveEdge.get();
|
|
2009
2213
|
});
|
|
2214
|
+
const clearCrosshair = useCallback(() => {
|
|
2215
|
+
"worklet";
|
|
2216
|
+
crosshairScrubActive.set(false);
|
|
2217
|
+
}, [crosshairScrubActive]);
|
|
2010
2218
|
const panScrollGesture = usePanScroll({
|
|
2011
2219
|
engine,
|
|
2012
2220
|
padding: effectivePadding,
|
|
2013
2221
|
minTime: scrollMinTime,
|
|
2014
2222
|
enabled: timeScrollEnabled,
|
|
2223
|
+
clampOnOverscrollChange: viewportCfg === null,
|
|
2015
2224
|
mode: scrollGestureMode,
|
|
2016
2225
|
overscroll: timeScrollOverscroll,
|
|
2017
2226
|
fling: timeScrollFling,
|
|
@@ -2020,10 +2229,7 @@ function useLiveChartController({
|
|
|
2020
2229
|
// finger only moves the price indicator across a fixed window.
|
|
2021
2230
|
scrubActive: crosshairScrubActive,
|
|
2022
2231
|
// Clear any live crosshair when a scroll drag takes over.
|
|
2023
|
-
onScrollStart:
|
|
2024
|
-
"worklet";
|
|
2025
|
-
crosshairScrubActive.set(false);
|
|
2026
|
-
},
|
|
2232
|
+
onScrollStart: clearCrosshair,
|
|
2027
2233
|
});
|
|
2028
2234
|
|
|
2029
2235
|
// Pinch-to-zoom the visible window (two-finger). Anchors at the focal point and
|
|
@@ -2038,14 +2244,12 @@ function useLiveChartController({
|
|
|
2038
2244
|
minTimeWindow: zoomCfg?.minTimeWindow,
|
|
2039
2245
|
maxTimeWindow: zoomCfg?.maxTimeWindow,
|
|
2040
2246
|
overscroll: timeScrollOverscroll,
|
|
2041
|
-
onZoomStart:
|
|
2042
|
-
"worklet";
|
|
2043
|
-
crosshairScrubActive.set(false);
|
|
2044
|
-
},
|
|
2247
|
+
onZoomStart: clearCrosshair,
|
|
2045
2248
|
});
|
|
2046
2249
|
|
|
2047
2250
|
const axisAutoHideOpacity = useAxisAutoHide({
|
|
2048
2251
|
config: axisAutoHide,
|
|
2252
|
+
scaleActive: axisScaleActive,
|
|
2049
2253
|
scrollActive,
|
|
2050
2254
|
scrubActive: crosshairScrubActive,
|
|
2051
2255
|
engine,
|
|
@@ -2064,8 +2268,11 @@ function useLiveChartController({
|
|
|
2064
2268
|
// ahead of the pan via Exclusive, so a tap is tried first and only becomes a
|
|
2065
2269
|
// drag (live-scrub, or lock-adjust once placed) if the finger moves. `Exclusive`
|
|
2066
2270
|
// (not `Race`) prevents a jittery tap from being swallowed by the pan.
|
|
2067
|
-
const
|
|
2068
|
-
|
|
2271
|
+
const crosshairGesture = crosshair.gesture;
|
|
2272
|
+
const crosshairTapGesture = crosshair.tapGesture;
|
|
2273
|
+
const rootGesture = useMemo(() => composeLiveChartRootGesture({
|
|
2274
|
+
crosshairGesture,
|
|
2275
|
+
crosshairTapGesture,
|
|
2069
2276
|
markerTapGesture,
|
|
2070
2277
|
refLineTapGesture,
|
|
2071
2278
|
refDragGesture,
|
|
@@ -2078,7 +2285,22 @@ function useLiveChartController({
|
|
|
2078
2285
|
timeScrollEnabled,
|
|
2079
2286
|
scrollGestureMode,
|
|
2080
2287
|
zoomEnabled,
|
|
2081
|
-
})
|
|
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
|
+
]);
|
|
2082
2304
|
|
|
2083
2305
|
// ── Derived render values ──────────────────────────────────────────────
|
|
2084
2306
|
const {
|
|
@@ -2130,6 +2352,15 @@ function useLiveChartController({
|
|
|
2130
2352
|
viewEnd: engine.viewEnd,
|
|
2131
2353
|
fadeOverlaysOnScrub,
|
|
2132
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
|
+
});
|
|
2133
2364
|
const modelDefaults = resolveLiveChartModelDefaults({
|
|
2134
2365
|
isCandle,
|
|
2135
2366
|
candleWidth,
|
|
@@ -2140,6 +2371,10 @@ function useLiveChartController({
|
|
|
2140
2371
|
});
|
|
2141
2372
|
|
|
2142
2373
|
return {
|
|
2374
|
+
effectiveYRangeScale,
|
|
2375
|
+
axisScaleActive,
|
|
2376
|
+
deferAxisScaleHit: deferTapHit,
|
|
2377
|
+
clearCrosshair,
|
|
2143
2378
|
// passthrough props the render needs
|
|
2144
2379
|
style,
|
|
2145
2380
|
canvasMode,
|
|
@@ -2159,6 +2394,7 @@ function useLiveChartController({
|
|
|
2159
2394
|
// configs
|
|
2160
2395
|
yAxisCfg,
|
|
2161
2396
|
yAxisFloat: effectiveYAxisFloat,
|
|
2397
|
+
referenceValueAxis,
|
|
2162
2398
|
xAxisCfg,
|
|
2163
2399
|
badgeCfg,
|
|
2164
2400
|
scrubCfg,
|
|
@@ -2172,6 +2408,7 @@ function useLiveChartController({
|
|
|
2172
2408
|
dotTracksParked,
|
|
2173
2409
|
dotOuterRadius,
|
|
2174
2410
|
gridStyleCfg,
|
|
2411
|
+
xGridStyleCfg,
|
|
2175
2412
|
degenCfg,
|
|
2176
2413
|
tradeStreamResolved,
|
|
2177
2414
|
tradeStream,
|
|
@@ -2182,11 +2419,12 @@ function useLiveChartController({
|
|
|
2182
2419
|
refLineCustom,
|
|
2183
2420
|
refLineOffAxisCustom,
|
|
2184
2421
|
refLineCustomTagWidths,
|
|
2185
|
-
dragValues,
|
|
2422
|
+
dragValues: drawnRefValues,
|
|
2186
2423
|
dragActive,
|
|
2187
2424
|
renderReferenceLine,
|
|
2188
2425
|
renderOffAxisReferenceLine,
|
|
2189
2426
|
refGroupingActive: refGroupingRadius != null,
|
|
2427
|
+
refStackEnabled, refStackAvoidValueBadge, refTagSizes, refTagStack, refLiveBadgeRect,
|
|
2190
2428
|
refGroupResult,
|
|
2191
2429
|
groupHidden,
|
|
2192
2430
|
refGroupBadge,
|
|
@@ -2244,6 +2482,7 @@ function useLiveChartController({
|
|
|
2244
2482
|
linePath,
|
|
2245
2483
|
fillPath,
|
|
2246
2484
|
thresholdFillPath,
|
|
2485
|
+
seriesClip,
|
|
2247
2486
|
lineIsLinear,
|
|
2248
2487
|
volumeCfg,
|
|
2249
2488
|
candleGapsCfg,
|
|
@@ -2284,15 +2523,18 @@ function useLiveChartController({
|
|
|
2284
2523
|
type LiveChartModel = ReturnType<typeof useLiveChartController>;
|
|
2285
2524
|
|
|
2286
2525
|
type YAxisEntries = ReturnType<typeof useYAxis>["yAxisEntries"];
|
|
2526
|
+
type XAxisEntries = ReturnType<typeof useXAxis>["xAxisEntries"];
|
|
2287
2527
|
type DegenState = ReturnType<typeof useDegen>;
|
|
2288
2528
|
|
|
2289
2529
|
/** Owns the particle/shake state only while the degen effect is enabled. */
|
|
2290
2530
|
function ChartWithDegen({
|
|
2291
2531
|
model,
|
|
2292
2532
|
yAxisEntries,
|
|
2533
|
+
xAxisEntries,
|
|
2293
2534
|
}: {
|
|
2294
2535
|
model: LiveChartModel;
|
|
2295
2536
|
yAxisEntries: YAxisEntries | null;
|
|
2537
|
+
xAxisEntries: XAxisEntries | null;
|
|
2296
2538
|
}) {
|
|
2297
2539
|
const {
|
|
2298
2540
|
engine,
|
|
@@ -2312,7 +2554,61 @@ function ChartWithDegen({
|
|
|
2312
2554
|
onDegenShake,
|
|
2313
2555
|
isFrameLoopActive,
|
|
2314
2556
|
);
|
|
2315
|
-
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
|
+
);
|
|
2316
2612
|
}
|
|
2317
2613
|
|
|
2318
2614
|
/**
|
|
@@ -2321,7 +2617,13 @@ function ChartWithDegen({
|
|
|
2321
2617
|
* The entries are passed through ordinary props so both paint-order positions
|
|
2322
2618
|
* receive the same mapper across the React Native → Skia renderer boundary.
|
|
2323
2619
|
*/
|
|
2324
|
-
function ChartWithYAxis({
|
|
2620
|
+
function ChartWithYAxis({
|
|
2621
|
+
model,
|
|
2622
|
+
xAxisEntries,
|
|
2623
|
+
}: {
|
|
2624
|
+
model: LiveChartModel;
|
|
2625
|
+
xAxisEntries: XAxisEntries | null;
|
|
2626
|
+
}) {
|
|
2325
2627
|
const {
|
|
2326
2628
|
engine,
|
|
2327
2629
|
effectivePadding,
|
|
@@ -2341,9 +2643,22 @@ function ChartWithYAxis({ model }: { model: LiveChartModel }) {
|
|
|
2341
2643
|
yAxisCfg?.intervalScale ?? 1,
|
|
2342
2644
|
);
|
|
2343
2645
|
if (model.degenCfg) {
|
|
2344
|
-
return
|
|
2646
|
+
return (
|
|
2647
|
+
<ChartWithDegen
|
|
2648
|
+
model={model}
|
|
2649
|
+
yAxisEntries={yAxisEntries}
|
|
2650
|
+
xAxisEntries={xAxisEntries}
|
|
2651
|
+
/>
|
|
2652
|
+
);
|
|
2345
2653
|
}
|
|
2346
|
-
return
|
|
2654
|
+
return (
|
|
2655
|
+
<ChartView
|
|
2656
|
+
model={model}
|
|
2657
|
+
yAxisEntries={yAxisEntries}
|
|
2658
|
+
xAxisEntries={xAxisEntries}
|
|
2659
|
+
degen={null}
|
|
2660
|
+
/>
|
|
2661
|
+
);
|
|
2347
2662
|
}
|
|
2348
2663
|
|
|
2349
2664
|
function ChartYAxisLayer({
|
|
@@ -2404,27 +2719,21 @@ function ChartYAxisLayer({
|
|
|
2404
2719
|
);
|
|
2405
2720
|
}
|
|
2406
2721
|
|
|
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
|
-
);
|
|
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;
|
|
2423
2732
|
return (
|
|
2424
2733
|
// Axis auto-hide fade (1 when the feature is off).
|
|
2425
2734
|
<Group opacity={model.axisAutoHideOpacity}>
|
|
2426
2735
|
<XAxisOverlay
|
|
2427
|
-
entries={
|
|
2736
|
+
entries={entries}
|
|
2428
2737
|
engine={engine}
|
|
2429
2738
|
padding={effectivePadding}
|
|
2430
2739
|
palette={palette}
|
|
@@ -2436,22 +2745,30 @@ function ChartXAxisLayer({ model }: { model: LiveChartModel }) {
|
|
|
2436
2745
|
}
|
|
2437
2746
|
|
|
2438
2747
|
/**
|
|
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
|
|
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.
|
|
2443
2753
|
*/
|
|
2444
2754
|
function ChartFillLayer({
|
|
2445
2755
|
model,
|
|
2446
2756
|
yAxisEntries,
|
|
2757
|
+
xAxisEntries,
|
|
2447
2758
|
degen,
|
|
2448
2759
|
}: {
|
|
2449
2760
|
model: LiveChartModel;
|
|
2450
2761
|
yAxisEntries: YAxisEntries | null;
|
|
2762
|
+
xAxisEntries: XAxisEntries | null;
|
|
2451
2763
|
degen: DegenState | null;
|
|
2452
2764
|
}) {
|
|
2453
2765
|
const {
|
|
2454
2766
|
yAxisCfg,
|
|
2767
|
+
xGridStyleCfg,
|
|
2768
|
+
engine,
|
|
2769
|
+
palette,
|
|
2770
|
+
volumeBandHeight,
|
|
2771
|
+
axisAutoHideOpacity,
|
|
2455
2772
|
yAxisFloat,
|
|
2456
2773
|
reveal,
|
|
2457
2774
|
effectivePadding,
|
|
@@ -2470,6 +2787,7 @@ function ChartFillLayer({
|
|
|
2470
2787
|
thresholdSeriesHasPoints,
|
|
2471
2788
|
thresholdFillUniforms,
|
|
2472
2789
|
seriesOpacity,
|
|
2790
|
+
seriesClip,
|
|
2473
2791
|
} = model;
|
|
2474
2792
|
return (
|
|
2475
2793
|
<Group transform={degen?.shakeTransform}>
|
|
@@ -2484,7 +2802,22 @@ function ChartFillLayer({
|
|
|
2484
2802
|
/>
|
|
2485
2803
|
)}
|
|
2486
2804
|
|
|
2487
|
-
|
|
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}>
|
|
2488
2821
|
{/* Dot-lattice area fill (the under-line `fillPath` painted with a dot
|
|
2489
2822
|
shader). Drawn before the gradient so a gradient (if also enabled)
|
|
2490
2823
|
composites on top. */}
|
|
@@ -2712,6 +3045,7 @@ function ChartCandleLayer({ model }: { model: LiveChartModel }) {
|
|
|
2712
3045
|
candleGapsCfg,
|
|
2713
3046
|
scrubCfg,
|
|
2714
3047
|
crosshair,
|
|
3048
|
+
seriesClip,
|
|
2715
3049
|
} = model;
|
|
2716
3050
|
const paths = useCandlePaths(
|
|
2717
3051
|
engine,
|
|
@@ -2822,7 +3156,7 @@ function ChartCandleLayer({ model }: { model: LiveChartModel }) {
|
|
|
2822
3156
|
|
|
2823
3157
|
return (
|
|
2824
3158
|
<Group opacity={seriesOpacity}>
|
|
2825
|
-
<Group opacity={candleGroupOpacity}>
|
|
3159
|
+
<Group opacity={candleGroupOpacity} clip={seriesClip}>
|
|
2826
3160
|
{candleGapsCfg && (
|
|
2827
3161
|
<ChartCandleGapLayer
|
|
2828
3162
|
model={model}
|
|
@@ -2932,9 +3266,11 @@ function ChartLineStrokeShader({ model }: { model: LiveChartModel }) {
|
|
|
2932
3266
|
function ChartMainPlotLayer({
|
|
2933
3267
|
model,
|
|
2934
3268
|
yAxisEntries,
|
|
3269
|
+
xAxisEntries,
|
|
2935
3270
|
}: {
|
|
2936
3271
|
model: LiveChartModel;
|
|
2937
3272
|
yAxisEntries: YAxisEntries | null;
|
|
3273
|
+
xAxisEntries: XAxisEntries | null;
|
|
2938
3274
|
}) {
|
|
2939
3275
|
const {
|
|
2940
3276
|
engine,
|
|
@@ -2947,14 +3283,14 @@ function ChartMainPlotLayer({
|
|
|
2947
3283
|
strokeWidth,
|
|
2948
3284
|
lineProp,
|
|
2949
3285
|
isCandle,
|
|
2950
|
-
xAxisCfg,
|
|
2951
3286
|
yAxisCfg,
|
|
2952
3287
|
yAxisFloat,
|
|
3288
|
+
seriesClip,
|
|
2953
3289
|
} = model;
|
|
2954
3290
|
|
|
2955
3291
|
return (
|
|
2956
3292
|
<>
|
|
2957
|
-
<Group opacity={seriesOpacity}>
|
|
3293
|
+
<Group opacity={seriesOpacity} clip={seriesClip}>
|
|
2958
3294
|
<Group opacity={lineGroupOpacity}>
|
|
2959
3295
|
<Path
|
|
2960
3296
|
path={linePath}
|
|
@@ -2979,7 +3315,9 @@ function ChartMainPlotLayer({
|
|
|
2979
3315
|
entries={yAxisEntries!}
|
|
2980
3316
|
/>
|
|
2981
3317
|
) : null}
|
|
2982
|
-
{
|
|
3318
|
+
{xAxisEntries ? (
|
|
3319
|
+
<ChartXAxisLayer model={model} entries={xAxisEntries} />
|
|
3320
|
+
) : null}
|
|
2983
3321
|
</>
|
|
2984
3322
|
);
|
|
2985
3323
|
}
|
|
@@ -2991,10 +3329,12 @@ function ChartMainPlotLayer({
|
|
|
2991
3329
|
function ChartStack({
|
|
2992
3330
|
model,
|
|
2993
3331
|
yAxisEntries,
|
|
3332
|
+
xAxisEntries,
|
|
2994
3333
|
degen,
|
|
2995
3334
|
}: {
|
|
2996
3335
|
model: LiveChartModel;
|
|
2997
3336
|
yAxisEntries: YAxisEntries | null;
|
|
3337
|
+
xAxisEntries: XAxisEntries | null;
|
|
2998
3338
|
degen: DegenState | null;
|
|
2999
3339
|
}) {
|
|
3000
3340
|
const {
|
|
@@ -3100,6 +3440,7 @@ function ChartStack({
|
|
|
3100
3440
|
engine={engine}
|
|
3101
3441
|
padding={effectivePadding}
|
|
3102
3442
|
line={rl}
|
|
3443
|
+
valueAxis={model.referenceValueAxis}
|
|
3103
3444
|
palette={palette}
|
|
3104
3445
|
formatValue={formatValue}
|
|
3105
3446
|
font={skiaFont}
|
|
@@ -3130,7 +3471,11 @@ function ChartStack({
|
|
|
3130
3471
|
/>
|
|
3131
3472
|
)}
|
|
3132
3473
|
|
|
3133
|
-
<ChartMainPlotLayer
|
|
3474
|
+
<ChartMainPlotLayer
|
|
3475
|
+
model={model}
|
|
3476
|
+
yAxisEntries={yAxisEntries}
|
|
3477
|
+
xAxisEntries={xAxisEntries}
|
|
3478
|
+
/>
|
|
3134
3479
|
|
|
3135
3480
|
{/* Live dot — the badge is drawn later (after the scrub layer) so the
|
|
3136
3481
|
scrub dim never clips the live-price badge's left edge. Hidden while
|
|
@@ -3442,9 +3787,11 @@ function ChartValueOverlay({
|
|
|
3442
3787
|
function ChartBadgeLayer({
|
|
3443
3788
|
model,
|
|
3444
3789
|
degen,
|
|
3790
|
+
yAxisEntries,
|
|
3445
3791
|
}: {
|
|
3446
3792
|
model: LiveChartModel;
|
|
3447
3793
|
degen: DegenState | null;
|
|
3794
|
+
yAxisEntries: YAxisEntries | null;
|
|
3448
3795
|
}) {
|
|
3449
3796
|
const {
|
|
3450
3797
|
badgeFont,
|
|
@@ -3456,8 +3803,27 @@ function ChartBadgeLayer({
|
|
|
3456
3803
|
metricsCfg,
|
|
3457
3804
|
yAxisFloat,
|
|
3458
3805
|
liveBadgeOpacity,
|
|
3806
|
+
skiaFont,
|
|
3807
|
+
yAxisCfg,
|
|
3808
|
+
badgeUsesRightGutter,
|
|
3459
3809
|
} = model;
|
|
3460
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;
|
|
3461
3827
|
const badgeData = useBadge(
|
|
3462
3828
|
engine,
|
|
3463
3829
|
effectivePadding,
|
|
@@ -3476,7 +3842,18 @@ function ChartBadgeLayer({
|
|
|
3476
3842
|
badgeCfg.followViewEdge,
|
|
3477
3843
|
badgeCfg.radius,
|
|
3478
3844
|
badgeCfg.textColor,
|
|
3845
|
+
labelColumn?.entries,
|
|
3846
|
+
labelColumn?.labelRightMargin,
|
|
3847
|
+
labelColumn?.font,
|
|
3479
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
|
+
});
|
|
3480
3857
|
return (
|
|
3481
3858
|
<Group transform={degen?.shakeTransform}>
|
|
3482
3859
|
<Group opacity={liveBadgeOpacity}>
|
|
@@ -3537,6 +3914,7 @@ function ChartRefBadgeLayer({
|
|
|
3537
3914
|
engine={engine}
|
|
3538
3915
|
padding={effectivePadding}
|
|
3539
3916
|
line={rl}
|
|
3917
|
+
valueAxis={model.referenceValueAxis}
|
|
3540
3918
|
palette={palette}
|
|
3541
3919
|
formatValue={formatValue}
|
|
3542
3920
|
font={skiaFont}
|
|
@@ -3547,6 +3925,7 @@ function ChartRefBadgeLayer({
|
|
|
3547
3925
|
suppressTag={refLineCustom[i]}
|
|
3548
3926
|
suppressTagWhenOffAxis={refLineOffAxisCustom[i]}
|
|
3549
3927
|
customTagWidths={refLineCustomTagWidths}
|
|
3928
|
+
tagStack={model.refStackEnabled ? model.refTagStack : undefined}
|
|
3550
3929
|
groupHidden={refGroupingActive ? groupHidden : undefined}
|
|
3551
3930
|
yAxisEntries={yAxisEntries}
|
|
3552
3931
|
labelRightMargin={yAxisCfg?.labelRightMargin}
|
|
@@ -3664,6 +4043,8 @@ function ChartCustomAnnotations({ model }: { model: LiveChartModel }) {
|
|
|
3664
4043
|
dragValues={dragValues}
|
|
3665
4044
|
dragActive={dragActive}
|
|
3666
4045
|
tagWidths={refLineCustomTagWidths}
|
|
4046
|
+
tagSizes={model.refStackEnabled ? model.refTagSizes : undefined}
|
|
4047
|
+
tagStack={model.refStackEnabled ? model.refTagStack : undefined}
|
|
3667
4048
|
/>
|
|
3668
4049
|
)}
|
|
3669
4050
|
{renderOffAxisReferenceLine && allRefLines.length > 0 && (
|
|
@@ -3677,6 +4058,8 @@ function ChartCustomAnnotations({ model }: { model: LiveChartModel }) {
|
|
|
3677
4058
|
dragValues={dragValues}
|
|
3678
4059
|
dragActive={dragActive}
|
|
3679
4060
|
tagWidths={refLineCustomTagWidths}
|
|
4061
|
+
tagSizes={model.refStackEnabled ? model.refTagSizes : undefined}
|
|
4062
|
+
tagStack={model.refStackEnabled ? model.refTagStack : undefined}
|
|
3680
4063
|
offAxisOnly
|
|
3681
4064
|
/>
|
|
3682
4065
|
)}
|
|
@@ -3694,10 +4077,12 @@ function ChartCustomConsumerOverlay({ model }: { model: LiveChartModel }) {
|
|
|
3694
4077
|
function ChartCanvas({
|
|
3695
4078
|
model,
|
|
3696
4079
|
yAxisEntries,
|
|
4080
|
+
xAxisEntries,
|
|
3697
4081
|
degen,
|
|
3698
4082
|
}: {
|
|
3699
4083
|
model: LiveChartModel;
|
|
3700
4084
|
yAxisEntries: YAxisEntries | null;
|
|
4085
|
+
xAxisEntries: XAxisEntries | null;
|
|
3701
4086
|
degen: DegenState | null;
|
|
3702
4087
|
}) {
|
|
3703
4088
|
const {
|
|
@@ -3728,7 +4113,12 @@ function ChartCanvas({
|
|
|
3728
4113
|
color={backgroundColor}
|
|
3729
4114
|
/>
|
|
3730
4115
|
) : null}
|
|
3731
|
-
<ChartFillLayer
|
|
4116
|
+
<ChartFillLayer
|
|
4117
|
+
model={model}
|
|
4118
|
+
yAxisEntries={yAxisEntries}
|
|
4119
|
+
xAxisEntries={xAxisEntries}
|
|
4120
|
+
degen={degen}
|
|
4121
|
+
/>
|
|
3732
4122
|
{leftEdgeFadeCfg ? (
|
|
3733
4123
|
<LeftEdgeFade
|
|
3734
4124
|
paddingLeft={effectivePadding.left}
|
|
@@ -3741,7 +4131,12 @@ function ChartCanvas({
|
|
|
3741
4131
|
}
|
|
3742
4132
|
/>
|
|
3743
4133
|
) : null}
|
|
3744
|
-
<ChartStack
|
|
4134
|
+
<ChartStack
|
|
4135
|
+
model={model}
|
|
4136
|
+
yAxisEntries={yAxisEntries}
|
|
4137
|
+
xAxisEntries={xAxisEntries}
|
|
4138
|
+
degen={degen}
|
|
4139
|
+
/>
|
|
3745
4140
|
{topConnector || bottomConnector ? (
|
|
3746
4141
|
<ExtremaConnectorOverlay
|
|
3747
4142
|
engine={engine}
|
|
@@ -3766,7 +4161,13 @@ function ChartCanvas({
|
|
|
3766
4161
|
<ChartTradeStreamLayer model={model} degen={degen} />
|
|
3767
4162
|
) : null}
|
|
3768
4163
|
<ChartScrubLayer model={model} degen={degen} />
|
|
3769
|
-
{model.badgeCfg ?
|
|
4164
|
+
{model.badgeCfg ? (
|
|
4165
|
+
<ChartBadgeLayer
|
|
4166
|
+
model={model}
|
|
4167
|
+
degen={degen}
|
|
4168
|
+
yAxisEntries={yAxisEntries}
|
|
4169
|
+
/>
|
|
4170
|
+
) : null}
|
|
3770
4171
|
<ChartScrubActionLayer model={model} />
|
|
3771
4172
|
</Canvas>
|
|
3772
4173
|
);
|
|
@@ -3836,6 +4237,7 @@ function ChartNativeOverlays({ model }: { model: LiveChartModel }) {
|
|
|
3836
4237
|
scrubActive={crosshair.scrubActive}
|
|
3837
4238
|
scrubCandle={crosshair.scrubCandle}
|
|
3838
4239
|
scrubGap={crosshair.scrubGap}
|
|
4240
|
+
scrubMarkers={crosshair.scrubMarkers}
|
|
3839
4241
|
tooltipLayout={crosshair.tooltipLayout}
|
|
3840
4242
|
engine={engine}
|
|
3841
4243
|
padding={effectivePadding}
|
|
@@ -3855,10 +4257,12 @@ function ChartNativeOverlays({ model }: { model: LiveChartModel }) {
|
|
|
3855
4257
|
function ChartView({
|
|
3856
4258
|
model,
|
|
3857
4259
|
yAxisEntries,
|
|
4260
|
+
xAxisEntries,
|
|
3858
4261
|
degen,
|
|
3859
4262
|
}: {
|
|
3860
4263
|
model: LiveChartModel;
|
|
3861
4264
|
yAxisEntries: YAxisEntries | null;
|
|
4265
|
+
xAxisEntries: XAxisEntries | null;
|
|
3862
4266
|
degen: DegenState | null;
|
|
3863
4267
|
}) {
|
|
3864
4268
|
const {
|
|
@@ -3870,8 +4274,22 @@ function ChartView({
|
|
|
3870
4274
|
accessibilityRole,
|
|
3871
4275
|
} = model;
|
|
3872
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
|
+
|
|
3873
4291
|
return (
|
|
3874
|
-
<GestureDetector gesture={
|
|
4292
|
+
<GestureDetector gesture={gesture}>
|
|
3875
4293
|
<View
|
|
3876
4294
|
style={[{ flex: 1, backgroundColor }, style]}
|
|
3877
4295
|
onLayout={onLayout}
|
|
@@ -3879,15 +4297,22 @@ function ChartView({
|
|
|
3879
4297
|
accessibilityLabel={accessibilityLabel}
|
|
3880
4298
|
accessibilityRole={accessibilityRole}
|
|
3881
4299
|
>
|
|
3882
|
-
<ChartCanvas
|
|
4300
|
+
<ChartCanvas
|
|
4301
|
+
model={model}
|
|
4302
|
+
yAxisEntries={yAxisEntries}
|
|
4303
|
+
xAxisEntries={xAxisEntries}
|
|
4304
|
+
degen={degen}
|
|
4305
|
+
/>
|
|
3883
4306
|
<ChartNativeOverlays model={model} />
|
|
3884
4307
|
</View>
|
|
3885
4308
|
</GestureDetector>
|
|
3886
4309
|
);
|
|
3887
4310
|
}
|
|
3888
4311
|
|
|
3889
|
-
|
|
3890
|
-
|
|
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) {
|
|
3891
4316
|
const model = useLiveChartController(props);
|
|
3892
4317
|
const { viewEnd, viewWindow } = model.engine;
|
|
3893
4318
|
useImperativeHandle(
|
|
@@ -3897,12 +4322,9 @@ export const LiveChart = forwardRef<LiveChartHandle, LiveChartProps>(
|
|
|
3897
4322
|
}),
|
|
3898
4323
|
[viewEnd, viewWindow],
|
|
3899
4324
|
);
|
|
3900
|
-
if (model.
|
|
3901
|
-
return <
|
|
3902
|
-
}
|
|
3903
|
-
if (model.degenCfg) {
|
|
3904
|
-
return <ChartWithDegen model={model} yAxisEntries={null} />;
|
|
4325
|
+
if (model.xAxisCfg) {
|
|
4326
|
+
return <ChartWithXAxis model={model} />;
|
|
3905
4327
|
}
|
|
3906
|
-
return <
|
|
3907
|
-
},
|
|
4328
|
+
return <ChartWithYAxisOrDegen model={model} xAxisEntries={null} />;
|
|
4329
|
+
}),
|
|
3908
4330
|
);
|