@coinbase/cds-web-visualization 3.4.0-beta.4 → 3.4.0-beta.6

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 (167) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dts/chart/CartesianChart.d.ts +38 -2
  3. package/dts/chart/CartesianChart.d.ts.map +1 -1
  4. package/dts/chart/Path.d.ts +27 -7
  5. package/dts/chart/Path.d.ts.map +1 -1
  6. package/dts/chart/PeriodSelector.d.ts +0 -4
  7. package/dts/chart/PeriodSelector.d.ts.map +1 -1
  8. package/dts/chart/area/Area.d.ts +54 -24
  9. package/dts/chart/area/Area.d.ts.map +1 -1
  10. package/dts/chart/area/AreaChart.d.ts +33 -6
  11. package/dts/chart/area/AreaChart.d.ts.map +1 -1
  12. package/dts/chart/area/DottedArea.d.ts +21 -44
  13. package/dts/chart/area/DottedArea.d.ts.map +1 -1
  14. package/dts/chart/area/GradientArea.d.ts +21 -12
  15. package/dts/chart/area/GradientArea.d.ts.map +1 -1
  16. package/dts/chart/area/SolidArea.d.ts +16 -1
  17. package/dts/chart/area/SolidArea.d.ts.map +1 -1
  18. package/dts/chart/axis/Axis.d.ts +89 -43
  19. package/dts/chart/axis/Axis.d.ts.map +1 -1
  20. package/dts/chart/axis/DefaultAxisTickLabel.d.ts +8 -0
  21. package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +1 -0
  22. package/dts/chart/axis/XAxis.d.ts +1 -1
  23. package/dts/chart/axis/XAxis.d.ts.map +1 -1
  24. package/dts/chart/axis/YAxis.d.ts +1 -1
  25. package/dts/chart/axis/YAxis.d.ts.map +1 -1
  26. package/dts/chart/axis/index.d.ts +1 -0
  27. package/dts/chart/axis/index.d.ts.map +1 -1
  28. package/dts/chart/bar/Bar.d.ts +16 -13
  29. package/dts/chart/bar/Bar.d.ts.map +1 -1
  30. package/dts/chart/bar/BarChart.d.ts +17 -8
  31. package/dts/chart/bar/BarChart.d.ts.map +1 -1
  32. package/dts/chart/bar/BarPlot.d.ts +2 -1
  33. package/dts/chart/bar/BarPlot.d.ts.map +1 -1
  34. package/dts/chart/bar/BarStack.d.ts +40 -48
  35. package/dts/chart/bar/BarStack.d.ts.map +1 -1
  36. package/dts/chart/bar/BarStackGroup.d.ts +1 -0
  37. package/dts/chart/bar/BarStackGroup.d.ts.map +1 -1
  38. package/dts/chart/bar/DefaultBar.d.ts.map +1 -1
  39. package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -1
  40. package/dts/chart/gradient/Gradient.d.ts +35 -0
  41. package/dts/chart/gradient/Gradient.d.ts.map +1 -0
  42. package/dts/chart/gradient/index.d.ts +2 -0
  43. package/dts/chart/gradient/index.d.ts.map +1 -0
  44. package/dts/chart/index.d.ts +2 -1
  45. package/dts/chart/index.d.ts.map +1 -1
  46. package/dts/chart/line/DefaultReferenceLineLabel.d.ts +9 -0
  47. package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +1 -0
  48. package/dts/chart/line/DottedLine.d.ts +15 -3
  49. package/dts/chart/line/DottedLine.d.ts.map +1 -1
  50. package/dts/chart/line/Line.d.ts +70 -28
  51. package/dts/chart/line/Line.d.ts.map +1 -1
  52. package/dts/chart/line/LineChart.d.ts +26 -8
  53. package/dts/chart/line/LineChart.d.ts.map +1 -1
  54. package/dts/chart/line/ReferenceLine.d.ts +85 -44
  55. package/dts/chart/line/ReferenceLine.d.ts.map +1 -1
  56. package/dts/chart/line/SolidLine.d.ts +14 -3
  57. package/dts/chart/line/SolidLine.d.ts.map +1 -1
  58. package/dts/chart/line/index.d.ts +1 -1
  59. package/dts/chart/line/index.d.ts.map +1 -1
  60. package/dts/chart/point/DefaultPointLabel.d.ts +10 -0
  61. package/dts/chart/point/DefaultPointLabel.d.ts.map +1 -0
  62. package/dts/chart/point/Point.d.ts +201 -0
  63. package/dts/chart/point/Point.d.ts.map +1 -0
  64. package/dts/chart/point/index.d.ts +3 -0
  65. package/dts/chart/point/index.d.ts.map +1 -0
  66. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +24 -0
  67. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -0
  68. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +12 -0
  69. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +1 -0
  70. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +10 -0
  71. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -0
  72. package/dts/chart/scrubber/Scrubber.d.ts +203 -64
  73. package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
  74. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +70 -0
  75. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -0
  76. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +32 -0
  77. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -0
  78. package/dts/chart/scrubber/index.d.ts +3 -0
  79. package/dts/chart/scrubber/index.d.ts.map +1 -1
  80. package/dts/chart/text/ChartText.d.ts +46 -43
  81. package/dts/chart/text/ChartText.d.ts.map +1 -1
  82. package/dts/chart/text/{SmartChartTextGroup.d.ts → ChartTextGroup.d.ts} +9 -3
  83. package/dts/chart/text/ChartTextGroup.d.ts.map +1 -0
  84. package/dts/chart/text/index.d.ts +1 -1
  85. package/dts/chart/text/index.d.ts.map +1 -1
  86. package/dts/chart/utils/chart.d.ts +27 -7
  87. package/dts/chart/utils/chart.d.ts.map +1 -1
  88. package/dts/chart/utils/context.d.ts +6 -0
  89. package/dts/chart/utils/context.d.ts.map +1 -1
  90. package/dts/chart/utils/gradient.d.ts +104 -0
  91. package/dts/chart/utils/gradient.d.ts.map +1 -0
  92. package/dts/chart/utils/index.d.ts +4 -0
  93. package/dts/chart/utils/index.d.ts.map +1 -1
  94. package/dts/chart/utils/interpolate.d.ts +112 -0
  95. package/dts/chart/utils/interpolate.d.ts.map +1 -0
  96. package/dts/chart/utils/path.d.ts +24 -1
  97. package/dts/chart/utils/path.d.ts.map +1 -1
  98. package/dts/chart/utils/point.d.ts +29 -0
  99. package/dts/chart/utils/point.d.ts.map +1 -1
  100. package/dts/chart/utils/scrubber.d.ts +39 -0
  101. package/dts/chart/utils/scrubber.d.ts.map +1 -0
  102. package/dts/chart/utils/transition.d.ts +65 -0
  103. package/dts/chart/utils/transition.d.ts.map +1 -0
  104. package/esm/chart/CartesianChart.js +140 -85
  105. package/esm/chart/Path.js +51 -46
  106. package/esm/chart/PeriodSelector.js +4 -18
  107. package/esm/chart/area/Area.js +24 -34
  108. package/esm/chart/area/AreaChart.js +24 -15
  109. package/esm/chart/area/DottedArea.js +35 -89
  110. package/esm/chart/area/GradientArea.js +34 -80
  111. package/esm/chart/area/SolidArea.js +29 -11
  112. package/esm/chart/axis/Axis.js +4 -25
  113. package/esm/chart/axis/DefaultAxisTickLabel.js +15 -0
  114. package/esm/chart/axis/XAxis.js +53 -36
  115. package/esm/chart/axis/YAxis.js +55 -32
  116. package/esm/chart/axis/index.js +1 -0
  117. package/esm/chart/bar/Bar.js +3 -1
  118. package/esm/chart/bar/BarChart.js +15 -32
  119. package/esm/chart/bar/BarPlot.js +3 -2
  120. package/esm/chart/bar/BarStack.js +65 -23
  121. package/esm/chart/bar/BarStackGroup.js +7 -17
  122. package/esm/chart/bar/DefaultBar.js +4 -7
  123. package/esm/chart/bar/DefaultBarStack.js +5 -7
  124. package/esm/chart/gradient/Gradient.js +104 -0
  125. package/esm/chart/gradient/index.js +1 -0
  126. package/esm/chart/index.js +2 -1
  127. package/esm/chart/line/DefaultReferenceLineLabel.js +81 -0
  128. package/esm/chart/line/DottedLine.js +38 -17
  129. package/esm/chart/line/Line.js +96 -70
  130. package/esm/chart/line/LineChart.js +18 -6
  131. package/esm/chart/line/ReferenceLine.js +34 -41
  132. package/esm/chart/line/SolidLine.js +36 -15
  133. package/esm/chart/line/index.js +1 -1
  134. package/esm/chart/{line/GradientLine.js → point/DefaultPointLabel.js} +31 -45
  135. package/esm/chart/point/Point.css +2 -0
  136. package/esm/chart/{Point.js → point/Point.js} +66 -57
  137. package/esm/chart/point/index.js +2 -0
  138. package/esm/chart/scrubber/DefaultScrubberBeacon.js +155 -0
  139. package/esm/chart/scrubber/{ScrubberBeaconLabel.js → DefaultScrubberBeaconLabel.js} +23 -10
  140. package/esm/chart/scrubber/DefaultScrubberLabel.js +30 -0
  141. package/esm/chart/scrubber/Scrubber.js +98 -392
  142. package/esm/chart/scrubber/ScrubberBeaconGroup.js +166 -0
  143. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +186 -0
  144. package/esm/chart/scrubber/index.js +3 -1
  145. package/esm/chart/text/ChartText.js +13 -19
  146. package/esm/chart/text/{SmartChartTextGroup.js → ChartTextGroup.js} +4 -3
  147. package/esm/chart/text/index.js +1 -1
  148. package/esm/chart/utils/chart.js +29 -3
  149. package/esm/chart/utils/gradient.js +257 -0
  150. package/esm/chart/utils/index.js +4 -0
  151. package/esm/chart/utils/interpolate.js +644 -0
  152. package/esm/chart/utils/path.js +32 -9
  153. package/esm/chart/utils/point.js +69 -0
  154. package/esm/chart/utils/scrubber.js +132 -0
  155. package/esm/chart/utils/transition.js +111 -0
  156. package/package.json +9 -9
  157. package/dts/chart/Point.d.ts +0 -153
  158. package/dts/chart/Point.d.ts.map +0 -1
  159. package/dts/chart/line/GradientLine.d.ts +0 -42
  160. package/dts/chart/line/GradientLine.d.ts.map +0 -1
  161. package/dts/chart/scrubber/ScrubberBeacon.d.ts +0 -93
  162. package/dts/chart/scrubber/ScrubberBeacon.d.ts.map +0 -1
  163. package/dts/chart/scrubber/ScrubberBeaconLabel.d.ts +0 -7
  164. package/dts/chart/scrubber/ScrubberBeaconLabel.d.ts.map +0 -1
  165. package/dts/chart/text/SmartChartTextGroup.d.ts.map +0 -1
  166. package/esm/chart/Point.css +0 -2
  167. package/esm/chart/scrubber/ScrubberBeacon.js +0 -195
@@ -0,0 +1,70 @@
1
+ import type { SharedProps } from '@coinbase/cds-common/types';
2
+ import type { ScrubberBeaconComponent, ScrubberBeaconProps } from './Scrubber';
3
+ export type ScrubberBeaconGroupRef = {
4
+ /**
5
+ * Triggers a pulse animation on all beacons.
6
+ */
7
+ pulse: () => void;
8
+ };
9
+ export type ScrubberBeaconGroupBaseProps = SharedProps & {
10
+ /**
11
+ * Array of series IDs to render beacons for.
12
+ */
13
+ seriesIds: string[];
14
+ /**
15
+ * Pulse the beacons while at rest.
16
+ */
17
+ idlePulse?: boolean;
18
+ };
19
+ export type ScrubberBeaconGroupProps = ScrubberBeaconGroupBaseProps & {
20
+ /**
21
+ * Transition configuration for beacon animations.
22
+ */
23
+ transitions?: ScrubberBeaconProps['transitions'];
24
+ /**
25
+ * Custom component for the scrubber beacon.
26
+ * @default DefaultScrubberBeacon
27
+ */
28
+ BeaconComponent?: ScrubberBeaconComponent;
29
+ /**
30
+ * Custom className for beacon styling.
31
+ */
32
+ className?: string;
33
+ /**
34
+ * Custom inline styles for beacons.
35
+ */
36
+ style?: React.CSSProperties;
37
+ };
38
+ export declare const ScrubberBeaconGroup: import('react').MemoExoticComponent<
39
+ import('react').ForwardRefExoticComponent<
40
+ SharedProps & {
41
+ /**
42
+ * Array of series IDs to render beacons for.
43
+ */
44
+ seriesIds: string[];
45
+ /**
46
+ * Pulse the beacons while at rest.
47
+ */
48
+ idlePulse?: boolean;
49
+ } & {
50
+ /**
51
+ * Transition configuration for beacon animations.
52
+ */
53
+ transitions?: ScrubberBeaconProps['transitions'];
54
+ /**
55
+ * Custom component for the scrubber beacon.
56
+ * @default DefaultScrubberBeacon
57
+ */
58
+ BeaconComponent?: ScrubberBeaconComponent;
59
+ /**
60
+ * Custom className for beacon styling.
61
+ */
62
+ className?: string;
63
+ /**
64
+ * Custom inline styles for beacons.
65
+ */
66
+ style?: React.CSSProperties;
67
+ } & import('react').RefAttributes<ScrubberBeaconGroupRef>
68
+ >
69
+ >;
70
+ //# sourceMappingURL=ScrubberBeaconGroup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrubberBeaconGroup.d.ts","sourceRoot":"","sources":["../../../src/chart/scrubber/ScrubberBeaconGroup.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAW9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,mBAAmB,EAAqB,MAAM,YAAY,CAAC;AAsGlG,MAAM,MAAM,sBAAsB,GAAG;IACnC;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,WAAW,GAAG;IACvD;;OAEG;IACH,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,4BAA4B,GAAG;IACpE;;OAEG;IACH,WAAW,CAAC,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;IACjD;;;OAGG;IACH,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAC1C;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,mBAAmB;IA9B9B;;OAEG;eACQ,MAAM,EAAE;IACnB;;OAEG;gBACS,OAAO;;IAInB;;OAEG;kBACW,mBAAmB,CAAC,aAAa,CAAC;IAChD;;;OAGG;sBACe,uBAAuB;IACzC;;OAEG;gBACS,MAAM;IAClB;;OAEG;YACK,KAAK,CAAC,aAAa;2DAsF5B,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { SharedProps } from '@coinbase/cds-common/types';
2
+ import type { ChartTextProps } from '../text';
3
+ import type { ScrubberBeaconLabelComponent, ScrubberBeaconLabelProps } from './Scrubber';
4
+ export type ScrubberBeaconLabelGroupBaseProps = SharedProps & {
5
+ /**
6
+ * Labels to be displayed.
7
+ */
8
+ labels: Array<Pick<ScrubberBeaconLabelProps, 'seriesId' | 'label' | 'color'>>;
9
+ /**
10
+ * Minimum gap between labels in pixels.
11
+ * @default 4
12
+ */
13
+ labelMinGap?: number;
14
+ /**
15
+ * Horizontal offset of labels from the scrubber line in pixels.
16
+ * @default 16
17
+ */
18
+ labelHorizontalOffset?: number;
19
+ /**
20
+ * Font style for the beacon labels.
21
+ */
22
+ labelFont?: ChartTextProps['font'];
23
+ };
24
+ export type ScrubberBeaconLabelGroupProps = ScrubberBeaconLabelGroupBaseProps & {
25
+ /**
26
+ * Custom component to render as a scrubber beacon label.
27
+ * @default DefaultScrubberBeaconLabel
28
+ */
29
+ BeaconLabelComponent?: ScrubberBeaconLabelComponent;
30
+ };
31
+ export declare const ScrubberBeaconLabelGroup: import('react').NamedExoticComponent<ScrubberBeaconLabelGroupProps>;
32
+ //# sourceMappingURL=ScrubberBeaconLabelGroup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrubberBeaconLabelGroup.d.ts","sourceRoot":"","sources":["../../../src/chart/scrubber/ScrubberBeaconLabelGroup.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAW9C,OAAO,KAAK,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAsDzF,MAAM,MAAM,iCAAiC,GAAG,WAAW,GAAG;IAC5D;;OAEG;IACH,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,wBAAwB,EAAE,UAAU,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAC9E;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B;;OAEG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,iCAAiC,GAAG;IAC9E;;;OAGG;IACH,oBAAoB,CAAC,EAAE,4BAA4B,CAAC;CACrD,CAAC;AAEF,eAAO,MAAM,wBAAwB,qEA0KpC,CAAC"}
@@ -1,2 +1,5 @@
1
+ export * from './DefaultScrubberBeacon';
2
+ export * from './DefaultScrubberBeaconLabel';
3
+ export * from './DefaultScrubberLabel';
1
4
  export * from './Scrubber';
2
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chart/scrubber/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chart/scrubber/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { ElevationLevels, Rect, SharedProps } from '@coinbase/cds-common/types';
2
+ import type { Rect, SharedProps } from '@coinbase/cds-common/types';
3
3
  import { type BoxProps } from '@coinbase/cds-web/layout';
4
4
  import { type ChartInset } from '../utils';
5
5
  type ValidChartTextChildElements =
@@ -23,18 +23,50 @@ export type TextHorizontalAlignment = 'left' | 'center' | 'right';
23
23
  * Vertical alignment options for chart text.
24
24
  */
25
25
  export type TextVerticalAlignment = 'top' | 'middle' | 'bottom';
26
- export type ChartTextProps = SharedProps &
26
+ export type ChartTextBaseProps = SharedProps & {
27
+ /**
28
+ * The text color.
29
+ * @default 'var(--color-fgMuted)'
30
+ */
31
+ color?: string;
32
+ /**
33
+ * The background color of the text's background rectangle.
34
+ * @default 'var(--color-bg)' if elevated, otherwise 'transparent'
35
+ */
36
+ background?: string;
37
+ /**
38
+ * Whether the text should have an elevated appearance with a shadow.
39
+ * @default false
40
+ */
41
+ elevated?: boolean;
42
+ /**
43
+ * When true, disables automatic repositioning to fit within bounds.
44
+ */
45
+ disableRepositioning?: boolean;
46
+ /**
47
+ * Optional bounds rectangle to constrain the text within. If provided, text will be positioned
48
+ * to stay within these bounds. Defaults to the full chart bounds when not provided.
49
+ */
50
+ bounds?: Rect;
51
+ /**
52
+ * Callback fired when text dimensions change.
53
+ * Used for collision detection and smart positioning.
54
+ * Returns the adjusted position and dimensions.
55
+ */
56
+ onDimensionsChange?: (rect: Rect) => void;
57
+ /**
58
+ * Inset around the text content for the background rect.
59
+ * Only affects the background, text position remains unchanged.
60
+ */
61
+ inset?: number | ChartInset;
62
+ /**
63
+ * Border radius for the background rectangle.
64
+ * @default 4
65
+ */
66
+ borderRadius?: number;
67
+ };
68
+ export type ChartTextProps = ChartTextBaseProps &
27
69
  Pick<BoxProps<'g'>, 'font' | 'fontFamily' | 'fontSize' | 'fontWeight' | 'opacity'> & {
28
- /**
29
- * The text color.
30
- * @default 'var(--color-fgMuted)'
31
- */
32
- color?: string;
33
- /**
34
- * The background color of the text's background rectangle.
35
- * @default 'transparent' if not elevated, 'var(--color-bg)' if elevated
36
- */
37
- background?: string;
38
70
  /**
39
71
  * The desired x offset in SVG pixels.
40
72
  */
@@ -43,10 +75,6 @@ export type ChartTextProps = SharedProps &
43
75
  * The desired y offset in SVG pixels.
44
76
  */
45
77
  dy?: number;
46
- /**
47
- * The elevation for the background.
48
- */
49
- elevation?: ElevationLevels;
50
78
  /**
51
79
  * The text content to display.
52
80
  */
@@ -62,35 +90,15 @@ export type ChartTextProps = SharedProps &
62
90
  */
63
91
  y: number;
64
92
  /**
65
- * Horizontal alignment of the text.
93
+ * Horizontal alignment of the component.
66
94
  * @default 'center'
67
95
  */
68
96
  horizontalAlignment?: TextHorizontalAlignment;
69
97
  /**
70
- * Vertical alignment of the text.
98
+ * Vertical alignment of the component.
71
99
  * @default 'middle'
72
100
  */
73
101
  verticalAlignment?: TextVerticalAlignment;
74
- /**
75
- * When true, disables automatic repositioning to fit within bounds.
76
- */
77
- disableRepositioning?: boolean;
78
- /**
79
- * Optional bounds rectangle to constrain the text within. If provided, text will be positioned
80
- * to stay within these bounds. Defaults to the full chart bounds when not provided.
81
- */
82
- bounds?: Rect;
83
- /**
84
- * Callback fired when text dimensions change.
85
- * Used for collision detection and smart positioning.
86
- * Returns the adjusted position and dimensions.
87
- */
88
- onDimensionsChange?: (rect: Rect) => void;
89
- /**
90
- * Inset around the text content for the background rect.
91
- * Only affects the background, text position remains unchanged.
92
- */
93
- inset?: number | ChartInset;
94
102
  style?: React.CSSProperties;
95
103
  styles?: {
96
104
  root?: React.CSSProperties;
@@ -103,11 +111,6 @@ export type ChartTextProps = SharedProps &
103
111
  text?: string;
104
112
  backgroundRect?: string;
105
113
  };
106
- /**
107
- * Border radius for the background rectangle.
108
- * @default 4
109
- */
110
- borderRadius?: number;
111
114
  };
112
115
  export declare const ChartText: React.NamedExoticComponent<ChartTextProps>;
113
116
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"ChartText.d.ts","sourceRoot":"","sources":["../../../src/chart/text/ChartText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqD,MAAM,OAAO,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAErF,OAAO,EAAO,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAK9D,OAAO,EAAE,KAAK,UAAU,EAAiB,MAAM,UAAU,CAAC;AAE1D,KAAK,2BAA2B,GAC5B,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC,GAC5D,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,UAAU,CAAC,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,MAAM,GACN,MAAM,GACN,IAAI,GACJ,SAAS,GACT,2BAA2B,GAC3B,2BA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C;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH,CAAC;AAkCJ,eAAO,MAAM,SAAS,4CA0MrB,CAAC"}
@@ -23,7 +23,7 @@ export type TextLabelData = {
23
23
  export type TextLabelDataWithKey = TextLabelData & {
24
24
  key: string;
25
25
  };
26
- export type SmartChartTextGroupProps = {
26
+ export type ChartTextGroupBaseProps = {
27
27
  /**
28
28
  * Array of text labels to display
29
29
  */
@@ -42,7 +42,13 @@ export type SmartChartTextGroupProps = {
42
42
  * Common props to apply to all ChartText components
43
43
  */
44
44
  chartTextProps?: Partial<ChartTextProps>;
45
+ /**
46
+ * Custom component to render each label
47
+ * @default ChartText
48
+ */
49
+ LabelComponent?: React.FC<ChartTextProps>;
45
50
  };
51
+ export type ChartTextGroupProps = ChartTextGroupBaseProps;
46
52
  /**
47
53
  * A smart text display component that prevents label overlap through collision detection.
48
54
  *
@@ -51,5 +57,5 @@ export type SmartChartTextGroupProps = {
51
57
  *
52
58
  * The component focuses solely on overlap prevention logic for better separation of concerns.
53
59
  */
54
- export declare const SmartChartTextGroup: import('react').NamedExoticComponent<SmartChartTextGroupProps>;
55
- //# sourceMappingURL=SmartChartTextGroup.d.ts.map
60
+ export declare const ChartTextGroup: import('react').NamedExoticComponent<ChartTextGroupBaseProps>;
61
+ //# sourceMappingURL=ChartTextGroup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartTextGroup.d.ts","sourceRoot":"","sources":["../../../src/chart/text/ChartTextGroup.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAa,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAErF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,KAAK,EAAE,iBAAiB,CAAC;IACzB;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACzC;;;OAGG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AAiB1D;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,+DA0M1B,CAAC"}
@@ -1,3 +1,3 @@
1
1
  export * from './ChartText';
2
- export * from './SmartChartTextGroup';
2
+ export * from './ChartTextGroup';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chart/text/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chart/text/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC"}
@@ -1,3 +1,4 @@
1
+ import type { GradientDefinition } from './gradient';
1
2
  export declare const defaultStackId = 'DEFAULT_STACK_ID';
2
3
  export type AxisBounds = {
3
4
  min: number;
@@ -11,11 +12,11 @@ export type AxisBounds = {
11
12
  export declare const isValidBounds: (bounds: Partial<AxisBounds>) => bounds is AxisBounds;
12
13
  export type Series = {
13
14
  /**
14
- * The id of the series.
15
+ * Id of the series.
15
16
  */
16
17
  id: string;
17
18
  /**
18
- * The data array for this series. Use null values to create gaps in the visualization.
19
+ * Data array for this series. Use null values to create gaps in the visualization.
19
20
  *
20
21
  * Can be either:
21
22
  * - Array of numbers: `[10, -5, 20]`
@@ -23,20 +24,28 @@ export type Series = {
23
24
  */
24
25
  data?: Array<number | null> | Array<[number, number] | null>;
25
26
  /**
26
- * The label of the series. Can be a React node or a function that receives the data index and returns a React node.
27
+ * Label of the series.
28
+ * Used for scrubber beacon labels.
27
29
  */
28
- label?: string | ((dataIndex: number) => string);
30
+ label?: string;
29
31
  /**
30
- * The color of the series.
32
+ * Color of the series.
33
+ * If gradient is provided, that will be used for chart components
34
+ * Color will still be used by scrubber beacon labels
31
35
  */
32
36
  color?: string;
33
37
  /**
34
- * The ID of the y-axis this series uses.
38
+ * Color gradient configuration.
39
+ * Takes precedence over color except for scrubber beacon labels.
40
+ */
41
+ gradient?: GradientDefinition;
42
+ /**
43
+ * Id of the y-axis this series uses.
35
44
  * Defaults to defaultAxisId if not specified.
36
45
  */
37
46
  yAxisId?: string;
38
47
  /**
39
- * The stack group this series belongs to.
48
+ * Id of the stack group this series belongs to.
40
49
  * Series with the same stackId value will be stacked together.
41
50
  * If not specified, the series will not be stacked.
42
51
  */
@@ -61,6 +70,17 @@ export declare const getChartDomain: (
61
70
  export declare const getStackedSeriesData: (
62
71
  series: Series[],
63
72
  ) => Map<string, Array<[number, number] | null>>;
73
+ /**
74
+ * Extracts line data values from series data that may contain tuples.
75
+ * For tuple data [[baseline, value]], extracts the last value.
76
+ * For numeric data [value], returns as-is.
77
+ *
78
+ * @param data - Array of numbers, tuples, or null values
79
+ * @returns Array of numbers or null values
80
+ */
81
+ export declare const getLineData: (
82
+ data?: Array<number | null> | Array<[number, number] | null>,
83
+ ) => Array<number | null>;
64
84
  /**
65
85
  * Calculates the range of a chart from series data.
66
86
  * Range represents the range of y-values from the data.
@@ -1 +1 @@
1
- {"version":3,"file":"chart.d.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eAAO,MAAM,cAAc,GACzB,QAAQ,MAAM,EAAE,EAChB,MAAM,MAAM,EACZ,MAAM,MAAM,KACX,OAAO,CAAC,UAAU,CAoBpB,CAAC;AAcF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,MAAM,EAAE,KACf,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CA0E5C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GACtB,OAAO,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,KAC3D,KAAK,CAAC,MAAM,GAAG,IAAI,CAerB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,MAAM,EAAE,EAChB,MAAM,MAAM,EACZ,MAAM,MAAM,KACX,OAAO,CAAC,UAAU,CA2EpB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,UAK/B,CAAC;AAEF;;;;;GAKG;AACH;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,EACpC,WAAW,UAAU,KACpB,UAuBF,CAAC"}
@@ -56,6 +56,12 @@ export type CartesianChartContextValue = {
56
56
  * Drawing area of the chart.
57
57
  */
58
58
  drawingArea: Rect;
59
+ /**
60
+ * Length of the data domain.
61
+ * This is equal to the length of xAxis.data or the longest series data length
62
+ * This equals the number of possible scrubber positions
63
+ */
64
+ dataLength: number;
59
65
  /**
60
66
  * Registers an axis.
61
67
  * Used by axis components to reserve space in the chart, preventing overlap with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AEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,EAAE,MAAM,UAAU,GAAG,SAAS,CAAC;IACvC;;;OAGG;IACH,QAAQ,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,UAAU,GAAG,SAAS,CAAC;IAClD;;OAEG;IACH,SAAS,EAAE,MAAM,kBAAkB,GAAG,SAAS,CAAC;IAChD;;;OAGG;IACH,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,kBAAkB,GAAG,SAAS,CAAC;IAC3D;;OAEG;IACH,WAAW,EAAE,IAAI,CAAC;IAClB;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChG;;OAEG;IACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC;;;OAGG;IACH,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,GAAG,SAAS,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,wBAAwB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CAC/D,CAAC;AAEF,eAAO,MAAM,eAAe,2DAA6D,CAAC;AAE1F,eAAO,MAAM,kBAAkB,QAAO,oBAMrC,CAAC"}
@@ -0,0 +1,104 @@
1
+ import type { AxisBounds } from './chart';
2
+ import { type ChartScaleFunction } from './scale';
3
+ /**
4
+ * Defines a color transition point in the gradient
5
+ */
6
+ export type GradientStop = {
7
+ /**
8
+ * Position in data space.
9
+ * Multiple stops at the same offset create hard color transitions.
10
+ */
11
+ offset: number;
12
+ /** Color at the stop (any valid CSS color) */
13
+ color: string;
14
+ /** Optional opacity (0-1). Defaults to 1. */
15
+ opacity?: number;
16
+ };
17
+ /**
18
+ * Defines a gradient.
19
+ */
20
+ export type GradientDefinition = {
21
+ /**
22
+ * Axis that the gradient maps to.
23
+ * @default 'y'
24
+ */
25
+ axis?: 'x' | 'y';
26
+ /**
27
+ * Gradient stops with colors and positions.
28
+ * Can be an array of stop objects or a function that receives domain bounds.
29
+ */
30
+ stops: GradientStop[] | ((domain: AxisBounds) => GradientStop[]);
31
+ };
32
+ /**
33
+ * Evaluates the color at a specific data value based on the gradient stops, ignoring opacity.
34
+ * @param stops - The gradient stops configuration
35
+ * @param dataValue - The data value to evaluate (for band scales, this is the index)
36
+ * @param scale - The scale to use for value mapping (handles log scales correctly)
37
+ * @returns The color string at this data value, or undefined if invalid
38
+ */
39
+ export declare const evaluateGradientAtValue: (
40
+ stops: GradientStop[],
41
+ dataValue: number,
42
+ scale: ChartScaleFunction,
43
+ ) => string | undefined;
44
+ /**
45
+ * Creates a gradient configuration for SVG components.
46
+ * Processes a GradientDefinition into a renderable GradientConfig.
47
+ * Supports both numeric scales (linear, log) and categorical scales (band).
48
+ *
49
+ * @param gradient - GradientDefinition configuration (required)
50
+ * @param xScale - X-axis scale (required)
51
+ * @param yScale - Y-axis scale (required)
52
+ * @returns GradientConfig or null if gradient processing fails
53
+ *
54
+ * @example
55
+ * const gradientConfig = useMemo(() => {
56
+ * if (!gradient || !xScale || !yScale) return;
57
+ * return getGradientConfig(gradient, xScale, yScale);
58
+ * }, [gradient, xScale, yScale]);
59
+ *
60
+ * if (gradientConfig) {
61
+ * return (
62
+ * <defs>
63
+ * <Gradient
64
+ * config={gradientConfig}
65
+ * direction={gradient.axis === 'x' ? 'horizontal' : 'vertical'}
66
+ * id={gradientId}
67
+ * />
68
+ * </defs>
69
+ * );
70
+ * }
71
+ */
72
+ export declare const getGradientConfig: (
73
+ gradient: GradientDefinition,
74
+ xScale: ChartScaleFunction,
75
+ yScale: ChartScaleFunction,
76
+ ) => GradientStop[] | undefined;
77
+ /**
78
+ * Determines the baseline value for the gradient area by finding the value
79
+ * within the axis bounds that is closest to the target baseline.
80
+ *
81
+ * @param axisBounds - The min and max bounds of the axis
82
+ * @param baseline - The target baseline value (defaults to 0)
83
+ * @returns The value within bounds closest to the baseline
84
+ */
85
+ export declare const getBaseline: (axisBounds: AxisBounds, baseline?: number) => number;
86
+ /**
87
+ * Generates a gradient definition for the area chart based on the axis bounds
88
+ * and styling parameters. Ensures gradient stops are in ascending order.
89
+ *
90
+ * @param axisBounds - The min and max bounds of the axis
91
+ * @param baselineValue - The baseline value for the gradient
92
+ * @param fill - The color to use for the gradient
93
+ * @param peakOpacity - Opacity at the peak of the gradient
94
+ * @param baselineOpacity - Opacity at the baseline
95
+ * @returns A gradient definition with y-axis stops in ascending order
96
+ */
97
+ export declare const createGradient: (
98
+ axisBounds: AxisBounds,
99
+ baselineValue: number,
100
+ fill: string,
101
+ peakOpacity: number,
102
+ baselineOpacity: number,
103
+ ) => GradientDefinition;
104
+ //# sourceMappingURL=gradient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gradient.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/gradient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,SAAS,CAAC;AAEtE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;OAGG;IACH,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC;IACjB;;;OAGG;IACH,KAAK,EAAE,YAAY,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,UAAU,KAAK,YAAY,EAAE,CAAC,CAAC;CAClE,CAAC;AA8DF;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAClC,OAAO,YAAY,EAAE,EACrB,WAAW,MAAM,EACjB,OAAO,kBAAkB,KACxB,MAAM,GAAG,SAiEX,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,kBAAkB,EAC5B,QAAQ,kBAAkB,EAC1B,QAAQ,kBAAkB,KACzB,YAAY,EAAE,GAAG,SAqBnB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GAAI,YAAY,UAAU,EAAE,WAAU,MAAU,KAAG,MAc1E,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,GACzB,YAAY,UAAU,EACtB,eAAe,MAAM,EACrB,MAAM,MAAM,EACZ,aAAa,MAAM,EACnB,iBAAiB,MAAM,KACtB,kBA0BF,CAAC"}
@@ -2,7 +2,11 @@ export * from './axis';
2
2
  export * from './bar';
3
3
  export * from './chart';
4
4
  export * from './context';
5
+ export * from './gradient';
6
+ export * from './interpolate';
5
7
  export * from './path';
6
8
  export * from './point';
7
9
  export * from './scale';
10
+ export * from './scrubber';
11
+ export * from './transition';
8
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,112 @@
1
+ type CommandType =
2
+ | 'M'
3
+ | 'L'
4
+ | 'H'
5
+ | 'V'
6
+ | 'C'
7
+ | 'S'
8
+ | 'Q'
9
+ | 'T'
10
+ | 'A'
11
+ | 'Z'
12
+ | 'm'
13
+ | 'l'
14
+ | 'h'
15
+ | 'v'
16
+ | 'c'
17
+ | 's'
18
+ | 'q'
19
+ | 't'
20
+ | 'a'
21
+ | 'z';
22
+ type PathCommand = {
23
+ type: CommandType;
24
+ x?: number;
25
+ y?: number;
26
+ x1?: number;
27
+ y1?: number;
28
+ x2?: number;
29
+ y2?: number;
30
+ rx?: number;
31
+ ry?: number;
32
+ xAxisRotation?: number;
33
+ largeArcFlag?: number;
34
+ sweepFlag?: number;
35
+ [key: string]: any;
36
+ };
37
+ /**
38
+ * Convert command objects to arrays of points, run de Casteljau's algorithm on it
39
+ * to split into to the desired number of segments.
40
+ *
41
+ * @param {Object} commandStart The start command object
42
+ * @param {Object} commandEnd The end command object
43
+ * @param {Number} segmentCount The number of segments to create
44
+ * @return {Object[]} An array of commands representing the segments in sequence
45
+ */
46
+ export declare function splitCurve(
47
+ commandStart: PathCommand,
48
+ commandEnd: PathCommand,
49
+ segmentCount?: number,
50
+ ): PathCommand[];
51
+ type ExcludeSegmentFn = (commandStart: PathCommand, commandEnd: PathCommand) => boolean;
52
+ /**
53
+ * Takes a path `d` string and converts it into an array of command
54
+ * objects. Drops the `Z` character.
55
+ *
56
+ * @param {String|null} d A path `d` string
57
+ */
58
+ export declare function pathCommandsFromString(d: string | null | undefined): PathCommand[];
59
+ type InterpolateOptions = {
60
+ excludeSegment?: ExcludeSegmentFn;
61
+ snapEndsToInput?: boolean;
62
+ };
63
+ /**
64
+ * Interpolate from A to B by extending A and B during interpolation to have
65
+ * the same number of points. This allows for a smooth transition when they
66
+ * have a different number of points.
67
+ *
68
+ * Ignores the `Z` command in paths unless both A and B end with it.
69
+ *
70
+ * This function works directly with arrays of command objects instead of with
71
+ * path `d` strings (see interpolatePath for working with `d` strings).
72
+ *
73
+ * @param {Object[]} aCommandsInput Array of path commands
74
+ * @param {Object[]} bCommandsInput Array of path commands
75
+ * @param {(Function|Object)} interpolateOptions
76
+ * @param {Function} interpolateOptions.excludeSegment a function that takes a start command object and
77
+ * end command object and returns true if the segment should be excluded from splitting.
78
+ * @param {Boolean} interpolateOptions.snapEndsToInput a boolean indicating whether end of input should
79
+ * be sourced from input argument or computed.
80
+ * @returns {Function} Interpolation function that maps t ([0, 1]) to an array of path commands.
81
+ */
82
+ export declare function interpolatePathCommands(
83
+ aCommandsInput: PathCommand[] | null | undefined,
84
+ bCommandsInput: PathCommand[] | null | undefined,
85
+ interpolateOptions?: ExcludeSegmentFn | InterpolateOptions,
86
+ ): (t: number) => PathCommand[];
87
+ /**
88
+ * Interpolate from A to B by extending A and B during interpolation to have
89
+ * the same number of points. This allows for a smooth transition when they
90
+ * have a different number of points.
91
+ *
92
+ * Ignores the `Z` character in paths unless both A and B end with it.
93
+ *
94
+ * @param {String} a The `d` attribute for a path
95
+ * @param {String} b The `d` attribute for a path
96
+ * @param {((command1, command2) => boolean|{
97
+ * excludeSegment?: (command1, command2) => boolean;
98
+ * snapEndsToInput?: boolean
99
+ * })} interpolateOptions The excludeSegment function or an options object
100
+ * - interpolateOptions.excludeSegment a function that takes a start command object and
101
+ * end command object and returns true if the segment should be excluded from splitting.
102
+ * - interpolateOptions.snapEndsToInput a boolean indicating whether end of input should
103
+ * be sourced from input argument or computed.
104
+ * @returns {Function} Interpolation function that maps t ([0, 1]) to a path `d` string.
105
+ */
106
+ export declare function interpolatePath(
107
+ a: string | null | undefined,
108
+ b: string | null | undefined,
109
+ interpolateOptions?: ExcludeSegmentFn | InterpolateOptions,
110
+ ): (t: number) => string;
111
+ export {};
112
+ //# sourceMappingURL=interpolate.d.ts.map