react-native-livechart 4.8.0 → 4.9.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/LiveChart.d.ts.map +1 -1
- package/dist/components/LiveChartSeries.d.ts.map +1 -1
- package/dist/components/ThresholdLineOverlay.d.ts +4 -1
- package/dist/components/ThresholdLineOverlay.d.ts.map +1 -1
- package/dist/components/ThresholdSplitShader.d.ts +26 -0
- package/dist/components/ThresholdSplitShader.d.ts.map +1 -0
- package/dist/core/liveChartEngineTick.d.ts +9 -0
- package/dist/core/liveChartEngineTick.d.ts.map +1 -1
- package/dist/core/liveChartSeriesEngineTick.d.ts.map +1 -1
- package/dist/core/resolveConfig.d.ts +22 -5
- package/dist/core/resolveConfig.d.ts.map +1 -1
- package/dist/core/useLiveChartEngine.d.ts +14 -0
- package/dist/core/useLiveChartEngine.d.ts.map +1 -1
- package/dist/hooks/useChartPaths.d.ts +6 -1
- package/dist/hooks/useChartPaths.d.ts.map +1 -1
- package/dist/hooks/useChartSkiaFont.d.ts +2 -1
- package/dist/hooks/useChartSkiaFont.d.ts.map +1 -1
- package/dist/hooks/useThreshold.d.ts +63 -6
- package/dist/hooks/useThreshold.d.ts.map +1 -1
- package/dist/math/threshold.d.ts +82 -0
- package/dist/math/threshold.d.ts.map +1 -1
- package/dist/types.d.ts +77 -18
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/LiveChart.tsx +271 -42
- package/src/components/LiveChartSeries.tsx +5 -1
- package/src/components/ThresholdLineOverlay.tsx +35 -5
- package/src/components/ThresholdSplitShader.tsx +92 -0
- package/src/core/liveChartEngineTick.ts +45 -4
- package/src/core/liveChartSeriesEngineTick.ts +6 -0
- package/src/core/resolveConfig.ts +32 -6
- package/src/core/useLiveChartEngine.ts +35 -0
- package/src/hooks/useChartPaths.ts +51 -7
- package/src/hooks/useChartSkiaFont.ts +31 -5
- package/src/hooks/useThreshold.ts +267 -10
- package/src/math/threshold.ts +250 -0
- package/src/types.ts +78 -18
package/src/types.ts
CHANGED
|
@@ -431,32 +431,77 @@ export interface LineConfig {
|
|
|
431
431
|
}
|
|
432
432
|
|
|
433
433
|
/**
|
|
434
|
-
* Color the line above vs. below a
|
|
435
|
-
*
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
-
*
|
|
434
|
+
* Color the line above vs. below a threshold — green above, red below by
|
|
435
|
+
* default. The threshold is either a single **live benchmark** (a
|
|
436
|
+
* `SharedValue<number>` that tracks on the UI thread without re-rendering) or a
|
|
437
|
+
* **time-varying series** (a `LiveChartPoint[]` the split follows point-for-point
|
|
438
|
+
* — a stepped break-even, a historical VWAP). Drives a hard-split line stroke
|
|
439
|
+
* and, optionally, a tinted profit/loss fill band and a marker line at the
|
|
440
|
+
* threshold.
|
|
439
441
|
*
|
|
440
442
|
* The split stroke supersedes `LineConfig.color`/`colors` and segment recoloring
|
|
441
443
|
* for the main line while a threshold is set.
|
|
442
444
|
*/
|
|
443
445
|
export interface ThresholdConfig {
|
|
444
446
|
/**
|
|
445
|
-
* The split value, in Y-axis (price) units.
|
|
446
|
-
*
|
|
447
|
-
*
|
|
447
|
+
* The split value, in Y-axis (price) units. Two forms:
|
|
448
|
+
*
|
|
449
|
+
* - **`SharedValue<number>`** — a single live benchmark. Update it with
|
|
450
|
+
* `.set()` and the horizontal split tracks on the UI thread without
|
|
451
|
+
* re-rendering (break-even / average cost, VWAP, the previous close, a peg).
|
|
452
|
+
* - **`LiveChartPoint[]`** — a *time-varying* threshold (e.g. a historical
|
|
453
|
+
* break-even that steps up as you average in). The stroke split, fill band
|
|
454
|
+
* and marker line follow the series point-for-point. The series clamps to its
|
|
455
|
+
* first/last value outside its own time range, so a threshold whose last
|
|
456
|
+
* point sits behind the live edge extends as a flat line to "now" (see
|
|
457
|
+
* {@link extendToNow}). Flows in on re-render — pass a stable (memoized)
|
|
458
|
+
* array and reserve it for thresholds that change occasionally; for a
|
|
459
|
+
* threshold series that updates live, use {@link series} instead.
|
|
460
|
+
*
|
|
461
|
+
* Provide `value` or {@link series} (not both) — `series` wins if both are set.
|
|
462
|
+
*/
|
|
463
|
+
value?: SharedValue<number> | LiveChartPoint[];
|
|
464
|
+
/**
|
|
465
|
+
* A **live** time-varying threshold: like the `LiveChartPoint[]` form of
|
|
466
|
+
* {@link value}, but a `SharedValue` — update it with `.set()`/`.modify()` and
|
|
467
|
+
* the split tracks on the UI thread without re-rendering (a VWAP that updates
|
|
468
|
+
* every tick, mirroring how the chart's own `data` prop works). Points must be
|
|
469
|
+
* sorted by `time`, like `data`. Takes precedence over {@link value}.
|
|
470
|
+
*/
|
|
471
|
+
series?: SharedValue<LiveChartPoint[]>;
|
|
472
|
+
/**
|
|
473
|
+
* Stroke color where the line is at/above `value`. Default: palette up-green
|
|
474
|
+
* (`candleUp`). With a series `value`, use hex (`#rgb`/`#rrggbb`), `rgb()` or
|
|
475
|
+
* `rgba()` — the split shader parses these; named CSS colors and 8-digit hex
|
|
476
|
+
* are only supported by the constant form.
|
|
448
477
|
*/
|
|
449
|
-
value: SharedValue<number>;
|
|
450
|
-
/** Stroke color where the line is at/above `value`. Default: palette up-green (`candleUp`). */
|
|
451
478
|
aboveColor?: string;
|
|
452
|
-
/** Stroke color where the line is below `value`. Default: palette down-red
|
|
479
|
+
/** Stroke color where the line is below `value`. Default: palette down-red
|
|
480
|
+
* (`candleDown`). Same format support as `aboveColor`. */
|
|
453
481
|
belowColor?: string;
|
|
454
482
|
/**
|
|
455
|
-
* Tint the area between the line and
|
|
456
|
-
* above/below colors. Independent of the baseline `gradient` fill —
|
|
457
|
-
* `gradient={false}` for the threshold band alone.
|
|
483
|
+
* Tint the area between the line and the threshold (the profit/loss band)
|
|
484
|
+
* toward the above/below colors. Independent of the baseline `gradient` fill —
|
|
485
|
+
* set `gradient={false}` for the threshold band alone. `true` → default band
|
|
486
|
+
* opacity (`0.16`), or an object to tune it. Default `false`.
|
|
487
|
+
*/
|
|
488
|
+
fill?: boolean | ThresholdFillConfig;
|
|
489
|
+
/**
|
|
490
|
+
* Fold the threshold into the Y-axis range fit — like reference lines — so a
|
|
491
|
+
* benchmark outside the data's own range stays on-plot instead of rendering
|
|
492
|
+
* invisibly (marker off-plot, whole line one color). For a series, the values
|
|
493
|
+
* visible in the current window count (respecting {@link extendToNow}).
|
|
494
|
+
* Default `false` (range fits the data only).
|
|
495
|
+
*/
|
|
496
|
+
includeInRange?: boolean;
|
|
497
|
+
/**
|
|
498
|
+
* Series forms only: extend the threshold **flat past its last point to
|
|
499
|
+
* "now"**, carrying the last known benchmark forward. Set `false` for a
|
|
500
|
+
* benchmark that must not project into the future (a closed session's VWAP) —
|
|
501
|
+
* right of the last point the stroke keeps its plain line color and the band /
|
|
502
|
+
* marker / badge end. Default `true`.
|
|
458
503
|
*/
|
|
459
|
-
|
|
504
|
+
extendToNow?: boolean;
|
|
460
505
|
/**
|
|
461
506
|
* Dashed marker line + optional gutter label at the threshold. `true` → a dashed
|
|
462
507
|
* line in the palette reference color; object → styled; omit/`false` → none.
|
|
@@ -483,6 +528,16 @@ export interface ThresholdLineConfig {
|
|
|
483
528
|
strokeWidth?: number;
|
|
484
529
|
/** Append the formatted threshold value to the label. Default `false`. */
|
|
485
530
|
showValue?: boolean;
|
|
531
|
+
/** Label text color. Defaults to {@link color}, then palette `refLabel` —
|
|
532
|
+
* mirroring `ReferenceLine.labelColor`. */
|
|
533
|
+
labelColor?: string;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/** Object form of {@link ThresholdConfig.fill} — band tuning. */
|
|
537
|
+
export interface ThresholdFillConfig {
|
|
538
|
+
/** Band fill opacity (0–1), applied to the above/below colors. Multiplies an
|
|
539
|
+
* `rgba()` color's own alpha. Default `0.16` (matching reference-line bands). */
|
|
540
|
+
opacity?: number;
|
|
486
541
|
}
|
|
487
542
|
|
|
488
543
|
/** Area fill gradient beneath the chart line. */
|
|
@@ -1924,9 +1979,14 @@ export interface LiveChartCoreProps {
|
|
|
1924
1979
|
/** Crosshair scrubbing on hover/drag. `true` = defaults, `false` = disabled, or pass `ScrubConfig`. Default `true`. */
|
|
1925
1980
|
scrub?: boolean | ScrubConfig;
|
|
1926
1981
|
/**
|
|
1927
|
-
* Selection dot drawn at the scrub intersection while scrubbing. `true
|
|
1928
|
-
*
|
|
1929
|
-
* `color`, `ring`, or a custom `component`).
|
|
1982
|
+
* Selection dot drawn at the scrub intersection while scrubbing. `true` =
|
|
1983
|
+
* built-in dot, `false` = hidden, or pass `SelectionDotConfig` (`size`,
|
|
1984
|
+
* `color`, `ring`, or a custom `component`).
|
|
1985
|
+
*
|
|
1986
|
+
* Defaults differ per chart: `LiveChart` shows it (`true`); `LiveChartSeries`
|
|
1987
|
+
* hides it (`false`) — with multiple lines the dot can only track the leading
|
|
1988
|
+
* series, so the crosshair + per-series tooltips mark the scrub point instead.
|
|
1989
|
+
* Pass `true` / a config to opt a multi-series chart in.
|
|
1930
1990
|
*/
|
|
1931
1991
|
selectionDot?: boolean | SelectionDotConfig;
|
|
1932
1992
|
/** Called once when the user starts scrubbing/panning the chart. */
|