@coinbase/cds-web-visualization 3.4.0-beta.1 → 3.4.0-beta.10

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 (169) hide show
  1. package/CHANGELOG.md +47 -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 +92 -45
  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 +91 -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 +207 -66
  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/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts.map +1 -1
  105. package/esm/chart/CartesianChart.js +140 -85
  106. package/esm/chart/Path.js +53 -47
  107. package/esm/chart/PeriodSelector.js +4 -18
  108. package/esm/chart/area/Area.js +24 -34
  109. package/esm/chart/area/AreaChart.js +24 -15
  110. package/esm/chart/area/DottedArea.js +35 -89
  111. package/esm/chart/area/GradientArea.js +34 -80
  112. package/esm/chart/area/SolidArea.js +29 -11
  113. package/esm/chart/axis/Axis.js +4 -25
  114. package/esm/chart/axis/DefaultAxisTickLabel.js +15 -0
  115. package/esm/chart/axis/XAxis.js +76 -52
  116. package/esm/chart/axis/YAxis.js +80 -49
  117. package/esm/chart/axis/index.js +1 -0
  118. package/esm/chart/bar/Bar.js +3 -1
  119. package/esm/chart/bar/BarChart.js +15 -32
  120. package/esm/chart/bar/BarPlot.js +3 -2
  121. package/esm/chart/bar/BarStack.js +65 -23
  122. package/esm/chart/bar/BarStackGroup.js +7 -17
  123. package/esm/chart/bar/DefaultBar.js +4 -7
  124. package/esm/chart/bar/DefaultBarStack.js +5 -7
  125. package/esm/chart/gradient/Gradient.js +104 -0
  126. package/esm/chart/gradient/index.js +1 -0
  127. package/esm/chart/index.js +2 -1
  128. package/esm/chart/line/DefaultReferenceLineLabel.js +81 -0
  129. package/esm/chart/line/DottedLine.js +38 -17
  130. package/esm/chart/line/Line.js +96 -70
  131. package/esm/chart/line/LineChart.js +18 -6
  132. package/esm/chart/line/ReferenceLine.js +41 -43
  133. package/esm/chart/line/SolidLine.js +36 -15
  134. package/esm/chart/line/index.js +1 -1
  135. package/esm/chart/{line/GradientLine.js → point/DefaultPointLabel.js} +31 -45
  136. package/esm/chart/point/Point.css +2 -0
  137. package/esm/chart/{Point.js → point/Point.js} +66 -57
  138. package/esm/chart/point/index.js +2 -0
  139. package/esm/chart/scrubber/DefaultScrubberBeacon.js +155 -0
  140. package/esm/chart/scrubber/{ScrubberBeaconLabel.js → DefaultScrubberBeaconLabel.js} +23 -10
  141. package/esm/chart/scrubber/DefaultScrubberLabel.js +30 -0
  142. package/esm/chart/scrubber/Scrubber.js +98 -392
  143. package/esm/chart/scrubber/ScrubberBeaconGroup.js +166 -0
  144. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +186 -0
  145. package/esm/chart/scrubber/index.js +3 -1
  146. package/esm/chart/text/ChartText.js +13 -19
  147. package/esm/chart/text/{SmartChartTextGroup.js → ChartTextGroup.js} +4 -3
  148. package/esm/chart/text/index.js +1 -1
  149. package/esm/chart/utils/chart.js +29 -3
  150. package/esm/chart/utils/gradient.js +257 -0
  151. package/esm/chart/utils/index.js +4 -0
  152. package/esm/chart/utils/interpolate.js +644 -0
  153. package/esm/chart/utils/path.js +32 -9
  154. package/esm/chart/utils/point.js +69 -0
  155. package/esm/chart/utils/scrubber.js +132 -0
  156. package/esm/chart/utils/transition.js +111 -0
  157. package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.js +8 -4
  158. package/package.json +9 -9
  159. package/dts/chart/Point.d.ts +0 -153
  160. package/dts/chart/Point.d.ts.map +0 -1
  161. package/dts/chart/line/GradientLine.d.ts +0 -42
  162. package/dts/chart/line/GradientLine.d.ts.map +0 -1
  163. package/dts/chart/scrubber/ScrubberBeacon.d.ts +0 -93
  164. package/dts/chart/scrubber/ScrubberBeacon.d.ts.map +0 -1
  165. package/dts/chart/scrubber/ScrubberBeaconLabel.d.ts +0 -7
  166. package/dts/chart/scrubber/ScrubberBeaconLabel.d.ts.map +0 -1
  167. package/dts/chart/text/SmartChartTextGroup.d.ts.map +0 -1
  168. package/esm/chart/Point.css +0 -2
  169. package/esm/chart/scrubber/ScrubberBeacon.js +0 -195
@@ -0,0 +1,104 @@
1
+ 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; }
2
+ 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; }
3
+ 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; }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
+ 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); }
6
+ import { memo, useMemo } from 'react';
7
+ import { m as motion } from 'framer-motion';
8
+ import { useCartesianChartContext } from '../ChartProvider';
9
+ import { getGradientConfig } from '../utils/gradient';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ /**
12
+ * Renders an SVG linearGradient element based on a GradientDefinition.
13
+ * The gradient can be referenced via `fill="url(#${id})"` or `stroke="url(#${id})"`.
14
+ */
15
+ export const Gradient = /*#__PURE__*/memo(_ref => {
16
+ var _gradient$axis;
17
+ let {
18
+ id,
19
+ gradient,
20
+ yAxisId,
21
+ animate: animateProp,
22
+ transition
23
+ } = _ref;
24
+ const context = useCartesianChartContext();
25
+ const animate = animateProp !== null && animateProp !== void 0 ? animateProp : context.animate;
26
+ const xScale = context.getXScale();
27
+ const yScale = context.getYScale(yAxisId);
28
+
29
+ // Process gradient definition into stops
30
+ const stops = useMemo(() => {
31
+ if (!xScale || !yScale) return;
32
+ return getGradientConfig(gradient, xScale, yScale);
33
+ }, [gradient, xScale, yScale]);
34
+ const drawingArea = context.drawingArea;
35
+ const yAxis = context.getYAxis(yAxisId);
36
+ const xAxis = context.getXAxis();
37
+
38
+ // If gradient processing failed, don't render
39
+ if (!stops) return null;
40
+ const axis = (_gradient$axis = gradient.axis) !== null && _gradient$axis !== void 0 ? _gradient$axis : 'y';
41
+ let coordinates;
42
+ if (axis === 'y') {
43
+ const yRange = yAxis === null || yAxis === void 0 ? void 0 : yAxis.range;
44
+ if (yRange) {
45
+ coordinates = {
46
+ x1: drawingArea.x,
47
+ y1: yRange.max,
48
+ x2: drawingArea.x,
49
+ y2: yRange.min
50
+ };
51
+ } else {
52
+ coordinates = {
53
+ x1: drawingArea.x,
54
+ y1: drawingArea.y + drawingArea.height,
55
+ x2: drawingArea.x,
56
+ y2: drawingArea.y
57
+ };
58
+ }
59
+ } else {
60
+ const xRange = xAxis === null || xAxis === void 0 ? void 0 : xAxis.range;
61
+ if (xRange) {
62
+ coordinates = {
63
+ x1: xRange.min,
64
+ y1: drawingArea.y,
65
+ x2: xRange.max,
66
+ y2: drawingArea.y
67
+ };
68
+ } else {
69
+ coordinates = {
70
+ x1: drawingArea.x,
71
+ y1: drawingArea.y,
72
+ x2: drawingArea.x + drawingArea.width,
73
+ y2: drawingArea.y
74
+ };
75
+ }
76
+ }
77
+ return /*#__PURE__*/_jsx("linearGradient", _objectSpread(_objectSpread({
78
+ gradientUnits: "userSpaceOnUse",
79
+ id: id
80
+ }, coordinates), {}, {
81
+ children: stops.map((stop, index) => {
82
+ const offset = "".concat(stop.offset * 100, "%");
83
+ const opacity = stop.opacity;
84
+ if (!animate) {
85
+ return /*#__PURE__*/_jsx("stop", {
86
+ offset: offset,
87
+ stopColor: stop.color,
88
+ stopOpacity: opacity !== null && opacity !== void 0 ? opacity : 1
89
+ }, "".concat(id, "-stop-").concat(index));
90
+ }
91
+ return /*#__PURE__*/_jsx(motion.stop, {
92
+ animate: {
93
+ offset
94
+ },
95
+ initial: {
96
+ offset
97
+ },
98
+ stopColor: stop.color,
99
+ stopOpacity: opacity !== null && opacity !== void 0 ? opacity : 1,
100
+ transition: transition
101
+ }, "".concat(id, "-stop-").concat(index));
102
+ })
103
+ }));
104
+ });
@@ -0,0 +1 @@
1
+ export { Gradient } from './Gradient';
@@ -4,10 +4,11 @@ export * from './axis/index';
4
4
  export * from './bar/index';
5
5
  export * from './CartesianChart';
6
6
  export * from './ChartProvider';
7
+ export * from './gradient/index';
7
8
  export * from './line/index';
8
9
  export * from './Path';
9
10
  export * from './PeriodSelector';
10
- export * from './Point';
11
+ export * from './point/index';
11
12
  export * from './scrubber/index';
12
13
  export * from './text/index';
13
14
  export * from './utils/index';
@@ -0,0 +1,81 @@
1
+ const _excluded = ["color", "elevated", "borderRadius", "inset", "boundsInset", "className", "classNames", "style", "styles"];
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
+ 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
+ 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; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
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
+ 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
+ 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, useMemo } from 'react';
10
+ import { useCartesianChartContext } from '../ChartProvider';
11
+ import { ChartText } from '../text';
12
+ import { getChartInset } from '../utils';
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ const elevatedInset = {
15
+ top: 8,
16
+ bottom: 8,
17
+ left: 12,
18
+ right: 12
19
+ };
20
+ const elevatedBorderRadius = 4;
21
+ // Default bounds inset when elevated to prevent shadow clipping
22
+ const elevatedBoundsInset = {
23
+ top: 4,
24
+ bottom: 20,
25
+ left: 12,
26
+ right: 12
27
+ };
28
+ const nonElevatedBoundsInset = {
29
+ top: 0,
30
+ bottom: 0,
31
+ left: 0,
32
+ right: 0
33
+ };
34
+
35
+ /**
36
+ * DefaultReferenceLineLabel is the default label component for ReferenceLine.
37
+ * Provides standard styling with elevation, inset, and color defaults.
38
+ * When elevated, automatically adds bounds to prevent shadow cutoff at chart edges.
39
+ */
40
+ export const DefaultReferenceLineLabel = /*#__PURE__*/memo(_ref => {
41
+ let {
42
+ color = 'var(--color-fgMuted)',
43
+ elevated,
44
+ borderRadius = elevated ? elevatedBorderRadius : undefined,
45
+ inset = elevated ? elevatedInset : undefined,
46
+ boundsInset: boundsInsetProp,
47
+ className,
48
+ classNames,
49
+ style,
50
+ styles
51
+ } = _ref,
52
+ props = _objectWithoutProperties(_ref, _excluded);
53
+ const {
54
+ width: chartWidth,
55
+ height: chartHeight
56
+ } = useCartesianChartContext();
57
+ const bounds = useMemo(() => {
58
+ const boundsInset = getChartInset(boundsInsetProp, elevated ? elevatedBoundsInset : nonElevatedBoundsInset);
59
+ return {
60
+ x: boundsInset.left,
61
+ y: boundsInset.top,
62
+ width: chartWidth - boundsInset.left - boundsInset.right,
63
+ height: chartHeight - boundsInset.top - boundsInset.bottom
64
+ };
65
+ }, [elevated, boundsInsetProp, chartWidth, chartHeight]);
66
+ const mergedClassNames = useMemo(() => _objectSpread(_objectSpread({}, className && {
67
+ text: className
68
+ }), classNames), [className, classNames]);
69
+ const mergedStyles = useMemo(() => _objectSpread(_objectSpread({}, style && {
70
+ text: style
71
+ }), styles), [style, styles]);
72
+ return /*#__PURE__*/_jsx(ChartText, _objectSpread({
73
+ borderRadius: borderRadius,
74
+ bounds: bounds,
75
+ classNames: mergedClassNames,
76
+ color: color,
77
+ elevated: elevated,
78
+ inset: inset,
79
+ styles: mergedStyles
80
+ }, props));
81
+ });
@@ -1,4 +1,4 @@
1
- const _excluded = ["fill", "stroke", "strokeDasharray", "strokeLinecap", "strokeLinejoin", "strokeOpacity", "strokeWidth", "vectorEffect"];
1
+ const _excluded = ["fill", "stroke", "strokeDasharray", "strokeLinecap", "strokeLinejoin", "strokeOpacity", "strokeWidth", "vectorEffect", "gradient", "yAxisId", "animate", "transition", "d"];
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,33 +6,54 @@ 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 } from 'react';
9
+ import { memo, useId } from 'react';
10
+ import { Gradient } from '../gradient';
10
11
  import { Path } from '../Path';
11
- import { jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
12
13
  /**
13
- * A customizable dotted line component which uses path element.
14
+ * A customizable dotted line component.
15
+ * Supports gradient for gradient effects on the dots.
14
16
  */
15
17
  export const DottedLine = /*#__PURE__*/memo(_ref => {
16
18
  let {
17
19
  fill = 'none',
18
- stroke = 'var(--color-bgLine)',
20
+ stroke = 'var(--color-fgPrimary)',
19
21
  strokeDasharray = '0 4',
20
22
  strokeLinecap = 'round',
21
23
  strokeLinejoin = 'round',
22
24
  strokeOpacity = 1,
23
25
  strokeWidth = 2,
24
- vectorEffect = 'non-scaling-stroke'
26
+ vectorEffect = 'non-scaling-stroke',
27
+ gradient,
28
+ yAxisId,
29
+ animate,
30
+ transition,
31
+ d
25
32
  } = _ref,
26
33
  props = _objectWithoutProperties(_ref, _excluded);
27
- return /*#__PURE__*/_jsx(Path, _objectSpread({
28
- clipOffset: strokeWidth,
29
- fill: fill,
30
- stroke: stroke,
31
- strokeDasharray: strokeDasharray,
32
- strokeLinecap: strokeLinecap,
33
- strokeLinejoin: strokeLinejoin,
34
- strokeOpacity: strokeOpacity,
35
- strokeWidth: strokeWidth,
36
- vectorEffect: vectorEffect
37
- }, props));
34
+ const gradientId = useId();
35
+ return /*#__PURE__*/_jsxs(_Fragment, {
36
+ children: [gradient && /*#__PURE__*/_jsx("defs", {
37
+ children: /*#__PURE__*/_jsx(Gradient, {
38
+ animate: animate,
39
+ gradient: gradient,
40
+ id: gradientId,
41
+ transition: transition,
42
+ yAxisId: yAxisId
43
+ })
44
+ }), /*#__PURE__*/_jsx(Path, _objectSpread({
45
+ animate: animate,
46
+ clipOffset: strokeWidth,
47
+ d: d,
48
+ fill: fill,
49
+ stroke: gradient ? "url(#".concat(gradientId, ")") : stroke,
50
+ strokeDasharray: strokeDasharray,
51
+ strokeLinecap: strokeLinecap,
52
+ strokeLinejoin: strokeLinejoin,
53
+ strokeOpacity: strokeOpacity,
54
+ strokeWidth: strokeWidth,
55
+ transition: transition,
56
+ vectorEffect: vectorEffect
57
+ }, props))]
58
+ });
38
59
  });
@@ -1,4 +1,4 @@
1
- const _excluded = ["seriesId", "curve", "type", "areaType", "areaBaseline", "stroke", "onPointClick", "showArea", "LineComponent", "AreaComponent", "opacity", "renderPoints"];
1
+ const _excluded = ["seriesId", "curve", "type", "areaType", "areaBaseline", "stroke", "strokeOpacity", "onPointClick", "showArea", "LineComponent", "AreaComponent", "opacity", "points", "connectNulls", "transition", "gradient"];
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; }
@@ -9,29 +9,31 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
9
9
  import React, { memo, useMemo } from 'react';
10
10
  import { m as motion } from 'framer-motion';
11
11
  import { Area } from '../area/Area';
12
- import { axisTickLabelsInitialAnimationVariants } from '../axis';
13
12
  import { useCartesianChartContext } from '../ChartProvider';
14
- import { Point } from '../Point';
15
- import { getLinePath } from '../utils';
13
+ import { Point } from '../point';
14
+ import { accessoryFadeTransitionDelay, accessoryFadeTransitionDuration, evaluateGradientAtValue, getGradientConfig, getLineData, getLinePath } from '../utils';
16
15
  import { DottedLine } from './DottedLine';
17
- import { GradientLine } from './GradientLine';
18
16
  import { SolidLine } from './SolidLine';
19
17
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
20
18
  export const Line = /*#__PURE__*/memo(_ref => {
21
19
  var _ref2;
22
20
  let {
23
21
  seriesId,
24
- curve = 'linear',
22
+ curve = 'bump',
25
23
  type = 'solid',
26
24
  areaType = 'gradient',
27
25
  areaBaseline,
28
- stroke: specifiedStroke,
26
+ stroke: strokeProp,
27
+ strokeOpacity,
29
28
  onPointClick,
30
29
  showArea = false,
31
30
  LineComponent: SelectedLineComponent,
32
31
  AreaComponent,
33
32
  opacity = 1,
34
- renderPoints
33
+ points,
34
+ connectNulls,
35
+ transition,
36
+ gradient: gradientProp
35
37
  } = _ref,
36
38
  props = _objectWithoutProperties(_ref, _excluded);
37
39
  const {
@@ -40,42 +42,18 @@ export const Line = /*#__PURE__*/memo(_ref => {
40
42
  getSeriesData,
41
43
  getXScale,
42
44
  getYScale,
43
- getXAxis
45
+ getXAxis,
46
+ getYAxis
44
47
  } = useCartesianChartContext();
45
- const matchedSeries = getSeries(seriesId);
46
- const sourceData = useMemo(() => {
47
- const stackedData = getSeriesData(seriesId);
48
- if (stackedData) {
49
- return stackedData;
50
- }
51
- return getSeriesData(seriesId) || null;
52
- }, [seriesId, getSeriesData]);
53
- const xAxis = getXAxis();
54
- const xScale = getXScale();
55
- const yScale = getYScale(matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId);
48
+ const matchedSeries = useMemo(() => getSeries(seriesId), [getSeries, seriesId]);
49
+ 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]);
50
+ const sourceData = useMemo(() => getSeriesData(seriesId), [getSeriesData, seriesId]);
51
+ const xAxis = useMemo(() => getXAxis(), [getXAxis]);
52
+ const xScale = useMemo(() => getXScale(), [getXScale]);
53
+ const yScale = useMemo(() => getYScale(matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId), [getYScale, matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId]);
56
54
 
57
55
  // Convert sourceData to number array (line only supports numbers, not tuples)
58
- // If data is stacked (tuples), extract the actual values from [baseline, actualValue] format
59
- const chartData = useMemo(() => {
60
- if (!sourceData) return [];
61
-
62
- // Check if this is stacked data (array of tuples)
63
- const firstNonNull = sourceData.find(d => d !== null);
64
- if (Array.isArray(firstNonNull)) {
65
- // Extract actual values from [baseline, value] tuples
66
- return sourceData.map(d => {
67
- if (d === null) return null;
68
- if (Array.isArray(d)) return d[1];
69
- return d;
70
- });
71
- }
72
-
73
- // Regular number array
74
- if (sourceData.every(d => typeof d === 'number' || d === null)) {
75
- return sourceData;
76
- }
77
- return [];
78
- }, [sourceData]);
56
+ const chartData = useMemo(() => getLineData(sourceData), [sourceData]);
79
57
  const path = useMemo(() => {
80
58
  if (!xScale || !yScale || chartData.length === 0) return '';
81
59
 
@@ -86,9 +64,10 @@ export const Line = /*#__PURE__*/memo(_ref => {
86
64
  xScale,
87
65
  yScale,
88
66
  curve,
89
- xData
67
+ xData,
68
+ connectNulls
90
69
  });
91
- }, [chartData, xScale, yScale, curve, xAxis === null || xAxis === void 0 ? void 0 : xAxis.data]);
70
+ }, [chartData, xScale, yScale, curve, xAxis === null || xAxis === void 0 ? void 0 : xAxis.data, connectNulls]);
92
71
  const LineComponent = useMemo(() => {
93
72
  if (SelectedLineComponent) {
94
73
  return SelectedLineComponent;
@@ -96,63 +75,110 @@ export const Line = /*#__PURE__*/memo(_ref => {
96
75
  switch (type) {
97
76
  case 'dotted':
98
77
  return DottedLine;
99
- case 'gradient':
100
- return GradientLine;
101
- case 'solid':
102
78
  default:
103
79
  return SolidLine;
104
80
  }
105
81
  }, [SelectedLineComponent, type]);
106
82
 
107
83
  // Get series color for stroke
108
- const stroke = (_ref2 = specifiedStroke !== null && specifiedStroke !== void 0 ? specifiedStroke : matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.color) !== null && _ref2 !== void 0 ? _ref2 : 'var(--color-fgPrimary)';
84
+ const stroke = (_ref2 = strokeProp !== null && strokeProp !== void 0 ? strokeProp : matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.color) !== null && _ref2 !== void 0 ? _ref2 : 'var(--color-fgPrimary)';
109
85
  const xData = useMemo(() => {
110
86
  const data = xAxis === null || xAxis === void 0 ? void 0 : xAxis.data;
111
87
  return data && Array.isArray(data) && data.length > 0 && typeof data[0] === 'number' ? data : null;
112
88
  }, [xAxis === null || xAxis === void 0 ? void 0 : xAxis.data]);
89
+ const gradientConfig = useMemo(() => {
90
+ if (!gradient || !xScale || !yScale) return;
91
+ const gradientScale = gradient.axis === 'x' ? xScale : yScale;
92
+ const stops = getGradientConfig(gradient, xScale, yScale);
93
+ if (!stops) return;
94
+ return {
95
+ scale: gradientScale,
96
+ stops
97
+ };
98
+ }, [gradient, xScale, yScale]);
99
+ if (!xScale || !yScale || !path) return;
113
100
  return /*#__PURE__*/_jsxs(_Fragment, {
114
101
  children: [showArea && /*#__PURE__*/_jsx(Area, {
115
102
  AreaComponent: AreaComponent,
116
103
  baseline: areaBaseline,
104
+ connectNulls: connectNulls,
117
105
  curve: curve,
118
106
  fill: stroke,
119
107
  fillOpacity: opacity,
108
+ gradient: gradient,
120
109
  seriesId: seriesId,
110
+ transition: transition,
121
111
  type: areaType
122
112
  }), /*#__PURE__*/_jsx(LineComponent, _objectSpread({
123
113
  d: path,
114
+ gradient: gradient,
124
115
  stroke: stroke,
125
- strokeOpacity: opacity
126
- }, props)), renderPoints && /*#__PURE__*/_jsx(motion.g, _objectSpread(_objectSpread({
116
+ strokeOpacity: strokeOpacity !== null && strokeOpacity !== void 0 ? strokeOpacity : opacity,
117
+ transition: transition,
118
+ yAxisId: matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId
119
+ }, props)), points && /*#__PURE__*/_jsx(motion.g, _objectSpread(_objectSpread({
127
120
  "data-component": "line-points-group"
128
121
  }, animate ? {
129
- animate: 'animate',
130
- exit: 'exit',
131
- initial: 'initial',
132
- variants: axisTickLabelsInitialAnimationVariants
122
+ animate: {
123
+ opacity: 1,
124
+ transition: {
125
+ duration: accessoryFadeTransitionDuration,
126
+ delay: accessoryFadeTransitionDelay
127
+ }
128
+ },
129
+ exit: {
130
+ opacity: 0,
131
+ transition: {
132
+ duration: accessoryFadeTransitionDuration
133
+ }
134
+ },
135
+ initial: {
136
+ opacity: 0
137
+ }
133
138
  } : {}), {}, {
134
139
  children: chartData.map((value, index) => {
135
- var _xScale, _yScale, _pointConfig$fill, _pointConfig$onClick, _pointConfig$opacity;
136
- if (value === null) {
137
- return null;
138
- }
140
+ var _pointConfig$onClick;
141
+ if (value === null) return;
139
142
  const xValue = xData && xData[index] !== undefined ? xData[index] : index;
140
- const point = renderPoints({
141
- dataY: value,
143
+ let pointFill = stroke;
144
+ if (gradientConfig && gradient) {
145
+ var _gradient$axis;
146
+ // Use the appropriate data value based on gradient axis
147
+ const axis = (_gradient$axis = gradient.axis) !== null && _gradient$axis !== void 0 ? _gradient$axis : 'y';
148
+ const dataValue = axis === 'x' ? xValue : value;
149
+ const evaluatedColor = evaluateGradientAtValue(gradientConfig.stops, dataValue, gradientConfig.scale);
150
+ if (evaluatedColor) {
151
+ // Apply gradient color to fill if not explicitly set
152
+ pointFill = evaluatedColor;
153
+ }
154
+ }
155
+
156
+ // Build defaults that would be passed to Point
157
+ const defaults = {
142
158
  dataX: xValue,
143
- x: (_xScale = xScale === null || xScale === void 0 ? void 0 : xScale(xValue)) !== null && _xScale !== void 0 ? _xScale : 0,
144
- y: (_yScale = yScale === null || yScale === void 0 ? void 0 : yScale(value)) !== null && _yScale !== void 0 ? _yScale : 0
145
- });
146
- if (!point) return;
147
- const pointConfig = typeof point === 'object' ? point : {};
159
+ dataY: value,
160
+ fill: pointFill,
161
+ yAxisId: matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId,
162
+ opacity,
163
+ testID: undefined
164
+ };
165
+
166
+ // If points is true, render with defaults
167
+ if (points === true) {
168
+ return /*#__PURE__*/_jsx(Point, _objectSpread({
169
+ onClick: onPointClick,
170
+ transition: transition
171
+ }, defaults), "".concat(seriesId, "-").concat(index));
172
+ }
173
+
174
+ // Call the function with defaults
175
+ const result = points(defaults);
176
+ if (!result) return;
177
+ const pointConfig = result === true ? {} : result;
148
178
  return /*#__PURE__*/_jsx(Point, _objectSpread(_objectSpread({
149
- dataX: xValue,
150
- dataY: value
151
- }, pointConfig), {}, {
152
- fill: (_pointConfig$fill = pointConfig.fill) !== null && _pointConfig$fill !== void 0 ? _pointConfig$fill : stroke,
153
179
  onClick: (_pointConfig$onClick = pointConfig.onClick) !== null && _pointConfig$onClick !== void 0 ? _pointConfig$onClick : onPointClick,
154
- opacity: (_pointConfig$opacity = pointConfig.opacity) !== null && _pointConfig$opacity !== void 0 ? _pointConfig$opacity : opacity
155
- }), "".concat(seriesId, "-renderpoint-").concat(index));
180
+ transition: transition
181
+ }, defaults), pointConfig), "".concat(seriesId, "-").concat(index));
156
182
  })
157
183
  }))]
158
184
  });
@@ -1,4 +1,4 @@
1
- const _excluded = ["series", "showArea", "areaType", "type", "onPointClick", "LineComponent", "AreaComponent", "curve", "renderPoints", "strokeWidth", "showXAxis", "showYAxis", "xAxis", "yAxis", "inset", "children"],
1
+ const _excluded = ["series", "showArea", "areaType", "type", "onPointClick", "LineComponent", "AreaComponent", "curve", "points", "strokeWidth", "strokeOpacity", "connectNulls", "transition", "opacity", "showXAxis", "showYAxis", "xAxis", "yAxis", "inset", "children"],
2
2
  _excluded2 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range"],
3
3
  _excluded3 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range", "id"],
4
4
  _excluded4 = ["id", "data", "label", "color", "yAxisId"];
@@ -26,17 +26,21 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
26
26
  LineComponent,
27
27
  AreaComponent,
28
28
  curve,
29
- renderPoints,
29
+ points,
30
30
  strokeWidth,
31
+ strokeOpacity,
32
+ connectNulls,
33
+ transition,
34
+ opacity,
31
35
  showXAxis,
32
36
  showYAxis,
33
37
  xAxis,
34
38
  yAxis,
35
- inset: userInset,
39
+ inset,
36
40
  children
37
41
  } = _ref,
38
42
  chartProps = _objectWithoutProperties(_ref, _excluded);
39
- const calculatedInset = useMemo(() => getChartInset(userInset, defaultChartInset), [userInset]);
43
+ const calculatedInset = useMemo(() => getChartInset(inset, defaultChartInset), [inset]);
40
44
 
41
45
  // Convert LineSeries to Series for Chart context
42
46
  const chartSeries = useMemo(() => {
@@ -44,7 +48,10 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
44
48
  id: s.id,
45
49
  data: s.data,
46
50
  label: s.label,
47
- color: s.color
51
+ color: s.color,
52
+ yAxisId: s.yAxisId,
53
+ stackId: s.stackId,
54
+ gradient: s.gradient
48
55
  }));
49
56
  }, [series]);
50
57
 
@@ -95,6 +102,7 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
95
102
  children: [showXAxis && /*#__PURE__*/_jsx(XAxis, _objectSpread({}, xAxisVisualProps)), showYAxis && /*#__PURE__*/_jsx(YAxis, _objectSpread({
96
103
  axisId: yAxisId
97
104
  }, yAxisVisualProps)), series === null || series === void 0 ? void 0 : series.map(_ref4 => {
105
+ var _linePropsFromSeries$;
98
106
  let {
99
107
  id,
100
108
  data,
@@ -107,12 +115,16 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
107
115
  AreaComponent: AreaComponent,
108
116
  LineComponent: LineComponent,
109
117
  areaType: areaType,
118
+ connectNulls: connectNulls,
110
119
  curve: curve,
111
120
  onPointClick: onPointClick,
112
- renderPoints: renderPoints,
121
+ opacity: opacity,
122
+ points: points,
113
123
  seriesId: id,
114
124
  showArea: showArea,
125
+ strokeOpacity: strokeOpacity,
115
126
  strokeWidth: strokeWidth,
127
+ transition: (_linePropsFromSeries$ = linePropsFromSeries.transition) !== null && _linePropsFromSeries$ !== void 0 ? _linePropsFromSeries$ : transition,
116
128
  type: type
117
129
  }, linePropsFromSeries), id);
118
130
  }), children]