@coinbase/cds-web-visualization 3.4.0-beta.9 → 3.4.0

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 (156) hide show
  1. package/CHANGELOG.md +126 -0
  2. package/dts/chart/CartesianChart.d.ts +40 -4
  3. package/dts/chart/CartesianChart.d.ts.map +1 -1
  4. package/dts/chart/ChartProvider.d.ts +3 -0
  5. package/dts/chart/ChartProvider.d.ts.map +1 -1
  6. package/dts/chart/Path.d.ts +51 -12
  7. package/dts/chart/Path.d.ts.map +1 -1
  8. package/dts/chart/PeriodSelector.d.ts +25 -4
  9. package/dts/chart/PeriodSelector.d.ts.map +1 -1
  10. package/dts/chart/area/Area.d.ts +13 -11
  11. package/dts/chart/area/Area.d.ts.map +1 -1
  12. package/dts/chart/area/AreaChart.d.ts +18 -5
  13. package/dts/chart/area/AreaChart.d.ts.map +1 -1
  14. package/dts/chart/area/DottedArea.d.ts.map +1 -1
  15. package/dts/chart/area/GradientArea.d.ts.map +1 -1
  16. package/dts/chart/area/SolidArea.d.ts.map +1 -1
  17. package/dts/chart/axis/Axis.d.ts +29 -29
  18. package/dts/chart/axis/Axis.d.ts.map +1 -1
  19. package/dts/chart/axis/XAxis.d.ts +6 -0
  20. package/dts/chart/axis/XAxis.d.ts.map +1 -1
  21. package/dts/chart/axis/YAxis.d.ts +2 -1
  22. package/dts/chart/axis/YAxis.d.ts.map +1 -1
  23. package/dts/chart/bar/Bar.d.ts +51 -51
  24. package/dts/chart/bar/Bar.d.ts.map +1 -1
  25. package/dts/chart/bar/BarChart.d.ts +29 -6
  26. package/dts/chart/bar/BarChart.d.ts.map +1 -1
  27. package/dts/chart/bar/BarPlot.d.ts +2 -1
  28. package/dts/chart/bar/BarPlot.d.ts.map +1 -1
  29. package/dts/chart/bar/BarStack.d.ts +58 -20
  30. package/dts/chart/bar/BarStack.d.ts.map +1 -1
  31. package/dts/chart/bar/BarStackGroup.d.ts +2 -1
  32. package/dts/chart/bar/BarStackGroup.d.ts.map +1 -1
  33. package/dts/chart/bar/DefaultBar.d.ts.map +1 -1
  34. package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -1
  35. package/dts/chart/gradient/Gradient.d.ts +7 -0
  36. package/dts/chart/gradient/Gradient.d.ts.map +1 -1
  37. package/dts/chart/index.d.ts +1 -0
  38. package/dts/chart/index.d.ts.map +1 -1
  39. package/dts/chart/legend/DefaultLegendEntry.d.ts +21 -0
  40. package/dts/chart/legend/DefaultLegendEntry.d.ts.map +1 -0
  41. package/dts/chart/legend/DefaultLegendShape.d.ts +7 -0
  42. package/dts/chart/legend/DefaultLegendShape.d.ts.map +1 -0
  43. package/dts/chart/legend/Legend.d.ts +169 -0
  44. package/dts/chart/legend/Legend.d.ts.map +1 -0
  45. package/dts/chart/legend/index.d.ts +4 -0
  46. package/dts/chart/legend/index.d.ts.map +1 -0
  47. package/dts/chart/line/DottedLine.d.ts.map +1 -1
  48. package/dts/chart/line/Line.d.ts +45 -24
  49. package/dts/chart/line/Line.d.ts.map +1 -1
  50. package/dts/chart/line/LineChart.d.ts +5 -3
  51. package/dts/chart/line/LineChart.d.ts.map +1 -1
  52. package/dts/chart/line/ReferenceLine.d.ts +9 -0
  53. package/dts/chart/line/ReferenceLine.d.ts.map +1 -1
  54. package/dts/chart/line/SolidLine.d.ts.map +1 -1
  55. package/dts/chart/point/Point.d.ts +26 -2
  56. package/dts/chart/point/Point.d.ts.map +1 -1
  57. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +34 -17
  58. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -1
  59. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +1 -1
  60. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +2 -1
  61. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -1
  62. package/dts/chart/scrubber/Scrubber.d.ts +148 -46
  63. package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
  64. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +10 -0
  65. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -1
  66. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +25 -1
  67. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -1
  68. package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -1
  69. package/dts/chart/text/ChartText.d.ts.map +1 -1
  70. package/dts/chart/utils/axis.d.ts +48 -9
  71. package/dts/chart/utils/axis.d.ts.map +1 -1
  72. package/dts/chart/utils/bar.d.ts +188 -0
  73. package/dts/chart/utils/bar.d.ts.map +1 -1
  74. package/dts/chart/utils/chart.d.ts +32 -0
  75. package/dts/chart/utils/chart.d.ts.map +1 -1
  76. package/dts/chart/utils/context.d.ts +20 -4
  77. package/dts/chart/utils/context.d.ts.map +1 -1
  78. package/dts/chart/utils/gradient.d.ts +3 -1
  79. package/dts/chart/utils/gradient.d.ts.map +1 -1
  80. package/dts/chart/utils/path.d.ts +26 -0
  81. package/dts/chart/utils/path.d.ts.map +1 -1
  82. package/dts/chart/utils/point.d.ts +18 -7
  83. package/dts/chart/utils/point.d.ts.map +1 -1
  84. package/dts/chart/utils/scale.d.ts +11 -0
  85. package/dts/chart/utils/scale.d.ts.map +1 -1
  86. package/dts/chart/utils/scrubber.d.ts +2 -1
  87. package/dts/chart/utils/scrubber.d.ts.map +1 -1
  88. package/dts/chart/utils/transition.d.ts +50 -14
  89. package/dts/chart/utils/transition.d.ts.map +1 -1
  90. package/dts/sparkline/Sparkline.d.ts +2 -1
  91. package/dts/sparkline/Sparkline.d.ts.map +1 -1
  92. package/dts/sparkline/SparklineArea.d.ts +2 -1
  93. package/dts/sparkline/SparklineArea.d.ts.map +1 -1
  94. package/dts/sparkline/SparklineGradient.d.ts +2 -1
  95. package/dts/sparkline/SparklineGradient.d.ts.map +1 -1
  96. package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +2 -1
  97. package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +1 -1
  98. package/esm/chart/CartesianChart.js +154 -90
  99. package/esm/chart/ChartProvider.js +2 -2
  100. package/esm/chart/Path.js +35 -19
  101. package/esm/chart/PeriodSelector.js +33 -15
  102. package/esm/chart/area/Area.js +21 -9
  103. package/esm/chart/area/AreaChart.js +28 -25
  104. package/esm/chart/area/DottedArea.js +18 -9
  105. package/esm/chart/area/GradientArea.js +16 -8
  106. package/esm/chart/area/SolidArea.js +8 -3
  107. package/esm/chart/axis/Axis.js +3 -17
  108. package/esm/chart/axis/XAxis.js +153 -50
  109. package/esm/chart/axis/YAxis.js +146 -36
  110. package/esm/chart/bar/Bar.js +16 -8
  111. package/esm/chart/bar/BarChart.js +38 -33
  112. package/esm/chart/bar/BarPlot.js +20 -25
  113. package/esm/chart/bar/BarStack.js +109 -505
  114. package/esm/chart/bar/BarStackGroup.js +36 -27
  115. package/esm/chart/bar/DefaultBar.js +34 -26
  116. package/esm/chart/bar/DefaultBarStack.js +31 -18
  117. package/esm/chart/gradient/Gradient.js +3 -2
  118. package/esm/chart/index.js +1 -0
  119. package/esm/chart/legend/DefaultLegendEntry.css +1 -0
  120. package/esm/chart/legend/DefaultLegendEntry.js +50 -0
  121. package/esm/chart/legend/DefaultLegendShape.css +5 -0
  122. package/esm/chart/legend/DefaultLegendShape.js +47 -0
  123. package/esm/chart/legend/Legend.js +76 -0
  124. package/esm/chart/legend/index.js +3 -0
  125. package/esm/chart/line/DottedLine.js +7 -2
  126. package/esm/chart/line/Line.js +41 -42
  127. package/esm/chart/line/LineChart.js +18 -13
  128. package/esm/chart/line/ReferenceLine.js +6 -2
  129. package/esm/chart/line/SolidLine.js +8 -3
  130. package/esm/chart/point/Point.js +41 -24
  131. package/esm/chart/scrubber/DefaultScrubberBeacon.js +64 -65
  132. package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +25 -14
  133. package/esm/chart/scrubber/DefaultScrubberLabel.js +26 -8
  134. package/esm/chart/scrubber/Scrubber.js +54 -43
  135. package/esm/chart/scrubber/ScrubberBeaconGroup.js +60 -35
  136. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +31 -8
  137. package/esm/chart/scrubber/ScrubberProvider.js +44 -39
  138. package/esm/chart/text/ChartText.js +3 -2
  139. package/esm/chart/utils/axis.js +90 -43
  140. package/esm/chart/utils/bar.js +863 -0
  141. package/esm/chart/utils/chart.js +34 -7
  142. package/esm/chart/utils/context.js +7 -0
  143. package/esm/chart/utils/gradient.js +6 -4
  144. package/esm/chart/utils/path.js +88 -61
  145. package/esm/chart/utils/point.js +57 -30
  146. package/esm/chart/utils/scale.js +13 -2
  147. package/esm/chart/utils/scrubber.js +9 -4
  148. package/esm/chart/utils/transition.js +68 -41
  149. package/esm/sparkline/Sparkline.js +2 -1
  150. package/esm/sparkline/SparklineArea.js +2 -1
  151. package/esm/sparkline/SparklineGradient.js +2 -1
  152. package/esm/sparkline/__figma__/Sparkline.figma.js +1 -1
  153. package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +2 -1
  154. package/esm/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.js +1 -1
  155. package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +1 -1
  156. package/package.json +8 -7
@@ -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"];
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; }
@@ -8,15 +8,14 @@ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, 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
9
  import { memo, useCallback, useEffect, useId, useMemo } from 'react';
10
10
  import { cx } from '@coinbase/cds-web';
11
- import { AnimatePresence, m as motion } from 'framer-motion';
11
+ import { m as motion } from 'framer-motion';
12
12
  import { useCartesianChartContext } from '../ChartProvider';
13
13
  import { DottedLine } from '../line/DottedLine';
14
- import { ReferenceLine } from '../line/ReferenceLine';
15
14
  import { SolidLine } from '../line/SolidLine';
16
15
  import { ChartText } from '../text/ChartText';
17
16
  import { ChartTextGroup } from '../text/ChartTextGroup';
18
- import { getAxisTicksData, isCategoricalScale, lineToPath } from '../utils';
19
- import { axisLineStyles, axisTickMarkStyles, axisUpdateAnimationVariants } from './Axis';
17
+ import { getAxisTicksData, getPointOnScale, isCategoricalScale, lineToPath, toPointAnchor } from '../utils';
18
+ import { axisLineStyles, axisTickMarkStyles, axisUpdateAnimationTransition } from './Axis';
20
19
  import { DefaultAxisTickLabel } from './DefaultAxisTickLabel';
21
20
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
21
  const AXIS_HEIGHT = 32;
@@ -25,6 +24,7 @@ const axisTickMarkCss = "cds-axisTickMarkCss-a6j4s2q";
25
24
  const axisLineCss = "cds-axisLineCss-a12llxjj";
26
25
  export const XAxis = /*#__PURE__*/memo(_ref => {
27
26
  let {
27
+ axisId,
28
28
  position = 'bottom',
29
29
  showGrid,
30
30
  requestedTickCount,
@@ -48,20 +48,25 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
48
48
  tickMaxStep,
49
49
  label,
50
50
  labelGap = 4,
51
- height = label ? AXIS_HEIGHT + LABEL_SIZE : AXIS_HEIGHT
51
+ height = label ? AXIS_HEIGHT + LABEL_SIZE : AXIS_HEIGHT,
52
+ testID = 'x-axis',
53
+ bandGridLinePlacement = 'edges',
54
+ bandTickMarkPlacement = 'middle'
52
55
  } = _ref,
53
56
  props = _objectWithoutProperties(_ref, _excluded);
54
57
  const registrationId = useId();
55
58
  const {
56
59
  animate,
60
+ layout,
57
61
  getXScale,
58
62
  getXAxis,
59
63
  registerAxis,
60
64
  unregisterAxis,
61
- getAxisBounds
65
+ getAxisBounds,
66
+ drawingArea
62
67
  } = useCartesianChartContext();
63
- const xScale = getXScale();
64
- const xAxis = getXAxis();
68
+ const xScale = getXScale(axisId);
69
+ const xAxis = getXAxis(axisId);
65
70
  const axisBounds = getAxisBounds(registrationId);
66
71
  useEffect(() => {
67
72
  registerAxis(registrationId, position, height);
@@ -72,15 +77,12 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
72
77
  // If we have string labels and no custom formatter, use the labels
73
78
  const axisData = xAxis === null || xAxis === void 0 ? void 0 : xAxis.data;
74
79
  const hasStringLabels = axisData && Array.isArray(axisData) && typeof axisData[0] === 'string';
75
- let finalValue = value;
76
-
77
- // For band scales with string data, value is an index
78
- if (hasStringLabels && typeof value === 'number' && axisData[value] !== undefined) {
79
- finalValue = axisData[value];
80
+ if (hasStringLabels && !tickLabelFormatter && axisData[value] !== undefined) {
81
+ return axisData[value];
80
82
  }
81
83
 
82
- // Use the formatter (if provided) or the value itself
83
- 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;
84
86
  }, [xAxis === null || xAxis === void 0 ? void 0 : xAxis.data, tickLabelFormatter]);
85
87
  const ticksData = useMemo(() => {
86
88
  if (!xScale) return [];
@@ -99,16 +101,10 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
99
101
  const domain = xScale.domain();
100
102
  categories = domain.map(String);
101
103
  }
102
- let possibleTickValues;
103
-
104
- // If we have discrete data, we can use the indices as possible tick values
105
- if (axisData && Array.isArray(axisData) && (typeof axisData[0] === 'string' || typeof axisData[0] === 'number' && isCategoricalScale(xScale))) possibleTickValues = Array.from({
106
- length: axisData.length
107
- }, (_, i) => i);
108
104
  return getAxisTicksData({
109
105
  scaleFunction: xScale,
110
106
  ticks,
111
- requestedTickCount,
107
+ requestedTickCount: requestedTickCount !== null && requestedTickCount !== void 0 ? requestedTickCount : layout === 'horizontal' ? 5 : undefined,
112
108
  categories,
113
109
  possibleTickValues: axisData && Array.isArray(axisData) && typeof axisData[0] === 'string' ? Array.from({
114
110
  length: axisData.length
@@ -119,15 +115,80 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
119
115
  maxStep: tickMaxStep
120
116
  }
121
117
  });
122
- }, [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]);
119
+ const isBandScale = useMemo(() => {
120
+ if (!xScale) return false;
121
+ return isCategoricalScale(xScale);
122
+ }, [xScale]);
123
+
124
+ // Compute grid line positions (including bounds closing line for band scales)
125
+ const gridLinePositions = useMemo(() => {
126
+ if (!xScale) return [];
127
+ return ticksData.flatMap((tick, index) => {
128
+ if (!isBandScale) {
129
+ return [{
130
+ x: tick.position,
131
+ key: "grid-".concat(tick.tick, "-").concat(index)
132
+ }];
133
+ }
134
+ const bandScale = xScale;
135
+ const isLastTick = index === ticksData.length - 1;
136
+ const isEdges = bandGridLinePlacement === 'edges';
137
+ const startX = getPointOnScale(tick.tick, bandScale, toPointAnchor(bandGridLinePlacement));
138
+ const positions = [{
139
+ x: startX,
140
+ key: "grid-".concat(tick.tick, "-").concat(index)
141
+ }];
142
+
143
+ // For edges on last tick, add the closing line at stepEnd
144
+ if (isLastTick && isEdges) {
145
+ const endX = getPointOnScale(tick.tick, bandScale, 'stepEnd');
146
+ positions.push({
147
+ x: endX,
148
+ key: "grid-".concat(tick.tick, "-").concat(index, "-end")
149
+ });
150
+ }
151
+ return positions;
152
+ });
153
+ }, [ticksData, xScale, isBandScale, bandGridLinePlacement]);
154
+
155
+ // Compute tick mark positions (including bounds closing tick mark for band scales)
156
+ const tickMarkPositions = useMemo(() => {
157
+ if (!xScale) return [];
158
+ return ticksData.flatMap((tick, index) => {
159
+ if (!isBandScale) {
160
+ return [{
161
+ x: tick.position,
162
+ key: "tick-mark-".concat(tick.tick, "-").concat(index)
163
+ }];
164
+ }
165
+ const bandScale = xScale;
166
+ const isLastTick = index === ticksData.length - 1;
167
+ const isEdges = bandTickMarkPlacement === 'edges';
168
+ const startX = getPointOnScale(tick.tick, bandScale, toPointAnchor(bandTickMarkPlacement));
169
+ const positions = [{
170
+ x: startX,
171
+ key: "tick-mark-".concat(tick.tick, "-").concat(index)
172
+ }];
173
+
174
+ // For edges on last tick, add the closing tick mark at stepEnd
175
+ if (isLastTick && isEdges) {
176
+ const endX = getPointOnScale(tick.tick, bandScale, 'stepEnd');
177
+ positions.push({
178
+ x: endX,
179
+ key: "tick-mark-".concat(tick.tick, "-").concat(index, "-end")
180
+ });
181
+ }
182
+ return positions;
183
+ });
184
+ }, [ticksData, xScale, isBandScale, bandTickMarkPlacement]);
123
185
  const chartTextData = useMemo(() => {
124
186
  if (!axisBounds) return null;
125
187
  return ticksData.map(tick => {
126
188
  const tickOffset = tickMarkLabelGap + (showTickMarks ? tickMarkSize : 0);
127
189
  const availableSpace = AXIS_HEIGHT - tickOffset;
128
190
  const labelOffset = availableSpace / 2;
129
- const baseY = position === 'top' && label ? axisBounds.y + LABEL_SIZE : axisBounds.y;
130
- const labelY = position === 'top' ? baseY + labelOffset - tickOffset : baseY + labelOffset + tickOffset;
191
+ const labelY = position === 'top' ? axisBounds.y + axisBounds.height - tickOffset - labelOffset : axisBounds.y + labelOffset + tickOffset;
131
192
  return {
132
193
  x: tick.position,
133
194
  y: labelY,
@@ -141,32 +202,51 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
141
202
  }
142
203
  };
143
204
  });
144
- }, [axisBounds, ticksData, tickMarkLabelGap, showTickMarks, tickMarkSize, position, formatTick, classNames === null || classNames === void 0 ? void 0 : classNames.tickLabel, styles === null || styles === void 0 ? void 0 : styles.tickLabel, label]);
145
- if (!xScale || !axisBounds) return;
205
+ }, [axisBounds, ticksData, tickMarkLabelGap, showTickMarks, tickMarkSize, position, formatTick, classNames === null || classNames === void 0 ? void 0 : classNames.tickLabel, styles === null || styles === void 0 ? void 0 : styles.tickLabel]);
206
+ if (!xScale || !axisBounds || !drawingArea) return;
146
207
  const labelX = axisBounds.x + axisBounds.width / 2;
147
208
  const labelY = position === 'bottom' ? axisBounds.y + axisBounds.height - LABEL_SIZE / 2 : axisBounds.y + LABEL_SIZE / 2;
209
+ const tickYTop = axisBounds.y;
210
+ const tickYBottom = axisBounds.y + axisBounds.height;
211
+ const tickYStart = position === 'bottom' ? tickYTop : tickYBottom;
212
+ const tickYEnd = position === 'bottom' ? tickYTop + tickMarkSize : tickYBottom - tickMarkSize;
148
213
  return /*#__PURE__*/_jsxs("g", _objectSpread(_objectSpread({
149
214
  className: cx(className, classNames === null || classNames === void 0 ? void 0 : classNames.root),
150
215
  "data-axis": "x",
151
216
  "data-position": position,
152
217
  style: _objectSpread(_objectSpread({}, style), styles === null || styles === void 0 ? void 0 : styles.root)
153
218
  }, props), {}, {
154
- children: [showGrid && /*#__PURE__*/_jsx(AnimatePresence, {
155
- initial: false,
156
- children: ticksData.map((tick, index) => {
157
- const verticalLine = /*#__PURE__*/_jsx(ReferenceLine, {
158
- LineComponent: GridLineComponent,
159
- dataX: tick.tick
160
- });
219
+ children: [showGrid && /*#__PURE__*/_jsx("g", {
220
+ "data-testid": "".concat(testID, "-grid"),
221
+ children: gridLinePositions.map(_ref2 => {
222
+ let {
223
+ x,
224
+ key
225
+ } = _ref2;
161
226
  return animate ? /*#__PURE__*/_jsx(motion.g, {
162
- animate: "animate",
163
- exit: "exit",
164
- initial: "initial",
165
- variants: axisUpdateAnimationVariants,
166
- children: verticalLine
167
- }, "grid-".concat(tick.tick, "-").concat(index)) : /*#__PURE__*/_jsx("g", {
168
- children: verticalLine
169
- }, "grid-".concat(tick.tick, "-").concat(index));
227
+ animate: {
228
+ opacity: 1
229
+ },
230
+ initial: {
231
+ opacity: 0
232
+ },
233
+ transition: axisUpdateAnimationTransition,
234
+ children: /*#__PURE__*/_jsx(GridLineComponent, {
235
+ animate: false,
236
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.gridLine,
237
+ clipRect: null,
238
+ d: lineToPath(x, drawingArea.y, x, drawingArea.y + drawingArea.height),
239
+ stroke: "var(--color-bgLine)",
240
+ style: styles === null || styles === void 0 ? void 0 : styles.gridLine
241
+ })
242
+ }, key) : /*#__PURE__*/_jsx(GridLineComponent, {
243
+ animate: false,
244
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.gridLine,
245
+ clipRect: null,
246
+ d: lineToPath(x, drawingArea.y, x, drawingArea.y + drawingArea.height),
247
+ stroke: "var(--color-bgLine)",
248
+ style: styles === null || styles === void 0 ? void 0 : styles.gridLine
249
+ }, key);
170
250
  })
171
251
  }), chartTextData && /*#__PURE__*/_jsx(ChartTextGroup, {
172
252
  prioritizeEndLabels: true,
@@ -174,25 +254,47 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
174
254
  labels: chartTextData,
175
255
  minGap: minTickLabelGap
176
256
  }), axisBounds && showTickMarks && /*#__PURE__*/_jsx("g", {
177
- "data-testid": "tick-marks",
178
- children: ticksData.map((tick, index) => {
179
- const tickY = position === 'bottom' ? axisBounds.y : axisBounds.y + axisBounds.height;
180
- const tickY2 = position === 'bottom' ? tickY + tickMarkSize : tickY - tickMarkSize;
181
- return /*#__PURE__*/_jsx(TickMarkLineComponent, {
257
+ "data-testid": "".concat(testID, "-tick-marks"),
258
+ children: tickMarkPositions.map(_ref3 => {
259
+ let {
260
+ x,
261
+ key
262
+ } = _ref3;
263
+ return animate ? /*#__PURE__*/_jsx(motion.g, {
264
+ animate: {
265
+ opacity: 1
266
+ },
267
+ initial: {
268
+ opacity: 0
269
+ },
270
+ transition: axisUpdateAnimationTransition,
271
+ children: /*#__PURE__*/_jsx(TickMarkLineComponent, {
272
+ animate: false,
273
+ className: cx(axisTickMarkCss, classNames === null || classNames === void 0 ? void 0 : classNames.tickMark),
274
+ clipRect: null,
275
+ d: lineToPath(x, tickYEnd, x, tickYStart),
276
+ stroke: "var(--color-fg)",
277
+ strokeLinecap: "square",
278
+ strokeWidth: 1,
279
+ style: styles === null || styles === void 0 ? void 0 : styles.tickMark
280
+ })
281
+ }, key) : /*#__PURE__*/_jsx(TickMarkLineComponent, {
182
282
  animate: false,
183
283
  className: cx(axisTickMarkCss, classNames === null || classNames === void 0 ? void 0 : classNames.tickMark),
184
284
  clipRect: null,
185
- d: lineToPath(tick.position, tickY2, tick.position, tickY),
285
+ d: lineToPath(x, tickYEnd, x, tickYStart),
186
286
  stroke: "var(--color-fg)",
187
287
  strokeLinecap: "square",
188
288
  strokeWidth: 1,
189
289
  style: styles === null || styles === void 0 ? void 0 : styles.tickMark
190
- }, "tick-mark-".concat(tick.tick, "-").concat(index));
290
+ }, key);
191
291
  })
192
292
  }), showLine && /*#__PURE__*/_jsx(LineComponent, {
193
293
  animate: false,
194
294
  className: cx(axisLineCss, classNames === null || classNames === void 0 ? void 0 : classNames.line),
295
+ clipRect: null,
195
296
  d: lineToPath(axisBounds.x, position === 'bottom' ? axisBounds.y : axisBounds.y + axisBounds.height, axisBounds.x + axisBounds.width, position === 'bottom' ? axisBounds.y : axisBounds.y + axisBounds.height),
297
+ "data-testid": "".concat(testID, "-line"),
196
298
  stroke: "var(--color-fg)",
197
299
  strokeLinecap: "square",
198
300
  strokeWidth: 1,
@@ -202,6 +304,7 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
202
304
  className: classNames === null || classNames === void 0 ? void 0 : classNames.label,
203
305
  horizontalAlignment: "center",
204
306
  style: styles === null || styles === void 0 ? void 0 : styles.label,
307
+ testID: "".concat(testID, "-label"),
205
308
  verticalAlignment: "middle",
206
309
  x: labelX,
207
310
  y: labelY,
@@ -1,4 +1,4 @@
1
- const _excluded = ["axisId", "position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "TickLabelComponent", "style", "className", "styles", "classNames", "GridLineComponent", "LineComponent", "TickMarkLineComponent", "tickMarkLabelGap", "minTickLabelGap", "showTickMarks", "showLine", "tickMarkSize", "tickInterval", "label", "labelGap", "width"];
1
+ const _excluded = ["axisId", "position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "TickLabelComponent", "style", "className", "styles", "classNames", "GridLineComponent", "LineComponent", "TickMarkLineComponent", "tickMarkLabelGap", "minTickLabelGap", "showTickMarks", "showLine", "tickMarkSize", "tickInterval", "label", "labelGap", "width", "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; }
@@ -8,15 +8,14 @@ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, 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
9
  import { memo, useCallback, useEffect, useId, useMemo } from 'react';
10
10
  import { cx } from '@coinbase/cds-web';
11
- import { AnimatePresence, m as motion } from 'framer-motion';
11
+ import { m as motion } from 'framer-motion';
12
12
  import { useCartesianChartContext } from '../ChartProvider';
13
13
  import { DottedLine } from '../line/DottedLine';
14
- import { ReferenceLine } from '../line/ReferenceLine';
15
14
  import { SolidLine } from '../line/SolidLine';
16
15
  import { ChartText } from '../text/ChartText';
17
16
  import { ChartTextGroup } from '../text/ChartTextGroup';
18
- import { getAxisTicksData, isCategoricalScale, lineToPath } from '../utils';
19
- import { axisLineStyles, axisTickMarkStyles, axisUpdateAnimationVariants } from './Axis';
17
+ import { getAxisTicksData, getPointOnScale, isCategoricalScale, lineToPath, toPointAnchor } from '../utils';
18
+ import { axisLineStyles, axisTickMarkStyles, axisUpdateAnimationTransition } from './Axis';
20
19
  import { DefaultAxisTickLabel } from './DefaultAxisTickLabel';
21
20
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
21
  const AXIS_WIDTH = 44;
@@ -47,17 +46,22 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
47
46
  tickInterval,
48
47
  label,
49
48
  labelGap = 4,
50
- width = label ? AXIS_WIDTH + LABEL_SIZE : AXIS_WIDTH
49
+ width = label ? AXIS_WIDTH + LABEL_SIZE : AXIS_WIDTH,
50
+ testID = 'y-axis',
51
+ bandGridLinePlacement = 'edges',
52
+ bandTickMarkPlacement = 'middle'
51
53
  } = _ref,
52
54
  props = _objectWithoutProperties(_ref, _excluded);
53
55
  const registrationId = useId();
54
56
  const {
55
57
  animate,
58
+ layout,
56
59
  getYScale,
57
60
  getYAxis,
58
61
  registerAxis,
59
62
  unregisterAxis,
60
- getAxisBounds
63
+ getAxisBounds,
64
+ drawingArea
61
65
  } = useCartesianChartContext();
62
66
  const yScale = getYScale(axisId);
63
67
  const yAxis = getYAxis(axisId);
@@ -72,11 +76,10 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
72
76
  const axisData = yAxis === null || yAxis === void 0 ? void 0 : yAxis.data;
73
77
  const hasStringLabels = axisData && Array.isArray(axisData) && typeof axisData[0] === 'string';
74
78
  if (hasStringLabels && !tickLabelFormatter && axisData[value] !== undefined) {
75
- // Use the string label from the data array
76
79
  return axisData[value];
77
80
  }
78
81
 
79
- // Otherwise use the formatter (if provided) or the value itself
82
+ // Otherwise passes raw index to formatter
80
83
  return (_tickLabelFormatter = tickLabelFormatter === null || tickLabelFormatter === void 0 ? void 0 : tickLabelFormatter(value)) !== null && _tickLabelFormatter !== void 0 ? _tickLabelFormatter : value;
81
84
  }, [yAxis === null || yAxis === void 0 ? void 0 : yAxis.data, tickLabelFormatter]);
82
85
 
@@ -104,11 +107,77 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
104
107
  return getAxisTicksData({
105
108
  scaleFunction: yScale,
106
109
  ticks,
107
- 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,
108
111
  categories,
109
112
  tickInterval: tickInterval
110
113
  });
111
- }, [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
+ const isBandScale = useMemo(() => {
116
+ if (!yScale) return false;
117
+ return isCategoricalScale(yScale);
118
+ }, [yScale]);
119
+
120
+ // Compute grid line positions (including bounds closing line for band scales)
121
+ const gridLinePositions = useMemo(() => {
122
+ if (!yScale) return [];
123
+ return ticksData.flatMap((tick, index) => {
124
+ if (!isBandScale) {
125
+ return [{
126
+ y: tick.position,
127
+ key: "grid-".concat(tick.tick, "-").concat(index)
128
+ }];
129
+ }
130
+ const bandScale = yScale;
131
+ const isLastTick = index === ticksData.length - 1;
132
+ const isEdges = bandGridLinePlacement === 'edges';
133
+ const startY = getPointOnScale(tick.tick, bandScale, toPointAnchor(bandGridLinePlacement));
134
+ const positions = [{
135
+ y: startY,
136
+ key: "grid-".concat(tick.tick, "-").concat(index)
137
+ }];
138
+
139
+ // For edges on last tick, add the closing line at stepEnd
140
+ if (isLastTick && isEdges) {
141
+ const endY = getPointOnScale(tick.tick, bandScale, 'stepEnd');
142
+ positions.push({
143
+ y: endY,
144
+ key: "grid-".concat(tick.tick, "-").concat(index, "-end")
145
+ });
146
+ }
147
+ return positions;
148
+ });
149
+ }, [ticksData, yScale, isBandScale, bandGridLinePlacement]);
150
+
151
+ // Compute tick mark positions (including bounds closing tick mark for band scales)
152
+ const tickMarkPositions = useMemo(() => {
153
+ if (!yScale) return [];
154
+ return ticksData.flatMap((tick, index) => {
155
+ if (!isBandScale) {
156
+ return [{
157
+ y: tick.position,
158
+ key: "tick-mark-".concat(tick.tick, "-").concat(index)
159
+ }];
160
+ }
161
+ const bandScale = yScale;
162
+ const isLastTick = index === ticksData.length - 1;
163
+ const isEdges = bandTickMarkPlacement === 'edges';
164
+ const startY = getPointOnScale(tick.tick, bandScale, toPointAnchor(bandTickMarkPlacement));
165
+ const positions = [{
166
+ y: startY,
167
+ key: "tick-mark-".concat(tick.tick, "-").concat(index)
168
+ }];
169
+
170
+ // For edges on last tick, add the closing tick mark at stepEnd
171
+ if (isLastTick && isEdges) {
172
+ const endY = getPointOnScale(tick.tick, bandScale, 'stepEnd');
173
+ positions.push({
174
+ y: endY,
175
+ key: "tick-mark-".concat(tick.tick, "-").concat(index, "-end")
176
+ });
177
+ }
178
+ return positions;
179
+ });
180
+ }, [ticksData, yScale, isBandScale, bandTickMarkPlacement]);
112
181
  const chartTextData = useMemo(() => {
113
182
  if (!axisBounds) return null;
114
183
  return ticksData.map(tick => {
@@ -128,32 +197,50 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
128
197
  };
129
198
  });
130
199
  }, [axisBounds, ticksData, tickMarkLabelGap, showTickMarks, tickMarkSize, position, formatTick, classNames === null || classNames === void 0 ? void 0 : classNames.tickLabel, styles === null || styles === void 0 ? void 0 : styles.tickLabel]);
131
- if (!yScale || !axisBounds) return;
200
+ if (!yScale || !axisBounds || !drawingArea) return;
132
201
  const labelX = position === 'left' ? axisBounds.x + LABEL_SIZE / 2 : axisBounds.x + axisBounds.width - LABEL_SIZE / 2;
133
202
  const labelY = axisBounds.y + axisBounds.height / 2;
203
+ const tickXLeft = axisBounds.x;
204
+ const tickXRight = axisBounds.x + axisBounds.width;
205
+ const tickXStart = position === 'left' ? tickXRight : tickXLeft;
206
+ const tickXEnd = position === 'left' ? tickXRight - tickMarkSize : tickXLeft + tickMarkSize;
134
207
  return /*#__PURE__*/_jsxs("g", _objectSpread(_objectSpread({
135
208
  className: cx(className, classNames === null || classNames === void 0 ? void 0 : classNames.root),
136
209
  "data-axis": "y",
137
210
  "data-position": position,
138
211
  style: _objectSpread(_objectSpread({}, style), styles === null || styles === void 0 ? void 0 : styles.root)
139
212
  }, props), {}, {
140
- children: [showGrid && /*#__PURE__*/_jsx(AnimatePresence, {
141
- initial: false,
142
- children: ticksData.map((tick, index) => {
143
- const horizontalLine = /*#__PURE__*/_jsx(ReferenceLine, {
144
- LineComponent: GridLineComponent,
145
- dataY: tick.tick,
146
- yAxisId: axisId
147
- });
213
+ children: [showGrid && /*#__PURE__*/_jsx("g", {
214
+ "data-testid": "".concat(testID, "-grid"),
215
+ children: gridLinePositions.map(_ref2 => {
216
+ let {
217
+ y,
218
+ key
219
+ } = _ref2;
148
220
  return animate ? /*#__PURE__*/_jsx(motion.g, {
149
- animate: "animate",
150
- exit: "exit",
151
- initial: "initial",
152
- variants: axisUpdateAnimationVariants,
153
- children: horizontalLine
154
- }, "grid-".concat(tick.tick, "-").concat(index)) : /*#__PURE__*/_jsx("g", {
155
- children: horizontalLine
156
- }, "grid-".concat(tick.tick, "-").concat(index));
221
+ animate: {
222
+ opacity: 1
223
+ },
224
+ initial: {
225
+ opacity: 0
226
+ },
227
+ transition: axisUpdateAnimationTransition,
228
+ children: /*#__PURE__*/_jsx(GridLineComponent, {
229
+ animate: false,
230
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.gridLine,
231
+ clipRect: null,
232
+ d: lineToPath(drawingArea.x, y, drawingArea.x + drawingArea.width, y),
233
+ stroke: "var(--color-bgLine)",
234
+ style: styles === null || styles === void 0 ? void 0 : styles.gridLine
235
+ })
236
+ }, key) : /*#__PURE__*/_jsx(GridLineComponent, {
237
+ animate: false,
238
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.gridLine,
239
+ clipRect: null,
240
+ d: lineToPath(drawingArea.x, y, drawingArea.x + drawingArea.width, y),
241
+ stroke: "var(--color-bgLine)",
242
+ style: styles === null || styles === void 0 ? void 0 : styles.gridLine
243
+ }, key);
157
244
  })
158
245
  }), chartTextData && /*#__PURE__*/_jsx(ChartTextGroup, {
159
246
  prioritizeEndLabels: true,
@@ -161,31 +248,53 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
161
248
  labels: chartTextData,
162
249
  minGap: minTickLabelGap
163
250
  }), showTickMarks && /*#__PURE__*/_jsx("g", {
164
- "data-testid": "tick-marks",
165
- children: ticksData.map((tick, index) => {
166
- const tickX = position === 'left' ? axisBounds.x + axisBounds.width : axisBounds.x;
167
- const tickMarkSizePixels = tickMarkSize;
168
- const tickX2 = position === 'left' ? axisBounds.x + axisBounds.width - tickMarkSizePixels : axisBounds.x + tickMarkSizePixels;
169
- return /*#__PURE__*/_jsx(TickMarkLineComponent, {
251
+ "data-testid": "".concat(testID, "-tick-marks"),
252
+ children: tickMarkPositions.map(_ref3 => {
253
+ let {
254
+ y,
255
+ key
256
+ } = _ref3;
257
+ return animate ? /*#__PURE__*/_jsx(motion.g, {
258
+ animate: {
259
+ opacity: 1
260
+ },
261
+ initial: {
262
+ opacity: 0
263
+ },
264
+ transition: axisUpdateAnimationTransition,
265
+ children: /*#__PURE__*/_jsx(TickMarkLineComponent, {
266
+ animate: false,
267
+ className: cx(axisTickMarkCss, classNames === null || classNames === void 0 ? void 0 : classNames.tickMark),
268
+ clipRect: null,
269
+ d: lineToPath(tickXStart, y, tickXEnd, y),
270
+ stroke: "var(--color-fg)",
271
+ strokeLinecap: "square",
272
+ strokeWidth: 1,
273
+ style: styles === null || styles === void 0 ? void 0 : styles.tickMark
274
+ })
275
+ }, key) : /*#__PURE__*/_jsx(TickMarkLineComponent, {
170
276
  animate: false,
171
277
  className: cx(axisTickMarkCss, classNames === null || classNames === void 0 ? void 0 : classNames.tickMark),
172
278
  clipRect: null,
173
- d: lineToPath(tickX, tick.position, tickX2, tick.position),
279
+ d: lineToPath(tickXStart, y, tickXEnd, y),
174
280
  stroke: "var(--color-fg)",
175
281
  strokeLinecap: "square",
176
282
  strokeWidth: 1,
177
283
  style: styles === null || styles === void 0 ? void 0 : styles.tickMark
178
- }, "tick-mark-".concat(tick.tick, "-").concat(index));
284
+ }, key);
179
285
  })
180
286
  }), showLine && /*#__PURE__*/_jsx(LineComponent, {
181
287
  animate: false,
182
288
  className: cx(axisLineCss, classNames === null || classNames === void 0 ? void 0 : classNames.line),
289
+ clipRect: null,
183
290
  d: lineToPath(position === 'left' ? axisBounds.x + axisBounds.width : axisBounds.x, axisBounds.y, position === 'left' ? axisBounds.x + axisBounds.width : axisBounds.x, axisBounds.y + axisBounds.height),
291
+ "data-testid": "".concat(testID, "-line"),
184
292
  stroke: "var(--color-fg)",
185
293
  strokeLinecap: "square",
186
294
  strokeWidth: 1,
187
295
  style: styles === null || styles === void 0 ? void 0 : styles.line
188
296
  }), label && /*#__PURE__*/_jsx("g", {
297
+ "data-testid": "".concat(testID, "-label"),
189
298
  style: {
190
299
  transformOrigin: "".concat(labelX, "px ").concat(labelY, "px"),
191
300
  transform: "rotate(".concat(position === 'left' ? -90 : 90, "deg)")
@@ -195,6 +304,7 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
195
304
  className: classNames === null || classNames === void 0 ? void 0 : classNames.label,
196
305
  horizontalAlignment: "center",
197
306
  style: styles === null || styles === void 0 ? void 0 : styles.label,
307
+ testID: "".concat(testID, "-label-text"),
198
308
  verticalAlignment: "middle",
199
309
  x: labelX,
200
310
  y: labelY,
@@ -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,9 +21,10 @@ 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,
27
+ seriesId,
26
28
  BarComponent = DefaultBar,
27
29
  fill = 'var(--color-fgPrimary)',
28
30
  fillOpacity = 1,
@@ -31,15 +33,18 @@ export const Bar = /*#__PURE__*/memo(_ref => {
31
33
  borderRadius = 4,
32
34
  roundTop = true,
33
35
  roundBottom = true,
36
+ minSize,
37
+ transitions,
34
38
  transition
35
39
  } = _ref;
40
+ const {
41
+ layout
42
+ } = useCartesianChartContext();
36
43
  const barPath = useMemo(() => {
37
- return getBarPath(x, y, width, height, borderRadius, roundTop, roundBottom);
38
- }, [x, y, width, height, borderRadius, roundTop, roundBottom]);
39
- const effectiveOriginY = originY !== null && originY !== void 0 ? originY : y + height;
40
- if (!barPath) {
41
- return null;
42
- }
44
+ return getBarPath(x, y, width, height, borderRadius, !!roundTop, !!roundBottom, layout);
45
+ }, [x, y, width, height, borderRadius, roundTop, roundBottom, layout]);
46
+ const origin = useMemo(() => originProp !== null && originProp !== void 0 ? originProp : layout === 'horizontal' ? x : y + height, [originProp, layout, x, y, height]);
47
+ if (!barPath) return;
43
48
  return /*#__PURE__*/_jsx(BarComponent, {
44
49
  borderRadius: borderRadius,
45
50
  d: barPath,
@@ -48,12 +53,15 @@ export const Bar = /*#__PURE__*/memo(_ref => {
48
53
  fill: fill,
49
54
  fillOpacity: fillOpacity,
50
55
  height: height,
51
- originY: effectiveOriginY,
56
+ minSize: minSize,
57
+ origin: origin,
52
58
  roundBottom: roundBottom,
53
59
  roundTop: roundTop,
60
+ seriesId: seriesId,
54
61
  stroke: stroke,
55
62
  strokeWidth: strokeWidth,
56
63
  transition: transition,
64
+ transitions: transitions,
57
65
  width: width,
58
66
  x: x,
59
67
  y: y