@economic/taco 2.57.0-charts.1 → 2.57.0-charts.11
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 +101 -40
- package/dist/taco.cjs.map +1 -1
- package/dist/taco.css +66 -23
- package/dist/taco.d.ts +1 -0
- package/dist/taco.js +101 -40
- package/dist/taco.js.map +1 -1
- package/package.json +2 -2
package/dist/taco.css
CHANGED
@@ -181,29 +181,6 @@ table.yt-table tbody.yt-table__body tr.yt-table__row td.yt-table__cell {
|
|
181
181
|
@apply opacity-100;
|
182
182
|
}
|
183
183
|
}
|
184
|
-
|
185
|
-
.recharts-cartesian-axis line,
|
186
|
-
.recharts-cartesian-grid-horizontal line,
|
187
|
-
.recharts-cartesian-grid-vertical line {
|
188
|
-
@apply !stroke-grey-100;
|
189
|
-
}
|
190
|
-
|
191
|
-
.recharts-cartesian-axis-tick-value {
|
192
|
-
@apply !fill-grey-700;
|
193
|
-
}
|
194
|
-
|
195
|
-
.recharts-tooltip-cursor {
|
196
|
-
@apply !fill-transparent;
|
197
|
-
}
|
198
|
-
|
199
|
-
.recharts-legend-wrapper {
|
200
|
-
@apply !left-0 !w-full;
|
201
|
-
}
|
202
|
-
|
203
|
-
.recharts-sector,
|
204
|
-
.recharts-wrapper > svg g {
|
205
|
-
@apply !outline-none;
|
206
|
-
}
|
207
184
|
[data-taco='badge'] > [data-taco='spinner'] {
|
208
185
|
@apply ml-2 h-3 w-3;
|
209
186
|
}
|
@@ -1581,3 +1558,69 @@ table[data-taco^='table'][data-table-row-height='extra-tall'] tr[data-row-create
|
|
1581
1558
|
table[data-taco^='table'] tr[data-row-create] {
|
1582
1559
|
@apply print:hidden;
|
1583
1560
|
}
|
1561
|
+
[data-taco='card-content'] > [data-taco='chart-wrapper']:not(:has([data-taco='chart-donut'], [data-taco='chart-pie'])) {
|
1562
|
+
@apply w-full;
|
1563
|
+
}
|
1564
|
+
|
1565
|
+
[data-taco='card-content']
|
1566
|
+
> [data-taco='chart-wrapper']:not([class*='h-']):not(:has([data-taco='chart-donut'], [data-taco='chart-pie'])) {
|
1567
|
+
@apply h-full;
|
1568
|
+
}
|
1569
|
+
|
1570
|
+
[data-taco='card-content'] > [data-taco='chart-wrapper'] {
|
1571
|
+
container: wrapper / inline-size;
|
1572
|
+
}
|
1573
|
+
|
1574
|
+
[data-taco='card-content'] > [data-taco='chart-wrapper'] [data-taco='chart-donut']:not([class*='w-']),
|
1575
|
+
[data-taco='card-content'] > [data-taco='chart-wrapper'] [data-taco='chart-pie']:not([class*='w-']) {
|
1576
|
+
@apply aspect-square w-3/5;
|
1577
|
+
}
|
1578
|
+
|
1579
|
+
@container wrapper (width > 400px) {
|
1580
|
+
[data-taco='card-content'] > [data-taco='chart-wrapper'] [data-taco='chart-donut']:not([class*='w-']),
|
1581
|
+
[data-taco='card-content'] > [data-taco='chart-wrapper'] [data-taco='chart-pie']:not([class*='w-']) {
|
1582
|
+
@apply w-2/3;
|
1583
|
+
}
|
1584
|
+
}
|
1585
|
+
|
1586
|
+
.recharts-cartesian-axis line,
|
1587
|
+
.recharts-cartesian-grid-horizontal line,
|
1588
|
+
.recharts-cartesian-grid-vertical line {
|
1589
|
+
@apply !stroke-grey-100;
|
1590
|
+
}
|
1591
|
+
|
1592
|
+
.recharts-cartesian-axis-tick-value {
|
1593
|
+
@apply !fill-grey-700;
|
1594
|
+
}
|
1595
|
+
|
1596
|
+
.recharts-tooltip-cursor {
|
1597
|
+
@apply !fill-transparent;
|
1598
|
+
}
|
1599
|
+
|
1600
|
+
.recharts-legend-wrapper {
|
1601
|
+
@apply !left-0 !w-full;
|
1602
|
+
}
|
1603
|
+
|
1604
|
+
.recharts-sector,
|
1605
|
+
.recharts-wrapper > svg g {
|
1606
|
+
@apply !outline-none;
|
1607
|
+
}
|
1608
|
+
[data-taco='chart-donut-total'] {
|
1609
|
+
container: wrapper / inline-size;
|
1610
|
+
}
|
1611
|
+
|
1612
|
+
@container wrapper (width > 130px) {
|
1613
|
+
[data-taco='chart-donut-total'] span:first-child {
|
1614
|
+
@apply text-xl;
|
1615
|
+
}
|
1616
|
+
}
|
1617
|
+
|
1618
|
+
@container wrapper (width < 80px) {
|
1619
|
+
[data-taco='chart-donut-total'] span:first-child {
|
1620
|
+
@apply text-base;
|
1621
|
+
}
|
1622
|
+
}
|
1623
|
+
|
1624
|
+
[data-taco='chart-donut']:has([data-taco='chart-tooltip']) {
|
1625
|
+
@apply relative z-10;
|
1626
|
+
}
|
package/dist/taco.d.ts
CHANGED
@@ -461,6 +461,7 @@ declare interface ChartProps<TData extends object> {
|
|
461
461
|
xAxisTickFormatter?: TickFormatter;
|
462
462
|
yAxisScale?: ScaleType | Function;
|
463
463
|
yAxisTickFormatter?: TickFormatter;
|
464
|
+
yAxisWidth?: number;
|
464
465
|
}
|
465
466
|
|
466
467
|
declare type ChartValueFormatter = (value: number) => string | JSX.Element;
|
package/dist/taco.js
CHANGED
@@ -82743,18 +82743,21 @@ var AreaChart$1 = generateCategoricalChart({
|
|
82743
82743
|
}],
|
82744
82744
|
formatAxisMap: formatAxisMap2
|
82745
82745
|
});
|
82746
|
-
function getAxisProps(scale2, tickFormatter, dataKey) {
|
82746
|
+
function getAxisProps(scale2, tickFormatter, dataKey, width) {
|
82747
|
+
const isYAxis = dataKey === void 0;
|
82747
82748
|
return {
|
82748
82749
|
axisLine: false,
|
82749
82750
|
dataKey,
|
82750
82751
|
fontSize: 11,
|
82752
|
+
interval: "preserveStartEnd",
|
82751
82753
|
scale: scale2,
|
82752
82754
|
tickLine: false,
|
82753
|
-
tickMargin:
|
82754
|
-
tickFormatter
|
82755
|
+
tickMargin: isYAxis ? 2 : 6,
|
82756
|
+
tickFormatter,
|
82757
|
+
width: width ?? 55
|
82755
82758
|
};
|
82756
82759
|
}
|
82757
|
-
function
|
82760
|
+
function ChartWrapper(props) {
|
82758
82761
|
const { onSetWidth: handleSetWidth, ...attributes } = props;
|
82759
82762
|
const ref = React__default.useRef(null);
|
82760
82763
|
React__default.useLayoutEffect(() => {
|
@@ -82763,17 +82766,17 @@ function ChartContainer(props) {
|
|
82763
82766
|
handleSetWidth(rect.width);
|
82764
82767
|
}
|
82765
82768
|
}, [ref]);
|
82766
|
-
const className = clsx("flex justify-center
|
82769
|
+
const className = clsx("flex justify-center m-auto", attributes.className);
|
82767
82770
|
return /* @__PURE__ */ React__default.createElement("div", { ...attributes, className, ref }, /* @__PURE__ */ React__default.createElement(ResponsiveContainer, null, props.children));
|
82768
82771
|
}
|
82769
82772
|
function Tooltip(props) {
|
82770
82773
|
const { active, payload = [], style, title } = props;
|
82771
82774
|
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) => {
|
82775
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: "border-grey-300 z-20 z-[999] 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
82776
|
const color2 = entry.color ?? entry.payload.color;
|
82774
82777
|
const formatter = entry.formatter ?? entry.payload.formatter;
|
82775
82778
|
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));
|
82779
|
+
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", "data-taco": "chart-tooltip" }, /* @__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
82780
|
})));
|
82778
82781
|
}
|
82779
82782
|
return null;
|
@@ -82794,11 +82797,14 @@ function Legend$1(props) {
|
|
82794
82797
|
handleToggle(item.dataKey);
|
82795
82798
|
};
|
82796
82799
|
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) => {
|
82800
|
+
return /* @__PURE__ */ React__default.createElement(OverflowGroup, { className: "mt-3 w-full gap-x-1", moreButton }, items.map((item, index2) => {
|
82798
82801
|
const className = clsx("mr-1 flex h-3 w-3 rounded-sm", {
|
82799
|
-
[`bg-${item.color}`]: !item.isHidden,
|
82800
82802
|
border: item.isHidden
|
82801
82803
|
});
|
82804
|
+
let style;
|
82805
|
+
if (!item.isHidden) {
|
82806
|
+
style = { backgroundColor: item.color };
|
82807
|
+
}
|
82802
82808
|
return /* @__PURE__ */ React__default.createElement(
|
82803
82809
|
"button",
|
82804
82810
|
{
|
@@ -82811,7 +82817,7 @@ function Legend$1(props) {
|
|
82811
82817
|
onMouseEnter: () => handleMouseEnter(item, index2),
|
82812
82818
|
onMouseLeave: () => handleMouseLeave()
|
82813
82819
|
},
|
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),
|
82820
|
+
/* @__PURE__ */ React__default.createElement("span", { className, style }, hoverIndex === index2 ? /* @__PURE__ */ React__default.createElement(Icon$1, { name: "tick-bold", className: clsx("!h-full !w-full", { "text-white": !item.isHidden }) }) : null),
|
82815
82821
|
item.label
|
82816
82822
|
);
|
82817
82823
|
}));
|
@@ -82952,7 +82958,8 @@ const mapColor = (palette, prefix2 = "") => {
|
|
82952
82958
|
};
|
82953
82959
|
const colors = mapColor(THEME_COLORS);
|
82954
82960
|
const getThemeColor = (color2, def = "") => colors[color2 ?? def];
|
82955
|
-
const getInverseThemeColor = (
|
82961
|
+
const getInverseThemeColor = (hexCode) => {
|
82962
|
+
const themeColor = Object.keys(colors)[Object.values(colors).indexOf(hexCode)];
|
82956
82963
|
const [color2, number2] = String(themeColor).split("-");
|
82957
82964
|
const shade = Number(number2);
|
82958
82965
|
if (shade) {
|
@@ -82978,28 +82985,28 @@ function useChart(children, options) {
|
|
82978
82985
|
return {
|
82979
82986
|
...child.props,
|
82980
82987
|
dataKey,
|
82988
|
+
color: getThemeColor(child.props.color, "blue-300"),
|
82981
82989
|
formatter: child.props.formatter ?? (options == null ? void 0 : options.formatter) ?? defaultFormatter2,
|
82982
82990
|
isHidden: !!hiddenItems[dataKey],
|
82983
82991
|
unit: child.props.unit ?? (options == null ? void 0 : options.unit)
|
82984
82992
|
};
|
82985
82993
|
});
|
82986
82994
|
const shapes2 = items2.filter((item) => !hiddenItems[item.dataKey]).map((item) => {
|
82987
|
-
const color2 = getThemeColor(item.color, "blue-500");
|
82988
82995
|
return {
|
82989
82996
|
activeDot: {
|
82990
82997
|
strokeWidth: 1
|
82991
82998
|
},
|
82992
|
-
color:
|
82999
|
+
color: item.color,
|
82993
83000
|
dataKey: item.dataKey,
|
82994
83001
|
dot: {
|
82995
|
-
fillOpacity: 0.
|
83002
|
+
fillOpacity: 0.8
|
82996
83003
|
},
|
82997
83004
|
isAnimationActive: false,
|
82998
|
-
fill:
|
82999
|
-
fillOpacity: 0.
|
83005
|
+
fill: item.color,
|
83006
|
+
fillOpacity: 0.8,
|
83000
83007
|
formatter: item.formatter,
|
83001
83008
|
name: item.label,
|
83002
|
-
stroke:
|
83009
|
+
stroke: item.color,
|
83003
83010
|
strokeWidth: 1.5,
|
83004
83011
|
unit: item.unit
|
83005
83012
|
};
|
@@ -83026,6 +83033,7 @@ function useChartDataHiddenState() {
|
|
83026
83033
|
function AreaChart(props) {
|
83027
83034
|
const {
|
83028
83035
|
children,
|
83036
|
+
className: customClassName,
|
83029
83037
|
data,
|
83030
83038
|
dataKey,
|
83031
83039
|
showDots = false,
|
@@ -83039,15 +83047,22 @@ function AreaChart(props) {
|
|
83039
83047
|
xAxisTickFormatter,
|
83040
83048
|
yAxisScale,
|
83041
83049
|
yAxisTickFormatter,
|
83050
|
+
yAxisWidth,
|
83042
83051
|
...attributes
|
83043
83052
|
} = props;
|
83044
|
-
const className = clsx("aspect-video",
|
83053
|
+
const className = clsx("relative aspect-video", { "pb-8": showLegend }, customClassName);
|
83045
83054
|
const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children);
|
83046
|
-
return /* @__PURE__ */ React__default.createElement("div", { className
|
83055
|
+
return /* @__PURE__ */ React__default.createElement("div", { className, "data-taco": "chart-wrapper" }, /* @__PURE__ */ React__default.createElement(ChartWrapper, { ...attributes, className: "h-full w-full", "data-taco": "chart-area" }, /* @__PURE__ */ React__default.createElement(
|
83047
83056
|
AreaChart$1,
|
83048
83057
|
{
|
83049
83058
|
data,
|
83050
|
-
margin: {
|
83059
|
+
margin: {
|
83060
|
+
bottom: 0,
|
83061
|
+
// ensures dots on the edges of the chart don't get cropped
|
83062
|
+
left: 4,
|
83063
|
+
right: 4,
|
83064
|
+
top: 4
|
83065
|
+
},
|
83051
83066
|
stackOffset: stacked === "expand" ? "expand" : void 0
|
83052
83067
|
},
|
83053
83068
|
/* @__PURE__ */ React__default.createElement(CartesianGrid, { vertical: false }),
|
@@ -83059,13 +83074,20 @@ function AreaChart(props) {
|
|
83059
83074
|
hide: !showXAxis
|
83060
83075
|
}
|
83061
83076
|
),
|
83062
|
-
/* @__PURE__ */ React__default.createElement(
|
83077
|
+
/* @__PURE__ */ React__default.createElement(
|
83078
|
+
YAxis,
|
83079
|
+
{
|
83080
|
+
...getAxisProps(yAxisScale, yAxisTickFormatter, void 0, yAxisWidth),
|
83081
|
+
hide: !showYAxis
|
83082
|
+
}
|
83083
|
+
),
|
83063
83084
|
shapes.map((shape) => /* @__PURE__ */ React__default.createElement(
|
83064
83085
|
Area$1,
|
83065
83086
|
{
|
83066
83087
|
key: shape.dataKey,
|
83067
83088
|
...shape,
|
83068
83089
|
dot: showDots ? shape.dot : false,
|
83090
|
+
fillOpacity: 0.4,
|
83069
83091
|
stackId: stacked ? "stack" : void 0,
|
83070
83092
|
type
|
83071
83093
|
}
|
@@ -83076,11 +83098,12 @@ function Area(_) {
|
|
83076
83098
|
return null;
|
83077
83099
|
}
|
83078
83100
|
AreaChart.Area = Area;
|
83079
|
-
const BAR_WIDTH =
|
83101
|
+
const BAR_WIDTH = 18;
|
83080
83102
|
function BarChart(props) {
|
83081
83103
|
const isHorizontal = props.layout === "horizontal";
|
83082
83104
|
const {
|
83083
83105
|
children,
|
83106
|
+
className: customClassName,
|
83084
83107
|
data,
|
83085
83108
|
dataKey,
|
83086
83109
|
showLabels = false,
|
@@ -83088,26 +83111,34 @@ function BarChart(props) {
|
|
83088
83111
|
showXAxis = !isHorizontal,
|
83089
83112
|
showYAxis = isHorizontal,
|
83090
83113
|
stacked = false,
|
83114
|
+
tooltipTitle,
|
83091
83115
|
xAxisScale,
|
83092
83116
|
xAxisTickFormatter,
|
83093
83117
|
yAxisScale,
|
83094
83118
|
yAxisTickFormatter,
|
83119
|
+
yAxisWidth,
|
83095
83120
|
...attributes
|
83096
83121
|
} = props;
|
83097
|
-
const className = clsx("aspect-video",
|
83122
|
+
const className = clsx("relative aspect-video", { "pb-8": showLegend }, customClassName);
|
83098
83123
|
const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children);
|
83099
|
-
return /* @__PURE__ */ React__default.createElement("div", { className
|
83124
|
+
return /* @__PURE__ */ React__default.createElement("div", { className, "data-taco": "chart-wrapper" }, /* @__PURE__ */ React__default.createElement(ChartWrapper, { ...attributes, className: "h-full w-full", "data-taco": "chart-bar" }, /* @__PURE__ */ React__default.createElement(
|
83100
83125
|
BarChart$1,
|
83101
83126
|
{
|
83102
83127
|
data,
|
83103
83128
|
barCategoryGap: "15%",
|
83104
83129
|
barGap: "7.5%",
|
83105
|
-
margin: {
|
83130
|
+
margin: {
|
83131
|
+
bottom: 0,
|
83132
|
+
left: 0,
|
83133
|
+
right: 0,
|
83134
|
+
// ensures labels on top of bars don't get cropped
|
83135
|
+
top: isHorizontal ? 0 : 10
|
83136
|
+
},
|
83106
83137
|
layout: isHorizontal ? "vertical" : void 0,
|
83107
83138
|
stackOffset: stacked === "expand" ? "expand" : void 0
|
83108
83139
|
},
|
83109
83140
|
/* @__PURE__ */ React__default.createElement(CartesianGrid, { horizontal: !isHorizontal, vertical: false }),
|
83110
|
-
/* @__PURE__ */ React__default.createElement(Tooltip$1, { content: /* @__PURE__ */ React__default.createElement(Tooltip,
|
83141
|
+
/* @__PURE__ */ React__default.createElement(Tooltip$1, { content: /* @__PURE__ */ React__default.createElement(Tooltip, { title: tooltipTitle }) }),
|
83111
83142
|
/* @__PURE__ */ React__default.createElement(
|
83112
83143
|
XAxis,
|
83113
83144
|
{
|
@@ -83119,8 +83150,14 @@ function BarChart(props) {
|
|
83119
83150
|
/* @__PURE__ */ React__default.createElement(
|
83120
83151
|
YAxis,
|
83121
83152
|
{
|
83122
|
-
...getAxisProps(
|
83153
|
+
...getAxisProps(
|
83154
|
+
yAxisScale,
|
83155
|
+
yAxisTickFormatter,
|
83156
|
+
isHorizontal ? dataKey : void 0,
|
83157
|
+
yAxisWidth
|
83158
|
+
),
|
83123
83159
|
hide: !showYAxis,
|
83160
|
+
minTickGap: isHorizontal ? 1 : 5,
|
83124
83161
|
type: isHorizontal ? "category" : void 0
|
83125
83162
|
}
|
83126
83163
|
),
|
@@ -83130,17 +83167,17 @@ function BarChart(props) {
|
|
83130
83167
|
key: shape.dataKey,
|
83131
83168
|
...shape,
|
83132
83169
|
activeBar: { fillOpacity: 1, strokeWidth: 0 },
|
83133
|
-
strokeWidth: 0,
|
83134
83170
|
maxBarSize: BAR_WIDTH,
|
83135
83171
|
radius: getRadius(index2, shapes.length, !!stacked, isHorizontal),
|
83136
|
-
stackId: stacked ? "stack" : void 0
|
83172
|
+
stackId: stacked ? "stack" : void 0,
|
83173
|
+
strokeWidth: 0
|
83137
83174
|
},
|
83138
83175
|
showLabels ? /* @__PURE__ */ React__default.createElement(
|
83139
83176
|
LabelList,
|
83140
83177
|
{
|
83141
83178
|
position: isHorizontal ? "insideRight" : "top",
|
83142
83179
|
formatter: shape.formatter,
|
83143
|
-
offset:
|
83180
|
+
offset: 6,
|
83144
83181
|
fill: isHorizontal ? getInverseThemeColor(shape.color ?? "") : "black",
|
83145
83182
|
fontSize: 11
|
83146
83183
|
}
|
@@ -83212,15 +83249,15 @@ function DonutChart(props) {
|
|
83212
83249
|
unit: unit2
|
83213
83250
|
});
|
83214
83251
|
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(
|
83252
|
+
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(
|
83216
83253
|
Total,
|
83217
83254
|
{
|
83218
83255
|
formatter,
|
83219
83256
|
items,
|
83220
83257
|
unit: unit2,
|
83221
|
-
style: { top: radius
|
83258
|
+
style: { top: radius + DONUT_WIDTH$1 / 2, width: radius + DONUT_WIDTH$1 * 2 }
|
83222
83259
|
}
|
83223
|
-
) : null,
|
83260
|
+
) : null, showLegend ? /* @__PURE__ */ React__default.createElement(Legend$1, { items, hoverIndex: activeIndex, onHover: setActiveIndex, onToggle: toggleItem }) : null);
|
83224
83261
|
}
|
83225
83262
|
function Segment$2(_) {
|
83226
83263
|
return null;
|
@@ -83233,7 +83270,16 @@ function Total(props) {
|
|
83233
83270
|
const total2 = items.filter((item) => !item.isHidden).reduce((acc, curr) => acc + curr.value, 0);
|
83234
83271
|
return (formatter == null ? void 0 : formatter(total2)) ?? new Intl.NumberFormat(localization.locale).format(total2);
|
83235
83272
|
}, [items]);
|
83236
|
-
return /* @__PURE__ */ React__default.createElement(
|
83273
|
+
return /* @__PURE__ */ React__default.createElement(
|
83274
|
+
"div",
|
83275
|
+
{
|
83276
|
+
...attributes,
|
83277
|
+
className: "absolute-center flex aspect-video flex-col items-center justify-center overflow-hidden rounded-full",
|
83278
|
+
"data-taco": "chart-donut-total"
|
83279
|
+
},
|
83280
|
+
/* @__PURE__ */ React__default.createElement(Tooltip$3, { title: total }, /* @__PURE__ */ React__default.createElement("span", { className: "w-full truncate text-center text-lg font-bold tabular-nums" }, total)),
|
83281
|
+
unit2 ? /* @__PURE__ */ React__default.createElement("span", { className: "text-grey-700 -mb-1 -mt-0.5 truncate text-xs" }, unit2) : null
|
83282
|
+
);
|
83237
83283
|
}
|
83238
83284
|
const Legend = ({ hoveredItem, selectedItem, data, onClick, setHoveredItem, formatter, total, label }) => {
|
83239
83285
|
const isTotalLegendSelected = selectedItem.length === data.length;
|
@@ -83262,7 +83308,7 @@ const Legend = ({ hoveredItem, selectedItem, data, onClick, setHoveredItem, form
|
|
83262
83308
|
};
|
83263
83309
|
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)));
|
83264
83310
|
};
|
83265
|
-
const DONUT_WIDTH =
|
83311
|
+
const DONUT_WIDTH = 16;
|
83266
83312
|
const HOVER_DONUT_WIDTH = 10;
|
83267
83313
|
const CenteredLabel = ({ radius, label, total, formatter }) => {
|
83268
83314
|
const totalInset = HOVER_DONUT_WIDTH + DONUT_WIDTH + DONUT_WIDTH;
|
@@ -83399,6 +83445,7 @@ const LegacyDonutChart = function LegacyDonutChart2({ children, formatter, onCli
|
|
83399
83445
|
onMouseEnter: (segment) => data.length > 0 && setHoveredItem([segment.id]),
|
83400
83446
|
onMouseLeave: () => setHoveredItem([]),
|
83401
83447
|
outerRadius: radius - HOVER_DONUT_WIDTH,
|
83448
|
+
paddingAngle: 2.5,
|
83402
83449
|
stroke: "0",
|
83403
83450
|
rootTabIndex: -1
|
83404
83451
|
},
|
@@ -83421,6 +83468,7 @@ LegacyDonutChart.Segment = Segment$1;
|
|
83421
83468
|
function LineChart(props) {
|
83422
83469
|
const {
|
83423
83470
|
children,
|
83471
|
+
className: customClassName,
|
83424
83472
|
data,
|
83425
83473
|
dataKey,
|
83426
83474
|
showDots = false,
|
@@ -83433,15 +83481,22 @@ function LineChart(props) {
|
|
83433
83481
|
xAxisTickFormatter,
|
83434
83482
|
yAxisScale,
|
83435
83483
|
yAxisTickFormatter,
|
83484
|
+
yAxisWidth,
|
83436
83485
|
...attributes
|
83437
83486
|
} = props;
|
83438
|
-
const className = clsx("aspect-video",
|
83487
|
+
const className = clsx("relative aspect-video", { "pb-8": showLegend }, customClassName);
|
83439
83488
|
const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children);
|
83440
|
-
return /* @__PURE__ */ React__default.createElement("div", { className
|
83489
|
+
return /* @__PURE__ */ React__default.createElement("div", { className, "data-taco": "chart-wrapper" }, /* @__PURE__ */ React__default.createElement(ChartWrapper, { ...attributes, className: "h-full w-full", "data-taco": "chart-line" }, /* @__PURE__ */ React__default.createElement(
|
83441
83490
|
LineChart$1,
|
83442
83491
|
{
|
83443
83492
|
data,
|
83444
|
-
margin: {
|
83493
|
+
margin: {
|
83494
|
+
bottom: 0,
|
83495
|
+
// ensures dots on the edges of the chart don't get cropped
|
83496
|
+
left: 4,
|
83497
|
+
right: 4,
|
83498
|
+
top: 4
|
83499
|
+
}
|
83445
83500
|
},
|
83446
83501
|
/* @__PURE__ */ React__default.createElement(CartesianGrid, { vertical: false }),
|
83447
83502
|
/* @__PURE__ */ React__default.createElement(Tooltip$1, { content: /* @__PURE__ */ React__default.createElement(Tooltip, { title: tooltipTitle }) }),
|
@@ -83452,7 +83507,13 @@ function LineChart(props) {
|
|
83452
83507
|
hide: !showXAxis
|
83453
83508
|
}
|
83454
83509
|
),
|
83455
|
-
/* @__PURE__ */ React__default.createElement(
|
83510
|
+
/* @__PURE__ */ React__default.createElement(
|
83511
|
+
YAxis,
|
83512
|
+
{
|
83513
|
+
...getAxisProps(yAxisScale, yAxisTickFormatter, void 0, yAxisWidth),
|
83514
|
+
hide: !showYAxis
|
83515
|
+
}
|
83516
|
+
),
|
83456
83517
|
shapes.map((shape) => /* @__PURE__ */ React__default.createElement(Line$1, { key: shape.dataKey, ...shape, dot: showDots ? shape.dot : false, type }))
|
83457
83518
|
)), showLegend ? /* @__PURE__ */ React__default.createElement(Legend$1, { items, hoverIndex: activeIndex, onHover: setActiveIndex, onToggle: toggleItem }) : null);
|
83458
83519
|
}
|
@@ -83467,7 +83528,7 @@ function PieChart(props) {
|
|
83467
83528
|
unit: unit2
|
83468
83529
|
});
|
83469
83530
|
const className = clsx("aspect-square", attributes.className);
|
83470
|
-
return /* @__PURE__ */ React__default.createElement("div", { className: "relative", "data-taco": "chart-wrapper" }, /* @__PURE__ */ React__default.createElement(
|
83531
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: "relative", "data-taco": "chart-wrapper" }, /* @__PURE__ */ React__default.createElement(ChartWrapper, { ...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
83532
|
}
|
83472
83533
|
function Segment(_) {
|
83473
83534
|
return null;
|