react-native-livechart 3.12.0 → 4.0.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 (136) hide show
  1. package/dist/components/BadgeOverlay.d.ts +9 -1
  2. package/dist/components/BadgeOverlay.d.ts.map +1 -1
  3. package/dist/components/ChartOverlayLayer.d.ts +19 -0
  4. package/dist/components/ChartOverlayLayer.d.ts.map +1 -0
  5. package/dist/components/CustomMarkerOverlay.d.ts +16 -6
  6. package/dist/components/CustomMarkerOverlay.d.ts.map +1 -1
  7. package/dist/components/CustomReferenceLineOverlay.d.ts +36 -0
  8. package/dist/components/CustomReferenceLineOverlay.d.ts.map +1 -0
  9. package/dist/components/CustomTooltipOverlay.d.ts +5 -2
  10. package/dist/components/CustomTooltipOverlay.d.ts.map +1 -1
  11. package/dist/components/DotOverlay.d.ts +7 -1
  12. package/dist/components/DotOverlay.d.ts.map +1 -1
  13. package/dist/components/LiveChart.d.ts.map +1 -1
  14. package/dist/components/LiveChartSeries.d.ts.map +1 -1
  15. package/dist/components/MarkerOverlay.d.ts +6 -3
  16. package/dist/components/MarkerOverlay.d.ts.map +1 -1
  17. package/dist/components/MultiSeriesDots.d.ts +4 -1
  18. package/dist/components/MultiSeriesDots.d.ts.map +1 -1
  19. package/dist/components/ReferenceLineGroupOverlay.d.ts +27 -0
  20. package/dist/components/ReferenceLineGroupOverlay.d.ts.map +1 -0
  21. package/dist/components/ReferenceLineOverlay.d.ts +25 -2
  22. package/dist/components/ReferenceLineOverlay.d.ts.map +1 -1
  23. package/dist/components/XAxisOverlay.d.ts +7 -1
  24. package/dist/components/XAxisOverlay.d.ts.map +1 -1
  25. package/dist/components/YAxisOverlay.d.ts +12 -1
  26. package/dist/components/YAxisOverlay.d.ts.map +1 -1
  27. package/dist/constants.d.ts +7 -0
  28. package/dist/constants.d.ts.map +1 -1
  29. package/dist/core/liveChartEngineTick.d.ts +29 -0
  30. package/dist/core/liveChartEngineTick.d.ts.map +1 -1
  31. package/dist/core/liveChartSeriesEngineTick.d.ts +18 -0
  32. package/dist/core/liveChartSeriesEngineTick.d.ts.map +1 -1
  33. package/dist/core/resolveConfig.d.ts +56 -2
  34. package/dist/core/resolveConfig.d.ts.map +1 -1
  35. package/dist/core/useLiveChartEngine.d.ts +58 -7
  36. package/dist/core/useLiveChartEngine.d.ts.map +1 -1
  37. package/dist/core/useLiveChartSeriesEngine.d.ts +8 -2
  38. package/dist/core/useLiveChartSeriesEngine.d.ts.map +1 -1
  39. package/dist/draw/grid.d.ts.map +1 -1
  40. package/dist/draw/markerAtlas.d.ts +20 -2
  41. package/dist/draw/markerAtlas.d.ts.map +1 -1
  42. package/dist/draw/volume.d.ts +25 -0
  43. package/dist/draw/volume.d.ts.map +1 -0
  44. package/dist/hooks/crosshairShared.d.ts +12 -6
  45. package/dist/hooks/crosshairShared.d.ts.map +1 -1
  46. package/dist/hooks/overlayScale.d.ts +22 -0
  47. package/dist/hooks/overlayScale.d.ts.map +1 -0
  48. package/dist/hooks/resolveChartLayout.d.ts +9 -0
  49. package/dist/hooks/resolveChartLayout.d.ts.map +1 -1
  50. package/dist/hooks/useBadge.d.ts +22 -1
  51. package/dist/hooks/useBadge.d.ts.map +1 -1
  52. package/dist/hooks/useCandlePaths.d.ts +6 -0
  53. package/dist/hooks/useCandlePaths.d.ts.map +1 -1
  54. package/dist/hooks/useChartOverlayContext.d.ts +45 -0
  55. package/dist/hooks/useChartOverlayContext.d.ts.map +1 -0
  56. package/dist/hooks/useChartPaths.d.ts +8 -1
  57. package/dist/hooks/useChartPaths.d.ts.map +1 -1
  58. package/dist/hooks/useCrosshair.d.ts +9 -2
  59. package/dist/hooks/useCrosshair.d.ts.map +1 -1
  60. package/dist/hooks/useLiveDot.d.ts +6 -1
  61. package/dist/hooks/useLiveDot.d.ts.map +1 -1
  62. package/dist/hooks/useMarkers.d.ts +9 -4
  63. package/dist/hooks/useMarkers.d.ts.map +1 -1
  64. package/dist/hooks/usePanScroll.d.ts +82 -0
  65. package/dist/hooks/usePanScroll.d.ts.map +1 -0
  66. package/dist/hooks/usePinchZoom.d.ts +74 -0
  67. package/dist/hooks/usePinchZoom.d.ts.map +1 -0
  68. package/dist/hooks/useReferenceDrag.d.ts +24 -0
  69. package/dist/hooks/useReferenceDrag.d.ts.map +1 -0
  70. package/dist/hooks/useReferenceLine.d.ts +23 -4
  71. package/dist/hooks/useReferenceLine.d.ts.map +1 -1
  72. package/dist/hooks/useReferenceLinePress.d.ts +5 -1
  73. package/dist/hooks/useReferenceLinePress.d.ts.map +1 -1
  74. package/dist/hooks/useVisibleRange.d.ts +39 -0
  75. package/dist/hooks/useVisibleRange.d.ts.map +1 -0
  76. package/dist/index.d.ts +2 -1
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/math/markerCluster.d.ts +47 -0
  79. package/dist/math/markerCluster.d.ts.map +1 -0
  80. package/dist/math/markers.d.ts +10 -0
  81. package/dist/math/markers.d.ts.map +1 -1
  82. package/dist/math/referenceDrag.d.ts +24 -0
  83. package/dist/math/referenceDrag.d.ts.map +1 -0
  84. package/dist/math/referenceGroup.d.ts +31 -0
  85. package/dist/math/referenceGroup.d.ts.map +1 -0
  86. package/dist/math/referenceLines.d.ts +33 -7
  87. package/dist/math/referenceLines.d.ts.map +1 -1
  88. package/dist/types.d.ts +505 -21
  89. package/dist/types.d.ts.map +1 -1
  90. package/package.json +1 -1
  91. package/src/components/BadgeOverlay.tsx +26 -1
  92. package/src/components/ChartOverlayLayer.tsx +32 -0
  93. package/src/components/CustomMarkerOverlay.tsx +150 -57
  94. package/src/components/CustomReferenceLineOverlay.tsx +250 -0
  95. package/src/components/CustomTooltipOverlay.tsx +27 -7
  96. package/src/components/DotOverlay.tsx +9 -0
  97. package/src/components/LiveChart.tsx +549 -32
  98. package/src/components/LiveChartSeries.tsx +110 -5
  99. package/src/components/MarkerOverlay.tsx +92 -6
  100. package/src/components/MultiSeriesDots.tsx +12 -3
  101. package/src/components/ReferenceLineGroupOverlay.tsx +207 -0
  102. package/src/components/ReferenceLineOverlay.tsx +105 -32
  103. package/src/components/XAxisOverlay.tsx +9 -2
  104. package/src/components/YAxisOverlay.tsx +48 -26
  105. package/src/constants.ts +10 -0
  106. package/src/core/liveChartEngineTick.ts +81 -8
  107. package/src/core/liveChartSeriesEngineTick.ts +50 -9
  108. package/src/core/resolveConfig.ts +122 -1
  109. package/src/core/useLiveChartEngine.ts +103 -10
  110. package/src/core/useLiveChartSeriesEngine.ts +26 -3
  111. package/src/draw/grid.ts +13 -1
  112. package/src/draw/markerAtlas.ts +117 -3
  113. package/src/draw/volume.ts +190 -0
  114. package/src/hooks/crosshairShared.ts +37 -9
  115. package/src/hooks/overlayScale.ts +59 -0
  116. package/src/hooks/resolveChartLayout.ts +33 -0
  117. package/src/hooks/useBadge.ts +89 -21
  118. package/src/hooks/useCandlePaths.ts +104 -7
  119. package/src/hooks/useChartOverlayContext.ts +93 -0
  120. package/src/hooks/useChartPaths.ts +14 -1
  121. package/src/hooks/useCrosshair.ts +29 -2
  122. package/src/hooks/useLiveDot.ts +16 -5
  123. package/src/hooks/useMarkers.ts +39 -11
  124. package/src/hooks/usePanScroll.ts +253 -0
  125. package/src/hooks/usePinchZoom.ts +189 -0
  126. package/src/hooks/useReferenceDrag.ts +254 -0
  127. package/src/hooks/useReferenceLine.ts +56 -9
  128. package/src/hooks/useReferenceLinePress.ts +16 -2
  129. package/src/hooks/useVisibleRange.ts +119 -0
  130. package/src/index.ts +17 -1
  131. package/src/math/markerCluster.ts +214 -0
  132. package/src/math/markers.ts +35 -3
  133. package/src/math/referenceDrag.ts +66 -0
  134. package/src/math/referenceGroup.ts +65 -0
  135. package/src/math/referenceLines.ts +76 -19
  136. package/src/types.ts +525 -21
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Pure, worklet-safe helpers for dragging a Form-A reference line along the
3
+ * Y-axis. Kept free of hooks / SharedValues so they unit-test without Reanimated
4
+ * (the gesture wiring lives in {@link useReferenceDrag}).
5
+ */
6
+ /** Clamp a value to an optional `[min, max]` bound (order-independent). No-op when
7
+ * `bounds` is omitted. */
8
+ export declare function clampToBounds(value: number, bounds?: [number, number]): number;
9
+ /**
10
+ * Index of the draggable line whose handle-Y is nearest the touch `y`, within
11
+ * `slop` px — or `-1` when none is in reach. `handleYs` is index-aligned with the
12
+ * chart's `referenceLines`; entries `< 0` (not draggable / off-screen / not laid
13
+ * out) are skipped. Ties favor the later (topmost-drawn) line.
14
+ */
15
+ export declare function nearestDraggableIndex(handleYs: number[], y: number, slop: number): number;
16
+ /**
17
+ * Whether a line's value sits **outside** its watched interval — the trigger for
18
+ * `onDragOut` / `onDragIn` (edge-detected by the caller). When `bounds` is set the
19
+ * watched interval is `bounds` (at-or-past a bound counts as out, since the drag
20
+ * clamps there); otherwise it's the visible `[min, max]` Y-range (out = scrolled /
21
+ * dragged off-screen).
22
+ */
23
+ export declare function referenceValueOut(value: number, min: number, max: number, bounds?: [number, number]): boolean;
24
+ //# sourceMappingURL=referenceDrag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"referenceDrag.d.ts","sourceRoot":"","sources":["../../src/math/referenceDrag.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;2BAC2B;AAC3B,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GACxB,MAAM,CAMR;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAAE,EAClB,CAAC,EAAE,MAAM,EACT,IAAI,EAAE,MAAM,GACX,MAAM,CAcR;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GACxB,OAAO,CAQT"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Pure, worklet-safe clustering for reference-line grouping — collapse Form-A
3
+ * lines whose value-Y positions sit near each other into one count handle. Free of
4
+ * hooks / SharedValues so it unit-tests without Reanimated; the per-frame call +
5
+ * rendering live in the controller / `ReferenceLineGroupOverlay`.
6
+ */
7
+ /** One collapsed cluster of nearby reference lines. */
8
+ export interface ReferenceGroup {
9
+ /** Centroid Y (canvas px) of the cluster — where the count handle is drawn. */
10
+ cy: number;
11
+ /** Number of lines collapsed into the cluster (≥ 2). */
12
+ count: number;
13
+ }
14
+ /** Result of clustering a frame's reference-line Y positions. */
15
+ export interface ReferenceGrouping {
16
+ /**
17
+ * Index-aligned with the input Ys: `true` when this line's individual tag is
18
+ * collapsed into a cluster (a multi-line group) and should be suppressed.
19
+ */
20
+ hidden: boolean[];
21
+ /** One entry per multi-line cluster (singletons render normally, never here). */
22
+ groups: ReferenceGroup[];
23
+ }
24
+ /**
25
+ * Single-linkage cluster of reference-line handle Ys: lines whose sorted Y gaps are
26
+ * all `<= radius` chain into one group. Entries `< 0` (not a Form-A line / off the
27
+ * canvas) are ignored. Returns which lines are collapsed (`hidden`) plus a centroid
28
+ * + count per multi-line cluster. A non-positive `radius` disables grouping.
29
+ */
30
+ export declare function groupReferenceLines(ys: number[], radius: number): ReferenceGrouping;
31
+ //# sourceMappingURL=referenceGroup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"referenceGroup.d.ts","sourceRoot":"","sources":["../../src/math/referenceGroup.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,uDAAuD;AACvD,MAAM,WAAW,cAAc;IAC7B,+EAA+E;IAC/E,EAAE,EAAE,MAAM,CAAC;IACX,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,iEAAiE;AACjE,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,iFAAiF;IACjF,MAAM,EAAE,cAAc,EAAE,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,MAAM,EAAE,EACZ,MAAM,EAAE,MAAM,GACb,iBAAiB,CA6BnB"}
@@ -1,4 +1,4 @@
1
- import type { ReferenceLine } from "../types";
1
+ import type { FontWeight, ReferenceLine, ReferenceLineBadgeConfig } from "../types";
2
2
  /** Which of the three reference-line forms a `ReferenceLine` resolves to. */
3
3
  export type ReferenceLineForm = "line" | "value-band" | "time-band" | "none";
4
4
  /**
@@ -12,23 +12,49 @@ export declare function referenceLineForm(rl: ReferenceLine): ReferenceLineForm;
12
12
  * time bands (Form C) which constrain time, not value.
13
13
  */
14
14
  export declare function collectReferenceValues(lines: ReferenceLine[]): number[];
15
- /** Fully-resolved badge presentation for a Form-A reference line. */
16
- export interface ResolvedReferenceBadge {
17
- position: "left" | "right";
15
+ /**
16
+ * Fully-resolved badge **style/shape** + anchor — the resolved counterpart of
17
+ * {@link BadgeStyleConfig} (`position` / `icon` / `showText` plus the style knobs).
18
+ * Shared by the reference-line badge ({@link ResolvedReferenceBadge}) and the
19
+ * grouping count pill ({@link ResolvedReferenceGroupBadge}). Unset colors stay
20
+ * `undefined` so the overlay applies the appropriate theme default at render time.
21
+ */
22
+ export interface ResolvedReferenceBadgeStyle {
23
+ position: "left" | "center" | "right";
18
24
  /** Leading glyph, or "" for none. */
19
25
  icon: string;
20
- /** Whether the text label is shown. */
26
+ /** Whether the text label is shown (false → icon-only). */
21
27
  showText: boolean;
22
- /** undefined → theme tooltipBg at render time. */
23
28
  background: string | undefined;
24
- /** undefined → the line color at render time. */
25
29
  borderColor: string | undefined;
30
+ /** Border stroke width in px. Default `1`. */
31
+ borderWidth: number;
26
32
  radius: number;
33
+ textColor: string | undefined;
34
+ /** Per-badge font knobs; undefined → the chart font. */
35
+ fontSize: number | undefined;
36
+ fontFamily: string | undefined;
37
+ fontWeight: FontWeight | undefined;
38
+ /** Nudge the whole badge from its anchor, in px. Default `0`. */
39
+ offsetX: number;
40
+ offsetY: number;
41
+ }
42
+ /** Fully-resolved presentation for a Form-A reference-line badge — the shared
43
+ * style/shape plus the in-range / legacy-text flags. */
44
+ export interface ResolvedReferenceBadge extends ResolvedReferenceBadgeStyle {
27
45
  /** Show the pill at the value when in range (`badge`) vs only off-screen (legacy `offAxisBadge`). */
28
46
  inRange: boolean;
29
47
  /** Legacy `"word: value"` text format (off-axis badge) vs the `label`/value format. */
30
48
  legacyText: boolean;
31
49
  }
50
+ /** Fully-resolved styling for the grouping **count pill** — exactly the shared
51
+ * badge style/shape (no in-range / legacy concepts). */
52
+ export type ResolvedReferenceGroupBadge = ResolvedReferenceBadgeStyle;
53
+ /**
54
+ * Resolves the grouping count-pill styling from a {@link ReferenceLineBadgeConfig}
55
+ * (the same shape a per-line badge uses). Pure — driven only by the config.
56
+ */
57
+ export declare function resolveReferenceGroupBadge(badge?: ReferenceLineBadgeConfig): ResolvedReferenceGroupBadge;
32
58
  /**
33
59
  * Resolves a Form-A reference line's badge presentation from the new `badge`
34
60
  * config or the legacy `offAxisBadge` flag (the `badge` config wins). Returns
@@ -1 +1 @@
1
- {"version":3,"file":"referenceLines.d.ts","sourceRoot":"","sources":["../../src/math/referenceLines.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,6EAA6E;AAC7E,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,YAAY,GAAG,WAAW,GAAG,MAAM,CAAC;AAE7E;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,aAAa,GAAG,iBAAiB,CAQtE;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,MAAM,EAAE,CAgBvE;AAED,qEAAqE;AACrE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,QAAQ,EAAE,OAAO,CAAC;IAClB,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