@economic/taco 2.57.0-charts.2 → 2.57.0-charts.4
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 +61 -21
- package/dist/taco.cjs.map +1 -1
- package/dist/taco.d.ts +1 -0
- package/dist/taco.js +61 -21
- package/dist/taco.js.map +1 -1
- package/package.json +2 -2
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,15 +82743,18 @@ 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
82760
|
function ChartContainer(props) {
|
@@ -82794,7 +82797,7 @@ 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-2.5 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
82802
|
[`bg-${item.color}`]: !item.isHidden,
|
82800
82803
|
border: item.isHidden
|
@@ -82984,7 +82987,7 @@ function useChart(children, options) {
|
|
82984
82987
|
};
|
82985
82988
|
});
|
82986
82989
|
const shapes2 = items2.filter((item) => !hiddenItems[item.dataKey]).map((item) => {
|
82987
|
-
const color2 = getThemeColor(item.color, "blue-
|
82990
|
+
const color2 = getThemeColor(item.color, "blue-300");
|
82988
82991
|
return {
|
82989
82992
|
activeDot: {
|
82990
82993
|
strokeWidth: 1
|
@@ -82992,7 +82995,7 @@ function useChart(children, options) {
|
|
82992
82995
|
color: color2,
|
82993
82996
|
dataKey: item.dataKey,
|
82994
82997
|
dot: {
|
82995
|
-
fillOpacity: 0.
|
82998
|
+
fillOpacity: 0.8
|
82996
82999
|
},
|
82997
83000
|
isAnimationActive: false,
|
82998
83001
|
fill: color2,
|
@@ -83026,6 +83029,7 @@ function useChartDataHiddenState() {
|
|
83026
83029
|
function AreaChart(props) {
|
83027
83030
|
const {
|
83028
83031
|
children,
|
83032
|
+
className: customClassName,
|
83029
83033
|
data,
|
83030
83034
|
dataKey,
|
83031
83035
|
showDots = false,
|
@@ -83041,13 +83045,19 @@ function AreaChart(props) {
|
|
83041
83045
|
yAxisTickFormatter,
|
83042
83046
|
...attributes
|
83043
83047
|
} = props;
|
83044
|
-
const className = clsx("aspect-video",
|
83048
|
+
const className = clsx("relative aspect-video", { "mb-6": showLegend }, customClassName);
|
83045
83049
|
const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children);
|
83046
|
-
return /* @__PURE__ */ React__default.createElement("div", { className
|
83050
|
+
return /* @__PURE__ */ React__default.createElement("div", { className, "data-taco": "chart-wrapper" }, /* @__PURE__ */ React__default.createElement(ChartContainer, { ...attributes, className: "h-full w-full", "data-taco": "chart-area" }, /* @__PURE__ */ React__default.createElement(
|
83047
83051
|
AreaChart$1,
|
83048
83052
|
{
|
83049
83053
|
data,
|
83050
|
-
margin: {
|
83054
|
+
margin: {
|
83055
|
+
bottom: 0,
|
83056
|
+
// ensures dots on the edges of the chart don't get cropped
|
83057
|
+
left: 4,
|
83058
|
+
right: 4,
|
83059
|
+
top: 4
|
83060
|
+
},
|
83051
83061
|
stackOffset: stacked === "expand" ? "expand" : void 0
|
83052
83062
|
},
|
83053
83063
|
/* @__PURE__ */ React__default.createElement(CartesianGrid, { vertical: false }),
|
@@ -83066,6 +83076,7 @@ function AreaChart(props) {
|
|
83066
83076
|
key: shape.dataKey,
|
83067
83077
|
...shape,
|
83068
83078
|
dot: showDots ? shape.dot : false,
|
83079
|
+
fillOpacity: 0.4,
|
83069
83080
|
stackId: stacked ? "stack" : void 0,
|
83070
83081
|
type
|
83071
83082
|
}
|
@@ -83076,11 +83087,12 @@ function Area(_) {
|
|
83076
83087
|
return null;
|
83077
83088
|
}
|
83078
83089
|
AreaChart.Area = Area;
|
83079
|
-
const BAR_WIDTH =
|
83090
|
+
const BAR_WIDTH = 18;
|
83080
83091
|
function BarChart(props) {
|
83081
83092
|
const isHorizontal = props.layout === "horizontal";
|
83082
83093
|
const {
|
83083
83094
|
children,
|
83095
|
+
className: customClassName,
|
83084
83096
|
data,
|
83085
83097
|
dataKey,
|
83086
83098
|
showLabels = false,
|
@@ -83092,17 +83104,24 @@ function BarChart(props) {
|
|
83092
83104
|
xAxisTickFormatter,
|
83093
83105
|
yAxisScale,
|
83094
83106
|
yAxisTickFormatter,
|
83107
|
+
yAxisWidth,
|
83095
83108
|
...attributes
|
83096
83109
|
} = props;
|
83097
|
-
const className = clsx("aspect-video",
|
83110
|
+
const className = clsx("relative aspect-video", { "mb-6": showLegend }, customClassName);
|
83098
83111
|
const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children);
|
83099
|
-
return /* @__PURE__ */ React__default.createElement("div", { className
|
83112
|
+
return /* @__PURE__ */ React__default.createElement("div", { className, "data-taco": "chart-wrapper" }, /* @__PURE__ */ React__default.createElement(ChartContainer, { ...attributes, className: "h-full w-full", "data-taco": "chart-bar" }, /* @__PURE__ */ React__default.createElement(
|
83100
83113
|
BarChart$1,
|
83101
83114
|
{
|
83102
83115
|
data,
|
83103
83116
|
barCategoryGap: "15%",
|
83104
83117
|
barGap: "7.5%",
|
83105
|
-
margin: {
|
83118
|
+
margin: {
|
83119
|
+
bottom: 0,
|
83120
|
+
left: 0,
|
83121
|
+
right: 0,
|
83122
|
+
// ensures labels on top of bars don't get cropped
|
83123
|
+
top: isHorizontal ? 0 : 10
|
83124
|
+
},
|
83106
83125
|
layout: isHorizontal ? "vertical" : void 0,
|
83107
83126
|
stackOffset: stacked === "expand" ? "expand" : void 0
|
83108
83127
|
},
|
@@ -83119,7 +83138,12 @@ function BarChart(props) {
|
|
83119
83138
|
/* @__PURE__ */ React__default.createElement(
|
83120
83139
|
YAxis,
|
83121
83140
|
{
|
83122
|
-
...getAxisProps(
|
83141
|
+
...getAxisProps(
|
83142
|
+
yAxisScale,
|
83143
|
+
yAxisTickFormatter,
|
83144
|
+
isHorizontal ? dataKey : void 0,
|
83145
|
+
yAxisWidth
|
83146
|
+
),
|
83123
83147
|
hide: !showYAxis,
|
83124
83148
|
type: isHorizontal ? "category" : void 0
|
83125
83149
|
}
|
@@ -83130,17 +83154,17 @@ function BarChart(props) {
|
|
83130
83154
|
key: shape.dataKey,
|
83131
83155
|
...shape,
|
83132
83156
|
activeBar: { fillOpacity: 1, strokeWidth: 0 },
|
83133
|
-
strokeWidth: 0,
|
83134
83157
|
maxBarSize: BAR_WIDTH,
|
83135
83158
|
radius: getRadius(index2, shapes.length, !!stacked, isHorizontal),
|
83136
|
-
stackId: stacked ? "stack" : void 0
|
83159
|
+
stackId: stacked ? "stack" : void 0,
|
83160
|
+
strokeWidth: 0
|
83137
83161
|
},
|
83138
83162
|
showLabels ? /* @__PURE__ */ React__default.createElement(
|
83139
83163
|
LabelList,
|
83140
83164
|
{
|
83141
83165
|
position: isHorizontal ? "insideRight" : "top",
|
83142
83166
|
formatter: shape.formatter,
|
83143
|
-
offset:
|
83167
|
+
offset: 6,
|
83144
83168
|
fill: isHorizontal ? getInverseThemeColor(shape.color ?? "") : "black",
|
83145
83169
|
fontSize: 11
|
83146
83170
|
}
|
@@ -83233,7 +83257,15 @@ function Total(props) {
|
|
83233
83257
|
const total2 = items.filter((item) => !item.isHidden).reduce((acc, curr) => acc + curr.value, 0);
|
83234
83258
|
return (formatter == null ? void 0 : formatter(total2)) ?? new Intl.NumberFormat(localization.locale).format(total2);
|
83235
83259
|
}, [items]);
|
83236
|
-
return /* @__PURE__ */ React__default.createElement(
|
83260
|
+
return /* @__PURE__ */ React__default.createElement(
|
83261
|
+
"div",
|
83262
|
+
{
|
83263
|
+
...attributes,
|
83264
|
+
className: "absolute-center-x flex aspect-square flex-col items-center justify-center rounded-full pt-[2px]"
|
83265
|
+
},
|
83266
|
+
/* @__PURE__ */ React__default.createElement("span", { className: "truncate text-2xl font-bold tabular-nums" }, total),
|
83267
|
+
unit2 ? /* @__PURE__ */ React__default.createElement("span", { className: "text-grey-700 -mb-1 -mt-0.5 truncate text-xs" }, unit2) : null
|
83268
|
+
);
|
83237
83269
|
}
|
83238
83270
|
const Legend = ({ hoveredItem, selectedItem, data, onClick, setHoveredItem, formatter, total, label }) => {
|
83239
83271
|
const isTotalLegendSelected = selectedItem.length === data.length;
|
@@ -83399,6 +83431,7 @@ const LegacyDonutChart = function LegacyDonutChart2({ children, formatter, onCli
|
|
83399
83431
|
onMouseEnter: (segment) => data.length > 0 && setHoveredItem([segment.id]),
|
83400
83432
|
onMouseLeave: () => setHoveredItem([]),
|
83401
83433
|
outerRadius: radius - HOVER_DONUT_WIDTH,
|
83434
|
+
paddingAngle: 2.5,
|
83402
83435
|
stroke: "0",
|
83403
83436
|
rootTabIndex: -1
|
83404
83437
|
},
|
@@ -83421,6 +83454,7 @@ LegacyDonutChart.Segment = Segment$1;
|
|
83421
83454
|
function LineChart(props) {
|
83422
83455
|
const {
|
83423
83456
|
children,
|
83457
|
+
className: customClassName,
|
83424
83458
|
data,
|
83425
83459
|
dataKey,
|
83426
83460
|
showDots = false,
|
@@ -83435,13 +83469,19 @@ function LineChart(props) {
|
|
83435
83469
|
yAxisTickFormatter,
|
83436
83470
|
...attributes
|
83437
83471
|
} = props;
|
83438
|
-
const className = clsx("aspect-video",
|
83472
|
+
const className = clsx("relative aspect-video", { "mb-6": showLegend }, customClassName);
|
83439
83473
|
const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children);
|
83440
|
-
return /* @__PURE__ */ React__default.createElement("div", { className
|
83474
|
+
return /* @__PURE__ */ React__default.createElement("div", { className, "data-taco": "chart-wrapper" }, /* @__PURE__ */ React__default.createElement(ChartContainer, { ...attributes, className: "h-full w-full", "data-taco": "chart-line" }, /* @__PURE__ */ React__default.createElement(
|
83441
83475
|
LineChart$1,
|
83442
83476
|
{
|
83443
83477
|
data,
|
83444
|
-
margin: {
|
83478
|
+
margin: {
|
83479
|
+
bottom: 0,
|
83480
|
+
// ensures dots on the edges of the chart don't get cropped
|
83481
|
+
left: 4,
|
83482
|
+
right: 4,
|
83483
|
+
top: 4
|
83484
|
+
}
|
83445
83485
|
},
|
83446
83486
|
/* @__PURE__ */ React__default.createElement(CartesianGrid, { vertical: false }),
|
83447
83487
|
/* @__PURE__ */ React__default.createElement(Tooltip$1, { content: /* @__PURE__ */ React__default.createElement(Tooltip, { title: tooltipTitle }) }),
|