@economic/taco 2.56.0 → 2.57.0-charts.1

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.
package/dist/taco.js CHANGED
@@ -19610,8 +19610,8 @@ function mixValues(target, follow, lead, progress2, shouldCrossfadeOpacity, isOn
19610
19610
  }
19611
19611
  for (var i3 = 0; i3 < numBorders; i3++) {
19612
19612
  var borderLabel = "border".concat(borders[i3], "Radius");
19613
- var followRadius = getRadius(follow, borderLabel);
19614
- var leadRadius = getRadius(lead, borderLabel);
19613
+ var followRadius = getRadius$1(follow, borderLabel);
19614
+ var leadRadius = getRadius$1(lead, borderLabel);
19615
19615
  if (followRadius === void 0 && leadRadius === void 0)
19616
19616
  continue;
19617
19617
  followRadius || (followRadius = 0);
@@ -19630,7 +19630,7 @@ function mixValues(target, follow, lead, progress2, shouldCrossfadeOpacity, isOn
19630
19630
  target.rotate = mix(follow.rotate || 0, lead.rotate || 0, progress2);
19631
19631
  }
19632
19632
  }
19633
- function getRadius(values, radiusName) {
19633
+ function getRadius$1(values, radiusName) {
19634
19634
  var _a;
19635
19635
  return (_a = values[radiusName]) !== null && _a !== void 0 ? _a : values.borderRadius;
19636
19636
  }
@@ -61545,7 +61545,7 @@ var symbolFactories = {
61545
61545
  symbolTriangle,
61546
61546
  symbolWye
61547
61547
  };
61548
- var RADIAN$2 = Math.PI / 180;
61548
+ var RADIAN$3 = Math.PI / 180;
61549
61549
  var getSymbolFactory = function getSymbolFactory2(type) {
61550
61550
  var name = "symbol".concat(upperFirst(type));
61551
61551
  return symbolFactories[name] || symbolCircle;
@@ -61562,7 +61562,7 @@ var calculateAreaSize = function calculateAreaSize2(size2, sizeType, type) {
61562
61562
  case "square":
61563
61563
  return size2 * size2;
61564
61564
  case "star": {
61565
- var angle = 18 * RADIAN$2;
61565
+ var angle = 18 * RADIAN$3;
61566
61566
  return 1.25 * size2 * size2 * (Math.tan(angle) - Math.tan(angle * 2) * Math.pow(Math.tan(angle), 2));
61567
61567
  }
61568
61568
  case "triangle":
@@ -64034,7 +64034,7 @@ function _iterableToArrayLimit$b(r2, l2) {
64034
64034
  function _arrayWithHoles$c(arr) {
64035
64035
  if (Array.isArray(arr)) return arr;
64036
64036
  }
64037
- var ResponsiveContainer$1 = /* @__PURE__ */ forwardRef(function(_ref, ref) {
64037
+ var ResponsiveContainer = /* @__PURE__ */ forwardRef(function(_ref, ref) {
64038
64038
  var aspect = _ref.aspect, _ref$initialDimension = _ref.initialDimension, initialDimension = _ref$initialDimension === void 0 ? {
64039
64039
  width: -1,
64040
64040
  height: -1
@@ -69172,7 +69172,7 @@ function _toPrimitive$y(t3, r2) {
69172
69172
  }
69173
69173
  return ("string" === r2 ? String : Number)(t3);
69174
69174
  }
69175
- var getLegendProps$1 = function getLegendProps(_ref) {
69175
+ var getLegendProps = function getLegendProps2(_ref) {
69176
69176
  var children = _ref.children, formattedGraphicalItems = _ref.formattedGraphicalItems, legendWidth = _ref.legendWidth, legendContent = _ref.legendContent;
69177
69177
  var legendItem = findChildByType(children, Legend$2);
69178
69178
  if (!legendItem) {
@@ -69515,7 +69515,7 @@ var getBarPosition = function getBarPosition2(_ref3) {
69515
69515
  var appendOffsetOfLegend = function appendOffsetOfLegend2(offset2, _unused, props, legendBox) {
69516
69516
  var children = props.children, width = props.width, margin = props.margin;
69517
69517
  var legendWidth = width - (margin.left || 0) - (margin.right || 0);
69518
- var legendProps = getLegendProps$1({
69518
+ var legendProps = getLegendProps({
69519
69519
  children,
69520
69520
  legendWidth
69521
69521
  });
@@ -70189,14 +70189,14 @@ function _iterableToArrayLimit$6(r2, l2) {
70189
70189
  function _arrayWithHoles$7(arr) {
70190
70190
  if (Array.isArray(arr)) return arr;
70191
70191
  }
70192
- var RADIAN$1 = Math.PI / 180;
70192
+ var RADIAN$2 = Math.PI / 180;
70193
70193
  var radianToDegree = function radianToDegree2(angleInRadian) {
70194
70194
  return angleInRadian * 180 / Math.PI;
70195
70195
  };
70196
70196
  var polarToCartesian = function polarToCartesian2(cx, cy, radius, angle) {
70197
70197
  return {
70198
- x: cx + Math.cos(-RADIAN$1 * angle) * radius,
70199
- y: cy + Math.sin(-RADIAN$1 * angle) * radius
70198
+ x: cx + Math.cos(-RADIAN$2 * angle) * radius,
70199
+ y: cy + Math.sin(-RADIAN$2 * angle) * radius
70200
70200
  };
70201
70201
  };
70202
70202
  var getMaxRadius = function getMaxRadius2(width, height) {
@@ -70704,7 +70704,7 @@ var getAttrsOfCartesianLabel = function getAttrsOfCartesianLabel2(props) {
70704
70704
  var isPolar = function isPolar2(viewBox) {
70705
70705
  return "cx" in viewBox && isNumber(viewBox.cx);
70706
70706
  };
70707
- function Label(_ref4) {
70707
+ function Label$1(_ref4) {
70708
70708
  var _ref4$offset = _ref4.offset, offset2 = _ref4$offset === void 0 ? 5 : _ref4$offset, restProps = _objectWithoutProperties$d(_ref4, _excluded$d);
70709
70709
  var props = _objectSpread$s({
70710
70710
  offset: offset2
@@ -70737,7 +70737,7 @@ function Label(_ref4) {
70737
70737
  breakAll: textBreakAll
70738
70738
  }), label);
70739
70739
  }
70740
- Label.displayName = "Label";
70740
+ Label$1.displayName = "Label";
70741
70741
  var parseViewBox = function parseViewBox2(props) {
70742
70742
  var cx = props.cx, cy = props.cy, angle = props.angle, startAngle = props.startAngle, endAngle = props.endAngle, r2 = props.r, radius = props.radius, innerRadius = props.innerRadius, outerRadius = props.outerRadius, x3 = props.x, y4 = props.y, top = props.top, left = props.left, width = props.width, height = props.height, clockWise = props.clockWise, labelViewBox = props.labelViewBox;
70743
70743
  if (labelViewBox) {
@@ -70790,40 +70790,40 @@ var parseLabel = function parseLabel2(label, viewBox) {
70790
70790
  return null;
70791
70791
  }
70792
70792
  if (label === true) {
70793
- return /* @__PURE__ */ React__default.createElement(Label, {
70793
+ return /* @__PURE__ */ React__default.createElement(Label$1, {
70794
70794
  key: "label-implicit",
70795
70795
  viewBox
70796
70796
  });
70797
70797
  }
70798
70798
  if (isNumOrStr(label)) {
70799
- return /* @__PURE__ */ React__default.createElement(Label, {
70799
+ return /* @__PURE__ */ React__default.createElement(Label$1, {
70800
70800
  key: "label-implicit",
70801
70801
  viewBox,
70802
70802
  value: label
70803
70803
  });
70804
70804
  }
70805
70805
  if (/* @__PURE__ */ isValidElement(label)) {
70806
- if (label.type === Label) {
70806
+ if (label.type === Label$1) {
70807
70807
  return /* @__PURE__ */ cloneElement(label, {
70808
70808
  key: "label-implicit",
70809
70809
  viewBox
70810
70810
  });
70811
70811
  }
70812
- return /* @__PURE__ */ React__default.createElement(Label, {
70812
+ return /* @__PURE__ */ React__default.createElement(Label$1, {
70813
70813
  key: "label-implicit",
70814
70814
  content: label,
70815
70815
  viewBox
70816
70816
  });
70817
70817
  }
70818
70818
  if (isFunction(label)) {
70819
- return /* @__PURE__ */ React__default.createElement(Label, {
70819
+ return /* @__PURE__ */ React__default.createElement(Label$1, {
70820
70820
  key: "label-implicit",
70821
70821
  content: label,
70822
70822
  viewBox
70823
70823
  });
70824
70824
  }
70825
70825
  if (isObject(label)) {
70826
- return /* @__PURE__ */ React__default.createElement(Label, _extends$o({
70826
+ return /* @__PURE__ */ React__default.createElement(Label$1, _extends$o({
70827
70827
  viewBox
70828
70828
  }, label, {
70829
70829
  key: "label-implicit"
@@ -70838,7 +70838,7 @@ var renderCallByParent$1 = function renderCallByParent(parentProps, viewBox) {
70838
70838
  }
70839
70839
  var children = parentProps.children;
70840
70840
  var parentViewBox = parseViewBox(parentProps);
70841
- var explicitChildren = findAllByType(children, Label).map(function(child, index2) {
70841
+ var explicitChildren = findAllByType(children, Label$1).map(function(child, index2) {
70842
70842
  return /* @__PURE__ */ cloneElement(child, {
70843
70843
  viewBox: viewBox || parentViewBox,
70844
70844
  // eslint-disable-next-line react/no-array-index-key
@@ -70851,8 +70851,8 @@ var renderCallByParent$1 = function renderCallByParent(parentProps, viewBox) {
70851
70851
  var implicitLabel = parseLabel(parentProps.label, viewBox || parentViewBox);
70852
70852
  return [implicitLabel].concat(_toConsumableArray$8(explicitChildren));
70853
70853
  };
70854
- Label.parseViewBox = parseViewBox;
70855
- Label.renderCallByParent = renderCallByParent$1;
70854
+ Label$1.parseViewBox = parseViewBox;
70855
+ Label$1.renderCallByParent = renderCallByParent$1;
70856
70856
  var lastExports = requireLast();
70857
70857
  const last = /* @__PURE__ */ getDefaultExportFromCjs(lastExports);
70858
70858
  function _typeof$w(o2) {
@@ -70989,11 +70989,11 @@ function LabelList(_ref) {
70989
70989
  var idProps = isNil(id2) ? {} : {
70990
70990
  id: "".concat(id2, "-").concat(index2)
70991
70991
  };
70992
- return /* @__PURE__ */ React__default.createElement(Label, _extends$n({}, filterProps(entry, true), others, idProps, {
70992
+ return /* @__PURE__ */ React__default.createElement(Label$1, _extends$n({}, filterProps(entry, true), others, idProps, {
70993
70993
  parentViewBox: entry.parentViewBox,
70994
70994
  value,
70995
70995
  textBreakAll,
70996
- viewBox: Label.parseViewBox(isNil(clockWise) ? entry : _objectSpread$r(_objectSpread$r({}, entry), {}, {
70996
+ viewBox: Label$1.parseViewBox(isNil(clockWise) ? entry : _objectSpread$r(_objectSpread$r({}, entry), {}, {
70997
70997
  clockWise
70998
70998
  })),
70999
70999
  key: "label-".concat(index2),
@@ -71122,12 +71122,12 @@ var getDeltaAngle2 = function getDeltaAngle3(startAngle, endAngle) {
71122
71122
  var getTangentCircle = function getTangentCircle2(_ref) {
71123
71123
  var cx = _ref.cx, cy = _ref.cy, radius = _ref.radius, angle = _ref.angle, sign2 = _ref.sign, isExternal = _ref.isExternal, cornerRadius = _ref.cornerRadius, cornerIsExternal = _ref.cornerIsExternal;
71124
71124
  var centerRadius = cornerRadius * (isExternal ? 1 : -1) + radius;
71125
- var theta = Math.asin(cornerRadius / centerRadius) / RADIAN$1;
71125
+ var theta = Math.asin(cornerRadius / centerRadius) / RADIAN$2;
71126
71126
  var centerAngle = cornerIsExternal ? angle : angle + sign2 * theta;
71127
71127
  var center = polarToCartesian(cx, cy, centerRadius, centerAngle);
71128
71128
  var circleTangency = polarToCartesian(cx, cy, radius, centerAngle);
71129
71129
  var lineTangencyAngle = cornerIsExternal ? angle - sign2 * theta : angle;
71130
- var lineTangency = polarToCartesian(cx, cy, centerRadius * Math.cos(theta * RADIAN$1), lineTangencyAngle);
71130
+ var lineTangency = polarToCartesian(cx, cy, centerRadius * Math.cos(theta * RADIAN$2), lineTangencyAngle);
71131
71131
  return {
71132
71132
  center,
71133
71133
  circleTangency,
@@ -73707,7 +73707,7 @@ var PolarRadiusAxis = /* @__PURE__ */ function(_PureComponent) {
73707
73707
  }
73708
73708
  return /* @__PURE__ */ React__default.createElement(Layer, {
73709
73709
  className: clsx("recharts-polar-radius-axis", this.props.className)
73710
- }, axisLine && this.renderAxisLine(), tick && this.renderTicks(), Label.renderCallByParent(this.props, this.getViewBox()));
73710
+ }, axisLine && this.renderAxisLine(), tick && this.renderTicks(), Label$1.renderCallByParent(this.props, this.getViewBox()));
73711
73711
  }
73712
73712
  }], [{
73713
73713
  key: "renderTickItem",
@@ -73877,7 +73877,7 @@ function _toPrimitive$l(t3, r2) {
73877
73877
  }
73878
73878
  return String(t3);
73879
73879
  }
73880
- var RADIAN = Math.PI / 180;
73880
+ var RADIAN$1 = Math.PI / 180;
73881
73881
  var eps = 1e-5;
73882
73882
  var PolarAngleAxis = /* @__PURE__ */ function(_PureComponent) {
73883
73883
  function PolarAngleAxis2() {
@@ -73917,7 +73917,7 @@ var PolarAngleAxis = /* @__PURE__ */ function(_PureComponent) {
73917
73917
  key: "getTickTextAnchor",
73918
73918
  value: function getTickTextAnchor(data) {
73919
73919
  var orientation = this.props.orientation;
73920
- var cos2 = Math.cos(-data.coordinate * RADIAN);
73920
+ var cos2 = Math.cos(-data.coordinate * RADIAN$1);
73921
73921
  var textAnchor;
73922
73922
  if (cos2 > eps) {
73923
73923
  textAnchor = orientation === "outer" ? "start" : "end";
@@ -74836,7 +74836,7 @@ var Pie = /* @__PURE__ */ function(_PureComponent) {
74836
74836
  ref: function ref(_ref3) {
74837
74837
  _this5.pieRef = _ref3;
74838
74838
  }
74839
- }, this.renderSectors(), label && this.renderLabels(sectors), Label.renderCallByParent(this.props, null, false), (!isAnimationActive || isAnimationFinished) && LabelList.renderCallByParent(this.props, sectors, false));
74839
+ }, this.renderSectors(), label && this.renderLabels(sectors), Label$1.renderCallByParent(this.props, null, false), (!isAnimationActive || isAnimationFinished) && LabelList.renderCallByParent(this.props, sectors, false));
74840
74840
  }
74841
74841
  }], [{
74842
74842
  key: "getDerivedStateFromProps",
@@ -77288,7 +77288,7 @@ function ReferenceLineImpl(props) {
77288
77288
  });
77289
77289
  return /* @__PURE__ */ React__default.createElement(Layer, {
77290
77290
  className: clsx("recharts-reference-line", className)
77291
- }, renderLine(shape, lineProps), Label.renderCallByParent(props, rectWithCoords({
77291
+ }, renderLine(shape, lineProps), Label$1.renderCallByParent(props, rectWithCoords({
77292
77292
  x1,
77293
77293
  y1,
77294
77294
  x2: x22,
@@ -77501,7 +77501,7 @@ var ReferenceDot = /* @__PURE__ */ function(_React$Component) {
77501
77501
  });
77502
77502
  return /* @__PURE__ */ React__default.createElement(Layer, {
77503
77503
  className: clsx("recharts-reference-dot", className)
77504
- }, ReferenceDot2.renderDot(shape, dotProps), Label.renderCallByParent(this.props, {
77504
+ }, ReferenceDot2.renderDot(shape, dotProps), Label$1.renderCallByParent(this.props, {
77505
77505
  x: cx - r2,
77506
77506
  y: cy - r2,
77507
77507
  width: 2 * r2,
@@ -77726,7 +77726,7 @@ var ReferenceArea = /* @__PURE__ */ function(_React$Component) {
77726
77726
  className: clsx("recharts-reference-area", className)
77727
77727
  }, ReferenceArea2.renderRect(shape, _objectSpread$7(_objectSpread$7({
77728
77728
  clipPath
77729
- }, filterProps(this.props, true)), rect)), Label.renderCallByParent(this.props, rect));
77729
+ }, filterProps(this.props, true)), rect)), Label$1.renderCallByParent(this.props, rect));
77730
77730
  }
77731
77731
  }]);
77732
77732
  }(React__default.Component);
@@ -78409,7 +78409,7 @@ var CartesianAxis = /* @__PURE__ */ function(_Component) {
78409
78409
  ref: function ref(_ref2) {
78410
78410
  _this3.layerReference = _ref2;
78411
78411
  }
78412
- }, axisLine && this.renderAxisLine(), this.renderTicks(finalTicks, this.state.fontSize, this.state.letterSpacing), Label.renderCallByParent(this.props));
78412
+ }, axisLine && this.renderAxisLine(), this.renderTicks(finalTicks, this.state.fontSize, this.state.letterSpacing), Label$1.renderCallByParent(this.props));
78413
78413
  }
78414
78414
  }], [{
78415
78415
  key: "renderTickItem",
@@ -81942,7 +81942,7 @@ var generateCategoricalChart = function generateCategoricalChart2(_ref6) {
81942
81942
  var _this$props2 = _this.props, children = _this$props2.children, width = _this$props2.width, height = _this$props2.height;
81943
81943
  var margin = _this.props.margin || {};
81944
81944
  var legendWidth = width - (margin.left || 0) - (margin.right || 0);
81945
- var props = getLegendProps$1({
81945
+ var props = getLegendProps({
81946
81946
  children,
81947
81947
  formattedGraphicalItems,
81948
81948
  legendWidth,
@@ -82707,7 +82707,7 @@ var BarChart$1 = generateCategoricalChart({
82707
82707
  }],
82708
82708
  formatAxisMap: formatAxisMap2
82709
82709
  });
82710
- var PieChart = generateCategoricalChart({
82710
+ var PieChart$1 = generateCategoricalChart({
82711
82711
  chartName: "PieChart",
82712
82712
  GraphicalChild: Pie,
82713
82713
  validateTooltipEventTypes: ["item"],
@@ -82743,6 +82743,79 @@ var AreaChart$1 = generateCategoricalChart({
82743
82743
  }],
82744
82744
  formatAxisMap: formatAxisMap2
82745
82745
  });
82746
+ function getAxisProps(scale2, tickFormatter, dataKey) {
82747
+ return {
82748
+ axisLine: false,
82749
+ dataKey,
82750
+ fontSize: 11,
82751
+ scale: scale2,
82752
+ tickLine: false,
82753
+ tickMargin: 8,
82754
+ tickFormatter
82755
+ };
82756
+ }
82757
+ function ChartContainer(props) {
82758
+ const { onSetWidth: handleSetWidth, ...attributes } = props;
82759
+ const ref = React__default.useRef(null);
82760
+ React__default.useLayoutEffect(() => {
82761
+ if (ref.current && typeof handleSetWidth === "function") {
82762
+ const rect = ref.current.getBoundingClientRect();
82763
+ handleSetWidth(rect.width);
82764
+ }
82765
+ }, [ref]);
82766
+ const className = clsx("flex justify-center mx-auto", attributes.className);
82767
+ return /* @__PURE__ */ React__default.createElement("div", { ...attributes, className, ref }, /* @__PURE__ */ React__default.createElement(ResponsiveContainer, null, props.children));
82768
+ }
82769
+ function Tooltip(props) {
82770
+ const { active, payload = [], style, title } = props;
82771
+ if (active && payload.length) {
82772
+ return /* @__PURE__ */ React__default.createElement("div", { className: "border-grey-300 z-20 flex flex-col gap-y-1 rounded-md border bg-white px-2 py-1.5 text-xs shadow-sm" }, title ? /* @__PURE__ */ React__default.createElement("span", { className: "font-bold" }, title) : null, /* @__PURE__ */ React__default.createElement("dl", { className: "m-0 grid grid-cols-[max-content_max-content] gap-x-4 gap-y-0.5", style }, payload.map((entry, index2) => {
82773
+ const color2 = entry.color ?? entry.payload.color;
82774
+ const formatter = entry.formatter ?? entry.payload.formatter;
82775
+ const unit2 = entry.unit ?? entry.payload.unit;
82776
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, { key: `${entry.name}-${index2}` }, /* @__PURE__ */ React__default.createElement("dt", { className: "text-grey-700 mb-0 flex items-center gap-1 font-normal" }, /* @__PURE__ */ React__default.createElement("span", { className: "-mt-px h-2.5 w-2.5 rounded-sm", style: { background: color2 } }), entry.name), /* @__PURE__ */ React__default.createElement("dd", { className: "mb-0 text-right font-bold tabular-nums text-black" }, (formatter == null ? void 0 : formatter(entry.value ?? "", entry.name ?? "", entry, index2, entry.payload)) ?? entry.value, " ", unit2 ? /* @__PURE__ */ React__default.createElement("span", { className: "text-grey-700" }, unit2) : null));
82777
+ })));
82778
+ }
82779
+ return null;
82780
+ }
82781
+ function Legend$1(props) {
82782
+ const { hoverIndex, items, onHover: handleHover, onToggle: handleToggle } = props;
82783
+ const handleMouseEnter = (item, index2) => {
82784
+ if (item.isHidden) {
82785
+ return;
82786
+ }
82787
+ handleHover(index2);
82788
+ };
82789
+ const handleMouseLeave = () => handleHover(void 0);
82790
+ const handleClick = (item) => {
82791
+ if (!item.isHidden) {
82792
+ handleHover(void 0);
82793
+ }
82794
+ handleToggle(item.dataKey);
82795
+ };
82796
+ const moreButton = (moreButtonText) => /* @__PURE__ */ React__default.createElement(Button$4, { appearance: "transparent", className: "text-grey-700 !h-5 !min-h-[1.25rem] !px-1.5 text-xs" }, moreButtonText);
82797
+ return /* @__PURE__ */ React__default.createElement(OverflowGroup, { className: "w-full gap-x-1", moreButton }, items.map((item, index2) => {
82798
+ const className = clsx("mr-1 flex h-3 w-3 rounded-sm", {
82799
+ [`bg-${item.color}`]: !item.isHidden,
82800
+ border: item.isHidden
82801
+ });
82802
+ return /* @__PURE__ */ React__default.createElement(
82803
+ "button",
82804
+ {
82805
+ key: item.label,
82806
+ className: "hover:bg-grey-200 focus-visible:yt-focus flex items-center rounded px-1 !text-xs",
82807
+ onClick: (event) => {
82808
+ event == null ? void 0 : event.preventDefault();
82809
+ handleClick(item);
82810
+ },
82811
+ onMouseEnter: () => handleMouseEnter(item, index2),
82812
+ onMouseLeave: () => handleMouseLeave()
82813
+ },
82814
+ /* @__PURE__ */ React__default.createElement("span", { className }, hoverIndex === index2 ? /* @__PURE__ */ React__default.createElement(Icon$1, { name: "tick-bold", className: clsx("!h-full !w-full", { "text-white": !item.isHidden }) }) : null),
82815
+ item.label
82816
+ );
82817
+ }));
82818
+ }
82746
82819
  const THEME_COLORS = {
82747
82820
  transparent: "transparent",
82748
82821
  current: "currentColor",
@@ -82878,266 +82951,291 @@ const mapColor = (palette, prefix2 = "") => {
82878
82951
  }, {});
82879
82952
  };
82880
82953
  const colors = mapColor(THEME_COLORS);
82881
- const getThemeColor = (color2) => colors[color2];
82882
- function Legend$1(props) {
82883
- const { activeIndex, onMouseEnter, onMouseLeave, onClick, payload, layout, activeItems } = props;
82884
- const [hoverIndex, setHoverIndex] = useState(null);
82885
- const handleMouseEnter = (entry, index2) => {
82886
- setHoverIndex(index2);
82887
- if (activeItems[entry.dataKey]) onMouseEnter(entry, index2);
82888
- };
82889
- const handleMouseLeave = () => {
82890
- onMouseLeave();
82891
- setHoverIndex(null);
82892
- };
82893
- const moreButton = (moreButtonText) => /* @__PURE__ */ React__default.createElement(Button$4, { appearance: "transparent", className: "text-grey-700" }, moreButtonText);
82894
- return /* @__PURE__ */ React__default.createElement("div", { className: "mx-auto w-auto max-w-full overflow-hidden" }, /* @__PURE__ */ React__default.createElement("div", { className: clsx("mb-0 ml-0 flex justify-center", { "flex-col": layout === "vertical" }) }, /* @__PURE__ */ React__default.createElement(OverflowGroup, { className: "w-full items-center py-1", moreButton }, payload.map((entry, index2) => /* @__PURE__ */ React__default.createElement(
82895
- "span",
82896
- {
82897
- key: `${entry.dataKey}-${index2}`,
82898
- className: clsx(" hover:bg-grey-100 cursor-pointer px-[8px] py-[2px] hover:rounded-[4px]", {
82899
- "bg-grey-100 rounded": activeIndex === index2
82900
- }),
82901
- onMouseEnter: () => handleMouseEnter(entry, index2),
82902
- onMouseLeave: handleMouseLeave,
82903
- onClick: onClick ? () => onClick(entry) : void 0
82904
- },
82905
- /* @__PURE__ */ React__default.createElement("span", { className: "text-grey-700 flex items-center gap-[4px]" }, /* @__PURE__ */ React__default.createElement(
82906
- "span",
82907
- {
82908
- className: clsx("-mt-px ml-1 flex h-3 w-3 rounded-sm", {
82909
- "border-grey-300 border !bg-white": !activeItems[entry.dataKey]
82910
- }),
82911
- style: { backgroundColor: entry.color }
82912
- },
82913
- hoverIndex === index2 && activeItems[entry.dataKey] && /* @__PURE__ */ React__default.createElement(Icon$1, { name: "tick-bold", className: "!h-full !w-full text-white" })
82914
- ), entry.value)
82915
- )))));
82916
- }
82917
- const Tooltip = ({ active, formatter, payload, style, singlePieDonutChart }) => {
82918
- const getColor = (entry) => {
82919
- if (singlePieDonutChart) {
82920
- return getThemeColor(entry.payload.color);
82954
+ const getThemeColor = (color2, def = "") => colors[color2 ?? def];
82955
+ const getInverseThemeColor = (themeColor) => {
82956
+ const [color2, number2] = String(themeColor).split("-");
82957
+ const shade = Number(number2);
82958
+ if (shade) {
82959
+ if (shade > 500) {
82960
+ return getThemeColor(`${color2}-100`);
82961
+ } else {
82962
+ if (shade === 500 && (color2 === "red" || color2 === "blue" || color2 === "brown" || color2 === "purple" || color2 === "green")) {
82963
+ return "white";
82964
+ }
82965
+ return getThemeColor(`${color2}-900`);
82921
82966
  }
82922
- return entry.color ?? entry.payload.fill ?? "blue-500";
82923
- };
82924
- if (active && payload && payload.length) {
82925
- return /* @__PURE__ */ React__default.createElement(
82926
- "dl",
82927
- {
82928
- className: "z-20 grid grid-cols-[max-content_max-content] gap-x-4 rounded-md bg-white p-4 text-xs shadow-[0px_0px_1px_rgba(0,0,0,0.1),_0px_6px_18px_rgba(47,51,68,0.2)]",
82929
- style
82930
- },
82931
- payload.map((entry, index2) => /* @__PURE__ */ React__default.createElement(React__default.Fragment, { key: `${entry.name}-${index2}` }, /* @__PURE__ */ React__default.createElement(
82932
- "dt",
82933
- { className: "text-grey-700 mb-0 flex items-center gap-1 font-normal" },
82934
- /* @__PURE__ */ React__default.createElement("span", { className: "-mt-px h-2.5 w-2.5 rounded-sm", style: { background: getColor(entry) } }),
82935
- // We use entry.payload.label because the payload structure differs between a Donut chart with a single pie
82936
- // and one with multiple pies.
82937
- singlePieDonutChart ? entry.payload.label : entry.name
82938
- ), /* @__PURE__ */ React__default.createElement("dd", { className: "mb-0 text-right font-bold text-black " }, formatter ? formatter(entry.value) : entry.value)))
82939
- );
82940
82967
  }
82941
- return null;
82968
+ return color2 === "black" ? "white" : "black";
82942
82969
  };
82943
- const getCartesianGridProps = () => ({
82944
- vertical: false
82945
- });
82946
- const getXAxisProps = (props) => ({
82947
- axisLine: false,
82948
- dataKey: props.accessor,
82949
- fontSize: 12,
82950
- scale: props.xAxisScale,
82951
- tickLine: false,
82952
- tickFormatter: props.xAxisTickFormat
82953
- });
82954
- const getYAxisProps = (props) => ({
82955
- axisLine: false,
82956
- fontSize: 12,
82957
- scale: props.yAxisScale,
82958
- tickLine: false,
82959
- tickFormatter: props.yAxisTickFormat
82960
- });
82961
- const getLegendProps2 = (props) => ({
82962
- content: /* @__PURE__ */ React__default.createElement(Legend$1, { ...props })
82963
- });
82964
- const getTooltipProps = (props = void 0) => ({
82965
- content: /* @__PURE__ */ React__default.createElement(Tooltip, { ...props }),
82966
- wrapperStyle: { outline: "none" }
82967
- });
82968
- const ResponsiveContainer = (props) => /* @__PURE__ */ React__default.createElement(ResponsiveContainer$1, { className: "!h-[calc(100%-1px)] !w-[calc(100%-1px)]", ...props });
82969
- const Area = (_) => null;
82970
- const AreaChart = function AreaChart2(externalProps) {
82971
- const { children, data, formatter, ...props } = externalProps;
82972
- const [hoveredArea, setHoveredArea] = useState(null);
82973
- const [activeAreas, setActiveAreas] = useState(() => {
82974
- const areas = {};
82975
- React__default.Children.forEach(children, (child) => {
82976
- areas[child.props.accessor] = true;
82970
+ function useChart(children, options) {
82971
+ const [activeIndex, setActiveIndex] = React__default.useState();
82972
+ const [hiddenItems, toggleItem] = useChartDataHiddenState();
82973
+ const localization = useLocalization();
82974
+ const defaultFormatter2 = (value) => new Intl.NumberFormat(localization.locale).format(value);
82975
+ const { items, shapes } = React__default.useMemo(() => {
82976
+ const items2 = React__default.Children.toArray(children).filter((child) => React__default.isValidElement(child)).map((child) => {
82977
+ const dataKey = child.props.dataKey ?? child.props.label;
82978
+ return {
82979
+ ...child.props,
82980
+ dataKey,
82981
+ formatter: child.props.formatter ?? (options == null ? void 0 : options.formatter) ?? defaultFormatter2,
82982
+ isHidden: !!hiddenItems[dataKey],
82983
+ unit: child.props.unit ?? (options == null ? void 0 : options.unit)
82984
+ };
82977
82985
  });
82978
- return areas;
82979
- });
82980
- const handleLegendClick = (entry) => {
82981
- setHoveredArea(null);
82982
- setActiveAreas({ ...activeAreas, [entry.dataKey]: !activeAreas[entry.dataKey] });
82983
- };
82984
- return /* @__PURE__ */ React__default.createElement(ResponsiveContainer, null, /* @__PURE__ */ React__default.createElement(AreaChart$1, { data, margin: { top: 10, right: 0, left: -25, bottom: 0 } }, /* @__PURE__ */ React__default.createElement(CartesianGrid, { ...getCartesianGridProps() }), /* @__PURE__ */ React__default.createElement(XAxis, { ...getXAxisProps(props) }), /* @__PURE__ */ React__default.createElement(YAxis, { ...getYAxisProps(props) }), /* @__PURE__ */ React__default.createElement(
82985
- Legend$2,
82986
- {
82987
- ...getLegendProps2({
82988
- onClick: handleLegendClick,
82989
- onMouseEnter: (entry) => setHoveredArea(entry.dataKey),
82990
- onMouseLeave: () => setHoveredArea(null),
82991
- activeItems: activeAreas
82992
- })
82993
- }
82994
- ), /* @__PURE__ */ React__default.createElement(Tooltip$1, { ...getTooltipProps(), formatter }), React__default.Children.map(children, (child) => /* @__PURE__ */ React__default.createElement(
82995
- Area$1,
82996
- {
82997
- activeDot: {
82998
- fill: getThemeColor(child.props.color ?? "blue-300")
82999
- },
83000
- isAnimationActive: false,
83001
- dataKey: child.props.accessor,
83002
- dot: false,
83003
- fill: getThemeColor(child.props.color ?? "grey-100"),
83004
- name: child.props.label,
83005
- strokeWidth: 2,
83006
- stroke: getThemeColor(child.props.color ?? "grey-300"),
83007
- stackId: child.props.stackId,
83008
- hide: !activeAreas[child.props.accessor],
83009
- opacity: hoveredArea && child.props.accessor !== hoveredArea ? 0.3 : 1
83010
- }
83011
- ))));
83012
- };
83013
- AreaChart.Area = Area;
83014
- const Bar = (_) => null;
83015
- const getXAxisVerticalProps = (props) => ({
83016
- ...getXAxisProps(props),
83017
- ...{ type: "number", dataKey: void 0 }
83018
- });
83019
- const getYAxisVerticalProps = (props) => ({
83020
- ...getYAxisProps(props),
83021
- ...{ dataKey: props.accessor, type: "category" }
83022
- });
83023
- const BarChart = function BarChart2(externalProps) {
83024
- const { children, data, formatter, layout = "horizontal", ...props } = externalProps;
83025
- const [activeIndex, setActiveIndex] = React__default.useState(void 0);
83026
- const [hoveredBar, setHoveredBar] = useState(null);
83027
- const [activeBars, setActiveBars] = useState(() => {
83028
- const keys2 = {};
83029
- React__default.Children.forEach(children, (child) => {
83030
- keys2[child.props.accessor] = true;
82986
+ const shapes2 = items2.filter((item) => !hiddenItems[item.dataKey]).map((item) => {
82987
+ const color2 = getThemeColor(item.color, "blue-500");
82988
+ return {
82989
+ activeDot: {
82990
+ strokeWidth: 1
82991
+ },
82992
+ color: color2,
82993
+ dataKey: item.dataKey,
82994
+ dot: {
82995
+ fillOpacity: 0.6
82996
+ },
82997
+ isAnimationActive: false,
82998
+ fill: color2,
82999
+ fillOpacity: 0.65,
83000
+ formatter: item.formatter,
83001
+ name: item.label,
83002
+ stroke: color2,
83003
+ strokeWidth: 1.5,
83004
+ unit: item.unit
83005
+ };
83031
83006
  });
83032
- return keys2;
83033
- });
83034
- const stacks = {};
83035
- React__default.Children.forEach(children, (child) => {
83036
- if (child.props.stackId) {
83037
- if (!stacks[child.props.stackId]) {
83038
- stacks[child.props.stackId] = [child.props.accessor];
83007
+ return { items: items2, shapes: shapes2 };
83008
+ }, [children, hiddenItems]);
83009
+ return { items, shapes, activeIndex, setActiveIndex, toggleItem };
83010
+ }
83011
+ function useChartDataHiddenState() {
83012
+ const [state, setState] = React__default.useState({});
83013
+ function toggle(name) {
83014
+ setState((currentState) => {
83015
+ const nextState = { ...currentState };
83016
+ if (currentState[name]) {
83017
+ delete nextState[name];
83039
83018
  } else {
83040
- stacks[child.props.stackId].push(child.props.accessor);
83019
+ nextState[name] = true;
83041
83020
  }
83042
- }
83043
- });
83044
- const handleLegendClick = (entry) => {
83045
- setHoveredBar(null);
83046
- setActiveBars({ ...activeBars, [entry.dataKey]: !activeBars[entry.dataKey] });
83047
- };
83048
- const handleLegendHover = (entry, index2) => {
83049
- setHoveredBar(entry.dataKey);
83050
- setActiveIndex(index2);
83051
- };
83052
- return /* @__PURE__ */ React__default.createElement(ResponsiveContainer, null, /* @__PURE__ */ React__default.createElement(
83053
- BarChart$1,
83021
+ return nextState;
83022
+ });
83023
+ }
83024
+ return [state, toggle];
83025
+ }
83026
+ function AreaChart(props) {
83027
+ const {
83028
+ children,
83029
+ data,
83030
+ dataKey,
83031
+ showDots = false,
83032
+ showLegend = false,
83033
+ showXAxis = true,
83034
+ showYAxis = false,
83035
+ stacked = false,
83036
+ tooltipTitle,
83037
+ type = "natural",
83038
+ xAxisScale,
83039
+ xAxisTickFormatter,
83040
+ yAxisScale,
83041
+ yAxisTickFormatter,
83042
+ ...attributes
83043
+ } = props;
83044
+ const className = clsx("aspect-video", attributes.className);
83045
+ const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children);
83046
+ return /* @__PURE__ */ React__default.createElement("div", { className: "relative", "data-taco": "chart-wrapper" }, /* @__PURE__ */ React__default.createElement(ChartContainer, { ...attributes, className, "data-taco": "chart-area" }, /* @__PURE__ */ React__default.createElement(
83047
+ AreaChart$1,
83054
83048
  {
83055
- layout,
83056
83049
  data,
83057
- margin: { top: 10, right: 0, left: layout === "vertical" ? 0 : -25, bottom: 0 },
83058
- onMouseMove: (chartState) => setActiveIndex(chartState.activeTooltipIndex),
83059
- onMouseLeave: () => setActiveIndex(void 0)
83050
+ margin: { bottom: 10, left: 10, right: 10, top: 10 },
83051
+ stackOffset: stacked === "expand" ? "expand" : void 0
83060
83052
  },
83061
- /* @__PURE__ */ React__default.createElement(CartesianGrid, { ...getCartesianGridProps() }),
83053
+ /* @__PURE__ */ React__default.createElement(CartesianGrid, { vertical: false }),
83054
+ /* @__PURE__ */ React__default.createElement(Tooltip$1, { content: /* @__PURE__ */ React__default.createElement(Tooltip, { title: tooltipTitle }) }),
83062
83055
  /* @__PURE__ */ React__default.createElement(
83063
83056
  XAxis,
83064
83057
  {
83065
- ...layout === "vertical" ? getXAxisVerticalProps(props) : getXAxisProps(props)
83058
+ ...getAxisProps(xAxisScale, xAxisTickFormatter, dataKey),
83059
+ hide: !showXAxis
83066
83060
  }
83067
83061
  ),
83062
+ /* @__PURE__ */ React__default.createElement(YAxis, { ...getAxisProps(yAxisScale, yAxisTickFormatter), hide: !showYAxis }),
83063
+ shapes.map((shape) => /* @__PURE__ */ React__default.createElement(
83064
+ Area$1,
83065
+ {
83066
+ key: shape.dataKey,
83067
+ ...shape,
83068
+ dot: showDots ? shape.dot : false,
83069
+ stackId: stacked ? "stack" : void 0,
83070
+ type
83071
+ }
83072
+ ))
83073
+ )), showLegend ? /* @__PURE__ */ React__default.createElement(Legend$1, { items, hoverIndex: activeIndex, onHover: setActiveIndex, onToggle: toggleItem }) : null);
83074
+ }
83075
+ function Area(_) {
83076
+ return null;
83077
+ }
83078
+ AreaChart.Area = Area;
83079
+ const BAR_WIDTH = 20;
83080
+ function BarChart(props) {
83081
+ const isHorizontal = props.layout === "horizontal";
83082
+ const {
83083
+ children,
83084
+ data,
83085
+ dataKey,
83086
+ showLabels = false,
83087
+ showLegend = false,
83088
+ showXAxis = !isHorizontal,
83089
+ showYAxis = isHorizontal,
83090
+ stacked = false,
83091
+ xAxisScale,
83092
+ xAxisTickFormatter,
83093
+ yAxisScale,
83094
+ yAxisTickFormatter,
83095
+ ...attributes
83096
+ } = props;
83097
+ const className = clsx("aspect-video", attributes.className);
83098
+ const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children);
83099
+ return /* @__PURE__ */ React__default.createElement("div", { className: "relative", "data-taco": "chart-wrapper" }, /* @__PURE__ */ React__default.createElement(ChartContainer, { ...attributes, className, "data-taco": "chart-bar" }, /* @__PURE__ */ React__default.createElement(
83100
+ BarChart$1,
83101
+ {
83102
+ data,
83103
+ barCategoryGap: "15%",
83104
+ barGap: "7.5%",
83105
+ margin: { bottom: 10, left: isHorizontal ? -15 : 10, right: 10, top: 10 },
83106
+ layout: isHorizontal ? "vertical" : void 0,
83107
+ stackOffset: stacked === "expand" ? "expand" : void 0
83108
+ },
83109
+ /* @__PURE__ */ React__default.createElement(CartesianGrid, { horizontal: !isHorizontal, vertical: false }),
83110
+ /* @__PURE__ */ React__default.createElement(Tooltip$1, { content: /* @__PURE__ */ React__default.createElement(Tooltip, null) }),
83068
83111
  /* @__PURE__ */ React__default.createElement(
83069
- YAxis,
83112
+ XAxis,
83070
83113
  {
83071
- ...layout === "vertical" ? getYAxisVerticalProps(props) : getYAxisProps(props)
83114
+ ...getAxisProps(xAxisScale, xAxisTickFormatter, isHorizontal ? void 0 : dataKey),
83115
+ hide: !showXAxis,
83116
+ type: isHorizontal ? "number" : void 0
83072
83117
  }
83073
83118
  ),
83074
83119
  /* @__PURE__ */ React__default.createElement(
83075
- Legend$2,
83120
+ YAxis,
83076
83121
  {
83077
- ...getLegendProps2({
83078
- onClick: handleLegendClick,
83079
- onMouseEnter: handleLegendHover,
83080
- onMouseLeave: () => setHoveredBar(null),
83081
- activeItems: activeBars
83082
- })
83122
+ ...getAxisProps(yAxisScale, yAxisTickFormatter, isHorizontal ? dataKey : void 0),
83123
+ hide: !showYAxis,
83124
+ type: isHorizontal ? "category" : void 0
83083
83125
  }
83084
83126
  ),
83085
- /* @__PURE__ */ React__default.createElement(Tooltip$1, { ...getTooltipProps(), formatter }),
83086
- React__default.Children.map(children, (child) => /* @__PURE__ */ React__default.createElement(
83127
+ shapes.map((shape, index2) => /* @__PURE__ */ React__default.createElement(
83087
83128
  Bar$1,
83088
83129
  {
83089
- isAnimationActive: false,
83090
- barSize: 16,
83091
- dataKey: child.props.accessor,
83092
- name: child.props.label,
83093
- onMouseEnter: (_, index2) => setActiveIndex(index2),
83094
- onMouseLeave: () => setActiveIndex(void 0),
83095
- fill: getThemeColor(child.props.color ? `${child.props.color}` : `blue-300`),
83096
- radius: getBarRadius(stacks, child.props.accessor, child.props.stackId, activeBars),
83097
- stackId: child.props.stackId,
83098
- style: child.props.stackId ? { stroke: "#fff", strokeWidth: "2px" } : void 0,
83099
- hide: !activeBars[child.props.accessor]
83130
+ key: shape.dataKey,
83131
+ ...shape,
83132
+ activeBar: { fillOpacity: 1, strokeWidth: 0 },
83133
+ strokeWidth: 0,
83134
+ maxBarSize: BAR_WIDTH,
83135
+ radius: getRadius(index2, shapes.length, !!stacked, isHorizontal),
83136
+ stackId: stacked ? "stack" : void 0
83100
83137
  },
83101
- data.map((_, index2) => /* @__PURE__ */ React__default.createElement(
83102
- Cell,
83138
+ showLabels ? /* @__PURE__ */ React__default.createElement(
83139
+ LabelList,
83103
83140
  {
83104
- key: `cell-${index2}`,
83105
- opacity: hoveredBar && child.props.accessor !== hoveredBar || activeIndex !== void 0 && activeIndex !== index2 ? 0.3 : 1
83141
+ position: isHorizontal ? "insideRight" : "top",
83142
+ formatter: shape.formatter,
83143
+ offset: isHorizontal ? 6 : 8,
83144
+ fill: isHorizontal ? getInverseThemeColor(shape.color ?? "") : "black",
83145
+ fontSize: 11
83106
83146
  }
83107
- ))
83147
+ ) : null
83108
83148
  ))
83109
- ));
83110
- };
83111
- BarChart.Bar = Bar;
83112
- const getBarRadius = (stacks, accessor, stackId, activeBars) => {
83113
- if (stackId && Array.isArray(stacks[stackId])) {
83114
- const length = stacks[stackId].length - 1;
83115
- const index2 = stacks[stackId].indexOf(accessor);
83116
- if (Object.entries(activeBars).filter((item) => item[0] !== accessor).every((item) => !item[1])) {
83117
- return [3, 3, 0, 0];
83149
+ )), showLegend ? /* @__PURE__ */ React__default.createElement(Legend$1, { items, hoverIndex: activeIndex, onHover: setActiveIndex, onToggle: toggleItem }) : null);
83150
+ }
83151
+ function getRadius(index2, length, stacked, isHorizontal) {
83152
+ if (stacked) {
83153
+ if (index2 === 0) {
83154
+ return isHorizontal ? [3, 0, 0, 3] : [0, 0, 3, 3];
83118
83155
  }
83119
- if (activeBars[stacks[stackId][index2 + 1]] === false) {
83120
- return [index2 === 0 ? 0 : 3, index2 === 0 ? 0 : 3, index2 === length - 1 ? 0 : 3, index2 === length - 1 ? 0 : 3];
83156
+ if (index2 === length - 1) {
83157
+ return isHorizontal ? [0, 3, 3, 0] : [3, 3, 0, 0];
83121
83158
  }
83122
- if (index2 !== 0 && index2 !== length) {
83123
- return 0;
83124
- }
83125
- return [index2 === 0 ? 0 : 3, index2 === 0 ? 0 : 3, index2 === length ? 0 : 3, index2 === length ? 0 : 3];
83159
+ return 0;
83126
83160
  }
83127
83161
  return 3;
83128
- };
83129
- const Legend = ({
83130
- legendPosition,
83131
- hoveredItem,
83132
- selectedItem,
83133
- data,
83134
- onClick,
83135
- setHoveredItem,
83136
- formatter,
83137
- total,
83138
- visibleItems,
83139
- label
83140
- }) => {
83162
+ }
83163
+ function Bar(_) {
83164
+ return null;
83165
+ }
83166
+ BarChart.Bar = Bar;
83167
+ const PIE_ACTIVE_WIDTH = 10;
83168
+ const PIE_ACTIVE_WIDTH_OFFSET = 2;
83169
+ function usePieChart(children, options) {
83170
+ const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children, options);
83171
+ const [radius, _setRadius] = React__default.useState(0);
83172
+ function setRadius(width) {
83173
+ _setRadius((width - 2 * (PIE_ACTIVE_WIDTH + PIE_ACTIVE_WIDTH_OFFSET)) / 2);
83174
+ }
83175
+ const pieProps = {
83176
+ activeIndex,
83177
+ activeShape: (props) => /* @__PURE__ */ React__default.createElement(ActiveShape$1, { ...props }),
83178
+ children: shapes.map((shape) => /* @__PURE__ */ React__default.createElement(Cell, { key: shape.dataKey, color: shape.color, fill: shape.fill })),
83179
+ // data props
83180
+ data: items.filter((item) => !item.isHidden),
83181
+ dataKey: "value",
83182
+ nameKey: "label",
83183
+ // style props
83184
+ isAnimationActive: false,
83185
+ startAngle: 90,
83186
+ endAngle: -270,
83187
+ stroke: "0",
83188
+ labelLine: false,
83189
+ outerRadius: radius
83190
+ };
83191
+ return { pieProps, radius, setRadius, items, activeIndex, setActiveIndex, toggleItem, shapes };
83192
+ }
83193
+ const PIE_CHART_HOVER = 10;
83194
+ const PIE_CHART_HOVER_OFFSET = 2;
83195
+ function ActiveShape$1(props) {
83196
+ const { outerRadius = 0, ...attributes } = props;
83197
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(Sector, { ...attributes, outerRadius }), /* @__PURE__ */ React__default.createElement(
83198
+ Sector,
83199
+ {
83200
+ ...attributes,
83201
+ innerRadius: outerRadius + PIE_CHART_HOVER_OFFSET,
83202
+ outerRadius: outerRadius + PIE_CHART_HOVER,
83203
+ opacity: 0.4
83204
+ }
83205
+ ));
83206
+ }
83207
+ const DONUT_WIDTH$1 = 20;
83208
+ function DonutChart(props) {
83209
+ const { children, formatter, showLegend = false, showTotal = false, tooltipTitle, unit: unit2, ...attributes } = props;
83210
+ const { pieProps, radius, setRadius, items, activeIndex, setActiveIndex, toggleItem } = usePieChart(children, {
83211
+ formatter,
83212
+ unit: unit2
83213
+ });
83214
+ const className = clsx("aspect-square", attributes.className);
83215
+ return /* @__PURE__ */ React__default.createElement("div", { className: "relative", "data-taco": "chart-wrapper" }, showTotal ? /* @__PURE__ */ React__default.createElement(
83216
+ Total,
83217
+ {
83218
+ formatter,
83219
+ items,
83220
+ unit: unit2,
83221
+ style: { top: radius / 2 - 2, width: radius + DONUT_WIDTH$1 }
83222
+ }
83223
+ ) : null, /* @__PURE__ */ React__default.createElement(ChartContainer, { ...attributes, className, "data-taco": "chart-donut", onSetWidth: setRadius }, /* @__PURE__ */ React__default.createElement(PieChart$1, null, /* @__PURE__ */ React__default.createElement(Tooltip$1, { content: /* @__PURE__ */ React__default.createElement(Tooltip, { title: tooltipTitle }) }), /* @__PURE__ */ React__default.createElement(Pie, { ...pieProps, innerRadius: radius - DONUT_WIDTH$1 }))), showLegend ? /* @__PURE__ */ React__default.createElement(Legend$1, { items, hoverIndex: activeIndex, onHover: setActiveIndex, onToggle: toggleItem }) : null);
83224
+ }
83225
+ function Segment$2(_) {
83226
+ return null;
83227
+ }
83228
+ DonutChart.Segment = Segment$2;
83229
+ function Total(props) {
83230
+ const { formatter, items, unit: unit2, ...attributes } = props;
83231
+ const localization = useLocalization();
83232
+ const total = React__default.useMemo(() => {
83233
+ const total2 = items.filter((item) => !item.isHidden).reduce((acc, curr) => acc + curr.value, 0);
83234
+ return (formatter == null ? void 0 : formatter(total2)) ?? new Intl.NumberFormat(localization.locale).format(total2);
83235
+ }, [items]);
83236
+ return /* @__PURE__ */ React__default.createElement("div", { ...attributes, className: "absolute-center-x flex aspect-square flex-col items-center justify-center rounded-full" }, /* @__PURE__ */ React__default.createElement("span", { className: "truncate text-2xl font-bold tabular-nums" }, total), unit2 ? /* @__PURE__ */ React__default.createElement("span", { className: "text-grey-700 -mb-1 -mt-0.5 truncate text-xs" }, unit2) : null);
83237
+ }
83238
+ const Legend = ({ hoveredItem, selectedItem, data, onClick, setHoveredItem, formatter, total, label }) => {
83141
83239
  const isTotalLegendSelected = selectedItem.length === data.length;
83142
83240
  const isTotalLegendHovered = hoveredItem.length === data.length;
83143
83241
  const handleMouseLeave = () => setHoveredItem([]);
@@ -83151,49 +83249,22 @@ const Legend = ({
83151
83249
  {
83152
83250
  key: isTotal ? "total" : `${itemData.label}-${index2}`,
83153
83251
  className: clsx("mr-2 flex cursor-pointer gap-2 rounded pl-0 pr-1", {
83154
- "bg-grey-100": isHovered && (!isTotal || legendPosition === "right"),
83155
- "bg-grey-200": isSelected && (!isTotal || legendPosition === "right")
83252
+ "bg-grey-100": isHovered,
83253
+ "bg-grey-200": isSelected
83156
83254
  }),
83157
83255
  onClick: () => onClick(isTotal ? data : itemData),
83158
83256
  onMouseEnter: () => setHoveredItem(isTotal ? data.map((item) => item.id) : [itemData.id]),
83159
83257
  onMouseLeave: handleMouseLeave
83160
83258
  },
83161
- legendPosition === "bottom" ? /* @__PURE__ */ React__default.createElement("div", { className: "flex items-center gap-1" }, /* @__PURE__ */ React__default.createElement(
83162
- "span",
83163
- {
83164
- className: clsx("ml-1 h-3 w-3 rounded-sm", {
83165
- "border-grey-300 border !bg-white": !visibleItems[itemData.id]
83166
- }),
83167
- style: { backgroundColor: getThemeColor(itemData.color) }
83168
- },
83169
- visibleItems[itemData.id] && isHovered && /* @__PURE__ */ React__default.createElement(Icon$1, { name: "tick-bold", className: "mb-2.5 !h-full !w-full text-white" })
83170
- ), /* @__PURE__ */ React__default.createElement("div", null, itemData.label)) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
83171
- "span",
83172
- {
83173
- className: "ml-1 mt-1 h-9 w-2 rounded-[1px]",
83174
- style: { backgroundColor: getThemeColor(itemData.color) }
83175
- }
83176
- ), /* @__PURE__ */ React__default.createElement("div", null, itemData.label, /* @__PURE__ */ React__default.createElement("span", { className: "-mt-1 flex w-full text-lg font-bold" }, formatter ? formatter(itemData.value) : itemData.value)))
83259
+ /* @__PURE__ */ React__default.createElement("span", { className: "ml-1 mt-1 h-9 w-2 rounded-[1px]", style: { backgroundColor: getThemeColor(itemData.color) } }),
83260
+ /* @__PURE__ */ React__default.createElement("div", null, itemData.label, /* @__PURE__ */ React__default.createElement("span", { className: "-mt-1 flex w-full text-lg font-bold" }, formatter ? formatter(itemData.value) : itemData.value))
83177
83261
  );
83178
83262
  };
83179
- const moreButton = (moreButtonText) => /* @__PURE__ */ React__default.createElement(Button$4, { appearance: "transparent", className: "text-grey-700" }, moreButtonText);
83180
- const className = clsx("flex-grow pl-4", {
83181
- "w-full": legendPosition === "bottom"
83182
- });
83183
- return /* @__PURE__ */ React__default.createElement("div", { className }, /* @__PURE__ */ React__default.createElement(
83184
- "ul",
83185
- {
83186
- className: clsx(
83187
- "mb-0 ml-0 mt-4 flex justify-center space-y-1",
83188
- legendPosition === "right" ? "flex-col gap-1" : "flex-row"
83189
- )
83190
- },
83191
- legendPosition === "right" ? /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, renderLegendItem(null), data.map(renderLegendItem)) : /* @__PURE__ */ React__default.createElement(OverflowGroup, { className: "w-full items-center py-1", moreButton }, data.map(renderLegendItem))
83192
- ));
83263
+ return /* @__PURE__ */ React__default.createElement("div", { className: "flex-grow pl-4" }, /* @__PURE__ */ React__default.createElement("ul", { className: "mb-0 ml-0 mt-4 flex flex-col justify-center gap-1 space-y-1" }, renderLegendItem(null), data.map(renderLegendItem)));
83193
83264
  };
83194
- const DONUT_WIDTH = 16;
83265
+ const DONUT_WIDTH = 24;
83195
83266
  const HOVER_DONUT_WIDTH = 10;
83196
- const CenteredLabel = ({ radius, legendPosition, label, total, formatter, showLegend }) => {
83267
+ const CenteredLabel = ({ radius, label, total, formatter }) => {
83197
83268
  const totalInset = HOVER_DONUT_WIDTH + DONUT_WIDTH + DONUT_WIDTH;
83198
83269
  const diameter = radius * 2;
83199
83270
  return /* @__PURE__ */ React__default.createElement(
@@ -83203,8 +83274,8 @@ const CenteredLabel = ({ radius, legendPosition, label, total, formatter, showLe
83203
83274
  style: {
83204
83275
  top: `calc(${radius}px - (3rem / 2))`,
83205
83276
  // h-12 is 3rem
83206
- left: legendPosition === "right" ? `${totalInset}px` : `calc(50%-${diameter - 2 * totalInset})`,
83207
- width: showLegend ? `${diameter - 2 * totalInset}px` : `${diameter}px`
83277
+ left: `${totalInset}px`,
83278
+ width: `${diameter - 2 * totalInset}px`
83208
83279
  }
83209
83280
  },
83210
83281
  /* @__PURE__ */ React__default.createElement("span", { className: "w-full truncate text-lg font-bold" }, formatter ? formatter(total) : total),
@@ -83233,42 +83304,28 @@ const ActiveShape = (props) => {
83233
83304
  endAngle,
83234
83305
  innerRadius: outerRadius + 2,
83235
83306
  outerRadius: outerRadius + HOVER_DONUT_WIDTH,
83236
- fill: id2 !== void 0 ? getThemeColor(pieColors[id2]) ?? getThemeColor("blue-500") : getThemeColor("blue-500"),
83237
- opacity: 0.3
83307
+ fill: id2 !== void 0 ? getThemeColor(pieColors[id2], "blue-500") : getThemeColor("blue-500"),
83308
+ opacity: 0.4
83238
83309
  }
83239
83310
  ));
83240
83311
  };
83241
- const Segment = (_) => null;
83242
- const DonutChart = function DonutChart2({
83243
- children,
83244
- formatter,
83245
- onClick,
83246
- showLegend = false,
83247
- legendPosition = "bottom",
83248
- label
83249
- }) {
83312
+ const Segment$1 = (_) => null;
83313
+ const LegacyDonutChart = function LegacyDonutChart2({ children, formatter, onClick, label }) {
83250
83314
  const ref = React__default.useRef(null);
83251
83315
  const [radius, setRadius] = React__default.useState(0);
83252
83316
  const [hoveredItem, setHoveredItem] = React__default.useState([]);
83253
83317
  const [selectedItem, setSelectedItem] = React__default.useState([]);
83254
- const [visibleItems, setVisibleItems] = React__default.useState(() => {
83255
- const keys2 = {};
83256
- React__default.Children.forEach(children, (child) => {
83257
- keys2[child.props.id] = true;
83258
- });
83259
- return keys2;
83260
- });
83261
83318
  React__default.useEffect(() => {
83262
83319
  var _a;
83263
83320
  if (ref.current) {
83264
83321
  const rect = (_a = ref.current.parentElement) == null ? void 0 : _a.getBoundingClientRect();
83265
83322
  if (rect) {
83266
- const width = showLegend ? rect.width / 2 : rect.width;
83323
+ const width = rect.width / 2;
83267
83324
  const max2 = rect.height < width ? rect.height : width;
83268
83325
  setRadius(max2 / 2);
83269
83326
  }
83270
83327
  }
83271
- }, [showLegend]);
83328
+ }, [ref.current]);
83272
83329
  const diameter = radius * 2;
83273
83330
  const data = React__default.Children.map(children, (child) => ({
83274
83331
  id: child.props.id,
@@ -83276,34 +83333,27 @@ const DonutChart = function DonutChart2({
83276
83333
  label: child.props.label,
83277
83334
  value: child.props.value
83278
83335
  }));
83279
- const displayedData = data.filter((child) => visibleItems[child.id]);
83280
- const total = displayedData.reduce((accum, entry) => accum + entry.value, 0);
83281
- const showTooltip = (!showLegend || legendPosition === "bottom") && displayedData.length > 0;
83336
+ const total = data.reduce((accum, entry) => accum + entry.value, 0);
83282
83337
  const handleLegendClick = (entry) => {
83283
- if (legendPosition === "bottom" && !Array.isArray(entry)) {
83284
- setVisibleItems({ ...visibleItems, [entry.id]: !visibleItems[entry.id] });
83285
- } else {
83286
- const nextSelectedItem = Array.isArray(entry) ? entry.map((entryItem) => entryItem.id) : [entry.id];
83287
- const isCurrentSegmentActive = selectedItem.slice().sort().join(",") === nextSelectedItem.sort().join(",");
83288
- if (onClick && !isCurrentSegmentActive) {
83289
- onClick(entry);
83290
- }
83291
- setSelectedItem(isCurrentSegmentActive ? [] : nextSelectedItem);
83338
+ const nextSelectedItem = Array.isArray(entry) ? entry.map((entryItem) => entryItem.id) : [entry.id];
83339
+ const isCurrentSegmentActive = selectedItem.slice().sort().join(",") === nextSelectedItem.sort().join(",");
83340
+ if (onClick && !isCurrentSegmentActive) {
83341
+ onClick(entry);
83292
83342
  }
83343
+ setSelectedItem(isCurrentSegmentActive ? [] : nextSelectedItem);
83293
83344
  };
83294
83345
  const handlePieClick = React__default.useCallback(
83295
83346
  (pieId) => {
83296
83347
  if (onClick && pieId !== void 0) {
83297
- const pieProps = displayedData.find((item) => item.id === pieId);
83348
+ const pieProps = data.find((item) => item.id === pieId);
83298
83349
  onClick(pieProps);
83299
83350
  }
83300
83351
  },
83301
- [onClick, displayedData]
83352
+ [onClick, data]
83302
83353
  );
83303
- const singlePieDonutChart = displayedData.length === 1;
83304
83354
  const activeShapeColor = React__default.useMemo(() => {
83305
83355
  const getSegmentColor = (item) => item.reduce((colors2, itemId) => {
83306
- const visibleHoveredItem = displayedData.find((dataItem) => dataItem.id === itemId);
83356
+ const visibleHoveredItem = data.find((dataItem) => dataItem.id === itemId);
83307
83357
  if (visibleHoveredItem) {
83308
83358
  colors2[visibleHoveredItem.id] = visibleHoveredItem.color;
83309
83359
  }
@@ -83311,20 +83361,20 @@ const DonutChart = function DonutChart2({
83311
83361
  }, {});
83312
83362
  const hoveredSegmentColor = getSegmentColor(hoveredItem);
83313
83363
  const selectedSegmentColor = getSegmentColor(selectedItem);
83314
- return legendPosition === "bottom" || hoveredItem.length !== 0 ? hoveredSegmentColor : selectedSegmentColor;
83315
- }, [hoveredItem, selectedItem, legendPosition]);
83364
+ return hoveredItem.length !== 0 ? hoveredSegmentColor : selectedSegmentColor;
83365
+ }, [hoveredItem, selectedItem]);
83316
83366
  if (ref.current && !radius) {
83317
83367
  return null;
83318
83368
  }
83319
83369
  const getActiveIndex = () => {
83320
83370
  if (hoveredItem.length > 0) {
83321
- return hoveredItem.map((itemId) => displayedData.findIndex((element) => element.id === itemId));
83371
+ return hoveredItem.map((itemId) => data.findIndex((element) => element.id === itemId));
83322
83372
  }
83323
- return selectedItem.map((selectedItemId) => displayedData.findIndex((element) => element.id === selectedItemId));
83373
+ return selectedItem.map((selectedItemId) => data.findIndex((element) => element.id === selectedItemId));
83324
83374
  };
83325
83375
  const content = () => {
83326
83376
  const elements = React__default.Children.toArray(children).filter(
83327
- (child) => React__default.isValidElement(child) && visibleItems[child.props.id]
83377
+ (child) => React__default.isValidElement(child)
83328
83378
  );
83329
83379
  return elements.length > 0 ? elements.map((child, index2) => {
83330
83380
  return /* @__PURE__ */ React__default.createElement(
@@ -83337,112 +83387,112 @@ const DonutChart = function DonutChart2({
83337
83387
  );
83338
83388
  }) : /* @__PURE__ */ React__default.createElement(Cell, { key: "empty-chart", name: "", fill: getThemeColor("grey-200") });
83339
83389
  };
83340
- return /* @__PURE__ */ React__default.createElement(
83341
- "div",
83390
+ return /* @__PURE__ */ React__default.createElement("div", { className: "relative flex h-full w-full", ref }, /* @__PURE__ */ React__default.createElement(CenteredLabel, { radius, label, total, formatter }), /* @__PURE__ */ React__default.createElement(PieChart$1, { data, height: diameter, width: diameter, style: { transform: "rotate(90deg) scale(-1,1)" } }, /* @__PURE__ */ React__default.createElement(
83391
+ Pie,
83342
83392
  {
83343
- className: clsx("relative h-full w-full", {
83344
- [`flex `]: showLegend,
83345
- "flex-col items-center": legendPosition === "bottom"
83346
- }),
83347
- ref
83393
+ isAnimationActive: false,
83394
+ activeIndex: getActiveIndex(),
83395
+ activeShape: /* @__PURE__ */ React__default.createElement(ActiveShape, { pieColors: activeShapeColor, onClick: handlePieClick }),
83396
+ data: data.length > 0 ? data : [],
83397
+ dataKey: "value",
83398
+ innerRadius: radius - HOVER_DONUT_WIDTH - DONUT_WIDTH,
83399
+ onMouseEnter: (segment) => data.length > 0 && setHoveredItem([segment.id]),
83400
+ onMouseLeave: () => setHoveredItem([]),
83401
+ outerRadius: radius - HOVER_DONUT_WIDTH,
83402
+ stroke: "0",
83403
+ rootTabIndex: -1
83348
83404
  },
83405
+ content()
83406
+ )), /* @__PURE__ */ React__default.createElement(
83407
+ Legend,
83408
+ {
83409
+ data,
83410
+ onClick: handleLegendClick,
83411
+ total,
83412
+ setHoveredItem,
83413
+ label,
83414
+ hoveredItem,
83415
+ selectedItem,
83416
+ formatter
83417
+ }
83418
+ ));
83419
+ };
83420
+ LegacyDonutChart.Segment = Segment$1;
83421
+ function LineChart(props) {
83422
+ const {
83423
+ children,
83424
+ data,
83425
+ dataKey,
83426
+ showDots = false,
83427
+ showLegend = false,
83428
+ showXAxis = true,
83429
+ showYAxis = false,
83430
+ tooltipTitle,
83431
+ type = "natural",
83432
+ xAxisScale,
83433
+ xAxisTickFormatter,
83434
+ yAxisScale,
83435
+ yAxisTickFormatter,
83436
+ ...attributes
83437
+ } = props;
83438
+ const className = clsx("aspect-video", attributes.className);
83439
+ const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children);
83440
+ return /* @__PURE__ */ React__default.createElement("div", { className: "relative", "data-taco": "chart-wrapper" }, /* @__PURE__ */ React__default.createElement(ChartContainer, { ...attributes, className, "data-taco": "chart-area" }, /* @__PURE__ */ React__default.createElement(
83441
+ LineChart$1,
83442
+ {
83443
+ data,
83444
+ margin: { bottom: 10, left: 10, right: 10, top: 10 }
83445
+ },
83446
+ /* @__PURE__ */ React__default.createElement(CartesianGrid, { vertical: false }),
83447
+ /* @__PURE__ */ React__default.createElement(Tooltip$1, { content: /* @__PURE__ */ React__default.createElement(Tooltip, { title: tooltipTitle }) }),
83349
83448
  /* @__PURE__ */ React__default.createElement(
83350
- CenteredLabel,
83449
+ XAxis,
83351
83450
  {
83352
- radius,
83353
- legendPosition,
83354
- label,
83355
- total,
83356
- formatter,
83357
- showLegend
83451
+ ...getAxisProps(xAxisScale, xAxisTickFormatter, dataKey),
83452
+ hide: !showXAxis
83358
83453
  }
83359
83454
  ),
83360
- /* @__PURE__ */ React__default.createElement(PieChart, { data, height: diameter, width: diameter, style: { transform: "rotate(90deg) scale(-1,1)" } }, showTooltip ? /* @__PURE__ */ React__default.createElement(
83361
- Tooltip$1,
83362
- {
83363
- ...getTooltipProps({
83364
- style: { transform: "rotate(90deg) scale(-1,1)" },
83365
- singlePieDonutChart
83366
- })
83367
- }
83368
- ) : null, /* @__PURE__ */ React__default.createElement(
83369
- Pie,
83370
- {
83371
- isAnimationActive: false,
83372
- activeIndex: getActiveIndex(),
83373
- activeShape: /* @__PURE__ */ React__default.createElement(ActiveShape, { pieColors: activeShapeColor, onClick: handlePieClick }),
83374
- data: displayedData.length > 0 ? displayedData : [],
83375
- dataKey: "value",
83376
- innerRadius: radius - HOVER_DONUT_WIDTH - DONUT_WIDTH,
83377
- onMouseEnter: (segment) => displayedData.length > 0 && setHoveredItem([segment.id]),
83378
- onMouseLeave: () => setHoveredItem([]),
83379
- outerRadius: radius - HOVER_DONUT_WIDTH,
83380
- paddingAngle: 2,
83381
- rootTabIndex: -1
83382
- },
83383
- content()
83384
- )),
83385
- showLegend && /* @__PURE__ */ React__default.createElement(
83386
- Legend,
83387
- {
83388
- data,
83389
- visibleItems,
83390
- onClick: handleLegendClick,
83391
- total,
83392
- setHoveredItem,
83393
- label,
83394
- legendPosition,
83395
- hoveredItem,
83396
- selectedItem,
83397
- formatter
83398
- }
83399
- )
83400
- );
83401
- };
83402
- DonutChart.Segment = Segment;
83403
- const Line = (_) => null;
83404
- const LineChart = function LineChart2(externalProps) {
83405
- const { children, data, formatter, ...props } = externalProps;
83406
- const [hoveredLine, setHoveredLine] = useState(null);
83407
- const [activeLines, setActiveLines] = useState(() => {
83408
- const keys2 = {};
83409
- React__default.Children.forEach(children, (child) => {
83410
- keys2[child.props.accessor] = true;
83411
- });
83412
- return keys2;
83455
+ /* @__PURE__ */ React__default.createElement(YAxis, { ...getAxisProps(yAxisScale, yAxisTickFormatter), hide: !showYAxis }),
83456
+ shapes.map((shape) => /* @__PURE__ */ React__default.createElement(Line$1, { key: shape.dataKey, ...shape, dot: showDots ? shape.dot : false, type }))
83457
+ )), showLegend ? /* @__PURE__ */ React__default.createElement(Legend$1, { items, hoverIndex: activeIndex, onHover: setActiveIndex, onToggle: toggleItem }) : null);
83458
+ }
83459
+ function Line(_) {
83460
+ return null;
83461
+ }
83462
+ LineChart.Line = Line;
83463
+ function PieChart(props) {
83464
+ const { children, formatter, showLabels = false, showLegend = false, tooltipTitle, unit: unit2, ...attributes } = props;
83465
+ const { pieProps, setRadius, items, activeIndex, setActiveIndex, toggleItem } = usePieChart(children, {
83466
+ formatter,
83467
+ unit: unit2
83413
83468
  });
83414
- const handleLegendClick = (entry) => {
83415
- setHoveredLine(null);
83416
- setActiveLines({ ...activeLines, [entry.dataKey]: !activeLines[entry.dataKey] });
83417
- };
83418
- return /* @__PURE__ */ React__default.createElement(ResponsiveContainer, null, /* @__PURE__ */ React__default.createElement(LineChart$1, { data, margin: { top: 10, right: 0, left: -25, bottom: 0 } }, /* @__PURE__ */ React__default.createElement(CartesianGrid, { ...getCartesianGridProps() }), /* @__PURE__ */ React__default.createElement(XAxis, { ...getXAxisProps(props) }), /* @__PURE__ */ React__default.createElement(YAxis, { ...getYAxisProps(props) }), /* @__PURE__ */ React__default.createElement(
83419
- Legend$2,
83420
- {
83421
- ...getLegendProps2({
83422
- onClick: handleLegendClick,
83423
- onMouseEnter: (entry) => setHoveredLine(entry.dataKey),
83424
- onMouseLeave: () => setHoveredLine(null),
83425
- activeItems: activeLines
83426
- })
83427
- }
83428
- ), /* @__PURE__ */ React__default.createElement(Tooltip$1, { ...getTooltipProps(), formatter }), React__default.Children.map(children, (child) => /* @__PURE__ */ React__default.createElement(
83429
- Line$1,
83469
+ const className = clsx("aspect-square", attributes.className);
83470
+ return /* @__PURE__ */ React__default.createElement("div", { className: "relative", "data-taco": "chart-wrapper" }, /* @__PURE__ */ React__default.createElement(ChartContainer, { ...attributes, className, "data-taco": "chart-pie", onSetWidth: setRadius }, /* @__PURE__ */ React__default.createElement(PieChart$1, null, /* @__PURE__ */ React__default.createElement(Tooltip$1, { content: /* @__PURE__ */ React__default.createElement(Tooltip, { title: tooltipTitle }) }), /* @__PURE__ */ React__default.createElement(Pie, { ...pieProps, label: showLabels ? /* @__PURE__ */ React__default.createElement(Label, null) : void 0 }))), showLegend ? /* @__PURE__ */ React__default.createElement(Legend$1, { items, hoverIndex: activeIndex, onHover: setActiveIndex, onToggle: toggleItem }) : null);
83471
+ }
83472
+ function Segment(_) {
83473
+ return null;
83474
+ }
83475
+ PieChart.Segment = Segment;
83476
+ const RADIAN = Math.PI / 180;
83477
+ function Label(props) {
83478
+ var _a, _b;
83479
+ const { cx, cy, midAngle, name, innerRadius, outerRadius } = props;
83480
+ const radius = innerRadius + (outerRadius - innerRadius) * 0.7;
83481
+ const x3 = cx + radius * Math.cos(-midAngle * RADIAN);
83482
+ const y4 = cy + radius * Math.sin(-midAngle * RADIAN);
83483
+ return /* @__PURE__ */ React__default.createElement(
83484
+ "text",
83430
83485
  {
83431
- activeDot: {
83432
- fill: getThemeColor(child.props.color ?? "blue-300")
83433
- },
83434
- dataKey: child.props.accessor,
83435
- isAnimationActive: false,
83436
- dot: false,
83437
- name: child.props.label,
83438
- stroke: getThemeColor(child.props.color ?? "blue-300"),
83439
- strokeWidth: 2,
83440
- hide: !activeLines[child.props.accessor],
83441
- opacity: hoveredLine && child.props.accessor !== hoveredLine ? 0.3 : 1
83442
- }
83443
- ))));
83444
- };
83445
- LineChart.Line = Line;
83486
+ x: x3,
83487
+ y: y4,
83488
+ fontSize: 12,
83489
+ fill: getInverseThemeColor(((_b = (_a = props.payload) == null ? void 0 : _a.payload) == null ? void 0 : _b.color) ?? ""),
83490
+ textAnchor: "middle",
83491
+ dominantBaseline: "middle"
83492
+ },
83493
+ name
83494
+ );
83495
+ }
83446
83496
  const Button3 = React__default.forwardRef(function Button23(props, ref) {
83447
83497
  const { ...attributes } = props;
83448
83498
  const className = clsx(getButtonClasses(), props.className);
@@ -84312,6 +84362,7 @@ export {
84312
84362
  IconButton,
84313
84363
  Input,
84314
84364
  Layout,
84365
+ LegacyDonutChart,
84315
84366
  LineChart,
84316
84367
  List$1 as List,
84317
84368
  Listbox,
@@ -84325,6 +84376,7 @@ export {
84325
84376
  OverflowGroup,
84326
84377
  PaginatedTable,
84327
84378
  Pagination,
84379
+ PieChart,
84328
84380
  Popover,
84329
84381
  Progress,
84330
84382
  Provider,