@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
package/esm/chart/Path.js CHANGED
@@ -1,4 +1,5 @@
1
- const _excluded = ["animate", "clipRect", "clipOffset", "d"];
1
+ const _excluded = ["d", "transition"],
2
+ _excluded2 = ["animate", "clipRect", "clipOffset", "d", "transition"];
2
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
5
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -6,52 +7,65 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
6
7
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
8
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
8
9
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
9
- import 'd3-transition';
10
- import { memo, useCallback, useEffect, useId, useRef } from 'react';
11
- import { useValueChanges } from '@coinbase/cds-common/hooks/useValueChanges';
12
- import { interpolatePath } from 'd3-interpolate-path';
13
- import { select } from 'd3-selection';
10
+ import { memo, useId, useMemo } from 'react';
14
11
  import { m as motion } from 'framer-motion';
12
+ import { usePathTransition } from './utils/transition';
15
13
  import { useCartesianChartContext } from './ChartProvider';
14
+
15
+ /**
16
+ * Duration in seconds for path enter transition.
17
+ */
16
18
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
17
- export const Path = /*#__PURE__*/memo(_ref => {
19
+ export const pathEnterTransitionDuration = 0.5;
20
+ const AnimatedPath = /*#__PURE__*/memo(_ref => {
21
+ let {
22
+ d = '',
23
+ transition
24
+ } = _ref,
25
+ pathProps = _objectWithoutProperties(_ref, _excluded);
26
+ const interpolatedPath = usePathTransition({
27
+ currentPath: d,
28
+ transition
29
+ });
30
+ return /*#__PURE__*/_jsx(motion.path, _objectSpread({
31
+ d: interpolatedPath
32
+ }, pathProps));
33
+ });
34
+ export const Path = /*#__PURE__*/memo(_ref2 => {
18
35
  let {
19
36
  animate: animateProp,
20
37
  clipRect,
21
38
  clipOffset = 0,
22
- d = ''
23
- } = _ref,
24
- pathProps = _objectWithoutProperties(_ref, _excluded);
25
- const pathRef = useRef(null);
39
+ d = '',
40
+ transition
41
+ } = _ref2,
42
+ pathProps = _objectWithoutProperties(_ref2, _excluded2);
26
43
  const clipPathId = useId();
27
44
  const context = useCartesianChartContext();
28
- const rect = clipRect !== null && clipRect !== void 0 ? clipRect : context.drawingArea;
45
+ const rect = clipRect !== undefined ? clipRect : context.drawingArea;
29
46
  const animate = animateProp !== null && animateProp !== void 0 ? animateProp : context.animate;
30
- const {
31
- previousValue: previousPath,
32
- newValue: newPath,
33
- hasChanged,
34
- addPreviousValue
35
- } = useValueChanges(d);
36
- const morphPath = useCallback(() => {
37
- if (!pathRef.current || !newPath || !previousPath) return;
38
- select(pathRef.current).transition().duration(300).attrTween('d', function tween() {
39
- return interpolatePath(previousPath, newPath);
40
- });
41
- }, [previousPath, newPath]);
42
- useEffect(() => {
43
- addPreviousValue(newPath);
44
- if (animate && hasChanged && previousPath) {
45
- morphPath();
46
- }
47
- }, [addPreviousValue, newPath, animate, hasChanged, previousPath, morphPath]);
48
47
 
49
48
  // The clip offset provides extra padding to prevent path from being cut off
50
49
  // Area charts typically use offset=0 for exact clipping, while lines use offset=2 for breathing room
51
50
  const totalOffset = clipOffset * 2; // Applied on both sides
52
51
 
52
+ const clipPathAnimation = useMemo(() => {
53
+ if (rect === null) return;
54
+ return {
55
+ hidden: {
56
+ width: 0
57
+ },
58
+ visible: {
59
+ width: rect.width + totalOffset,
60
+ transition: {
61
+ type: 'timing',
62
+ duration: pathEnterTransitionDuration
63
+ }
64
+ }
65
+ };
66
+ }, [rect, totalOffset]);
53
67
  return /*#__PURE__*/_jsxs(_Fragment, {
54
- children: [/*#__PURE__*/_jsx("defs", {
68
+ children: [rect !== null && /*#__PURE__*/_jsx("defs", {
55
69
  children: /*#__PURE__*/_jsx("clipPath", {
56
70
  id: clipPathId,
57
71
  children: !animate ? /*#__PURE__*/_jsx("rect", {
@@ -63,27 +77,18 @@ export const Path = /*#__PURE__*/memo(_ref => {
63
77
  animate: "visible",
64
78
  height: rect.height + totalOffset,
65
79
  initial: "hidden",
66
- variants: {
67
- hidden: {
68
- width: 0
69
- },
70
- visible: {
71
- width: rect.width + totalOffset,
72
- transition: {
73
- type: 'spring',
74
- duration: 1,
75
- bounce: 0
76
- }
77
- }
78
- },
80
+ variants: clipPathAnimation,
79
81
  x: rect.x - clipOffset,
80
82
  y: rect.y - clipOffset
81
83
  })
82
84
  })
83
- }), /*#__PURE__*/_jsx("path", _objectSpread({
84
- ref: pathRef,
85
+ }), !animate ? /*#__PURE__*/_jsx("path", _objectSpread({
85
86
  clipPath: "url(#".concat(clipPathId, ")"),
86
87
  d: d
88
+ }, pathProps)) : /*#__PURE__*/_jsx(AnimatedPath, _objectSpread({
89
+ clipPath: "url(#".concat(clipPathId, ")"),
90
+ d: d,
91
+ transition: transition
87
92
  }, pathProps))]
88
93
  });
89
94
  });
@@ -1,4 +1,4 @@
1
- const _excluded = ["as", "color", "label", "display", "alignItems", "font", "hideDot", "disablePulse"],
1
+ const _excluded = ["as", "color", "label", "display", "alignItems", "font", "hideDot"],
2
2
  _excluded2 = ["background", "activeBackground", "width", "justifyContent", "TabComponent", "TabsActiveIndicatorComponent"];
3
3
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
4
4
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
@@ -15,11 +15,6 @@ import { Text } from '@coinbase/cds-web/typography';
15
15
  import { m as motion } from 'framer-motion';
16
16
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
17
  const MotionBox = motion(Box);
18
- const pulseTransitionConfig = {
19
- duration: 2,
20
- repeat: Infinity,
21
- ease: 'easeInOut'
22
- };
23
18
 
24
19
  // Animated active indicator to support smooth transition of background color
25
20
  export const PeriodSelectorActiveIndicator = /*#__PURE__*/memo(_ref => {
@@ -66,15 +61,10 @@ export const LiveTabLabel = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2, re
66
61
  display = 'inline-flex',
67
62
  alignItems = 'center',
68
63
  font = 'label1',
69
- hideDot,
70
- disablePulse
64
+ hideDot
71
65
  } = _ref2,
72
66
  props = _objectWithoutProperties(_ref2, _excluded);
73
67
  const Component = as !== null && as !== void 0 ? as : liveTabLabelDefaultElement;
74
- const pulseAnimation = !disablePulse ? {
75
- opacity: [1, 0, 1],
76
- transition: pulseTransitionConfig
77
- } : undefined;
78
68
  return /*#__PURE__*/_jsxs(Text, _objectSpread(_objectSpread({
79
69
  ref: ref,
80
70
  alignItems: alignItems,
@@ -83,12 +73,8 @@ export const LiveTabLabel = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2, re
83
73
  display: display,
84
74
  font: font
85
75
  }, props), {}, {
86
- children: [!hideDot && /*#__PURE__*/_jsx(motion.span, {
87
- animate: !disablePulse && pulseAnimation,
88
- className: dotBaseCss,
89
- initial: {
90
- opacity: 1
91
- }
76
+ children: [!hideDot && /*#__PURE__*/_jsx("span", {
77
+ className: dotBaseCss
92
78
  }), label]
93
79
  }));
94
80
  }));
@@ -6,17 +6,18 @@ import { GradientArea } from './GradientArea';
6
6
  import { SolidArea } from './SolidArea';
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
8
  export const Area = /*#__PURE__*/memo(_ref => {
9
- var _ref2;
10
9
  let {
11
10
  seriesId,
12
- curve = 'linear',
11
+ curve = 'bump',
13
12
  type = 'solid',
14
- AreaComponent: SelectedAreaComponent,
15
- fill: specifiedFill,
13
+ AreaComponent: AreaComponentProp,
14
+ fill: fillProp,
16
15
  fillOpacity = 1,
17
- stroke,
18
- strokeWidth,
19
- baseline
16
+ baseline,
17
+ connectNulls,
18
+ gradient: gradientProp,
19
+ transition,
20
+ animate
20
21
  } = _ref;
21
22
  const {
22
23
  getSeries,
@@ -25,20 +26,10 @@ export const Area = /*#__PURE__*/memo(_ref => {
25
26
  getYScale,
26
27
  getXAxis
27
28
  } = useCartesianChartContext();
28
-
29
- // Get sourceData from series (using stacked data if available)
30
29
  const matchedSeries = useMemo(() => getSeries(seriesId), [seriesId, getSeries]);
31
-
32
- // Check for stacked data first, then fall back to raw data
33
- const sourceData = useMemo(() => {
34
- const stackedData = getSeriesData(seriesId);
35
- if (stackedData) {
36
- return stackedData;
37
- }
38
- return getSeriesData(seriesId) || null;
39
- }, [seriesId, getSeriesData]);
40
-
41
- // Get scales and axes for this series
30
+ const gradient = useMemo(() => gradientProp !== null && gradientProp !== void 0 ? gradientProp : matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.gradient, [gradientProp, matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.gradient]);
31
+ const fill = useMemo(() => fillProp !== null && fillProp !== void 0 ? fillProp : matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.color, [fillProp, matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.color]);
32
+ const sourceData = useMemo(() => getSeriesData(seriesId), [seriesId, getSeriesData]);
42
33
  const xAxis = getXAxis();
43
34
  const xScale = getXScale();
44
35
  const yScale = getYScale(matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId);
@@ -52,34 +43,33 @@ export const Area = /*#__PURE__*/memo(_ref => {
52
43
  xScale,
53
44
  yScale,
54
45
  curve,
55
- xData
46
+ xData,
47
+ connectNulls
56
48
  });
57
- }, [sourceData, xScale, yScale, curve, xAxis === null || xAxis === void 0 ? void 0 : xAxis.data]);
49
+ }, [sourceData, xScale, yScale, curve, xAxis === null || xAxis === void 0 ? void 0 : xAxis.data, connectNulls]);
58
50
  const AreaComponent = useMemo(() => {
59
- if (SelectedAreaComponent) {
60
- return SelectedAreaComponent;
51
+ if (AreaComponentProp) {
52
+ return AreaComponentProp;
61
53
  }
62
54
  switch (type) {
63
- case 'solid':
64
- return SolidArea;
65
55
  case 'dotted':
66
56
  return DottedArea;
67
57
  case 'gradient':
68
- default:
69
58
  return GradientArea;
59
+ case 'solid':
60
+ default:
61
+ return SolidArea;
70
62
  }
71
- }, [SelectedAreaComponent, type]);
72
- if (!xScale || !yScale || !sourceData || !area) {
73
- return null;
74
- }
75
- const fill = (_ref2 = specifiedFill !== null && specifiedFill !== void 0 ? specifiedFill : matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.color) !== null && _ref2 !== void 0 ? _ref2 : 'var(--color-fgPrimary)';
63
+ }, [AreaComponentProp, type]);
64
+ if (!xScale || !yScale || !sourceData || !area) return;
76
65
  return /*#__PURE__*/_jsx(AreaComponent, {
66
+ animate: animate,
77
67
  baseline: baseline,
78
68
  d: area,
79
69
  fill: fill,
80
70
  fillOpacity: fillOpacity,
81
- stroke: stroke,
82
- strokeWidth: strokeWidth,
71
+ gradient: gradient,
72
+ transition: transition,
83
73
  yAxisId: matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId
84
74
  });
85
75
  });
@@ -1,8 +1,8 @@
1
- const _excluded = ["series", "stacked", "AreaComponent", "curve", "fillOpacity", "type", "LineComponent", "strokeWidth", "showXAxis", "showYAxis", "showLines", "lineType", "xAxis", "yAxis", "inset", "children"],
1
+ const _excluded = ["series", "stacked", "AreaComponent", "curve", "fillOpacity", "type", "connectNulls", "transition", "LineComponent", "strokeWidth", "showXAxis", "showYAxis", "showLines", "lineType", "xAxis", "yAxis", "inset", "children"],
2
2
  _excluded2 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range"],
3
3
  _excluded3 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range", "id"],
4
- _excluded4 = ["id", "data", "label", "color", "yAxisId", "opacity", "LineComponent", "stackId"],
5
- _excluded5 = ["id", "data", "label", "color", "yAxisId", "fill", "fillOpacity", "stackId"];
4
+ _excluded4 = ["id", "data", "label", "color", "yAxisId", "opacity", "LineComponent", "stackId", "transition"],
5
+ _excluded5 = ["id", "data", "label", "color", "yAxisId", "fill", "fillOpacity", "stackId", "type", "lineType", "transition"];
6
6
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
7
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
8
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -25,6 +25,8 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
25
25
  curve,
26
26
  fillOpacity,
27
27
  type,
28
+ connectNulls,
29
+ transition,
28
30
  LineComponent,
29
31
  strokeWidth,
30
32
  showXAxis,
@@ -33,11 +35,11 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
33
35
  lineType = 'solid',
34
36
  xAxis,
35
37
  yAxis,
36
- inset: userInset,
38
+ inset,
37
39
  children
38
40
  } = _ref,
39
41
  chartProps = _objectWithoutProperties(_ref, _excluded);
40
- const calculatedInset = useMemo(() => getChartInset(userInset, defaultChartInset), [userInset]);
42
+ const calculatedInset = useMemo(() => getChartInset(inset, defaultChartInset), [inset]);
41
43
 
42
44
  // Convert AreaSeries to Series for Chart context
43
45
  const chartSeries = useMemo(() => {
@@ -47,7 +49,8 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
47
49
  label: s.label,
48
50
  color: s.color,
49
51
  yAxisId: s.yAxisId,
50
- stackId: s.stackId
52
+ stackId: s.stackId,
53
+ gradient: s.gradient
51
54
  }));
52
55
  }, [series]);
53
56
  const transformedSeries = useMemo(() => {
@@ -127,14 +130,17 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
127
130
  yAxisId,
128
131
  opacity,
129
132
  LineComponent,
130
- stackId
133
+ stackId,
134
+ transition: seriesTransition
131
135
  } = _ref4,
132
136
  areaPropsFromSeries = _objectWithoutProperties(_ref4, _excluded4);
133
137
  return /*#__PURE__*/_jsx(Area, _objectSpread({
134
138
  AreaComponent: AreaComponent,
139
+ connectNulls: connectNulls,
135
140
  curve: curve,
136
141
  fillOpacity: fillOpacity,
137
142
  seriesId: id,
143
+ transition: seriesTransition !== null && seriesTransition !== void 0 ? seriesTransition : transition,
138
144
  type: type
139
145
  }, areaPropsFromSeries), id);
140
146
  }), showLines && (series === null || series === void 0 ? void 0 : series.map(_ref5 => {
@@ -146,19 +152,22 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
146
152
  yAxisId,
147
153
  fill,
148
154
  fillOpacity,
149
- stackId
155
+ stackId,
156
+ type,
157
+ // Area type (don't pass to Line)
158
+ lineType: seriesLineType,
159
+ transition: seriesTransition
150
160
  } = _ref5,
151
- linePropsFromSeries = _objectWithoutProperties(_ref5, _excluded5);
161
+ otherPropsFromSeries = _objectWithoutProperties(_ref5, _excluded5);
152
162
  return /*#__PURE__*/_jsx(Line, _objectSpread({
153
163
  LineComponent: LineComponent,
164
+ connectNulls: connectNulls,
154
165
  curve: curve,
155
- seriesId: id // Line component now handles stacked data automatically
156
- ,
157
- stroke: color // Default to series color
158
- ,
166
+ seriesId: id,
159
167
  strokeWidth: strokeWidth,
160
- type: lineType
161
- }, linePropsFromSeries), "".concat(id, "-line"));
168
+ transition: seriesTransition !== null && seriesTransition !== void 0 ? seriesTransition : transition,
169
+ type: seriesLineType !== null && seriesLineType !== void 0 ? seriesLineType : lineType
170
+ }, otherPropsFromSeries), id);
162
171
  })), children]
163
172
  }));
164
173
  }));
@@ -1,4 +1,4 @@
1
- const _excluded = ["d", "fill", "className", "style", "patternSize", "dotSize", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "classNames", "styles", "animate"];
1
+ const _excluded = ["d", "fill", "patternSize", "dotSize", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "gradient", "animate", "transition"];
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -6,136 +6,82 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
6
6
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
8
8
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
9
- import { memo, useId } from 'react';
9
+ import { memo, useId, useMemo } from 'react';
10
10
  import { useCartesianChartContext } from '../ChartProvider';
11
+ import { Gradient } from '../gradient';
11
12
  import { Path } from '../Path';
12
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { createGradient, getBaseline } from '../utils';
14
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
+ /**
16
+ * A customizable dotted area gradient component.
17
+ * When no gradient is provided, renders a default gradient based
18
+ * on the fill color and peak/baseline opacities.
19
+ */
13
20
  export const DottedArea = /*#__PURE__*/memo(_ref => {
14
21
  let {
15
22
  d,
16
- fill,
17
- className,
18
- style,
23
+ fill = 'var(--color-fgPrimary)',
19
24
  patternSize = 4,
20
25
  dotSize = 1,
21
26
  peakOpacity = 1,
22
27
  baselineOpacity = 0,
23
28
  baseline,
24
29
  yAxisId,
25
- classNames,
26
- styles,
27
- animate
30
+ gradient: gradientProp,
31
+ animate,
32
+ transition
28
33
  } = _ref,
29
34
  pathProps = _objectWithoutProperties(_ref, _excluded);
30
- const context = useCartesianChartContext();
35
+ const {
36
+ getYAxis
37
+ } = useCartesianChartContext();
31
38
  const patternId = useId();
32
39
  const gradientId = useId();
33
40
  const maskId = useId();
34
41
  const dotCenterPosition = patternSize / 2;
35
-
36
- // Get the y-scale for the specified axis (or default)
37
- const yScale = context.getYScale(yAxisId);
38
- const yRange = yScale === null || yScale === void 0 ? void 0 : yScale.range();
39
- const yDomain = yScale === null || yScale === void 0 ? void 0 : yScale.domain();
40
-
41
- // Use chart range if available, otherwise fall back to percentage
42
- const useUserSpaceUnits = yRange !== undefined;
43
-
44
- // Auto-calculate baseline position based on domain
45
- let baselinePosition;
46
- let baselinePercentage;
47
- if (yScale && yDomain) {
48
- const [minValue, maxValue] = yDomain;
49
- let dataBaseline;
50
- if (minValue >= 0) {
51
- // All positive: baseline at min
52
- dataBaseline = minValue;
53
- } else if (maxValue <= 0) {
54
- // All negative: baseline at max
55
- dataBaseline = maxValue;
56
- } else {
57
- // Crosses zero: baseline at 0
58
- dataBaseline = 0;
59
- }
60
- if (useUserSpaceUnits) {
61
- // Get the actual y coordinate for the baseline
62
- const scaledValue = yScale(baseline !== null && baseline !== void 0 ? baseline : dataBaseline);
63
- if (typeof scaledValue === 'number') {
64
- baselinePosition = scaledValue;
65
- }
66
- } else {
67
- // Calculate percentage position
68
- baselinePercentage = "".concat((maxValue - (baseline !== null && baseline !== void 0 ? baseline : dataBaseline)) / (maxValue - minValue) * 100, "%");
69
- }
70
- }
71
- const gradientY1 = useUserSpaceUnits ? yRange[1] : '0%';
72
- const gradientY2 = useUserSpaceUnits ? yRange[0] : '100%';
42
+ const yAxisConfig = getYAxis(yAxisId);
43
+ const gradient = useMemo(() => {
44
+ if (gradientProp) return gradientProp;
45
+ if (!yAxisConfig) return;
46
+ const baselineValue = getBaseline(yAxisConfig.domain, baseline);
47
+ return createGradient(yAxisConfig.domain, baselineValue, fill, peakOpacity, baselineOpacity);
48
+ }, [gradientProp, yAxisConfig, fill, baseline, peakOpacity, baselineOpacity]);
73
49
  return /*#__PURE__*/_jsxs("g", {
74
- className: className !== null && className !== void 0 ? className : classNames === null || classNames === void 0 ? void 0 : classNames.root,
75
- style: style !== null && style !== void 0 ? style : styles === null || styles === void 0 ? void 0 : styles.root,
76
50
  children: [/*#__PURE__*/_jsxs("defs", {
77
51
  children: [/*#__PURE__*/_jsx("pattern", {
78
- className: classNames === null || classNames === void 0 ? void 0 : classNames.pattern,
79
52
  height: patternSize,
80
53
  id: patternId,
81
54
  patternUnits: "userSpaceOnUse",
82
- style: styles === null || styles === void 0 ? void 0 : styles.pattern,
83
55
  width: patternSize,
84
56
  x: "0",
85
57
  y: "0",
86
58
  children: /*#__PURE__*/_jsx("circle", {
87
59
  cx: dotCenterPosition,
88
60
  cy: dotCenterPosition,
89
- fill: fill,
61
+ fill: "white",
90
62
  r: dotSize
91
63
  })
92
- }), /*#__PURE__*/_jsx("linearGradient", {
93
- gradientUnits: useUserSpaceUnits ? 'userSpaceOnUse' : 'objectBoundingBox',
94
- id: gradientId,
95
- x1: useUserSpaceUnits ? 0 : '0%',
96
- x2: useUserSpaceUnits ? 0 : '0%',
97
- y1: gradientY1,
98
- y2: gradientY2,
99
- children: baselinePosition !== undefined || baselinePercentage !== undefined ? /*#__PURE__*/_jsxs(_Fragment, {
100
- children: [/*#__PURE__*/_jsx("stop", {
101
- offset: "0%",
102
- stopColor: "white",
103
- stopOpacity: peakOpacity
104
- }), /*#__PURE__*/_jsx("stop", {
105
- offset: baselinePercentage !== null && baselinePercentage !== void 0 ? baselinePercentage : "".concat((baselinePosition - yRange[1]) / (yRange[0] - yRange[1]) * 100, "%"),
106
- stopColor: "white",
107
- stopOpacity: baselineOpacity
108
- }), /*#__PURE__*/_jsx("stop", {
109
- offset: "100%",
110
- stopColor: "white",
111
- stopOpacity: peakOpacity
112
- })]
113
- }) : /*#__PURE__*/_jsxs(_Fragment, {
114
- children: [/*#__PURE__*/_jsx("stop", {
115
- offset: "0%",
116
- stopColor: "white",
117
- stopOpacity: peakOpacity
118
- }), /*#__PURE__*/_jsx("stop", {
119
- offset: "100%",
120
- stopColor: "white",
121
- stopOpacity: baselineOpacity
122
- })]
123
- })
124
64
  }), /*#__PURE__*/_jsx("mask", {
125
65
  id: maskId,
126
66
  children: /*#__PURE__*/_jsx(Path, {
127
67
  animate: animate,
128
68
  d: d,
129
- fill: "url(#".concat(gradientId, ")")
69
+ fill: "url(#".concat(patternId, ")"),
70
+ transition: transition
130
71
  })
72
+ }), gradient && /*#__PURE__*/_jsx(Gradient, {
73
+ animate: animate,
74
+ gradient: gradient,
75
+ id: gradientId,
76
+ transition: transition,
77
+ yAxisId: yAxisId
131
78
  })]
132
79
  }), /*#__PURE__*/_jsx(Path, _objectSpread({
133
80
  animate: animate,
134
- className: classNames === null || classNames === void 0 ? void 0 : classNames.path,
135
81
  d: d,
136
- fill: "url(#".concat(patternId, ")"),
82
+ fill: gradient ? "url(#".concat(gradientId, ")") : fill,
137
83
  mask: "url(#".concat(maskId, ")"),
138
- style: styles === null || styles === void 0 ? void 0 : styles.path
84
+ transition: transition
139
85
  }, pathProps))]
140
86
  });
141
87
  });