@economic/taco 2.57.0-charts.12 → 2.57.0-charts.13

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.cjs CHANGED
@@ -8035,7 +8035,7 @@ const defaultLocalisationTexts = {
8035
8035
  }
8036
8036
  };
8037
8037
  const defaultLocalizationContext = {
8038
- locale: "en-GB",
8038
+ locale: "da-DK",
8039
8039
  texts: defaultLocalisationTexts,
8040
8040
  formatting: {
8041
8041
  date: "dd.mm.yy"
@@ -82996,7 +82996,10 @@ function useChart(children, options) {
82996
82996
  const [activeIndex, setActiveIndex] = React.useState();
82997
82997
  const [hiddenItems, toggleItem] = useChartDataHiddenState();
82998
82998
  const localization = useLocalization();
82999
- const defaultFormatter2 = (value) => new Intl.NumberFormat(localization.locale).format(value);
82999
+ const defaultFormatter2 = (value) => new Intl.NumberFormat(localization.locale, { minimumFractionDigits: 2, trailingZeroDisplay: "stripIfInteger" }).format(
83000
+ value
83001
+ );
83002
+ const globalFormatter = (options == null ? void 0 : options.formatter) ?? defaultFormatter2;
83000
83003
  const { items, shapes } = React.useMemo(() => {
83001
83004
  const items2 = React.Children.toArray(children).filter((child) => React.isValidElement(child)).map((child) => {
83002
83005
  const dataKey = child.props.dataKey ?? child.props.label;
@@ -83004,7 +83007,7 @@ function useChart(children, options) {
83004
83007
  ...child.props,
83005
83008
  dataKey,
83006
83009
  color: getThemeColor(child.props.color, "blue-300"),
83007
- formatter: child.props.formatter ?? (options == null ? void 0 : options.formatter) ?? defaultFormatter2,
83010
+ formatter: child.props.formatter ?? globalFormatter,
83008
83011
  isHidden: !!hiddenItems[dataKey],
83009
83012
  unit: child.props.unit ?? (options == null ? void 0 : options.unit)
83010
83013
  };
@@ -83031,7 +83034,7 @@ function useChart(children, options) {
83031
83034
  });
83032
83035
  return { items: items2, shapes: shapes2 };
83033
83036
  }, [children, hiddenItems]);
83034
- return { items, shapes, activeIndex, setActiveIndex, toggleItem };
83037
+ return { items, shapes, activeIndex, setActiveIndex, globalFormatter, toggleItem };
83035
83038
  }
83036
83039
  function useChartDataHiddenState() {
83037
83040
  const [state, setState] = React.useState({});
@@ -83222,7 +83225,7 @@ BarChart.Bar = Bar;
83222
83225
  const PIE_ACTIVE_WIDTH = 10;
83223
83226
  const PIE_ACTIVE_WIDTH_OFFSET = 2;
83224
83227
  function usePieChart(children, options) {
83225
- const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children, options);
83228
+ const { items, shapes, activeIndex, setActiveIndex, globalFormatter, toggleItem } = useChart(children, options);
83226
83229
  const [radius, _setRadius] = React.useState(0);
83227
83230
  function setRadius(width) {
83228
83231
  _setRadius((width - 2 * (PIE_ACTIVE_WIDTH + PIE_ACTIVE_WIDTH_OFFSET)) / 2);
@@ -83243,7 +83246,7 @@ function usePieChart(children, options) {
83243
83246
  labelLine: false,
83244
83247
  outerRadius: radius
83245
83248
  };
83246
- return { pieProps, radius, setRadius, items, activeIndex, setActiveIndex, toggleItem, shapes };
83249
+ return { pieProps, radius, setRadius, items, activeIndex, setActiveIndex, globalFormatter, toggleItem, shapes };
83247
83250
  }
83248
83251
  const PIE_CHART_HOVER = 10;
83249
83252
  const PIE_CHART_HOVER_OFFSET = 2;
@@ -83262,15 +83265,18 @@ function ActiveShape$1(props) {
83262
83265
  const DONUT_WIDTH$1 = 20;
83263
83266
  function DonutChart(props) {
83264
83267
  const { children, formatter, showLegend = false, showTotal = false, tooltipTitle, unit: unit2, ...attributes } = props;
83265
- const { pieProps, radius, setRadius, items, activeIndex, setActiveIndex, toggleItem } = usePieChart(children, {
83266
- formatter,
83267
- unit: unit2
83268
- });
83268
+ const { pieProps, radius, setRadius, items, activeIndex, setActiveIndex, globalFormatter, toggleItem } = usePieChart(
83269
+ children,
83270
+ {
83271
+ formatter,
83272
+ unit: unit2
83273
+ }
83274
+ );
83269
83275
  const className = clsx("aspect-square", attributes.className);
83270
83276
  return /* @__PURE__ */ React.createElement("div", { className: "relative", "data-taco": "chart-wrapper" }, /* @__PURE__ */ React.createElement(ChartWrapper, { ...attributes, className, "data-taco": "chart-donut", onSetWidth: setRadius }, /* @__PURE__ */ React.createElement(PieChart$1, null, /* @__PURE__ */ React.createElement(Tooltip$1, { content: /* @__PURE__ */ React.createElement(Tooltip, { title: tooltipTitle }) }), /* @__PURE__ */ React.createElement(Pie, { ...pieProps, innerRadius: radius - DONUT_WIDTH$1 }))), showTotal ? /* @__PURE__ */ React.createElement(
83271
83277
  Total,
83272
83278
  {
83273
- formatter,
83279
+ formatter: globalFormatter,
83274
83280
  items,
83275
83281
  unit: unit2,
83276
83282
  style: { top: radius + DONUT_WIDTH$1 / 2, width: radius + DONUT_WIDTH$1 * 2 }
@@ -83283,10 +83289,9 @@ function Segment$2(_) {
83283
83289
  DonutChart.Segment = Segment$2;
83284
83290
  function Total(props) {
83285
83291
  const { formatter, items, unit: unit2, ...attributes } = props;
83286
- const localization = useLocalization();
83287
83292
  const total = React.useMemo(() => {
83288
83293
  const total2 = items.filter((item) => !item.isHidden).reduce((acc, curr) => acc + curr.value, 0);
83289
- return (formatter == null ? void 0 : formatter(total2)) ?? new Intl.NumberFormat(localization.locale).format(total2);
83294
+ return formatter(total2);
83290
83295
  }, [items]);
83291
83296
  return /* @__PURE__ */ React.createElement(
83292
83297
  "div",