react-native-livechart 3.12.0 → 4.1.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/BadgeOverlay.d.ts +9 -1
- package/dist/components/BadgeOverlay.d.ts.map +1 -1
- package/dist/components/ChartOverlayLayer.d.ts +19 -0
- package/dist/components/ChartOverlayLayer.d.ts.map +1 -0
- package/dist/components/CustomMarkerOverlay.d.ts +16 -6
- package/dist/components/CustomMarkerOverlay.d.ts.map +1 -1
- package/dist/components/CustomReferenceLineOverlay.d.ts +36 -0
- package/dist/components/CustomReferenceLineOverlay.d.ts.map +1 -0
- package/dist/components/CustomTooltipOverlay.d.ts +5 -2
- package/dist/components/CustomTooltipOverlay.d.ts.map +1 -1
- package/dist/components/DotOverlay.d.ts +7 -1
- package/dist/components/DotOverlay.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 +6 -3
- package/dist/components/MarkerOverlay.d.ts.map +1 -1
- package/dist/components/MultiSeriesDots.d.ts +4 -1
- package/dist/components/MultiSeriesDots.d.ts.map +1 -1
- package/dist/components/ReferenceLineGroupOverlay.d.ts +27 -0
- package/dist/components/ReferenceLineGroupOverlay.d.ts.map +1 -0
- package/dist/components/ReferenceLineOverlay.d.ts +25 -2
- package/dist/components/ReferenceLineOverlay.d.ts.map +1 -1
- package/dist/components/XAxisOverlay.d.ts +7 -1
- package/dist/components/XAxisOverlay.d.ts.map +1 -1
- package/dist/components/YAxisOverlay.d.ts +12 -1
- package/dist/components/YAxisOverlay.d.ts.map +1 -1
- package/dist/constants.d.ts +13 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/core/liveChartEngineTick.d.ts +29 -0
- package/dist/core/liveChartEngineTick.d.ts.map +1 -1
- package/dist/core/liveChartSeriesEngineTick.d.ts +18 -0
- package/dist/core/liveChartSeriesEngineTick.d.ts.map +1 -1
- package/dist/core/resolveConfig.d.ts +62 -2
- package/dist/core/resolveConfig.d.ts.map +1 -1
- package/dist/core/useLiveChartEngine.d.ts +58 -7
- package/dist/core/useLiveChartEngine.d.ts.map +1 -1
- package/dist/core/useLiveChartSeriesEngine.d.ts +8 -2
- package/dist/core/useLiveChartSeriesEngine.d.ts.map +1 -1
- package/dist/draw/grid.d.ts +13 -1
- package/dist/draw/grid.d.ts.map +1 -1
- package/dist/draw/markerAtlas.d.ts +20 -2
- package/dist/draw/markerAtlas.d.ts.map +1 -1
- package/dist/draw/volume.d.ts +25 -0
- package/dist/draw/volume.d.ts.map +1 -0
- package/dist/hooks/crosshairShared.d.ts +12 -6
- package/dist/hooks/crosshairShared.d.ts.map +1 -1
- package/dist/hooks/overlayScale.d.ts +22 -0
- package/dist/hooks/overlayScale.d.ts.map +1 -0
- package/dist/hooks/resolveChartLayout.d.ts +9 -0
- package/dist/hooks/resolveChartLayout.d.ts.map +1 -1
- package/dist/hooks/useBadge.d.ts +22 -1
- package/dist/hooks/useBadge.d.ts.map +1 -1
- package/dist/hooks/useCandlePaths.d.ts +6 -0
- package/dist/hooks/useCandlePaths.d.ts.map +1 -1
- package/dist/hooks/useChartOverlayContext.d.ts +45 -0
- package/dist/hooks/useChartOverlayContext.d.ts.map +1 -0
- package/dist/hooks/useChartPaths.d.ts +8 -1
- package/dist/hooks/useChartPaths.d.ts.map +1 -1
- package/dist/hooks/useCrosshair.d.ts +9 -2
- package/dist/hooks/useCrosshair.d.ts.map +1 -1
- package/dist/hooks/useLiveDot.d.ts +6 -1
- package/dist/hooks/useLiveDot.d.ts.map +1 -1
- package/dist/hooks/useMarkers.d.ts +9 -4
- package/dist/hooks/useMarkers.d.ts.map +1 -1
- package/dist/hooks/usePanScroll.d.ts +82 -0
- package/dist/hooks/usePanScroll.d.ts.map +1 -0
- package/dist/hooks/usePinchZoom.d.ts +74 -0
- package/dist/hooks/usePinchZoom.d.ts.map +1 -0
- package/dist/hooks/useReferenceDrag.d.ts +24 -0
- package/dist/hooks/useReferenceDrag.d.ts.map +1 -0
- package/dist/hooks/useReferenceLine.d.ts +23 -4
- package/dist/hooks/useReferenceLine.d.ts.map +1 -1
- package/dist/hooks/useReferenceLinePress.d.ts +5 -1
- package/dist/hooks/useReferenceLinePress.d.ts.map +1 -1
- package/dist/hooks/useVisibleRange.d.ts +39 -0
- package/dist/hooks/useVisibleRange.d.ts.map +1 -0
- package/dist/hooks/useYAxis.d.ts +1 -1
- package/dist/hooks/useYAxis.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/math/markerCluster.d.ts +47 -0
- package/dist/math/markerCluster.d.ts.map +1 -0
- package/dist/math/markers.d.ts +10 -0
- package/dist/math/markers.d.ts.map +1 -1
- package/dist/math/referenceDrag.d.ts +24 -0
- package/dist/math/referenceDrag.d.ts.map +1 -0
- package/dist/math/referenceGroup.d.ts +31 -0
- package/dist/math/referenceGroup.d.ts.map +1 -0
- package/dist/math/referenceLines.d.ts +33 -7
- package/dist/math/referenceLines.d.ts.map +1 -1
- package/dist/types.d.ts +524 -21
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/BadgeOverlay.tsx +26 -1
- package/src/components/ChartOverlayLayer.tsx +32 -0
- package/src/components/CustomMarkerOverlay.tsx +150 -57
- package/src/components/CustomReferenceLineOverlay.tsx +250 -0
- package/src/components/CustomTooltipOverlay.tsx +27 -7
- package/src/components/DotOverlay.tsx +9 -0
- package/src/components/LiveChart.tsx +550 -32
- package/src/components/LiveChartSeries.tsx +111 -5
- package/src/components/MarkerOverlay.tsx +92 -6
- package/src/components/MultiSeriesDots.tsx +12 -3
- package/src/components/ReferenceLineGroupOverlay.tsx +207 -0
- package/src/components/ReferenceLineOverlay.tsx +105 -32
- package/src/components/XAxisOverlay.tsx +9 -2
- package/src/components/YAxisOverlay.tsx +49 -28
- package/src/constants.ts +17 -0
- package/src/core/liveChartEngineTick.ts +81 -8
- package/src/core/liveChartSeriesEngineTick.ts +50 -9
- package/src/core/resolveConfig.ts +133 -2
- package/src/core/useLiveChartEngine.ts +111 -11
- package/src/core/useLiveChartSeriesEngine.ts +26 -3
- package/src/draw/grid.ts +71 -2
- package/src/draw/markerAtlas.ts +117 -3
- package/src/draw/volume.ts +190 -0
- package/src/hooks/crosshairShared.ts +37 -9
- package/src/hooks/overlayScale.ts +59 -0
- package/src/hooks/resolveChartLayout.ts +33 -0
- package/src/hooks/useBadge.ts +89 -21
- package/src/hooks/useCandlePaths.ts +104 -7
- package/src/hooks/useChartOverlayContext.ts +93 -0
- package/src/hooks/useChartPaths.ts +14 -1
- package/src/hooks/useCrosshair.ts +33 -2
- package/src/hooks/useLiveDot.ts +16 -5
- package/src/hooks/useMarkers.ts +39 -11
- package/src/hooks/usePanScroll.ts +253 -0
- package/src/hooks/usePinchZoom.ts +189 -0
- package/src/hooks/useReferenceDrag.ts +254 -0
- package/src/hooks/useReferenceLine.ts +56 -9
- package/src/hooks/useReferenceLinePress.ts +16 -2
- package/src/hooks/useVisibleRange.ts +119 -0
- package/src/hooks/useYAxis.ts +2 -0
- package/src/index.ts +17 -1
- package/src/math/markerCluster.ts +214 -0
- package/src/math/markers.ts +35 -3
- package/src/math/referenceDrag.ts +66 -0
- package/src/math/referenceGroup.ts +65 -0
- package/src/math/referenceLines.ts +76 -19
- package/src/types.ts +544 -21
package/dist/types.d.ts
CHANGED
|
@@ -56,6 +56,15 @@ export interface ReferenceLine {
|
|
|
56
56
|
strokeWidth?: number;
|
|
57
57
|
/** Dash pattern as `[dashLength, gapLength]` in pixels (line stroke + band border). */
|
|
58
58
|
intervals?: [number, number];
|
|
59
|
+
/**
|
|
60
|
+
* Span the **full chart width** — edge to edge through the Y-axis gutter, not
|
|
61
|
+
* clipped at the plot's right edge — so the line/band visually connects to its
|
|
62
|
+
* value on the axis (like a price tag). Only the line/band extends; any
|
|
63
|
+
* `label`/`badge` stays anchored inside the plot. For a Form-A line with a
|
|
64
|
+
* `badge`, the full-width line replaces the dashed connector. No effect on a
|
|
65
|
+
* vertical time band. Default `false` (stops at the plot edge). Form A / B.
|
|
66
|
+
*/
|
|
67
|
+
fullWidth?: boolean;
|
|
59
68
|
/** Line / band color override. Defaults to palette `refLine`. */
|
|
60
69
|
color?: string;
|
|
61
70
|
/** Fill opacity for a value / time band (0–1). Default `0.16`. */
|
|
@@ -103,16 +112,103 @@ export interface ReferenceLine {
|
|
|
103
112
|
badgeBorderColor?: string;
|
|
104
113
|
/** Badge pill corner radius in pixels. Default `5`. (Fallback for `badge.radius`.) */
|
|
105
114
|
badgeRadius?: number;
|
|
115
|
+
/**
|
|
116
|
+
* Make this Form-A line **draggable** along the Y-axis — grab its handle / badge
|
|
117
|
+
* and drag to set a new value (a working-order price, alert level, or target).
|
|
118
|
+
* The line tracks the finger on the UI thread; {@link onChange} / {@link onCommit}
|
|
119
|
+
* report the value to JS. The line is *uncontrolled* by default (it stays where
|
|
120
|
+
* you drop it); pair `onCommit` with writing the value back into `value` to make
|
|
121
|
+
* it controlled. No effect on bands / time bands. Default `false`.
|
|
122
|
+
*/
|
|
123
|
+
draggable?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Snap the dragged value to this increment (e.g. `0.01` for cents, `0.5` for a
|
|
126
|
+
* tick size) so drops land on round levels. Omit for free dragging. Applies only
|
|
127
|
+
* while {@link draggable}.
|
|
128
|
+
*/
|
|
129
|
+
snap?: number;
|
|
130
|
+
/**
|
|
131
|
+
* Hard-clamp the draggable value to `[min, max]` in Y-axis units — the line
|
|
132
|
+
* can't be dragged past either end. Omit for unbounded (clamped only to the
|
|
133
|
+
* visible range). Reaching a bound fires {@link onDragOut}. Applies only while
|
|
134
|
+
* {@link draggable}.
|
|
135
|
+
*/
|
|
136
|
+
bounds?: [number, number];
|
|
137
|
+
/**
|
|
138
|
+
* Fired on the JS thread *while* dragging, each time the (snapped, clamped)
|
|
139
|
+
* value changes. De-duplicated to value changes — not every frame. Form-A
|
|
140
|
+
* draggable only.
|
|
141
|
+
*/
|
|
142
|
+
onChange?: (value: number) => void;
|
|
143
|
+
/**
|
|
144
|
+
* Fired once on the JS thread when the drag ends (finger up), with the final
|
|
145
|
+
* (snapped, clamped) value. Pair with a controlled `value` to persist the move.
|
|
146
|
+
* Form-A draggable only.
|
|
147
|
+
*/
|
|
148
|
+
onCommit?: (value: number) => void;
|
|
149
|
+
/**
|
|
150
|
+
* Fired on the JS thread when the line's value crosses **into** its watched
|
|
151
|
+
* interval — the visible Y-range, or {@link bounds} when set. Triggers from
|
|
152
|
+
* dragging *or* the axis rescaling under a fixed value (e.g. a target scrolling
|
|
153
|
+
* back into view). Edge-triggered: once per crossing. Form-A only.
|
|
154
|
+
*/
|
|
155
|
+
onDragIn?: (value: number) => void;
|
|
156
|
+
/**
|
|
157
|
+
* Fired on the JS thread when the line's value crosses **out of** its watched
|
|
158
|
+
* interval (the visible Y-range, or {@link bounds}) — dragged/scrolled off-screen
|
|
159
|
+
* or pinned at a bound. Edge-triggered: once per crossing. Form-A only.
|
|
160
|
+
*/
|
|
161
|
+
onDragOut?: (value: number) => void;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Shared **style & shape** knobs for every badge pill — the value `badge`
|
|
165
|
+
* ({@link BadgeConfig}), reference-line badges ({@link ReferenceLineBadgeConfig}),
|
|
166
|
+
* and the grouping count pill. Each badge interface extends this and adds its own
|
|
167
|
+
* anchor (`position`) / content fields. Unset values fall back to that badge's own
|
|
168
|
+
* defaults (documented on each interface). One source of truth so every badge is
|
|
169
|
+
* configured identically.
|
|
170
|
+
*/
|
|
171
|
+
export interface BadgeStyleConfig {
|
|
172
|
+
/** Pill background color. */
|
|
173
|
+
background?: string;
|
|
174
|
+
/** Pill border color. */
|
|
175
|
+
borderColor?: string;
|
|
176
|
+
/** Border stroke width in pixels. Default `1`. */
|
|
177
|
+
borderWidth?: number;
|
|
178
|
+
/** Pill corner radius in pixels. */
|
|
179
|
+
radius?: number;
|
|
180
|
+
/** Label / icon text color override. */
|
|
181
|
+
textColor?: string;
|
|
182
|
+
/** Badge font size in pixels. Falls back to the chart `font`. */
|
|
183
|
+
fontSize?: number;
|
|
184
|
+
/** Badge font family. Falls back to the chart `font`. */
|
|
185
|
+
fontFamily?: string;
|
|
186
|
+
/** Badge font weight. Falls back to the chart `font`. */
|
|
187
|
+
fontWeight?: FontWeight;
|
|
188
|
+
/** Nudge the whole badge horizontally from its anchor, in pixels. Default `0`. */
|
|
189
|
+
offsetX?: number;
|
|
190
|
+
/** Nudge the whole badge vertically from its anchor, in pixels. Default `0`. */
|
|
191
|
+
offsetY?: number;
|
|
106
192
|
}
|
|
107
193
|
/**
|
|
108
194
|
* Pill-badge presentation for a Form-A {@link ReferenceLine} — a working order,
|
|
109
195
|
* price alert, or target tag. The badge sits at the line's value (pinned to
|
|
110
196
|
* `position`) with a dashed connector to the opposite edge, and pins to the
|
|
111
197
|
* nearest edge with a chevron once the value scrolls off-screen.
|
|
198
|
+
*
|
|
199
|
+
* Extends {@link BadgeStyleConfig} for the style/shape knobs. Their reference-line
|
|
200
|
+
* fallbacks: `background` → `badgeBackground` → theme `tooltipBg`; `borderColor` →
|
|
201
|
+
* `badgeBorderColor` → the line `color`; `radius` → `badgeRadius` → `5`; `textColor`
|
|
202
|
+
* → `labelColor` → the line `color` → theme `refLabel`; the `font*` knobs → the
|
|
203
|
+
* chart `font`.
|
|
112
204
|
*/
|
|
113
|
-
export interface ReferenceLineBadgeConfig {
|
|
114
|
-
/**
|
|
115
|
-
|
|
205
|
+
export interface ReferenceLineBadgeConfig extends BadgeStyleConfig {
|
|
206
|
+
/**
|
|
207
|
+
* Where the badge pins horizontally. `"left"` / `"right"` pin to that plot edge
|
|
208
|
+
* with a dashed connector running to the opposite edge; `"center"` floats the
|
|
209
|
+
* pill centered in the plot at the line's value (no connector). Default `"left"`.
|
|
210
|
+
*/
|
|
211
|
+
position?: "left" | "center" | "right";
|
|
116
212
|
/**
|
|
117
213
|
* Leading glyph drawn in the badge — rendered with the chart font, so pass an
|
|
118
214
|
* emoji-capable font (via the chart `font` prop) for emoji. Like `Marker.icon`.
|
|
@@ -123,12 +219,69 @@ export interface ReferenceLineBadgeConfig {
|
|
|
123
219
|
* Default `true`. Set `false` for an **icon-only** badge.
|
|
124
220
|
*/
|
|
125
221
|
text?: boolean;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Context passed to a custom {@link LiveChartProps.renderReferenceLine}. The chart
|
|
225
|
+
* floats the element you return over the canvas and pins it to the line's value on
|
|
226
|
+
* the UI thread (vertically centered on the line, horizontally at the badge /
|
|
227
|
+
* label position) — so it tracks the rescaling axis and any drag smoothly without
|
|
228
|
+
* JS re-renders, just like {@link TooltipRenderProps}. Replaces the built-in pill
|
|
229
|
+
* badge / gutter label for that line; return `null`/`undefined` to keep the
|
|
230
|
+
* built-in. Bind the SharedValues to animated text (e.g. an animated `TextInput`)
|
|
231
|
+
* for the value to update on the UI thread too.
|
|
232
|
+
*/
|
|
233
|
+
export interface ReferenceLineRenderProps {
|
|
234
|
+
/** The reference line being rendered. */
|
|
235
|
+
line: ReferenceLine;
|
|
236
|
+
/** Its index in the `referenceLines` array. */
|
|
237
|
+
index: number;
|
|
238
|
+
/** Live Y-axis value of the line — tracks dragging when {@link ReferenceLine.draggable}. */
|
|
239
|
+
value: SharedValue<number>;
|
|
240
|
+
/** The value formatted with the chart's `formatValue` (computed UI-side). */
|
|
241
|
+
valueStr: SharedValue<string>;
|
|
242
|
+
/** Canvas Y pixel of the line, recomputed each frame (`-1` when not laid out). */
|
|
243
|
+
y: SharedValue<number>;
|
|
244
|
+
/** Whether the value currently sits within the visible plot range. */
|
|
245
|
+
inRange: SharedValue<boolean>;
|
|
246
|
+
/**
|
|
247
|
+
* Which visible edge the value is pinned to when off-screen: `"above"` (past the
|
|
248
|
+
* top), `"below"` (past the bottom), or `"in"`. Use it to flip a directional
|
|
249
|
+
* chevron on a custom off-axis handle.
|
|
250
|
+
*/
|
|
251
|
+
edge: SharedValue<"above" | "in" | "below">;
|
|
252
|
+
/** Whether this line is currently being dragged. */
|
|
253
|
+
dragging: SharedValue<boolean>;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Grouping behavior for reference lines (single-series). When enabled, Form-A
|
|
257
|
+
* lines whose handles fall within {@link ReferenceLineGroupingConfig.radius} px of
|
|
258
|
+
* each other collapse into a single count handle, so a cluster of nearby orders /
|
|
259
|
+
* alerts reads as one tag instead of an unreadable pile. Pass `true` for defaults
|
|
260
|
+
* or an object to tune the proximity radius.
|
|
261
|
+
*/
|
|
262
|
+
export interface ReferenceLineGroupingConfig {
|
|
263
|
+
/**
|
|
264
|
+
* Collapse lines whose value-Y positions are within this many px of each other.
|
|
265
|
+
* Default `18`.
|
|
266
|
+
*/
|
|
131
267
|
radius?: number;
|
|
268
|
+
/**
|
|
269
|
+
* Styling for the collapsed **count pill** — the same style/shape config as a
|
|
270
|
+
* reference-line badge ({@link ReferenceLineBadgeConfig}): `position`
|
|
271
|
+
* (`"left"` / `"center"` / `"right"`), `icon` (a leading glyph before the count),
|
|
272
|
+
* `background`, `borderColor`, `borderWidth`, `radius` (corner radius),
|
|
273
|
+
* `textColor`, `fontSize` / `fontFamily` / `fontWeight`, and `offsetX` / `offsetY`.
|
|
274
|
+
* Omit for the theme defaults (left-pinned, `tooltipBg` fill, `refLine` border,
|
|
275
|
+
* `refLabel` text). The badge's `text: false` hides the count for an icon-only pill.
|
|
276
|
+
*/
|
|
277
|
+
badge?: ReferenceLineBadgeConfig;
|
|
278
|
+
/**
|
|
279
|
+
* Format the collapsed count for the pill label, e.g. `n => \`×${n}\`` or
|
|
280
|
+
* `n => \`${n} orders\``. Default `String(n)` (the bare count). **Must be a
|
|
281
|
+
* worklet** (add the `"worklet"` directive) — it runs on the UI thread each
|
|
282
|
+
* frame, like the chart's `formatValue`. A plain JS closure throws.
|
|
283
|
+
*/
|
|
284
|
+
format?: (count: number) => string;
|
|
132
285
|
}
|
|
133
286
|
/**
|
|
134
287
|
* A time-range segment of the chart — e.g. a pre-market / regular / after-hours
|
|
@@ -318,21 +471,77 @@ export interface AreaDotsConfig {
|
|
|
318
471
|
/** Overall opacity (0..1) applied to the whole field. Default `1`. */
|
|
319
472
|
opacity?: number;
|
|
320
473
|
}
|
|
321
|
-
/**
|
|
322
|
-
|
|
474
|
+
/**
|
|
475
|
+
* Value badge pill configuration. Extends {@link BadgeStyleConfig} for the
|
|
476
|
+
* style/shape knobs (`background`, `borderColor` / `borderWidth`, `radius`,
|
|
477
|
+
* `textColor`, `font*`, `offsetX/Y`). Value-badge specifics: `radius` defaults to a
|
|
478
|
+
* full capsule (clamped to `[0, pillHeight / 2]`); `borderColor` unset → no border;
|
|
479
|
+
* `textColor` unset → the `variant` / theme rule.
|
|
480
|
+
*/
|
|
481
|
+
export interface BadgeConfig extends BadgeStyleConfig {
|
|
323
482
|
/** Visual style of the badge pill. Default `"default"`. */
|
|
324
483
|
variant?: BadgeVariant;
|
|
325
484
|
/** Show the pointed tail toward the live dot. Default `true`. */
|
|
326
485
|
tail?: boolean;
|
|
327
|
-
/** Badge background color override. */
|
|
328
|
-
background?: string;
|
|
329
486
|
/** Which side of the chart the badge appears on. Default `"right"`. */
|
|
330
487
|
position?: "right" | "left";
|
|
488
|
+
/**
|
|
489
|
+
* When the chart is scrolled back (see `timeScroll`), move the live-price
|
|
490
|
+
* indicators — the badge, the value line, and the live dot — to the price at
|
|
491
|
+
* the visible window's right edge instead of the live price, so they track the
|
|
492
|
+
* last visible price as you pan. Default `false`.
|
|
493
|
+
*
|
|
494
|
+
* @experimental
|
|
495
|
+
*/
|
|
496
|
+
followViewEdge?: boolean;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Volume-bar configuration (candle mode only — see {@link LiveChartProps.volume}).
|
|
500
|
+
* Bars are drawn in a reserved band below the candles; the candle/price plot
|
|
501
|
+
* shrinks by {@link maxHeight} to make room (the x-axis stays at the bottom).
|
|
502
|
+
* Each bar's height is its candle's `volume` normalized to the largest visible
|
|
503
|
+
* volume, so the tallest visible bar fills the band.
|
|
504
|
+
*/
|
|
505
|
+
export interface VolumeConfig {
|
|
506
|
+
/** Bar color for up (close ≥ open) candles. Default: `palette.candleUp`. */
|
|
507
|
+
upColor?: string;
|
|
508
|
+
/** Bar color for down (close < open) candles. Default: `palette.candleDown`. */
|
|
509
|
+
downColor?: string;
|
|
510
|
+
/**
|
|
511
|
+
* Height (px) of the reserved band — the tallest a bar can be. Reserved out of
|
|
512
|
+
* the plot below the candles. Default `48`.
|
|
513
|
+
*/
|
|
514
|
+
maxHeight?: number;
|
|
515
|
+
/** Corner radius (px) of bar tops. `0` = sharp. Default `2`. */
|
|
516
|
+
radius?: number;
|
|
517
|
+
/** Opacity (0..1) applied to the whole band. Default `0.6`. */
|
|
518
|
+
opacity?: number;
|
|
331
519
|
}
|
|
332
520
|
/** Y-axis grid configuration. */
|
|
333
521
|
export interface YAxisConfig {
|
|
334
522
|
/** Minimum pixel gap between grid lines. Default `36`. */
|
|
335
523
|
minGap?: number;
|
|
524
|
+
/**
|
|
525
|
+
* Show a fixed number of price labels instead of the dynamic nice-interval
|
|
526
|
+
* grid. When set (≥ 2), exactly `count` labels are spaced evenly **in pixels**
|
|
527
|
+
* across the plot — top label = current high, bottom = current low — so the
|
|
528
|
+
* count never changes as data streams in. Values are not rounded to "nice"
|
|
529
|
+
* numbers; they track the live range each frame.
|
|
530
|
+
*
|
|
531
|
+
* `minGap` still acts as a floor: if `count` labels won't fit at least
|
|
532
|
+
* `minGap` px apart, the count is reduced to what fits. Clamped to at most 15
|
|
533
|
+
* (the label pool size). Omit (or `0`) for the default dynamic grid.
|
|
534
|
+
*/
|
|
535
|
+
count?: number;
|
|
536
|
+
/**
|
|
537
|
+
* Float the price axis over a full-width plot instead of reserving a right
|
|
538
|
+
* gutter for it. The line/candles run all the way to the right edge, and the
|
|
539
|
+
* price labels (and the live-value badge) float on top — so the chart isn't
|
|
540
|
+
* cut off short of the edge, especially while time-scrolling. Default `false`.
|
|
541
|
+
*
|
|
542
|
+
* @experimental
|
|
543
|
+
*/
|
|
544
|
+
float?: boolean;
|
|
336
545
|
}
|
|
337
546
|
/**
|
|
338
547
|
* Axis edge label — the value floated at the plot's top or bottom edge
|
|
@@ -438,11 +647,13 @@ export interface ScrubConfig {
|
|
|
438
647
|
* Where the tooltip pill sits relative to the vertical scrub line.
|
|
439
648
|
* `"side"` (default) offsets it to the right of the line and flips left near
|
|
440
649
|
* the right edge. `"top"` / `"bottom"` center it horizontally over the line,
|
|
441
|
-
* clamped into the plot and pinned to the plot's top or bottom.
|
|
442
|
-
*
|
|
443
|
-
*
|
|
650
|
+
* clamped into the plot and pinned to the plot's top or bottom. `"point"`
|
|
651
|
+
* centers it over the line and floats it just above the scrub dot, flipping
|
|
652
|
+
* below the dot when there isn't room above (single-series line mode; candle
|
|
653
|
+
* mode keeps its top-pinned OHLC stack). This also drives a custom
|
|
654
|
+
* {@link LiveChartProps.renderTooltip} so it gets the same placement for free.
|
|
444
655
|
*/
|
|
445
|
-
tooltipPlacement?: "side" | "top" | "bottom";
|
|
656
|
+
tooltipPlacement?: "side" | "top" | "bottom" | "point";
|
|
446
657
|
/**
|
|
447
658
|
* Gap in px between the tooltip and the plot edge it's pinned to — the top for
|
|
448
659
|
* `"side"`/`"top"`, the bottom for `"bottom"`. Applies to the built-in pill and
|
|
@@ -504,6 +715,13 @@ export interface ScrubActionConfig {
|
|
|
504
715
|
* instead of moving it. Default `false` (an empty-plot tap re-places the reticle).
|
|
505
716
|
*/
|
|
506
717
|
dismissOnTapOutside?: boolean;
|
|
718
|
+
/**
|
|
719
|
+
* Dismiss the reticle once the action badge is pressed (and
|
|
720
|
+
* {@link LiveChartProps.onScrubAction} fires), so no crosshair lingers after the
|
|
721
|
+
* action — e.g. clear the order reticle once the order has been placed. Default
|
|
722
|
+
* `false` (the reticle stays until tapped away).
|
|
723
|
+
*/
|
|
724
|
+
dismissOnAction?: boolean;
|
|
507
725
|
}
|
|
508
726
|
/**
|
|
509
727
|
* Payload for {@link LiveChartProps.onScrubAction} — the chosen price **level**
|
|
@@ -579,6 +797,89 @@ export interface TooltipRenderProps {
|
|
|
579
797
|
*/
|
|
580
798
|
candle: SharedValue<CandlePoint | null>;
|
|
581
799
|
}
|
|
800
|
+
/** Inner plot rectangle in canvas pixels (a snapshot field of {@link ChartScale}). */
|
|
801
|
+
export interface ChartPlotRect {
|
|
802
|
+
/** Inner plot left edge (`padding.left`). */
|
|
803
|
+
left: number;
|
|
804
|
+
/** Inner plot top edge (`padding.top`). */
|
|
805
|
+
top: number;
|
|
806
|
+
/** Inner plot right edge (`canvasWidth - padding.right`). */
|
|
807
|
+
right: number;
|
|
808
|
+
/** Inner plot bottom edge (`canvasHeight - padding.bottom`). */
|
|
809
|
+
bottom: number;
|
|
810
|
+
/** Full canvas width. */
|
|
811
|
+
width: number;
|
|
812
|
+
/** Full canvas height. */
|
|
813
|
+
height: number;
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* A snapshot of the chart's live scale — the value range, time window, and plot
|
|
817
|
+
* rect at one frame. Carried by {@link ChartOverlayContext.scale} (a `SharedValue`
|
|
818
|
+
* recomputed each frame) and consumed by the pure mapping functions. Reading
|
|
819
|
+
* `scale.get()` inside your worklet is what subscribes the overlay to per-frame
|
|
820
|
+
* updates, so it tracks the chart as it scrolls and rescales.
|
|
821
|
+
*/
|
|
822
|
+
export interface ChartScale {
|
|
823
|
+
/** Live Y-axis lower bound (price at the plot bottom). */
|
|
824
|
+
min: number;
|
|
825
|
+
/** Live Y-axis upper bound (price at the plot top). */
|
|
826
|
+
max: number;
|
|
827
|
+
/** Visible time window in seconds. */
|
|
828
|
+
window: number;
|
|
829
|
+
/** Right-edge timestamp (unix seconds) — "now". */
|
|
830
|
+
now: number;
|
|
831
|
+
/** Inner plot rectangle in canvas px. */
|
|
832
|
+
plot: ChartPlotRect;
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* The price↔pixel / time↔pixel bridge handed to a custom
|
|
836
|
+
* {@link LiveChartProps.renderOverlay}.
|
|
837
|
+
*
|
|
838
|
+
* **Easiest path — the `usePriceY` / `useTimeX` hooks.** They project a price / time
|
|
839
|
+
* to a `SharedValue<number>` that tracks the live axis for you; just read it in
|
|
840
|
+
* your `useAnimatedStyle` like any SharedValue:
|
|
841
|
+
*
|
|
842
|
+
* ```tsx
|
|
843
|
+
* function PriceLevel({ ctx, price }) {
|
|
844
|
+
* const y = usePriceY(ctx, price); // reactive — tracks the rescaling axis
|
|
845
|
+
* const style = useAnimatedStyle(() => ({ transform: [{ translateY: y.get() }] }));
|
|
846
|
+
* return <Animated.View style={style} />;
|
|
847
|
+
* }
|
|
848
|
+
* ```
|
|
849
|
+
*
|
|
850
|
+
* **Manual path — {@link scale} + the pure mappings.** For one-off math (e.g. a
|
|
851
|
+
* gesture handler) or when you want everything in one worklet, read `scale.get()`
|
|
852
|
+
* inside your worklet — that read subscribes it to the per-frame scale — then pass
|
|
853
|
+
* the snapshot to the pure mappings (`priceToY` / `yToPrice` / `timeToX` /
|
|
854
|
+
* `xToTime`). The mappings do **not** read `scale` themselves, so they only reflect
|
|
855
|
+
* the chart live when you feed them `scale.get()`:
|
|
856
|
+
*
|
|
857
|
+
* ```tsx
|
|
858
|
+
* const style = useAnimatedStyle(() => {
|
|
859
|
+
* const s = scale.get(); // subscribe to the live scale
|
|
860
|
+
* const y = priceToY(142.5, s); // project a price to its pixel
|
|
861
|
+
* return { transform: [{ translateY: y }] };
|
|
862
|
+
* });
|
|
863
|
+
* ```
|
|
864
|
+
*/
|
|
865
|
+
export interface ChartOverlayContext {
|
|
866
|
+
/**
|
|
867
|
+
* The live {@link ChartScale} snapshot, recomputed each frame. Read `.get()`
|
|
868
|
+
* inside your worklet to subscribe it to chart updates.
|
|
869
|
+
*/
|
|
870
|
+
scale: SharedValue<ChartScale>;
|
|
871
|
+
/** Maps a price (Y-axis value) → canvas Y px for a {@link ChartScale}. Worklet. -1 when not laid out. */
|
|
872
|
+
priceToY: (price: number, scale: ChartScale) => number;
|
|
873
|
+
/**
|
|
874
|
+
* Inverse of {@link priceToY}: canvas Y px → price. Worklet. Clamps to the
|
|
875
|
+
* visible range; `null` when not laid out.
|
|
876
|
+
*/
|
|
877
|
+
yToPrice: (y: number, scale: ChartScale) => number | null;
|
|
878
|
+
/** Maps a unix-seconds timestamp → canvas X px for a {@link ChartScale}. Worklet. -1 when not laid out. */
|
|
879
|
+
timeToX: (time: number, scale: ChartScale) => number;
|
|
880
|
+
/** Inverse of {@link timeToX}: canvas X px → unix-seconds timestamp. Worklet. */
|
|
881
|
+
xToTime: (x: number, scale: ChartScale) => number;
|
|
882
|
+
}
|
|
582
883
|
/** Outer ring drawn around the built-in selection dot (the subtle halo). */
|
|
583
884
|
export interface SelectionDotRingConfig {
|
|
584
885
|
/** Ring color. Defaults to the dot color. */
|
|
@@ -728,16 +1029,59 @@ export interface Marker {
|
|
|
728
1029
|
pill?: boolean;
|
|
729
1030
|
/** Icon / image box size in px (icon font size or image width+height). Default `16`. */
|
|
730
1031
|
size?: number;
|
|
731
|
-
/**
|
|
1032
|
+
/**
|
|
1033
|
+
* Sit the glyph above / below its anchor instead of centered on it. Default
|
|
1034
|
+
* `"center"` (on the line/value, today's behavior). Also the stack direction
|
|
1035
|
+
* when `markerCluster: "stacked"` — e.g. buys `"below"`, sells `"above"`.
|
|
1036
|
+
*/
|
|
1037
|
+
side?: MarkerSide;
|
|
1038
|
+
/** Pass-through payload surfaced on `onMarkerPress`. */
|
|
732
1039
|
data?: unknown;
|
|
733
1040
|
}
|
|
734
|
-
/**
|
|
735
|
-
export
|
|
1041
|
+
/** Where a marker glyph sits relative to its anchor (and the stack direction). */
|
|
1042
|
+
export type MarkerSide = "above" | "below" | "center";
|
|
1043
|
+
/**
|
|
1044
|
+
* Object form of {@link LiveChartProps.markerCluster} for tuning the stacked
|
|
1045
|
+
* collision behavior. Passing this object implies `mode: "stacked"` unless you
|
|
1046
|
+
* set `mode` explicitly.
|
|
1047
|
+
*/
|
|
1048
|
+
export interface MarkerClusterConfig {
|
|
1049
|
+
/** Defaults to `"stacked"` when this object form is used. */
|
|
1050
|
+
mode?: "anchored" | "stacked";
|
|
1051
|
+
/**
|
|
1052
|
+
* How much adjacent co-located glyphs overlap when fanned, `0` (just touching)
|
|
1053
|
+
* to `1` (fully stacked). Default `0.75`. The on-screen overlap is approximate
|
|
1054
|
+
* (the fan step is estimated from the glyph size, not its exact pixels).
|
|
1055
|
+
*/
|
|
1056
|
+
overlap?: number;
|
|
1057
|
+
/** Collapse a co-located run to a single count badge once it exceeds this many.
|
|
1058
|
+
* Default `5`. */
|
|
1059
|
+
maxBeforeGroup?: number;
|
|
1060
|
+
}
|
|
1061
|
+
/** Context passed to `renderMarker` alongside the marker (cluster / position state). */
|
|
1062
|
+
export interface MarkerRenderContext {
|
|
1063
|
+
/** Index of the marker in the `markers` array. */
|
|
1064
|
+
index: number;
|
|
1065
|
+
/** `true` when this marker is the representative of a collapsed cluster. */
|
|
1066
|
+
isGrouped: boolean;
|
|
1067
|
+
/** Number of markers in the collapsed cluster (`0` when not grouped). */
|
|
1068
|
+
groupCount: number;
|
|
1069
|
+
/** Resolved side the glyph is drawn on. */
|
|
1070
|
+
side: MarkerSide;
|
|
1071
|
+
}
|
|
1072
|
+
/** Payload for `onMarkerPress` — the marker and its screen position. */
|
|
1073
|
+
export interface MarkerPressEvent {
|
|
736
1074
|
marker: Marker;
|
|
737
1075
|
point: {
|
|
738
1076
|
x: number;
|
|
739
1077
|
y: number;
|
|
740
1078
|
};
|
|
1079
|
+
/** Index of the pressed marker in the `markers` array. */
|
|
1080
|
+
index: number;
|
|
1081
|
+
/** `true` when the press landed on a collapsed cluster (count badge). */
|
|
1082
|
+
isGrouped: boolean;
|
|
1083
|
+
/** The cluster's markers when `isGrouped`, so the consumer can list them. */
|
|
1084
|
+
members?: Marker[];
|
|
741
1085
|
}
|
|
742
1086
|
/** Particle burst + screen shake on momentum swings ("degen mode"). */
|
|
743
1087
|
export interface DegenOptions {
|
|
@@ -935,6 +1279,13 @@ export interface CandlePoint {
|
|
|
935
1279
|
low: number;
|
|
936
1280
|
/** Closing price. */
|
|
937
1281
|
close: number;
|
|
1282
|
+
/**
|
|
1283
|
+
* Traded volume in the bucket. Drives the optional volume bars
|
|
1284
|
+
* (see {@link LiveChartProps.volume}); bar heights are normalized to the
|
|
1285
|
+
* largest visible volume, so only relative values matter. Omitted candles
|
|
1286
|
+
* contribute no bar. Ignored when `volume` is off or in line mode.
|
|
1287
|
+
*/
|
|
1288
|
+
volume?: number;
|
|
938
1289
|
}
|
|
939
1290
|
/**
|
|
940
1291
|
* Spatial sizing & motion tokens — the geometry/timing analogue of
|
|
@@ -977,6 +1328,10 @@ export interface CandleMetrics {
|
|
|
977
1328
|
maxBodyPx: number;
|
|
978
1329
|
/** Body width as a fraction of the per-candle slot width (0–1). Default `0.8`. */
|
|
979
1330
|
bodyWidthRatio: number;
|
|
1331
|
+
/** Corner radius (px) of candle bodies. `0` = sharp corners. Default `0`. */
|
|
1332
|
+
bodyRadius: number;
|
|
1333
|
+
/** Wick (high–low line) stroke width in px. Default `1`. */
|
|
1334
|
+
wickWidth: number;
|
|
980
1335
|
}
|
|
981
1336
|
/** Grid-line and axis-label fade animation speeds. */
|
|
982
1337
|
export interface GridMetrics {
|
|
@@ -1013,6 +1368,58 @@ export interface LiveChartMetricsOverride {
|
|
|
1013
1368
|
motion?: Partial<MotionMetrics>;
|
|
1014
1369
|
emptyState?: Partial<EmptyStateMetrics>;
|
|
1015
1370
|
}
|
|
1371
|
+
/**
|
|
1372
|
+
* Time-scroll activation (see {@link LiveChartCoreProps.timeScroll}).
|
|
1373
|
+
*
|
|
1374
|
+
* @experimental Prototype — gesture model and API may change.
|
|
1375
|
+
*/
|
|
1376
|
+
export interface TimeScrollConfig {
|
|
1377
|
+
/**
|
|
1378
|
+
* Which gesture pans the timeline:
|
|
1379
|
+
* - `"holdToScrub"` (default) — a one-finger drag anywhere scrolls; scrub
|
|
1380
|
+
* moves to press-and-hold (Rainbow-style). See {@link scrubHoldMs} for the
|
|
1381
|
+
* hold duration.
|
|
1382
|
+
* - `"axisDrag"` — a one-finger drag starting in the bottom X-axis band
|
|
1383
|
+
* ("grab the time ruler"); the plot area stays free for one-finger scrub.
|
|
1384
|
+
*/
|
|
1385
|
+
gesture?: "holdToScrub" | "axisDrag";
|
|
1386
|
+
/**
|
|
1387
|
+
* `holdToScrub` only: press-and-hold duration (ms) before scrub engages, so a
|
|
1388
|
+
* quicker one-finger drag scrolls instead. Higher = more deliberate scrub and
|
|
1389
|
+
* fewer accidental scrubs while scrolling. Falls back to `scrub.panGestureDelay`
|
|
1390
|
+
* if set, otherwise `500`.
|
|
1391
|
+
*/
|
|
1392
|
+
scrubHoldMs?: number;
|
|
1393
|
+
}
|
|
1394
|
+
/**
|
|
1395
|
+
* Pinch-to-zoom the visible time window (see {@link LiveChartCoreProps.zoom}).
|
|
1396
|
+
*
|
|
1397
|
+
* @experimental Prototype — gesture model and API may change.
|
|
1398
|
+
*/
|
|
1399
|
+
export interface ZoomConfig {
|
|
1400
|
+
/**
|
|
1401
|
+
* Tightest visible window in seconds (max zoom-in). Default `timeWindow / 8`.
|
|
1402
|
+
*/
|
|
1403
|
+
minTimeWindow?: number;
|
|
1404
|
+
/**
|
|
1405
|
+
* Widest visible window in seconds (max zoom-out). Defaults to the full data
|
|
1406
|
+
* span (you can zoom out to all retained history), never below `timeWindow`.
|
|
1407
|
+
*/
|
|
1408
|
+
maxTimeWindow?: number;
|
|
1409
|
+
}
|
|
1410
|
+
/**
|
|
1411
|
+
* The visible time range reported by {@link LiveChartCoreProps.onVisibleRangeChange}.
|
|
1412
|
+
*
|
|
1413
|
+
* @experimental
|
|
1414
|
+
*/
|
|
1415
|
+
export interface VisibleRange {
|
|
1416
|
+
/** Left-edge time of the visible window (unix seconds). */
|
|
1417
|
+
startSec: number;
|
|
1418
|
+
/** Right-edge time of the visible window (unix seconds). */
|
|
1419
|
+
endSec: number;
|
|
1420
|
+
/** True when the window is at the live edge (not scrolled back / paused). */
|
|
1421
|
+
following: boolean;
|
|
1422
|
+
}
|
|
1016
1423
|
/** Props shared between `LiveChart` and `LiveChartSeries`. */
|
|
1017
1424
|
export interface LiveChartCoreProps {
|
|
1018
1425
|
/** Color scheme. Default `"dark"`. */
|
|
@@ -1090,9 +1497,19 @@ export interface LiveChartCoreProps {
|
|
|
1090
1497
|
*/
|
|
1091
1498
|
markers?: SharedValue<Marker[]>;
|
|
1092
1499
|
/** Fires when a marker is tapped; `null` when a tap misses every marker. */
|
|
1093
|
-
|
|
1500
|
+
onMarkerPress?: (event: MarkerPressEvent | null) => void;
|
|
1094
1501
|
/** Tap hit-test radius in px. Default `16` (≈ 44px touch target with the glyph). */
|
|
1095
1502
|
markerHitRadius?: number;
|
|
1503
|
+
/**
|
|
1504
|
+
* Collision handling for co-located markers. `"anchored"` (default) keeps
|
|
1505
|
+
* today's behavior — glyphs draw at their anchor and overlap. `"stacked"` fans
|
|
1506
|
+
* co-located markers apart horizontally (overlapping, left-over-right) along
|
|
1507
|
+
* their {@link Marker.side}, collapsing a cluster into a single count-badge
|
|
1508
|
+
* marker once it exceeds {@link MarkerClusterConfig.maxBeforeGroup}. Grouping is
|
|
1509
|
+
* recomputed per frame, so a cluster fans back out as you zoom/scroll in. Pass a
|
|
1510
|
+
* {@link MarkerClusterConfig} object to tune the `overlap` and group threshold.
|
|
1511
|
+
*/
|
|
1512
|
+
markerCluster?: "anchored" | "stacked" | MarkerClusterConfig;
|
|
1096
1513
|
/**
|
|
1097
1514
|
* Render a marker as a custom **React Native** element instead of a built-in
|
|
1098
1515
|
* Skia glyph — e.g. an `expo-blur` glass badge or any non-Skia view that the
|
|
@@ -1105,8 +1522,12 @@ export interface LiveChartCoreProps {
|
|
|
1105
1522
|
* each custom marker is its own animated view + projection, whereas built-in
|
|
1106
1523
|
* glyphs batch into a single draw call. Custom-rendered markers skip the atlas
|
|
1107
1524
|
* glyph entirely (no double-draw).
|
|
1525
|
+
*
|
|
1526
|
+
* The second argument carries cluster / position state (see
|
|
1527
|
+
* {@link MarkerRenderContext}) — e.g. render a distinct collapsed look when
|
|
1528
|
+
* `ctx.isGrouped` (showing `ctx.groupCount`).
|
|
1108
1529
|
*/
|
|
1109
|
-
renderMarker?: (marker: Marker) => ReactElement | null | undefined;
|
|
1530
|
+
renderMarker?: (marker: Marker, ctx: MarkerRenderContext) => ReactElement | null | undefined;
|
|
1110
1531
|
/**
|
|
1111
1532
|
* Render a fully custom scrub tooltip as a **React Native** element instead of
|
|
1112
1533
|
* the built-in pill — the same idea as `renderMarker`. The chart floats the
|
|
@@ -1148,6 +1569,31 @@ export interface LiveChartCoreProps {
|
|
|
1148
1569
|
* and `timeWindow = maxT - minT` to fill the canvas edge-to-edge with historical data.
|
|
1149
1570
|
*/
|
|
1150
1571
|
nowOverride?: number;
|
|
1572
|
+
/**
|
|
1573
|
+
* Enable horizontal time-scrolling: drag (or fling) to pan back through history.
|
|
1574
|
+
* The chart stops auto-scrolling while panned and resumes once you reach the
|
|
1575
|
+
* live edge again. One-finger plot-area scrub is unchanged. Requires retained
|
|
1576
|
+
* history in `data` / `candles` to scroll into.
|
|
1577
|
+
*
|
|
1578
|
+
* `true` uses the default drag-to-scroll gesture (`"holdToScrub"`); pass a
|
|
1579
|
+
* {@link TimeScrollConfig} to pick the activation (`"holdToScrub"` or
|
|
1580
|
+
* `"axisDrag"`). Default `false`.
|
|
1581
|
+
*
|
|
1582
|
+
* @experimental Prototype — gesture model and API may change.
|
|
1583
|
+
*/
|
|
1584
|
+
timeScroll?: boolean | TimeScrollConfig;
|
|
1585
|
+
/**
|
|
1586
|
+
* Pinch-to-zoom the visible time window. Two-finger pinch in/out narrows or
|
|
1587
|
+
* widens the window, anchored at the focal point between your fingers. Composes
|
|
1588
|
+
* with `timeScroll` (zoom level and scroll position are independent). Seed extra
|
|
1589
|
+
* history in `data` / `candles` to have room to zoom out into.
|
|
1590
|
+
*
|
|
1591
|
+
* `true` uses sensible default bounds; pass a {@link ZoomConfig} to set
|
|
1592
|
+
* `minTimeWindow` / `maxTimeWindow`. Default `false`.
|
|
1593
|
+
*
|
|
1594
|
+
* @experimental Prototype — gesture model and API may change.
|
|
1595
|
+
*/
|
|
1596
|
+
zoom?: boolean | ZoomConfig;
|
|
1151
1597
|
/** Accessibility label for the chart container. */
|
|
1152
1598
|
accessibilityLabel?: string;
|
|
1153
1599
|
/** Accessibility role for the chart container. Default `"image"`. */
|
|
@@ -1164,6 +1610,22 @@ export interface LiveChartCoreProps {
|
|
|
1164
1610
|
onGestureStart?: () => void;
|
|
1165
1611
|
/** Called once when the user stops scrubbing/panning the chart. */
|
|
1166
1612
|
onGestureEnd?: () => void;
|
|
1613
|
+
/**
|
|
1614
|
+
* Called as the visible time window changes (throttled to ~1 Hz), with the
|
|
1615
|
+
* window's edges in unix seconds and whether the chart is at the live edge.
|
|
1616
|
+
* Useful for paging data sources alongside `timeScroll` / `zoom`.
|
|
1617
|
+
*
|
|
1618
|
+
* @experimental
|
|
1619
|
+
*/
|
|
1620
|
+
onVisibleRangeChange?: (range: VisibleRange) => void;
|
|
1621
|
+
/**
|
|
1622
|
+
* Called once when the visible window's left edge comes within one
|
|
1623
|
+
* window-width of the earliest retained data — the cue to lazily load older
|
|
1624
|
+
* history. Re-arms after the edge moves back out.
|
|
1625
|
+
*
|
|
1626
|
+
* @experimental
|
|
1627
|
+
*/
|
|
1628
|
+
onReachStart?: () => void;
|
|
1167
1629
|
/**
|
|
1168
1630
|
* Fade out chart content on the left (destination-out style). `true` = defaults, `false` = off,
|
|
1169
1631
|
* or pass `LeftEdgeFadeConfig`. Default `true`.
|
|
@@ -1241,6 +1703,19 @@ export interface LiveChartProps extends LiveChartCoreProps {
|
|
|
1241
1703
|
* in a list. Pulse/scrub/degen and the entry animation are disabled. Frame the data
|
|
1242
1704
|
* with `timeWindow` + `nowOverride` (see the historical-data-fill pattern). */
|
|
1243
1705
|
static?: boolean;
|
|
1706
|
+
/**
|
|
1707
|
+
* Render a custom overlay floated over the chart canvas, handed a price↔pixel /
|
|
1708
|
+
* time↔pixel {@link ChartOverlayContext} so it can track the auto-rescaling axis
|
|
1709
|
+
* on the UI thread. Return any React Native view tree (e.g. order / avg-entry /
|
|
1710
|
+
* liquidation price tags) and position its pieces with the context's worklet
|
|
1711
|
+
* mappings inside `useAnimatedStyle`; return `null`/`undefined` for no overlay.
|
|
1712
|
+
*
|
|
1713
|
+
* The returned tree is mounted as an RN sibling of the `<Canvas>` (like
|
|
1714
|
+
* `renderMarker` / `renderTooltip`), full-bleed with `pointerEvents="box-none"`
|
|
1715
|
+
* so empty areas still scrub while an interactive leaf can receive touches.
|
|
1716
|
+
* Single-series only.
|
|
1717
|
+
*/
|
|
1718
|
+
renderOverlay?: (ctx: ChartOverlayContext) => ReactElement | null | undefined;
|
|
1244
1719
|
/** Called when the user scrubs the crosshair. `null` when scrub ends. */
|
|
1245
1720
|
onScrub?: (point: ScrubPoint | null) => void;
|
|
1246
1721
|
/**
|
|
@@ -1266,6 +1741,34 @@ export interface LiveChartProps extends LiveChartCoreProps {
|
|
|
1266
1741
|
* routed here, not to reticle placement). Single-series only.
|
|
1267
1742
|
*/
|
|
1268
1743
|
onReferenceLinePress?: (line: ReferenceLine, index: number) => void;
|
|
1744
|
+
/**
|
|
1745
|
+
* Render a reference line's tag as a custom **React Native** element instead of
|
|
1746
|
+
* the built-in Skia pill / gutter label — the same model as `renderMarker` /
|
|
1747
|
+
* `renderTooltip`. The chart floats the returned element over the canvas and
|
|
1748
|
+
* pins it to the line's value on the UI thread (see {@link ReferenceLineRenderProps}),
|
|
1749
|
+
* so it tracks the rescaling axis and any drag without JS re-renders. Called per
|
|
1750
|
+
* Form-A line; return `null`/`undefined` to keep that line's built-in tag. Works
|
|
1751
|
+
* with `badge: false` too (replace the plain gutter label). Single-series only.
|
|
1752
|
+
*/
|
|
1753
|
+
renderReferenceLine?: (ctx: ReferenceLineRenderProps) => ReactElement | null | undefined;
|
|
1754
|
+
/**
|
|
1755
|
+
* Collapse Form-A reference lines whose handles sit near the same value into a
|
|
1756
|
+
* single count handle (e.g. a stack of working orders at adjacent prices reads
|
|
1757
|
+
* as one "×3" tag). `true` = defaults, `false`/omitted = off, or pass a
|
|
1758
|
+
* {@link ReferenceLineGroupingConfig} to tune the proximity radius. Lines a
|
|
1759
|
+
* {@link LiveChartProps.renderReferenceLine} owns are excluded (their custom tag
|
|
1760
|
+
* draws itself), so the count reflects only collapsed built-in tags. Single-series
|
|
1761
|
+
* only. Default off.
|
|
1762
|
+
*/
|
|
1763
|
+
referenceLineGrouping?: boolean | ReferenceLineGroupingConfig;
|
|
1764
|
+
/**
|
|
1765
|
+
* Volume bars below the candles (candle mode only). `true` = defaults,
|
|
1766
|
+
* `false`/omitted = off, or pass a {@link VolumeConfig} for colors, band
|
|
1767
|
+
* height, rounding, and opacity. The candle/price plot shrinks by the band
|
|
1768
|
+
* height to make room; the x-axis stays pinned to the bottom. Reads each
|
|
1769
|
+
* candle's `CandlePoint.volume`. Ignored in line mode. Default off.
|
|
1770
|
+
*/
|
|
1771
|
+
volume?: boolean | VolumeConfig;
|
|
1269
1772
|
/**
|
|
1270
1773
|
* Called on the JS thread when degen chart shake starts (momentum swing with shake enabled).
|
|
1271
1774
|
* Not called when `degen` is off or `DegenOptions.shake` is `false`.
|