@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
@@ -1,4 +1,4 @@
1
- const _excluded = ["d", "fill", "fillOpacity", "yAxisId", "animate", "transitions", "transition", "gradient"];
1
+ const _excluded = ["d", "fill", "fillOpacity", "xAxisId", "yAxisId", "animate", "transitions", "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; }
@@ -21,6 +21,7 @@ export const SolidArea = /*#__PURE__*/memo(_ref => {
21
21
  d,
22
22
  fill = 'var(--color-fgPrimary)',
23
23
  fillOpacity = 1,
24
+ xAxisId,
24
25
  yAxisId,
25
26
  animate,
26
27
  transitions,
@@ -36,6 +37,7 @@ export const SolidArea = /*#__PURE__*/memo(_ref => {
36
37
  gradient: gradient,
37
38
  id: patternId,
38
39
  transition: (_transitions$update = transitions === null || transitions === void 0 ? void 0 : transitions.update) !== null && _transitions$update !== void 0 ? _transitions$update : transition,
40
+ xAxisId: xAxisId,
39
41
  yAxisId: yAxisId
40
42
  })
41
43
  }), /*#__PURE__*/_jsx(Path, _objectSpread({
@@ -1,4 +1,4 @@
1
- const _excluded = ["position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "TickLabelComponent", "style", "className", "styles", "classNames", "GridLineComponent", "LineComponent", "TickMarkLineComponent", "tickMarkLabelGap", "minTickLabelGap", "showTickMarks", "showLine", "tickMarkSize", "tickInterval", "tickMinStep", "tickMaxStep", "label", "labelGap", "height", "testID", "bandGridLinePlacement", "bandTickMarkPlacement"];
1
+ const _excluded = ["axisId", "position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "TickLabelComponent", "style", "className", "styles", "classNames", "GridLineComponent", "LineComponent", "TickMarkLineComponent", "tickMarkLabelGap", "minTickLabelGap", "showTickMarks", "showLine", "tickMarkSize", "tickInterval", "tickMinStep", "tickMaxStep", "label", "labelGap", "height", "testID", "bandGridLinePlacement", "bandTickMarkPlacement"];
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; }
@@ -24,6 +24,7 @@ const axisTickMarkCss = "cds-axisTickMarkCss-a6j4s2q";
24
24
  const axisLineCss = "cds-axisLineCss-a12llxjj";
25
25
  export const XAxis = /*#__PURE__*/memo(_ref => {
26
26
  let {
27
+ axisId,
27
28
  position = 'bottom',
28
29
  showGrid,
29
30
  requestedTickCount,
@@ -56,6 +57,7 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
56
57
  const registrationId = useId();
57
58
  const {
58
59
  animate,
60
+ layout,
59
61
  getXScale,
60
62
  getXAxis,
61
63
  registerAxis,
@@ -63,8 +65,8 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
63
65
  getAxisBounds,
64
66
  drawingArea
65
67
  } = useCartesianChartContext();
66
- const xScale = getXScale();
67
- const xAxis = getXAxis();
68
+ const xScale = getXScale(axisId);
69
+ const xAxis = getXAxis(axisId);
68
70
  const axisBounds = getAxisBounds(registrationId);
69
71
  useEffect(() => {
70
72
  registerAxis(registrationId, position, height);
@@ -75,15 +77,12 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
75
77
  // If we have string labels and no custom formatter, use the labels
76
78
  const axisData = xAxis === null || xAxis === void 0 ? void 0 : xAxis.data;
77
79
  const hasStringLabels = axisData && Array.isArray(axisData) && typeof axisData[0] === 'string';
78
- let finalValue = value;
79
-
80
- // For band scales with string data, value is an index
81
- if (hasStringLabels && typeof value === 'number' && axisData[value] !== undefined) {
82
- finalValue = axisData[value];
80
+ if (hasStringLabels && !tickLabelFormatter && axisData[value] !== undefined) {
81
+ return axisData[value];
83
82
  }
84
83
 
85
- // Use the formatter (if provided) or the value itself
86
- return (_tickLabelFormatter = tickLabelFormatter === null || tickLabelFormatter === void 0 ? void 0 : tickLabelFormatter(finalValue)) !== null && _tickLabelFormatter !== void 0 ? _tickLabelFormatter : finalValue;
84
+ // Otherwise passes raw index to formatter
85
+ return (_tickLabelFormatter = tickLabelFormatter === null || tickLabelFormatter === void 0 ? void 0 : tickLabelFormatter(value)) !== null && _tickLabelFormatter !== void 0 ? _tickLabelFormatter : value;
87
86
  }, [xAxis === null || xAxis === void 0 ? void 0 : xAxis.data, tickLabelFormatter]);
88
87
  const ticksData = useMemo(() => {
89
88
  if (!xScale) return [];
@@ -105,7 +104,7 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
105
104
  return getAxisTicksData({
106
105
  scaleFunction: xScale,
107
106
  ticks,
108
- requestedTickCount,
107
+ requestedTickCount: requestedTickCount !== null && requestedTickCount !== void 0 ? requestedTickCount : layout === 'horizontal' ? 5 : undefined,
109
108
  categories,
110
109
  possibleTickValues: axisData && Array.isArray(axisData) && typeof axisData[0] === 'string' ? Array.from({
111
110
  length: axisData.length
@@ -116,7 +115,7 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
116
115
  maxStep: tickMaxStep
117
116
  }
118
117
  });
119
- }, [ticks, xScale, requestedTickCount, tickInterval, tickMinStep, tickMaxStep, xAxis === null || xAxis === void 0 ? void 0 : xAxis.data]);
118
+ }, [ticks, xScale, requestedTickCount, tickInterval, tickMinStep, tickMaxStep, xAxis === null || xAxis === void 0 ? void 0 : xAxis.data, layout]);
120
119
  const isBandScale = useMemo(() => {
121
120
  if (!xScale) return false;
122
121
  return isCategoricalScale(xScale);
@@ -55,6 +55,7 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
55
55
  const registrationId = useId();
56
56
  const {
57
57
  animate,
58
+ layout,
58
59
  getYScale,
59
60
  getYAxis,
60
61
  registerAxis,
@@ -75,11 +76,10 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
75
76
  const axisData = yAxis === null || yAxis === void 0 ? void 0 : yAxis.data;
76
77
  const hasStringLabels = axisData && Array.isArray(axisData) && typeof axisData[0] === 'string';
77
78
  if (hasStringLabels && !tickLabelFormatter && axisData[value] !== undefined) {
78
- // Use the string label from the data array
79
79
  return axisData[value];
80
80
  }
81
81
 
82
- // Otherwise use the formatter (if provided) or the value itself
82
+ // Otherwise passes raw index to formatter
83
83
  return (_tickLabelFormatter = tickLabelFormatter === null || tickLabelFormatter === void 0 ? void 0 : tickLabelFormatter(value)) !== null && _tickLabelFormatter !== void 0 ? _tickLabelFormatter : value;
84
84
  }, [yAxis === null || yAxis === void 0 ? void 0 : yAxis.data, tickLabelFormatter]);
85
85
 
@@ -107,11 +107,11 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
107
107
  return getAxisTicksData({
108
108
  scaleFunction: yScale,
109
109
  ticks,
110
- requestedTickCount: tickInterval !== undefined ? undefined : requestedTickCount !== null && requestedTickCount !== void 0 ? requestedTickCount : 5,
110
+ requestedTickCount: tickInterval !== undefined ? undefined : requestedTickCount !== null && requestedTickCount !== void 0 ? requestedTickCount : layout === 'horizontal' ? undefined : 5,
111
111
  categories,
112
112
  tickInterval: tickInterval
113
113
  });
114
- }, [ticks, yScale, requestedTickCount, tickInterval, yAxis === null || yAxis === void 0 ? void 0 : yAxis.data]);
114
+ }, [ticks, yScale, requestedTickCount, tickInterval, yAxis === null || yAxis === void 0 ? void 0 : yAxis.data, layout]);
115
115
  const isBandScale = useMemo(() => {
116
116
  if (!yScale) return false;
117
117
  return isCategoricalScale(yScale);
@@ -1,4 +1,5 @@
1
1
  import React, { memo, useMemo } from 'react';
2
+ import { useCartesianChartContext } from '../ChartProvider';
2
3
  import { getBarPath } from '../utils';
3
4
  import { DefaultBar } from './';
4
5
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -20,7 +21,7 @@ export const Bar = /*#__PURE__*/memo(_ref => {
20
21
  y,
21
22
  width,
22
23
  height,
23
- originY,
24
+ origin: originProp,
24
25
  dataX,
25
26
  dataY,
26
27
  seriesId,
@@ -35,10 +36,15 @@ export const Bar = /*#__PURE__*/memo(_ref => {
35
36
  transitions,
36
37
  transition
37
38
  } = _ref;
39
+ const {
40
+ layout
41
+ } = useCartesianChartContext();
38
42
  const barPath = useMemo(() => {
39
- return getBarPath(x, y, width, height, borderRadius, roundTop, roundBottom);
40
- }, [x, y, width, height, borderRadius, roundTop, roundBottom]);
41
- const effectiveOriginY = originY !== null && originY !== void 0 ? originY : y + height;
43
+ return getBarPath(x, y, width, height, borderRadius, !!roundTop, !!roundBottom, layout);
44
+ }, [x, y, width, height, borderRadius, roundTop, roundBottom, layout]);
45
+ const origin = useMemo(() => {
46
+ return originProp !== null && originProp !== void 0 ? originProp : layout === 'horizontal' ? x : y + height;
47
+ }, [originProp, layout, x, y, height]);
42
48
  if (!barPath) {
43
49
  return null;
44
50
  }
@@ -50,7 +56,7 @@ export const Bar = /*#__PURE__*/memo(_ref => {
50
56
  fill: fill,
51
57
  fillOpacity: fillOpacity,
52
58
  height: height,
53
- originY: effectiveOriginY,
59
+ origin: origin,
54
60
  roundBottom: roundBottom,
55
61
  roundTop: roundTop,
56
62
  seriesId: seriesId,
@@ -1,5 +1,5 @@
1
1
  const _excluded = ["series", "stacked", "showXAxis", "showYAxis", "xAxis", "yAxis", "inset", "children", "barPadding", "BarComponent", "fillOpacity", "stroke", "strokeWidth", "borderRadius", "roundBaseline", "BarStackComponent", "stackGap", "barMinSize", "stackMinSize", "transitions", "transition"],
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
4
  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; }
5
5
  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; }
@@ -11,12 +11,12 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
11
11
  import { forwardRef, memo, useMemo } from 'react';
12
12
  import { XAxis, YAxis } from '../axis';
13
13
  import { CartesianChart } from '../CartesianChart';
14
- import { defaultChartInset, defaultStackId, getChartInset } from '../utils';
14
+ import { defaultStackId } from '../utils';
15
15
  import { BarPlot } from './BarPlot';
16
16
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
17
  export const BarChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
18
18
  let {
19
- series,
19
+ series: seriesProp,
20
20
  stacked,
21
21
  showXAxis,
22
22
  showYAxis,
@@ -39,21 +39,19 @@ export const BarChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =>
39
39
  transition
40
40
  } = _ref,
41
41
  chartProps = _objectWithoutProperties(_ref, _excluded);
42
- const calculatedInset = useMemo(() => getChartInset(inset, defaultChartInset), [inset]);
43
- const transformedSeries = useMemo(() => {
44
- if (!stacked || !series) return series;
45
- return series.map(s => {
42
+ const series = useMemo(() => {
43
+ if (!stacked || !seriesProp) return seriesProp;
44
+ return seriesProp.map(s => {
46
45
  var _s$stackId;
47
46
  return _objectSpread(_objectSpread({}, s), {}, {
48
47
  stackId: (_s$stackId = s.stackId) !== null && _s$stackId !== void 0 ? _s$stackId : defaultStackId
49
48
  });
50
49
  });
51
- }, [series, stacked]);
52
-
53
- // Unlike other charts with custom props per series, we do not need to pick out
54
- // the props from each series that shouldn't be passed to CartesianChart
55
- const seriesToRender = transformedSeries !== null && transformedSeries !== void 0 ? transformedSeries : series;
56
- const seriesIds = seriesToRender === null || seriesToRender === void 0 ? void 0 : seriesToRender.map(s => s.id);
50
+ }, [seriesProp, stacked]);
51
+ const seriesIds = useMemo(() => series === null || series === void 0 ? void 0 : series.map(s => s.id), [series]);
52
+ const isHorizontal = chartProps.layout === 'horizontal';
53
+ const defaultXScaleType = isHorizontal ? 'linear' : 'band';
54
+ const defaultYScaleType = isHorizontal ? 'band' : 'linear';
57
55
 
58
56
  // Split axis props into config props for Chart and visual props for axis components
59
57
  const _ref2 = xAxis || {},
@@ -63,7 +61,8 @@ export const BarChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =>
63
61
  categoryPadding: xCategoryPadding,
64
62
  domain: xDomain,
65
63
  domainLimit: xDomainLimit,
66
- range: xRange
64
+ range: xRange,
65
+ id: xAxisId
67
66
  } = _ref2,
68
67
  xAxisVisualProps = _objectWithoutProperties(_ref2, _excluded2);
69
68
  const _ref3 = yAxis || {},
@@ -77,14 +76,6 @@ export const BarChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =>
77
76
  id: yAxisId
78
77
  } = _ref3,
79
78
  yAxisVisualProps = _objectWithoutProperties(_ref3, _excluded3);
80
- const xAxisConfig = {
81
- scaleType: xScaleType !== null && xScaleType !== void 0 ? xScaleType : 'band',
82
- data: xData,
83
- categoryPadding: xCategoryPadding,
84
- domain: xDomain,
85
- domainLimit: xDomainLimit,
86
- range: xRange
87
- };
88
79
  const hasNegativeValues = useMemo(() => {
89
80
  if (!series) return false;
90
81
  return series.some(s => {
@@ -92,25 +83,37 @@ export const BarChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =>
92
83
  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));
93
84
  });
94
85
  }, [series]);
86
+ const xAxisConfig = useMemo(() => ({
87
+ scaleType: xScaleType !== null && xScaleType !== void 0 ? xScaleType : defaultXScaleType,
88
+ data: xData,
89
+ categoryPadding: xCategoryPadding,
90
+ domain: isHorizontal && !hasNegativeValues ? _objectSpread({
91
+ min: 0
92
+ }, xDomain) : xDomain,
93
+ domainLimit: xDomainLimit,
94
+ range: xRange
95
+ }), [xScaleType, isHorizontal, xData, xCategoryPadding, hasNegativeValues, xDomain, xDomainLimit, xRange, defaultXScaleType]);
95
96
 
96
- // Set default min domain to 0 for area chart, but only if there are no negative values
97
- const yAxisConfig = {
98
- scaleType: yScaleType,
97
+ // Set default min domain to 0 for bar chart, but only if there are no negative values
98
+ const yAxisConfig = useMemo(() => ({
99
+ scaleType: yScaleType !== null && yScaleType !== void 0 ? yScaleType : defaultYScaleType,
99
100
  data: yData,
100
101
  categoryPadding: yCategoryPadding,
101
- domain: hasNegativeValues ? yDomain : _objectSpread({
102
+ domain: !isHorizontal && !hasNegativeValues ? _objectSpread({
102
103
  min: 0
103
- }, yDomain),
104
+ }, yDomain) : yDomain,
104
105
  domainLimit: yDomainLimit,
105
106
  range: yRange
106
- };
107
+ }), [yScaleType, isHorizontal, yData, yCategoryPadding, hasNegativeValues, yDomain, yDomainLimit, yRange, defaultYScaleType]);
107
108
  return /*#__PURE__*/_jsxs(CartesianChart, _objectSpread(_objectSpread({}, chartProps), {}, {
108
109
  ref: ref,
109
- inset: calculatedInset,
110
- series: seriesToRender,
110
+ inset: inset,
111
+ series: series,
111
112
  xAxis: xAxisConfig,
112
113
  yAxis: yAxisConfig,
113
- children: [showXAxis && /*#__PURE__*/_jsx(XAxis, _objectSpread({}, xAxisVisualProps)), showYAxis && /*#__PURE__*/_jsx(YAxis, _objectSpread({
114
+ children: [showXAxis && /*#__PURE__*/_jsx(XAxis, _objectSpread({
115
+ axisId: xAxisId
116
+ }, xAxisVisualProps)), showYAxis && /*#__PURE__*/_jsx(YAxis, _objectSpread({
114
117
  axisId: yAxisId
115
118
  }, yAxisVisualProps)), /*#__PURE__*/_jsx(BarPlot, {
116
119
  BarComponent: BarComponent,
@@ -41,16 +41,18 @@ export const BarPlot = /*#__PURE__*/memo(_ref => {
41
41
  const stackGroups = useMemo(() => {
42
42
  const groups = new Map();
43
43
 
44
- // Group series into stacks based on stackId + yAxisId combination
44
+ // Group series into stacks based on stackId + axis ID combination
45
45
  targetSeries.forEach(series => {
46
- var _series$yAxisId;
46
+ var _series$xAxisId, _series$yAxisId;
47
+ const xAxisId = (_series$xAxisId = series.xAxisId) !== null && _series$xAxisId !== void 0 ? _series$xAxisId : defaultAxisId;
47
48
  const yAxisId = (_series$yAxisId = series.yAxisId) !== null && _series$yAxisId !== void 0 ? _series$yAxisId : defaultAxisId;
48
49
  const stackId = series.stackId || "individual-".concat(series.id);
49
- const stackKey = "".concat(stackId, ":").concat(yAxisId);
50
+ const stackKey = "".concat(stackId, ":").concat(xAxisId, ":").concat(yAxisId);
50
51
  if (!groups.has(stackKey)) {
51
52
  groups.set(stackKey, {
52
53
  stackId: stackKey,
53
54
  series: [],
55
+ xAxisId: series.xAxisId,
54
56
  yAxisId: series.yAxisId
55
57
  });
56
58
  }
@@ -92,6 +94,7 @@ export const BarPlot = /*#__PURE__*/memo(_ref => {
92
94
  totalStacks: stackGroups.length,
93
95
  transition: transition,
94
96
  transitions: transitions,
97
+ xAxisId: group.xAxisId,
95
98
  yAxisId: group.yAxisId
96
99
  }, group.stackId))
97
100
  })]