react-native-livechart 4.21.0 → 4.21.1
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/AxisLabelOverlay.d.ts +5 -1
- package/dist/components/AxisLabelOverlay.d.ts.map +1 -1
- package/dist/components/CrosshairOverlay.d.ts +4 -2
- package/dist/components/CrosshairOverlay.d.ts.map +1 -1
- package/dist/components/CustomMarkerOverlay.d.ts.map +1 -1
- package/dist/components/DegenParticlesOverlay.d.ts.map +1 -1
- package/dist/components/ExtremaConnectorOverlay.d.ts +5 -1
- package/dist/components/ExtremaConnectorOverlay.d.ts.map +1 -1
- package/dist/components/LiveChart.d.ts.map +1 -1
- package/dist/components/LiveChartSeries.d.ts.map +1 -1
- package/dist/components/MarkerOverlay.d.ts +4 -2
- package/dist/components/MarkerOverlay.d.ts.map +1 -1
- package/dist/components/ReferenceLineOverlay.d.ts +1 -1
- package/dist/components/ReferenceLineOverlay.d.ts.map +1 -1
- package/dist/core/chartDataPresence.d.ts +8 -0
- package/dist/core/chartDataPresence.d.ts.map +1 -0
- package/dist/core/useLiveChartEngine.d.ts.map +1 -1
- package/dist/core/useLiveChartSeriesEngine.d.ts.map +1 -1
- package/dist/draw/markerAtlas.d.ts +3 -2
- package/dist/draw/markerAtlas.d.ts.map +1 -1
- package/dist/hooks/useChartReveal.d.ts +1 -1
- package/dist/hooks/useChartReveal.d.ts.map +1 -1
- package/dist/hooks/useCrosshair.d.ts.map +1 -1
- package/dist/hooks/useDegen.d.ts.map +1 -1
- package/dist/hooks/useLiveChartHasData.d.ts +2 -2
- package/dist/hooks/useLiveChartHasData.d.ts.map +1 -1
- package/dist/hooks/useReverseMorphEngineInputs.d.ts.map +1 -1
- package/dist/types.d.ts +3 -3
- package/package.json +1 -1
- package/src/components/AxisLabelOverlay.tsx +162 -81
- package/src/components/CrosshairOverlay.tsx +394 -147
- package/src/components/CustomMarkerOverlay.tsx +9 -6
- package/src/components/DegenParticlesOverlay.tsx +34 -23
- package/src/components/ExtremaConnectorOverlay.tsx +43 -3
- package/src/components/LiveChart.tsx +1692 -1025
- package/src/components/LiveChartSeries.tsx +445 -296
- package/src/components/MarkerOverlay.tsx +215 -156
- package/src/components/ReferenceLineOverlay.tsx +77 -50
- package/src/core/chartDataPresence.ts +24 -0
- package/src/core/useLiveChartEngine.ts +6 -3
- package/src/core/useLiveChartSeriesEngine.ts +2 -0
- package/src/draw/markerAtlas.ts +8 -3
- package/src/hooks/useChartReveal.ts +1 -1
- package/src/hooks/useCrosshair.ts +69 -46
- package/src/hooks/useDegen.ts +82 -53
- package/src/hooks/useLiveChartHasData.ts +8 -4
- package/src/hooks/useReverseMorphEngineInputs.ts +11 -20
- package/src/types.ts +3 -3
|
@@ -11,7 +11,11 @@ import type {
|
|
|
11
11
|
} from "../core/useLiveChartEngine";
|
|
12
12
|
import type { ChartPadding } from "../draw/line";
|
|
13
13
|
import { usePathBuilder } from "../hooks/usePathBuilder";
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
EXTREMA_EDGE_INSET,
|
|
16
|
+
EXTREMA_LABEL_FONT_SIZE,
|
|
17
|
+
extremaPointsCoincide,
|
|
18
|
+
} from "./AxisLabelOverlay";
|
|
15
19
|
|
|
16
20
|
/** How far off-plot (px) the extremum may sit before the connector is dropped. */
|
|
17
21
|
const CONNECTOR_CULL = 24;
|
|
@@ -55,6 +59,7 @@ function ConnectorLine({
|
|
|
55
59
|
engine,
|
|
56
60
|
padding,
|
|
57
61
|
config,
|
|
62
|
+
suppressWhen,
|
|
58
63
|
}: {
|
|
59
64
|
side: "top" | "bottom";
|
|
60
65
|
timeSV: SharedValue<number>;
|
|
@@ -63,6 +68,10 @@ function ConnectorLine({
|
|
|
63
68
|
engine: ChartEngineLayout;
|
|
64
69
|
padding: ChartPadding;
|
|
65
70
|
config: ResolvedConnector;
|
|
71
|
+
suppressWhen?: {
|
|
72
|
+
timeSV: SharedValue<number>;
|
|
73
|
+
valueSV: SharedValue<number>;
|
|
74
|
+
};
|
|
66
75
|
}) {
|
|
67
76
|
const builder = usePathBuilder();
|
|
68
77
|
const { line, fontSize } = config;
|
|
@@ -88,6 +97,13 @@ function ConnectorLine({
|
|
|
88
97
|
|
|
89
98
|
if (
|
|
90
99
|
!Number.isFinite(value) ||
|
|
100
|
+
(suppressWhen != null &&
|
|
101
|
+
extremaPointsCoincide(
|
|
102
|
+
time,
|
|
103
|
+
value,
|
|
104
|
+
suppressWhen.timeSV.get(),
|
|
105
|
+
suppressWhen.valueSV.get(),
|
|
106
|
+
)) ||
|
|
91
107
|
cw === 0 ||
|
|
92
108
|
ch === 0 ||
|
|
93
109
|
chartW <= 0 ||
|
|
@@ -153,15 +169,29 @@ export function ExtremaConnectorOverlay({
|
|
|
153
169
|
extremaTimeOffset = 0,
|
|
154
170
|
top,
|
|
155
171
|
bottom,
|
|
172
|
+
hideExtrema = false,
|
|
173
|
+
suppressBottomWhenCoincident = false,
|
|
156
174
|
}: {
|
|
157
175
|
engine: ChartEngineLayout & Partial<ChartEngineExtrema>;
|
|
158
176
|
padding: ChartPadding;
|
|
159
177
|
extremaTimeOffset?: number;
|
|
160
178
|
top: ResolvedConnector | null;
|
|
161
179
|
bottom: ResolvedConnector | null;
|
|
180
|
+
/** Hide extrema connectors while the chart is showing its loading shell. */
|
|
181
|
+
hideExtrema?: boolean;
|
|
182
|
+
/** Drop the lower connector when both configured labels share one point. */
|
|
183
|
+
suppressBottomWhenCoincident?: boolean;
|
|
162
184
|
}) {
|
|
163
|
-
const hasTop =
|
|
164
|
-
|
|
185
|
+
const hasTop =
|
|
186
|
+
!hideExtrema &&
|
|
187
|
+
top != null &&
|
|
188
|
+
engine.extremaMaxTime != null &&
|
|
189
|
+
engine.extremaMaxValue != null;
|
|
190
|
+
const hasBottom =
|
|
191
|
+
!hideExtrema &&
|
|
192
|
+
bottom != null &&
|
|
193
|
+
engine.extremaMinTime != null &&
|
|
194
|
+
engine.extremaMinValue != null;
|
|
165
195
|
if (!hasTop && !hasBottom) return null;
|
|
166
196
|
|
|
167
197
|
return (
|
|
@@ -186,6 +216,16 @@ export function ExtremaConnectorOverlay({
|
|
|
186
216
|
engine={engine}
|
|
187
217
|
padding={padding}
|
|
188
218
|
config={bottom!}
|
|
219
|
+
suppressWhen={
|
|
220
|
+
suppressBottomWhenCoincident &&
|
|
221
|
+
engine.extremaMaxTime != null &&
|
|
222
|
+
engine.extremaMaxValue != null
|
|
223
|
+
? {
|
|
224
|
+
timeSV: engine.extremaMaxTime!,
|
|
225
|
+
valueSV: engine.extremaMaxValue!,
|
|
226
|
+
}
|
|
227
|
+
: undefined
|
|
228
|
+
}
|
|
189
229
|
/>
|
|
190
230
|
)}
|
|
191
231
|
</>
|