@yamada-ui/charts 2.0.0-next-20240820160301 → 2.0.0-next-20240908154823
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +7 -13
- package/dist/area-chart-split.js +4 -2
- package/dist/area-chart-split.js.map +1 -1
- package/dist/area-chart-split.mjs +1 -1
- package/dist/area-chart.d.mts +1 -2
- package/dist/area-chart.d.ts +1 -2
- package/dist/area-chart.js +57 -50
- package/dist/area-chart.js.map +1 -1
- package/dist/area-chart.mjs +12 -12
- package/dist/bar-chart.d.mts +1 -2
- package/dist/bar-chart.d.ts +1 -2
- package/dist/bar-chart.js +15 -9
- package/dist/bar-chart.js.map +1 -1
- package/dist/bar-chart.mjs +11 -11
- package/dist/chart-legend.mjs +3 -3
- package/dist/chart-tooltip.d.mts +3 -1
- package/dist/chart-tooltip.d.ts +3 -1
- package/dist/chart-tooltip.js +9 -1
- package/dist/chart-tooltip.js.map +1 -1
- package/dist/chart-tooltip.mjs +3 -3
- package/dist/chart.types.d.mts +12 -5
- package/dist/chart.types.d.ts +12 -5
- package/dist/chart.types.js.map +1 -1
- package/dist/{chunk-STBYN5JW.mjs → chunk-3AOICU4Q.mjs} +2 -2
- package/dist/chunk-3HQ2UC3I.mjs +45 -0
- package/dist/chunk-3HQ2UC3I.mjs.map +1 -0
- package/dist/{chunk-FALZDKAW.mjs → chunk-3VKCTSPC.mjs} +10 -11
- package/dist/chunk-3VKCTSPC.mjs.map +1 -0
- package/dist/{chunk-S5NKKKV5.mjs → chunk-5PSRSNGH.mjs} +7 -8
- package/dist/chunk-5PSRSNGH.mjs.map +1 -0
- package/dist/{chunk-F34FV5DY.mjs → chunk-6YUJLLGN.mjs} +59 -3
- package/dist/chunk-6YUJLLGN.mjs.map +1 -0
- package/dist/{chunk-KBBHISBO.mjs → chunk-BYL7HWNN.mjs} +13 -14
- package/dist/chunk-BYL7HWNN.mjs.map +1 -0
- package/dist/chunk-D5IRVU4W.mjs +46 -0
- package/dist/chunk-D5IRVU4W.mjs.map +1 -0
- package/dist/{chunk-DGOXJ373.mjs → chunk-EL2VTGFB.mjs} +2 -2
- package/dist/{chunk-6L73M52L.mjs → chunk-FPFCMFCJ.mjs} +7 -9
- package/dist/chunk-FPFCMFCJ.mjs.map +1 -0
- package/dist/{chunk-Q7CCSKX3.mjs → chunk-JTQ5QCML.mjs} +4 -4
- package/dist/chunk-JTQ5QCML.mjs.map +1 -0
- package/dist/chunk-KVE6VXTJ.mjs +37 -0
- package/dist/chunk-KVE6VXTJ.mjs.map +1 -0
- package/dist/{chunk-PNE3JG54.mjs → chunk-MGTMKKSH.mjs} +5 -3
- package/dist/chunk-MGTMKKSH.mjs.map +1 -0
- package/dist/chunk-PG7ZV76C.mjs +155 -0
- package/dist/chunk-PG7ZV76C.mjs.map +1 -0
- package/dist/{chunk-D7EZKGCJ.mjs → chunk-PPBHLDVN.mjs} +2 -2
- package/dist/{chunk-AODYT4HF.mjs → chunk-RKO6KM3T.mjs} +13 -14
- package/dist/chunk-RKO6KM3T.mjs.map +1 -0
- package/dist/chunk-SBPKRYF2.mjs +199 -0
- package/dist/chunk-SBPKRYF2.mjs.map +1 -0
- package/dist/{chunk-FCMP6QEZ.mjs → chunk-SWATR7CU.mjs} +14 -15
- package/dist/chunk-SWATR7CU.mjs.map +1 -0
- package/dist/{chunk-MT5JI4OR.mjs → chunk-T5DNDBW6.mjs} +11 -3
- package/dist/chunk-T5DNDBW6.mjs.map +1 -0
- package/dist/{chunk-5Q6O726L.mjs → chunk-TCSYDMC7.mjs} +2 -2
- package/dist/{chunk-UHQ6WE5D.mjs → chunk-TMHSYM3V.mjs} +17 -13
- package/dist/chunk-TMHSYM3V.mjs.map +1 -0
- package/dist/{chunk-AOGTJ4EN.mjs → chunk-VMBRDEM2.mjs} +2 -2
- package/dist/{chunk-XUAAKVRL.mjs → chunk-WMG5U5AU.mjs} +26 -13
- package/dist/chunk-WMG5U5AU.mjs.map +1 -0
- package/dist/{chunk-6BNJZIBK.mjs → chunk-X7XFG7TS.mjs} +10 -12
- package/dist/chunk-X7XFG7TS.mjs.map +1 -0
- package/dist/{chunk-MOFNE6PO.mjs → chunk-XRF3TNSQ.mjs} +6 -30
- package/dist/chunk-XRF3TNSQ.mjs.map +1 -0
- package/dist/{chunk-VK4VQQYY.mjs → chunk-YNJ423BR.mjs} +2 -2
- package/dist/{chunk-BGMNYKQY.mjs → chunk-ZQWVMOT6.mjs} +9 -7
- package/dist/chunk-ZQWVMOT6.mjs.map +1 -0
- package/dist/donut-chart.d.mts +3 -3
- package/dist/donut-chart.d.ts +3 -3
- package/dist/donut-chart.js +109 -58
- package/dist/donut-chart.js.map +1 -1
- package/dist/donut-chart.mjs +9 -8
- package/dist/index.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +599 -167
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -22
- package/dist/index.mjs.map +1 -1
- package/dist/line-chart.d.mts +1 -2
- package/dist/line-chart.d.ts +1 -2
- package/dist/line-chart.js +15 -10
- package/dist/line-chart.js.map +1 -1
- package/dist/line-chart.mjs +11 -11
- package/dist/pie-chart.d.mts +2 -3
- package/dist/pie-chart.d.ts +2 -3
- package/dist/pie-chart.js +13 -7
- package/dist/pie-chart.js.map +1 -1
- package/dist/pie-chart.mjs +8 -8
- package/dist/radar-chart.d.mts +3 -3
- package/dist/radar-chart.d.ts +3 -3
- package/dist/radar-chart.js +90 -70
- package/dist/radar-chart.js.map +1 -1
- package/dist/radar-chart.mjs +9 -8
- package/dist/radial-chart.d.mts +53 -0
- package/dist/radial-chart.d.ts +53 -0
- package/dist/radial-chart.js +767 -0
- package/dist/radial-chart.js.map +1 -0
- package/dist/radial-chart.mjs +18 -0
- package/dist/radial-chart.mjs.map +1 -0
- package/dist/rechart-properties.d.mts +5 -1
- package/dist/rechart-properties.d.ts +5 -1
- package/dist/rechart-properties.js +60 -1
- package/dist/rechart-properties.js.map +1 -1
- package/dist/rechart-properties.mjs +7 -1
- package/dist/use-area-chart.d.mts +1 -2
- package/dist/use-area-chart.d.ts +1 -2
- package/dist/use-area-chart.js +7 -9
- package/dist/use-area-chart.js.map +1 -1
- package/dist/use-area-chart.mjs +2 -2
- package/dist/use-bar-chart.d.mts +1 -2
- package/dist/use-bar-chart.d.ts +1 -2
- package/dist/use-bar-chart.js +4 -5
- package/dist/use-bar-chart.js.map +1 -1
- package/dist/use-bar-chart.mjs +2 -2
- package/dist/use-chart-axis.d.mts +0 -1
- package/dist/use-chart-axis.d.ts +0 -1
- package/dist/use-chart-axis.js.map +1 -1
- package/dist/use-chart-axis.mjs +2 -2
- package/dist/use-chart-grid.d.mts +0 -1
- package/dist/use-chart-grid.d.ts +0 -1
- package/dist/use-chart-grid.js.map +1 -1
- package/dist/use-chart-grid.mjs +2 -2
- package/dist/use-chart-label-list.d.mts +22 -0
- package/dist/use-chart-label-list.d.ts +22 -0
- package/dist/use-chart-label-list.js +93 -0
- package/dist/use-chart-label-list.js.map +1 -0
- package/dist/use-chart-label-list.mjs +10 -0
- package/dist/use-chart-label-list.mjs.map +1 -0
- package/dist/use-chart-label.d.mts +20 -0
- package/dist/use-chart-label.d.ts +20 -0
- package/dist/use-chart-label.js +82 -0
- package/dist/use-chart-label.js.map +1 -0
- package/dist/use-chart-label.mjs +10 -0
- package/dist/use-chart-label.mjs.map +1 -0
- package/dist/use-chart-legend.d.mts +0 -1
- package/dist/use-chart-legend.d.ts +0 -1
- package/dist/use-chart-legend.js.map +1 -1
- package/dist/use-chart-legend.mjs +2 -2
- package/dist/use-chart-reference-line.d.mts +0 -1
- package/dist/use-chart-reference-line.d.ts +0 -1
- package/dist/use-chart-reference-line.js +1 -1
- package/dist/use-chart-reference-line.js.map +1 -1
- package/dist/use-chart-reference-line.mjs +2 -2
- package/dist/use-chart-tooltip.d.mts +0 -1
- package/dist/use-chart-tooltip.d.ts +0 -1
- package/dist/use-chart-tooltip.js.map +1 -1
- package/dist/use-chart-tooltip.mjs +2 -2
- package/dist/use-chart.d.mts +0 -1
- package/dist/use-chart.d.ts +0 -1
- package/dist/use-chart.js.map +1 -1
- package/dist/use-chart.mjs +2 -2
- package/dist/use-line-chart.d.mts +1 -2
- package/dist/use-line-chart.d.ts +1 -2
- package/dist/use-line-chart.js +4 -6
- package/dist/use-line-chart.js.map +1 -1
- package/dist/use-line-chart.mjs +2 -2
- package/dist/use-pie-chart.d.mts +1 -2
- package/dist/use-pie-chart.d.ts +1 -2
- package/dist/use-pie-chart.js +3 -4
- package/dist/use-pie-chart.js.map +1 -1
- package/dist/use-pie-chart.mjs +2 -2
- package/dist/use-polar-grid.d.mts +24 -0
- package/dist/use-polar-grid.d.ts +24 -0
- package/dist/use-polar-grid.js +90 -0
- package/dist/use-polar-grid.js.map +1 -0
- package/dist/use-polar-grid.mjs +10 -0
- package/dist/use-polar-grid.mjs.map +1 -0
- package/dist/use-radar-chart.d.mts +3 -13
- package/dist/use-radar-chart.d.ts +3 -13
- package/dist/use-radar-chart.js +3 -35
- package/dist/use-radar-chart.js.map +1 -1
- package/dist/use-radar-chart.mjs +2 -2
- package/dist/use-radial-chart.d.mts +80 -0
- package/dist/use-radial-chart.d.ts +80 -0
- package/dist/use-radial-chart.js +228 -0
- package/dist/use-radial-chart.js.map +1 -0
- package/dist/use-radial-chart.mjs +10 -0
- package/dist/use-radial-chart.mjs.map +1 -0
- package/package.json +4 -4
- package/dist/chunk-6BNJZIBK.mjs.map +0 -1
- package/dist/chunk-6L73M52L.mjs.map +0 -1
- package/dist/chunk-AODYT4HF.mjs.map +0 -1
- package/dist/chunk-BGMNYKQY.mjs.map +0 -1
- package/dist/chunk-F34FV5DY.mjs.map +0 -1
- package/dist/chunk-FALZDKAW.mjs.map +0 -1
- package/dist/chunk-FCMP6QEZ.mjs.map +0 -1
- package/dist/chunk-KBBHISBO.mjs.map +0 -1
- package/dist/chunk-MOFNE6PO.mjs.map +0 -1
- package/dist/chunk-MT5JI4OR.mjs.map +0 -1
- package/dist/chunk-PNE3JG54.mjs.map +0 -1
- package/dist/chunk-Q7CCSKX3.mjs.map +0 -1
- package/dist/chunk-S5NKKKV5.mjs.map +0 -1
- package/dist/chunk-UHQ6WE5D.mjs.map +0 -1
- package/dist/chunk-XUAAKVRL.mjs.map +0 -1
- /package/dist/{chunk-STBYN5JW.mjs.map → chunk-3AOICU4Q.mjs.map} +0 -0
- /package/dist/{chunk-DGOXJ373.mjs.map → chunk-EL2VTGFB.mjs.map} +0 -0
- /package/dist/{chunk-D7EZKGCJ.mjs.map → chunk-PPBHLDVN.mjs.map} +0 -0
- /package/dist/{chunk-5Q6O726L.mjs.map → chunk-TCSYDMC7.mjs.map} +0 -0
- /package/dist/{chunk-AOGTJ4EN.mjs.map → chunk-VMBRDEM2.mjs.map} +0 -0
- /package/dist/{chunk-VK4VQQYY.mjs.map → chunk-YNJ423BR.mjs.map} +0 -0
package/dist/donut-chart.js
CHANGED
@@ -24,9 +24,9 @@ __export(donut_chart_exports, {
|
|
24
24
|
DonutChart: () => DonutChart
|
25
25
|
});
|
26
26
|
module.exports = __toCommonJS(donut_chart_exports);
|
27
|
-
var
|
28
|
-
var
|
29
|
-
var
|
27
|
+
var import_core9 = require("@yamada-ui/core");
|
28
|
+
var import_utils10 = require("@yamada-ui/utils");
|
29
|
+
var import_react6 = require("react");
|
30
30
|
var import_recharts = require("recharts");
|
31
31
|
|
32
32
|
// src/chart-legend.tsx
|
@@ -143,6 +143,16 @@ var pieProperties = [
|
|
143
143
|
"onMouseEnter",
|
144
144
|
"onMouseLeave"
|
145
145
|
];
|
146
|
+
var labelProperties = [
|
147
|
+
"viewBox",
|
148
|
+
"formatter",
|
149
|
+
"value",
|
150
|
+
"position",
|
151
|
+
"offset",
|
152
|
+
"children",
|
153
|
+
"content",
|
154
|
+
"id"
|
155
|
+
];
|
146
156
|
|
147
157
|
// src/use-chart.ts
|
148
158
|
var [ChartProvider, useChartContext] = (0, import_utils2.createContext)({
|
@@ -230,18 +240,26 @@ var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
230
240
|
var ChartTooltip = (0, import_core4.forwardRef)(
|
231
241
|
({
|
232
242
|
label,
|
243
|
+
dataKey = "value",
|
233
244
|
className,
|
234
245
|
payload = [],
|
235
246
|
valueFormatter,
|
236
247
|
labelFormatter,
|
237
248
|
unit,
|
249
|
+
isRadialChart,
|
238
250
|
...rest
|
239
251
|
}, ref) => {
|
240
252
|
var _a;
|
241
253
|
const { styles } = useTooltip();
|
242
254
|
const items = payload.map(
|
243
|
-
({
|
255
|
+
({
|
256
|
+
color: colorProp,
|
257
|
+
name: nameProp,
|
258
|
+
[dataKey]: valueProp,
|
259
|
+
payload: payload2
|
260
|
+
} = {}, index) => {
|
244
261
|
var _a2;
|
262
|
+
const name = isRadialChart ? payload2 == null ? void 0 : payload2.name : nameProp;
|
245
263
|
const color = colorProp != null ? colorProp : payload2 == null ? void 0 : payload2.color;
|
246
264
|
let value;
|
247
265
|
if ((0, import_utils4.isArray)(valueProp)) {
|
@@ -307,17 +325,42 @@ var ChartTooltip = (0, import_core4.forwardRef)(
|
|
307
325
|
}
|
308
326
|
);
|
309
327
|
|
310
|
-
// src/use-chart-
|
328
|
+
// src/use-chart-label.ts
|
329
|
+
var import_core5 = require("@yamada-ui/core");
|
311
330
|
var import_utils5 = require("@yamada-ui/utils");
|
312
331
|
var import_react2 = require("react");
|
332
|
+
var useChartLabel = ({ styles, ...rest }) => {
|
333
|
+
var _a;
|
334
|
+
const { theme } = (0, import_core5.useTheme)();
|
335
|
+
const [labelProps, labelClassName] = getComponentProps(
|
336
|
+
[(_a = rest.labelProps) != null ? _a : {}, labelProperties],
|
337
|
+
styles.label
|
338
|
+
)(theme);
|
339
|
+
const getLabelProps = (0, import_react2.useCallback)(
|
340
|
+
({ className, ...props } = {}, ref = null) => {
|
341
|
+
return {
|
342
|
+
ref,
|
343
|
+
className: (0, import_utils5.cx)(className, labelClassName),
|
344
|
+
...props,
|
345
|
+
...labelProps
|
346
|
+
};
|
347
|
+
},
|
348
|
+
[labelClassName, labelProps]
|
349
|
+
);
|
350
|
+
return { getLabelProps };
|
351
|
+
};
|
352
|
+
|
353
|
+
// src/use-chart-legend.ts
|
354
|
+
var import_utils6 = require("@yamada-ui/utils");
|
355
|
+
var import_react3 = require("react");
|
313
356
|
var useChartLegend = ({
|
314
357
|
legendProps: _legendProps = {}
|
315
358
|
}) => {
|
316
|
-
const [rest, legendProps] = (0,
|
359
|
+
const [rest, legendProps] = (0, import_utils6.splitObject)(
|
317
360
|
_legendProps,
|
318
361
|
legendProperties
|
319
362
|
);
|
320
|
-
const getLegendProps = (0,
|
363
|
+
const getLegendProps = (0, import_react3.useCallback)(
|
321
364
|
(props, ref = null) => {
|
322
365
|
return {
|
323
366
|
ref,
|
@@ -332,31 +375,31 @@ var useChartLegend = ({
|
|
332
375
|
};
|
333
376
|
|
334
377
|
// src/use-chart-tooltip.ts
|
335
|
-
var
|
336
|
-
var
|
337
|
-
var
|
378
|
+
var import_core6 = require("@yamada-ui/core");
|
379
|
+
var import_utils7 = require("@yamada-ui/utils");
|
380
|
+
var import_react4 = require("react");
|
338
381
|
var useChartTooltip = ({
|
339
382
|
tooltipProps: _tooltipProps = {},
|
340
383
|
tooltipAnimationDuration = 0,
|
341
384
|
styles
|
342
385
|
}) => {
|
343
|
-
const { theme } = (0,
|
386
|
+
const { theme } = (0, import_core6.useTheme)();
|
344
387
|
const { cursor, ...rest } = _tooltipProps;
|
345
|
-
const cursorClassName = (0,
|
388
|
+
const cursorClassName = (0, import_react4.useMemo)(
|
346
389
|
() => getClassName({ ...styles.cursor, ...cursor })(theme),
|
347
390
|
[cursor, styles.cursor, theme]
|
348
391
|
);
|
349
|
-
const [tooltipProps, tooltipUIProps] = (0,
|
392
|
+
const [tooltipProps, tooltipUIProps] = (0, import_utils7.splitObject)(
|
350
393
|
rest,
|
351
394
|
tooltipProperties
|
352
395
|
);
|
353
|
-
const getTooltipProps = (0,
|
396
|
+
const getTooltipProps = (0, import_react4.useCallback)(
|
354
397
|
(props, ref = null) => ({
|
355
398
|
ref,
|
356
399
|
animationDuration: tooltipAnimationDuration,
|
357
400
|
isAnimationActive: (tooltipAnimationDuration || 0) > 0,
|
358
401
|
cursor: {
|
359
|
-
className: (0,
|
402
|
+
className: (0, import_utils7.cx)("ui-chart__cursor", cursorClassName)
|
360
403
|
},
|
361
404
|
...props,
|
362
405
|
...tooltipProps
|
@@ -367,13 +410,13 @@ var useChartTooltip = ({
|
|
367
410
|
};
|
368
411
|
|
369
412
|
// src/use-pie-chart.ts
|
370
|
-
var
|
371
|
-
var
|
372
|
-
var
|
413
|
+
var import_core8 = require("@yamada-ui/core");
|
414
|
+
var import_utils9 = require("@yamada-ui/utils");
|
415
|
+
var import_react5 = require("react");
|
373
416
|
|
374
417
|
// src/pie-chart-label.tsx
|
375
|
-
var
|
376
|
-
var
|
418
|
+
var import_core7 = require("@yamada-ui/core");
|
419
|
+
var import_utils8 = require("@yamada-ui/utils");
|
377
420
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
378
421
|
var RADIAN = Math.PI / 180;
|
379
422
|
var DEFAULT_LABEL_OFFSET = 22;
|
@@ -400,16 +443,16 @@ var pieChartLabel = ({
|
|
400
443
|
const displayLabel = () => {
|
401
444
|
if (isPercent) {
|
402
445
|
return parseFloat((percent * 100).toFixed(0)) > 0 && `${(percent * 100).toFixed(0)}%`;
|
403
|
-
} else if (!(0,
|
446
|
+
} else if (!(0, import_utils8.isUndefined)(labelFormatter)) {
|
404
447
|
return labelFormatter(value);
|
405
448
|
} else {
|
406
449
|
return value;
|
407
450
|
}
|
408
451
|
};
|
409
452
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
410
|
-
|
453
|
+
import_core7.ui.text,
|
411
454
|
{
|
412
|
-
className: (0,
|
455
|
+
className: (0, import_utils8.cx)(cellClassName, "ui-chart__label"),
|
413
456
|
x,
|
414
457
|
y,
|
415
458
|
textAnchor,
|
@@ -438,9 +481,9 @@ var pieChartLabelLine = ({
|
|
438
481
|
const y = cyProp + (middleRadius + labelOffset) * Math.sin(-midAngle * RADIAN);
|
439
482
|
const d = `M ${points[0].x} ${points[0].y} L ${x} ${y}`;
|
440
483
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
441
|
-
|
484
|
+
import_core7.ui.path,
|
442
485
|
{
|
443
|
-
className: (0,
|
486
|
+
className: (0, import_utils8.cx)(cellClassName, "ui-chart__label-line"),
|
444
487
|
d,
|
445
488
|
__css: styles,
|
446
489
|
...labelLineProps
|
@@ -467,8 +510,8 @@ var usePieChart = ({
|
|
467
510
|
...rest
|
468
511
|
}) => {
|
469
512
|
var _a, _b;
|
470
|
-
const { theme } = (0,
|
471
|
-
const [highlightedArea, setHighlightedArea] = (0,
|
513
|
+
const { theme } = (0, import_core8.useTheme)();
|
514
|
+
const [highlightedArea, setHighlightedArea] = (0, import_react5.useState)(null);
|
472
515
|
const shouldHighlight = highlightedArea !== null;
|
473
516
|
const { dimCell, ...computedCellProps } = (_a = rest.cellProps) != null ? _a : {};
|
474
517
|
const {
|
@@ -478,23 +521,22 @@ var usePieChart = ({
|
|
478
521
|
labelLine: labelLineProps,
|
479
522
|
...computedPieProps
|
480
523
|
} = (_b = rest.pieProps) != null ? _b : {};
|
481
|
-
const cellColors = (0,
|
524
|
+
const cellColors = (0, import_react5.useMemo)(
|
482
525
|
() => data.map(({ color }, index) => ({
|
483
|
-
__prefix: "ui",
|
484
526
|
name: `cell-${index}`,
|
485
527
|
token: "colors",
|
486
528
|
value: color != null ? color : "transparent"
|
487
529
|
})),
|
488
530
|
[data]
|
489
531
|
);
|
490
|
-
const pieVars = (0,
|
532
|
+
const pieVars = (0, import_react5.useMemo)(
|
491
533
|
() => [
|
492
534
|
...cellColors,
|
493
|
-
{
|
535
|
+
{ name: "fill-opacity", value: fillOpacity }
|
494
536
|
],
|
495
537
|
[fillOpacity, cellColors]
|
496
538
|
);
|
497
|
-
const [chartProps, chartClassName] = (0,
|
539
|
+
const [chartProps, chartClassName] = (0, import_react5.useMemo)(
|
498
540
|
() => {
|
499
541
|
var _a2;
|
500
542
|
return getComponentProps(
|
@@ -504,40 +546,40 @@ var usePieChart = ({
|
|
504
546
|
},
|
505
547
|
[rest.chartProps, styles.chart, theme]
|
506
548
|
);
|
507
|
-
const [pieProps, pieClassName] = (0,
|
549
|
+
const [pieProps, pieClassName] = (0, import_react5.useMemo)(
|
508
550
|
() => getComponentProps(
|
509
551
|
[computedPieProps, pieProperties],
|
510
552
|
styles.pie
|
511
553
|
)(theme),
|
512
554
|
[computedPieProps, styles.pie, theme]
|
513
555
|
);
|
514
|
-
const cellClassName = (0,
|
556
|
+
const cellClassName = (0, import_react5.useMemo)(() => {
|
515
557
|
const resolvedCellProps = {
|
516
|
-
fillOpacity: "
|
558
|
+
fillOpacity: "$fill-opacity",
|
517
559
|
...styles.cell,
|
518
560
|
...computedCellProps
|
519
561
|
};
|
520
562
|
return getClassName(resolvedCellProps)(theme);
|
521
563
|
}, [computedCellProps, styles.cell, theme]);
|
522
|
-
const dimCellClassName = (0,
|
564
|
+
const dimCellClassName = (0, import_react5.useMemo)(() => {
|
523
565
|
const resolvedDimCell = { ...styles.dimCell, ...dimCell };
|
524
566
|
return getClassName(resolvedDimCell)(theme);
|
525
567
|
}, [dimCell, styles.dimCell, theme]);
|
526
|
-
const activeShapeProps = (0,
|
568
|
+
const activeShapeProps = (0, import_react5.useMemo)(
|
527
569
|
() => getComponentProps(
|
528
570
|
[activeShape, pieProperties],
|
529
571
|
styles.activeShape
|
530
572
|
)(theme, true),
|
531
573
|
[activeShape, styles.activeShape, theme]
|
532
574
|
);
|
533
|
-
const inactiveShapeProps = (0,
|
575
|
+
const inactiveShapeProps = (0, import_react5.useMemo)(
|
534
576
|
() => getComponentProps(
|
535
577
|
[inactiveShape, pieProperties],
|
536
578
|
styles.inactiveShape
|
537
579
|
)(theme, true),
|
538
580
|
[inactiveShape, styles.inactiveShape, theme]
|
539
581
|
);
|
540
|
-
const label = (0,
|
582
|
+
const label = (0, import_react5.useCallback)(
|
541
583
|
(props) => pieChartLabel({
|
542
584
|
labelOffset,
|
543
585
|
isPercent,
|
@@ -548,7 +590,7 @@ var usePieChart = ({
|
|
548
590
|
}),
|
549
591
|
[isPercent, labelOffset, labelProps, styles.label, labelFormatter]
|
550
592
|
);
|
551
|
-
const labelLine = (0,
|
593
|
+
const labelLine = (0, import_react5.useCallback)(
|
552
594
|
(props) => {
|
553
595
|
return pieChartLabelLine({
|
554
596
|
labelOffset,
|
@@ -559,10 +601,10 @@ var usePieChart = ({
|
|
559
601
|
},
|
560
602
|
[labelLineProps, labelOffset, styles.labelLine]
|
561
603
|
);
|
562
|
-
const cellPropList = (0,
|
604
|
+
const cellPropList = (0, import_react5.useMemo)(
|
563
605
|
() => data.map((props, index) => {
|
564
606
|
const { name, dimCell: dimCell2 = {}, ...computedProps } = props;
|
565
|
-
const color = `
|
607
|
+
const color = (0, import_core8.getVar)(`cell-${index}`)(theme);
|
566
608
|
const dimmed = shouldHighlight && highlightedArea !== name;
|
567
609
|
const resolvedProps = {
|
568
610
|
...computedProps,
|
@@ -589,19 +631,19 @@ var usePieChart = ({
|
|
589
631
|
theme
|
590
632
|
]
|
591
633
|
);
|
592
|
-
const getPieChartProps = (0,
|
634
|
+
const getPieChartProps = (0, import_react5.useCallback)(
|
593
635
|
({ className, ...props } = {}, ref = null) => ({
|
594
636
|
ref,
|
595
|
-
className: (0,
|
637
|
+
className: (0, import_utils9.cx)(className, chartClassName),
|
596
638
|
...props,
|
597
639
|
...chartProps
|
598
640
|
}),
|
599
641
|
[chartProps, chartClassName]
|
600
642
|
);
|
601
|
-
const getPieProps = (0,
|
643
|
+
const getPieProps = (0, import_react5.useCallback)(
|
602
644
|
({ className, ...props }, ref = null) => ({
|
603
645
|
ref,
|
604
|
-
className: (0,
|
646
|
+
className: (0, import_utils9.cx)(className, pieClassName),
|
605
647
|
dataKey: "value",
|
606
648
|
data,
|
607
649
|
rootTabIndex: -1,
|
@@ -635,12 +677,12 @@ var usePieChart = ({
|
|
635
677
|
pieProps
|
636
678
|
]
|
637
679
|
);
|
638
|
-
const getCellProps = (0,
|
680
|
+
const getCellProps = (0, import_react5.useCallback)(
|
639
681
|
({ index, className: classNameProp, ...props }, ref = null) => {
|
640
682
|
const { className, color } = cellPropList[index];
|
641
683
|
return {
|
642
684
|
ref,
|
643
|
-
className: (0,
|
685
|
+
className: (0, import_utils9.cx)(classNameProp, className),
|
644
686
|
fill: color,
|
645
687
|
stroke: color,
|
646
688
|
strokeWidth,
|
@@ -660,8 +702,8 @@ var usePieChart = ({
|
|
660
702
|
|
661
703
|
// src/donut-chart.tsx
|
662
704
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
663
|
-
var DonutChart = (0,
|
664
|
-
const [styles, mergedProps] = (0,
|
705
|
+
var DonutChart = (0, import_core9.forwardRef)((props, ref) => {
|
706
|
+
const [styles, mergedProps] = (0, import_core9.useMultiComponentStyle)("DonutChart", props);
|
665
707
|
const {
|
666
708
|
className,
|
667
709
|
data,
|
@@ -688,8 +730,9 @@ var DonutChart = (0, import_core8.forwardRef)((props, ref) => {
|
|
688
730
|
outerRadius,
|
689
731
|
strokeWidth,
|
690
732
|
legendProps,
|
733
|
+
labelProps,
|
691
734
|
...rest
|
692
|
-
} = (0,
|
735
|
+
} = (0, import_core9.omitThemeProps)(mergedProps);
|
693
736
|
const {
|
694
737
|
pieVars,
|
695
738
|
getPieProps,
|
@@ -723,7 +766,8 @@ var DonutChart = (0, import_core8.forwardRef)((props, ref) => {
|
|
723
766
|
const { legendProps: computedLegendProps, getLegendProps } = useChartLegend({
|
724
767
|
legendProps
|
725
768
|
});
|
726
|
-
const
|
769
|
+
const { getLabelProps } = useChartLabel({ labelProps, styles });
|
770
|
+
const cells = (0, import_react6.useMemo)(
|
727
771
|
() => data.map(({ name }, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
728
772
|
import_recharts.Cell,
|
729
773
|
{
|
@@ -734,12 +778,11 @@ var DonutChart = (0, import_core8.forwardRef)((props, ref) => {
|
|
734
778
|
[data, getCellProps]
|
735
779
|
);
|
736
780
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ChartProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
737
|
-
|
781
|
+
import_core9.ui.div,
|
738
782
|
{
|
739
783
|
ref,
|
740
|
-
className: (0,
|
741
|
-
|
742
|
-
__css: { ...styles.container },
|
784
|
+
className: (0, import_utils10.cx)("ui-donut-chart", className),
|
785
|
+
__css: { maxW: "full", vars: pieVars, ...styles.container },
|
743
786
|
...rest,
|
744
787
|
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
745
788
|
import_recharts.ResponsiveContainer,
|
@@ -750,13 +793,21 @@ var DonutChart = (0, import_core8.forwardRef)((props, ref) => {
|
|
750
793
|
{
|
751
794
|
...getPieChartProps({ className: "ui-donut-chart__chart" }),
|
752
795
|
children: [
|
753
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.
|
796
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
754
797
|
import_recharts.Pie,
|
755
798
|
{
|
756
799
|
...getPieProps({
|
757
800
|
className: "ui-donut-chart__donut"
|
758
801
|
}),
|
759
|
-
children:
|
802
|
+
children: [
|
803
|
+
cells,
|
804
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
805
|
+
import_recharts.Label,
|
806
|
+
{
|
807
|
+
...getLabelProps({ className: "ui-donut-chart__label" })
|
808
|
+
}
|
809
|
+
)
|
810
|
+
]
|
760
811
|
}
|
761
812
|
),
|
762
813
|
withLegend ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|