@yamada-ui/charts 1.1.2 → 1.1.4-dev-20240508155232
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/area-chart-gradient.d.mts +11 -0
- package/dist/area-chart-gradient.d.ts +11 -0
- package/dist/area-chart-gradient.js +47 -0
- package/dist/area-chart-gradient.js.map +1 -0
- package/dist/area-chart-gradient.mjs +8 -0
- package/dist/area-chart-gradient.mjs.map +1 -0
- package/dist/area-chart-split.d.mts +10 -0
- package/dist/area-chart-split.d.ts +10 -0
- package/dist/area-chart-split.js +52 -0
- package/dist/area-chart-split.js.map +1 -0
- package/dist/area-chart-split.mjs +8 -0
- package/dist/area-chart-split.mjs.map +1 -0
- package/dist/area-chart.d.mts +41 -0
- package/dist/area-chart.d.ts +41 -0
- package/dist/area-chart.js +1223 -0
- package/dist/area-chart.js.map +1 -0
- package/dist/area-chart.mjs +21 -0
- package/dist/area-chart.mjs.map +1 -0
- package/dist/bar-chart.d.mts +38 -0
- package/dist/bar-chart.d.ts +38 -0
- package/dist/bar-chart.js +1027 -0
- package/dist/bar-chart.js.map +1 -0
- package/dist/bar-chart.mjs +19 -0
- package/dist/bar-chart.mjs.map +1 -0
- package/dist/chart-legend.d.mts +12 -0
- package/dist/chart-legend.d.ts +12 -0
- package/dist/chart-legend.js +90 -0
- package/dist/chart-legend.js.map +1 -0
- package/dist/chart-legend.mjs +11 -0
- package/dist/chart-legend.mjs.map +1 -0
- package/dist/chart-tooltip.d.mts +12 -0
- package/dist/chart-tooltip.d.ts +12 -0
- package/dist/chart-tooltip.js +121 -0
- package/dist/chart-tooltip.js.map +1 -0
- package/dist/chart-tooltip.mjs +11 -0
- package/dist/chart-tooltip.mjs.map +1 -0
- package/dist/chart-utils.d.mts +9 -0
- package/dist/chart-utils.d.ts +9 -0
- package/dist/chart-utils.js +45 -0
- package/dist/chart-utils.js.map +1 -0
- package/dist/chart-utils.mjs +10 -0
- package/dist/chart-utils.mjs.map +1 -0
- package/dist/chart.types.d.mts +78 -0
- package/dist/chart.types.d.ts +78 -0
- package/dist/chart.types.js +20 -0
- package/dist/chart.types.js.map +1 -0
- package/dist/chart.types.mjs +2 -0
- package/dist/chart.types.mjs.map +1 -0
- package/dist/chunk-4WX5YS7M.mjs +179 -0
- package/dist/chunk-4WX5YS7M.mjs.map +1 -0
- package/dist/chunk-5TVYPA64.mjs +256 -0
- package/dist/chunk-5TVYPA64.mjs.map +1 -0
- package/dist/chunk-BPR7YL3O.mjs +179 -0
- package/dist/chunk-BPR7YL3O.mjs.map +1 -0
- package/dist/chunk-E2I2XAZ6.mjs +232 -0
- package/dist/chunk-E2I2XAZ6.mjs.map +1 -0
- package/dist/chunk-HDOYOHLA.mjs +326 -0
- package/dist/chunk-HDOYOHLA.mjs.map +1 -0
- package/dist/chunk-KNAADLWO.mjs +225 -0
- package/dist/chunk-KNAADLWO.mjs.map +1 -0
- package/dist/chunk-KT4YOMM4.mjs +344 -0
- package/dist/chunk-KT4YOMM4.mjs.map +1 -0
- package/dist/chunk-LBC2B6UX.mjs +84 -0
- package/dist/chunk-LBC2B6UX.mjs.map +1 -0
- package/dist/chunk-LGMALZCN.mjs +42 -0
- package/dist/chunk-LGMALZCN.mjs.map +1 -0
- package/dist/chunk-LHI57S6P.mjs +215 -0
- package/dist/chunk-LHI57S6P.mjs.map +1 -0
- package/dist/chunk-LM2DQK2P.mjs +33 -0
- package/dist/chunk-LM2DQK2P.mjs.map +1 -0
- package/dist/chunk-MSIOYYWR.mjs +24 -0
- package/dist/chunk-MSIOYYWR.mjs.map +1 -0
- package/dist/chunk-MWPICUEW.mjs +56 -0
- package/dist/chunk-MWPICUEW.mjs.map +1 -0
- package/dist/chunk-NEGDEVRX.mjs +53 -0
- package/dist/chunk-NEGDEVRX.mjs.map +1 -0
- package/dist/chunk-OSNFBRHL.mjs +474 -0
- package/dist/chunk-OSNFBRHL.mjs.map +1 -0
- package/dist/chunk-OW7SOTEF.mjs +206 -0
- package/dist/chunk-OW7SOTEF.mjs.map +1 -0
- package/dist/chunk-P7AFSM5W.mjs +114 -0
- package/dist/chunk-P7AFSM5W.mjs.map +1 -0
- package/dist/chunk-PNE3JG54.mjs +29 -0
- package/dist/chunk-PNE3JG54.mjs.map +1 -0
- package/dist/chunk-QL3DB7OJ.mjs +21 -0
- package/dist/chunk-QL3DB7OJ.mjs.map +1 -0
- package/dist/chunk-QZ5OXZ6Z.mjs +251 -0
- package/dist/chunk-QZ5OXZ6Z.mjs.map +1 -0
- package/dist/chunk-RN6PXJAD.mjs +47 -0
- package/dist/chunk-RN6PXJAD.mjs.map +1 -0
- package/dist/chunk-STBYRLC5.mjs +208 -0
- package/dist/chunk-STBYRLC5.mjs.map +1 -0
- package/dist/chunk-XIFDRM7J.mjs +56 -0
- package/dist/chunk-XIFDRM7J.mjs.map +1 -0
- package/dist/donut-chart.d.mts +31 -0
- package/dist/donut-chart.d.ts +31 -0
- package/dist/donut-chart.js +702 -0
- package/dist/donut-chart.js.map +1 -0
- package/dist/donut-chart.mjs +16 -0
- package/dist/donut-chart.mjs.map +1 -0
- package/dist/index.d.mts +26 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +3228 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +45 -0
- package/dist/index.mjs.map +1 -0
- package/dist/line-chart.d.mts +38 -0
- package/dist/line-chart.d.ts +38 -0
- package/dist/line-chart.js +1088 -0
- package/dist/line-chart.js.map +1 -0
- package/dist/line-chart.mjs +19 -0
- package/dist/line-chart.mjs.map +1 -0
- package/dist/pie-chart.d.mts +49 -0
- package/dist/pie-chart.d.ts +49 -0
- package/dist/pie-chart.js +702 -0
- package/dist/pie-chart.js.map +1 -0
- package/dist/pie-chart.mjs +16 -0
- package/dist/pie-chart.mjs.map +1 -0
- package/dist/radar-chart.d.mts +57 -0
- package/dist/radar-chart.d.ts +57 -0
- package/dist/radar-chart.js +918 -0
- package/dist/radar-chart.js.map +1 -0
- package/dist/radar-chart.mjs +16 -0
- package/dist/radar-chart.mjs.map +1 -0
- package/dist/rechart-properties.d.mts +26 -0
- package/dist/rechart-properties.d.ts +26 -0
- package/dist/rechart-properties.js +517 -0
- package/dist/rechart-properties.js.map +1 -0
- package/dist/rechart-properties.mjs +48 -0
- package/dist/rechart-properties.mjs.map +1 -0
- package/dist/use-area-chart.d.mts +123 -0
- package/dist/use-area-chart.d.ts +123 -0
- package/dist/use-area-chart.js +420 -0
- package/dist/use-area-chart.js.map +1 -0
- package/dist/use-area-chart.mjs +10 -0
- package/dist/use-area-chart.mjs.map +1 -0
- package/dist/use-bar-chart.d.mts +73 -0
- package/dist/use-bar-chart.d.ts +73 -0
- package/dist/use-bar-chart.js +290 -0
- package/dist/use-bar-chart.js.map +1 -0
- package/dist/use-bar-chart.mjs +10 -0
- package/dist/use-bar-chart.mjs.map +1 -0
- package/dist/use-chart-axis.d.mts +73 -0
- package/dist/use-chart-axis.d.ts +73 -0
- package/dist/use-chart-axis.js +227 -0
- package/dist/use-chart-axis.js.map +1 -0
- package/dist/use-chart-axis.mjs +10 -0
- package/dist/use-chart-axis.mjs.map +1 -0
- package/dist/use-chart-grid.d.mts +32 -0
- package/dist/use-chart-grid.d.ts +32 -0
- package/dist/use-chart-grid.js +92 -0
- package/dist/use-chart-grid.js.map +1 -0
- package/dist/use-chart-grid.mjs +10 -0
- package/dist/use-chart-grid.mjs.map +1 -0
- package/dist/use-chart-legend.d.mts +18 -0
- package/dist/use-chart-legend.d.ts +18 -0
- package/dist/use-chart-legend.js +81 -0
- package/dist/use-chart-legend.js.map +1 -0
- package/dist/use-chart-legend.mjs +9 -0
- package/dist/use-chart-legend.mjs.map +1 -0
- package/dist/use-chart-reference-line.d.mts +22 -0
- package/dist/use-chart-reference-line.d.ts +22 -0
- package/dist/use-chart-reference-line.js +105 -0
- package/dist/use-chart-reference-line.js.map +1 -0
- package/dist/use-chart-reference-line.mjs +10 -0
- package/dist/use-chart-reference-line.mjs.map +1 -0
- package/dist/use-chart-tooltip.d.mts +27 -0
- package/dist/use-chart-tooltip.d.ts +27 -0
- package/dist/use-chart-tooltip.js +100 -0
- package/dist/use-chart-tooltip.js.map +1 -0
- package/dist/use-chart-tooltip.mjs +10 -0
- package/dist/use-chart-tooltip.mjs.map +1 -0
- package/dist/use-chart.d.mts +33 -0
- package/dist/use-chart.d.ts +33 -0
- package/dist/use-chart.js +104 -0
- package/dist/use-chart.js.map +1 -0
- package/dist/use-chart.mjs +18 -0
- package/dist/use-chart.mjs.map +1 -0
- package/dist/use-line-chart.d.mts +97 -0
- package/dist/use-line-chart.d.ts +97 -0
- package/dist/use-line-chart.js +344 -0
- package/dist/use-line-chart.js.map +1 -0
- package/dist/use-line-chart.mjs +10 -0
- package/dist/use-line-chart.mjs.map +1 -0
- package/dist/use-pie-chart.d.mts +112 -0
- package/dist/use-pie-chart.d.ts +112 -0
- package/dist/use-pie-chart.js +282 -0
- package/dist/use-pie-chart.js.map +1 -0
- package/dist/use-pie-chart.mjs +10 -0
- package/dist/use-pie-chart.mjs.map +1 -0
- package/dist/use-radar-chart.d.mts +105 -0
- package/dist/use-radar-chart.d.ts +105 -0
- package/dist/use-radar-chart.js +473 -0
- package/dist/use-radar-chart.js.map +1 -0
- package/dist/use-radar-chart.mjs +10 -0
- package/dist/use-radar-chart.mjs.map +1 -0
- package/package.json +2 -5
@@ -0,0 +1,282 @@
|
|
1
|
+
"use client"
|
2
|
+
"use strict";
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __export = (target, all) => {
|
8
|
+
for (var name in all)
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
10
|
+
};
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
+
for (let key of __getOwnPropNames(from))
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
|
+
}
|
17
|
+
return to;
|
18
|
+
};
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
20
|
+
|
21
|
+
// src/use-pie-chart.ts
|
22
|
+
var use_pie_chart_exports = {};
|
23
|
+
__export(use_pie_chart_exports, {
|
24
|
+
usePieChart: () => usePieChart
|
25
|
+
});
|
26
|
+
module.exports = __toCommonJS(use_pie_chart_exports);
|
27
|
+
var import_core2 = require("@yamada-ui/core");
|
28
|
+
var import_utils2 = require("@yamada-ui/utils");
|
29
|
+
var import_react = require("react");
|
30
|
+
|
31
|
+
// src/chart-utils.ts
|
32
|
+
var import_core = require("@yamada-ui/core");
|
33
|
+
var import_utils = require("@yamada-ui/utils");
|
34
|
+
var getClassName = (...styles) => (theme) => (0, import_utils.cx)(
|
35
|
+
...styles.map(
|
36
|
+
(style) => (0, import_utils.isString)(style) ? style : (0, import_core.getCSS)(style)(theme)
|
37
|
+
)
|
38
|
+
);
|
39
|
+
var getComponentProps = ([obj, keys], ...props) => (theme, isContain) => {
|
40
|
+
const [pickedProps, omittedProps] = (0, import_utils.splitObject)(obj, keys);
|
41
|
+
const className = getClassName(...props, omittedProps)(theme);
|
42
|
+
return !isContain ? [pickedProps, className] : { ...pickedProps, className };
|
43
|
+
};
|
44
|
+
|
45
|
+
// src/rechart-properties.ts
|
46
|
+
var pieChartProperties = ["width", "height", "margin", "onClick", "onMouseEnter", "onMouseLeave"];
|
47
|
+
var pieProperties = [
|
48
|
+
"cx",
|
49
|
+
"cy",
|
50
|
+
"innerRadius",
|
51
|
+
"outerRadius",
|
52
|
+
"startAngle",
|
53
|
+
"endAngle",
|
54
|
+
"minAngle",
|
55
|
+
"paddingAngle",
|
56
|
+
"nameKey",
|
57
|
+
"dataKey",
|
58
|
+
"legendType",
|
59
|
+
"label",
|
60
|
+
"labelLine",
|
61
|
+
"data",
|
62
|
+
"activeIndex",
|
63
|
+
"activeShape",
|
64
|
+
"inactiveShape",
|
65
|
+
"isAnimationActive",
|
66
|
+
"animationBegin",
|
67
|
+
"animationDuration",
|
68
|
+
"animationEasing",
|
69
|
+
"onAnimationStart",
|
70
|
+
"onAnimationEnd",
|
71
|
+
"onClick",
|
72
|
+
"onMouseDown",
|
73
|
+
"onMouseUp",
|
74
|
+
"onMouseMove",
|
75
|
+
"onMouseOver",
|
76
|
+
"onMouseOut",
|
77
|
+
"onMouseEnter",
|
78
|
+
"onMouseLeave"
|
79
|
+
];
|
80
|
+
|
81
|
+
// src/use-pie-chart.ts
|
82
|
+
var usePieChart = ({
|
83
|
+
data,
|
84
|
+
withLabels = false,
|
85
|
+
withLabelLines = false,
|
86
|
+
strokeWidth = 1,
|
87
|
+
fillOpacity = 1,
|
88
|
+
innerRadius = "0%",
|
89
|
+
outerRadius = withLabels ? "80%" : "100%",
|
90
|
+
paddingAngle = 0,
|
91
|
+
startAngle = 90,
|
92
|
+
endAngle = -270,
|
93
|
+
styles,
|
94
|
+
...rest
|
95
|
+
}) => {
|
96
|
+
var _a, _b;
|
97
|
+
const { theme } = (0, import_core2.useTheme)();
|
98
|
+
const [highlightedArea, setHighlightedArea] = (0, import_react.useState)(null);
|
99
|
+
const shouldHighlight = highlightedArea !== null;
|
100
|
+
const { dimCell, ...computedCellProps } = (_a = rest.cellProps) != null ? _a : {};
|
101
|
+
const {
|
102
|
+
activeShape = {},
|
103
|
+
inactiveShape = {},
|
104
|
+
label,
|
105
|
+
labelLine,
|
106
|
+
...computedPieProps
|
107
|
+
} = (_b = rest.pieProps) != null ? _b : {};
|
108
|
+
const cellColors = (0, import_react.useMemo)(
|
109
|
+
() => data.map(({ color }, index) => ({
|
110
|
+
__prefix: "ui",
|
111
|
+
name: `cell-${index}`,
|
112
|
+
token: "colors",
|
113
|
+
value: color != null ? color : "transparent"
|
114
|
+
})),
|
115
|
+
[data]
|
116
|
+
);
|
117
|
+
const pieVars = (0, import_react.useMemo)(
|
118
|
+
() => [
|
119
|
+
...cellColors,
|
120
|
+
{ __prefix: "ui", name: "fill-opacity", value: fillOpacity }
|
121
|
+
],
|
122
|
+
[fillOpacity, cellColors]
|
123
|
+
);
|
124
|
+
const [chartProps, chartClassName] = (0, import_react.useMemo)(
|
125
|
+
() => {
|
126
|
+
var _a2;
|
127
|
+
return getComponentProps(
|
128
|
+
[(_a2 = rest.chartProps) != null ? _a2 : {}, pieChartProperties],
|
129
|
+
styles.chart
|
130
|
+
)(theme);
|
131
|
+
},
|
132
|
+
[rest.chartProps, styles.chart, theme]
|
133
|
+
);
|
134
|
+
const [pieProps, pieClassName] = (0, import_react.useMemo)(
|
135
|
+
() => getComponentProps(
|
136
|
+
[computedPieProps, pieProperties],
|
137
|
+
styles.pie
|
138
|
+
)(theme),
|
139
|
+
[computedPieProps, styles.pie, theme]
|
140
|
+
);
|
141
|
+
const cellClassName = (0, import_react.useMemo)(() => {
|
142
|
+
const resolvedCellProps = {
|
143
|
+
fillOpacity: "var(--ui-fill-opacity)",
|
144
|
+
...styles.cell,
|
145
|
+
...computedCellProps
|
146
|
+
};
|
147
|
+
return getClassName(resolvedCellProps)(theme);
|
148
|
+
}, [computedCellProps, styles.cell, theme]);
|
149
|
+
const dimCellClassName = (0, import_react.useMemo)(() => {
|
150
|
+
const resolvedDimCell = { fillOpacity: 0.3, strokeOpacity: 0, ...dimCell };
|
151
|
+
return getClassName(resolvedDimCell)(theme);
|
152
|
+
}, [dimCell, theme]);
|
153
|
+
const activeShapeProps = (0, import_react.useMemo)(
|
154
|
+
() => getComponentProps(
|
155
|
+
[{ _focus: { outline: "none" }, ...activeShape }, pieProperties],
|
156
|
+
styles.activeShape
|
157
|
+
)(theme, true),
|
158
|
+
[activeShape, styles.activeShape, theme]
|
159
|
+
);
|
160
|
+
const inactiveShapeProps = (0, import_react.useMemo)(
|
161
|
+
() => getComponentProps(
|
162
|
+
[inactiveShape, pieProperties],
|
163
|
+
styles.inactiveShape
|
164
|
+
)(theme, true),
|
165
|
+
[inactiveShape, styles.inactiveShape, theme]
|
166
|
+
);
|
167
|
+
const labelClassName = (0, import_react.useMemo)(
|
168
|
+
() => getClassName({ fillOpacity: 1, ...styles.label, ...label })(theme),
|
169
|
+
[label, styles.label, theme]
|
170
|
+
);
|
171
|
+
const labelLineClassName = (0, import_react.useMemo)(
|
172
|
+
() => getClassName({ ...styles.labelLine, ...labelLine })(theme),
|
173
|
+
[labelLine, styles.labelLine, theme]
|
174
|
+
);
|
175
|
+
const cellPropList = (0, import_react.useMemo)(
|
176
|
+
() => data.map((props, index) => {
|
177
|
+
const { name, dimCell: dimCell2 = {}, ...computedProps } = props;
|
178
|
+
const color = `var(--ui-cell-${index})`;
|
179
|
+
const dimmed = shouldHighlight && highlightedArea !== name;
|
180
|
+
const resolvedProps = {
|
181
|
+
...computedProps,
|
182
|
+
...dimmed ? dimCell2 : {}
|
183
|
+
};
|
184
|
+
const className = getClassName(
|
185
|
+
{
|
186
|
+
cellClassName,
|
187
|
+
...resolvedProps
|
188
|
+
},
|
189
|
+
dimmed ? dimCellClassName : void 0
|
190
|
+
)(theme);
|
191
|
+
return {
|
192
|
+
color,
|
193
|
+
className
|
194
|
+
};
|
195
|
+
}),
|
196
|
+
[
|
197
|
+
cellClassName,
|
198
|
+
data,
|
199
|
+
dimCellClassName,
|
200
|
+
highlightedArea,
|
201
|
+
shouldHighlight,
|
202
|
+
theme
|
203
|
+
]
|
204
|
+
);
|
205
|
+
const getPieChartProps = (0, import_react.useCallback)(
|
206
|
+
({ className, ...props } = {}, ref = null) => ({
|
207
|
+
ref,
|
208
|
+
className: (0, import_utils2.cx)(className, chartClassName),
|
209
|
+
...props,
|
210
|
+
...chartProps
|
211
|
+
}),
|
212
|
+
[chartProps, chartClassName]
|
213
|
+
);
|
214
|
+
const getPieProps = (0, import_react.useCallback)(
|
215
|
+
({
|
216
|
+
className,
|
217
|
+
labelClassName: labelClassNameProp,
|
218
|
+
labelLineClassName: labelLineClassNameProp,
|
219
|
+
...props
|
220
|
+
}, ref = null) => ({
|
221
|
+
ref,
|
222
|
+
className: (0, import_utils2.cx)(className, pieClassName),
|
223
|
+
dataKey: "value",
|
224
|
+
data,
|
225
|
+
rootTabIndex: -1,
|
226
|
+
outerRadius,
|
227
|
+
innerRadius,
|
228
|
+
paddingAngle,
|
229
|
+
startAngle,
|
230
|
+
endAngle,
|
231
|
+
isAnimationActive: false,
|
232
|
+
label: withLabels ? { className: (0, import_utils2.cx)(labelClassNameProp, labelClassName) } : false,
|
233
|
+
labelLine: withLabelLines ? { className: (0, import_utils2.cx)(labelLineClassNameProp, labelLineClassName) } : false,
|
234
|
+
activeShape: activeShapeProps,
|
235
|
+
inactiveShape: inactiveShapeProps,
|
236
|
+
...props,
|
237
|
+
...pieProps
|
238
|
+
}),
|
239
|
+
[
|
240
|
+
pieClassName,
|
241
|
+
data,
|
242
|
+
outerRadius,
|
243
|
+
innerRadius,
|
244
|
+
paddingAngle,
|
245
|
+
startAngle,
|
246
|
+
endAngle,
|
247
|
+
withLabels,
|
248
|
+
labelClassName,
|
249
|
+
withLabelLines,
|
250
|
+
labelLineClassName,
|
251
|
+
activeShapeProps,
|
252
|
+
inactiveShapeProps,
|
253
|
+
pieProps
|
254
|
+
]
|
255
|
+
);
|
256
|
+
const getCellProps = (0, import_react.useCallback)(
|
257
|
+
({ index, className: classNameProp, ...props }, ref = null) => {
|
258
|
+
const { className, color } = cellPropList[index];
|
259
|
+
return {
|
260
|
+
ref,
|
261
|
+
className: (0, import_utils2.cx)(classNameProp, className),
|
262
|
+
fill: color,
|
263
|
+
stroke: color,
|
264
|
+
strokeWidth,
|
265
|
+
...props
|
266
|
+
};
|
267
|
+
},
|
268
|
+
[cellPropList, strokeWidth]
|
269
|
+
);
|
270
|
+
return {
|
271
|
+
pieVars,
|
272
|
+
getPieProps,
|
273
|
+
getPieChartProps,
|
274
|
+
getCellProps,
|
275
|
+
setHighlightedArea
|
276
|
+
};
|
277
|
+
};
|
278
|
+
// Annotate the CommonJS export names for ESM import in node:
|
279
|
+
0 && (module.exports = {
|
280
|
+
usePieChart
|
281
|
+
});
|
282
|
+
//# sourceMappingURL=use-pie-chart.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/use-pie-chart.ts","../src/chart-utils.ts","../src/rechart-properties.ts"],"sourcesContent":["import { useTheme, type CSSUIObject, type CSSUIProps } from \"@yamada-ui/core\"\nimport { cx, type Dict } from \"@yamada-ui/utils\"\nimport type { ComponentPropsWithoutRef } from \"react\"\nimport { useCallback, useMemo, useState } from \"react\"\nimport type * as Recharts from \"recharts\"\nimport { getClassName, getComponentProps } from \"./chart-utils\"\nimport type {\n CellProps,\n ChartPropGetter,\n PieChartProps,\n PieProps,\n RequiredChartPropGetter,\n} from \"./chart.types\"\nimport { pieChartProperties, pieProperties } from \"./rechart-properties\"\n\nexport type UsePieChartOptions = {\n /**\n * Chart data.\n */\n data: CellProps[]\n /**\n * Props passed down to recharts `PieChart` component.\n */\n chartProps?: PieChartProps\n /**\n * Props for the pie.\n */\n pieProps?: Partial<PieProps>\n /**\n * Props for the cell.\n */\n cellProps?: Partial<CellProps>\n /**\n * Determines whether each segment should have associated label.\n *\n * @default false\n */\n withLabels?: boolean\n /**\n * Determines whether segments labels should have lines that connect the segment with the label.\n *\n * @default false\n */\n withLabelLines?: boolean\n /**\n * Controls innerRadius of the chart segments.\n * If it is a number, it is the width of the radius.\n * For example, `60` means the radius is `60px` and the diameter is `120px`.\n *\n * @default '0%'\n */\n innerRadius?: number | string\n /**\n * Controls thickness of the chart segments. If it is a number, it is calculated as px.\n * If it is a number, it is the width of the radius.\n * For example, `60` means the radius is `60px` and the diameter is `120px`.\n *\n * @default '80%'\n */\n outerRadius?: number | string\n /**\n * Controls padding between segments.\n *\n * @default 0\n */\n paddingAngle?: number\n /**\n * Stroke width for the chart pies.\n *\n * @default 1\n */\n strokeWidth?: number\n /**\n * Controls angle at which chart starts.\n *\n * @default 90\n */\n startAngle?: number\n /**\n * Controls angle at which chart ends.\n *\n * @default -270\n */\n endAngle?: number\n /**\n * Controls fill opacity of all pies.\n *\n * @default 1\n */\n fillOpacity?: number | [number, number]\n /**\n * A function to format values inside the tooltip.\n */\n valueFormatter?: (value: number) => string\n}\n\ntype UsePieChartProps = UsePieChartOptions & {\n styles: Dict<CSSUIObject>\n}\n\nexport const usePieChart = ({\n data,\n withLabels = false,\n withLabelLines = false,\n strokeWidth = 1,\n fillOpacity = 1,\n innerRadius = \"0%\",\n outerRadius = withLabels ? \"80%\" : \"100%\",\n paddingAngle = 0,\n startAngle = 90,\n endAngle = -270,\n styles,\n ...rest\n}: UsePieChartProps) => {\n const { theme } = useTheme()\n const [highlightedArea, setHighlightedArea] = useState<string | null>(null)\n const shouldHighlight = highlightedArea !== null\n const { dimCell, ...computedCellProps } = rest.cellProps ?? {}\n const {\n activeShape = {},\n inactiveShape = {},\n label,\n labelLine,\n ...computedPieProps\n } = rest.pieProps ?? {}\n\n const cellColors: CSSUIProps[\"var\"] = useMemo(\n () =>\n data.map(({ color }, index) => ({\n __prefix: \"ui\",\n name: `cell-${index}`,\n token: \"colors\",\n value: color ?? \"transparent\",\n })),\n [data],\n )\n\n const pieVars: CSSUIProps[\"var\"] = useMemo(\n () =>\n [\n ...cellColors,\n { __prefix: \"ui\", name: \"fill-opacity\", value: fillOpacity },\n ] as Required<CSSUIProps>[\"var\"],\n [fillOpacity, cellColors],\n )\n\n const [chartProps, chartClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [rest.chartProps ?? {}, pieChartProperties],\n styles.chart,\n )(theme),\n [rest.chartProps, styles.chart, theme],\n )\n\n const [pieProps, pieClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [computedPieProps, pieProperties],\n styles.pie,\n )(theme),\n [computedPieProps, styles.pie, theme],\n )\n\n const cellClassName = useMemo(() => {\n const resolvedCellProps = {\n fillOpacity: \"var(--ui-fill-opacity)\",\n ...styles.cell,\n ...computedCellProps,\n }\n\n return getClassName(resolvedCellProps)(theme)\n }, [computedCellProps, styles.cell, theme])\n\n const dimCellClassName = useMemo(() => {\n const resolvedDimCell = { fillOpacity: 0.3, strokeOpacity: 0, ...dimCell }\n\n return getClassName(resolvedDimCell)(theme)\n }, [dimCell, theme])\n\n const activeShapeProps = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [{ _focus: { outline: \"none\" }, ...activeShape }, pieProperties],\n styles.activeShape,\n )(theme, true),\n [activeShape, styles.activeShape, theme],\n )\n\n const inactiveShapeProps = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [inactiveShape, pieProperties],\n styles.inactiveShape,\n )(theme, true),\n [inactiveShape, styles.inactiveShape, theme],\n )\n\n const labelClassName = useMemo(\n () => getClassName({ fillOpacity: 1, ...styles.label, ...label })(theme),\n [label, styles.label, theme],\n )\n\n const labelLineClassName = useMemo(\n () => getClassName({ ...styles.labelLine, ...labelLine })(theme),\n [labelLine, styles.labelLine, theme],\n )\n\n const cellPropList = useMemo(\n () =>\n data.map((props, index) => {\n const { name, dimCell = {}, ...computedProps } = props\n const color = `var(--ui-cell-${index})`\n const dimmed = shouldHighlight && highlightedArea !== name\n const resolvedProps = {\n ...computedProps,\n ...(dimmed ? dimCell : {}),\n }\n\n const className = getClassName(\n {\n cellClassName,\n ...resolvedProps,\n },\n dimmed ? dimCellClassName : undefined,\n )(theme)\n\n return {\n color,\n className,\n }\n }),\n [\n cellClassName,\n data,\n dimCellClassName,\n highlightedArea,\n shouldHighlight,\n theme,\n ],\n )\n\n const getPieChartProps: ChartPropGetter<\n \"div\",\n ComponentPropsWithoutRef<typeof Recharts.PieChart>,\n ComponentPropsWithoutRef<typeof Recharts.PieChart>\n > = useCallback(\n ({ className, ...props } = {}, ref = null) => ({\n ref,\n className: cx(className, chartClassName),\n ...props,\n ...chartProps,\n }),\n [chartProps, chartClassName],\n )\n\n const getPieProps: RequiredChartPropGetter<\n \"div\",\n Partial<Recharts.PieProps> & {\n labelClassName: string\n labelLineClassName: string\n },\n Omit<Recharts.PieProps, \"ref\">\n > = useCallback(\n (\n {\n className,\n labelClassName: labelClassNameProp,\n labelLineClassName: labelLineClassNameProp,\n ...props\n },\n ref = null,\n ) => ({\n ref,\n className: cx(className, pieClassName),\n dataKey: \"value\",\n data,\n rootTabIndex: -1,\n outerRadius,\n innerRadius,\n paddingAngle,\n startAngle,\n endAngle,\n isAnimationActive: false,\n label: withLabels\n ? { className: cx(labelClassNameProp, labelClassName) }\n : false,\n labelLine: withLabelLines\n ? { className: cx(labelLineClassNameProp, labelLineClassName) }\n : false,\n activeShape: activeShapeProps,\n inactiveShape: inactiveShapeProps,\n ...(props as Omit<Recharts.PieProps, \"dataKey\">),\n ...pieProps,\n }),\n [\n pieClassName,\n data,\n outerRadius,\n innerRadius,\n paddingAngle,\n startAngle,\n endAngle,\n withLabels,\n labelClassName,\n withLabelLines,\n labelLineClassName,\n activeShapeProps,\n inactiveShapeProps,\n pieProps,\n ],\n )\n\n const getCellProps: RequiredChartPropGetter<\n \"div\",\n Omit<Recharts.CellProps, \"ref\"> & { index: number },\n Omit<Recharts.CellProps, \"ref\">\n > = useCallback(\n ({ index, className: classNameProp, ...props }, ref = null) => {\n const { className, color } = cellPropList[index]\n\n return {\n ref,\n className: cx(classNameProp, className),\n fill: color,\n stroke: color,\n strokeWidth,\n ...(props as Recharts.CellProps),\n }\n },\n [cellPropList, strokeWidth],\n )\n\n return {\n pieVars,\n getPieProps,\n getPieChartProps,\n getCellProps,\n setHighlightedArea,\n }\n}\n\nexport type UsePieChartReturn = ReturnType<typeof usePieChart>\n","import type { StyledTheme } from \"@yamada-ui/core\"\nimport { getCSS } from \"@yamada-ui/core\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport { cx, isString, splitObject } from \"@yamada-ui/utils\"\n\nexport const getClassName =\n (...styles: (Dict | string | undefined)[]) =>\n (theme: StyledTheme) =>\n cx(\n ...styles.map((style) =>\n isString(style) ? style : getCSS(style)(theme),\n ),\n )\n\nexport const getComponentProps =\n <T extends Dict, K extends keyof T>(\n [obj, keys]: [T, K[]],\n ...props: (Dict | string | undefined)[]\n ) =>\n <P extends boolean = false>(theme: StyledTheme, isContain?: P) => {\n const [pickedProps, omittedProps] = splitObject<T, K>(obj, keys)\n const className = getClassName(...props, omittedProps)(theme)\n\n return (\n !isContain ? [pickedProps, className] : { ...pickedProps, className }\n ) as P extends false\n ? [{ [P in K]: T[P] }, string]\n : { [P in K]: T[P] } & { className: string }\n }\n","import type { ComponentPropsWithoutRef } from \"react\"\nimport type * as Recharts from \"recharts\"\n\nexport const areaChartProperties: (keyof ComponentPropsWithoutRef<\n typeof Recharts.AreaChart\n>)[] = [\n \"layout\",\n \"syncId\",\n \"syncMethod\",\n \"width\",\n \"height\",\n \"data\",\n \"margin\",\n \"stackOffset\",\n \"onClick\",\n \"onMouseEnter\",\n \"onMouseMove\",\n \"onMouseLeave\",\n]\n\nexport const barChartProperties: (keyof ComponentPropsWithoutRef<\n typeof Recharts.BarChart\n>)[] = [\n \"layout\",\n \"syncId\",\n \"syncMethod\",\n \"width\",\n \"height\",\n \"data\",\n \"margin\",\n \"barCategoryGap\",\n \"barGap\",\n \"barSize\",\n \"maxBarSize\",\n \"stackOffset\",\n \"reverseStackOrder\",\n \"onClick\",\n \"onMouseEnter\",\n \"onMouseMove\",\n \"onMouseLeave\",\n]\n\nexport const lineChartProperties: (keyof ComponentPropsWithoutRef<\n typeof Recharts.LineChart\n>)[] = [\n \"layout\",\n \"syncId\",\n \"syncMethod\",\n \"width\",\n \"height\",\n \"data\",\n \"margin\",\n \"onClick\",\n \"onMouseEnter\",\n \"onMouseMove\",\n \"onMouseLeave\",\n]\n\nexport const radarChartProperties: (keyof ComponentPropsWithoutRef<\n typeof Recharts.RadarChart\n>)[] = [\n \"width\",\n \"height\",\n \"data\",\n \"cx\",\n \"cy\",\n \"startAngle\",\n \"endAngle\",\n \"innerRadius\",\n \"outerRadius\",\n \"margin\",\n \"onMouseEnter\",\n \"onClick\",\n]\n\nexport const pieChartProperties: (keyof ComponentPropsWithoutRef<\n typeof Recharts.PieChart\n>)[] = [\"width\", \"height\", \"margin\", \"onClick\", \"onMouseEnter\", \"onMouseLeave\"]\n\nexport const referenceLineProperties: (keyof Recharts.ReferenceLineProps)[] = [\n \"xAxisId\",\n \"yAxisId\",\n \"x\",\n \"y\",\n \"ifOverflow\",\n \"viewBox\",\n \"xAxis\",\n \"yAxis\",\n \"label\",\n \"isFront\",\n \"strokeWidth\",\n \"segment\",\n]\n\nexport const containerProperties: (keyof Omit<\n Recharts.ResponsiveContainerProps,\n \"children\"\n>)[] = [\n \"aspect\",\n \"width\",\n \"height\",\n \"minWidth\",\n \"minHeight\",\n \"debounce\",\n \"onResize\",\n]\n\nexport const gridProperties: (keyof Recharts.CartesianGridProps)[] = [\n \"x\",\n \"y\",\n \"width\",\n \"height\",\n \"horizontal\",\n \"vertical\",\n \"horizontalPoints\",\n \"horizontalCoordinatesGenerator\",\n \"verticalPoints\",\n \"verticalCoordinatesGenerator\",\n \"fill\",\n \"fillOpacity\",\n \"strokeDasharray\",\n]\n\nexport const xAxisProperties: (keyof Recharts.XAxisProps)[] = [\n \"hide\",\n \"dataKey\",\n \"xAxisId\",\n \"width\",\n \"height\",\n \"orientation\",\n \"type\",\n \"allowDecimals\",\n \"allowDataOverflow\",\n \"allowDuplicatedCategory\",\n \"angle\",\n \"tickCount\",\n \"domain\",\n \"includeHidden\",\n \"interval\",\n \"padding\",\n \"minTickGap\",\n \"axisLine\",\n \"tickLine\",\n \"tickSize\",\n \"tickFormatter\",\n \"ticks\",\n \"tick\",\n \"mirror\",\n \"reversed\",\n \"label\",\n \"scale\",\n \"unit\",\n \"name\",\n \"onClick\",\n \"onMouseDown\",\n \"onMouseUp\",\n \"onMouseMove\",\n \"onMouseOver\",\n \"onMouseOut\",\n \"onMouseEnter\",\n \"onMouseLeave\",\n \"tickMargin\",\n]\n\nexport const yAxisProperties: (keyof Recharts.YAxisProps)[] = [\n \"hide\",\n \"dataKey\",\n \"yAxisId\",\n \"width\",\n \"height\",\n \"orientation\",\n \"type\",\n \"tickCount\",\n \"domain\",\n \"includeHidden\",\n \"interval\",\n \"padding\",\n \"minTickGap\",\n \"allowDecimals\",\n \"allowDataOverflow\",\n \"allowDuplicatedCategory\",\n \"axisLine\",\n \"tickLine\",\n \"tickSize\",\n \"tickFormatter\",\n \"ticks\",\n \"tick\",\n \"mirror\",\n \"reversed\",\n \"label\",\n \"scale\",\n \"unit\",\n \"name\",\n \"onClick\",\n \"onMouseDown\",\n \"onMouseUp\",\n \"onMouseMove\",\n \"onMouseOver\",\n \"onMouseOut\",\n \"onMouseEnter\",\n \"onMouseLeave\",\n \"tickMargin\",\n]\n\nexport const legendProperties: (keyof Omit<Recharts.LegendProps, \"ref\">)[] = [\n \"width\",\n \"height\",\n \"layout\",\n \"align\",\n \"verticalAlign\",\n \"iconSize\",\n \"iconType\",\n \"payload\",\n \"chartWidth\",\n \"chartHeight\",\n \"margin\",\n \"content\",\n \"formatter\",\n \"wrapperStyle\",\n \"onClick\",\n \"onMouseDown\",\n \"onMouseUp\",\n \"onMouseMove\",\n \"onMouseOver\",\n \"onMouseOut\",\n \"onMouseEnter\",\n \"onMouseLeave\",\n]\n\nexport const tooltipProperties: (keyof Recharts.TooltipProps<any, any>)[] = [\n \"offset\",\n \"filterNull\",\n \"itemStyle\",\n \"wrapperStyle\",\n \"contentStyle\",\n \"labelStyle\",\n \"cursor\",\n \"viewBox\",\n \"allowEscapeViewBox\",\n \"active\",\n \"position\",\n \"coordinate\",\n \"payload\",\n \"label\",\n \"content\",\n \"formatter\",\n \"labelFormatter\",\n \"itemSorter\",\n \"isAnimationActive\",\n \"animationDuration\",\n \"animationEasing\",\n]\n\nexport const areaProperties: (keyof Omit<Recharts.AreaProps, \"ref\">)[] = [\n \"type\",\n \"dataKey\",\n \"xAxisId\",\n \"yAxisId\",\n \"legendType\",\n \"dot\",\n \"activeDot\",\n \"label\",\n \"stroke\",\n \"strokeWidth\",\n \"layout\",\n \"baseLine\",\n \"points\",\n \"stackId\",\n \"connectNulls\",\n \"unit\",\n \"name\",\n \"isAnimationActive\",\n \"animationBegin\",\n \"animationDuration\",\n \"animationEasing\",\n \"id\",\n \"onAnimationStart\",\n \"onAnimationEnd\",\n \"onClick\",\n \"onMouseDown\",\n \"onMouseUp\",\n \"onMouseMove\",\n \"onMouseOver\",\n \"onMouseOut\",\n \"onMouseEnter\",\n \"onMouseLeave\",\n]\n\nexport const barProperties: (keyof Omit<Recharts.BarProps, \"ref\">)[] = [\n \"layout\",\n \"dataKey\",\n \"xAxisId\",\n \"yAxisId\",\n \"legendType\",\n \"label\",\n \"data\",\n \"barSize\",\n \"maxBarSize\",\n \"minPointSize\",\n \"background\",\n \"shape\",\n \"activeBar\",\n \"stackId\",\n \"unit\",\n \"name\",\n \"isAnimationActive\",\n \"animationBegin\",\n \"animationDuration\",\n \"animationEasing\",\n \"id\",\n \"onAnimationStart\",\n \"onAnimationEnd\",\n \"onClick\",\n \"onMouseDown\",\n \"onMouseUp\",\n \"onMouseMove\",\n \"onMouseOver\",\n \"onMouseOut\",\n \"onMouseEnter\",\n \"onMouseLeave\",\n \"radius\",\n]\n\nexport const radarProperties: (keyof Omit<Recharts.RadarProps, \"ref\">)[] = [\n \"dataKey\",\n \"points\",\n \"shape\",\n \"dot\",\n \"activeDot\",\n \"legendType\",\n \"label\",\n \"isAnimationActive\",\n \"animationBegin\",\n \"animationDuration\",\n \"animationEasing\",\n \"onAnimationStart\",\n \"onAnimationEnd\",\n]\n\nexport const lineProperties: (keyof Omit<Recharts.LineProps, \"ref\">)[] = [\n \"type\",\n \"dataKey\",\n \"xAxisId\",\n \"yAxisId\",\n \"legendType\",\n \"dot\",\n \"activeDot\",\n \"label\",\n \"hide\",\n \"points\",\n \"stroke\",\n \"strokeWidth\",\n \"layout\",\n \"connectNulls\",\n \"unit\",\n \"name\",\n \"isAnimationActive\",\n \"animationBegin\",\n \"animationDuration\",\n \"animationEasing\",\n \"id\",\n \"onAnimationStart\",\n \"onAnimationEnd\",\n \"onClick\",\n \"onMouseDown\",\n \"onMouseUp\",\n \"onMouseMove\",\n \"onMouseOver\",\n \"onMouseOut\",\n \"onMouseEnter\",\n \"onMouseLeave\",\n \"strokeDasharray\",\n]\n\nexport const pieProperties: (keyof Omit<Recharts.PieProps, \"ref\">)[] = [\n \"cx\",\n \"cy\",\n \"innerRadius\",\n \"outerRadius\",\n \"startAngle\",\n \"endAngle\",\n \"minAngle\",\n \"paddingAngle\",\n \"nameKey\",\n \"dataKey\",\n \"legendType\",\n \"label\",\n \"labelLine\",\n \"data\",\n \"activeIndex\",\n \"activeShape\",\n \"inactiveShape\",\n \"isAnimationActive\",\n \"animationBegin\",\n \"animationDuration\",\n \"animationEasing\",\n \"onAnimationStart\",\n \"onAnimationEnd\",\n \"onClick\",\n \"onMouseDown\",\n \"onMouseUp\",\n \"onMouseMove\",\n \"onMouseOver\",\n \"onMouseOut\",\n \"onMouseEnter\",\n \"onMouseLeave\",\n]\n\nexport const dotProperties: (keyof Omit<Recharts.DotProps, \"ref\">)[] = [\n \"cx\",\n \"cy\",\n \"r\",\n \"onClick\",\n \"onMouseDown\",\n \"onMouseUp\",\n \"onMouseMove\",\n \"onMouseOver\",\n \"onMouseOut\",\n \"onMouseEnter\",\n \"onMouseLeave\",\n]\n\nexport const polarGridProperties: (keyof Recharts.PolarGridProps)[] = [\n \"cx\",\n \"cy\",\n \"innerRadius\",\n \"outerRadius\",\n \"polarAngles\",\n \"polarRadius\",\n \"gridType\",\n]\n\nexport const polarAngleAxisProperties: (keyof Recharts.PolarAngleAxisProps)[] =\n [\n \"dataKey\",\n \"cx\",\n \"cy\",\n \"radius\",\n \"axisLine\",\n \"axisLineType\",\n \"tickLine\",\n \"tickSize\",\n \"tick\",\n \"ticks\",\n \"orient\",\n \"tickFormatter\",\n \"type\",\n \"allowDuplicatedCategory\",\n \"onClick\",\n \"onMouseDown\",\n \"onMouseUp\",\n \"onMouseMove\",\n \"onMouseOver\",\n \"onMouseOut\",\n \"onMouseEnter\",\n \"onMouseLeave\",\n ]\nexport const polarRadiusAxisProperties: (keyof Recharts.PolarRadiusAxisProps)[] =\n [\n \"angle\",\n \"type\",\n \"allowDuplicatedCategory\",\n \"cx\",\n \"cy\",\n \"domain\",\n \"reversed\",\n \"label\",\n \"orientation\",\n \"axisLine\",\n \"tick\",\n \"tickSize\",\n \"tickFormatter\",\n \"tickCount\",\n \"scale\",\n \"onClick\",\n \"onMouseDown\",\n \"onMouseUp\",\n \"onMouseMove\",\n \"onMouseOver\",\n \"onMouseOut\",\n \"onMouseEnter\",\n \"onMouseLeave\",\n ]\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,eAA4D;AAC5D,IAAAC,gBAA8B;AAE9B,mBAA+C;;;ACF/C,kBAAuB;AAEvB,mBAA0C;AAEnC,IAAM,eACX,IAAI,WACJ,CAAC,cACC;AAAA,EACE,GAAG,OAAO;AAAA,IAAI,CAAC,cACb,uBAAS,KAAK,IAAI,YAAQ,oBAAO,KAAK,EAAE,KAAK;AAAA,EAC/C;AACF;AAEG,IAAM,oBACX,CACE,CAAC,KAAK,IAAI,MACP,UAEL,CAA4B,OAAoB,cAAkB;AAChE,QAAM,CAAC,aAAa,YAAY,QAAI,0BAAkB,KAAK,IAAI;AAC/D,QAAM,YAAY,aAAa,GAAG,OAAO,YAAY,EAAE,KAAK;AAE5D,SACE,CAAC,YAAY,CAAC,aAAa,SAAS,IAAI,EAAE,GAAG,aAAa,UAAU;AAIxE;;;AC+CK,IAAM,qBAEN,CAAC,SAAS,UAAU,UAAU,WAAW,gBAAgB,cAAc;AAySvE,IAAM,gBAA0D;AAAA,EACrE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;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AAY;AAAA,MACrC,SAAS;AAAA,MACT;AAAA,MACA,cAAc;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,mBAAmB;AAAA,MACnB,OAAO,aACH,EAAE,eAAW,kBAAG,oBAAoB,cAAc,EAAE,IACpD;AAAA,MACJ,WAAW,iBACP,EAAE,eAAW,kBAAG,wBAAwB,kBAAkB,EAAE,IAC5D;AAAA,MACJ,aAAa;AAAA,MACb,eAAe;AAAA,MACf,GAAI;AAAA,MACJ,GAAG;AAAA,IACL;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,mBAIF;AAAA,IACF,CAAC,EAAE,OAAO,WAAW,eAAe,GAAG,MAAM,GAAG,MAAM,SAAS;AAC7D,YAAM,EAAE,WAAW,MAAM,IAAI,aAAa,KAAK;AAE/C,aAAO;AAAA,QACL;AAAA,QACA,eAAW,kBAAG,eAAe,SAAS;AAAA,QACtC,MAAM;AAAA,QACN,QAAQ;AAAA,QACR;AAAA,QACA,GAAI;AAAA,MACN;AAAA,IACF;AAAA,IACA,CAAC,cAAc,WAAW;AAAA,EAC5B;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["import_core","import_utils","_a","dimCell"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
@@ -0,0 +1,105 @@
|
|
1
|
+
import * as react from 'react';
|
2
|
+
import * as recharts_types_chart_generateCategoricalChart from 'recharts/types/chart/generateCategoricalChart';
|
3
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
4
|
+
import { CSSUIProps, CSSUIObject } from '@yamada-ui/core';
|
5
|
+
import * as _yamada_ui_utils from '@yamada-ui/utils';
|
6
|
+
import { Dict } from '@yamada-ui/utils';
|
7
|
+
import * as Recharts from 'recharts';
|
8
|
+
import { RadarProps, RadarChartProps, PolarGridProps, PolarAngleAxisProps, PolarRadiusAxisProps, ChartPropGetter, RequiredChartPropGetter } from './chart.types.mjs';
|
9
|
+
|
10
|
+
type UseRadarChartOptions = {
|
11
|
+
/**
|
12
|
+
* Chart data.
|
13
|
+
*/
|
14
|
+
data: Dict[];
|
15
|
+
/**
|
16
|
+
* An array of objects with `dataKey` and `color` keys. Determines which data should be consumed from the `data` array.
|
17
|
+
*/
|
18
|
+
series: RadarProps[];
|
19
|
+
/**
|
20
|
+
* The key of a group of data which should be unique in an chart.
|
21
|
+
*/
|
22
|
+
dataKey: string;
|
23
|
+
/**
|
24
|
+
* Props for the radar.
|
25
|
+
*/
|
26
|
+
radarProps?: Partial<RadarProps>;
|
27
|
+
/**
|
28
|
+
* Props passed down to recharts `RadarChart` component.
|
29
|
+
*/
|
30
|
+
chartProps?: RadarChartProps;
|
31
|
+
/**
|
32
|
+
* Props passed down to recharts `PolarGrid` component.
|
33
|
+
*/
|
34
|
+
polarGridProps?: PolarGridProps;
|
35
|
+
/**
|
36
|
+
* Props passed down to recharts `PolarAngleAxis` component.
|
37
|
+
*/
|
38
|
+
polarAngleAxisProps?: PolarAngleAxisProps;
|
39
|
+
/**
|
40
|
+
* Props passed down to recharts `tick` of `PolarAngleAxis` component.
|
41
|
+
*/
|
42
|
+
polarAngleAxisTickProps?: CSSUIProps;
|
43
|
+
/**
|
44
|
+
* Props passed down to recharts `PolarRadiusAxis` component.
|
45
|
+
*/
|
46
|
+
polarRadiusAxisProps?: PolarRadiusAxisProps;
|
47
|
+
/**
|
48
|
+
* Props passed down to recharts `tick` of `PolarRadiusAxis` component.
|
49
|
+
*/
|
50
|
+
polarRadiusAxisTickProps?: CSSUIProps;
|
51
|
+
/**
|
52
|
+
* Determines whether dots should be displayed.
|
53
|
+
*
|
54
|
+
* @default false
|
55
|
+
*/
|
56
|
+
withDots?: boolean;
|
57
|
+
/**
|
58
|
+
* Determines whether activeDots should be displayed.
|
59
|
+
*
|
60
|
+
* @default true
|
61
|
+
*/
|
62
|
+
withActiveDots?: boolean;
|
63
|
+
/**
|
64
|
+
* Stroke width for the chart radars.
|
65
|
+
*
|
66
|
+
* @default 2
|
67
|
+
*/
|
68
|
+
strokeWidth?: number;
|
69
|
+
/**
|
70
|
+
* Controls fill opacity of all radars.
|
71
|
+
*
|
72
|
+
* @default 1
|
73
|
+
*/
|
74
|
+
fillOpacity?: number | [number, number];
|
75
|
+
/**
|
76
|
+
* A function to format values on Y axis and inside the tooltip.
|
77
|
+
*/
|
78
|
+
valueFormatter?: (value: number) => string;
|
79
|
+
/**
|
80
|
+
* Dash array for the grid lines and cursor. The first number is the length of the solid line section and the second number is the length of the interval.
|
81
|
+
*/
|
82
|
+
strokeDasharray?: string | number;
|
83
|
+
};
|
84
|
+
type UseRadarChartProps = UseRadarChartOptions & {
|
85
|
+
styles: Dict<CSSUIObject>;
|
86
|
+
};
|
87
|
+
declare const useRadarChart: ({ data, series, dataKey, withDots, withActiveDots, strokeWidth, fillOpacity, valueFormatter, strokeDasharray, styles, ...rest }: UseRadarChartProps) => {
|
88
|
+
radarVars: {
|
89
|
+
__prefix?: string | undefined;
|
90
|
+
name: string;
|
91
|
+
token?: "colors" | "transitionDuration" | "transitionProperty" | "animations" | "blurs" | "borders" | "breakpoints" | "fonts" | "fontSizes" | "fontWeights" | "gradients" | "layerStyles" | "letterSpacings" | "lineHeights" | "radii" | "shadows" | "sizes" | "spaces" | "textStyles" | "transitionEasing" | "zIndices" | undefined;
|
92
|
+
value?: (number | _yamada_ui_utils.StringLiteral | Partial<Record<(string & {}) | "base" | "sm" | "md" | "lg" | "xl" | "2xl", number | _yamada_ui_utils.StringLiteral>> | _yamada_ui_core.ColorModeArray<number | _yamada_ui_utils.StringLiteral>) | undefined;
|
93
|
+
}[];
|
94
|
+
getRadarChartProps: ChartPropGetter<"div", recharts_types_chart_generateCategoricalChart.CategoricalChartProps, recharts_types_chart_generateCategoricalChart.CategoricalChartProps>;
|
95
|
+
getRadarProps: RequiredChartPropGetter<"div", {
|
96
|
+
index: number;
|
97
|
+
}, Omit<Recharts.RadarProps, "ref">>;
|
98
|
+
getPolarGridProps: ChartPropGetter<"div", Recharts.PolarGridProps, Recharts.PolarGridProps>;
|
99
|
+
getPolarAngleAxisProps: ChartPropGetter<"div", Recharts.PolarAngleAxisProps, Omit<Recharts.PolarAngleAxisProps, "ref">>;
|
100
|
+
getPolarRadiusAxisProps: ChartPropGetter<"div", Recharts.PolarRadiusAxisProps, Omit<Recharts.PolarRadiusAxisProps, "ref">>;
|
101
|
+
setHighlightedArea: react.Dispatch<react.SetStateAction<string | null>>;
|
102
|
+
};
|
103
|
+
type UseRadarChartReturn = ReturnType<typeof useRadarChart>;
|
104
|
+
|
105
|
+
export { type UseRadarChartOptions, type UseRadarChartReturn, useRadarChart };
|
@@ -0,0 +1,105 @@
|
|
1
|
+
import * as react from 'react';
|
2
|
+
import * as recharts_types_chart_generateCategoricalChart from 'recharts/types/chart/generateCategoricalChart';
|
3
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
4
|
+
import { CSSUIProps, CSSUIObject } from '@yamada-ui/core';
|
5
|
+
import * as _yamada_ui_utils from '@yamada-ui/utils';
|
6
|
+
import { Dict } from '@yamada-ui/utils';
|
7
|
+
import * as Recharts from 'recharts';
|
8
|
+
import { RadarProps, RadarChartProps, PolarGridProps, PolarAngleAxisProps, PolarRadiusAxisProps, ChartPropGetter, RequiredChartPropGetter } from './chart.types.js';
|
9
|
+
|
10
|
+
type UseRadarChartOptions = {
|
11
|
+
/**
|
12
|
+
* Chart data.
|
13
|
+
*/
|
14
|
+
data: Dict[];
|
15
|
+
/**
|
16
|
+
* An array of objects with `dataKey` and `color` keys. Determines which data should be consumed from the `data` array.
|
17
|
+
*/
|
18
|
+
series: RadarProps[];
|
19
|
+
/**
|
20
|
+
* The key of a group of data which should be unique in an chart.
|
21
|
+
*/
|
22
|
+
dataKey: string;
|
23
|
+
/**
|
24
|
+
* Props for the radar.
|
25
|
+
*/
|
26
|
+
radarProps?: Partial<RadarProps>;
|
27
|
+
/**
|
28
|
+
* Props passed down to recharts `RadarChart` component.
|
29
|
+
*/
|
30
|
+
chartProps?: RadarChartProps;
|
31
|
+
/**
|
32
|
+
* Props passed down to recharts `PolarGrid` component.
|
33
|
+
*/
|
34
|
+
polarGridProps?: PolarGridProps;
|
35
|
+
/**
|
36
|
+
* Props passed down to recharts `PolarAngleAxis` component.
|
37
|
+
*/
|
38
|
+
polarAngleAxisProps?: PolarAngleAxisProps;
|
39
|
+
/**
|
40
|
+
* Props passed down to recharts `tick` of `PolarAngleAxis` component.
|
41
|
+
*/
|
42
|
+
polarAngleAxisTickProps?: CSSUIProps;
|
43
|
+
/**
|
44
|
+
* Props passed down to recharts `PolarRadiusAxis` component.
|
45
|
+
*/
|
46
|
+
polarRadiusAxisProps?: PolarRadiusAxisProps;
|
47
|
+
/**
|
48
|
+
* Props passed down to recharts `tick` of `PolarRadiusAxis` component.
|
49
|
+
*/
|
50
|
+
polarRadiusAxisTickProps?: CSSUIProps;
|
51
|
+
/**
|
52
|
+
* Determines whether dots should be displayed.
|
53
|
+
*
|
54
|
+
* @default false
|
55
|
+
*/
|
56
|
+
withDots?: boolean;
|
57
|
+
/**
|
58
|
+
* Determines whether activeDots should be displayed.
|
59
|
+
*
|
60
|
+
* @default true
|
61
|
+
*/
|
62
|
+
withActiveDots?: boolean;
|
63
|
+
/**
|
64
|
+
* Stroke width for the chart radars.
|
65
|
+
*
|
66
|
+
* @default 2
|
67
|
+
*/
|
68
|
+
strokeWidth?: number;
|
69
|
+
/**
|
70
|
+
* Controls fill opacity of all radars.
|
71
|
+
*
|
72
|
+
* @default 1
|
73
|
+
*/
|
74
|
+
fillOpacity?: number | [number, number];
|
75
|
+
/**
|
76
|
+
* A function to format values on Y axis and inside the tooltip.
|
77
|
+
*/
|
78
|
+
valueFormatter?: (value: number) => string;
|
79
|
+
/**
|
80
|
+
* Dash array for the grid lines and cursor. The first number is the length of the solid line section and the second number is the length of the interval.
|
81
|
+
*/
|
82
|
+
strokeDasharray?: string | number;
|
83
|
+
};
|
84
|
+
type UseRadarChartProps = UseRadarChartOptions & {
|
85
|
+
styles: Dict<CSSUIObject>;
|
86
|
+
};
|
87
|
+
declare const useRadarChart: ({ data, series, dataKey, withDots, withActiveDots, strokeWidth, fillOpacity, valueFormatter, strokeDasharray, styles, ...rest }: UseRadarChartProps) => {
|
88
|
+
radarVars: {
|
89
|
+
__prefix?: string | undefined;
|
90
|
+
name: string;
|
91
|
+
token?: "colors" | "transitionDuration" | "transitionProperty" | "animations" | "blurs" | "borders" | "breakpoints" | "fonts" | "fontSizes" | "fontWeights" | "gradients" | "layerStyles" | "letterSpacings" | "lineHeights" | "radii" | "shadows" | "sizes" | "spaces" | "textStyles" | "transitionEasing" | "zIndices" | undefined;
|
92
|
+
value?: (number | _yamada_ui_utils.StringLiteral | Partial<Record<(string & {}) | "base" | "sm" | "md" | "lg" | "xl" | "2xl", number | _yamada_ui_utils.StringLiteral>> | _yamada_ui_core.ColorModeArray<number | _yamada_ui_utils.StringLiteral>) | undefined;
|
93
|
+
}[];
|
94
|
+
getRadarChartProps: ChartPropGetter<"div", recharts_types_chart_generateCategoricalChart.CategoricalChartProps, recharts_types_chart_generateCategoricalChart.CategoricalChartProps>;
|
95
|
+
getRadarProps: RequiredChartPropGetter<"div", {
|
96
|
+
index: number;
|
97
|
+
}, Omit<Recharts.RadarProps, "ref">>;
|
98
|
+
getPolarGridProps: ChartPropGetter<"div", Recharts.PolarGridProps, Recharts.PolarGridProps>;
|
99
|
+
getPolarAngleAxisProps: ChartPropGetter<"div", Recharts.PolarAngleAxisProps, Omit<Recharts.PolarAngleAxisProps, "ref">>;
|
100
|
+
getPolarRadiusAxisProps: ChartPropGetter<"div", Recharts.PolarRadiusAxisProps, Omit<Recharts.PolarRadiusAxisProps, "ref">>;
|
101
|
+
setHighlightedArea: react.Dispatch<react.SetStateAction<string | null>>;
|
102
|
+
};
|
103
|
+
type UseRadarChartReturn = ReturnType<typeof useRadarChart>;
|
104
|
+
|
105
|
+
export { type UseRadarChartOptions, type UseRadarChartReturn, useRadarChart };
|