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

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 (175) hide show
  1. package/CHANGELOG.md +53 -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 +109 -63
  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 +2 -2
  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 +87 -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/axis.d.ts +25 -1
  87. package/dts/chart/utils/axis.d.ts.map +1 -1
  88. package/dts/chart/utils/chart.d.ts +27 -7
  89. package/dts/chart/utils/chart.d.ts.map +1 -1
  90. package/dts/chart/utils/context.d.ts +6 -0
  91. package/dts/chart/utils/context.d.ts.map +1 -1
  92. package/dts/chart/utils/gradient.d.ts +104 -0
  93. package/dts/chart/utils/gradient.d.ts.map +1 -0
  94. package/dts/chart/utils/index.d.ts +4 -0
  95. package/dts/chart/utils/index.d.ts.map +1 -1
  96. package/dts/chart/utils/interpolate.d.ts +112 -0
  97. package/dts/chart/utils/interpolate.d.ts.map +1 -0
  98. package/dts/chart/utils/path.d.ts +24 -1
  99. package/dts/chart/utils/path.d.ts.map +1 -1
  100. package/dts/chart/utils/point.d.ts +40 -7
  101. package/dts/chart/utils/point.d.ts.map +1 -1
  102. package/dts/chart/utils/scale.d.ts +11 -0
  103. package/dts/chart/utils/scale.d.ts.map +1 -1
  104. package/dts/chart/utils/scrubber.d.ts +39 -0
  105. package/dts/chart/utils/scrubber.d.ts.map +1 -0
  106. package/dts/chart/utils/transition.d.ts +65 -0
  107. package/dts/chart/utils/transition.d.ts.map +1 -0
  108. package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts.map +1 -1
  109. package/esm/chart/CartesianChart.js +140 -85
  110. package/esm/chart/Path.js +53 -47
  111. package/esm/chart/PeriodSelector.js +4 -18
  112. package/esm/chart/area/Area.js +24 -34
  113. package/esm/chart/area/AreaChart.js +24 -15
  114. package/esm/chart/area/DottedArea.js +35 -89
  115. package/esm/chart/area/GradientArea.js +34 -80
  116. package/esm/chart/area/SolidArea.js +29 -11
  117. package/esm/chart/axis/Axis.js +4 -39
  118. package/esm/chart/axis/DefaultAxisTickLabel.js +15 -0
  119. package/esm/chart/axis/XAxis.js +184 -63
  120. package/esm/chart/axis/YAxis.js +190 -57
  121. package/esm/chart/axis/index.js +1 -0
  122. package/esm/chart/bar/Bar.js +3 -1
  123. package/esm/chart/bar/BarChart.js +15 -32
  124. package/esm/chart/bar/BarPlot.js +3 -2
  125. package/esm/chart/bar/BarStack.js +65 -23
  126. package/esm/chart/bar/BarStackGroup.js +7 -17
  127. package/esm/chart/bar/DefaultBar.js +4 -7
  128. package/esm/chart/bar/DefaultBarStack.js +5 -7
  129. package/esm/chart/gradient/Gradient.js +104 -0
  130. package/esm/chart/gradient/index.js +1 -0
  131. package/esm/chart/index.js +2 -1
  132. package/esm/chart/line/DefaultReferenceLineLabel.js +81 -0
  133. package/esm/chart/line/DottedLine.js +38 -17
  134. package/esm/chart/line/Line.js +96 -70
  135. package/esm/chart/line/LineChart.js +18 -6
  136. package/esm/chart/line/ReferenceLine.js +41 -43
  137. package/esm/chart/line/SolidLine.js +36 -15
  138. package/esm/chart/line/index.js +1 -1
  139. package/esm/chart/{line/GradientLine.js → point/DefaultPointLabel.js} +31 -45
  140. package/esm/chart/point/Point.css +2 -0
  141. package/esm/chart/{Point.js → point/Point.js} +66 -57
  142. package/esm/chart/point/index.js +2 -0
  143. package/esm/chart/scrubber/DefaultScrubberBeacon.js +155 -0
  144. package/esm/chart/scrubber/{ScrubberBeaconLabel.js → DefaultScrubberBeaconLabel.js} +23 -10
  145. package/esm/chart/scrubber/DefaultScrubberLabel.js +30 -0
  146. package/esm/chart/scrubber/Scrubber.js +98 -392
  147. package/esm/chart/scrubber/ScrubberBeaconGroup.js +166 -0
  148. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +186 -0
  149. package/esm/chart/scrubber/index.js +3 -1
  150. package/esm/chart/text/ChartText.js +15 -20
  151. package/esm/chart/text/{SmartChartTextGroup.js → ChartTextGroup.js} +4 -3
  152. package/esm/chart/text/index.js +1 -1
  153. package/esm/chart/utils/axis.js +45 -29
  154. package/esm/chart/utils/chart.js +29 -3
  155. package/esm/chart/utils/gradient.js +257 -0
  156. package/esm/chart/utils/index.js +4 -0
  157. package/esm/chart/utils/interpolate.js +644 -0
  158. package/esm/chart/utils/path.js +32 -9
  159. package/esm/chart/utils/point.js +99 -12
  160. package/esm/chart/utils/scale.js +13 -2
  161. package/esm/chart/utils/scrubber.js +132 -0
  162. package/esm/chart/utils/transition.js +111 -0
  163. package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.js +8 -4
  164. package/package.json +9 -9
  165. package/dts/chart/Point.d.ts +0 -153
  166. package/dts/chart/Point.d.ts.map +0 -1
  167. package/dts/chart/line/GradientLine.d.ts +0 -42
  168. package/dts/chart/line/GradientLine.d.ts.map +0 -1
  169. package/dts/chart/scrubber/ScrubberBeacon.d.ts +0 -93
  170. package/dts/chart/scrubber/ScrubberBeacon.d.ts.map +0 -1
  171. package/dts/chart/scrubber/ScrubberBeaconLabel.d.ts +0 -7
  172. package/dts/chart/scrubber/ScrubberBeaconLabel.d.ts.map +0 -1
  173. package/dts/chart/text/SmartChartTextGroup.d.ts.map +0 -1
  174. package/esm/chart/Point.css +0 -2
  175. package/esm/chart/scrubber/ScrubberBeacon.js +0 -195
@@ -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
  });
@@ -1,4 +1,4 @@
1
- const _excluded = ["d", "fill", "fillOpacity", "peakColor", "baselineColor", "peakOpacity", "baselineOpacity", "baseline", "yAxisId"];
1
+ const _excluded = ["d", "fill", "fillOpacity", "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,106 +6,60 @@ 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';
13
+ import { createGradient, getBaseline } from '../utils';
12
14
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
15
  /**
14
- * A customizable gradient area component which uses Path.
16
+ * A customizable gradient area component which uses Path with SVG linearGradient.
17
+ *
18
+ * When no gradient is provided, automatically creates an appropriate gradient:
19
+ * - For data crossing zero: Creates a diverging gradient with peak opacity at both extremes
20
+ * and baseline opacity at zero (or the specified baseline).
21
+ * - For all-positive or all-negative data: Creates a simple gradient from baseline to peak.
15
22
  */
16
23
  export const GradientArea = /*#__PURE__*/memo(_ref => {
17
24
  let {
18
25
  d,
19
26
  fill = 'var(--color-fgPrimary)',
20
27
  fillOpacity = 1,
21
- peakColor,
22
- baselineColor,
23
28
  peakOpacity = 0.3,
24
29
  baselineOpacity = 0,
25
30
  baseline,
26
- yAxisId
31
+ yAxisId,
32
+ gradient: gradientProp,
33
+ animate,
34
+ transition
27
35
  } = _ref,
28
36
  pathProps = _objectWithoutProperties(_ref, _excluded);
29
- const context = useCartesianChartContext();
37
+ const {
38
+ getYAxis
39
+ } = useCartesianChartContext();
30
40
  const patternId = useId();
31
-
32
- // Get the y-scale for the specified axis (or default)
33
- const yScale = context.getYScale(yAxisId);
34
- const yRange = yScale === null || yScale === void 0 ? void 0 : yScale.range();
35
- const yDomain = yScale === null || yScale === void 0 ? void 0 : yScale.domain();
36
-
37
- // Use chart range if available, otherwise fall back to percentage
38
- const useUserSpaceUnits = yRange !== undefined;
39
- const gradientY1 = useUserSpaceUnits ? yRange[1] : '0%';
40
- const gradientY2 = useUserSpaceUnits ? yRange[0] : '100%';
41
-
42
- // Auto-calculate baseline position based on domain
43
- let baselinePosition;
44
- let baselinePercentage;
45
- if (yScale && yDomain) {
46
- const [minValue, maxValue] = yDomain;
47
- let dataBaseline;
48
- if (minValue >= 0) {
49
- // All positive: baseline at min
50
- dataBaseline = minValue;
51
- } else if (maxValue <= 0) {
52
- // All negative: baseline at max
53
- dataBaseline = maxValue;
54
- } else {
55
- // Crosses zero: baseline at 0
56
- dataBaseline = 0;
57
- }
58
- if (useUserSpaceUnits) {
59
- // Get the actual y coordinate for the baseline
60
- const scaledValue = yScale(baseline !== null && baseline !== void 0 ? baseline : dataBaseline);
61
- if (typeof scaledValue === 'number') {
62
- baselinePosition = scaledValue;
63
- }
64
- } else {
65
- // Calculate percentage position
66
- baselinePercentage = "".concat((maxValue - (baseline !== null && baseline !== void 0 ? baseline : dataBaseline)) / (maxValue - minValue) * 100, "%");
67
- }
68
- }
69
- const effectivePeakColor = peakColor !== null && peakColor !== void 0 ? peakColor : fill;
70
- const effectiveBaselineColor = baselineColor !== null && baselineColor !== void 0 ? baselineColor : fill;
41
+ const yAxisConfig = getYAxis(yAxisId);
42
+ const gradient = useMemo(() => {
43
+ if (gradientProp) return gradientProp;
44
+ if (!yAxisConfig) return;
45
+ const baselineValue = getBaseline(yAxisConfig.domain, baseline);
46
+ return createGradient(yAxisConfig.domain, baselineValue, fill, peakOpacity, baselineOpacity);
47
+ }, [gradientProp, yAxisConfig, fill, baseline, peakOpacity, baselineOpacity]);
71
48
  return /*#__PURE__*/_jsxs(_Fragment, {
72
- children: [/*#__PURE__*/_jsx("defs", {
73
- children: /*#__PURE__*/_jsx("linearGradient", {
74
- gradientUnits: useUserSpaceUnits ? 'userSpaceOnUse' : 'objectBoundingBox',
49
+ children: [gradient && /*#__PURE__*/_jsx("defs", {
50
+ children: /*#__PURE__*/_jsx(Gradient, {
51
+ animate: animate,
52
+ gradient: gradient,
75
53
  id: patternId,
76
- x1: useUserSpaceUnits ? 0 : '0%',
77
- x2: useUserSpaceUnits ? 0 : '0%',
78
- y1: gradientY1,
79
- y2: gradientY2,
80
- children: baselinePosition !== undefined || baselinePercentage !== undefined ? /*#__PURE__*/_jsxs(_Fragment, {
81
- children: [/*#__PURE__*/_jsx("stop", {
82
- offset: "0%",
83
- stopColor: effectivePeakColor,
84
- stopOpacity: peakOpacity
85
- }), /*#__PURE__*/_jsx("stop", {
86
- offset: baselinePercentage !== null && baselinePercentage !== void 0 ? baselinePercentage : "".concat((baselinePosition - yRange[1]) / (yRange[0] - yRange[1]) * 100, "%"),
87
- stopColor: effectiveBaselineColor,
88
- stopOpacity: baselineOpacity
89
- }), /*#__PURE__*/_jsx("stop", {
90
- offset: "100%",
91
- stopColor: effectivePeakColor,
92
- stopOpacity: peakOpacity
93
- })]
94
- }) : /*#__PURE__*/_jsxs(_Fragment, {
95
- children: [/*#__PURE__*/_jsx("stop", {
96
- offset: "0%",
97
- stopColor: effectivePeakColor,
98
- stopOpacity: peakOpacity
99
- }), /*#__PURE__*/_jsx("stop", {
100
- offset: "100%",
101
- stopColor: effectiveBaselineColor,
102
- stopOpacity: baselineOpacity
103
- })]
104
- })
54
+ transition: transition,
55
+ yAxisId: yAxisId
105
56
  })
106
57
  }), /*#__PURE__*/_jsx(Path, _objectSpread({
58
+ animate: animate,
107
59
  d: d,
108
- fill: "url(#".concat(patternId, ")")
60
+ fill: gradient ? "url(#".concat(patternId, ")") : fill,
61
+ fillOpacity: fillOpacity,
62
+ transition: transition
109
63
  }, pathProps))]
110
64
  });
111
65
  });
@@ -1,4 +1,4 @@
1
- const _excluded = ["d", "fill", "fillOpacity", "yAxisId", "baseline"];
1
+ const _excluded = ["d", "fill", "fillOpacity", "yAxisId", "animate", "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; }
@@ -6,24 +6,42 @@ 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
14
  * A customizable solid area component which uses Path.
15
+ * When a gradient is provided, renders with gradient fill.
16
+ * Otherwise, renders with solid fill.
14
17
  */
15
18
  export const SolidArea = /*#__PURE__*/memo(_ref => {
16
19
  let {
17
20
  d,
18
- fill,
21
+ fill = 'var(--color-fgPrimary)',
19
22
  fillOpacity = 1,
20
23
  yAxisId,
21
- baseline
24
+ animate,
25
+ transition,
26
+ gradient
22
27
  } = _ref,
23
- props = _objectWithoutProperties(_ref, _excluded);
24
- return /*#__PURE__*/_jsx(Path, _objectSpread({
25
- d: d,
26
- fill: fill,
27
- fillOpacity: fillOpacity
28
- }, props));
28
+ pathProps = _objectWithoutProperties(_ref, _excluded);
29
+ const patternId = useId();
30
+ return /*#__PURE__*/_jsxs(_Fragment, {
31
+ children: [gradient && /*#__PURE__*/_jsx("defs", {
32
+ children: /*#__PURE__*/_jsx(Gradient, {
33
+ animate: animate,
34
+ gradient: gradient,
35
+ id: patternId,
36
+ transition: transition,
37
+ yAxisId: yAxisId
38
+ })
39
+ }), /*#__PURE__*/_jsx(Path, _objectSpread({
40
+ animate: animate,
41
+ d: d,
42
+ fill: gradient ? "url(#".concat(patternId, ")") : fill,
43
+ fillOpacity: fillOpacity,
44
+ transition: transition
45
+ }, pathProps))]
46
+ });
29
47
  });
@@ -1,46 +1,11 @@
1
+ import { accessoryFadeTransitionDuration } from '../utils';
1
2
  export const axisLineStyles = "\n stroke: var(--color-fg);\n stroke-linecap: square;\n stroke-width: 1px;\n";
2
3
  export const axisTickMarkStyles = "\n stroke: var(--color-fg);\n stroke-linecap: square;\n stroke-width: 1px;\n";
3
4
 
4
- /**
5
- * Animation variants for grouped axis tick labels - initial mount
6
- */
7
- export const axisTickLabelsInitialAnimationVariants = {
8
- initial: {
9
- opacity: 0
10
- },
11
- animate: {
12
- opacity: 1,
13
- transition: {
14
- duration: 0.15,
15
- delay: 0.85 // Initial animation: wait 850ms then fade in over 150ms
16
- }
17
- },
18
- exit: {
19
- opacity: 0,
20
- transition: {
21
- duration: 0.15
22
- }
23
- }
24
- };
25
-
26
5
  /**
27
6
  * Animation variants for axis elements - updates (used for both grid lines and tick labels)
28
7
  */
29
- export const axisUpdateAnimationVariants = {
30
- initial: {
31
- opacity: 0
32
- },
33
- animate: {
34
- opacity: 1,
35
- transition: {
36
- duration: 0.15,
37
- delay: 0.15 // For updates: fade out 150ms, then fade in 150ms
38
- }
39
- },
40
- exit: {
41
- opacity: 0,
42
- transition: {
43
- duration: 0.15
44
- }
45
- }
8
+ export const axisUpdateAnimationTransition = {
9
+ duration: accessoryFadeTransitionDuration,
10
+ ease: 'easeOut'
46
11
  };
@@ -0,0 +1,15 @@
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 } from 'react';
7
+ import { ChartText } from '../text';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ /**
10
+ * DefaultAxisTickLabel is the default label component for axis tick labels.
11
+ * Provides standard styling for both X and Y axis tick labels.
12
+ */
13
+ export const DefaultAxisTickLabel = /*#__PURE__*/memo(props => {
14
+ return /*#__PURE__*/_jsx(ChartText, _objectSpread({}, props));
15
+ });