@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,1027 @@
|
|
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/bar-chart.tsx
|
22
|
+
var bar_chart_exports = {};
|
23
|
+
__export(bar_chart_exports, {
|
24
|
+
BarChart: () => BarChart
|
25
|
+
});
|
26
|
+
module.exports = __toCommonJS(bar_chart_exports);
|
27
|
+
var import_core10 = require("@yamada-ui/core");
|
28
|
+
var import_utils11 = require("@yamada-ui/utils");
|
29
|
+
var import_react8 = require("react");
|
30
|
+
var import_recharts = require("recharts");
|
31
|
+
|
32
|
+
// src/chart-legend.tsx
|
33
|
+
var import_core3 = require("@yamada-ui/core");
|
34
|
+
var import_utils3 = require("@yamada-ui/utils");
|
35
|
+
|
36
|
+
// src/use-chart.ts
|
37
|
+
var import_core2 = require("@yamada-ui/core");
|
38
|
+
var import_utils2 = require("@yamada-ui/utils");
|
39
|
+
var import_react = require("react");
|
40
|
+
|
41
|
+
// src/chart-utils.ts
|
42
|
+
var import_core = require("@yamada-ui/core");
|
43
|
+
var import_utils = require("@yamada-ui/utils");
|
44
|
+
var getClassName = (...styles) => (theme) => (0, import_utils.cx)(
|
45
|
+
...styles.map(
|
46
|
+
(style) => (0, import_utils.isString)(style) ? style : (0, import_core.getCSS)(style)(theme)
|
47
|
+
)
|
48
|
+
);
|
49
|
+
var getComponentProps = ([obj, keys], ...props) => (theme, isContain) => {
|
50
|
+
const [pickedProps, omittedProps] = (0, import_utils.splitObject)(obj, keys);
|
51
|
+
const className = getClassName(...props, omittedProps)(theme);
|
52
|
+
return !isContain ? [pickedProps, className] : { ...pickedProps, className };
|
53
|
+
};
|
54
|
+
|
55
|
+
// src/rechart-properties.ts
|
56
|
+
var barChartProperties = [
|
57
|
+
"layout",
|
58
|
+
"syncId",
|
59
|
+
"syncMethod",
|
60
|
+
"width",
|
61
|
+
"height",
|
62
|
+
"data",
|
63
|
+
"margin",
|
64
|
+
"barCategoryGap",
|
65
|
+
"barGap",
|
66
|
+
"barSize",
|
67
|
+
"maxBarSize",
|
68
|
+
"stackOffset",
|
69
|
+
"reverseStackOrder",
|
70
|
+
"onClick",
|
71
|
+
"onMouseEnter",
|
72
|
+
"onMouseMove",
|
73
|
+
"onMouseLeave"
|
74
|
+
];
|
75
|
+
var referenceLineProperties = [
|
76
|
+
"xAxisId",
|
77
|
+
"yAxisId",
|
78
|
+
"x",
|
79
|
+
"y",
|
80
|
+
"ifOverflow",
|
81
|
+
"viewBox",
|
82
|
+
"xAxis",
|
83
|
+
"yAxis",
|
84
|
+
"label",
|
85
|
+
"isFront",
|
86
|
+
"strokeWidth",
|
87
|
+
"segment"
|
88
|
+
];
|
89
|
+
var containerProperties = [
|
90
|
+
"aspect",
|
91
|
+
"width",
|
92
|
+
"height",
|
93
|
+
"minWidth",
|
94
|
+
"minHeight",
|
95
|
+
"debounce",
|
96
|
+
"onResize"
|
97
|
+
];
|
98
|
+
var gridProperties = [
|
99
|
+
"x",
|
100
|
+
"y",
|
101
|
+
"width",
|
102
|
+
"height",
|
103
|
+
"horizontal",
|
104
|
+
"vertical",
|
105
|
+
"horizontalPoints",
|
106
|
+
"horizontalCoordinatesGenerator",
|
107
|
+
"verticalPoints",
|
108
|
+
"verticalCoordinatesGenerator",
|
109
|
+
"fill",
|
110
|
+
"fillOpacity",
|
111
|
+
"strokeDasharray"
|
112
|
+
];
|
113
|
+
var xAxisProperties = [
|
114
|
+
"hide",
|
115
|
+
"dataKey",
|
116
|
+
"xAxisId",
|
117
|
+
"width",
|
118
|
+
"height",
|
119
|
+
"orientation",
|
120
|
+
"type",
|
121
|
+
"allowDecimals",
|
122
|
+
"allowDataOverflow",
|
123
|
+
"allowDuplicatedCategory",
|
124
|
+
"angle",
|
125
|
+
"tickCount",
|
126
|
+
"domain",
|
127
|
+
"includeHidden",
|
128
|
+
"interval",
|
129
|
+
"padding",
|
130
|
+
"minTickGap",
|
131
|
+
"axisLine",
|
132
|
+
"tickLine",
|
133
|
+
"tickSize",
|
134
|
+
"tickFormatter",
|
135
|
+
"ticks",
|
136
|
+
"tick",
|
137
|
+
"mirror",
|
138
|
+
"reversed",
|
139
|
+
"label",
|
140
|
+
"scale",
|
141
|
+
"unit",
|
142
|
+
"name",
|
143
|
+
"onClick",
|
144
|
+
"onMouseDown",
|
145
|
+
"onMouseUp",
|
146
|
+
"onMouseMove",
|
147
|
+
"onMouseOver",
|
148
|
+
"onMouseOut",
|
149
|
+
"onMouseEnter",
|
150
|
+
"onMouseLeave",
|
151
|
+
"tickMargin"
|
152
|
+
];
|
153
|
+
var yAxisProperties = [
|
154
|
+
"hide",
|
155
|
+
"dataKey",
|
156
|
+
"yAxisId",
|
157
|
+
"width",
|
158
|
+
"height",
|
159
|
+
"orientation",
|
160
|
+
"type",
|
161
|
+
"tickCount",
|
162
|
+
"domain",
|
163
|
+
"includeHidden",
|
164
|
+
"interval",
|
165
|
+
"padding",
|
166
|
+
"minTickGap",
|
167
|
+
"allowDecimals",
|
168
|
+
"allowDataOverflow",
|
169
|
+
"allowDuplicatedCategory",
|
170
|
+
"axisLine",
|
171
|
+
"tickLine",
|
172
|
+
"tickSize",
|
173
|
+
"tickFormatter",
|
174
|
+
"ticks",
|
175
|
+
"tick",
|
176
|
+
"mirror",
|
177
|
+
"reversed",
|
178
|
+
"label",
|
179
|
+
"scale",
|
180
|
+
"unit",
|
181
|
+
"name",
|
182
|
+
"onClick",
|
183
|
+
"onMouseDown",
|
184
|
+
"onMouseUp",
|
185
|
+
"onMouseMove",
|
186
|
+
"onMouseOver",
|
187
|
+
"onMouseOut",
|
188
|
+
"onMouseEnter",
|
189
|
+
"onMouseLeave",
|
190
|
+
"tickMargin"
|
191
|
+
];
|
192
|
+
var legendProperties = [
|
193
|
+
"width",
|
194
|
+
"height",
|
195
|
+
"layout",
|
196
|
+
"align",
|
197
|
+
"verticalAlign",
|
198
|
+
"iconSize",
|
199
|
+
"iconType",
|
200
|
+
"payload",
|
201
|
+
"chartWidth",
|
202
|
+
"chartHeight",
|
203
|
+
"margin",
|
204
|
+
"content",
|
205
|
+
"formatter",
|
206
|
+
"wrapperStyle",
|
207
|
+
"onClick",
|
208
|
+
"onMouseDown",
|
209
|
+
"onMouseUp",
|
210
|
+
"onMouseMove",
|
211
|
+
"onMouseOver",
|
212
|
+
"onMouseOut",
|
213
|
+
"onMouseEnter",
|
214
|
+
"onMouseLeave"
|
215
|
+
];
|
216
|
+
var tooltipProperties = [
|
217
|
+
"offset",
|
218
|
+
"filterNull",
|
219
|
+
"itemStyle",
|
220
|
+
"wrapperStyle",
|
221
|
+
"contentStyle",
|
222
|
+
"labelStyle",
|
223
|
+
"cursor",
|
224
|
+
"viewBox",
|
225
|
+
"allowEscapeViewBox",
|
226
|
+
"active",
|
227
|
+
"position",
|
228
|
+
"coordinate",
|
229
|
+
"payload",
|
230
|
+
"label",
|
231
|
+
"content",
|
232
|
+
"formatter",
|
233
|
+
"labelFormatter",
|
234
|
+
"itemSorter",
|
235
|
+
"isAnimationActive",
|
236
|
+
"animationDuration",
|
237
|
+
"animationEasing"
|
238
|
+
];
|
239
|
+
var barProperties = [
|
240
|
+
"layout",
|
241
|
+
"dataKey",
|
242
|
+
"xAxisId",
|
243
|
+
"yAxisId",
|
244
|
+
"legendType",
|
245
|
+
"label",
|
246
|
+
"data",
|
247
|
+
"barSize",
|
248
|
+
"maxBarSize",
|
249
|
+
"minPointSize",
|
250
|
+
"background",
|
251
|
+
"shape",
|
252
|
+
"activeBar",
|
253
|
+
"stackId",
|
254
|
+
"unit",
|
255
|
+
"name",
|
256
|
+
"isAnimationActive",
|
257
|
+
"animationBegin",
|
258
|
+
"animationDuration",
|
259
|
+
"animationEasing",
|
260
|
+
"id",
|
261
|
+
"onAnimationStart",
|
262
|
+
"onAnimationEnd",
|
263
|
+
"onClick",
|
264
|
+
"onMouseDown",
|
265
|
+
"onMouseUp",
|
266
|
+
"onMouseMove",
|
267
|
+
"onMouseOver",
|
268
|
+
"onMouseOut",
|
269
|
+
"onMouseEnter",
|
270
|
+
"onMouseLeave",
|
271
|
+
"radius"
|
272
|
+
];
|
273
|
+
|
274
|
+
// src/use-chart.ts
|
275
|
+
var [ChartProvider, useChartContext] = (0, import_utils2.createContext)({
|
276
|
+
name: "ChartContext",
|
277
|
+
errorMessage: `useChartContext returned is 'undefined'. Seems you forgot to wrap the components in "<LineChart />" or "<BarChart />" etc.`
|
278
|
+
});
|
279
|
+
var useChart = ({ containerProps = {} }) => {
|
280
|
+
const { theme } = (0, import_core2.useTheme)();
|
281
|
+
const [reChartsProps, propClassName] = getComponentProps([
|
282
|
+
containerProps,
|
283
|
+
containerProperties
|
284
|
+
])(theme);
|
285
|
+
const getContainerProps = (0, import_react.useCallback)(
|
286
|
+
({ className, ...props } = {}, ref = null) => ({
|
287
|
+
ref,
|
288
|
+
className: (0, import_utils2.cx)("ui-chart__container", className, propClassName),
|
289
|
+
...props,
|
290
|
+
...reChartsProps
|
291
|
+
}),
|
292
|
+
[propClassName, reChartsProps]
|
293
|
+
);
|
294
|
+
return {
|
295
|
+
getContainerProps
|
296
|
+
};
|
297
|
+
};
|
298
|
+
var useLegend = ({} = {}) => {
|
299
|
+
const { styles } = useChartContext();
|
300
|
+
return {
|
301
|
+
styles
|
302
|
+
};
|
303
|
+
};
|
304
|
+
var useTooltip = ({} = {}) => {
|
305
|
+
const { styles } = useChartContext();
|
306
|
+
return {
|
307
|
+
styles
|
308
|
+
};
|
309
|
+
};
|
310
|
+
|
311
|
+
// src/chart-legend.tsx
|
312
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
313
|
+
var ChartLegend = (0, import_core3.forwardRef)(
|
314
|
+
({ className, payload = [], onHighlight, ...rest }, ref) => {
|
315
|
+
const { styles } = useLegend();
|
316
|
+
const items = payload.map(({ dataKey, value: valueProp, color }, index) => {
|
317
|
+
const value = dataKey != null ? dataKey : valueProp;
|
318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
319
|
+
import_core3.ui.div,
|
320
|
+
{
|
321
|
+
className: "ui-chart__legend-item",
|
322
|
+
onMouseEnter: () => onHighlight(value),
|
323
|
+
onMouseLeave: () => onHighlight(null),
|
324
|
+
__css: styles.legendItem,
|
325
|
+
children: [
|
326
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
327
|
+
import_core3.ui.div,
|
328
|
+
{
|
329
|
+
className: "ui-chart__legend-swatch",
|
330
|
+
background: color,
|
331
|
+
__css: styles.legendSwatch
|
332
|
+
}
|
333
|
+
),
|
334
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core3.ui.span, { className: "ui-chart__legend-label", children: value })
|
335
|
+
]
|
336
|
+
},
|
337
|
+
`legend-${index}`
|
338
|
+
);
|
339
|
+
});
|
340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
341
|
+
import_core3.ui.div,
|
342
|
+
{
|
343
|
+
ref,
|
344
|
+
className: (0, import_utils3.cx)("ui-chart__legend", className),
|
345
|
+
__css: styles.legend,
|
346
|
+
...rest,
|
347
|
+
children: items
|
348
|
+
}
|
349
|
+
);
|
350
|
+
}
|
351
|
+
);
|
352
|
+
|
353
|
+
// src/chart-tooltip.tsx
|
354
|
+
var import_core4 = require("@yamada-ui/core");
|
355
|
+
var import_utils4 = require("@yamada-ui/utils");
|
356
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
357
|
+
var ChartTooltip = (0, import_core4.forwardRef)(
|
358
|
+
({ label, className, payload = [], valueFormatter, unit, ...rest }, ref) => {
|
359
|
+
const { styles } = useTooltip();
|
360
|
+
const items = payload.map(
|
361
|
+
({ color: colorProp, name, value: valueProp, payload: payload2 } = {}, index) => {
|
362
|
+
var _a;
|
363
|
+
const color = colorProp != null ? colorProp : payload2 == null ? void 0 : payload2.color;
|
364
|
+
let value;
|
365
|
+
if ((0, import_utils4.isArray)(valueProp)) {
|
366
|
+
value = valueProp.map((value2) => {
|
367
|
+
var _a2;
|
368
|
+
return `${(_a2 = valueFormatter == null ? void 0 : valueFormatter(value2)) != null ? _a2 : value2}`;
|
369
|
+
}).join(" - ");
|
370
|
+
} else {
|
371
|
+
value = (_a = valueFormatter == null ? void 0 : valueFormatter(valueProp)) != null ? _a : valueProp;
|
372
|
+
}
|
373
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
374
|
+
import_core4.ui.div,
|
375
|
+
{
|
376
|
+
className: "ui-chart__tooltip-item",
|
377
|
+
__css: styles.tooltipItem,
|
378
|
+
children: [
|
379
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
380
|
+
import_core4.ui.div,
|
381
|
+
{
|
382
|
+
className: "ui-chart__tooltip-swatch",
|
383
|
+
background: color,
|
384
|
+
__css: styles.tooltipSwatch
|
385
|
+
}
|
386
|
+
),
|
387
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
388
|
+
import_core4.ui.span,
|
389
|
+
{
|
390
|
+
className: "ui-chart__tooltip-label",
|
391
|
+
__css: styles.tooltipLabel,
|
392
|
+
children: name
|
393
|
+
}
|
394
|
+
),
|
395
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
396
|
+
import_core4.ui.span,
|
397
|
+
{
|
398
|
+
className: "ui-chart__tooltip-value",
|
399
|
+
__css: styles.tooltipValue,
|
400
|
+
children: [
|
401
|
+
value,
|
402
|
+
unit ? unit : ""
|
403
|
+
]
|
404
|
+
}
|
405
|
+
)
|
406
|
+
]
|
407
|
+
},
|
408
|
+
`tooltip-payload-${index}`
|
409
|
+
);
|
410
|
+
}
|
411
|
+
);
|
412
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
413
|
+
import_core4.ui.div,
|
414
|
+
{
|
415
|
+
ref,
|
416
|
+
className: (0, import_utils4.cx)("ui-chart__tooltip", className),
|
417
|
+
__css: styles.tooltip,
|
418
|
+
...rest,
|
419
|
+
children: [
|
420
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core4.ui.p, { className: "ui-chart__tooltip-title", __css: styles.tooltipTitle, children: label }) : null,
|
421
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core4.ui.div, { className: "ui-chart__tooltip-list", __css: styles.tooltipList, children: items })
|
422
|
+
]
|
423
|
+
}
|
424
|
+
);
|
425
|
+
}
|
426
|
+
);
|
427
|
+
|
428
|
+
// src/use-bar-chart.ts
|
429
|
+
var import_core5 = require("@yamada-ui/core");
|
430
|
+
var import_utils5 = require("@yamada-ui/utils");
|
431
|
+
var import_react2 = require("react");
|
432
|
+
var useBarChart = ({
|
433
|
+
data,
|
434
|
+
series,
|
435
|
+
type = "default",
|
436
|
+
layoutType = "horizontal",
|
437
|
+
referenceLineProps = [],
|
438
|
+
fillOpacity = 1,
|
439
|
+
syncId,
|
440
|
+
styles,
|
441
|
+
...rest
|
442
|
+
}) => {
|
443
|
+
var _a;
|
444
|
+
const uuid = (0, import_react2.useId)();
|
445
|
+
const { theme } = (0, import_core5.useTheme)();
|
446
|
+
const [highlightedArea, setHighlightedArea] = (0, import_react2.useState)(null);
|
447
|
+
const stacked = type === "stacked" || type === "percent";
|
448
|
+
const shouldHighlight = highlightedArea !== null;
|
449
|
+
const {
|
450
|
+
activeBar = {},
|
451
|
+
background = {},
|
452
|
+
dimBar,
|
453
|
+
...computedBarProps
|
454
|
+
} = (_a = rest.barProps) != null ? _a : {};
|
455
|
+
const barColors = (0, import_react2.useMemo)(
|
456
|
+
() => series.map(({ color }, index) => ({
|
457
|
+
__prefix: "ui",
|
458
|
+
name: `bar-${index}`,
|
459
|
+
token: "colors",
|
460
|
+
value: color != null ? color : "transparent"
|
461
|
+
})),
|
462
|
+
[series]
|
463
|
+
);
|
464
|
+
const referenceLineColors = (0, import_react2.useMemo)(
|
465
|
+
() => referenceLineProps.map(({ color }, index) => ({
|
466
|
+
__prefix: "ui",
|
467
|
+
name: `reference-line-${index}`,
|
468
|
+
token: "colors",
|
469
|
+
value: color != null ? color : "transparent"
|
470
|
+
})),
|
471
|
+
[referenceLineProps]
|
472
|
+
);
|
473
|
+
const barVars = (0, import_react2.useMemo)(() => {
|
474
|
+
return [
|
475
|
+
...barColors,
|
476
|
+
...referenceLineColors,
|
477
|
+
{ __prefix: "ui", name: "fill-opacity", value: fillOpacity }
|
478
|
+
];
|
479
|
+
}, [barColors, fillOpacity, referenceLineColors]);
|
480
|
+
const [chartProps, barChartClassName] = (0, import_react2.useMemo)(() => {
|
481
|
+
const resolvedBarChartProps = { barGap: 8, ...rest.chartProps };
|
482
|
+
return getComponentProps(
|
483
|
+
[resolvedBarChartProps, barChartProperties],
|
484
|
+
styles.chart
|
485
|
+
)(theme);
|
486
|
+
}, [rest.chartProps, styles.chart, theme]);
|
487
|
+
const [barProps, barClassName] = (0, import_react2.useMemo)(() => {
|
488
|
+
const resolvedBarProps = {
|
489
|
+
fillOpacity: "var(--ui-fill-opacity)",
|
490
|
+
strokeOpacity: 1,
|
491
|
+
...computedBarProps
|
492
|
+
};
|
493
|
+
return getComponentProps(
|
494
|
+
[resolvedBarProps, barProperties],
|
495
|
+
styles.bar
|
496
|
+
)(theme);
|
497
|
+
}, [computedBarProps, styles.bar, theme]);
|
498
|
+
const [dimBarProps, dimBarClassName] = (0, import_react2.useMemo)(() => {
|
499
|
+
const resolvedDimBar = { fillOpacity: 0.3, strokeOpacity: 0, ...dimBar };
|
500
|
+
return getComponentProps([resolvedDimBar, barProperties])(
|
501
|
+
theme
|
502
|
+
);
|
503
|
+
}, [dimBar, theme]);
|
504
|
+
const [activeBarProps, activeBarClassName] = (0, import_react2.useMemo)(
|
505
|
+
() => getComponentProps(
|
506
|
+
[activeBar, barProperties],
|
507
|
+
styles.activeBar
|
508
|
+
)(theme),
|
509
|
+
[activeBar, styles.activeBar, theme]
|
510
|
+
);
|
511
|
+
const [backgroundProps, backgroundClassName] = (0, import_react2.useMemo)(
|
512
|
+
() => getComponentProps(
|
513
|
+
[background, barProperties],
|
514
|
+
styles.background
|
515
|
+
)(theme),
|
516
|
+
[background, styles.background, theme]
|
517
|
+
);
|
518
|
+
const barPropsList = (0, import_react2.useMemo)(
|
519
|
+
() => series.map((props, index) => {
|
520
|
+
const {
|
521
|
+
dataKey,
|
522
|
+
activeBar: activeBar2 = {},
|
523
|
+
background: background2 = {},
|
524
|
+
dimBar: dimBar2 = {},
|
525
|
+
...computedProps
|
526
|
+
} = props;
|
527
|
+
const id = `${uuid}-${dataKey}`;
|
528
|
+
const color = `var(--ui-bar-${index})`;
|
529
|
+
const dimmed = shouldHighlight && highlightedArea !== dataKey;
|
530
|
+
const computedDimBar = { ...dimBarProps, ...dimBar2 };
|
531
|
+
const resolvedProps = {
|
532
|
+
...barProps,
|
533
|
+
...computedProps,
|
534
|
+
...dimmed ? computedDimBar : {}
|
535
|
+
};
|
536
|
+
const rest2 = getComponentProps(
|
537
|
+
[resolvedProps, barProperties],
|
538
|
+
barClassName,
|
539
|
+
dimmed ? dimBarClassName : void 0
|
540
|
+
)(theme, true);
|
541
|
+
const computedActiveBar = { ...activeBarProps, ...activeBar2 };
|
542
|
+
const resolvedActiveBar = getComponentProps(
|
543
|
+
[computedActiveBar, barProperties],
|
544
|
+
activeBarClassName
|
545
|
+
)(theme, true);
|
546
|
+
const computedBackground = { ...backgroundProps, ...background2 };
|
547
|
+
const resolvedBackground = getComponentProps(
|
548
|
+
[computedBackground, barProperties],
|
549
|
+
backgroundClassName
|
550
|
+
)(theme, true);
|
551
|
+
return {
|
552
|
+
...rest2,
|
553
|
+
id,
|
554
|
+
activeBar: resolvedActiveBar,
|
555
|
+
background: resolvedBackground,
|
556
|
+
color,
|
557
|
+
dataKey
|
558
|
+
};
|
559
|
+
}),
|
560
|
+
[
|
561
|
+
activeBarClassName,
|
562
|
+
activeBarProps,
|
563
|
+
backgroundClassName,
|
564
|
+
backgroundProps,
|
565
|
+
barClassName,
|
566
|
+
barProps,
|
567
|
+
dimBarClassName,
|
568
|
+
dimBarProps,
|
569
|
+
highlightedArea,
|
570
|
+
series,
|
571
|
+
shouldHighlight,
|
572
|
+
theme,
|
573
|
+
uuid
|
574
|
+
]
|
575
|
+
);
|
576
|
+
const getBarProps = (0, import_react2.useCallback)(
|
577
|
+
({ index, className: classNameProp, ...props }, ref = null) => {
|
578
|
+
const { id, className, activeBar: activeBar2, background: background2, color, dataKey, ...rest2 } = barPropsList[index];
|
579
|
+
return {
|
580
|
+
ref,
|
581
|
+
className: (0, import_utils5.cx)(classNameProp, className),
|
582
|
+
activeBar: activeBar2,
|
583
|
+
background: background2,
|
584
|
+
id,
|
585
|
+
name: dataKey,
|
586
|
+
dataKey,
|
587
|
+
fill: color,
|
588
|
+
stroke: color,
|
589
|
+
isAnimationActive: false,
|
590
|
+
stackId: stacked ? "stack" : void 0,
|
591
|
+
...props,
|
592
|
+
...rest2
|
593
|
+
};
|
594
|
+
},
|
595
|
+
[barPropsList, stacked]
|
596
|
+
);
|
597
|
+
const getBarChartProps = (0, import_react2.useCallback)(
|
598
|
+
({ className, ...props } = {}, ref = null) => ({
|
599
|
+
ref,
|
600
|
+
className: (0, import_utils5.cx)(className, barChartClassName),
|
601
|
+
data,
|
602
|
+
stackOffset: type === "percent" ? "expand" : void 0,
|
603
|
+
layout: layoutType,
|
604
|
+
syncId,
|
605
|
+
...props,
|
606
|
+
...chartProps
|
607
|
+
}),
|
608
|
+
[barChartClassName, chartProps, data, syncId, layoutType, type]
|
609
|
+
);
|
610
|
+
return {
|
611
|
+
barVars,
|
612
|
+
getBarProps,
|
613
|
+
getBarChartProps,
|
614
|
+
setHighlightedArea
|
615
|
+
};
|
616
|
+
};
|
617
|
+
|
618
|
+
// src/use-chart-axis.ts
|
619
|
+
var import_core6 = require("@yamada-ui/core");
|
620
|
+
var import_utils6 = require("@yamada-ui/utils");
|
621
|
+
var import_react3 = require("react");
|
622
|
+
var useChartAxis = ({
|
623
|
+
dataKey,
|
624
|
+
type,
|
625
|
+
layoutType = "horizontal",
|
626
|
+
tickLine = "y",
|
627
|
+
gridAxis = "x",
|
628
|
+
withXAxis = true,
|
629
|
+
withYAxis = true,
|
630
|
+
xAxisProps: _xAxisProps = {},
|
631
|
+
yAxisProps: _yAxisProps = {},
|
632
|
+
unit,
|
633
|
+
valueFormatter,
|
634
|
+
styles
|
635
|
+
}) => {
|
636
|
+
const { theme } = (0, import_core6.useTheme)();
|
637
|
+
const xAxisKey = (0, import_react3.useMemo)(
|
638
|
+
() => layoutType === "vertical" ? { type: "number" } : { dataKey },
|
639
|
+
[dataKey, layoutType]
|
640
|
+
);
|
641
|
+
const yAxisKey = (0, import_react3.useMemo)(
|
642
|
+
() => layoutType === "vertical" ? { dataKey, type: "category" } : { type: "number" },
|
643
|
+
[dataKey, layoutType]
|
644
|
+
);
|
645
|
+
const withXTickLine = gridAxis !== "none" && (tickLine === "x" || tickLine === "xy");
|
646
|
+
const withYTickLine = gridAxis !== "none" && (tickLine === "y" || tickLine === "xy");
|
647
|
+
const getTickLine = (withTickLine) => withTickLine ? { stroke: "currentColor" } : false;
|
648
|
+
const xTickLine = getTickLine(withXTickLine);
|
649
|
+
const yTickLine = getTickLine(withYTickLine);
|
650
|
+
const yAxisTickFormatter = type === "percent" && layoutType !== "vertical" ? valueToPercent : valueFormatter;
|
651
|
+
const xAxisTickFormatter = type === "percent" && layoutType === "vertical" ? valueToPercent : valueFormatter;
|
652
|
+
const [xAxisReChartsProps, xAxisClassName] = getComponentProps(
|
653
|
+
[_xAxisProps, xAxisProperties],
|
654
|
+
styles.xAxis
|
655
|
+
)(theme);
|
656
|
+
const [yAxisReChartsProps, yAxisClassName] = getComponentProps(
|
657
|
+
[_yAxisProps, yAxisProperties],
|
658
|
+
styles.yAxis
|
659
|
+
)(theme);
|
660
|
+
const getXAxisProps = (0, import_react3.useCallback)(
|
661
|
+
({ className, ...props } = {}) => ({
|
662
|
+
className: (0, import_utils6.cx)(className, xAxisClassName),
|
663
|
+
hide: !withXAxis,
|
664
|
+
...xAxisKey,
|
665
|
+
tick: {
|
666
|
+
transform: "translate(0, 10)",
|
667
|
+
fill: "currentColor"
|
668
|
+
},
|
669
|
+
stroke: "",
|
670
|
+
interval: "preserveStartEnd",
|
671
|
+
tickLine: xTickLine,
|
672
|
+
minTickGap: 5,
|
673
|
+
tickFormatter: xAxisTickFormatter,
|
674
|
+
...props,
|
675
|
+
...xAxisReChartsProps
|
676
|
+
}),
|
677
|
+
[
|
678
|
+
xAxisClassName,
|
679
|
+
withXAxis,
|
680
|
+
xAxisKey,
|
681
|
+
xTickLine,
|
682
|
+
xAxisTickFormatter,
|
683
|
+
xAxisReChartsProps
|
684
|
+
]
|
685
|
+
);
|
686
|
+
const getYAxisProps = (0, import_react3.useCallback)(
|
687
|
+
({ className, ...props } = {}) => ({
|
688
|
+
className: (0, import_utils6.cx)(className, yAxisClassName),
|
689
|
+
hide: !withYAxis,
|
690
|
+
axisLine: false,
|
691
|
+
...yAxisKey,
|
692
|
+
tickLine: yTickLine,
|
693
|
+
tick: {
|
694
|
+
transform: "translate(-10, 0)",
|
695
|
+
fill: "currentColor"
|
696
|
+
},
|
697
|
+
allowDecimals: true,
|
698
|
+
unit,
|
699
|
+
tickFormatter: yAxisTickFormatter,
|
700
|
+
...props,
|
701
|
+
...yAxisReChartsProps
|
702
|
+
}),
|
703
|
+
[
|
704
|
+
yAxisClassName,
|
705
|
+
withYAxis,
|
706
|
+
yAxisKey,
|
707
|
+
yTickLine,
|
708
|
+
unit,
|
709
|
+
yAxisTickFormatter,
|
710
|
+
yAxisReChartsProps
|
711
|
+
]
|
712
|
+
);
|
713
|
+
return { getXAxisProps, getYAxisProps };
|
714
|
+
};
|
715
|
+
var valueToPercent = (value) => {
|
716
|
+
return `${(value * 100).toFixed(0)}%`;
|
717
|
+
};
|
718
|
+
|
719
|
+
// src/use-chart-grid.ts
|
720
|
+
var import_core7 = require("@yamada-ui/core");
|
721
|
+
var import_utils7 = require("@yamada-ui/utils");
|
722
|
+
var import_react4 = require("react");
|
723
|
+
var useChartGrid = ({
|
724
|
+
gridProps = {},
|
725
|
+
gridAxis = "x",
|
726
|
+
strokeDasharray = "5 5",
|
727
|
+
styles
|
728
|
+
}) => {
|
729
|
+
const { theme } = (0, import_core7.useTheme)();
|
730
|
+
const [reChartsProps, propClassName] = getComponentProps(
|
731
|
+
[gridProps, gridProperties],
|
732
|
+
styles.grid
|
733
|
+
)(theme);
|
734
|
+
const getGridProps = (0, import_react4.useCallback)(
|
735
|
+
({ className, ...props } = {}, ref = null) => ({
|
736
|
+
ref,
|
737
|
+
className: (0, import_utils7.cx)("ui-chart__grid", className, propClassName),
|
738
|
+
strokeDasharray,
|
739
|
+
vertical: gridAxis === "y" || gridAxis === "xy",
|
740
|
+
horizontal: gridAxis === "x" || gridAxis === "xy",
|
741
|
+
...props,
|
742
|
+
...reChartsProps
|
743
|
+
}),
|
744
|
+
[propClassName, strokeDasharray, gridAxis, reChartsProps]
|
745
|
+
);
|
746
|
+
return { getGridProps };
|
747
|
+
};
|
748
|
+
|
749
|
+
// src/use-chart-legend.ts
|
750
|
+
var import_utils8 = require("@yamada-ui/utils");
|
751
|
+
var import_react5 = require("react");
|
752
|
+
var useChartLegend = ({
|
753
|
+
legendProps: _legendProps = {}
|
754
|
+
}) => {
|
755
|
+
const [rest, legendProps] = (0, import_utils8.splitObject)(
|
756
|
+
_legendProps,
|
757
|
+
legendProperties
|
758
|
+
);
|
759
|
+
const getLegendProps = (0, import_react5.useCallback)(
|
760
|
+
(props, ref = null) => {
|
761
|
+
return {
|
762
|
+
ref,
|
763
|
+
verticalAlign: "top",
|
764
|
+
...props,
|
765
|
+
...rest
|
766
|
+
};
|
767
|
+
},
|
768
|
+
[rest]
|
769
|
+
);
|
770
|
+
return { legendProps, getLegendProps };
|
771
|
+
};
|
772
|
+
|
773
|
+
// src/use-chart-reference-line.ts
|
774
|
+
var import_core8 = require("@yamada-ui/core");
|
775
|
+
var import_utils9 = require("@yamada-ui/utils");
|
776
|
+
var import_react6 = require("react");
|
777
|
+
var useChartReferenceLine = ({
|
778
|
+
referenceLineProps = [],
|
779
|
+
styles
|
780
|
+
}) => {
|
781
|
+
const { theme } = (0, import_core8.useTheme)();
|
782
|
+
const styleClassName = (0, import_core8.getCSS)(styles.referenceLine)(theme);
|
783
|
+
const propList = (0, import_react6.useMemo)(
|
784
|
+
() => referenceLineProps.map((props, index) => {
|
785
|
+
const [{ label: labelProp, ...rest }, propClassName] = getComponentProps(
|
786
|
+
[props, referenceLineProperties],
|
787
|
+
styleClassName
|
788
|
+
)(theme);
|
789
|
+
const color = `var(--ui-reference-line-${index})`;
|
790
|
+
const label = {
|
791
|
+
value: labelProp,
|
792
|
+
fill: color,
|
793
|
+
position: "insideBottomLeft",
|
794
|
+
...(0, import_utils9.isObject)(labelProp) ? labelProp : {}
|
795
|
+
};
|
796
|
+
return { propClassName, color, label, ...rest };
|
797
|
+
}),
|
798
|
+
[referenceLineProps, styleClassName, theme]
|
799
|
+
);
|
800
|
+
const getReferenceLineProps = (0, import_react6.useCallback)(
|
801
|
+
({ index, className, ...props }, ref = null) => {
|
802
|
+
const { propClassName, color, label, ...rest } = propList[index];
|
803
|
+
return {
|
804
|
+
ref,
|
805
|
+
className: (0, import_utils9.cx)(className, propClassName),
|
806
|
+
stroke: color,
|
807
|
+
label,
|
808
|
+
...props,
|
809
|
+
...rest
|
810
|
+
};
|
811
|
+
},
|
812
|
+
[propList]
|
813
|
+
);
|
814
|
+
return { getReferenceLineProps };
|
815
|
+
};
|
816
|
+
|
817
|
+
// src/use-chart-tooltip.ts
|
818
|
+
var import_core9 = require("@yamada-ui/core");
|
819
|
+
var import_utils10 = require("@yamada-ui/utils");
|
820
|
+
var import_react7 = require("react");
|
821
|
+
var useChartTooltip = ({
|
822
|
+
tooltipProps: _tooltipProps = {},
|
823
|
+
tooltipAnimationDuration = 0,
|
824
|
+
styles
|
825
|
+
}) => {
|
826
|
+
const { theme } = (0, import_core9.useTheme)();
|
827
|
+
const { cursor, ...rest } = _tooltipProps;
|
828
|
+
const cursorClassName = (0, import_react7.useMemo)(
|
829
|
+
() => getClassName({ ...styles.cursor, ...cursor })(theme),
|
830
|
+
[cursor, styles.cursor, theme]
|
831
|
+
);
|
832
|
+
const [tooltipProps, tooltipUIProps] = (0, import_utils10.splitObject)(
|
833
|
+
rest,
|
834
|
+
tooltipProperties
|
835
|
+
);
|
836
|
+
const getTooltipProps = (0, import_react7.useCallback)(
|
837
|
+
(props, ref = null) => ({
|
838
|
+
ref,
|
839
|
+
animationDuration: tooltipAnimationDuration,
|
840
|
+
isAnimationActive: (tooltipAnimationDuration || 0) > 0,
|
841
|
+
cursor: {
|
842
|
+
className: (0, import_utils10.cx)("ui-chart__cursor", cursorClassName)
|
843
|
+
},
|
844
|
+
...props,
|
845
|
+
...tooltipProps
|
846
|
+
}),
|
847
|
+
[cursorClassName, tooltipAnimationDuration, tooltipProps]
|
848
|
+
);
|
849
|
+
return { tooltipProps: tooltipUIProps, getTooltipProps };
|
850
|
+
};
|
851
|
+
|
852
|
+
// src/bar-chart.tsx
|
853
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
854
|
+
var BarChart = (0, import_core10.forwardRef)((props, ref) => {
|
855
|
+
const [styles, mergedProps] = (0, import_core10.useMultiComponentStyle)("BarChart", props);
|
856
|
+
const {
|
857
|
+
className,
|
858
|
+
series,
|
859
|
+
dataKey,
|
860
|
+
layoutType,
|
861
|
+
tickLine,
|
862
|
+
gridAxis,
|
863
|
+
withXAxis,
|
864
|
+
withYAxis,
|
865
|
+
barProps,
|
866
|
+
xAxisProps,
|
867
|
+
yAxisProps,
|
868
|
+
type = "default",
|
869
|
+
withTooltip = true,
|
870
|
+
withLegend = false,
|
871
|
+
containerProps,
|
872
|
+
unit,
|
873
|
+
valueFormatter,
|
874
|
+
tooltipProps,
|
875
|
+
tooltipAnimationDuration,
|
876
|
+
legendProps,
|
877
|
+
data,
|
878
|
+
referenceLineProps = [],
|
879
|
+
gridProps,
|
880
|
+
strokeDasharray,
|
881
|
+
fillOpacity,
|
882
|
+
chartProps,
|
883
|
+
syncId,
|
884
|
+
...rest
|
885
|
+
} = (0, import_core10.omitThemeProps)(mergedProps);
|
886
|
+
const { getBarChartProps, getBarProps, barVars, setHighlightedArea } = useBarChart({
|
887
|
+
data,
|
888
|
+
series,
|
889
|
+
type,
|
890
|
+
layoutType,
|
891
|
+
chartProps,
|
892
|
+
barProps,
|
893
|
+
referenceLineProps,
|
894
|
+
fillOpacity,
|
895
|
+
syncId,
|
896
|
+
styles
|
897
|
+
});
|
898
|
+
const { getContainerProps } = useChart({ containerProps });
|
899
|
+
const { getXAxisProps, getYAxisProps } = useChartAxis({
|
900
|
+
dataKey,
|
901
|
+
type,
|
902
|
+
layoutType,
|
903
|
+
tickLine,
|
904
|
+
gridAxis,
|
905
|
+
withXAxis,
|
906
|
+
withYAxis,
|
907
|
+
xAxisProps,
|
908
|
+
yAxisProps,
|
909
|
+
unit,
|
910
|
+
valueFormatter,
|
911
|
+
styles
|
912
|
+
});
|
913
|
+
const { getReferenceLineProps } = useChartReferenceLine({
|
914
|
+
referenceLineProps,
|
915
|
+
styles
|
916
|
+
});
|
917
|
+
const { getGridProps } = useChartGrid({
|
918
|
+
gridProps,
|
919
|
+
gridAxis,
|
920
|
+
strokeDasharray,
|
921
|
+
styles
|
922
|
+
});
|
923
|
+
const { tooltipProps: computedTooltipProps, getTooltipProps } = useChartTooltip({
|
924
|
+
tooltipProps,
|
925
|
+
tooltipAnimationDuration,
|
926
|
+
styles
|
927
|
+
});
|
928
|
+
const { legendProps: computedLegendProps, getLegendProps } = useChartLegend({
|
929
|
+
legendProps
|
930
|
+
});
|
931
|
+
const bars = (0, import_react8.useMemo)(
|
932
|
+
() => series.map(({ dataKey: dataKey2 }, index) => {
|
933
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
934
|
+
import_recharts.Bar,
|
935
|
+
{
|
936
|
+
...getBarProps({ index, className: "ui-bar-chart__bar" })
|
937
|
+
},
|
938
|
+
`bar-${dataKey2}`
|
939
|
+
);
|
940
|
+
}),
|
941
|
+
[getBarProps, series]
|
942
|
+
);
|
943
|
+
const referenceLinesItems = (0, import_react8.useMemo)(
|
944
|
+
() => referenceLineProps.map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
945
|
+
import_recharts.ReferenceLine,
|
946
|
+
{
|
947
|
+
...getReferenceLineProps({
|
948
|
+
index,
|
949
|
+
className: "ui-bar-chart__reference-line"
|
950
|
+
})
|
951
|
+
},
|
952
|
+
`referenceLine-${index}`
|
953
|
+
)),
|
954
|
+
[getReferenceLineProps, referenceLineProps]
|
955
|
+
);
|
956
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
957
|
+
import_core10.ui.div,
|
958
|
+
{
|
959
|
+
ref,
|
960
|
+
className: (0, import_utils11.cx)("ui-bar-chart", className),
|
961
|
+
var: barVars,
|
962
|
+
__css: { maxW: "full", ...styles.container },
|
963
|
+
...rest,
|
964
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
965
|
+
import_recharts.ResponsiveContainer,
|
966
|
+
{
|
967
|
+
...getContainerProps({ className: "ui-bar-chart__container" }),
|
968
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
969
|
+
import_recharts.BarChart,
|
970
|
+
{
|
971
|
+
...getBarChartProps({ className: "ui-bar-chart__chart" }),
|
972
|
+
children: [
|
973
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
974
|
+
import_recharts.CartesianGrid,
|
975
|
+
{
|
976
|
+
...getGridProps({ className: "ui-bar-chart__grid" })
|
977
|
+
}
|
978
|
+
),
|
979
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_recharts.XAxis, { ...getXAxisProps({ className: "ui-bar-chart__x-axis" }) }),
|
980
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_recharts.YAxis, { ...getYAxisProps({ className: "ui-bar-chart__y-axis" }) }),
|
981
|
+
withLegend ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
982
|
+
import_recharts.Legend,
|
983
|
+
{
|
984
|
+
content: ({ payload }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
985
|
+
ChartLegend,
|
986
|
+
{
|
987
|
+
className: "ui-bar-chart__legend",
|
988
|
+
payload,
|
989
|
+
onHighlight: setHighlightedArea,
|
990
|
+
...computedLegendProps
|
991
|
+
}
|
992
|
+
),
|
993
|
+
...getLegendProps()
|
994
|
+
}
|
995
|
+
) : null,
|
996
|
+
withTooltip ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
997
|
+
import_recharts.Tooltip,
|
998
|
+
{
|
999
|
+
content: ({ label, payload }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
1000
|
+
ChartTooltip,
|
1001
|
+
{
|
1002
|
+
className: "ui-bar-chart__tooltip",
|
1003
|
+
label,
|
1004
|
+
payload,
|
1005
|
+
valueFormatter,
|
1006
|
+
unit,
|
1007
|
+
...computedTooltipProps
|
1008
|
+
}
|
1009
|
+
),
|
1010
|
+
...getTooltipProps()
|
1011
|
+
}
|
1012
|
+
) : null,
|
1013
|
+
bars,
|
1014
|
+
referenceLinesItems
|
1015
|
+
]
|
1016
|
+
}
|
1017
|
+
)
|
1018
|
+
}
|
1019
|
+
)
|
1020
|
+
}
|
1021
|
+
) });
|
1022
|
+
});
|
1023
|
+
// Annotate the CommonJS export names for ESM import in node:
|
1024
|
+
0 && (module.exports = {
|
1025
|
+
BarChart
|
1026
|
+
});
|
1027
|
+
//# sourceMappingURL=bar-chart.js.map
|