react-native-livechart 4.17.0 → 4.19.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 (75) 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/CustomMarkerOverlay.d.ts.map +1 -1
  4. package/dist/components/DotOverlay.d.ts +10 -2
  5. package/dist/components/DotOverlay.d.ts.map +1 -1
  6. package/dist/components/LiveChart.d.ts.map +1 -1
  7. package/dist/components/LiveChartSeries.d.ts.map +1 -1
  8. package/dist/components/MarkerOverlay.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 +20 -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/line.d.ts +9 -3
  19. package/dist/draw/line.d.ts.map +1 -1
  20. package/dist/hooks/crosshairShared.d.ts +8 -0
  21. package/dist/hooks/crosshairShared.d.ts.map +1 -1
  22. package/dist/hooks/resolveChartLayout.d.ts +12 -1
  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/useCrosshair.d.ts +7 -1
  29. package/dist/hooks/useCrosshair.d.ts.map +1 -1
  30. package/dist/hooks/useDegen.d.ts +1 -3
  31. package/dist/hooks/useDegen.d.ts.map +1 -1
  32. package/dist/hooks/useLiveDot.d.ts +8 -2
  33. package/dist/hooks/useLiveDot.d.ts.map +1 -1
  34. package/dist/hooks/useMarkers.d.ts.map +1 -1
  35. package/dist/hooks/useMultiSeriesLinePaths.d.ts +3 -1
  36. package/dist/hooks/useMultiSeriesLinePaths.d.ts.map +1 -1
  37. package/dist/hooks/useSeriesIndicatorOpacity.d.ts +13 -0
  38. package/dist/hooks/useSeriesIndicatorOpacity.d.ts.map +1 -0
  39. package/dist/hooks/useTradeStream.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/markerCluster.d.ts +6 -0
  43. package/dist/math/markerCluster.d.ts.map +1 -1
  44. package/dist/math/simplify.d.ts +20 -0
  45. package/dist/math/simplify.d.ts.map +1 -0
  46. package/dist/types.d.ts +106 -17
  47. package/dist/types.d.ts.map +1 -1
  48. package/package.json +1 -1
  49. package/src/components/CrosshairOverlay.tsx +14 -9
  50. package/src/components/CustomMarkerOverlay.tsx +5 -1
  51. package/src/components/DotOverlay.tsx +26 -3
  52. package/src/components/LiveChart.tsx +210 -55
  53. package/src/components/LiveChartSeries.tsx +28 -10
  54. package/src/components/MarkerOverlay.tsx +5 -1
  55. package/src/components/MultiSeriesDots.tsx +22 -3
  56. package/src/constants.ts +7 -0
  57. package/src/core/resolveConfig.ts +67 -13
  58. package/src/core/useLiveChartEngine.ts +6 -1
  59. package/src/draw/candle.ts +78 -0
  60. package/src/draw/line.ts +24 -10
  61. package/src/hooks/crosshairShared.ts +31 -0
  62. package/src/hooks/resolveChartLayout.ts +40 -16
  63. package/src/hooks/useCandlePaths.ts +9 -1
  64. package/src/hooks/useChartPaths.ts +37 -7
  65. package/src/hooks/useCrosshair.ts +29 -2
  66. package/src/hooks/useDegen.ts +2 -6
  67. package/src/hooks/useLiveDot.ts +28 -3
  68. package/src/hooks/useMarkers.ts +11 -3
  69. package/src/hooks/useMultiSeriesLinePaths.ts +31 -4
  70. package/src/hooks/useSeriesIndicatorOpacity.ts +56 -0
  71. package/src/hooks/useTradeStream.ts +6 -1
  72. package/src/index.ts +1 -0
  73. package/src/math/markerCluster.ts +15 -1
  74. package/src/math/simplify.ts +197 -0
  75. package/src/types.ts +107 -17
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
  /**
@@ -591,7 +600,11 @@ export interface AreaDotsConfig {
591
600
  export interface BadgeConfig extends BadgeStyleConfig {
592
601
  /** Visual style of the badge pill. Default `"default"`. */
593
602
  variant?: BadgeVariant;
594
- /** Show the pointed tail toward the live dot. Default `true`. */
603
+ /**
604
+ * Show the pointed tail toward the live dot. When `false`, no tail space is
605
+ * reserved: the pill body sits flush at the gutter edge (right after the dot
606
+ * gap) and the auto right padding shrinks accordingly. Default `true`.
607
+ */
595
608
  tail?: boolean;
596
609
  /** Which side of the chart the badge appears on. Default `"right"`. */
597
610
  position?: "right" | "left";
@@ -850,13 +863,36 @@ export interface ScrubConfig {
850
863
  */
851
864
  seriesTooltip?: boolean | PerSeriesTooltipConfig;
852
865
  /**
853
- * Opacity of the chart content to the *right* of the crosshair (the "future")
854
- * while scrubbing — `0` fully fades it out, `1` disables the dim. Implemented
855
- * by erasing the content's alpha (`dstOut`), so it reveals the real background
856
- * and works on any background color. Default `0.3`. Ignored when
857
- * `crosshairDimColor` is set (that uses the legacy colored mask instead).
866
+ * Which content {@link dimOpacity} fades while scrubbing.
867
+ *
868
+ * - `"future"` fades all chart content to the right of the crosshair.
869
+ * - `"otherCandles"` keeps the candle under the finger at full strength and
870
+ * fades every other candle body and wick. Outside candle mode it falls back
871
+ * to the standard `"future"` behavior. When the finger is in a gap between
872
+ * candle buckets no candle is selected. Volume bars are unchanged. The
873
+ * vertical crosshair and scrub selection dot are hidden so the focused
874
+ * candle is the sole position indicator.
875
+ *
876
+ * Default `"future"`.
877
+ */
878
+ dimTarget?: "future" | "otherCandles";
879
+ /**
880
+ * Opacity of the content selected by {@link dimTarget} while scrubbing — `0`
881
+ * fully fades it out, `1` disables the dim. Values are clamped to `[0, 1]`.
882
+ *
883
+ * With the default `dimTarget: "future"`, the fade is implemented by erasing
884
+ * the trailing content's alpha (`dstOut`), so it reveals the real background
885
+ * and works on any background color. Default `0.3`. `crosshairDimColor`
886
+ * overrides this opacity only for the `"future"` target.
858
887
  */
859
888
  dimOpacity?: number;
889
+ /**
890
+ * Duration in milliseconds for other candles to ease toward
891
+ * {@link dimOpacity} when a focused-candle scrub starts, and back to full
892
+ * strength on release. Used only with `dimTarget: "otherCandles"`.
893
+ * Set `0` for an instant change. Negative values clamp to `0`. Default `60`.
894
+ */
895
+ dimFadeMs?: number;
860
896
  /** Vertical crosshair line stroke. Omit to use theme `crosshairLine`. */
861
897
  crosshairLineColor?: string;
862
898
  /** Vertical crosshair line width in px. Default `1`. */
@@ -961,6 +997,15 @@ export interface ScrubConfig {
961
997
  * Default `false`.
962
998
  */
963
999
  clampToPlot?: boolean;
1000
+ /**
1001
+ * Candle mode: snap the crosshair to candle centers. The scrub X is
1002
+ * quantized to the hovered candle's center before it drives the crosshair,
1003
+ * so the line — and everything derived from it (the time, tooltip, and
1004
+ * trailing dim) — jumps from candle to candle instead of gliding, the
1005
+ * tick-to-tick feel of pro charting tools. A position in a gap between
1006
+ * candles keeps the raw finger X; no effect in line mode. Default `false`.
1007
+ */
1008
+ snapToCandles?: boolean;
964
1009
  }
965
1010
 
966
1011
  /**
@@ -1509,11 +1554,23 @@ export interface DegenShakePayload {
1509
1554
  direction: "up" | "down";
1510
1555
  }
1511
1556
 
1512
- /** Contrasting outer ring drawn behind each series dot — the "haloed" look the
1513
- * single-series live dot has, so dots stand out against the lines and one
1514
- * another. */
1557
+ /** Optional soft, static color glow drawn behind a live dot. */
1558
+ export interface DotGlowConfig {
1559
+ /** Glow color. Defaults to the dot's resolved fill color. */
1560
+ color?: string;
1561
+ /** Radius of the glow's source circle in pixels. Default `7`. */
1562
+ radius?: number;
1563
+ /** Skia blur radius in pixels. Default `5`. */
1564
+ blur?: number;
1565
+ /** Glow opacity (0–1). Default `0.18`. */
1566
+ opacity?: number;
1567
+ }
1568
+
1569
+ /** Contrasting outer ring drawn behind each series dot — the crisp backing
1570
+ * circle the single-series live dot has, so dots stand out against the lines
1571
+ * and one another. */
1515
1572
  export interface DotRingConfig {
1516
- /** Ring color. Default: theme `badgeOuterBg` (a near-background halo). */
1573
+ /** Ring color. Default: theme `badgeOuterBg` (a near-background backing). */
1517
1574
  color?: string;
1518
1575
  /** Ring thickness in pixels — how far the halo extends past the dot. Default `2.5`. */
1519
1576
  width?: number;
@@ -1522,7 +1579,8 @@ export interface DotRingConfig {
1522
1579
  /**
1523
1580
  * Shared live-dot styling, used by both `LiveChart` (`dot`) and
1524
1581
  * `LiveChartSeries` (`dot`, which extends this). A dot is a color-filled circle
1525
- * of `radius` with an optional contrasting outer `ring` (halo).
1582
+ * of `radius` with an optional contrasting outer `ring` and opt-in soft
1583
+ * `glow`. The glow is static; use `pulse` for an animated heartbeat.
1526
1584
  */
1527
1585
  export interface DotConfig {
1528
1586
  /** Radius of the (color-filled) dot in pixels. Default `3.5`. */
@@ -1533,6 +1591,12 @@ export interface DotConfig {
1533
1591
  * `DotRingConfig`. Default `true`.
1534
1592
  */
1535
1593
  ring?: boolean | DotRingConfig;
1594
+ /**
1595
+ * Soft static glow behind the dot. `true` = restrained defaults, `false` =
1596
+ * off, or pass `DotGlowConfig` to tune its color, radius, blur, and opacity.
1597
+ * Default `false`.
1598
+ */
1599
+ glow?: boolean | DotGlowConfig;
1536
1600
  /**
1537
1601
  * Show the dot. `false` hides it (line, badge, and labels still render). Default `true`.
1538
1602
  *
@@ -1542,6 +1606,21 @@ export interface DotConfig {
1542
1606
  show?: boolean;
1543
1607
  /** Dot fill color. Defaults to the chart line color (per series for multi-series). */
1544
1608
  color?: string;
1609
+ /**
1610
+ * Keep the dot on the **true live point** while scrolled back or overscrolled
1611
+ * with `timeScroll`: it tracks the live point's x (instead of staying pinned
1612
+ * to the plot's right edge), keeps its heartbeat pulse (the dot still marks
1613
+ * an honest live position), stays visible under
1614
+ * `timeScroll.hideLiveOnScrollBack`, and hides once the live point leaves the
1615
+ * visible window. Ignored when `badge.followViewEdge` is set — an edge-pinned
1616
+ * dot must stay aligned with its badge. Single-series `LiveChart` only
1617
+ * (multi-series dots already ride each line's end while scrolled). Default
1618
+ * `false` (the dot stays pinned to the right edge with its pulse suppressed
1619
+ * while scrolled back).
1620
+ *
1621
+ * @experimental
1622
+ */
1623
+ trackWhileParked?: boolean;
1545
1624
  }
1546
1625
 
1547
1626
  /** Live dot configuration for multi-series charts (extends the shared {@link DotConfig}). */
@@ -1609,6 +1688,13 @@ export interface SeriesConfig {
1609
1688
  * anchored to this series snap to the straight chord to match.
1610
1689
  */
1611
1690
  curve?: "monotone" | "linear";
1691
+ /**
1692
+ * Per-series screen-space path simplification tolerance in pixels. Overrides
1693
+ * `LiveChartSeries.line.simplify`; `0` disables simplification for this series.
1694
+ * Only rendered geometry is simplified — values, range fitting, and scrubbing
1695
+ * continue to use the original points.
1696
+ */
1697
+ simplify?: number;
1612
1698
  /** Per-series stroke width override (px). Falls back to the chart line width. */
1613
1699
  strokeWidth?: number;
1614
1700
  /** Render a soft glow behind this series' line. Default `false`. */
@@ -1958,9 +2044,11 @@ export interface LiveChartCoreProps {
1958
2044
  /**
1959
2045
  * UI-thread opacity multiplier for the plotted data. Set a value from `0`
1960
2046
  * (hidden) to `1` (fully visible), such as `0.5` while replacement data loads.
1961
- * Applies to every plotted series — line/fill/candles, live dots, value lines,
1962
- * and inline values — without affecting axes, reference lines, legends, or
1963
- * scrub UI. Default `1`.
2047
+ * Applies to every plotted series — line/fill/candles, value lines, and inline
2048
+ * values — without affecting axes, reference lines, legends, or scrub UI.
2049
+ * While the multiplier is below `1`, live dots and pulse rings fade completely
2050
+ * out so the dimmed stroke cannot show through them; they fade back in when it
2051
+ * returns to `1`. Default `1`.
1964
2052
  */
1965
2053
  seriesOpacity?: SharedValue<number>;
1966
2054
  /**
@@ -2298,7 +2386,8 @@ export interface LiveChartProps extends LiveChartCoreProps {
2298
2386
  pulse?: boolean | PulseConfig;
2299
2387
  /**
2300
2388
  * Live dot styling. `true`/omitted = shown defaults, `false` = hidden, or pass
2301
- * `DotConfig` (`radius`, `ring` halo, `color`). See {@link DotConfig}. Default `true`.
2389
+ * `DotConfig` (`radius`, `ring`, opt-in `glow`, `color`). See
2390
+ * {@link DotConfig}. Default `true`.
2302
2391
  */
2303
2392
  dot?: boolean | DotConfig;
2304
2393
  /** Horizontal dashed line at the current live value. `true` = defaults, or pass `ValueLineConfig`. */
@@ -2346,8 +2435,9 @@ export interface LiveChartProps extends LiveChartCoreProps {
2346
2435
  /** Render once with no per-frame animation loop — for many small charts (sparklines)
2347
2436
  * in a list. The continuous animations (pulse, degen, the entry reveal) are disabled,
2348
2437
  * but `scrub` / `scrubAction` stay available — they're on-demand touch gestures with
2349
- * no per-frame cost, so a still chart is still scrubbable. Frame the data with
2350
- * `timeWindow` + `nowOverride` (see the historical-data-fill pattern). */
2438
+ * no per-frame cost, so a still chart is still scrubbable. May be toggled at runtime:
2439
+ * switching back to live restarts the suspended loops and catches up. Frame the data
2440
+ * with `timeWindow` + `nowOverride` (see the historical-data-fill pattern). */
2351
2441
  static?: boolean;
2352
2442
  /**
2353
2443
  * Render a custom overlay floated over the chart canvas, handed a price↔pixel /