@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 +18 -13
- package/dist/taco.cjs.map +1 -1
- package/dist/taco.js +18 -13
- package/dist/taco.js.map +1 -1
- package/package.json +2 -2
package/dist/taco.js
CHANGED
@@ -8017,7 +8017,7 @@ const defaultLocalisationTexts = {
|
|
8017
8017
|
}
|
8018
8018
|
};
|
8019
8019
|
const defaultLocalizationContext = {
|
8020
|
-
locale: "
|
8020
|
+
locale: "da-DK",
|
8021
8021
|
texts: defaultLocalisationTexts,
|
8022
8022
|
formatting: {
|
8023
8023
|
date: "dd.mm.yy"
|
@@ -82978,7 +82978,10 @@ function useChart(children, options) {
|
|
82978
82978
|
const [activeIndex, setActiveIndex] = React__default.useState();
|
82979
82979
|
const [hiddenItems, toggleItem] = useChartDataHiddenState();
|
82980
82980
|
const localization = useLocalization();
|
82981
|
-
const defaultFormatter2 = (value) => new Intl.NumberFormat(localization.locale).format(
|
82981
|
+
const defaultFormatter2 = (value) => new Intl.NumberFormat(localization.locale, { minimumFractionDigits: 2, trailingZeroDisplay: "stripIfInteger" }).format(
|
82982
|
+
value
|
82983
|
+
);
|
82984
|
+
const globalFormatter = (options == null ? void 0 : options.formatter) ?? defaultFormatter2;
|
82982
82985
|
const { items, shapes } = React__default.useMemo(() => {
|
82983
82986
|
const items2 = React__default.Children.toArray(children).filter((child) => React__default.isValidElement(child)).map((child) => {
|
82984
82987
|
const dataKey = child.props.dataKey ?? child.props.label;
|
@@ -82986,7 +82989,7 @@ function useChart(children, options) {
|
|
82986
82989
|
...child.props,
|
82987
82990
|
dataKey,
|
82988
82991
|
color: getThemeColor(child.props.color, "blue-300"),
|
82989
|
-
formatter: child.props.formatter ??
|
82992
|
+
formatter: child.props.formatter ?? globalFormatter,
|
82990
82993
|
isHidden: !!hiddenItems[dataKey],
|
82991
82994
|
unit: child.props.unit ?? (options == null ? void 0 : options.unit)
|
82992
82995
|
};
|
@@ -83013,7 +83016,7 @@ function useChart(children, options) {
|
|
83013
83016
|
});
|
83014
83017
|
return { items: items2, shapes: shapes2 };
|
83015
83018
|
}, [children, hiddenItems]);
|
83016
|
-
return { items, shapes, activeIndex, setActiveIndex, toggleItem };
|
83019
|
+
return { items, shapes, activeIndex, setActiveIndex, globalFormatter, toggleItem };
|
83017
83020
|
}
|
83018
83021
|
function useChartDataHiddenState() {
|
83019
83022
|
const [state, setState] = React__default.useState({});
|
@@ -83204,7 +83207,7 @@ BarChart.Bar = Bar;
|
|
83204
83207
|
const PIE_ACTIVE_WIDTH = 10;
|
83205
83208
|
const PIE_ACTIVE_WIDTH_OFFSET = 2;
|
83206
83209
|
function usePieChart(children, options) {
|
83207
|
-
const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children, options);
|
83210
|
+
const { items, shapes, activeIndex, setActiveIndex, globalFormatter, toggleItem } = useChart(children, options);
|
83208
83211
|
const [radius, _setRadius] = React__default.useState(0);
|
83209
83212
|
function setRadius(width) {
|
83210
83213
|
_setRadius((width - 2 * (PIE_ACTIVE_WIDTH + PIE_ACTIVE_WIDTH_OFFSET)) / 2);
|
@@ -83225,7 +83228,7 @@ function usePieChart(children, options) {
|
|
83225
83228
|
labelLine: false,
|
83226
83229
|
outerRadius: radius
|
83227
83230
|
};
|
83228
|
-
return { pieProps, radius, setRadius, items, activeIndex, setActiveIndex, toggleItem, shapes };
|
83231
|
+
return { pieProps, radius, setRadius, items, activeIndex, setActiveIndex, globalFormatter, toggleItem, shapes };
|
83229
83232
|
}
|
83230
83233
|
const PIE_CHART_HOVER = 10;
|
83231
83234
|
const PIE_CHART_HOVER_OFFSET = 2;
|
@@ -83244,15 +83247,18 @@ function ActiveShape$1(props) {
|
|
83244
83247
|
const DONUT_WIDTH$1 = 20;
|
83245
83248
|
function DonutChart(props) {
|
83246
83249
|
const { children, formatter, showLegend = false, showTotal = false, tooltipTitle, unit: unit2, ...attributes } = props;
|
83247
|
-
const { pieProps, radius, setRadius, items, activeIndex, setActiveIndex, toggleItem } = usePieChart(
|
83248
|
-
|
83249
|
-
|
83250
|
-
|
83250
|
+
const { pieProps, radius, setRadius, items, activeIndex, setActiveIndex, globalFormatter, toggleItem } = usePieChart(
|
83251
|
+
children,
|
83252
|
+
{
|
83253
|
+
formatter,
|
83254
|
+
unit: unit2
|
83255
|
+
}
|
83256
|
+
);
|
83251
83257
|
const className = clsx("aspect-square", attributes.className);
|
83252
83258
|
return /* @__PURE__ */ React__default.createElement("div", { className: "relative", "data-taco": "chart-wrapper" }, /* @__PURE__ */ React__default.createElement(ChartWrapper, { ...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 }))), showTotal ? /* @__PURE__ */ React__default.createElement(
|
83253
83259
|
Total,
|
83254
83260
|
{
|
83255
|
-
formatter,
|
83261
|
+
formatter: globalFormatter,
|
83256
83262
|
items,
|
83257
83263
|
unit: unit2,
|
83258
83264
|
style: { top: radius + DONUT_WIDTH$1 / 2, width: radius + DONUT_WIDTH$1 * 2 }
|
@@ -83265,10 +83271,9 @@ function Segment$2(_) {
|
|
83265
83271
|
DonutChart.Segment = Segment$2;
|
83266
83272
|
function Total(props) {
|
83267
83273
|
const { formatter, items, unit: unit2, ...attributes } = props;
|
83268
|
-
const localization = useLocalization();
|
83269
83274
|
const total = React__default.useMemo(() => {
|
83270
83275
|
const total2 = items.filter((item) => !item.isHidden).reduce((acc, curr) => acc + curr.value, 0);
|
83271
|
-
return
|
83276
|
+
return formatter(total2);
|
83272
83277
|
}, [items]);
|
83273
83278
|
return /* @__PURE__ */ React__default.createElement(
|
83274
83279
|
"div",
|