react-native-livechart 4.18.0 → 4.20.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.
Files changed (70) hide show
  1. package/dist/components/CrosshairOverlay.d.ts +3 -1
  2. package/dist/components/CrosshairOverlay.d.ts.map +1 -1
  3. package/dist/components/DotOverlay.d.ts +4 -2
  4. package/dist/components/DotOverlay.d.ts.map +1 -1
  5. package/dist/components/LiveChart.d.ts +2 -2
  6. package/dist/components/LiveChart.d.ts.map +1 -1
  7. package/dist/components/LiveChartSeries.d.ts +2 -2
  8. package/dist/components/LiveChartSeries.d.ts.map +1 -1
  9. package/dist/components/MultiSeriesDots.d.ts +5 -3
  10. package/dist/components/MultiSeriesDots.d.ts.map +1 -1
  11. package/dist/constants.d.ts +6 -0
  12. package/dist/constants.d.ts.map +1 -1
  13. package/dist/core/resolveConfig.d.ts +19 -3
  14. package/dist/core/resolveConfig.d.ts.map +1 -1
  15. package/dist/core/useLiveChartEngine.d.ts.map +1 -1
  16. package/dist/draw/candle.d.ts +21 -0
  17. package/dist/draw/candle.d.ts.map +1 -1
  18. package/dist/draw/grid.d.ts +1 -1
  19. package/dist/draw/grid.d.ts.map +1 -1
  20. package/dist/draw/line.d.ts +7 -1
  21. package/dist/draw/line.d.ts.map +1 -1
  22. package/dist/hooks/resolveChartLayout.d.ts +8 -0
  23. package/dist/hooks/resolveChartLayout.d.ts.map +1 -1
  24. package/dist/hooks/useCandlePaths.d.ts +3 -1
  25. package/dist/hooks/useCandlePaths.d.ts.map +1 -1
  26. package/dist/hooks/useChartPaths.d.ts +3 -1
  27. package/dist/hooks/useChartPaths.d.ts.map +1 -1
  28. package/dist/hooks/useDegen.d.ts +1 -3
  29. package/dist/hooks/useDegen.d.ts.map +1 -1
  30. package/dist/hooks/useMarkers.d.ts.map +1 -1
  31. package/dist/hooks/useMultiSeriesLinePaths.d.ts +3 -1
  32. package/dist/hooks/useMultiSeriesLinePaths.d.ts.map +1 -1
  33. package/dist/hooks/usePinchZoom.d.ts +7 -0
  34. package/dist/hooks/usePinchZoom.d.ts.map +1 -1
  35. package/dist/hooks/useSeriesIndicatorOpacity.d.ts +13 -0
  36. package/dist/hooks/useSeriesIndicatorOpacity.d.ts.map +1 -0
  37. package/dist/hooks/useTradeStream.d.ts.map +1 -1
  38. package/dist/hooks/useYAxis.d.ts +1 -1
  39. package/dist/hooks/useYAxis.d.ts.map +1 -1
  40. package/dist/index.d.ts +1 -1
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/math/simplify.d.ts +20 -0
  43. package/dist/math/simplify.d.ts.map +1 -0
  44. package/dist/types.d.ts +101 -16
  45. package/dist/types.d.ts.map +1 -1
  46. package/package.json +1 -1
  47. package/src/components/CrosshairOverlay.tsx +14 -9
  48. package/src/components/DotOverlay.tsx +17 -1
  49. package/src/components/LiveChart.tsx +227 -67
  50. package/src/components/LiveChartSeries.tsx +56 -16
  51. package/src/components/MultiSeriesDots.tsx +22 -3
  52. package/src/constants.ts +7 -0
  53. package/src/core/resolveConfig.ts +72 -14
  54. package/src/core/useLiveChartEngine.ts +6 -1
  55. package/src/draw/candle.ts +78 -0
  56. package/src/draw/grid.ts +34 -4
  57. package/src/draw/line.ts +20 -7
  58. package/src/hooks/resolveChartLayout.ts +30 -18
  59. package/src/hooks/useCandlePaths.ts +9 -1
  60. package/src/hooks/useChartPaths.ts +37 -7
  61. package/src/hooks/useDegen.ts +2 -6
  62. package/src/hooks/useMarkers.ts +6 -2
  63. package/src/hooks/useMultiSeriesLinePaths.ts +31 -4
  64. package/src/hooks/usePinchZoom.ts +21 -0
  65. package/src/hooks/useSeriesIndicatorOpacity.ts +56 -0
  66. package/src/hooks/useTradeStream.ts +6 -1
  67. package/src/hooks/useYAxis.ts +2 -0
  68. package/src/index.ts +2 -0
  69. package/src/math/simplify.ts +197 -0
  70. package/src/types.ts +103 -16
package/src/types.ts CHANGED
@@ -422,6 +422,15 @@ export interface LineConfig {
422
422
  * pair with `join: "miter"` + `cap: "butt"` for true sharp corners (no rounding).
423
423
  */
424
424
  curve?: "monotone" | "linear";
425
+ /**
426
+ * Screen-space path simplification tolerance in pixels. Values above `0`
427
+ * remove intermediate points that deviate by no more than this amount while
428
+ * retaining endpoints and larger peaks/valleys. This changes only the drawn
429
+ * line/fill; axis fitting, live values, markers, and scrubbing still use the
430
+ * original data. Default `0` (off). Start around `0.75`–`1.5` for sub-pixel
431
+ * noise reduction.
432
+ */
433
+ simplify?: number;
425
434
  /** Line color override. Defaults to palette-derived accent. */
426
435
  color?: string;
427
436
  /**
@@ -639,6 +648,15 @@ export interface VolumeConfig {
639
648
  export interface YAxisConfig {
640
649
  /** Minimum pixel gap between grid lines. Default `36`. */
641
650
  minGap?: number;
651
+ /**
652
+ * Multiplier used to choose and align dynamic "nice" intervals without
653
+ * changing plotted values. Pair it with a `formatValue` that applies the
654
+ * same multiplier. Must be positive and finite; invalid values use `1`.
655
+ * If applying the multiplier to the live range would overflow or underflow,
656
+ * interval selection falls back to source units for that range.
657
+ * Ignored when {@link count} is set. Default `1`.
658
+ */
659
+ intervalScale?: number;
642
660
  /**
643
661
  * Show a fixed number of price labels instead of the dynamic nice-interval
644
662
  * grid. When set (≥ 2), exactly `count` labels are spaced evenly **in pixels**
@@ -854,13 +872,36 @@ export interface ScrubConfig {
854
872
  */
855
873
  seriesTooltip?: boolean | PerSeriesTooltipConfig;
856
874
  /**
857
- * Opacity of the chart content to the *right* of the crosshair (the "future")
858
- * while scrubbing — `0` fully fades it out, `1` disables the dim. Implemented
859
- * by erasing the content's alpha (`dstOut`), so it reveals the real background
860
- * and works on any background color. Default `0.3`. Ignored when
861
- * `crosshairDimColor` is set (that uses the legacy colored mask instead).
875
+ * Which content {@link dimOpacity} fades while scrubbing.
876
+ *
877
+ * - `"future"` fades all chart content to the right of the crosshair.
878
+ * - `"otherCandles"` keeps the candle under the finger at full strength and
879
+ * fades every other candle body and wick. Outside candle mode it falls back
880
+ * to the standard `"future"` behavior. When the finger is in a gap between
881
+ * candle buckets no candle is selected. Volume bars are unchanged. The
882
+ * vertical crosshair and scrub selection dot are hidden so the focused
883
+ * candle is the sole position indicator.
884
+ *
885
+ * Default `"future"`.
886
+ */
887
+ dimTarget?: "future" | "otherCandles";
888
+ /**
889
+ * Opacity of the content selected by {@link dimTarget} while scrubbing — `0`
890
+ * fully fades it out, `1` disables the dim. Values are clamped to `[0, 1]`.
891
+ *
892
+ * With the default `dimTarget: "future"`, the fade is implemented by erasing
893
+ * the trailing content's alpha (`dstOut`), so it reveals the real background
894
+ * and works on any background color. Default `0.3`. `crosshairDimColor`
895
+ * overrides this opacity only for the `"future"` target.
862
896
  */
863
897
  dimOpacity?: number;
898
+ /**
899
+ * Duration in milliseconds for other candles to ease toward
900
+ * {@link dimOpacity} when a focused-candle scrub starts, and back to full
901
+ * strength on release. Used only with `dimTarget: "otherCandles"`.
902
+ * Set `0` for an instant change. Negative values clamp to `0`. Default `60`.
903
+ */
904
+ dimFadeMs?: number;
864
905
  /** Vertical crosshair line stroke. Omit to use theme `crosshairLine`. */
865
906
  crosshairLineColor?: string;
866
907
  /** Vertical crosshair line width in px. Default `1`. */
@@ -1522,11 +1563,23 @@ export interface DegenShakePayload {
1522
1563
  direction: "up" | "down";
1523
1564
  }
1524
1565
 
1525
- /** Contrasting outer ring drawn behind each series dot — the "haloed" look the
1526
- * single-series live dot has, so dots stand out against the lines and one
1527
- * another. */
1566
+ /** Optional soft, static color glow drawn behind a live dot. */
1567
+ export interface DotGlowConfig {
1568
+ /** Glow color. Defaults to the dot's resolved fill color. */
1569
+ color?: string;
1570
+ /** Radius of the glow's source circle in pixels. Default `7`. */
1571
+ radius?: number;
1572
+ /** Skia blur radius in pixels. Default `5`. */
1573
+ blur?: number;
1574
+ /** Glow opacity (0–1). Default `0.18`. */
1575
+ opacity?: number;
1576
+ }
1577
+
1578
+ /** Contrasting outer ring drawn behind each series dot — the crisp backing
1579
+ * circle the single-series live dot has, so dots stand out against the lines
1580
+ * and one another. */
1528
1581
  export interface DotRingConfig {
1529
- /** Ring color. Default: theme `badgeOuterBg` (a near-background halo). */
1582
+ /** Ring color. Default: theme `badgeOuterBg` (a near-background backing). */
1530
1583
  color?: string;
1531
1584
  /** Ring thickness in pixels — how far the halo extends past the dot. Default `2.5`. */
1532
1585
  width?: number;
@@ -1535,7 +1588,8 @@ export interface DotRingConfig {
1535
1588
  /**
1536
1589
  * Shared live-dot styling, used by both `LiveChart` (`dot`) and
1537
1590
  * `LiveChartSeries` (`dot`, which extends this). A dot is a color-filled circle
1538
- * of `radius` with an optional contrasting outer `ring` (halo).
1591
+ * of `radius` with an optional contrasting outer `ring` and opt-in soft
1592
+ * `glow`. The glow is static; use `pulse` for an animated heartbeat.
1539
1593
  */
1540
1594
  export interface DotConfig {
1541
1595
  /** Radius of the (color-filled) dot in pixels. Default `3.5`. */
@@ -1546,6 +1600,12 @@ export interface DotConfig {
1546
1600
  * `DotRingConfig`. Default `true`.
1547
1601
  */
1548
1602
  ring?: boolean | DotRingConfig;
1603
+ /**
1604
+ * Soft static glow behind the dot. `true` = restrained defaults, `false` =
1605
+ * off, or pass `DotGlowConfig` to tune its color, radius, blur, and opacity.
1606
+ * Default `false`.
1607
+ */
1608
+ glow?: boolean | DotGlowConfig;
1549
1609
  /**
1550
1610
  * Show the dot. `false` hides it (line, badge, and labels still render). Default `true`.
1551
1611
  *
@@ -1637,6 +1697,13 @@ export interface SeriesConfig {
1637
1697
  * anchored to this series snap to the straight chord to match.
1638
1698
  */
1639
1699
  curve?: "monotone" | "linear";
1700
+ /**
1701
+ * Per-series screen-space path simplification tolerance in pixels. Overrides
1702
+ * `LiveChartSeries.line.simplify`; `0` disables simplification for this series.
1703
+ * Only rendered geometry is simplified — values, range fitting, and scrubbing
1704
+ * continue to use the original points.
1705
+ */
1706
+ simplify?: number;
1640
1707
  /** Per-series stroke width override (px). Falls back to the chart line width. */
1641
1708
  strokeWidth?: number;
1642
1709
  /** Render a soft glow behind this series' line. Default `false`. */
@@ -1884,6 +1951,22 @@ export interface ZoomConfig {
1884
1951
  maxTimeWindow?: number;
1885
1952
  }
1886
1953
 
1954
+ /** Imperative methods exposed by `LiveChart` and `LiveChartSeries`. */
1955
+ export interface LiveChartHandle {
1956
+ /**
1957
+ * Reset built-in pinch/time-window zoom to the configured `timeWindow` and
1958
+ * clear the focal-point offset so the chart follows the live edge again.
1959
+ * Safe to call when already reset. A paused chart remains paused.
1960
+ *
1961
+ * ```tsx
1962
+ * const chartRef = useRef<LiveChartHandle>(null);
1963
+ * <Button title="Reset zoom" onPress={() => chartRef.current?.resetZoom()} />
1964
+ * <LiveChart ref={chartRef} data={data} value={value} zoom />
1965
+ * ```
1966
+ */
1967
+ resetZoom(): void;
1968
+ }
1969
+
1887
1970
  /**
1888
1971
  * The visible time range reported by {@link LiveChartCoreProps.onVisibleRangeChange}.
1889
1972
  *
@@ -1986,9 +2069,11 @@ export interface LiveChartCoreProps {
1986
2069
  /**
1987
2070
  * UI-thread opacity multiplier for the plotted data. Set a value from `0`
1988
2071
  * (hidden) to `1` (fully visible), such as `0.5` while replacement data loads.
1989
- * Applies to every plotted series — line/fill/candles, live dots, value lines,
1990
- * and inline values — without affecting axes, reference lines, legends, or
1991
- * scrub UI. Default `1`.
2072
+ * Applies to every plotted series — line/fill/candles, value lines, and inline
2073
+ * values — without affecting axes, reference lines, legends, or scrub UI.
2074
+ * While the multiplier is below `1`, live dots and pulse rings fade completely
2075
+ * out so the dimmed stroke cannot show through them; they fade back in when it
2076
+ * returns to `1`. Default `1`.
1992
2077
  */
1993
2078
  seriesOpacity?: SharedValue<number>;
1994
2079
  /**
@@ -2326,7 +2411,8 @@ export interface LiveChartProps extends LiveChartCoreProps {
2326
2411
  pulse?: boolean | PulseConfig;
2327
2412
  /**
2328
2413
  * Live dot styling. `true`/omitted = shown defaults, `false` = hidden, or pass
2329
- * `DotConfig` (`radius`, `ring` halo, `color`). See {@link DotConfig}. Default `true`.
2414
+ * `DotConfig` (`radius`, `ring`, opt-in `glow`, `color`). See
2415
+ * {@link DotConfig}. Default `true`.
2330
2416
  */
2331
2417
  dot?: boolean | DotConfig;
2332
2418
  /** Horizontal dashed line at the current live value. `true` = defaults, or pass `ValueLineConfig`. */
@@ -2374,8 +2460,9 @@ export interface LiveChartProps extends LiveChartCoreProps {
2374
2460
  /** Render once with no per-frame animation loop — for many small charts (sparklines)
2375
2461
  * in a list. The continuous animations (pulse, degen, the entry reveal) are disabled,
2376
2462
  * but `scrub` / `scrubAction` stay available — they're on-demand touch gestures with
2377
- * no per-frame cost, so a still chart is still scrubbable. Frame the data with
2378
- * `timeWindow` + `nowOverride` (see the historical-data-fill pattern). */
2463
+ * no per-frame cost, so a still chart is still scrubbable. May be toggled at runtime:
2464
+ * switching back to live restarts the suspended loops and catches up. Frame the data
2465
+ * with `timeWindow` + `nowOverride` (see the historical-data-fill pattern). */
2379
2466
  static?: boolean;
2380
2467
  /**
2381
2468
  * Render a custom overlay floated over the chart canvas, handed a price↔pixel /