@yamada-ui/charts 2.0.0-next-20240706053520 → 2.0.0-next-20240713062626

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. package/dist/area-chart.js +5 -1
  2. package/dist/area-chart.js.map +1 -1
  3. package/dist/area-chart.mjs +2 -2
  4. package/dist/chart.types.d.mts +2 -2
  5. package/dist/chart.types.d.ts +2 -2
  6. package/dist/chart.types.js.map +1 -1
  7. package/dist/{chunk-HZSEVGCR.mjs → chunk-6BNJZIBK.mjs} +6 -2
  8. package/dist/chunk-6BNJZIBK.mjs.map +1 -0
  9. package/dist/{chunk-XZVWGY4J.mjs → chunk-6L73M52L.mjs} +6 -2
  10. package/dist/chunk-6L73M52L.mjs.map +1 -0
  11. package/dist/{chunk-OSSQ2IHJ.mjs → chunk-CCFQC3T6.mjs} +2 -2
  12. package/dist/{chunk-B7M3YMES.mjs → chunk-CIRGC4FT.mjs} +6 -2
  13. package/dist/chunk-CIRGC4FT.mjs.map +1 -0
  14. package/dist/chunk-CPXE3PV4.mjs +84 -0
  15. package/dist/chunk-CPXE3PV4.mjs.map +1 -0
  16. package/dist/{chunk-YGKNNA34.mjs → chunk-ELXW3EQE.mjs} +35 -19
  17. package/dist/chunk-ELXW3EQE.mjs.map +1 -0
  18. package/dist/{chunk-K6OUXJQK.mjs → chunk-KPKLW25H.mjs} +2 -2
  19. package/dist/{chunk-P4MMHTAP.mjs → chunk-VVR3DSUX.mjs} +8 -5
  20. package/dist/chunk-VVR3DSUX.mjs.map +1 -0
  21. package/dist/{chunk-DWLZIGGL.mjs → chunk-X7MOM6U4.mjs} +2 -2
  22. package/dist/{chunk-F2RBOLDY.mjs → chunk-XORRW2KT.mjs} +8 -5
  23. package/dist/chunk-XORRW2KT.mjs.map +1 -0
  24. package/dist/donut-chart.js +137 -43
  25. package/dist/donut-chart.js.map +1 -1
  26. package/dist/donut-chart.mjs +3 -2
  27. package/dist/index.js +176 -67
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +10 -9
  30. package/dist/line-chart.js +5 -1
  31. package/dist/line-chart.js.map +1 -1
  32. package/dist/line-chart.mjs +2 -2
  33. package/dist/pie-chart-label.d.mts +40 -0
  34. package/dist/pie-chart-label.d.ts +40 -0
  35. package/dist/pie-chart-label.js +108 -0
  36. package/dist/pie-chart-label.js.map +1 -0
  37. package/dist/pie-chart-label.mjs +10 -0
  38. package/dist/pie-chart-label.mjs.map +1 -0
  39. package/dist/pie-chart.js +137 -43
  40. package/dist/pie-chart.js.map +1 -1
  41. package/dist/pie-chart.mjs +3 -2
  42. package/dist/radar-chart.js +5 -1
  43. package/dist/radar-chart.js.map +1 -1
  44. package/dist/radar-chart.mjs +2 -2
  45. package/dist/use-area-chart.js +5 -1
  46. package/dist/use-area-chart.js.map +1 -1
  47. package/dist/use-area-chart.mjs +1 -1
  48. package/dist/use-line-chart.js +5 -1
  49. package/dist/use-line-chart.js.map +1 -1
  50. package/dist/use-line-chart.mjs +1 -1
  51. package/dist/use-pie-chart.d.mts +12 -5
  52. package/dist/use-pie-chart.d.ts +12 -5
  53. package/dist/use-pie-chart.js +113 -24
  54. package/dist/use-pie-chart.js.map +1 -1
  55. package/dist/use-pie-chart.mjs +2 -1
  56. package/dist/use-radar-chart.js +5 -1
  57. package/dist/use-radar-chart.js.map +1 -1
  58. package/dist/use-radar-chart.mjs +1 -1
  59. package/package.json +2 -2
  60. package/dist/chunk-B7M3YMES.mjs.map +0 -1
  61. package/dist/chunk-F2RBOLDY.mjs.map +0 -1
  62. package/dist/chunk-HZSEVGCR.mjs.map +0 -1
  63. package/dist/chunk-P4MMHTAP.mjs.map +0 -1
  64. package/dist/chunk-XZVWGY4J.mjs.map +0 -1
  65. package/dist/chunk-YGKNNA34.mjs.map +0 -1
  66. /package/dist/{chunk-OSSQ2IHJ.mjs.map → chunk-CCFQC3T6.mjs.map} +0 -0
  67. /package/dist/{chunk-K6OUXJQK.mjs.map → chunk-KPKLW25H.mjs.map} +0 -0
  68. /package/dist/{chunk-DWLZIGGL.mjs.map → chunk-X7MOM6U4.mjs.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  useRadarChart
4
- } from "./chunk-B7M3YMES.mjs";
4
+ } from "./chunk-CIRGC4FT.mjs";
5
5
  import {
6
6
  useChartLegend
7
7
  } from "./chunk-5Q6O726L.mjs";
@@ -203,4 +203,4 @@ var RadarChart = forwardRef((props, ref) => {
203
203
  export {
204
204
  RadarChart
205
205
  };
206
- //# sourceMappingURL=chunk-OSSQ2IHJ.mjs.map
206
+ //# sourceMappingURL=chunk-CCFQC3T6.mjs.map
@@ -179,7 +179,11 @@ var useRadarChart = ({
179
179
  activeDotClassName
180
180
  )(theme);
181
181
  resolvedActiveDot = {
182
- className: cx("ui-radar-chart__active-dot", className),
182
+ className: cx(
183
+ "ui-radar-chart__dot",
184
+ "ui-radar-chart__dot--active",
185
+ className
186
+ ),
183
187
  fill: color,
184
188
  stroke: color,
185
189
  r: 4,
@@ -336,4 +340,4 @@ var useRadarChart = ({
336
340
  export {
337
341
  useRadarChart
338
342
  };
339
- //# sourceMappingURL=chunk-B7M3YMES.mjs.map
343
+ //# sourceMappingURL=chunk-CIRGC4FT.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/use-radar-chart.ts"],"sourcesContent":["import { useTheme } from \"@yamada-ui/core\"\nimport type { CSSUIObject, 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 ChartPropGetter,\n PolarAngleAxisProps,\n PolarGridProps,\n PolarRadiusAxisProps,\n RadarChartProps,\n RadarProps,\n RequiredChartPropGetter,\n} from \"./chart.types\"\nimport {\n dotProperties,\n polarAngleAxisProperties,\n polarGridProperties,\n polarRadiusAxisProperties,\n radarChartProperties,\n radarProperties,\n} from \"./rechart-properties\"\n\nexport type UseRadarChartOptions = {\n /**\n * Chart data.\n */\n data: Dict[]\n /**\n * An array of objects with `dataKey` and `color` keys. Determines which data should be consumed from the `data` array.\n */\n series: RadarProps[]\n /**\n * The key of a group of data which should be unique in an chart.\n */\n dataKey: string\n /**\n * Props for the radar.\n */\n radarProps?: Partial<RadarProps>\n /**\n * Props passed down to recharts `RadarChart` component.\n */\n chartProps?: RadarChartProps\n /**\n * Props passed down to recharts `PolarGrid` component.\n */\n polarGridProps?: PolarGridProps\n /**\n * Props passed down to recharts `PolarAngleAxis` component.\n */\n polarAngleAxisProps?: PolarAngleAxisProps\n /**\n * Props passed down to recharts `tick` of `PolarAngleAxis` component.\n */\n polarAngleAxisTickProps?: CSSUIProps\n /**\n * Props passed down to recharts `PolarRadiusAxis` component.\n */\n polarRadiusAxisProps?: PolarRadiusAxisProps\n /**\n * Props passed down to recharts `tick` of `PolarRadiusAxis` component.\n */\n polarRadiusAxisTickProps?: CSSUIProps\n /**\n * Determines whether dots should be displayed.\n *\n * @default false\n */\n withDots?: boolean\n /**\n * Determines whether activeDots should be displayed.\n *\n * @default true\n */\n withActiveDots?: boolean\n /**\n * Stroke width for the chart radars.\n *\n * @default 2\n */\n strokeWidth?: number\n /**\n * Controls fill opacity of all radars.\n *\n * @default 1\n */\n fillOpacity?: number | [number, number]\n /**\n * A function to format values on Y axis and inside the tooltip.\n */\n valueFormatter?: (value: number) => string\n /**\n * 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.\n */\n strokeDasharray?: string | number\n}\n\ntype UseRadarChartProps = UseRadarChartOptions & {\n styles: Dict<CSSUIObject>\n}\n\nexport const useRadarChart = ({\n data,\n series,\n dataKey,\n withDots = false,\n withActiveDots = false,\n strokeWidth = 2,\n fillOpacity = 0.4,\n valueFormatter,\n strokeDasharray,\n styles,\n ...rest\n}: UseRadarChartProps) => {\n const { theme } = useTheme()\n const [highlightedArea, setHighlightedArea] = useState<string | null>(null)\n const shouldHighlight = highlightedArea !== null\n const {\n dot = {},\n activeDot = {},\n dimDot = {},\n dimRadar = {},\n ...computedRadarProps\n } = rest.radarProps ?? {}\n\n const radarColors: CSSUIProps[\"var\"] = useMemo(\n () =>\n series.map(({ color }, index) => ({\n __prefix: \"ui\",\n name: `radar-${index}`,\n token: \"colors\",\n value: color ?? \"transparent\",\n })),\n [series],\n )\n\n const radarVars: CSSUIProps[\"var\"] = useMemo(\n () =>\n [\n ...radarColors,\n { __prefix: \"ui\", name: \"fill-opacity\", value: fillOpacity },\n ] as Required<CSSUIProps>[\"var\"],\n [fillOpacity, radarColors],\n )\n\n const [chartProps, radarChartClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [rest.chartProps ?? {}, radarChartProperties],\n styles.chart,\n )(theme),\n [rest.chartProps, styles.chart, theme],\n )\n\n const [polarGridProps, polarGridClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [rest.polarGridProps ?? {}, polarGridProperties],\n styles.polarGrid,\n )(theme),\n [rest.polarGridProps, styles.polarGrid, theme],\n )\n\n const [polarAngleAxisProps, polarAngleAxisClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [rest.polarAngleAxisProps ?? {}, polarAngleAxisProperties],\n styles.polarAngleAxis,\n )(theme),\n [rest.polarAngleAxisProps, styles.polarAngleAxis, theme],\n )\n\n const polarAngleAxisTickClassName = useMemo(\n () =>\n getClassName({\n ...styles.polarAngleAxisTick,\n ...rest.polarAngleAxisTickProps,\n })(theme),\n [rest.polarAngleAxisTickProps, styles.polarAngleAxisTick, theme],\n )\n\n const [polarRadiusAxisProps, polarRadiusAxisClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [rest.polarRadiusAxisProps ?? {}, polarRadiusAxisProperties],\n styles.polarRadiusAxis,\n )(theme),\n [rest.polarRadiusAxisProps, styles.polarRadiusAxis, theme],\n )\n\n const polarRadiusAxisTickClassName = useMemo(\n () =>\n getClassName({\n ...styles.polarRadiusAxisTick,\n ...rest.polarRadiusAxisTickProps,\n })(theme),\n [rest.polarRadiusAxisTickProps, styles.polarRadiusAxisTick, theme],\n )\n\n const [radarProps, radarClassName] = useMemo(() => {\n const resolvedRadarProps = {\n fillOpacity: \"var(--ui-fill-opacity)\",\n ...computedRadarProps,\n }\n\n return getComponentProps<Dict, string>(\n [resolvedRadarProps, radarProperties],\n styles.radar,\n )(theme)\n }, [computedRadarProps, styles.radar, theme])\n\n const [dimRadarProps, dimRadarClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [dimRadar, radarProperties],\n styles.dimRadar,\n )(theme),\n [dimRadar, styles.dimRadar, theme],\n )\n\n const [dotProps, dotClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>([dot, dotProperties], styles.dot)(theme),\n [dot, styles.dot, theme],\n )\n\n const [activeDotProps, activeDotClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [activeDot, dotProperties],\n styles.activeDot,\n )(theme),\n [activeDot, styles.activeDot, theme],\n )\n\n const [dimDotProps, dimDotClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [dimDot, dotProperties],\n styles.dimDot,\n )(theme),\n [dimDot, styles.dimDot, theme],\n )\n\n const radarPropList = useMemo(\n () =>\n series.map((props, index) => {\n const {\n dataKey,\n dot = {},\n activeDot = {},\n dimDot = {},\n dimRadar = {},\n ...computedProps\n } = props\n const color = `var(--ui-radar-${index})`\n const dimmed = shouldHighlight && highlightedArea !== dataKey\n const computedDimRadar = { ...dimRadarProps, ...dimRadar }\n\n const resolvedProps = {\n ...radarProps,\n ...computedProps,\n ...(dimmed ? computedDimRadar : {}),\n }\n const rest = getComponentProps<Dict, string>(\n [resolvedProps, radarProperties],\n radarClassName,\n dimmed ? dimRadarClassName : undefined,\n )(theme, true)\n\n let resolvedActiveDot: Recharts.DotProps | boolean\n\n if (withActiveDots) {\n const computedActiveDot = {\n ...activeDotProps,\n ...activeDot,\n }\n\n const [rest, className] = getComponentProps<Dict, string>(\n [computedActiveDot, dotProperties],\n activeDotClassName,\n )(theme)\n\n resolvedActiveDot = {\n className: cx(\n \"ui-radar-chart__dot\",\n \"ui-radar-chart__dot--active\",\n className,\n ),\n fill: color,\n stroke: color,\n r: 4,\n ...rest,\n } as Recharts.DotProps\n } else {\n resolvedActiveDot = false\n }\n\n let resolvedDot: Recharts.DotProps | boolean\n\n if (withDots) {\n const computedDimDot = { ...dimDotProps, ...dimDot }\n const computedDot = {\n ...dotProps,\n ...dot,\n ...(dimmed ? computedDimDot : {}),\n }\n\n const [rest, className] = getComponentProps(\n [computedDot, dotProperties],\n dotClassName,\n dimmed ? dimDotClassName : undefined,\n )(theme)\n\n resolvedDot = {\n className: cx(\"ui-radar-chart__dot\", className),\n fill: color,\n r: 4,\n ...rest,\n } as Recharts.DotProps\n } else {\n resolvedDot = false\n }\n\n return {\n ...rest,\n color,\n dataKey,\n dot: resolvedDot,\n activeDot: resolvedActiveDot,\n }\n }),\n [\n activeDotClassName,\n activeDotProps,\n dimDotClassName,\n dimDotProps,\n dimRadarClassName,\n dimRadarProps,\n dotClassName,\n dotProps,\n highlightedArea,\n radarClassName,\n radarProps,\n series,\n shouldHighlight,\n theme,\n withActiveDots,\n withDots,\n ],\n )\n\n const getRadarChartProps: ChartPropGetter<\n \"div\",\n ComponentPropsWithoutRef<typeof Recharts.RadarChart>,\n ComponentPropsWithoutRef<typeof Recharts.RadarChart>\n > = useCallback(\n ({ className, ...props } = {}, ref = null) => ({\n ref,\n className: cx(className, radarChartClassName),\n data,\n ...props,\n ...chartProps,\n }),\n [data, radarChartClassName, chartProps],\n )\n\n const getRadarProps: RequiredChartPropGetter<\n \"div\",\n { index: number },\n Omit<Recharts.RadarProps, \"ref\">\n > = useCallback(\n ({ index, className: classNameProp, ...props }, ref = null) => {\n const { color, className, dataKey, activeDot, dot, ...rest } =\n radarPropList[index]\n\n return {\n ref,\n className: cx(classNameProp, className),\n activeDot,\n dot,\n name: dataKey as string,\n dataKey,\n fill: color,\n strokeWidth,\n stroke: color,\n isAnimationActive: false,\n ...(props as Omit<Recharts.RadarProps, \"dataKey\">),\n ...rest,\n }\n },\n [radarPropList, strokeWidth],\n )\n\n const getPolarGridProps: ChartPropGetter<\n \"div\",\n Recharts.PolarGridProps,\n Recharts.PolarGridProps\n > = useCallback(\n ({ className, ...props } = {}, ref = null) => ({\n ref,\n className: cx(className, polarGridClassName),\n strokeDasharray,\n ...props,\n ...polarGridProps,\n }),\n [polarGridClassName, polarGridProps, strokeDasharray],\n )\n\n const getPolarAngleAxisProps: ChartPropGetter<\n \"div\",\n Recharts.PolarAngleAxisProps,\n Omit<Recharts.PolarAngleAxisProps, \"ref\">\n > = useCallback(\n ({ className, ...props } = {}, ref = null) => ({\n ref,\n className: cx(className, polarAngleAxisClassName),\n dataKey,\n tick: {\n className: cx(\n \"ui-radar-chart__polar-angle-axis-tick\",\n polarAngleAxisTickClassName,\n ),\n },\n tickFormatter: valueFormatter,\n tickSize: 16,\n ...props,\n ...polarAngleAxisProps,\n }),\n [\n dataKey,\n polarAngleAxisClassName,\n polarAngleAxisProps,\n polarAngleAxisTickClassName,\n valueFormatter,\n ],\n )\n\n const getPolarRadiusAxisProps: ChartPropGetter<\n \"div\",\n Recharts.PolarRadiusAxisProps,\n Omit<Recharts.PolarRadiusAxisProps, \"ref\">\n > = useCallback(\n ({ className, ...props } = {}, ref = null) => ({\n ref,\n className: cx(className, polarRadiusAxisClassName),\n tick: {\n className: cx(\n \"ui-radar-chart__polar-radius-axis-tick\",\n polarRadiusAxisTickClassName,\n ),\n },\n tickFormatter: valueFormatter,\n ...props,\n ...polarRadiusAxisProps,\n }),\n [\n polarRadiusAxisClassName,\n polarRadiusAxisProps,\n polarRadiusAxisTickClassName,\n valueFormatter,\n ],\n )\n\n return {\n radarVars,\n getRadarChartProps,\n getRadarProps,\n getPolarGridProps,\n getPolarAngleAxisProps,\n getPolarRadiusAxisProps,\n setHighlightedArea,\n }\n}\n\nexport type UseRadarChartReturn = ReturnType<typeof useRadarChart>\n"],"mappings":";;;;;;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AAE,WAAW,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,UAAU;AAAA,MAC7C;AAAA,MACA,WAAW,GAAG,WAAW,uBAAuB;AAAA,MAChD;AAAA,MACA,MAAM;AAAA,QACJ,WAAW;AAAA,UACT;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,MACA,eAAe;AAAA,MACf,UAAU;AAAA,MACV,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,0BAIF;AAAA,IACF,CAAC,EAAE,WAAW,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,UAAU;AAAA,MAC7C;AAAA,MACA,WAAW,GAAG,WAAW,wBAAwB;AAAA,MACjD,MAAM;AAAA,QACJ,WAAW;AAAA,UACT;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,MACA,eAAe;AAAA,MACf,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["_a","dataKey","dot","activeDot","dimDot","dimRadar","rest"]}
@@ -0,0 +1,84 @@
1
+ "use client"
2
+
3
+ // src/pie-chart-label.tsx
4
+ import { ui } from "@yamada-ui/core";
5
+ import { cx, isUndefined } from "@yamada-ui/utils";
6
+ import { jsx } from "react/jsx-runtime";
7
+ var RADIAN = Math.PI / 180;
8
+ var DEFAULT_LABEL_OFFSET = 22;
9
+ var pieChartLabel = ({
10
+ className: cellClassName,
11
+ cx: cxProp = 0,
12
+ cy: cyProp = 0,
13
+ midAngle = 0,
14
+ innerRadius = 0,
15
+ outerRadius = 0,
16
+ middleRadius = 0,
17
+ percent = 0,
18
+ value = 0,
19
+ labelOffset: labelOffsetProp,
20
+ isParcent,
21
+ labelProps,
22
+ valueFormatter,
23
+ styles
24
+ }) => {
25
+ const labelOffset = labelOffsetProp != null ? labelOffsetProp : (outerRadius - innerRadius) * 0.5 + DEFAULT_LABEL_OFFSET;
26
+ const x = cxProp + (middleRadius + labelOffset) * Math.cos(-midAngle * RADIAN);
27
+ const y = cyProp + (middleRadius + labelOffset) * Math.sin(-midAngle * RADIAN);
28
+ const textAnchor = x > cxProp ? "start" : x < cxProp ? "end" : "middle";
29
+ const displayLabel = () => {
30
+ if (isParcent) {
31
+ return parseFloat((percent * 100).toFixed(0)) > 0 && `${(percent * 100).toFixed(0)}%`;
32
+ } else if (!isUndefined(valueFormatter)) {
33
+ return valueFormatter(value);
34
+ } else {
35
+ return value;
36
+ }
37
+ };
38
+ return /* @__PURE__ */ jsx(
39
+ ui.text,
40
+ {
41
+ className: cx(cellClassName, "ui-chart__label"),
42
+ x,
43
+ y,
44
+ textAnchor,
45
+ dominantBaseline: "central",
46
+ __css: styles,
47
+ ...labelProps,
48
+ children: displayLabel()
49
+ }
50
+ );
51
+ };
52
+ var pieChartLabelLine = ({
53
+ className: cellClassName,
54
+ cx: cxProp = 0,
55
+ cy: cyProp = 0,
56
+ innerRadius = 0,
57
+ midAngle = 0,
58
+ middleRadius = 0,
59
+ outerRadius = 0,
60
+ points = [{ x: 0, y: 0 }],
61
+ labelOffset: labelOffsetProp,
62
+ labelLineProps,
63
+ styles
64
+ }) => {
65
+ const labelOffset = labelOffsetProp != null ? labelOffsetProp : (outerRadius - innerRadius) * 0.5 + DEFAULT_LABEL_OFFSET;
66
+ const x = cxProp + (middleRadius + labelOffset) * Math.cos(-midAngle * RADIAN);
67
+ const y = cyProp + (middleRadius + labelOffset) * Math.sin(-midAngle * RADIAN);
68
+ const d = `M ${points[0].x} ${points[0].y} L ${x} ${y}`;
69
+ return /* @__PURE__ */ jsx(
70
+ ui.path,
71
+ {
72
+ className: cx(cellClassName, "ui-chart__label-line"),
73
+ d,
74
+ __css: styles,
75
+ ...labelLineProps
76
+ }
77
+ );
78
+ };
79
+
80
+ export {
81
+ pieChartLabel,
82
+ pieChartLabelLine
83
+ };
84
+ //# sourceMappingURL=chunk-CPXE3PV4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/pie-chart-label.tsx"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps } from \"@yamada-ui/core\"\nimport { ui } from \"@yamada-ui/core\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport { cx, isUndefined } from \"@yamada-ui/utils\"\n\nconst RADIAN = Math.PI / 180\nconst DEFAULT_LABEL_OFFSET = 22\n\nexport type PieChartLabelProps = {\n className?: string\n cx?: number\n cy?: number\n midAngle?: number\n innerRadius?: number\n outerRadius?: number\n middleRadius?: number\n percent?: number\n value?: number\n labelOffset?: number\n isParcent?: boolean\n labelProps?: HTMLUIProps<\"text\">\n valueFormatter?: (value: number) => string\n styles: Dict<CSSUIObject>\n}\n\nexport const pieChartLabel: (props: PieChartLabelProps) => React.ReactNode = ({\n className: cellClassName,\n cx: cxProp = 0,\n cy: cyProp = 0,\n midAngle = 0,\n innerRadius = 0,\n outerRadius = 0,\n middleRadius = 0,\n percent = 0,\n value = 0,\n labelOffset: labelOffsetProp,\n isParcent,\n labelProps,\n valueFormatter,\n styles,\n}) => {\n const labelOffset =\n labelOffsetProp ?? (outerRadius - innerRadius) * 0.5 + DEFAULT_LABEL_OFFSET\n\n const x = cxProp + (middleRadius + labelOffset) * Math.cos(-midAngle * RADIAN)\n const y = cyProp + (middleRadius + labelOffset) * Math.sin(-midAngle * RADIAN)\n\n const textAnchor = x > cxProp ? \"start\" : x < cxProp ? \"end\" : \"middle\"\n const displayLabel = () => {\n if (isParcent) {\n return (\n parseFloat((percent * 100).toFixed(0)) > 0 &&\n `${(percent * 100).toFixed(0)}%`\n )\n } else if (!isUndefined(valueFormatter)) {\n return valueFormatter(value)\n } else {\n return value\n }\n }\n\n return (\n <ui.text\n className={cx(cellClassName, \"ui-chart__label\")}\n x={x}\n y={y}\n textAnchor={textAnchor}\n dominantBaseline=\"central\"\n __css={styles}\n {...labelProps}\n >\n {displayLabel()}\n </ui.text>\n )\n}\n\ntype Point = { x: number; y: number }\n\nexport type PieChartLabelLineProps = {\n className?: string\n cx?: number\n cy?: number\n innerRadius?: number\n midAngle?: number\n middleRadius?: number\n outerRadius?: number\n points?: Array<Point>\n labelOffset?: number\n labelLineProps?: HTMLUIProps<\"path\">\n styles: Dict<CSSUIObject>\n}\n\nexport const pieChartLabelLine: (\n props: PieChartLabelLineProps,\n) => React.ReactElement<SVGElement> = ({\n className: cellClassName,\n cx: cxProp = 0,\n cy: cyProp = 0,\n innerRadius = 0,\n midAngle = 0,\n middleRadius = 0,\n outerRadius = 0,\n points = [{ x: 0, y: 0 }],\n labelOffset: labelOffsetProp,\n labelLineProps,\n styles,\n}) => {\n const labelOffset =\n labelOffsetProp ?? (outerRadius - innerRadius) * 0.5 + DEFAULT_LABEL_OFFSET\n\n const x = cxProp + (middleRadius + labelOffset) * Math.cos(-midAngle * RADIAN)\n const y = cyProp + (middleRadius + labelOffset) * Math.sin(-midAngle * RADIAN)\n\n const d: string = `M ${points[0].x} ${points[0].y} L ${x} ${y}`\n\n return (\n <ui.path\n className={cx(cellClassName, \"ui-chart__label-line\")}\n d={d}\n __css={styles}\n {...labelLineProps}\n />\n )\n}\n"],"mappings":";;;AACA,SAAS,UAAU;AAEnB,SAAS,IAAI,mBAAmB;AA2D5B;AAzDJ,IAAM,SAAS,KAAK,KAAK;AACzB,IAAM,uBAAuB;AAmBtB,IAAM,gBAAgE,CAAC;AAAA,EAC5E,WAAW;AAAA,EACX,IAAI,SAAS;AAAA,EACb,IAAI,SAAS;AAAA,EACb,WAAW;AAAA,EACX,cAAc;AAAA,EACd,cAAc;AAAA,EACd,eAAe;AAAA,EACf,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,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AAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;AAE7D,SACE;AAAA,IAAC,GAAG;AAAA,IAAH;AAAA,MACC,WAAW,GAAG,eAAe,sBAAsB;AAAA,MACnD;AAAA,MACA,OAAO;AAAA,MACN,GAAG;AAAA;AAAA,EACN;AAEJ;","names":[]}
@@ -1,4 +1,8 @@
1
1
  "use client"
2
+ import {
3
+ pieChartLabel,
4
+ pieChartLabelLine
5
+ } from "./chunk-CPXE3PV4.mjs";
2
6
  import {
3
7
  pieChartProperties,
4
8
  pieProperties
@@ -16,6 +20,8 @@ var usePieChart = ({
16
20
  data,
17
21
  withLabels = false,
18
22
  withLabelLines = false,
23
+ labelOffset,
24
+ isParcent = false,
19
25
  strokeWidth = 1,
20
26
  fillOpacity = 1,
21
27
  innerRadius = "0%",
@@ -23,6 +29,7 @@ var usePieChart = ({
23
29
  paddingAngle = 0,
24
30
  startAngle = 90,
25
31
  endAngle = -270,
32
+ valueFormatter,
26
33
  styles,
27
34
  ...rest
28
35
  }) => {
@@ -34,8 +41,8 @@ var usePieChart = ({
34
41
  const {
35
42
  activeShape = {},
36
43
  inactiveShape = {},
37
- label,
38
- labelLine,
44
+ label: labelProps,
45
+ labelLine: labelLineProps,
39
46
  ...computedPieProps
40
47
  } = (_b = rest.pieProps) != null ? _b : {};
41
48
  const cellColors = useMemo(
@@ -97,13 +104,27 @@ var usePieChart = ({
97
104
  )(theme, true),
98
105
  [inactiveShape, styles.inactiveShape, theme]
99
106
  );
100
- const labelClassName = useMemo(
101
- () => getClassName({ ...styles.label, ...label })(theme),
102
- [label, styles.label, theme]
107
+ const label = useCallback(
108
+ (props) => pieChartLabel({
109
+ labelOffset,
110
+ isParcent,
111
+ labelProps,
112
+ valueFormatter,
113
+ styles: styles.label,
114
+ ...props
115
+ }),
116
+ [isParcent, labelOffset, labelProps, styles.label, valueFormatter]
103
117
  );
104
- const labelLineClassName = useMemo(
105
- () => getClassName({ ...styles.labelLine, ...labelLine })(theme),
106
- [labelLine, styles.labelLine, theme]
118
+ const labelLine = useCallback(
119
+ (props) => {
120
+ return pieChartLabelLine({
121
+ labelOffset,
122
+ labelLineProps,
123
+ styles: styles.labelLine,
124
+ ...props
125
+ });
126
+ },
127
+ [labelLineProps, labelOffset, styles.labelLine]
107
128
  );
108
129
  const cellPropList = useMemo(
109
130
  () => data.map((props, index) => {
@@ -145,12 +166,7 @@ var usePieChart = ({
145
166
  [chartProps, chartClassName]
146
167
  );
147
168
  const getPieProps = useCallback(
148
- ({
149
- className,
150
- labelClassName: labelClassNameProp,
151
- labelLineClassName: labelLineClassNameProp,
152
- ...props
153
- }, ref = null) => ({
169
+ ({ className, ...props }, ref = null) => ({
154
170
  ref,
155
171
  className: cx(className, pieClassName),
156
172
  dataKey: "value",
@@ -162,8 +178,8 @@ var usePieChart = ({
162
178
  startAngle,
163
179
  endAngle,
164
180
  isAnimationActive: false,
165
- label: withLabels ? { className: cx(labelClassNameProp, labelClassName) } : false,
166
- labelLine: withLabelLines ? { className: cx(labelLineClassNameProp, labelLineClassName) } : false,
181
+ label: withLabels ? label : false,
182
+ labelLine: withLabelLines ? labelLine : false,
167
183
  activeShape: activeShapeProps,
168
184
  inactiveShape: inactiveShapeProps,
169
185
  ...props,
@@ -178,9 +194,9 @@ var usePieChart = ({
178
194
  startAngle,
179
195
  endAngle,
180
196
  withLabels,
181
- labelClassName,
197
+ label,
182
198
  withLabelLines,
183
- labelLineClassName,
199
+ labelLine,
184
200
  activeShapeProps,
185
201
  inactiveShapeProps,
186
202
  pieProps
@@ -212,4 +228,4 @@ var usePieChart = ({
212
228
  export {
213
229
  usePieChart
214
230
  };
215
- //# sourceMappingURL=chunk-YGKNNA34.mjs.map
231
+ //# sourceMappingURL=chunk-ELXW3EQE.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/use-pie-chart.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 { pieChartLabel, pieChartLabelLine } from \"./pie-chart-label\"\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 * Distance between chart and label.\n */\n labelOffset?: number\n /**\n * Determines whether labels should be displayed as percentages.\n *\n * @default false\n */\n isParcent?: 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 labelOffset,\n isParcent = 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 valueFormatter,\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: labelProps,\n labelLine: labelLineProps,\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 = { ...styles.dimCell, ...dimCell }\n\n return getClassName(resolvedDimCell)(theme)\n }, [dimCell, styles.dimCell, theme])\n\n const activeShapeProps = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [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 label: Recharts.PieLabel = useCallback(\n (props: any) =>\n pieChartLabel({\n labelOffset,\n isParcent,\n labelProps,\n valueFormatter,\n styles: styles.label,\n ...props,\n }),\n [isParcent, labelOffset, labelProps, styles.label, valueFormatter],\n )\n\n const labelLine = useCallback(\n (props: any) => {\n return pieChartLabelLine({\n labelOffset,\n labelLineProps,\n styles: styles.labelLine,\n ...props,\n })\n },\n [labelLineProps, labelOffset, styles.labelLine],\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 Omit<Recharts.PieProps, \"ref\">\n > = useCallback(\n ({ className, ...props }, ref = null) => ({\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 ? label : false,\n labelLine: withLabelLines ? labelLine : 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 label,\n withLabelLines,\n labelLine,\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"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,gBAAmD;AAC5D,SAAS,UAAqB;AAE9B,SAAS,aAAa,SAAS,gBAAgB;AA4GxC,IAAM,cAAc,CAAC;AAAA,EAC1B;AAAA,EACA,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB;AAAA,EACA,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc,aAAa,QAAQ;AAAA,EACnC,eAAe;AAAA,EACf,aAAa;AAAA,EACb,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAwB;AA/HxB;AAgIE,QAAM,EAAE,MAAM,IAAI,SAAS;AAC3B,QAAM,CAAC,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,eAAe,GAAG,MAAM,GAAG,MAAM,SAAS;AAC7D,YAAM,EAAE,WAAW,MAAM,IAAI,aAAa,KAAK;AAE/C,aAAO;AAAA,QACL;AAAA,QACA,WAAW,GAAG,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":["_a","dimCell"]}
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  useLineChart
4
- } from "./chunk-XZVWGY4J.mjs";
4
+ } from "./chunk-6L73M52L.mjs";
5
5
  import {
6
6
  useChartAxis
7
7
  } from "./chunk-XHDDK4ZU.mjs";
@@ -259,4 +259,4 @@ var LineChart = forwardRef((props, ref) => {
259
259
  export {
260
260
  LineChart
261
261
  };
262
- //# sourceMappingURL=chunk-K6OUXJQK.mjs.map
262
+ //# sourceMappingURL=chunk-KPKLW25H.mjs.map
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  usePieChart
4
- } from "./chunk-YGKNNA34.mjs";
4
+ } from "./chunk-ELXW3EQE.mjs";
5
5
  import {
6
6
  useChartLegend
7
7
  } from "./chunk-5Q6O726L.mjs";
@@ -58,6 +58,8 @@ var DonutChart = forwardRef((props, ref) => {
58
58
  endAngle,
59
59
  withLabels,
60
60
  withLabelLines,
61
+ labelOffset,
62
+ isParcent,
61
63
  innerRadius = withLabels ? "60%" : "80%",
62
64
  outerRadius,
63
65
  strokeWidth,
@@ -83,6 +85,9 @@ var DonutChart = forwardRef((props, ref) => {
83
85
  strokeWidth,
84
86
  withLabels,
85
87
  withLabelLines,
88
+ labelOffset,
89
+ isParcent,
90
+ valueFormatter,
86
91
  styles
87
92
  });
88
93
  const { getContainerProps } = useChart({ containerProps });
@@ -125,9 +130,7 @@ var DonutChart = forwardRef((props, ref) => {
125
130
  Pie,
126
131
  {
127
132
  ...getPieProps({
128
- className: "ui-donut-chart__donut",
129
- labelClassName: "ui-donut-chart__label",
130
- labelLineClassName: "ui-donut-chart__label-line"
133
+ className: "ui-donut-chart__donut"
131
134
  }),
132
135
  children: cells
133
136
  }
@@ -176,4 +179,4 @@ var DonutChart = forwardRef((props, ref) => {
176
179
  export {
177
180
  DonutChart
178
181
  };
179
- //# sourceMappingURL=chunk-P4MMHTAP.mjs.map
182
+ //# sourceMappingURL=chunk-VVR3DSUX.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/donut-chart.tsx"],"sourcesContent":["import {\n forwardRef,\n omitThemeProps,\n ui,\n useMultiComponentStyle,\n} from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport { useMemo } from \"react\"\nimport {\n Cell,\n Legend,\n Pie,\n PieChart as RechartsPieChart,\n ResponsiveContainer,\n Tooltip,\n} from \"recharts\"\nimport { ChartLegend } from \"./chart-legend\"\nimport { ChartTooltip } from \"./chart-tooltip\"\nimport type { PieChartProps } from \"./pie-chart\"\nimport { ChartProvider, useChart } from \"./use-chart\"\nimport { useChartLegend } from \"./use-chart-legend\"\nimport { useChartTooltip } from \"./use-chart-tooltip\"\nimport { usePieChart } from \"./use-pie-chart\"\n\ntype DonutChartOptions = {\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 '60%'\n */\n innerRadius?: number | string\n}\n\nexport type DonutChartProps = PieChartProps & DonutChartOptions\n\n/**\n * `DonutChart` is a component for drawing donut charts to compare multiple sets of data.\n *\n * @see Docs https://yamada-ui.com/components/feedback/donut-chart\n */\nexport const DonutChart = forwardRef<DonutChartProps, \"div\">((props, ref) => {\n const [styles, mergedProps] = useMultiComponentStyle(\"DonutChart\", props)\n const {\n className,\n data,\n pieProps,\n chartProps,\n cellProps,\n containerProps,\n withTooltip = true,\n withLegend = false,\n tooltipProps,\n tooltipAnimationDuration,\n tooltipDataSource = \"all\",\n valueFormatter,\n unit,\n paddingAngle,\n startAngle,\n endAngle,\n withLabels,\n withLabelLines,\n labelOffset,\n isParcent,\n innerRadius = withLabels ? \"60%\" : \"80%\",\n outerRadius,\n strokeWidth,\n legendProps,\n ...rest\n } = omitThemeProps(mergedProps)\n\n const {\n pieVars,\n getPieProps,\n getPieChartProps,\n getCellProps,\n setHighlightedArea,\n } = usePieChart({\n data,\n pieProps,\n chartProps,\n cellProps,\n innerRadius,\n outerRadius,\n paddingAngle,\n startAngle,\n endAngle,\n strokeWidth,\n withLabels,\n withLabelLines,\n labelOffset,\n isParcent,\n valueFormatter,\n styles,\n })\n const { getContainerProps } = useChart({ containerProps })\n const { tooltipProps: computedTooltipProps, getTooltipProps } =\n useChartTooltip({\n tooltipProps,\n tooltipAnimationDuration,\n styles,\n })\n const { legendProps: computedLegendProps, getLegendProps } = useChartLegend({\n legendProps,\n })\n\n const cells = useMemo(\n () =>\n data.map(({ name }, index) => (\n <Cell\n key={`donut-cell-${name}`}\n {...getCellProps({ index, className: \"ui-donut-chart__cell\" })}\n />\n )),\n [data, getCellProps],\n )\n\n return (\n <ChartProvider value={{ styles }}>\n <ui.div\n ref={ref}\n className={cx(\"ui-donut-chart\", className)}\n var={pieVars}\n __css={{ ...styles.container }}\n {...rest}\n >\n <ResponsiveContainer\n {...getContainerProps({ className: \"ui-donut-chart__container\" })}\n >\n <RechartsPieChart\n {...getPieChartProps({ className: \"ui-donut-chart__chart\" })}\n >\n <Pie\n {...getPieProps({\n className: \"ui-donut-chart__donut\",\n })}\n >\n {cells}\n </Pie>\n\n {withLegend ? (\n <Legend\n content={({ payload }) => (\n <ChartLegend\n className=\"ui-donut-chart__legend\"\n payload={payload}\n onHighlight={setHighlightedArea}\n {...computedLegendProps}\n />\n )}\n {...getLegendProps()}\n />\n ) : null}\n\n {withTooltip ? (\n <Tooltip\n content={({ label, payload }) => (\n <ChartTooltip\n className=\"ui-donut-chart__tooltip\"\n label={label}\n payload={tooltipDataSource === \"segment\" ? payload : data}\n valueFormatter={valueFormatter}\n unit={unit}\n {...computedTooltipProps}\n />\n )}\n {...getTooltipProps()}\n />\n ) : null}\n </RechartsPieChart>\n </ResponsiveContainer>\n </ui.div>\n </ChartProvider>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU;AACnB,SAAS,eAAe;AACxB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,OACK;AA+FC,cAoBE,YApBF;AApED,IAAM,aAAa,WAAmC,CAAC,OAAO,QAAQ;AAC3E,QAAM,CAAC,QAAQ,WAAW,IAAI,uBAAuB,cAAc,KAAK;AACxE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA,oBAAoB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc,aAAa,QAAQ;AAAA,IACnC;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI,eAAe,WAAW;AAE9B,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,YAAY;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,EAAE,kBAAkB,IAA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oBACC,SAAS,CAAC,EAAE,OAAO,QAAQ,MACzB;AAAA,sBAAC;AAAA;AAAA,wBACC,WAAU;AAAA,wBACV;AAAA,wBACA,SAAS,sBAAsB,YAAY,UAAU;AAAA,wBACrD;AAAA,wBACA;AAAA,wBACC,GAAG;AAAA;AAAA,oBACN;AAAA,oBAED,GAAG,gBAAgB;AAAA;AAAA,gBACtB,IACE;AAAA;AAAA;AAAA,UACN;AAAA;AAAA,MACF;AAAA;AAAA,EACF,GACF;AAEJ,CAAC;","names":[]}
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  useAreaChart
4
- } from "./chunk-HZSEVGCR.mjs";
4
+ } from "./chunk-6BNJZIBK.mjs";
5
5
  import {
6
6
  AreaGradient
7
7
  } from "./chunk-MSIOYYWR.mjs";
@@ -283,4 +283,4 @@ var AreaChart = forwardRef((props, ref) => {
283
283
  export {
284
284
  AreaChart
285
285
  };
286
- //# sourceMappingURL=chunk-DWLZIGGL.mjs.map
286
+ //# sourceMappingURL=chunk-X7MOM6U4.mjs.map
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  usePieChart
4
- } from "./chunk-YGKNNA34.mjs";
4
+ } from "./chunk-ELXW3EQE.mjs";
5
5
  import {
6
6
  useChartLegend
7
7
  } from "./chunk-5Q6O726L.mjs";
@@ -60,6 +60,8 @@ var PieChart = forwardRef((props, ref) => {
60
60
  endAngle,
61
61
  withLabels,
62
62
  withLabelLines,
63
+ labelOffset,
64
+ isParcent,
63
65
  strokeWidth,
64
66
  legendProps,
65
67
  ...rest
@@ -83,6 +85,9 @@ var PieChart = forwardRef((props, ref) => {
83
85
  strokeWidth,
84
86
  withLabels,
85
87
  withLabelLines,
88
+ labelOffset,
89
+ isParcent,
90
+ valueFormatter,
86
91
  styles
87
92
  });
88
93
  const { getContainerProps } = useChart({ containerProps });
@@ -125,9 +130,7 @@ var PieChart = forwardRef((props, ref) => {
125
130
  Pie,
126
131
  {
127
132
  ...getPieProps({
128
- className: "ui-pie-chart__pie",
129
- labelClassName: "ui-pie-chart__label",
130
- labelLineClassName: "ui-pie-chart__label-line"
133
+ className: "ui-pie-chart__pie"
131
134
  }),
132
135
  children: cells
133
136
  }
@@ -176,4 +179,4 @@ var PieChart = forwardRef((props, ref) => {
176
179
  export {
177
180
  PieChart
178
181
  };
179
- //# sourceMappingURL=chunk-F2RBOLDY.mjs.map
182
+ //# sourceMappingURL=chunk-XORRW2KT.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/pie-chart.tsx"],"sourcesContent":["import type { HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useMultiComponentStyle,\n} from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport { useMemo } from \"react\"\nimport {\n Cell,\n Legend,\n Pie,\n PieChart as RechartsPieChart,\n ResponsiveContainer,\n Tooltip,\n} from \"recharts\"\nimport { ChartLegend } from \"./chart-legend\"\nimport { ChartTooltip } from \"./chart-tooltip\"\nimport type { TooltipDataSourceType } from \"./chart.types\"\nimport type { UseChartProps } from \"./use-chart\"\nimport { ChartProvider, useChart } from \"./use-chart\"\nimport type { UseChartLegendProps } from \"./use-chart-legend\"\nimport { useChartLegend } from \"./use-chart-legend\"\nimport {\n useChartTooltip,\n type UseChartTooltipOptions,\n} from \"./use-chart-tooltip\"\nimport type { UsePieChartOptions } from \"./use-pie-chart\"\nimport { usePieChart } from \"./use-pie-chart\"\n\ntype PieChartOptions = {\n /**\n * If `true`, tooltip is visible.\n *\n * @default true\n */\n withTooltip?: boolean\n /**\n * If `true`, legend is visible.\n *\n * @default false\n */\n withLegend?: boolean\n /**\n * Determines which data is displayed in the tooltip.\n *\n * @default 'all'\n */\n tooltipDataSource?: TooltipDataSourceType\n /**\n * A function to format values inside the tooltip\n */\n valueFormatter?: (value: number) => string\n /**\n * Unit displayed next to each tick in y-axis.\n */\n unit?: string\n}\n\nexport type PieChartProps = HTMLUIProps<\"div\"> &\n ThemeProps<\"pieChart\"> &\n PieChartOptions &\n UsePieChartOptions &\n UseChartTooltipOptions &\n UseChartLegendProps &\n UseChartProps\n\n/**\n * `PieChart` is a component for drawing pie charts to compare multiple sets of data.\n *\n * @see Docs https://yamada-ui.com/components/feedback/pie-chart\n */\nexport const PieChart = forwardRef<PieChartProps, \"div\">((props, ref) => {\n const [styles, mergedProps] = useMultiComponentStyle(\"PieChart\", props)\n const {\n className,\n data,\n pieProps,\n chartProps,\n cellProps,\n containerProps,\n withTooltip = true,\n withLegend = false,\n tooltipProps,\n tooltipAnimationDuration,\n tooltipDataSource = \"all\",\n valueFormatter,\n unit,\n innerRadius,\n outerRadius,\n paddingAngle,\n startAngle,\n endAngle,\n withLabels,\n withLabelLines,\n labelOffset,\n isParcent,\n strokeWidth,\n legendProps,\n ...rest\n } = omitThemeProps(mergedProps)\n\n const {\n pieVars,\n getPieProps,\n getPieChartProps,\n getCellProps,\n setHighlightedArea,\n } = usePieChart({\n data,\n pieProps,\n chartProps,\n cellProps,\n innerRadius,\n outerRadius,\n paddingAngle,\n startAngle,\n endAngle,\n strokeWidth,\n withLabels,\n withLabelLines,\n labelOffset,\n isParcent,\n valueFormatter,\n styles,\n })\n const { getContainerProps } = useChart({ containerProps })\n const { tooltipProps: computedTooltipProps, getTooltipProps } =\n useChartTooltip({\n tooltipProps,\n tooltipAnimationDuration,\n styles,\n })\n const { legendProps: computedLegendProps, getLegendProps } = useChartLegend({\n legendProps,\n })\n\n const cells = useMemo(\n () =>\n data.map(({ name }, index) => (\n <Cell\n key={`pie-cell-${name}`}\n {...getCellProps({ index, className: \"ui-pie-chart__cell\" })}\n />\n )),\n [data, getCellProps],\n )\n\n return (\n <ChartProvider value={{ styles }}>\n <ui.div\n ref={ref}\n className={cx(\"ui-pie-chart\", className)}\n var={pieVars}\n __css={{ ...styles.container }}\n {...rest}\n >\n <ResponsiveContainer\n {...getContainerProps({ className: \"ui-pie-chart__container\" })}\n >\n <RechartsPieChart\n {...getPieChartProps({ className: \"ui-pie-chart__chart\" })}\n >\n <Pie\n {...getPieProps({\n className: \"ui-pie-chart__pie\",\n })}\n >\n {cells}\n </Pie>\n\n {withLegend ? (\n <Legend\n content={({ payload }) => (\n <ChartLegend\n className=\"ui-pie-chart__legend\"\n payload={payload}\n onHighlight={setHighlightedArea}\n {...computedLegendProps}\n />\n )}\n {...getLegendProps()}\n />\n ) : null}\n\n {withTooltip ? (\n <Tooltip\n content={({ label, payload }) => (\n <ChartTooltip\n className=\"ui-pie-chart__tooltip\"\n label={label}\n payload={tooltipDataSource === \"segment\" ? payload : data}\n valueFormatter={valueFormatter}\n unit={unit}\n {...computedTooltipProps}\n />\n )}\n {...getTooltipProps()}\n />\n ) : null}\n </RechartsPieChart>\n </ResponsiveContainer>\n </ui.div>\n </ChartProvider>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU;AACnB,SAAS,eAAe;AACxB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,OACK;AA6HC,cAoBE,YApBF;AApED,IAAM,WAAW,WAAiC,CAAC,OAAO,QAAQ;AACvE,QAAM,CAAC,QAAQ,WAAW,IAAI,uBAAuB,YAAY,KAAK;AACtE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA,oBAAoB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI,eAAe,WAAW;AAE9B,QAAM;AAAA,IACJ;A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