@coinbase/cds-web-visualization 3.4.0-beta.21 → 3.4.0-beta.23

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 (102) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dts/chart/CartesianChart.d.ts +23 -4
  3. package/dts/chart/CartesianChart.d.ts.map +1 -1
  4. package/dts/chart/Path.d.ts.map +1 -1
  5. package/dts/chart/PeriodSelector.d.ts +22 -5
  6. package/dts/chart/PeriodSelector.d.ts.map +1 -1
  7. package/dts/chart/area/Area.d.ts +7 -0
  8. package/dts/chart/area/Area.d.ts.map +1 -1
  9. package/dts/chart/area/AreaChart.d.ts +3 -3
  10. package/dts/chart/area/AreaChart.d.ts.map +1 -1
  11. package/dts/chart/area/DottedArea.d.ts.map +1 -1
  12. package/dts/chart/area/GradientArea.d.ts.map +1 -1
  13. package/dts/chart/area/SolidArea.d.ts.map +1 -1
  14. package/dts/chart/axis/Axis.d.ts +10 -10
  15. package/dts/chart/axis/Axis.d.ts.map +1 -1
  16. package/dts/chart/axis/XAxis.d.ts +6 -0
  17. package/dts/chart/axis/XAxis.d.ts.map +1 -1
  18. package/dts/chart/axis/YAxis.d.ts +1 -0
  19. package/dts/chart/axis/YAxis.d.ts.map +1 -1
  20. package/dts/chart/bar/Bar.d.ts +4 -3
  21. package/dts/chart/bar/Bar.d.ts.map +1 -1
  22. package/dts/chart/bar/BarChart.d.ts +25 -5
  23. package/dts/chart/bar/BarChart.d.ts.map +1 -1
  24. package/dts/chart/bar/BarPlot.d.ts.map +1 -1
  25. package/dts/chart/bar/BarStack.d.ts +47 -12
  26. package/dts/chart/bar/BarStack.d.ts.map +1 -1
  27. package/dts/chart/bar/BarStackGroup.d.ts +1 -1
  28. package/dts/chart/bar/BarStackGroup.d.ts.map +1 -1
  29. package/dts/chart/bar/DefaultBar.d.ts.map +1 -1
  30. package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -1
  31. package/dts/chart/gradient/Gradient.d.ts +7 -0
  32. package/dts/chart/gradient/Gradient.d.ts.map +1 -1
  33. package/dts/chart/line/DottedLine.d.ts.map +1 -1
  34. package/dts/chart/line/Line.d.ts +7 -0
  35. package/dts/chart/line/Line.d.ts.map +1 -1
  36. package/dts/chart/line/LineChart.d.ts +3 -3
  37. package/dts/chart/line/LineChart.d.ts.map +1 -1
  38. package/dts/chart/line/ReferenceLine.d.ts +1 -0
  39. package/dts/chart/line/ReferenceLine.d.ts.map +1 -1
  40. package/dts/chart/line/SolidLine.d.ts.map +1 -1
  41. package/dts/chart/point/Point.d.ts +7 -0
  42. package/dts/chart/point/Point.d.ts.map +1 -1
  43. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -1
  44. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +2 -1
  45. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -1
  46. package/dts/chart/scrubber/Scrubber.d.ts +8 -0
  47. package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
  48. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -1
  49. package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -1
  50. package/dts/chart/utils/axis.d.ts +23 -8
  51. package/dts/chart/utils/axis.d.ts.map +1 -1
  52. package/dts/chart/utils/bar.d.ts +6 -5
  53. package/dts/chart/utils/bar.d.ts.map +1 -1
  54. package/dts/chart/utils/chart.d.ts +13 -0
  55. package/dts/chart/utils/chart.d.ts.map +1 -1
  56. package/dts/chart/utils/context.d.ts +20 -4
  57. package/dts/chart/utils/context.d.ts.map +1 -1
  58. package/dts/chart/utils/gradient.d.ts +3 -1
  59. package/dts/chart/utils/gradient.d.ts.map +1 -1
  60. package/dts/chart/utils/path.d.ts +20 -0
  61. package/dts/chart/utils/path.d.ts.map +1 -1
  62. package/dts/chart/utils/point.d.ts +7 -0
  63. package/dts/chart/utils/point.d.ts.map +1 -1
  64. package/dts/chart/utils/transition.d.ts +3 -3
  65. package/dts/chart/utils/transition.d.ts.map +1 -1
  66. package/esm/chart/CartesianChart.js +89 -57
  67. package/esm/chart/Path.js +21 -6
  68. package/esm/chart/area/Area.js +19 -9
  69. package/esm/chart/area/AreaChart.js +23 -25
  70. package/esm/chart/area/DottedArea.js +11 -6
  71. package/esm/chart/area/GradientArea.js +11 -6
  72. package/esm/chart/area/SolidArea.js +3 -1
  73. package/esm/chart/axis/XAxis.js +11 -12
  74. package/esm/chart/axis/YAxis.js +4 -4
  75. package/esm/chart/bar/Bar.js +11 -5
  76. package/esm/chart/bar/BarChart.js +34 -31
  77. package/esm/chart/bar/BarPlot.js +6 -3
  78. package/esm/chart/bar/BarStack.js +155 -356
  79. package/esm/chart/bar/BarStackGroup.js +36 -27
  80. package/esm/chart/bar/DefaultBar.js +26 -10
  81. package/esm/chart/bar/DefaultBarStack.js +27 -13
  82. package/esm/chart/gradient/Gradient.js +3 -2
  83. package/esm/chart/line/DottedLine.js +3 -1
  84. package/esm/chart/line/Line.js +29 -16
  85. package/esm/chart/line/LineChart.js +12 -11
  86. package/esm/chart/line/SolidLine.js +3 -1
  87. package/esm/chart/point/Point.js +3 -2
  88. package/esm/chart/scrubber/DefaultScrubberBeacon.js +3 -3
  89. package/esm/chart/scrubber/DefaultScrubberLabel.js +26 -8
  90. package/esm/chart/scrubber/Scrubber.js +36 -28
  91. package/esm/chart/scrubber/ScrubberBeaconGroup.js +49 -32
  92. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +1 -1
  93. package/esm/chart/scrubber/ScrubberProvider.js +44 -39
  94. package/esm/chart/utils/axis.js +44 -13
  95. package/esm/chart/utils/bar.js +6 -4
  96. package/esm/chart/utils/chart.js +18 -5
  97. package/esm/chart/utils/context.js +7 -0
  98. package/esm/chart/utils/gradient.js +6 -4
  99. package/esm/chart/utils/path.js +87 -61
  100. package/esm/chart/utils/point.js +30 -21
  101. package/esm/chart/utils/transition.js +8 -3
  102. package/package.json +5 -5
@@ -31,7 +31,7 @@ export declare const getTransition: (
31
31
  value: Transition | null | undefined,
32
32
  animate: boolean,
33
33
  defaultValue: Transition,
34
- ) => Transition;
34
+ ) => Transition | null;
35
35
  /**
36
36
  * Hook for path animation state and transitions.
37
37
  *
@@ -85,12 +85,12 @@ export declare const usePathTransition: ({
85
85
  * Only used when `initialPath` is provided.
86
86
  * If not provided, falls back to `update`.
87
87
  */
88
- enter?: Transition;
88
+ enter?: Transition | null;
89
89
  /**
90
90
  * Transition for subsequent data update animations.
91
91
  * @default defaultTransition
92
92
  */
93
- update?: Transition;
93
+ update?: Transition | null;
94
94
  };
95
95
  /**
96
96
  * Transition for updates.
@@ -1 +1 @@
1
- {"version":3,"file":"transition.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/transition.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,UAAU,EAGhB,MAAM,eAAe,CAAC;AAEvB;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,UAK/B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,UAG/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,+BAA+B,OAAO,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,4BAA4B,OAAO,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,+BAA+B,EAAE,UAI7C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACxB,OAAO,UAAU,GAAG,IAAI,GAAG,SAAS,EACpC,SAAS,OAAO,EAChB,cAAc,UAAU,KACvB,UAGF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,iBAAiB,GAAI,wDAK/B;IACD;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,WAAW,CAAC,EAAE;QACZ;;;;WAIG;QACH,KAAK,CAAC,EAAE,UAAU,CAAC;QACnB;;;WAGG;QACH,MAAM,CAAC,EAAE,UAAU,CAAC;KACrB,CAAC;IACF;;;OAGG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,KAAG,WAAW,CAAC,MAAM,CAqDrB,CAAC"}
1
+ {"version":3,"file":"transition.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/transition.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,UAAU,EAGhB,MAAM,eAAe,CAAC;AAEvB;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,UAK/B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,UAG/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,+BAA+B,OAAO,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,4BAA4B,OAAO,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,+BAA+B,EAAE,UAI7C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACxB,OAAO,UAAU,GAAG,IAAI,GAAG,SAAS,EACpC,SAAS,OAAO,EAChB,cAAc,UAAU,KACvB,UAAU,GAAG,IAGf,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,iBAAiB,GAAI,wDAK/B;IACD;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,WAAW,CAAC,EAAE;QACZ;;;;WAIG;QACH,KAAK,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;QAC1B;;;WAGG;QACH,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;KAC5B,CAAC;IACF;;;OAGG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,KAAG,WAAW,CAAC,MAAM,CA4DrB,CAAC"}
@@ -1,4 +1,4 @@
1
- const _excluded = ["series", "children", "animate", "xAxis", "yAxis", "inset", "enableScrubbing", "onScrubberPositionChange", "legend", "legendPosition", "legendAccessibilityLabel", "width", "height", "className", "classNames", "style", "styles", "accessibilityLabel"];
1
+ const _excluded = ["series", "children", "layout", "animate", "xAxis", "yAxis", "inset", "enableScrubbing", "onScrubberPositionChange", "legend", "legendPosition", "legendAccessibilityLabel", "width", "height", "className", "classNames", "style", "styles", "accessibilityLabel"];
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; }
@@ -13,13 +13,14 @@ import { Box } from '@coinbase/cds-web/layout';
13
13
  import { ScrubberProvider } from './scrubber/ScrubberProvider';
14
14
  import { CartesianChartProvider } from './ChartProvider';
15
15
  import { Legend } from './legend';
16
- import { defaultAxisId, defaultChartInset, getAxisConfig, getAxisDomain, getAxisRange, getAxisScale, getChartInset, getStackedSeriesData as calculateStackedSeriesData, useTotalAxisPadding } from './utils';
16
+ import { defaultAxisId, defaultHorizontalLayoutChartInset, defaultVerticalLayoutChartInset, getAxisConfig, getAxisRange, getCartesianAxisDomain, getCartesianAxisScale, getChartInset, getStackedSeriesData as calculateStackedSeriesData, useTotalAxisPadding } from './utils';
17
17
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
18
  const focusStylesCss = "cds-focusStylesCss-f4oy7ru";
19
19
  export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
20
20
  let {
21
21
  series,
22
22
  children,
23
+ layout = 'vertical',
23
24
  animate = true,
24
25
  xAxis: xAxisConfigProp,
25
26
  yAxis: yAxisConfigProp,
@@ -44,12 +45,20 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, r
44
45
  height: chartHeight
45
46
  } = useDimensions();
46
47
  const svgRef = useRef(null);
47
- const calculatedInset = useMemo(() => getChartInset(inset, defaultChartInset), [inset]);
48
+ const calculatedInset = useMemo(() => getChartInset(inset, layout === 'horizontal' ? defaultHorizontalLayoutChartInset : defaultVerticalLayoutChartInset), [inset, layout]);
48
49
 
49
50
  // Axis configs store the properties of each axis, such as id, scale type, domain limit, etc.
50
- // We only support 1 x axis but allow for multiple y axes.
51
- const xAxisConfig = useMemo(() => getAxisConfig('x', xAxisConfigProp)[0], [xAxisConfigProp]);
51
+ const xAxisConfig = useMemo(() => getAxisConfig('x', xAxisConfigProp), [xAxisConfigProp]);
52
52
  const yAxisConfig = useMemo(() => getAxisConfig('y', yAxisConfigProp), [yAxisConfigProp]);
53
+
54
+ // Horizontal layout supports multiple value axes on x, but only a single category axis on y.
55
+ // Vertical layout keeps a single x-axis to preserve existing behavior.
56
+ if (layout === 'horizontal' && yAxisConfig.length > 1) {
57
+ throw new Error('When layout="horizontal", only one y-axis is supported. See https://cds.coinbase.com/components/charts/CartesianChart.');
58
+ }
59
+ if (layout !== 'horizontal' && xAxisConfig.length > 1) {
60
+ throw new Error('Multiple x-axes are only supported when layout="horizontal". See https://cds.coinbase.com/components/charts/CartesianChart.');
61
+ }
53
62
  const {
54
63
  renderedAxes,
55
64
  registerAxis,
@@ -79,50 +88,64 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, r
79
88
  };
80
89
  }, [chartHeight, chartWidth, calculatedInset, axisPadding]);
81
90
  const {
82
- xAxis,
83
- xScale
91
+ xAxes,
92
+ xScales
84
93
  } = useMemo(() => {
94
+ const axes = new Map();
95
+ const scales = new Map();
85
96
  if (!chartRect || chartRect.width <= 0 || chartRect.height <= 0) return {
86
- xAxis: undefined,
87
- xScale: undefined
88
- };
89
- const domain = getAxisDomain(xAxisConfig, series !== null && series !== void 0 ? series : [], 'x');
90
- const range = getAxisRange(xAxisConfig, chartRect, 'x');
91
- const axisConfig = {
92
- scaleType: xAxisConfig.scaleType,
93
- domain,
94
- range,
95
- data: xAxisConfig.data,
96
- categoryPadding: xAxisConfig.categoryPadding,
97
- domainLimit: xAxisConfig.domainLimit
97
+ xAxes: axes,
98
+ xScales: scales
98
99
  };
100
+ xAxisConfig.forEach(axisParam => {
101
+ var _axisParam$id, _series$filter, _axisParam$domainLimi;
102
+ const axisId = (_axisParam$id = axisParam.id) !== null && _axisParam$id !== void 0 ? _axisParam$id : defaultAxisId;
99
103
 
100
- // Create the scale
101
- const scale = getAxisScale({
102
- config: axisConfig,
103
- type: 'x',
104
- range: axisConfig.range,
105
- dataDomain: axisConfig.domain
106
- });
107
- if (!scale) return {
108
- xAxis: undefined,
109
- xScale: undefined
110
- };
104
+ // Get relevant series data
105
+ const relevantSeries = xAxisConfig.length > 1 ? (_series$filter = series === null || series === void 0 ? void 0 : series.filter(s => {
106
+ var _s$xAxisId;
107
+ return ((_s$xAxisId = s.xAxisId) !== null && _s$xAxisId !== void 0 ? _s$xAxisId : defaultAxisId) === axisId;
108
+ })) !== null && _series$filter !== void 0 ? _series$filter : [] : series !== null && series !== void 0 ? series : [];
111
109
 
112
- // Update axis config with actual scale domain (after .nice() or other adjustments)
113
- const scaleDomain = scale.domain();
114
- const actualDomain = Array.isArray(scaleDomain) && scaleDomain.length === 2 ? {
115
- min: scaleDomain[0],
116
- max: scaleDomain[1]
117
- } : axisConfig.domain;
118
- const finalAxisConfig = _objectSpread(_objectSpread({}, axisConfig), {}, {
119
- domain: actualDomain
110
+ // Calculate domain and range
111
+ const dataDomain = getCartesianAxisDomain(axisParam, relevantSeries, 'x', layout);
112
+ const range = getAxisRange(axisParam, chartRect, 'x');
113
+ const axisConfig = {
114
+ scaleType: axisParam.scaleType,
115
+ domain: dataDomain,
116
+ range,
117
+ data: axisParam.data,
118
+ categoryPadding: axisParam.categoryPadding,
119
+ domainLimit: (_axisParam$domainLimi = axisParam.domainLimit) !== null && _axisParam$domainLimi !== void 0 ? _axisParam$domainLimi : layout === 'horizontal' ? 'nice' : 'strict'
120
+ };
121
+
122
+ // Create the scale
123
+ const scale = getCartesianAxisScale({
124
+ config: axisConfig,
125
+ type: 'x',
126
+ range: axisConfig.range,
127
+ dataDomain: axisConfig.domain,
128
+ layout
129
+ });
130
+ if (scale) {
131
+ scales.set(axisId, scale);
132
+
133
+ // Update axis config with actual scale domain (after .nice() or other adjustments)
134
+ const scaleDomain = scale.domain();
135
+ const actualDomain = Array.isArray(scaleDomain) && scaleDomain.length === 2 ? {
136
+ min: scaleDomain[0],
137
+ max: scaleDomain[1]
138
+ } : axisConfig.domain;
139
+ axes.set(axisId, _objectSpread(_objectSpread({}, axisConfig), {}, {
140
+ domain: actualDomain
141
+ }));
142
+ }
120
143
  });
121
144
  return {
122
- xAxis: finalAxisConfig,
123
- xScale: scale
145
+ xAxes: axes,
146
+ xScales: scales
124
147
  };
125
- }, [xAxisConfig, series, chartRect]);
148
+ }, [xAxisConfig, series, chartRect, layout]);
126
149
  const {
127
150
  yAxes,
128
151
  yScales
@@ -134,17 +157,17 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, r
134
157
  yScales: scales
135
158
  };
136
159
  yAxisConfig.forEach(axisParam => {
137
- var _axisParam$id, _series$filter, _axisParam$domainLimi;
138
- const axisId = (_axisParam$id = axisParam.id) !== null && _axisParam$id !== void 0 ? _axisParam$id : defaultAxisId;
160
+ var _axisParam$id2, _series$filter2, _axisParam$domainLimi2;
161
+ const axisId = (_axisParam$id2 = axisParam.id) !== null && _axisParam$id2 !== void 0 ? _axisParam$id2 : defaultAxisId;
139
162
 
140
163
  // Get relevant series data
141
- const relevantSeries = (_series$filter = series === null || series === void 0 ? void 0 : series.filter(s => {
164
+ const relevantSeries = yAxisConfig.length > 1 ? (_series$filter2 = series === null || series === void 0 ? void 0 : series.filter(s => {
142
165
  var _s$yAxisId;
143
166
  return ((_s$yAxisId = s.yAxisId) !== null && _s$yAxisId !== void 0 ? _s$yAxisId : defaultAxisId) === axisId;
144
- })) !== null && _series$filter !== void 0 ? _series$filter : [];
167
+ })) !== null && _series$filter2 !== void 0 ? _series$filter2 : [] : series !== null && series !== void 0 ? series : [];
145
168
 
146
169
  // Calculate domain and range
147
- const dataDomain = getAxisDomain(axisParam, relevantSeries, 'y');
170
+ const dataDomain = getCartesianAxisDomain(axisParam, relevantSeries, 'y', layout);
148
171
  const range = getAxisRange(axisParam, chartRect, 'y');
149
172
  const axisConfig = {
150
173
  scaleType: axisParam.scaleType,
@@ -152,15 +175,16 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, r
152
175
  range,
153
176
  data: axisParam.data,
154
177
  categoryPadding: axisParam.categoryPadding,
155
- domainLimit: (_axisParam$domainLimi = axisParam.domainLimit) !== null && _axisParam$domainLimi !== void 0 ? _axisParam$domainLimi : 'nice'
178
+ domainLimit: (_axisParam$domainLimi2 = axisParam.domainLimit) !== null && _axisParam$domainLimi2 !== void 0 ? _axisParam$domainLimi2 : layout === 'horizontal' ? 'strict' : 'nice'
156
179
  };
157
180
 
158
181
  // Create the scale
159
- const scale = getAxisScale({
182
+ const scale = getCartesianAxisScale({
160
183
  config: axisConfig,
161
184
  type: 'y',
162
185
  range: axisConfig.range,
163
- dataDomain: axisConfig.domain
186
+ dataDomain: axisConfig.domain,
187
+ layout
164
188
  });
165
189
  if (scale) {
166
190
  scales.set(axisId, scale);
@@ -180,10 +204,10 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, r
180
204
  yAxes: axes,
181
205
  yScales: scales
182
206
  };
183
- }, [yAxisConfig, series, chartRect]);
184
- const getXAxis = useCallback(() => xAxis, [xAxis]);
207
+ }, [yAxisConfig, series, chartRect, layout]);
208
+ const getXAxis = useCallback(id => xAxes.get(id !== null && id !== void 0 ? id : defaultAxisId), [xAxes]);
185
209
  const getYAxis = useCallback(id => yAxes.get(id !== null && id !== void 0 ? id : defaultAxisId), [yAxes]);
186
- const getXScale = useCallback(() => xScale, [xScale]);
210
+ const getXScale = useCallback(id => xScales.get(id !== null && id !== void 0 ? id : defaultAxisId), [xScales]);
187
211
  const getYScale = useCallback(id => yScales.get(id !== null && id !== void 0 ? id : defaultAxisId), [yScales]);
188
212
  const getSeries = useCallback(seriesId => series === null || series === void 0 ? void 0 : series.find(s => s.id === seriesId), [series]);
189
213
  const stackedDataMap = useMemo(() => {
@@ -194,10 +218,17 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, r
194
218
  if (!seriesId) return undefined;
195
219
  return stackedDataMap.get(seriesId);
196
220
  }, [stackedDataMap]);
221
+ const categoryAxisIsX = useMemo(() => {
222
+ return layout !== 'horizontal';
223
+ }, [layout]);
224
+ const categoryAxisConfig = useMemo(() => {
225
+ var _xAxisConfig$, _yAxisConfig$;
226
+ return categoryAxisIsX ? (_xAxisConfig$ = xAxisConfig[0]) !== null && _xAxisConfig$ !== void 0 ? _xAxisConfig$ : yAxisConfig[0] : (_yAxisConfig$ = yAxisConfig[0]) !== null && _yAxisConfig$ !== void 0 ? _yAxisConfig$ : xAxisConfig[0];
227
+ }, [categoryAxisIsX, xAxisConfig, yAxisConfig]);
197
228
  const dataLength = useMemo(() => {
198
- // If xAxis has categorical data, use that length
199
- if (xAxisConfig.data && xAxisConfig.data.length > 0) {
200
- return xAxisConfig.data.length;
229
+ // If category axis has categorical data, use that length
230
+ if (categoryAxisConfig.data && categoryAxisConfig.data.length > 0) {
231
+ return categoryAxisConfig.data.length;
201
232
  }
202
233
 
203
234
  // Otherwise, find the longest series
@@ -207,7 +238,7 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, r
207
238
  const seriesData = getStackedSeriesData(s.id);
208
239
  return Math.max(max, (_seriesData$length = seriesData === null || seriesData === void 0 ? void 0 : seriesData.length) !== null && _seriesData$length !== void 0 ? _seriesData$length : 0);
209
240
  }, 0);
210
- }, [xAxisConfig.data, series, getStackedSeriesData]);
241
+ }, [categoryAxisConfig, series, getStackedSeriesData]);
211
242
  const getAxisBounds = useCallback(axisId => {
212
243
  const axis = renderedAxes.get(axisId);
213
244
  if (!axis || !chartRect) return;
@@ -256,6 +287,7 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, r
256
287
  }
257
288
  }, [renderedAxes, chartRect, calculatedInset]);
258
289
  const contextValue = useMemo(() => ({
290
+ layout,
259
291
  series: series !== null && series !== void 0 ? series : [],
260
292
  getSeries,
261
293
  getSeriesData: getStackedSeriesData,
@@ -271,7 +303,7 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, r
271
303
  registerAxis,
272
304
  unregisterAxis,
273
305
  getAxisBounds
274
- }), [series, getSeries, getStackedSeriesData, animate, chartWidth, chartHeight, getXAxis, getYAxis, getXScale, getYScale, chartRect, dataLength, registerAxis, unregisterAxis, getAxisBounds]);
306
+ }), [layout, series, getSeries, getStackedSeriesData, animate, chartWidth, chartHeight, getXAxis, getYAxis, getXScale, getYScale, chartRect, dataLength, registerAxis, unregisterAxis, getAxisBounds]);
275
307
  const rootClassNames = useMemo(() => cx(className, classNames === null || classNames === void 0 ? void 0 : classNames.root), [className, classNames]);
276
308
  const rootStyles = useMemo(() => _objectSpread(_objectSpread({}, style), styles === null || styles === void 0 ? void 0 : styles.root), [style, styles === null || styles === void 0 ? void 0 : styles.root]);
277
309
  const legendElement = useMemo(() => {
package/esm/chart/Path.js CHANGED
@@ -49,8 +49,10 @@ export const Path = /*#__PURE__*/memo(_ref2 => {
49
49
  const context = useCartesianChartContext();
50
50
  const rect = clipRect !== undefined ? clipRect : context.drawingArea;
51
51
  const animate = animateProp !== null && animateProp !== void 0 ? animateProp : context.animate;
52
+ const clipPath = rect !== null ? "url(#".concat(clipPathId, ")") : undefined;
52
53
  const enterTransition = useMemo(() => getTransition(transitions === null || transitions === void 0 ? void 0 : transitions.enter, animate, defaultPathEnterTransition), [animate, transitions === null || transitions === void 0 ? void 0 : transitions.enter]);
53
54
  const updateTransition = useMemo(() => getTransition((transitions === null || transitions === void 0 ? void 0 : transitions.update) !== undefined ? transitions.update : transition, animate, defaultTransition), [animate, transitions === null || transitions === void 0 ? void 0 : transitions.update, transition]);
55
+ const shouldAnimateClip = animate && enterTransition !== null;
54
56
 
55
57
  // The clip offset provides extra padding to prevent path from being cut off
56
58
  // Area charts typically use offset=0 for exact clipping, while lines use offset=2 for breathing room
@@ -58,26 +60,39 @@ export const Path = /*#__PURE__*/memo(_ref2 => {
58
60
 
59
61
  const clipPathAnimation = useMemo(() => {
60
62
  if (rect === null) return;
63
+ const categoryAxisIsX = context.layout !== 'horizontal';
64
+ const fullWidth = rect.width + totalOffset;
65
+ const fullHeight = rect.height + totalOffset;
61
66
  return {
62
67
  hidden: {
63
- width: 0
68
+ width: categoryAxisIsX ? 0 : fullWidth,
69
+ height: categoryAxisIsX ? fullHeight : 0
64
70
  },
65
71
  visible: {
66
- width: rect.width + totalOffset,
67
- transition: enterTransition
72
+ width: fullWidth,
73
+ height: fullHeight,
74
+ transition: {
75
+ type: 'timing',
76
+ duration: pathEnterTransitionDuration
77
+ }
68
78
  }
69
79
  };
70
- }, [rect, totalOffset, enterTransition]);
71
- const clipPath = useMemo(() => rect !== null ? "url(#".concat(clipPathId, ")") : undefined, [rect, clipPathId]);
80
+ }, [rect, totalOffset, context.layout]);
72
81
  return /*#__PURE__*/_jsxs(_Fragment, {
73
82
  children: [rect !== null && /*#__PURE__*/_jsx("defs", {
74
83
  children: /*#__PURE__*/_jsx("clipPath", {
75
84
  id: clipPathId,
76
- children: /*#__PURE__*/_jsx(motion.rect, {
85
+ children: shouldAnimateClip ? /*#__PURE__*/_jsx(motion.rect, {
77
86
  animate: "visible",
78
87
  height: rect.height + totalOffset,
79
88
  initial: "hidden",
80
89
  variants: clipPathAnimation,
90
+ width: rect.width + totalOffset,
91
+ x: rect.x - clipOffset,
92
+ y: rect.y - clipOffset
93
+ }) : /*#__PURE__*/_jsx("rect", {
94
+ height: rect.height + totalOffset,
95
+ width: rect.width + totalOffset,
81
96
  x: rect.x - clipOffset,
82
97
  y: rect.y - clipOffset
83
98
  })
@@ -21,33 +21,42 @@ export const Area = /*#__PURE__*/memo(_ref => {
21
21
  animate
22
22
  } = _ref;
23
23
  const {
24
+ layout,
24
25
  getSeries,
25
26
  getSeriesData,
26
27
  getXScale,
27
28
  getYScale,
28
- getXAxis
29
+ getXAxis,
30
+ getYAxis
29
31
  } = useCartesianChartContext();
30
32
  const matchedSeries = useMemo(() => getSeries(seriesId), [seriesId, getSeries]);
31
33
  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]);
32
34
  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]);
33
35
  const sourceData = useMemo(() => getSeriesData(seriesId), [seriesId, getSeriesData]);
34
- const xAxis = getXAxis();
35
- const xScale = getXScale();
36
+ const xAxis = getXAxis(matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.xAxisId);
37
+ const xScale = getXScale(matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.xAxisId);
36
38
  const yScale = getYScale(matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId);
39
+ const yAxis = getYAxis(matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId);
40
+ const categoryAxisIsX = useMemo(() => {
41
+ return layout !== 'horizontal';
42
+ }, [layout]);
43
+ const categoryAxis = useMemo(() => {
44
+ return categoryAxisIsX ? xAxis : yAxis;
45
+ }, [categoryAxisIsX, xAxis, yAxis]);
37
46
  const area = useMemo(() => {
38
47
  if (!sourceData || sourceData.length === 0 || !xScale || !yScale) return '';
39
-
40
- // Get numeric x-axis data if available
41
- const xData = xAxis !== null && xAxis !== void 0 && xAxis.data && Array.isArray(xAxis.data) && typeof xAxis.data[0] === 'number' ? xAxis.data : undefined;
48
+ const indexData = categoryAxis !== null && categoryAxis !== void 0 && categoryAxis.data && Array.isArray(categoryAxis.data) && typeof categoryAxis.data[0] === 'number' ? categoryAxis.data : undefined;
42
49
  return getAreaPath({
43
50
  data: sourceData,
44
51
  xScale,
45
52
  yScale,
46
53
  curve,
47
- xData,
48
- connectNulls
54
+ xData: categoryAxisIsX ? indexData : undefined,
55
+ yData: !categoryAxisIsX ? indexData : undefined,
56
+ connectNulls,
57
+ layout
49
58
  });
50
- }, [sourceData, xScale, yScale, curve, xAxis === null || xAxis === void 0 ? void 0 : xAxis.data, connectNulls]);
59
+ }, [sourceData, xScale, yScale, curve, categoryAxis, categoryAxisIsX, connectNulls, layout]);
51
60
  const AreaComponent = useMemo(() => {
52
61
  if (AreaComponentProp) {
53
62
  return AreaComponentProp;
@@ -72,6 +81,7 @@ export const Area = /*#__PURE__*/memo(_ref => {
72
81
  gradient: gradient,
73
82
  transition: transition,
74
83
  transitions: transitions,
84
+ xAxisId: matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.xAxisId,
75
85
  yAxisId: matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId
76
86
  });
77
87
  });
@@ -1,8 +1,8 @@
1
1
  const _excluded = ["series", "stacked", "AreaComponent", "curve", "fillOpacity", "type", "connectNulls", "transitions", "transition", "LineComponent", "strokeWidth", "showXAxis", "showYAxis", "showLines", "lineType", "xAxis", "yAxis", "inset", "children"],
2
- _excluded2 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range"],
2
+ _excluded2 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range", "id"],
3
3
  _excluded3 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range", "id"],
4
- _excluded4 = ["id", "data", "label", "color", "yAxisId", "opacity", "LineComponent", "stackId", "legendShape", "transition"],
5
- _excluded5 = ["id", "data", "label", "color", "yAxisId", "fill", "fillOpacity", "stackId", "legendShape", "type", "lineType", "transition"];
4
+ _excluded4 = ["id", "data", "label", "color", "yAxisId", "opacity", "LineComponent", "stackId", "legendShape"],
5
+ _excluded5 = ["id", "data", "label", "color", "yAxisId", "fill", "fillOpacity", "stackId", "legendShape", "type"];
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; }
@@ -14,7 +14,7 @@ import { forwardRef, memo, useMemo } from 'react';
14
14
  import { XAxis, YAxis } from '../axis';
15
15
  import { CartesianChart } from '../CartesianChart';
16
16
  import { Line } from '../line/Line';
17
- import { defaultChartInset, defaultStackId, getChartInset } from '../utils';
17
+ import { defaultStackId } from '../utils';
18
18
  import { Area } from './Area';
19
19
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
20
  export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
@@ -40,8 +40,6 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
40
40
  children
41
41
  } = _ref,
42
42
  chartProps = _objectWithoutProperties(_ref, _excluded);
43
- const calculatedInset = useMemo(() => getChartInset(inset, defaultChartInset), [inset]);
44
-
45
43
  // Convert AreaSeries to Series for Chart context
46
44
  const chartSeries = useMemo(() => {
47
45
  return series === null || series === void 0 ? void 0 : series.map(s => ({
@@ -49,6 +47,7 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
49
47
  data: s.data,
50
48
  label: s.label,
51
49
  color: s.color,
50
+ xAxisId: s.xAxisId,
52
51
  yAxisId: s.yAxisId,
53
52
  stackId: s.stackId,
54
53
  gradient: s.gradient
@@ -73,7 +72,8 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
73
72
  categoryPadding: xCategoryPadding,
74
73
  domain: xDomain,
75
74
  domainLimit: xDomainLimit,
76
- range: xRange
75
+ range: xRange,
76
+ id: xAxisId
77
77
  } = _ref2,
78
78
  xAxisVisualProps = _objectWithoutProperties(_ref2, _excluded2);
79
79
  const _ref3 = yAxis || {},
@@ -87,6 +87,13 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
87
87
  id: yAxisId
88
88
  } = _ref3,
89
89
  yAxisVisualProps = _objectWithoutProperties(_ref3, _excluded3);
90
+ const hasNegativeValues = useMemo(() => {
91
+ if (!series) return false;
92
+ return series.some(s => {
93
+ var _s$data;
94
+ return (_s$data = s.data) === null || _s$data === void 0 ? void 0 : _s$data.some(value => typeof value === 'number' && value < 0 || Array.isArray(value) && value.some(v => typeof v === 'number' && v < 0));
95
+ });
96
+ }, [series]);
90
97
  const xAxisConfig = {
91
98
  scaleType: xScaleType,
92
99
  data: xData,
@@ -95,13 +102,6 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
95
102
  domainLimit: xDomainLimit,
96
103
  range: xRange
97
104
  };
98
- const hasNegativeValues = useMemo(() => {
99
- if (!series) return false;
100
- return series.some(s => {
101
- var _s$data;
102
- return (_s$data = s.data) === null || _s$data === void 0 ? void 0 : _s$data.some(value => typeof value === 'number' && value < 0 || Array.isArray(value) && value.some(v => typeof v === 'number' && v < 0));
103
- });
104
- }, [series]);
105
105
 
106
106
  // Set default min domain to 0 for area chart, but only if there are no negative values
107
107
  const yAxisConfig = {
@@ -116,11 +116,13 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
116
116
  };
117
117
  return /*#__PURE__*/_jsxs(CartesianChart, _objectSpread(_objectSpread({}, chartProps), {}, {
118
118
  ref: ref,
119
- inset: calculatedInset,
119
+ inset: inset,
120
120
  series: seriesToRender,
121
121
  xAxis: xAxisConfig,
122
122
  yAxis: yAxisConfig,
123
- children: [showXAxis && /*#__PURE__*/_jsx(XAxis, _objectSpread({}, xAxisVisualProps)), showYAxis && /*#__PURE__*/_jsx(YAxis, _objectSpread({
123
+ children: [showXAxis && /*#__PURE__*/_jsx(XAxis, _objectSpread({
124
+ axisId: xAxisId
125
+ }, xAxisVisualProps)), showYAxis && /*#__PURE__*/_jsx(YAxis, _objectSpread({
124
126
  axisId: yAxisId
125
127
  }, yAxisVisualProps)), series === null || series === void 0 ? void 0 : series.map(_ref4 => {
126
128
  let {
@@ -132,8 +134,7 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
132
134
  opacity,
133
135
  LineComponent,
134
136
  stackId,
135
- legendShape,
136
- transition: seriesTransition
137
+ legendShape
137
138
  } = _ref4,
138
139
  areaPropsFromSeries = _objectWithoutProperties(_ref4, _excluded4);
139
140
  return /*#__PURE__*/_jsx(Area, _objectSpread({
@@ -142,7 +143,7 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
142
143
  curve: curve,
143
144
  fillOpacity: fillOpacity,
144
145
  seriesId: id,
145
- transition: seriesTransition !== null && seriesTransition !== void 0 ? seriesTransition : transition,
146
+ transition: transition,
146
147
  transitions: transitions,
147
148
  type: type
148
149
  }, areaPropsFromSeries), id);
@@ -157,10 +158,7 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
157
158
  fillOpacity,
158
159
  stackId,
159
160
  legendShape,
160
- type,
161
- // Area type (don't pass to Line)
162
- lineType: seriesLineType,
163
- transition: seriesTransition
161
+ type // Area type (don't pass to Line)
164
162
  } = _ref5,
165
163
  otherPropsFromSeries = _objectWithoutProperties(_ref5, _excluded5);
166
164
  return /*#__PURE__*/_jsx(Line, _objectSpread({
@@ -169,9 +167,9 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
169
167
  curve: curve,
170
168
  seriesId: id,
171
169
  strokeWidth: strokeWidth,
172
- transition: seriesTransition !== null && seriesTransition !== void 0 ? seriesTransition : transition,
170
+ transition: transition,
173
171
  transitions: transitions,
174
- type: seriesLineType !== null && seriesLineType !== void 0 ? seriesLineType : lineType
172
+ type: lineType
175
173
  }, otherPropsFromSeries), id);
176
174
  })), children]
177
175
  }));
@@ -1,4 +1,4 @@
1
- const _excluded = ["d", "fill", "patternSize", "dotSize", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "gradient", "animate", "transitions", "transition"];
1
+ const _excluded = ["d", "fill", "patternSize", "dotSize", "peakOpacity", "baselineOpacity", "baseline", "xAxisId", "yAxisId", "gradient", "animate", "transitions", "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; }
@@ -27,6 +27,7 @@ export const DottedArea = /*#__PURE__*/memo(_ref => {
27
27
  peakOpacity = 1,
28
28
  baselineOpacity = 0,
29
29
  baseline,
30
+ xAxisId,
30
31
  yAxisId,
31
32
  gradient: gradientProp,
32
33
  animate,
@@ -35,19 +36,22 @@ export const DottedArea = /*#__PURE__*/memo(_ref => {
35
36
  } = _ref,
36
37
  pathProps = _objectWithoutProperties(_ref, _excluded);
37
38
  const {
39
+ layout,
40
+ getXAxis,
38
41
  getYAxis
39
42
  } = useCartesianChartContext();
40
43
  const patternId = useId();
41
44
  const gradientId = useId();
42
45
  const maskId = useId();
43
46
  const dotCenterPosition = patternSize / 2;
44
- const yAxisConfig = getYAxis(yAxisId);
47
+ const valueAxisConfig = layout !== 'horizontal' ? getYAxis(yAxisId) : getXAxis(xAxisId);
48
+ const gradientAxis = layout !== 'horizontal' ? 'y' : 'x';
45
49
  const gradient = useMemo(() => {
46
50
  if (gradientProp) return gradientProp;
47
- if (!yAxisConfig) return;
48
- const baselineValue = getBaseline(yAxisConfig.domain, baseline);
49
- return createGradient(yAxisConfig.domain, baselineValue, fill, peakOpacity, baselineOpacity);
50
- }, [gradientProp, yAxisConfig, fill, baseline, peakOpacity, baselineOpacity]);
51
+ if (!valueAxisConfig) return;
52
+ const baselineValue = getBaseline(valueAxisConfig.domain, baseline);
53
+ return createGradient(valueAxisConfig.domain, baselineValue, fill, peakOpacity, baselineOpacity, gradientAxis);
54
+ }, [gradientProp, valueAxisConfig, fill, baseline, peakOpacity, baselineOpacity, gradientAxis]);
51
55
  return /*#__PURE__*/_jsxs("g", {
52
56
  children: [/*#__PURE__*/_jsxs("defs", {
53
57
  children: [/*#__PURE__*/_jsx("pattern", {
@@ -77,6 +81,7 @@ export const DottedArea = /*#__PURE__*/memo(_ref => {
77
81
  gradient: gradient,
78
82
  id: gradientId,
79
83
  transition: (_transitions$update = transitions === null || transitions === void 0 ? void 0 : transitions.update) !== null && _transitions$update !== void 0 ? _transitions$update : transition,
84
+ xAxisId: xAxisId,
80
85
  yAxisId: yAxisId
81
86
  })]
82
87
  }), /*#__PURE__*/_jsx(Path, _objectSpread({
@@ -1,4 +1,4 @@
1
- const _excluded = ["d", "fill", "fillOpacity", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "gradient", "animate", "transitions", "transition"];
1
+ const _excluded = ["d", "fill", "fillOpacity", "peakOpacity", "baselineOpacity", "baseline", "xAxisId", "yAxisId", "gradient", "animate", "transitions", "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; }
@@ -29,6 +29,7 @@ export const GradientArea = /*#__PURE__*/memo(_ref => {
29
29
  peakOpacity = 0.3,
30
30
  baselineOpacity = 0,
31
31
  baseline,
32
+ xAxisId,
32
33
  yAxisId,
33
34
  gradient: gradientProp,
34
35
  animate,
@@ -37,16 +38,19 @@ export const GradientArea = /*#__PURE__*/memo(_ref => {
37
38
  } = _ref,
38
39
  pathProps = _objectWithoutProperties(_ref, _excluded);
39
40
  const {
41
+ layout,
42
+ getXAxis,
40
43
  getYAxis
41
44
  } = useCartesianChartContext();
42
45
  const patternId = useId();
43
- const yAxisConfig = getYAxis(yAxisId);
46
+ const valueAxisConfig = layout !== 'horizontal' ? getYAxis(yAxisId) : getXAxis(xAxisId);
47
+ const gradientAxis = layout !== 'horizontal' ? 'y' : 'x';
44
48
  const gradient = useMemo(() => {
45
49
  if (gradientProp) return gradientProp;
46
- if (!yAxisConfig) return;
47
- const baselineValue = getBaseline(yAxisConfig.domain, baseline);
48
- return createGradient(yAxisConfig.domain, baselineValue, fill, peakOpacity, baselineOpacity);
49
- }, [gradientProp, yAxisConfig, fill, baseline, peakOpacity, baselineOpacity]);
50
+ if (!valueAxisConfig) return;
51
+ const baselineValue = getBaseline(valueAxisConfig.domain, baseline);
52
+ return createGradient(valueAxisConfig.domain, baselineValue, fill, peakOpacity, baselineOpacity, gradientAxis);
53
+ }, [gradientProp, valueAxisConfig, fill, baseline, peakOpacity, baselineOpacity, gradientAxis]);
50
54
  return /*#__PURE__*/_jsxs(_Fragment, {
51
55
  children: [gradient && /*#__PURE__*/_jsx("defs", {
52
56
  children: /*#__PURE__*/_jsx(Gradient, {
@@ -54,6 +58,7 @@ export const GradientArea = /*#__PURE__*/memo(_ref => {
54
58
  gradient: gradient,
55
59
  id: patternId,
56
60
  transition: (_transitions$update = transitions === null || transitions === void 0 ? void 0 : transitions.update) !== null && _transitions$update !== void 0 ? _transitions$update : transition,
61
+ xAxisId: xAxisId,
57
62
  yAxisId: yAxisId
58
63
  })
59
64
  }), /*#__PURE__*/_jsx(Path, _objectSpread({