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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/dts/chart/CartesianChart.d.ts +38 -2
  3. package/dts/chart/CartesianChart.d.ts.map +1 -1
  4. package/dts/chart/Path.d.ts +27 -7
  5. package/dts/chart/Path.d.ts.map +1 -1
  6. package/dts/chart/PeriodSelector.d.ts +0 -4
  7. package/dts/chart/PeriodSelector.d.ts.map +1 -1
  8. package/dts/chart/area/Area.d.ts +54 -24
  9. package/dts/chart/area/Area.d.ts.map +1 -1
  10. package/dts/chart/area/AreaChart.d.ts +33 -6
  11. package/dts/chart/area/AreaChart.d.ts.map +1 -1
  12. package/dts/chart/area/DottedArea.d.ts +21 -44
  13. package/dts/chart/area/DottedArea.d.ts.map +1 -1
  14. package/dts/chart/area/GradientArea.d.ts +21 -12
  15. package/dts/chart/area/GradientArea.d.ts.map +1 -1
  16. package/dts/chart/area/SolidArea.d.ts +16 -1
  17. package/dts/chart/area/SolidArea.d.ts.map +1 -1
  18. package/dts/chart/axis/Axis.d.ts +92 -45
  19. package/dts/chart/axis/Axis.d.ts.map +1 -1
  20. package/dts/chart/axis/DefaultAxisTickLabel.d.ts +8 -0
  21. package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +1 -0
  22. package/dts/chart/axis/XAxis.d.ts +1 -1
  23. package/dts/chart/axis/XAxis.d.ts.map +1 -1
  24. package/dts/chart/axis/YAxis.d.ts +1 -1
  25. package/dts/chart/axis/YAxis.d.ts.map +1 -1
  26. package/dts/chart/axis/index.d.ts +1 -0
  27. package/dts/chart/axis/index.d.ts.map +1 -1
  28. package/dts/chart/bar/Bar.d.ts +16 -13
  29. package/dts/chart/bar/Bar.d.ts.map +1 -1
  30. package/dts/chart/bar/BarChart.d.ts +17 -8
  31. package/dts/chart/bar/BarChart.d.ts.map +1 -1
  32. package/dts/chart/bar/BarPlot.d.ts +2 -1
  33. package/dts/chart/bar/BarPlot.d.ts.map +1 -1
  34. package/dts/chart/bar/BarStack.d.ts +40 -48
  35. package/dts/chart/bar/BarStack.d.ts.map +1 -1
  36. package/dts/chart/bar/BarStackGroup.d.ts +1 -0
  37. package/dts/chart/bar/BarStackGroup.d.ts.map +1 -1
  38. package/dts/chart/bar/DefaultBar.d.ts.map +1 -1
  39. package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -1
  40. package/dts/chart/gradient/Gradient.d.ts +35 -0
  41. package/dts/chart/gradient/Gradient.d.ts.map +1 -0
  42. package/dts/chart/gradient/index.d.ts +2 -0
  43. package/dts/chart/gradient/index.d.ts.map +1 -0
  44. package/dts/chart/index.d.ts +2 -1
  45. package/dts/chart/index.d.ts.map +1 -1
  46. package/dts/chart/line/DefaultReferenceLineLabel.d.ts +9 -0
  47. package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +1 -0
  48. package/dts/chart/line/DottedLine.d.ts +15 -3
  49. package/dts/chart/line/DottedLine.d.ts.map +1 -1
  50. package/dts/chart/line/Line.d.ts +70 -28
  51. package/dts/chart/line/Line.d.ts.map +1 -1
  52. package/dts/chart/line/LineChart.d.ts +26 -8
  53. package/dts/chart/line/LineChart.d.ts.map +1 -1
  54. package/dts/chart/line/ReferenceLine.d.ts +91 -44
  55. package/dts/chart/line/ReferenceLine.d.ts.map +1 -1
  56. package/dts/chart/line/SolidLine.d.ts +14 -3
  57. package/dts/chart/line/SolidLine.d.ts.map +1 -1
  58. package/dts/chart/line/index.d.ts +1 -1
  59. package/dts/chart/line/index.d.ts.map +1 -1
  60. package/dts/chart/point/DefaultPointLabel.d.ts +10 -0
  61. package/dts/chart/point/DefaultPointLabel.d.ts.map +1 -0
  62. package/dts/chart/point/Point.d.ts +201 -0
  63. package/dts/chart/point/Point.d.ts.map +1 -0
  64. package/dts/chart/point/index.d.ts +3 -0
  65. package/dts/chart/point/index.d.ts.map +1 -0
  66. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +24 -0
  67. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -0
  68. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +12 -0
  69. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +1 -0
  70. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +10 -0
  71. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -0
  72. package/dts/chart/scrubber/Scrubber.d.ts +207 -66
  73. package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
  74. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +70 -0
  75. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -0
  76. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +32 -0
  77. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -0
  78. package/dts/chart/scrubber/index.d.ts +3 -0
  79. package/dts/chart/scrubber/index.d.ts.map +1 -1
  80. package/dts/chart/text/ChartText.d.ts +46 -43
  81. package/dts/chart/text/ChartText.d.ts.map +1 -1
  82. package/dts/chart/text/{SmartChartTextGroup.d.ts → ChartTextGroup.d.ts} +9 -3
  83. package/dts/chart/text/ChartTextGroup.d.ts.map +1 -0
  84. package/dts/chart/text/index.d.ts +1 -1
  85. package/dts/chart/text/index.d.ts.map +1 -1
  86. package/dts/chart/utils/chart.d.ts +27 -7
  87. package/dts/chart/utils/chart.d.ts.map +1 -1
  88. package/dts/chart/utils/context.d.ts +6 -0
  89. package/dts/chart/utils/context.d.ts.map +1 -1
  90. package/dts/chart/utils/gradient.d.ts +104 -0
  91. package/dts/chart/utils/gradient.d.ts.map +1 -0
  92. package/dts/chart/utils/index.d.ts +4 -0
  93. package/dts/chart/utils/index.d.ts.map +1 -1
  94. package/dts/chart/utils/interpolate.d.ts +112 -0
  95. package/dts/chart/utils/interpolate.d.ts.map +1 -0
  96. package/dts/chart/utils/path.d.ts +24 -1
  97. package/dts/chart/utils/path.d.ts.map +1 -1
  98. package/dts/chart/utils/point.d.ts +29 -0
  99. package/dts/chart/utils/point.d.ts.map +1 -1
  100. package/dts/chart/utils/scrubber.d.ts +39 -0
  101. package/dts/chart/utils/scrubber.d.ts.map +1 -0
  102. package/dts/chart/utils/transition.d.ts +65 -0
  103. package/dts/chart/utils/transition.d.ts.map +1 -0
  104. package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts.map +1 -1
  105. package/esm/chart/CartesianChart.js +140 -85
  106. package/esm/chart/Path.js +53 -47
  107. package/esm/chart/PeriodSelector.js +4 -18
  108. package/esm/chart/area/Area.js +24 -34
  109. package/esm/chart/area/AreaChart.js +24 -15
  110. package/esm/chart/area/DottedArea.js +35 -89
  111. package/esm/chart/area/GradientArea.js +34 -80
  112. package/esm/chart/area/SolidArea.js +29 -11
  113. package/esm/chart/axis/Axis.js +4 -25
  114. package/esm/chart/axis/DefaultAxisTickLabel.js +15 -0
  115. package/esm/chart/axis/XAxis.js +76 -52
  116. package/esm/chart/axis/YAxis.js +80 -49
  117. package/esm/chart/axis/index.js +1 -0
  118. package/esm/chart/bar/Bar.js +3 -1
  119. package/esm/chart/bar/BarChart.js +15 -32
  120. package/esm/chart/bar/BarPlot.js +3 -2
  121. package/esm/chart/bar/BarStack.js +65 -23
  122. package/esm/chart/bar/BarStackGroup.js +7 -17
  123. package/esm/chart/bar/DefaultBar.js +4 -7
  124. package/esm/chart/bar/DefaultBarStack.js +5 -7
  125. package/esm/chart/gradient/Gradient.js +104 -0
  126. package/esm/chart/gradient/index.js +1 -0
  127. package/esm/chart/index.js +2 -1
  128. package/esm/chart/line/DefaultReferenceLineLabel.js +81 -0
  129. package/esm/chart/line/DottedLine.js +38 -17
  130. package/esm/chart/line/Line.js +96 -70
  131. package/esm/chart/line/LineChart.js +18 -6
  132. package/esm/chart/line/ReferenceLine.js +41 -43
  133. package/esm/chart/line/SolidLine.js +36 -15
  134. package/esm/chart/line/index.js +1 -1
  135. package/esm/chart/{line/GradientLine.js → point/DefaultPointLabel.js} +31 -45
  136. package/esm/chart/point/Point.css +2 -0
  137. package/esm/chart/{Point.js → point/Point.js} +66 -57
  138. package/esm/chart/point/index.js +2 -0
  139. package/esm/chart/scrubber/DefaultScrubberBeacon.js +155 -0
  140. package/esm/chart/scrubber/{ScrubberBeaconLabel.js → DefaultScrubberBeaconLabel.js} +23 -10
  141. package/esm/chart/scrubber/DefaultScrubberLabel.js +30 -0
  142. package/esm/chart/scrubber/Scrubber.js +98 -392
  143. package/esm/chart/scrubber/ScrubberBeaconGroup.js +166 -0
  144. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +186 -0
  145. package/esm/chart/scrubber/index.js +3 -1
  146. package/esm/chart/text/ChartText.js +13 -19
  147. package/esm/chart/text/{SmartChartTextGroup.js → ChartTextGroup.js} +4 -3
  148. package/esm/chart/text/index.js +1 -1
  149. package/esm/chart/utils/chart.js +29 -3
  150. package/esm/chart/utils/gradient.js +257 -0
  151. package/esm/chart/utils/index.js +4 -0
  152. package/esm/chart/utils/interpolate.js +644 -0
  153. package/esm/chart/utils/path.js +32 -9
  154. package/esm/chart/utils/point.js +69 -0
  155. package/esm/chart/utils/scrubber.js +132 -0
  156. package/esm/chart/utils/transition.js +111 -0
  157. package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.js +8 -4
  158. package/package.json +9 -9
  159. package/dts/chart/Point.d.ts +0 -153
  160. package/dts/chart/Point.d.ts.map +0 -1
  161. package/dts/chart/line/GradientLine.d.ts +0 -42
  162. package/dts/chart/line/GradientLine.d.ts.map +0 -1
  163. package/dts/chart/scrubber/ScrubberBeacon.d.ts +0 -93
  164. package/dts/chart/scrubber/ScrubberBeacon.d.ts.map +0 -1
  165. package/dts/chart/scrubber/ScrubberBeaconLabel.d.ts +0 -7
  166. package/dts/chart/scrubber/ScrubberBeaconLabel.d.ts.map +0 -1
  167. package/dts/chart/text/SmartChartTextGroup.d.ts.map +0 -1
  168. package/esm/chart/Point.css +0 -2
  169. package/esm/chart/scrubber/ScrubberBeacon.js +0 -195
@@ -1,4 +1,4 @@
1
- const _excluded = ["axisId", "position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "style", "className", "styles", "classNames", "GridLineComponent", "tickMarkLabelGap", "width", "minTickLabelGap", "showTickMarks", "showLine", "tickMarkSize", "tickInterval"];
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"];
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; }
@@ -12,10 +12,15 @@ import { AnimatePresence, m as motion } from 'framer-motion';
12
12
  import { useCartesianChartContext } from '../ChartProvider';
13
13
  import { DottedLine } from '../line/DottedLine';
14
14
  import { ReferenceLine } from '../line/ReferenceLine';
15
- import { SmartChartTextGroup } from '../text/SmartChartTextGroup';
16
- import { getAxisTicksData, isCategoricalScale } from '../utils';
17
- import { axisLineStyles, axisTickLabelsInitialAnimationVariants, axisTickMarkStyles, axisUpdateAnimationVariants } from './Axis';
15
+ import { SolidLine } from '../line/SolidLine';
16
+ import { ChartText } from '../text/ChartText';
17
+ import { ChartTextGroup } from '../text/ChartTextGroup';
18
+ import { getAxisTicksData, isCategoricalScale, lineToPath } from '../utils';
19
+ import { axisLineStyles, axisTickMarkStyles, axisUpdateAnimationVariants } from './Axis';
20
+ import { DefaultAxisTickLabel } from './DefaultAxisTickLabel';
18
21
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
+ const AXIS_WIDTH = 44;
23
+ const LABEL_SIZE = 20;
19
24
  const axisTickMarkCss = "cds-axisTickMarkCss-au2toz5";
20
25
  const axisLineCss = "cds-axisLineCss-akmofp5";
21
26
  export const YAxis = /*#__PURE__*/memo(_ref => {
@@ -26,18 +31,24 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
26
31
  requestedTickCount,
27
32
  ticks,
28
33
  tickLabelFormatter,
34
+ TickLabelComponent = DefaultAxisTickLabel,
29
35
  style,
30
36
  className,
31
37
  styles,
32
38
  classNames,
33
39
  GridLineComponent = DottedLine,
40
+ LineComponent = SolidLine,
41
+ TickMarkLineComponent = SolidLine,
34
42
  tickMarkLabelGap = 8,
35
- width = 44,
36
43
  minTickLabelGap = 0,
37
44
  showTickMarks,
38
45
  showLine,
39
46
  tickMarkSize = 4,
40
- tickInterval
47
+ tickInterval,
48
+ label,
49
+ labelGap = 4,
50
+ width = label ? AXIS_WIDTH + LABEL_SIZE : AXIS_WIDTH,
51
+ testID = 'y-axis'
41
52
  } = _ref,
42
53
  props = _objectWithoutProperties(_ref, _excluded);
43
54
  const registrationId = useId();
@@ -118,65 +129,85 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
118
129
  };
119
130
  });
120
131
  }, [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]);
121
- if (!yScale) return;
132
+ if (!yScale || !axisBounds) return;
133
+ const labelX = position === 'left' ? axisBounds.x + LABEL_SIZE / 2 : axisBounds.x + axisBounds.width - LABEL_SIZE / 2;
134
+ const labelY = axisBounds.y + axisBounds.height / 2;
122
135
  return /*#__PURE__*/_jsxs("g", _objectSpread(_objectSpread({
123
136
  className: cx(className, classNames === null || classNames === void 0 ? void 0 : classNames.root),
124
137
  "data-axis": "y",
125
138
  "data-position": position,
126
139
  style: _objectSpread(_objectSpread({}, style), styles === null || styles === void 0 ? void 0 : styles.root)
127
140
  }, props), {}, {
128
- children: [showGrid && /*#__PURE__*/_jsx(AnimatePresence, {
129
- initial: false,
130
- children: ticksData.map((tick, index) => {
131
- const horizontalLine = /*#__PURE__*/_jsx(ReferenceLine, {
132
- LineComponent: GridLineComponent,
133
- dataY: tick.tick,
134
- yAxisId: axisId
135
- });
136
- return animate ? /*#__PURE__*/_jsx(motion.g, {
137
- animate: "animate",
138
- exit: "exit",
139
- initial: "initial",
140
- variants: axisUpdateAnimationVariants,
141
- children: horizontalLine
142
- }, "grid-".concat(tick.tick, "-").concat(index)) : /*#__PURE__*/_jsx("g", {
143
- children: horizontalLine
144
- }, "grid-".concat(tick.tick, "-").concat(index));
145
- })
146
- }), chartTextData && /*#__PURE__*/_jsx(AnimatePresence, {
147
- children: /*#__PURE__*/_jsx(motion.g, {
148
- animate: "animate",
149
- exit: "exit",
150
- initial: "initial",
151
- variants: animate ? axisTickLabelsInitialAnimationVariants : undefined,
152
- children: /*#__PURE__*/_jsx(SmartChartTextGroup, {
153
- prioritizeEndLabels: true,
154
- labels: chartTextData,
155
- minGap: minTickLabelGap
141
+ children: [showGrid && /*#__PURE__*/_jsx("g", {
142
+ "data-testid": "".concat(testID, "-grid"),
143
+ children: /*#__PURE__*/_jsx(AnimatePresence, {
144
+ initial: false,
145
+ children: ticksData.map((tick, index) => {
146
+ const horizontalLine = /*#__PURE__*/_jsx(ReferenceLine, {
147
+ LineComponent: GridLineComponent,
148
+ dataY: tick.tick,
149
+ yAxisId: axisId
150
+ });
151
+ return animate ? /*#__PURE__*/_jsx(motion.g, {
152
+ animate: "animate",
153
+ exit: "exit",
154
+ initial: "initial",
155
+ variants: axisUpdateAnimationVariants,
156
+ children: horizontalLine
157
+ }, "grid-".concat(tick.tick, "-").concat(index)) : /*#__PURE__*/_jsx("g", {
158
+ children: horizontalLine
159
+ }, "grid-".concat(tick.tick, "-").concat(index));
156
160
  })
157
161
  })
158
- }), axisBounds && showTickMarks && /*#__PURE__*/_jsx("g", {
159
- "data-testid": "tick-marks",
162
+ }), chartTextData && /*#__PURE__*/_jsx(ChartTextGroup, {
163
+ prioritizeEndLabels: true,
164
+ LabelComponent: TickLabelComponent,
165
+ labels: chartTextData,
166
+ minGap: minTickLabelGap
167
+ }), showTickMarks && /*#__PURE__*/_jsx("g", {
168
+ "data-testid": "".concat(testID, "-tick-marks"),
160
169
  children: ticksData.map((tick, index) => {
161
170
  const tickX = position === 'left' ? axisBounds.x + axisBounds.width : axisBounds.x;
162
171
  const tickMarkSizePixels = tickMarkSize;
163
172
  const tickX2 = position === 'left' ? axisBounds.x + axisBounds.width - tickMarkSizePixels : axisBounds.x + tickMarkSizePixels;
164
- return /*#__PURE__*/_jsx("line", {
173
+ return /*#__PURE__*/_jsx(TickMarkLineComponent, {
174
+ animate: false,
165
175
  className: cx(axisTickMarkCss, classNames === null || classNames === void 0 ? void 0 : classNames.tickMark),
166
- style: styles === null || styles === void 0 ? void 0 : styles.tickMark,
167
- x1: tickX,
168
- x2: tickX2,
169
- y1: tick.position,
170
- y2: tick.position
176
+ clipRect: null,
177
+ d: lineToPath(tickX, tick.position, tickX2, tick.position),
178
+ stroke: "var(--color-fg)",
179
+ strokeLinecap: "square",
180
+ strokeWidth: 1,
181
+ style: styles === null || styles === void 0 ? void 0 : styles.tickMark
171
182
  }, "tick-mark-".concat(tick.tick, "-").concat(index));
172
183
  })
173
- }), axisBounds && showLine && /*#__PURE__*/_jsx("line", {
184
+ }), showLine && /*#__PURE__*/_jsx(LineComponent, {
185
+ animate: false,
174
186
  className: cx(axisLineCss, classNames === null || classNames === void 0 ? void 0 : classNames.line),
175
- style: styles === null || styles === void 0 ? void 0 : styles.line,
176
- x1: position === 'left' ? axisBounds.x + axisBounds.width : axisBounds.x,
177
- x2: position === 'left' ? axisBounds.x + axisBounds.width : axisBounds.x,
178
- y1: axisBounds.y,
179
- y2: axisBounds.y + axisBounds.height
187
+ clipRect: null,
188
+ d: lineToPath(position === 'left' ? axisBounds.x + axisBounds.width : axisBounds.x, axisBounds.y, position === 'left' ? axisBounds.x + axisBounds.width : axisBounds.x, axisBounds.y + axisBounds.height),
189
+ "data-testid": "".concat(testID, "-line"),
190
+ stroke: "var(--color-fg)",
191
+ strokeLinecap: "square",
192
+ strokeWidth: 1,
193
+ style: styles === null || styles === void 0 ? void 0 : styles.line
194
+ }), label && /*#__PURE__*/_jsx("g", {
195
+ "data-testid": "".concat(testID, "-label"),
196
+ style: {
197
+ transformOrigin: "".concat(labelX, "px ").concat(labelY, "px"),
198
+ transform: "rotate(".concat(position === 'left' ? -90 : 90, "deg)")
199
+ },
200
+ children: /*#__PURE__*/_jsx(ChartText, {
201
+ disableRepositioning: true,
202
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.label,
203
+ horizontalAlignment: "center",
204
+ style: styles === null || styles === void 0 ? void 0 : styles.label,
205
+ testID: "".concat(testID, "-label-text"),
206
+ verticalAlignment: "middle",
207
+ x: labelX,
208
+ y: labelY,
209
+ children: label
210
+ })
180
211
  })]
181
212
  }));
182
213
  });
@@ -1,5 +1,6 @@
1
1
  // codegen:start {preset: barrel, include: ./*.tsx, exclude: ./__stories__/*.tsx}
2
2
  export * from './Axis';
3
+ export * from './DefaultAxisTickLabel';
3
4
  export * from './XAxis';
4
5
  export * from './YAxis';
5
6
  // codegen:end
@@ -30,7 +30,8 @@ export const Bar = /*#__PURE__*/memo(_ref => {
30
30
  strokeWidth,
31
31
  borderRadius = 4,
32
32
  roundTop = true,
33
- roundBottom = true
33
+ roundBottom = true,
34
+ transition
34
35
  } = _ref;
35
36
  const barPath = useMemo(() => {
36
37
  return getBarPath(x, y, width, height, borderRadius, roundTop, roundBottom);
@@ -52,6 +53,7 @@ export const Bar = /*#__PURE__*/memo(_ref => {
52
53
  roundTop: roundTop,
53
54
  stroke: stroke,
54
55
  strokeWidth: strokeWidth,
56
+ transition: transition,
55
57
  width: width,
56
58
  x: x,
57
59
  y: y
@@ -1,4 +1,4 @@
1
- const _excluded = ["series", "stacked", "showXAxis", "showYAxis", "xAxis", "yAxis", "inset", "children", "barPadding", "BarComponent", "fillOpacity", "stroke", "strokeWidth", "borderRadius", "roundBaseline", "BarStackComponent", "stackGap", "barMinSize", "stackMinSize"],
1
+ const _excluded = ["series", "stacked", "showXAxis", "showYAxis", "xAxis", "yAxis", "inset", "children", "barPadding", "BarComponent", "fillOpacity", "stroke", "strokeWidth", "borderRadius", "roundBaseline", "BarStackComponent", "stackGap", "barMinSize", "stackMinSize", "transition"],
2
2
  _excluded2 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range"],
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; }
@@ -22,7 +22,7 @@ export const BarChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =>
22
22
  showYAxis,
23
23
  xAxis,
24
24
  yAxis,
25
- inset: userInset,
25
+ inset,
26
26
  children,
27
27
  barPadding,
28
28
  BarComponent,
@@ -34,44 +34,26 @@ export const BarChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =>
34
34
  BarStackComponent,
35
35
  stackGap,
36
36
  barMinSize,
37
- stackMinSize
37
+ stackMinSize,
38
+ transition
38
39
  } = _ref,
39
40
  chartProps = _objectWithoutProperties(_ref, _excluded);
40
- const calculatedInset = useMemo(() => getChartInset(userInset, defaultChartInset), [userInset]);
41
-
42
- // Convert BarSeries to Series for Chart context
43
- const chartSeries = useMemo(() => {
44
- return series === null || series === void 0 ? void 0 : series.map(s => ({
45
- id: s.id,
46
- data: s.data,
47
- label: s.label,
48
- color: s.color,
49
- yAxisId: s.yAxisId,
50
- stackId: s.stackId
51
- }));
52
- }, [series]);
41
+ const calculatedInset = useMemo(() => getChartInset(inset, defaultChartInset), [inset]);
53
42
  const transformedSeries = useMemo(() => {
54
- if (!stacked || !chartSeries) return chartSeries;
55
- return chartSeries.map(s => {
56
- var _s$stackId;
57
- return _objectSpread(_objectSpread({}, s), {}, {
58
- stackId: (_s$stackId = s.stackId) !== null && _s$stackId !== void 0 ? _s$stackId : defaultStackId
59
- });
60
- });
61
- }, [chartSeries, stacked]);
62
- const seriesToRender = transformedSeries !== null && transformedSeries !== void 0 ? transformedSeries : chartSeries;
63
-
64
- // Keep the original series with bar-specific props for BarPlot
65
- const barSeriesToRender = useMemo(() => {
66
43
  if (!stacked || !series) return series;
67
44
  return series.map(s => {
68
- var _s$stackId2;
45
+ var _s$stackId;
69
46
  return _objectSpread(_objectSpread({}, s), {}, {
70
- stackId: (_s$stackId2 = s.stackId) !== null && _s$stackId2 !== void 0 ? _s$stackId2 : defaultStackId
47
+ stackId: (_s$stackId = s.stackId) !== null && _s$stackId !== void 0 ? _s$stackId : defaultStackId
71
48
  });
72
49
  });
73
50
  }, [series, stacked]);
74
51
 
52
+ // Unlike other charts with custom props per series, we do not need to pick out
53
+ // the props from each series that shouldn't be passed to CartesianChart
54
+ const seriesToRender = transformedSeries !== null && transformedSeries !== void 0 ? transformedSeries : series;
55
+ const seriesIds = seriesToRender === null || seriesToRender === void 0 ? void 0 : seriesToRender.map(s => s.id);
56
+
75
57
  // Split axis props into config props for Chart and visual props for axis components
76
58
  const _ref2 = xAxis || {},
77
59
  {
@@ -137,11 +119,12 @@ export const BarChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =>
137
119
  borderRadius: borderRadius,
138
120
  fillOpacity: fillOpacity,
139
121
  roundBaseline: roundBaseline,
140
- seriesIds: barSeriesToRender === null || barSeriesToRender === void 0 ? void 0 : barSeriesToRender.map(s => s.id),
122
+ seriesIds: seriesIds,
141
123
  stackGap: stackGap,
142
124
  stackMinSize: stackMinSize,
143
125
  stroke: stroke,
144
- strokeWidth: strokeWidth
126
+ strokeWidth: strokeWidth,
127
+ transition: transition
145
128
  }), children]
146
129
  }));
147
130
  }));
@@ -22,7 +22,8 @@ export const BarPlot = /*#__PURE__*/memo(_ref => {
22
22
  BarStackComponent,
23
23
  stackGap,
24
24
  barMinSize,
25
- stackMinSize
25
+ stackMinSize,
26
+ transition
26
27
  } = _ref;
27
28
  const {
28
29
  series: allSeries,
@@ -73,7 +74,6 @@ export const BarPlot = /*#__PURE__*/memo(_ref => {
73
74
  })
74
75
  }), /*#__PURE__*/_jsx("g", {
75
76
  clipPath: "url(#".concat(clipPathId, ")"),
76
- "data-testid": "whoa",
77
77
  children: stackGroups.map((group, stackIndex) => /*#__PURE__*/_jsx(BarStackGroup, {
78
78
  BarComponent: defaultBarComponent,
79
79
  BarStackComponent: BarStackComponent,
@@ -89,6 +89,7 @@ export const BarPlot = /*#__PURE__*/memo(_ref => {
89
89
  stroke: defaultStroke,
90
90
  strokeWidth: defaultStrokeWidth,
91
91
  totalStacks: stackGroups.length,
92
+ transition: transition,
92
93
  yAxisId: group.yAxisId
93
94
  }, group.stackId))
94
95
  })]
@@ -5,9 +5,11 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
5
5
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
6
  import React, { memo, useMemo } from 'react';
7
7
  import { useCartesianChartContext } from '../ChartProvider';
8
+ import { evaluateGradientAtValue, getGradientConfig } from '../utils/gradient';
8
9
  import { Bar } from './Bar';
9
10
  import { DefaultBarStack } from './DefaultBarStack';
10
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
+ const EPSILON = 1e-4;
11
13
  /**
12
14
  * BarStack component that renders a single stack of bars at a specific category index.
13
15
  * Handles the stacking logic for bars within a single category.
@@ -29,13 +31,16 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
29
31
  stackGap,
30
32
  barMinSize,
31
33
  stackMinSize,
32
- roundBaseline
34
+ roundBaseline,
35
+ transition
33
36
  } = _ref;
34
37
  const {
35
38
  getSeriesData,
36
- getXAxis
39
+ getXAxis,
40
+ getXScale,
41
+ getSeries
37
42
  } = useCartesianChartContext();
38
- const stackGapPx = stackGap;
43
+ const xScale = getXScale();
39
44
  const barMinSizePx = barMinSize;
40
45
  const stackMinSizePx = stackMinSize;
41
46
  const xAxis = getXAxis();
@@ -47,6 +52,20 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
47
52
  const baseline = (_yScale = yScale(baselineValue)) !== null && _yScale !== void 0 ? _yScale : rect.y + rect.height;
48
53
  return Math.max(rect.y, Math.min(baseline, rect.y + rect.height));
49
54
  }, [rect.height, rect.y, yScale]);
55
+ const seriesGradients = useMemo(() => {
56
+ return series.map(s => {
57
+ if (!s.gradient || !xScale || !yScale) return null;
58
+ const gradientScale = s.gradient.axis === 'x' ? xScale : yScale;
59
+ const stops = getGradientConfig(s.gradient, xScale, yScale);
60
+ if (!stops) return null;
61
+ return {
62
+ seriesId: s.id,
63
+ gradient: s.gradient,
64
+ scale: gradientScale,
65
+ stops
66
+ };
67
+ });
68
+ }, [series, xScale, yScale]);
50
69
 
51
70
  // Calculate bars for this specific category
52
71
  const {
@@ -65,7 +84,7 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
65
84
 
66
85
  // Process each series in the stack
67
86
  series.forEach(s => {
68
- var _yScale2, _yScale3;
87
+ var _yScale2, _yScale3, _s$color;
69
88
  const data = getSeriesData(s.id);
70
89
  if (!data) return;
71
90
  const value = data[categoryIndex];
@@ -103,6 +122,30 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
103
122
  // Update stack bounds
104
123
  minY = Math.min(minY, y);
105
124
  maxY = Math.max(maxY, y + height);
125
+ let barFill = (_s$color = s.color) !== null && _s$color !== void 0 ? _s$color : 'var(--color-fgPrimary)';
126
+
127
+ // Evaluate gradient if provided (using precomputed stops)
128
+ const seriesGradientConfig = seriesGradients.find(g => (g === null || g === void 0 ? void 0 : g.seriesId) === s.id);
129
+ if (seriesGradientConfig && originalValue !== null && originalValue !== undefined) {
130
+ var _seriesGradientConfig;
131
+ const axis = (_seriesGradientConfig = seriesGradientConfig.gradient.axis) !== null && _seriesGradientConfig !== void 0 ? _seriesGradientConfig : 'y';
132
+ // For x-axis gradient, use the categoryIndex
133
+ // For y-axis gradient, use the ORIGINAL data value (not the processed top value)
134
+ // This is important for bar charts where originalValue might be a single number (e.g., -40, 15)
135
+ // or a tuple (e.g., [0, 10] for range bars)
136
+ let evalValue;
137
+ if (axis === 'x') {
138
+ evalValue = categoryIndex;
139
+ } else {
140
+ // Use original value for evaluation - handles both single numbers and tuples
141
+ evalValue = Array.isArray(originalValue) ? originalValue[1] : originalValue;
142
+ }
143
+ const evaluatedColor = evaluateGradientAtValue(seriesGradientConfig.stops, evalValue, seriesGradientConfig.scale);
144
+ if (evaluatedColor) {
145
+ // Only apply gradient color if fill is not explicitly set
146
+ barFill = evaluatedColor;
147
+ }
148
+ }
106
149
  allBars.push({
107
150
  seriesId: s.id,
108
151
  x,
@@ -111,21 +154,16 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
111
154
  height,
112
155
  dataY: value,
113
156
  // Store the actual data value
114
- // Use series-specific properties, falling back to defaults
115
- BarComponent: s.BarComponent,
116
- fill: s.fill || s.color || 'var(--color-fgPrimary)',
117
- fillOpacity: s.fillOpacity,
118
- stroke: s.stroke,
119
- strokeWidth: s.strokeWidth,
120
- // Pass context data for custom components
121
- roundTop: roundBaseline || barTop !== baseline,
122
- roundBottom: roundBaseline || barBottom !== baseline,
157
+ fill: barFill,
158
+ // Check if the bar should be rounded based on the baseline, with an epsilon to handle floating-point rounding
159
+ roundTop: roundBaseline || Math.abs(barTop - baseline) >= EPSILON,
160
+ roundBottom: roundBaseline || Math.abs(barBottom - baseline) >= EPSILON,
123
161
  shouldApplyGap
124
162
  });
125
163
  });
126
164
 
127
165
  // Apply proportional gap distribution to maintain total stack height
128
- if (stackGapPx && allBars.length > 1) {
166
+ if (stackGap && allBars.length > 1) {
129
167
  // Separate bars by baseline side
130
168
  const barsAboveBaseline = allBars.filter(bar => {
131
169
  const [bottom, top] = bar.dataY.sort((a, b) => a - b);
@@ -138,7 +176,7 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
138
176
 
139
177
  // Apply proportional gaps to bars above baseline
140
178
  if (barsAboveBaseline.length > 1) {
141
- const totalGapSpace = stackGapPx * (barsAboveBaseline.length - 1);
179
+ const totalGapSpace = stackGap * (barsAboveBaseline.length - 1);
142
180
  const totalDataHeight = barsAboveBaseline.reduce((sum, bar) => sum + bar.height, 0);
143
181
  const heightReduction = totalGapSpace / totalDataHeight;
144
182
 
@@ -160,13 +198,13 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
160
198
  }
161
199
 
162
200
  // Move to next position (include gap for next bar)
163
- currentY = newY - (index < sortedBars.length - 1 ? stackGapPx : 0);
201
+ currentY = newY - (index < sortedBars.length - 1 ? stackGap : 0);
164
202
  });
165
203
  }
166
204
 
167
205
  // Apply proportional gaps to bars below baseline
168
206
  if (barsBelowBaseline.length > 1) {
169
- const totalGapSpace = stackGapPx * (barsBelowBaseline.length - 1);
207
+ const totalGapSpace = stackGap * (barsBelowBaseline.length - 1);
170
208
  const totalDataHeight = barsBelowBaseline.reduce((sum, bar) => sum + bar.height, 0);
171
209
  const heightReduction = totalGapSpace / totalDataHeight;
172
210
 
@@ -187,7 +225,7 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
187
225
  }
188
226
 
189
227
  // Move to next position (include gap for next bar)
190
- currentY = currentY + newHeight + (index < sortedBars.length - 1 ? stackGapPx : 0);
228
+ currentY = currentY + newHeight + (index < sortedBars.length - 1 ? stackGap : 0);
191
229
  });
192
230
  }
193
231
 
@@ -323,8 +361,8 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
323
361
  return bars.sort((a, b) => b.y - a.y).map((a, index) => {
324
362
  const barBefore = index > 0 ? bars[index - 1] : null;
325
363
  const barAfter = index < bars.length - 1 ? bars[index + 1] : null;
326
- const shouldRoundTop = index === bars.length - 1 || a.shouldApplyGap && stackGapPx || !a.shouldApplyGap && barAfter && barAfter.y + barAfter.height !== a.y;
327
- const shouldRoundBottom = index === 0 || a.shouldApplyGap && stackGapPx || !a.shouldApplyGap && barBefore && barBefore.y !== a.y + a.height;
364
+ const shouldRoundTop = index === bars.length - 1 || a.shouldApplyGap && stackGap || !a.shouldApplyGap && barAfter && barAfter.y + barAfter.height !== a.y;
365
+ const shouldRoundBottom = index === 0 || a.shouldApplyGap && stackGap || !a.shouldApplyGap && barBefore && barBefore.y !== a.y + a.height;
328
366
  return _objectSpread(_objectSpread({}, a), {}, {
329
367
  roundTop: Boolean(a.roundTop && shouldRoundTop),
330
368
  roundBottom: Boolean(a.roundBottom && shouldRoundBottom)
@@ -479,7 +517,7 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
479
517
  bars: allBars,
480
518
  stackRect: stackBounds
481
519
  };
482
- }, [series, x, width, getSeriesData, categoryIndex, roundBaseline, baseline, stackGapPx, barMinSizePx, stackMinSizePx, yScale]);
520
+ }, [series, stackGap, barMinSizePx, x, baseline, width, stackMinSizePx, getSeriesData, categoryIndex, yScale, seriesGradients, roundBaseline]);
483
521
  const xData = xAxis !== null && xAxis !== void 0 && xAxis.data && Array.isArray(xAxis.data) && typeof xAxis.data[0] === 'number' ? xAxis.data : undefined;
484
522
  const dataX = xData ? xData[categoryIndex] : categoryIndex;
485
523
  const barElements = bars.map((bar, index) => {
@@ -497,19 +535,23 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
497
535
  roundTop: bar.roundTop,
498
536
  stroke: (_bar$stroke = bar.stroke) !== null && _bar$stroke !== void 0 ? _bar$stroke : defaultStroke,
499
537
  strokeWidth: (_bar$strokeWidth = bar.strokeWidth) !== null && _bar$strokeWidth !== void 0 ? _bar$strokeWidth : defaultStrokeWidth,
538
+ transition: transition,
500
539
  width: bar.width,
501
540
  x: bar.x,
502
541
  y: bar.y
503
542
  }, "".concat(bar.seriesId, "-").concat(categoryIndex, "-").concat(index));
504
543
  });
505
- const stackRoundBottom = roundBaseline || stackRect.y + stackRect.height !== baseline;
506
- const stackRoundTop = roundBaseline || stackRect.y !== baseline;
544
+
545
+ // Check if the bar should be rounded based on the baseline, with an epsilon to handle floating-point rounding
546
+ const stackRoundBottom = roundBaseline || Math.abs(stackRect.y + stackRect.height - baseline) >= EPSILON;
547
+ const stackRoundTop = roundBaseline || Math.abs(stackRect.y - baseline) >= EPSILON;
507
548
  return /*#__PURE__*/_jsx(BarStackComponent, {
508
549
  borderRadius: borderRadius,
509
550
  categoryIndex: categoryIndex,
510
551
  height: stackRect.height,
511
552
  roundBottom: stackRoundBottom,
512
553
  roundTop: stackRoundTop,
554
+ transition: transition,
513
555
  width: stackRect.width,
514
556
  x: stackRect.x,
515
557
  y: stackRect.y,
@@ -25,26 +25,15 @@ export const BarStackGroup = /*#__PURE__*/memo(_ref => {
25
25
  } = _ref,
26
26
  props = _objectWithoutProperties(_ref, _excluded);
27
27
  const {
28
- getSeriesData,
29
28
  getXScale,
30
29
  getYScale,
31
- drawingArea
30
+ drawingArea,
31
+ dataLength
32
32
  } = useCartesianChartContext();
33
33
  const xScale = getXScale();
34
34
  const yScale = getYScale(yAxisId);
35
- const maxDataLength = useMemo(() => {
36
- if (!series || series.length === 0) return 0;
37
- let maxLength = 0;
38
- series.forEach(s => {
39
- const data = getSeriesData(s.id);
40
- if (data && data.length > maxLength) {
41
- maxLength = data.length;
42
- }
43
- });
44
- return maxLength;
45
- }, [series, getSeriesData]);
46
35
  const stackConfigs = useMemo(() => {
47
- if (!xScale || !yScale || !drawingArea || maxDataLength === 0) return [];
36
+ if (!xScale || !yScale || !drawingArea || dataLength === 0) return [];
48
37
  if (!isCategoricalScale(xScale)) {
49
38
  return [];
50
39
  }
@@ -57,7 +46,8 @@ export const BarStackGroup = /*#__PURE__*/memo(_ref => {
57
46
  const configs = [];
58
47
 
59
48
  // Calculate position for each category
60
- for (let categoryIndex = 0; categoryIndex < maxDataLength; categoryIndex++) {
49
+ // todo: look at using xDomain for this instead of dataLength
50
+ for (let categoryIndex = 0; categoryIndex < dataLength; categoryIndex++) {
61
51
  // Get x position for this category
62
52
  const categoryX = xScale(categoryIndex);
63
53
  if (categoryX !== undefined) {
@@ -71,11 +61,11 @@ export const BarStackGroup = /*#__PURE__*/memo(_ref => {
71
61
  }
72
62
  }
73
63
  return configs;
74
- }, [xScale, yScale, drawingArea, maxDataLength, stackIndex, totalStacks, barPadding]);
64
+ }, [xScale, yScale, drawingArea, dataLength, stackIndex, totalStacks, barPadding]);
75
65
  if (xScale && !isCategoricalScale(xScale)) {
76
66
  throw new Error('BarStackGroup requires a band scale for x-axis. See https://cds.coinbase.com/components/graphs/XAxis/#scale-type');
77
67
  }
78
- if (!yScale || !drawingArea || stackConfigs.length === 0) return;
68
+ if (!yScale || !drawingArea || stackConfigs.length === 0) return null;
79
69
  return stackConfigs.map(_ref2 => {
80
70
  let {
81
71
  categoryIndex,
@@ -1,4 +1,4 @@
1
- const _excluded = ["x", "width", "borderRadius", "roundTop", "roundBottom", "originY", "d", "fill", "fillOpacity", "dataX", "dataY"];
1
+ const _excluded = ["x", "width", "borderRadius", "roundTop", "roundBottom", "originY", "d", "fill", "fillOpacity", "dataX", "dataY", "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; }
@@ -26,7 +26,8 @@ export const DefaultBar = /*#__PURE__*/memo(_ref => {
26
26
  fill = 'var(--color-fgPrimary)',
27
27
  fillOpacity = 1,
28
28
  dataX,
29
- dataY
29
+ dataY,
30
+ transition
30
31
  } = _ref,
31
32
  props = _objectWithoutProperties(_ref, _excluded);
32
33
  const {
@@ -49,11 +50,7 @@ export const DefaultBar = /*#__PURE__*/memo(_ref => {
49
50
  initial: {
50
51
  d: initialPath
51
52
  },
52
- transition: {
53
- type: 'spring',
54
- duration: 1,
55
- bounce: 0
56
- }
53
+ transition: transition
57
54
  }));
58
55
  }
59
56
  return /*#__PURE__*/_jsx("path", _objectSpread(_objectSpread({}, props), {}, {
@@ -18,7 +18,8 @@ export const DefaultBarStack = /*#__PURE__*/memo(_ref => {
18
18
  borderRadius = 4,
19
19
  roundTop = true,
20
20
  roundBottom = true,
21
- yOrigin
21
+ yOrigin,
22
+ transition
22
23
  } = _ref;
23
24
  const {
24
25
  animate
@@ -28,8 +29,9 @@ export const DefaultBarStack = /*#__PURE__*/memo(_ref => {
28
29
  return getBarPath(x, y, width, height, borderRadius, roundTop, roundBottom);
29
30
  }, [x, y, width, height, borderRadius, roundTop, roundBottom]);
30
31
  const initialClipPathData = useMemo(() => {
32
+ if (!animate) return undefined;
31
33
  return getBarPath(x, yOrigin !== null && yOrigin !== void 0 ? yOrigin : y + height, width, 1, borderRadius, roundTop, roundBottom);
32
- }, [x, yOrigin, y, height, width, borderRadius, roundTop, roundBottom]);
34
+ }, [animate, x, yOrigin, y, height, width, borderRadius, roundTop, roundBottom]);
33
35
  return /*#__PURE__*/_jsxs(_Fragment, {
34
36
  children: [/*#__PURE__*/_jsx("defs", {
35
37
  children: /*#__PURE__*/_jsx("clipPath", {
@@ -41,11 +43,7 @@ export const DefaultBarStack = /*#__PURE__*/memo(_ref => {
41
43
  initial: {
42
44
  d: initialClipPathData
43
45
  },
44
- transition: {
45
- type: 'spring',
46
- duration: 1,
47
- bounce: 0
48
- }
46
+ transition: transition
49
47
  }) : /*#__PURE__*/_jsx("path", {
50
48
  d: clipPathData
51
49
  })