react-native-livechart 4.7.0 → 4.9.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/LiveChart.d.ts.map +1 -1
- package/dist/components/LiveChartSeries.d.ts.map +1 -1
- package/dist/components/LoadingOverlay.d.ts +3 -1
- package/dist/components/LoadingOverlay.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/resolveConfig.d.ts +24 -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/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 +80 -19
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/LiveChart.tsx +284 -46
- package/src/components/LiveChartSeries.tsx +12 -3
- package/src/components/LoadingOverlay.tsx +35 -28
- package/src/components/ThresholdLineOverlay.tsx +35 -5
- package/src/components/ThresholdSplitShader.tsx +92 -0
- package/src/core/liveChartEngineTick.ts +28 -0
- package/src/core/resolveConfig.ts +35 -6
- package/src/core/useLiveChartEngine.ts +35 -0
- package/src/hooks/useChartPaths.ts +51 -7
- package/src/hooks/useThreshold.ts +267 -10
- package/src/math/threshold.ts +250 -0
- package/src/types.ts +81 -19
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).
|
|
458
495
|
*/
|
|
459
|
-
|
|
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`.
|
|
503
|
+
*/
|
|
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. */
|
|
@@ -1668,6 +1723,12 @@ export interface LoadingConfig {
|
|
|
1668
1723
|
* `<1` slower, `0` freezes it. Default `1`.
|
|
1669
1724
|
*/
|
|
1670
1725
|
speed?: number;
|
|
1726
|
+
/**
|
|
1727
|
+
* Whether the shell draws the skeleton Y-axis label placeholders (the short
|
|
1728
|
+
* rounded dashes centred in the gutter). Set `false` to show only the breathing
|
|
1729
|
+
* squiggle with no placeholder ticks. Default `true`.
|
|
1730
|
+
*/
|
|
1731
|
+
axisLabels?: boolean;
|
|
1671
1732
|
}
|
|
1672
1733
|
|
|
1673
1734
|
/** Props shared between `LiveChart` and `LiveChartSeries`. */
|
|
@@ -1701,10 +1762,11 @@ export interface LiveChartCoreProps {
|
|
|
1701
1762
|
*
|
|
1702
1763
|
* `true` shows the shell with the defaults; pass a {@link LoadingConfig} to
|
|
1703
1764
|
* restyle it — `color` / `strokeWidth` for the squiggle + skeleton, `amplitude`
|
|
1704
|
-
* / `speed` for the breathing wave
|
|
1705
|
-
*
|
|
1706
|
-
*
|
|
1707
|
-
* {@link TransitionConfig.reveal} (the
|
|
1765
|
+
* / `speed` for the breathing wave, `axisLabels` to toggle the skeleton
|
|
1766
|
+
* placeholders. `false` / omitted is "not loading". Toggle between the config
|
|
1767
|
+
* and `false` as data loads (e.g. `loading={isLoading && cfg}`). The loading→live
|
|
1768
|
+
* reveal duration is governed separately by {@link TransitionConfig.reveal} (the
|
|
1769
|
+
* `transitions` prop).
|
|
1708
1770
|
*/
|
|
1709
1771
|
loading?: boolean | LoadingConfig;
|
|
1710
1772
|
/**
|