@yamada-ui/charts 2.0.0-next-20240729113003 → 2.0.0-next-20240820160301

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. package/dist/area-chart.d.mts +1 -0
  2. package/dist/area-chart.d.ts +1 -0
  3. package/dist/area-chart.js +23 -10
  4. package/dist/area-chart.js.map +1 -1
  5. package/dist/area-chart.mjs +4 -4
  6. package/dist/bar-chart.d.mts +2 -0
  7. package/dist/bar-chart.d.ts +2 -0
  8. package/dist/bar-chart.js +84 -45
  9. package/dist/bar-chart.js.map +1 -1
  10. package/dist/bar-chart.mjs +5 -5
  11. package/dist/chart-tooltip.d.mts +2 -1
  12. package/dist/chart-tooltip.d.ts +2 -1
  13. package/dist/chart-tooltip.js +15 -6
  14. package/dist/chart-tooltip.js.map +1 -1
  15. package/dist/chart-tooltip.mjs +1 -1
  16. package/dist/chart.types.d.mts +7 -5
  17. package/dist/chart.types.d.ts +7 -5
  18. package/dist/chart.types.js.map +1 -1
  19. package/dist/{chunk-J2HFHUKE.mjs → chunk-4MW4FB2T.mjs} +4 -4
  20. package/dist/{chunk-J2HFHUKE.mjs.map → chunk-4MW4FB2T.mjs.map} +1 -1
  21. package/dist/{chunk-IOVOXWUL.mjs → chunk-AODYT4HF.mjs} +14 -20
  22. package/dist/chunk-AODYT4HF.mjs.map +1 -0
  23. package/dist/{chunk-UK6B6KJ7.mjs → chunk-AOGTJ4EN.mjs} +1 -1
  24. package/dist/chunk-AOGTJ4EN.mjs.map +1 -0
  25. package/dist/{chunk-FTAFXLVL.mjs → chunk-BGMNYKQY.mjs} +5 -5
  26. package/dist/chunk-BGMNYKQY.mjs.map +1 -0
  27. package/dist/{chunk-OOWHC7AF.mjs → chunk-FALZDKAW.mjs} +6 -5
  28. package/dist/chunk-FALZDKAW.mjs.map +1 -0
  29. package/dist/{chunk-X7MOM6U4.mjs → chunk-FCMP6QEZ.mjs} +10 -5
  30. package/dist/chunk-FCMP6QEZ.mjs.map +1 -0
  31. package/dist/{chunk-KPKLW25H.mjs → chunk-KBBHISBO.mjs} +10 -5
  32. package/dist/chunk-KBBHISBO.mjs.map +1 -0
  33. package/dist/{chunk-CIRGC4FT.mjs → chunk-MOFNE6PO.mjs} +7 -6
  34. package/dist/chunk-MOFNE6PO.mjs.map +1 -0
  35. package/dist/{chunk-PSJKBKOF.mjs → chunk-MT5JI4OR.mjs} +16 -7
  36. package/dist/chunk-MT5JI4OR.mjs.map +1 -0
  37. package/dist/{chunk-MVKJVXAK.mjs → chunk-S5NKKKV5.mjs} +40 -9
  38. package/dist/chunk-S5NKKKV5.mjs.map +1 -0
  39. package/dist/{chunk-CCFQC3T6.mjs → chunk-UHQ6WE5D.mjs} +8 -5
  40. package/dist/chunk-UHQ6WE5D.mjs.map +1 -0
  41. package/dist/{chunk-XHDDK4ZU.mjs → chunk-VK4VQQYY.mjs} +3 -4
  42. package/dist/chunk-VK4VQQYY.mjs.map +1 -0
  43. package/dist/{chunk-TSAITPYC.mjs → chunk-XUAAKVRL.mjs} +6 -5
  44. package/dist/chunk-XUAAKVRL.mjs.map +1 -0
  45. package/dist/donut-chart.d.mts +1 -0
  46. package/dist/donut-chart.d.ts +1 -0
  47. package/dist/donut-chart.js +23 -13
  48. package/dist/donut-chart.js.map +1 -1
  49. package/dist/donut-chart.mjs +5 -5
  50. package/dist/index.d.mts +5 -4
  51. package/dist/index.d.ts +5 -4
  52. package/dist/index.js +213 -153
  53. package/dist/index.js.map +1 -1
  54. package/dist/index.mjs +17 -13
  55. package/dist/index.mjs.map +1 -1
  56. package/dist/line-chart.d.mts +1 -0
  57. package/dist/line-chart.d.ts +1 -0
  58. package/dist/line-chart.js +23 -10
  59. package/dist/line-chart.js.map +1 -1
  60. package/dist/line-chart.mjs +4 -4
  61. package/dist/pie-chart-label.d.mts +1 -1
  62. package/dist/pie-chart-label.d.ts +1 -1
  63. package/dist/pie-chart-label.js +3 -3
  64. package/dist/pie-chart-label.js.map +1 -1
  65. package/dist/pie-chart-label.mjs +1 -1
  66. package/dist/pie-chart.d.mts +2 -5
  67. package/dist/pie-chart.d.ts +2 -5
  68. package/dist/pie-chart.js +23 -13
  69. package/dist/pie-chart.js.map +1 -1
  70. package/dist/pie-chart.mjs +5 -5
  71. package/dist/radar-chart.d.mts +2 -1
  72. package/dist/radar-chart.d.ts +2 -1
  73. package/dist/radar-chart.js +25 -12
  74. package/dist/radar-chart.js.map +1 -1
  75. package/dist/radar-chart.mjs +4 -4
  76. package/dist/use-area-chart.d.mts +1 -0
  77. package/dist/use-area-chart.d.ts +1 -0
  78. package/dist/use-bar-chart.d.mts +16 -2
  79. package/dist/use-bar-chart.d.ts +16 -2
  80. package/dist/use-bar-chart.js +38 -2
  81. package/dist/use-bar-chart.js.map +1 -1
  82. package/dist/use-bar-chart.mjs +1 -1
  83. package/dist/use-chart-axis.d.mts +8 -3
  84. package/dist/use-chart-axis.d.ts +8 -3
  85. package/dist/use-chart-axis.js +2 -3
  86. package/dist/use-chart-axis.js.map +1 -1
  87. package/dist/use-chart-axis.mjs +1 -1
  88. package/dist/use-chart-grid.d.mts +1 -0
  89. package/dist/use-chart-grid.d.ts +1 -0
  90. package/dist/use-chart-legend.d.mts +1 -0
  91. package/dist/use-chart-legend.d.ts +1 -0
  92. package/dist/use-chart-reference-line.d.mts +1 -0
  93. package/dist/use-chart-reference-line.d.ts +1 -0
  94. package/dist/use-chart-tooltip.d.mts +9 -0
  95. package/dist/use-chart-tooltip.d.ts +9 -0
  96. package/dist/use-chart-tooltip.js.map +1 -1
  97. package/dist/use-chart-tooltip.mjs +1 -1
  98. package/dist/use-chart.d.mts +1 -0
  99. package/dist/use-chart.d.ts +1 -0
  100. package/dist/use-line-chart.d.mts +1 -0
  101. package/dist/use-line-chart.d.ts +1 -0
  102. package/dist/use-pie-chart.d.mts +4 -3
  103. package/dist/use-pie-chart.d.ts +4 -3
  104. package/dist/use-pie-chart.js +6 -6
  105. package/dist/use-pie-chart.js.map +1 -1
  106. package/dist/use-pie-chart.mjs +2 -2
  107. package/dist/use-radar-chart.d.mts +8 -3
  108. package/dist/use-radar-chart.d.ts +8 -3
  109. package/dist/use-radar-chart.js +6 -5
  110. package/dist/use-radar-chart.js.map +1 -1
  111. package/dist/use-radar-chart.mjs +1 -1
  112. package/package.json +3 -3
  113. package/dist/chunk-CCFQC3T6.mjs.map +0 -1
  114. package/dist/chunk-CIRGC4FT.mjs.map +0 -1
  115. package/dist/chunk-FTAFXLVL.mjs.map +0 -1
  116. package/dist/chunk-IOVOXWUL.mjs.map +0 -1
  117. package/dist/chunk-KPKLW25H.mjs.map +0 -1
  118. package/dist/chunk-MVKJVXAK.mjs.map +0 -1
  119. package/dist/chunk-OOWHC7AF.mjs.map +0 -1
  120. package/dist/chunk-PSJKBKOF.mjs.map +0 -1
  121. package/dist/chunk-TSAITPYC.mjs.map +0 -1
  122. package/dist/chunk-UK6B6KJ7.mjs.map +0 -1
  123. package/dist/chunk-X7MOM6U4.mjs.map +0 -1
  124. package/dist/chunk-XHDDK4ZU.mjs.map +0 -1
@@ -8,20 +8,29 @@ import { forwardRef, ui } from "@yamada-ui/core";
8
8
  import { cx, isArray } from "@yamada-ui/utils";
9
9
  import { jsx, jsxs } from "react/jsx-runtime";
10
10
  var ChartTooltip = forwardRef(
11
- ({ label, className, payload = [], valueFormatter, unit, ...rest }, ref) => {
11
+ ({
12
+ label,
13
+ className,
14
+ payload = [],
15
+ valueFormatter,
16
+ labelFormatter,
17
+ unit,
18
+ ...rest
19
+ }, ref) => {
20
+ var _a;
12
21
  const { styles } = useTooltip();
13
22
  const items = payload.map(
14
23
  ({ color: colorProp, name, value: valueProp, payload: payload2 } = {}, index) => {
15
- var _a;
24
+ var _a2;
16
25
  const color = colorProp != null ? colorProp : payload2 == null ? void 0 : payload2.color;
17
26
  let value;
18
27
  if (isArray(valueProp)) {
19
28
  value = valueProp.map((value2) => {
20
- var _a2;
21
- return `${(_a2 = valueFormatter == null ? void 0 : valueFormatter(value2)) != null ? _a2 : value2}`;
29
+ var _a3;
30
+ return `${(_a3 = valueFormatter == null ? void 0 : valueFormatter(value2)) != null ? _a3 : value2}`;
22
31
  }).join(" - ");
23
32
  } else {
24
- value = (_a = valueFormatter == null ? void 0 : valueFormatter(valueProp)) != null ? _a : valueProp;
33
+ value = (_a2 = valueFormatter == null ? void 0 : valueFormatter(valueProp)) != null ? _a2 : valueProp;
25
34
  }
26
35
  return /* @__PURE__ */ jsxs(
27
36
  ui.div,
@@ -70,7 +79,7 @@ var ChartTooltip = forwardRef(
70
79
  __css: styles.tooltip,
71
80
  ...rest,
72
81
  children: [
73
- label ? /* @__PURE__ */ jsx(ui.p, { className: "ui-chart__tooltip-title", __css: styles.tooltipTitle, children: label }) : null,
82
+ label ? /* @__PURE__ */ jsx(ui.p, { className: "ui-chart__tooltip-title", __css: styles.tooltipTitle, children: (_a = labelFormatter == null ? void 0 : labelFormatter(label)) != null ? _a : label }) : null,
74
83
  /* @__PURE__ */ jsx(ui.div, { className: "ui-chart__tooltip-list", __css: styles.tooltipList, children: items })
75
84
  ]
76
85
  }
@@ -81,4 +90,4 @@ var ChartTooltip = forwardRef(
81
90
  export {
82
91
  ChartTooltip
83
92
  };
84
- //# sourceMappingURL=chunk-PSJKBKOF.mjs.map
93
+ //# sourceMappingURL=chunk-MT5JI4OR.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/chart-tooltip.tsx"],"sourcesContent":["import { forwardRef, ui } from \"@yamada-ui/core\"\nimport { cx, isArray, type Dict } from \"@yamada-ui/utils\"\nimport { useTooltip } from \"./use-chart\"\n\nexport type ChartTooltipProps = {\n label: string | undefined\n payload: Dict[] | undefined\n valueFormatter?: (value: any) => string\n labelFormatter?: (label: string) => string\n unit?: string\n}\n\nexport const ChartTooltip = forwardRef<ChartTooltipProps, \"div\">(\n (\n {\n label,\n className,\n payload = [],\n valueFormatter,\n labelFormatter,\n unit,\n ...rest\n },\n ref,\n ) => {\n const { styles } = useTooltip()\n\n const items = payload.map(\n ({ color: colorProp, name, value: valueProp, payload } = {}, index) => {\n const color = colorProp ?? payload?.color\n let value: string\n\n if (isArray(valueProp)) {\n value = valueProp\n .map((value) => {\n return `${valueFormatter?.(value) ?? value}`\n })\n .join(\" - \")\n } else {\n value = valueFormatter?.(valueProp) ?? valueProp\n }\n\n return (\n <ui.div\n className=\"ui-chart__tooltip-item\"\n key={`tooltip-payload-${index}`}\n __css={styles.tooltipItem}\n >\n <ui.div\n className=\"ui-chart__tooltip-swatch\"\n background={color}\n __css={styles.tooltipSwatch}\n />\n\n <ui.span\n className=\"ui-chart__tooltip-label\"\n __css={styles.tooltipLabel}\n >\n {name}\n </ui.span>\n\n <ui.span\n className=\"ui-chart__tooltip-value\"\n __css={styles.tooltipValue}\n >\n {value}\n {unit ? unit : \"\"}\n </ui.span>\n </ui.div>\n )\n },\n )\n\n return (\n <ui.div\n ref={ref}\n className={cx(\"ui-chart__tooltip\", className)}\n __css={styles.tooltip}\n {...rest}\n >\n {label ? (\n <ui.p className=\"ui-chart__tooltip-title\" __css={styles.tooltipTitle}>\n {labelFormatter?.(label) ?? label}\n </ui.p>\n ) : null}\n\n <ui.div className=\"ui-chart__tooltip-list\" __css={styles.tooltipList}>\n {items}\n </ui.div>\n </ui.div>\n )\n },\n)\n"],"mappings":";;;;;;AAAA,SAAS,YAAY,UAAU;AAC/B,SAAS,IAAI,eAA0B;AA+C3B,cAaA,YAbA;AApCL,IAAM,eAAe;AAAA,EAC1B,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA,UAAU,CAAC;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AAxBP;AAyBI,UAAM,EAAE,OAAO,IAAI,WAAW;AAE9B,UAAM,QAAQ,QAAQ;AAAA,MACpB,CAAC,EAAE,OAAO,WAAW,MAAM,OAAO,WAAW,SAAAA,SAAQ,IAAI,CAAC,GAAG,UAAU;AA5B7E,YAAAC;AA6BQ,cAAM,QAAQ,gCAAaD,YAAA,gBAAAA,SAAS;AACpC,YAAI;AAEJ,Y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getComponentProps
8
8
  } from "./chunk-QL3DB7OJ.mjs";
9
9
 
10
- // src/use-bar-chart.ts
10
+ // src/use-bar-chart.tsx
11
11
  import { useTheme } from "@yamada-ui/core";
12
- import { cx } from "@yamada-ui/utils";
13
- import {
14
- useCallback,
15
- useState,
16
- useId,
17
- useMemo
18
- } from "react";
12
+ import { cx, runIfFunc } from "@yamada-ui/utils";
13
+ import { useCallback, useState, useId, useMemo } from "react";
14
+ import { Bar, Cell } from "recharts";
15
+ import { jsx } from "react/jsx-runtime";
19
16
  var useBarChart = ({
20
17
  data,
21
18
  series,
@@ -27,6 +24,7 @@ var useBarChart = ({
27
24
  xAxisLabel,
28
25
  yAxisLabel,
29
26
  styles,
27
+ cell = defaultBarCell,
30
28
  ...rest
31
29
  }) => {
32
30
  var _a;
@@ -183,6 +181,22 @@ var useBarChart = ({
183
181
  },
184
182
  [barPropsList, stacked]
185
183
  );
184
+ const bars = useMemo(() => {
185
+ const hasStack = series.some((entry) => entry.stackId);
186
+ return series.map((series2, index) => {
187
+ const { dataKey } = series2;
188
+ return /* @__PURE__ */ jsx(
189
+ Bar,
190
+ {
191
+ ...getBarProps({ index, className: "ui-bar-chart__bar" }),
192
+ children: data.map(
193
+ (data2, index2) => runIfFunc(cell, { series: series2, data: data2, index: index2, hasStack })
194
+ )
195
+ },
196
+ `bar-${dataKey}`
197
+ );
198
+ });
199
+ }, [series, getBarProps, cell, data]);
186
200
  const getBarChartProps = useCallback(
187
201
  ({ className, ...props } = {}, ref = null) => ({
188
202
  ref,
@@ -211,14 +225,31 @@ var useBarChart = ({
211
225
  ]
212
226
  );
213
227
  return {
228
+ bars,
214
229
  barVars,
215
230
  getBarProps,
216
231
  getBarChartProps,
217
232
  setHighlightedArea
218
233
  };
219
234
  };
235
+ var defaultBarCell = ({
236
+ hasStack,
237
+ series,
238
+ data,
239
+ index
240
+ }) => {
241
+ const { dataKey } = series;
242
+ const key = `cell-${dataKey}-${index}`;
243
+ if (!hasStack) return /* @__PURE__ */ jsx(Cell, {}, key);
244
+ const keys = Object.keys(data);
245
+ const values = Object.values(data);
246
+ const currentIndex = keys.findIndex((key2) => key2 === dataKey);
247
+ const lastIndex = values.findLastIndex((value) => value !== 0);
248
+ if (currentIndex === lastIndex) return /* @__PURE__ */ jsx(Cell, {}, key);
249
+ return /* @__PURE__ */ jsx(Cell, { radius: 0 }, key);
250
+ };
220
251
 
221
252
  export {
222
253
  useBarChart
223
254
  };
224
- //# sourceMappingURL=chunk-MVKJVXAK.mjs.map
255
+ //# sourceMappingURL=chunk-S5NKKKV5.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/use-bar-chart.tsx"],"sourcesContent":["import type { CSSUIObject, CSSUIProps } from \"@yamada-ui/core\"\nimport { useTheme } from \"@yamada-ui/core\"\nimport { cx, runIfFunc } from \"@yamada-ui/utils\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport type { FC, ComponentPropsWithoutRef, ReactNode } from \"react\"\nimport { useCallback, useState, useId, useMemo } from \"react\"\nimport type * as Recharts from \"recharts\"\nimport { Bar, Cell } from \"recharts\"\nimport { getComponentProps } from \"./chart-utils\"\nimport type {\n BarProps,\n BarChartType,\n BarChartProps,\n ChartPropGetter,\n ChartLayoutType,\n ReferenceLineProps,\n RequiredChartPropGetter,\n} from \"./chart.types\"\nimport { barProperties, barChartProperties } from \"./rechart-properties\"\n\nexport type UseBarChartOptions = {\n /**\n * Chart data.\n */\n data: Dict[]\n /**\n * An array of objects with `name` and `color` keys. Determines which data should be consumed from the `data` array.\n */\n series: BarProps[]\n /**\n * Props for the bars.\n */\n barProps?: Partial<BarProps>\n /**\n * Controls how chart bars are positioned relative to each other.\n *\n * @default `default`\n */\n type?: BarChartType\n /**\n * Chart orientation.\n *\n * @default 'horizontal'\n */\n layoutType?: ChartLayoutType\n /**\n * If any two categorical charts have the same syncId,\n * these two charts can sync the position tooltip, and the startIndex, endIndex of Brush.\n */\n syncId?: number | string\n /**\n * Props passed down to recharts `BarChart` component.\n */\n chartProps?: BarChartProps\n /**\n * Reference lines that should be displayed on the chart.\n */\n referenceLineProps?: ReferenceLineProps[]\n /**\n * Controls fill opacity of all bars.\n *\n * @default 1\n */\n fillOpacity?: number | [number, number]\n /**\n * A label to display below the X axis.\n */\n xAxisLabel?: string\n /**\n * A label to display below the Y axis.\n */\n yAxisLabel?: string\n /**\n * A function that returns a component that renders the bar cells.\n */\n cell?: ReactNode | FC<BarCellProps>\n}\n\nexport type UseBarChartProps = UseBarChartOptions & {\n styles: Dict<CSSUIObject>\n}\n\nexport const useBarChart = ({\n data,\n series,\n type = \"default\",\n layoutType = \"horizontal\",\n referenceLineProps = [],\n fillOpacity = 1,\n syncId,\n xAxisLabel,\n yAxisLabel,\n styles,\n cell = defaultBarCell,\n ...rest\n}: UseBarChartProps) => {\n const uuid = useId()\n const { theme } = useTheme()\n const [highlightedArea, setHighlightedArea] = useState<string | null>(null)\n const stacked = type === \"stacked\" || type === \"percent\"\n const shouldHighlight = highlightedArea !== null\n const {\n activeBar = {},\n background = {},\n dimBar = {},\n ...computedBarProps\n } = rest.barProps ?? {}\n\n const barColors: CSSUIProps[\"var\"] = useMemo(\n () =>\n series.map(({ color }, index) => ({\n __prefix: \"ui\",\n name: `bar-${index}`,\n token: \"colors\",\n value: color ?? \"transparent\",\n })),\n [series],\n )\n\n const referenceLineColors: CSSUIProps[\"var\"] = useMemo(\n () =>\n referenceLineProps.map(({ color }, index) => ({\n __prefix: \"ui\",\n name: `reference-line-${index}`,\n token: \"colors\",\n value: color ?? \"transparent\",\n })),\n [referenceLineProps],\n )\n\n const barVars: CSSUIProps[\"var\"] = useMemo(() => {\n return [\n ...barColors,\n ...referenceLineColors,\n { __prefix: \"ui\", name: \"fill-opacity\", value: fillOpacity },\n ]\n }, [barColors, fillOpacity, referenceLineColors])\n\n const [chartProps, barChartClassName] = useMemo(() => {\n const resolvedBarChartProps = { barGap: 8, ...rest.chartProps }\n\n return getComponentProps<Dict, string>(\n [resolvedBarChartProps, barChartProperties],\n styles.chart,\n )(theme)\n }, [rest.chartProps, styles.chart, theme])\n\n const [barProps, barClassName] = useMemo(() => {\n const resolvedBarProps = {\n fillOpacity: \"var(--ui-fill-opacity)\",\n ...computedBarProps,\n }\n\n return getComponentProps<Dict, string>(\n [resolvedBarProps, barProperties],\n styles.bar,\n )(theme)\n }, [computedBarProps, styles.bar, theme])\n\n const [dimBarProps, dimBarClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [dimBar, barProperties],\n styles.dimBar,\n )(theme),\n [dimBar, styles.dimBar, theme],\n )\n\n const [activeBarProps, activeBarClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [activeBar, barProperties],\n styles.activeBar,\n )(theme),\n [activeBar, styles.activeBar, theme],\n )\n\n const [backgroundProps, backgroundClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [background, barProperties],\n styles.background,\n )(theme),\n [background, styles.background, theme],\n )\n\n const barPropsList = useMemo(\n () =>\n series.map((props, index) => {\n const {\n dataKey,\n activeBar = {},\n background = {},\n dimBar = {},\n ...computedProps\n } = props\n const id = `${uuid}-${dataKey}`\n const color = `var(--ui-bar-${index})`\n const dimmed = shouldHighlight && highlightedArea !== dataKey\n const computedDimBar = { ...dimBarProps, ...dimBar }\n const resolvedProps = {\n ...barProps,\n ...computedProps,\n ...(dimmed ? computedDimBar : {}),\n }\n\n const rest = getComponentProps<Dict, string>(\n [resolvedProps, barProperties],\n barClassName,\n dimmed ? dimBarClassName : undefined,\n )(theme, true)\n\n const computedActiveBar = { ...activeBarProps, ...activeBar }\n\n const resolvedActiveBar = getComponentProps<Dict, string>(\n [computedActiveBar, barProperties],\n activeBarClassName,\n )(theme, true)\n\n const computedBackground = { ...backgroundProps, ...background }\n\n const resolvedBackground = getComponentProps<Dict, string>(\n [computedBackground, barProperties],\n backgroundClassName,\n )(theme, true)\n\n return {\n ...rest,\n id,\n activeBar: resolvedActiveBar,\n background: resolvedBackground,\n color,\n dataKey,\n }\n }),\n [\n activeBarClassName,\n activeBarProps,\n backgroundClassName,\n backgroundProps,\n barClassName,\n barProps,\n dimBarClassName,\n dimBarProps,\n highlightedArea,\n series,\n shouldHighlight,\n theme,\n uuid,\n ],\n )\n\n const getBarProps: RequiredChartPropGetter<\n \"div\",\n {\n index: number\n },\n Omit<Recharts.BarProps, \"ref\">\n > = useCallback(\n ({ index, className: classNameProp, ...props }, ref = null) => {\n const { id, className, activeBar, background, color, dataKey, ...rest } =\n barPropsList[index]\n\n return {\n ref,\n className: cx(classNameProp, className),\n activeBar,\n background,\n id,\n name: dataKey as string,\n dataKey,\n fill: color,\n stroke: color,\n isAnimationActive: false,\n stackId: stacked ? \"stack\" : undefined,\n ...(props as Omit<Recharts.BarProps, \"dataKey\">),\n ...rest,\n } as Recharts.BarProps\n },\n [barPropsList, stacked],\n )\n\n const bars = useMemo(() => {\n const hasStack = series.some((entry) => entry.stackId)\n\n return series.map((series, index) => {\n const { dataKey } = series\n\n return (\n <Bar\n key={`bar-${dataKey}`}\n {...getBarProps({ index, className: \"ui-bar-chart__bar\" })}\n >\n {data.map((data, index) =>\n runIfFunc(cell, { series, data, index, hasStack }),\n )}\n </Bar>\n )\n })\n }, [series, getBarProps, cell, data])\n\n const getBarChartProps: ChartPropGetter<\n \"div\",\n ComponentPropsWithoutRef<typeof Recharts.BarChart>,\n ComponentPropsWithoutRef<typeof Recharts.BarChart>\n > = useCallback(\n ({ className, ...props } = {}, ref = null) => ({\n ref,\n className: cx(className, barChartClassName),\n data,\n stackOffset: type === \"percent\" ? \"expand\" : undefined,\n layout: layoutType,\n syncId,\n margin: {\n bottom: xAxisLabel ? 30 : undefined,\n left: yAxisLabel ? 10 : undefined,\n right: yAxisLabel ? 5 : undefined,\n },\n ...props,\n ...chartProps,\n }),\n [\n barChartClassName,\n data,\n type,\n layoutType,\n syncId,\n xAxisLabel,\n yAxisLabel,\n chartProps,\n ],\n )\n\n return {\n bars,\n barVars,\n getBarProps,\n getBarChartProps,\n setHighlightedArea,\n }\n}\n\nexport type UseBarChartReturn = ReturnType<typeof useBarChart>\n\nexport type BarCellProps = {\n hasStack: boolean\n series: BarProps\n data: Dict\n index: number\n}\n\nconst defaultBarCell: FC<BarCellProps> = ({\n hasStack,\n series,\n data,\n index,\n}) => {\n const { dataKey } = series\n const key = `cell-${dataKey}-${index}`\n\n if (!hasStack) return <Cell key={key} />\n\n const keys = Object.keys(data)\n const values = Object.values(data)\n\n const currentIndex = keys.findIndex((key) => key === dataKey)\n const lastIndex = values.findLastIndex((value) => value !== 0)\n\n if (currentIndex === lastIndex) return <Cell key={key} />\n\n return <Cell key={key} radius={0} />\n}\n"],"mappings":";;;;;;;;;;AACA,SAAS,gBAAgB;AACzB,SAAS,IAAI,iBAAiB;AAG9B,SAAS,aAAa,UAAU,OAAO,eAAe;AAEtD,SAAS,KAAK,YAAY;AA0RlB;AA/MD,IAAM,cAAc,CAAC;AAAA,EAC1B;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,aAAa;AAAA,EACb,qBAAqB,CAAC;AAAA,EACtB,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,GAAG;AACL,MAAwB;AA/FxB;AAgGE,QAAM,OAAO,MAAM;AACnB,QAAM,EAAE,MAAM,IAAI,SAAS;AAC3B,QAAM,CAAC,iBAAiB,kBAAkB,IAAI,SAAwB,IAAI;AAC1E,QAAM,UAAU,SAAS,aAAa,SAAS;AAC/C,QAAM,kBAAkB,oBAAoB;AAC5C,QAAM;AAAA,IACJ,YAAY,CAAC;AAAA,IACb,aAAa,CAAC;AAAA,IACd,SAAS,CAAC;AAAA,IACV,GAAG;AAAA,EACL,KAAI,UAAK,aAAL,YAAiB,CAAC;AAEtB,QAAM,YAA+B;AAAA,IACnC,MACE,OAAO,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW;AAAA,MAChC,UAAU;AAAA,MACV,MAAM,OAAO,KAAK;AAAA,MAClB,OAAO;AAAA,MACP,O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3
  useRadarChart
4
- } from "./chunk-CIRGC4FT.mjs";
4
+ } from "./chunk-MOFNE6PO.mjs";
5
5
  import {
6
6
  useChartLegend
7
7
  } from "./chunk-5Q6O726L.mjs";
8
8
  import {
9
9
  useChartTooltip
10
- } from "./chunk-UK6B6KJ7.mjs";
10
+ } from "./chunk-AOGTJ4EN.mjs";
11
11
  import {
12
12
  ChartLegend
13
13
  } from "./chunk-DGOXJ373.mjs";
14
14
  import {
15
15
  ChartTooltip
16
- } from "./chunk-PSJKBKOF.mjs";
16
+ } from "./chunk-MT5JI4OR.mjs";
17
17
  import {
18
18
  ChartProvider,
19
19
  useChart
@@ -59,6 +59,8 @@ var RadarChart = forwardRef((props, ref) => {
59
59
  tooltipAnimationDuration,
60
60
  unit,
61
61
  valueFormatter,
62
+ polarAngleAxisTickFormatter,
63
+ polarRadiusAxisTickFormatter,
62
64
  strokeDasharray,
63
65
  withDots,
64
66
  withActiveDots,
@@ -94,7 +96,8 @@ var RadarChart = forwardRef((props, ref) => {
94
96
  withActiveDots,
95
97
  strokeWidth,
96
98
  fillOpacity,
97
- valueFormatter,
99
+ polarAngleAxisTickFormatter,
100
+ polarRadiusAxisTickFormatter,
98
101
  strokeDasharray,
99
102
  styles
100
103
  });
@@ -203,4 +206,4 @@ var RadarChart = forwardRef((props, ref) => {
203
206
  export {
204
207
  RadarChart
205
208
  };
206
- //# sourceMappingURL=chunk-CCFQC3T6.mjs.map
209
+ //# sourceMappingURL=chunk-UHQ6WE5D.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/radar-chart.tsx"],"sourcesContent":["import type { HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport {\n ui,\n forwardRef,\n useMultiComponentStyle,\n omitThemeProps,\n} from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport { useMemo } from \"react\"\nimport {\n ResponsiveContainer,\n RadarChart as ReChartsRadarChart,\n PolarGrid,\n PolarAngleAxis,\n PolarRadiusAxis,\n Radar,\n Tooltip,\n Legend,\n} from \"recharts\"\nimport { ChartLegend } from \"./chart-legend\"\nimport { ChartTooltip } from \"./chart-tooltip\"\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 type { UseChartTooltipOptions } from \"./use-chart-tooltip\"\nimport { useChartTooltip } from \"./use-chart-tooltip\"\nimport type { UseRadarChartOptions } from \"./use-radar-chart\"\nimport { useRadarChart } from \"./use-radar-chart\"\n\ntype RadarChartOptions = {\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 whether polarGrid should be displayed.\n *\n * @default true\n */\n withPolarGrid?: boolean\n /**\n * Determines whether polarAngleAxis should be displayed.\n *\n * @default true\n */\n withPolarAngleAxis?: boolean\n /**\n * Determines whether polarRadiusAxis should be displayed.\n *\n * @default false\n */\n withPolarRadiusAxis?: boolean\n /**\n * Unit displayed next to each tick in y-axis.\n */\n unit?: string\n}\n\nexport type RadarChartProps = HTMLUIProps<\"div\"> &\n ThemeProps<\"RadarChart\"> &\n RadarChartOptions &\n UseChartProps &\n Omit<UseChartTooltipOptions, \"labelFormatter\"> &\n UseChartLegendProps &\n UseRadarChartOptions\n\n/**\n * `RadarChart` is a component for drawing radar charts to compare multiple sets of data.\n *\n * @see Docs https://yamada-ui.com/components/feedback/radar-chart\n */\nexport const RadarChart = forwardRef<RadarChartProps, \"div\">((props, ref) => {\n const [styles, mergedProps] = useMultiComponentStyle(\"RadarChart\", props)\n const {\n className,\n data,\n series,\n dataKey,\n radarProps,\n chartProps,\n polarGridProps,\n polarAngleAxisProps,\n polarAngleAxisTickProps,\n polarRadiusAxisProps,\n polarRadiusAxisTickProps,\n containerProps,\n tooltipProps,\n legendProps,\n tooltipAnimationDuration,\n unit,\n valueFormatter,\n polarAngleAxisTickFormatter,\n polarRadiusAxisTickFormatter,\n strokeDasharray,\n withDots,\n withActiveDots,\n strokeWidth,\n fillOpacity,\n withTooltip = true,\n withLegend = false,\n withPolarGrid = true,\n withPolarAngleAxis = true,\n withPolarRadiusAxis = false,\n ...rest\n } = omitThemeProps(mergedProps)\n\n const {\n getRadarProps,\n getRadarChartProps,\n getPolarGridProps,\n getPolarAngleAxisProps,\n getPolarRadiusAxisProps,\n radarVars,\n setHighlightedArea,\n } = useRadarChart({\n data,\n series,\n dataKey,\n radarProps,\n chartProps,\n polarGridProps,\n polarAngleAxisProps,\n polarAngleAxisTickProps,\n polarRadiusAxisProps,\n polarRadiusAxisTickProps,\n withDots,\n withActiveDots,\n strokeWidth,\n fillOpacity,\n polarAngleAxisTickFormatter,\n polarRadiusAxisTickFormatter,\n strokeDasharray,\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 radars = useMemo(\n () =>\n series.map(({ dataKey }, index) => (\n <Radar\n key={`radar-${dataKey}`}\n {...getRadarProps({ index, className: \"ui-radar-chart__radar\" })}\n />\n )),\n [getRadarProps, series],\n )\n\n return (\n <ChartProvider value={{ styles }}>\n <ui.div\n ref={ref}\n className={cx(\"ui-radar-chart\", className)}\n var={radarVars}\n __css={{ ...styles.container }}\n {...rest}\n >\n <ResponsiveContainer\n {...getContainerProps({ className: \"ui-radar-chart__container\" })}\n >\n <ReChartsRadarChart\n {...getRadarChartProps({ className: \"ui-radar-chart__chart\" })}\n >\n {withPolarGrid ? (\n <PolarGrid\n {...getPolarGridProps({\n className: \"ui-radar-chart__polar-grid\",\n })}\n />\n ) : null}\n {withPolarAngleAxis ? (\n <PolarAngleAxis\n {...getPolarAngleAxisProps({\n className: \"ui-radar-chart__polar-angle-axis\",\n })}\n />\n ) : null}\n {withPolarRadiusAxis ? (\n <PolarRadiusAxis\n {...getPolarRadiusAxisProps({\n className: \"ui-radar-chart__polar-radius-axis\",\n })}\n />\n ) : null}\n\n {withLegend ? (\n <Legend\n content={({ payload }) => (\n <ChartLegend\n className=\"ui-area-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-line-chart__tooltip\"\n label={label}\n payload={payload}\n valueFormatter={valueFormatter}\n unit={unit}\n {...computedTooltipProps}\n />\n )}\n {...getTooltipProps()}\n />\n ) : null}\n\n {radars}\n </ReChartsRadarChart>\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,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA2IC,cAoBE,YApBF;AA7ED,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;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,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,aAAa;AAAA,IACb,gBAAgB;AAAA,IAChB,qBAAqB;AAAA,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W,wBAAwB,CAAC;AAAA,cAE5D;AAAA,gCACC;AAAA,kBAAC;AAAA;AAAA,oBACE,GAAG,kBAAkB;AAAA,sBACpB,WAAW;AAAA,oBACb,CAAC;AAAA;AAAA,gBACH,IACE;AAAA,gBACH,qBACC;AAAA,kBAAC;AAAA;AAAA,oBACE,GAAG,uBAAuB;AAAA,sBACzB,WAAW;AAAA,oBACb,CAAC;AAAA;AAAA,gBACH,IACE;AAAA,gBACH,sBACC;AAAA,kBAAC;AAAA;AAAA,oBACE,GAAG,wBAAwB;AAAA,sBAC1B,WAAW;AAAA,oBACb,CAAC;AAAA;AAAA,gBACH,IACE;AAAA,gBAEH,aACC;AAAA,kBAAC;AAAA;AAAA,oBACC,SAAS,CAAC,EAAE,QAAQ,MAClB;AAAA,sBAAC;AAAA;AAAA,wBACC,WAAU;AAAA,wBACV;AAAA,wBACA,aAAa;AAAA,wBACZ,GAAG;AAAA;AAAA,oBACN;AAAA,oBAED,GAAG,eAAe;AAAA;AAAA,gBACrB,IACE;AAAA,gBAEH,cACC;AAAA,kBAAC;AAAA;AAAA,oBACC,SAAS,CAAC,EAAE,OAAO,QAAQ,MACzB;AAAA,sBAAC;AAAA;AAAA,wBACC,WAAU;AAAA,wBACV;AAAA,wBACA;AAAA,wBACA;AAAA,wBACA;AAAA,wBACC,GAAG;AAAA;AAAA,oBACN;AAAA,oBAED,GAAG,gBAAgB;AAAA;AAAA,gBACtB,IACE;AAAA,gBAEH;AAAA;AAAA;AAAA,UACH;AAAA;AAAA,MACF;AAAA;AAAA,EACF,GACF;AAEJ,CAAC;","names":["dataKey"]}
@@ -23,7 +23,8 @@ var useChartAxis = ({
23
23
  xAxisLabel: xAxisLabelProp,
24
24
  yAxisLabel: yAxisLabelProp,
25
25
  unit,
26
- valueFormatter,
26
+ yAxisTickFormatter = type === "percent" && layoutType === "horizontal" ? valueToPercent : void 0,
27
+ xAxisTickFormatter = type === "percent" && layoutType === "vertical" ? valueToPercent : void 0,
27
28
  styles,
28
29
  ...rest
29
30
  }) => {
@@ -42,8 +43,6 @@ var useChartAxis = ({
42
43
  const getTickLine = (withTickLine) => withTickLine ? { stroke: "currentColor" } : false;
43
44
  const xTickLine = getTickLine(withXTickLine);
44
45
  const yTickLine = getTickLine(withYTickLine);
45
- const yAxisTickFormatter = type === "percent" && layoutType !== "vertical" ? valueToPercent : valueFormatter;
46
- const xAxisTickFormatter = type === "percent" && layoutType === "vertical" ? valueToPercent : valueFormatter;
47
46
  const xAxisLabel = layoutType === "vertical" ? yAxisLabelProp : xAxisLabelProp;
48
47
  const yAxisLabel = layoutType === "vertical" ? xAxisLabelProp : yAxisLabelProp;
49
48
  const [xAxisProps, xAxisClassName] = getComponentProps(
@@ -153,4 +152,4 @@ var valueToPercent = (value) => {
153
152
  export {
154
153
  useChartAxis
155
154
  };
156
- //# sourceMappingURL=chunk-XHDDK4ZU.mjs.map
155
+ //# sourceMappingURL=chunk-VK4VQQYY.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/use-chart-axis.ts"],"sourcesContent":["import type { CSSUIObject } from \"@yamada-ui/core\"\nimport { useTheme } from \"@yamada-ui/core\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { SVGProps } from \"react\"\nimport { useCallback, useMemo } from \"react\"\nimport type * as Recharts from \"recharts\"\nimport { getComponentProps } from \"./chart-utils\"\nimport type {\n ChartAxisType,\n ChartLayoutType,\n XAxisProps,\n YAxisProps,\n ChartPropGetter,\n AreaChartType,\n LabelProps,\n} from \"./chart.types\"\nimport {\n labelProperties,\n xAxisProperties,\n yAxisProperties,\n} from \"./rechart-properties\"\n\nexport type UseChartAxisOptions = {\n /**\n * The key of a group of data which should be unique in an chart.\n */\n dataKey: string\n /**\n * Controls how chart areas are positioned relative to each other\n *\n * @default `default`\n */\n type?: AreaChartType\n /**\n * Chart orientation.\n *\n * @default 'horizontal'\n */\n layoutType?: ChartLayoutType\n /**\n * The option is the configuration of tick lines.\n *\n * @default 'y'\n */\n tickLine?: ChartAxisType\n /**\n * Specifies which lines should be displayed in the grid.\n *\n * @default 'x'\n */\n gridAxis?: ChartAxisType\n /**\n * If `true`, X axis is visible.\n *\n * @default true\n */\n withXAxis?: boolean\n /**\n * If `true`, Y axis is visible.\n *\n * @default true\n */\n withYAxis?: boolean\n /**\n * Props passed down to recharts 'XAxis' component.\n */\n xAxisProps?: XAxisProps\n /**\n * Props passed down to recharts 'YAxis' component.\n */\n yAxisProps?: YAxisProps\n /**\n * A label to display below the X axis.\n */\n xAxisLabel?: string\n /**\n * A label to display below the Y axis.\n */\n yAxisLabel?: string\n /**\n * Props passed down to recharts 'XAxisLabel' component.\n */\n xAxisLabelProps?: LabelProps\n /**\n * Props passed down to recharts 'YAxisLabel' component.\n */\n yAxisLabelProps?: LabelProps\n /**\n * Unit displayed next to each tick in y-axis.\n */\n unit?: string\n /**\n * A function to format Y axis tick.\n */\n yAxisTickFormatter?: (value: any) => string\n /**\n * A function to format X axis tick.\n */\n xAxisTickFormatter?: (value: any) => string\n}\n\nexport type UseChartAxisProps = UseChartAxisOptions & {\n styles: Dict<CSSUIObject>\n}\n\nexport const useChartAxis = ({\n dataKey,\n type,\n layoutType = \"horizontal\",\n tickLine = \"y\",\n gridAxis = \"x\",\n withXAxis = true,\n withYAxis = true,\n xAxisLabel: xAxisLabelProp,\n yAxisLabel: yAxisLabelProp,\n unit,\n yAxisTickFormatter = type === \"percent\" && layoutType === \"horizontal\"\n ? valueToPercent\n : undefined,\n xAxisTickFormatter = type === \"percent\" && layoutType === \"vertical\"\n ? valueToPercent\n : undefined,\n styles,\n ...rest\n}: UseChartAxisProps) => {\n const { theme } = useTheme()\n const xAxisKey: Recharts.XAxisProps = useMemo(\n () => (layoutType === \"vertical\" ? { type: \"number\" } : { dataKey }),\n [dataKey, layoutType],\n )\n\n const yAxisKey: Recharts.YAxisProps = useMemo(\n () =>\n layoutType === \"vertical\"\n ? { dataKey, type: \"category\" }\n : { type: \"number\" },\n [dataKey, layoutType],\n )\n const withXTickLine =\n gridAxis !== \"none\" && (tickLine === \"x\" || tickLine === \"xy\")\n const withYTickLine =\n gridAxis !== \"none\" && (tickLine === \"y\" || tickLine === \"xy\")\n const getTickLine = (\n withTickLine: boolean,\n ): boolean | SVGProps<SVGTextElement> =>\n withTickLine ? { stroke: \"currentColor\" } : false\n const xTickLine = getTickLine(withXTickLine)\n const yTickLine = getTickLine(withYTickLine)\n\n const xAxisLabel = layoutType === \"vertical\" ? yAxisLabelProp : xAxisLabelProp\n const yAxisLabel = layoutType === \"vertical\" ? xAxisLabelProp : yAxisLabelProp\n\n const [xAxisProps, xAxisClassName] = getComponentProps<Dict, string>(\n [rest.xAxisProps ?? {}, xAxisProperties],\n styles.xAxis,\n )(theme)\n\n const [yAxisProps, yAxisClassName] = getComponentProps<Dict, string>(\n [rest.yAxisProps ?? {}, yAxisProperties],\n styles.yAxis,\n )(theme)\n\n const [xAxisLabelProps, xAxisLabelClassName] = getComponentProps<\n Dict,\n string\n >(\n [rest.xAxisLabelProps ?? {}, labelProperties],\n styles.xAxisLabel,\n )(theme)\n\n const [yAxisLabelProps, yAxisLabelClassName] = getComponentProps<\n Dict,\n string\n >(\n [rest.yAxisLabelProps ?? {}, labelProperties],\n styles.yAxisLabel,\n )(theme)\n\n const getXAxisProps: ChartPropGetter<\n \"div\",\n Partial<Recharts.XAxisProps>,\n Recharts.XAxisProps\n > = useCallback(\n ({ className, ...props } = {}) => ({\n className: cx(className, xAxisClassName),\n hide: !withXAxis,\n ...xAxisKey,\n tick: {\n transform: \"translate(0, 10)\",\n fill: \"currentColor\",\n },\n stroke: \"\",\n interval: \"preserveStartEnd\",\n tickLine: xTickLine,\n minTickGap: 5,\n tickFormatter: xAxisTickFormatter,\n ...props,\n ...(xAxisProps as Recharts.XAxisProps),\n }),\n [\n xAxisClassName,\n withXAxis,\n xAxisKey,\n xTickLine,\n xAxisTickFormatter,\n xAxisProps,\n ],\n )\n\n const getYAxisProps: ChartPropGetter<\n \"div\",\n Partial<Recharts.YAxisProps>,\n Recharts.YAxisProps\n > = useCallback(\n ({ className, ...props } = {}) => ({\n className: cx(className, yAxisClassName),\n hide: !withYAxis,\n axisLine: false,\n ...yAxisKey,\n tickLine: yTickLine,\n tick: {\n transform: \"translate(-10, 0)\",\n fill: \"currentColor\",\n },\n allowDecimals: true,\n unit: unit,\n tickFormatter: yAxisTickFormatter,\n ...props,\n ...(yAxisProps as Recharts.YAxisProps),\n }),\n [\n yAxisClassName,\n withYAxis,\n yAxisKey,\n yTickLine,\n unit,\n yAxisTickFormatter,\n yAxisProps,\n ],\n )\n\n const getXAxisLabelProps: ChartPropGetter<\n \"div\",\n Partial<Recharts.LabelProps>,\n Recharts.LabelProps\n > = useCallback(\n ({ className, ...props } = {}) => ({\n className: cx(className, xAxisLabelClassName),\n value: xAxisLabel,\n position: \"insideBottom\",\n offset: -20,\n ...props,\n ...xAxisLabelProps,\n }),\n [xAxisLabel, xAxisLabelClassName, xAxisLabelProps],\n )\n\n const getYAxisLabelProps: ChartPropGetter<\n \"div\",\n Partial<Recharts.LabelProps>,\n Recharts.LabelProps\n > = useCallback(\n ({ className, ...props } = {}) => ({\n className: cx(className, yAxisLabelClassName),\n value: yAxisLabel,\n position: \"insideLeft\",\n angle: -90,\n textAnchor: \"middle\",\n offset: -5,\n ...props,\n ...yAxisLabelProps,\n }),\n [yAxisLabel, yAxisLabelClassName, yAxisLabelProps],\n )\n\n return {\n getXAxisProps,\n getYAxisProps,\n getXAxisLabelProps,\n getYAxisLabelProps,\n }\n}\n\nconst valueToPercent = (value: any) => {\n return `${(value * 100).toFixed(0)}%`\n}\n"],"mappings":";;;;;;;;;;;AACA,SAAS,gBAAgB;AAEzB,SAAS,UAAU;AAEnB,SAAS,aAAa,eAAe;AAqG9B,IAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,WAAW;AAAA,EACX,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,YA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ACL;AAAA,IACA,CAAC,YAAY,qBAAqB,eAAe;AAAA,EACnD;AAEA,QAAM,qBAIF;AAAA,IACF,CAAC,EAAE,WAAW,GAAG,MAAM,IAAI,CAAC,OAAO;AAAA,MACjC,WAAW,GAAG,WAAW,mBAAmB;AAAA,MAC5C,OAAO;AAAA,MACP,UAAU;AAAA,MACV,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAAA,IACA,CAAC,YAAY,qBAAqB,eAAe;AAAA,EACnD;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,IAAM,iBAAiB,CAAC,UAAe;AACrC,SAAO,IAAI,QAAQ,KAAK,QAAQ,CAAC,CAAC;AACpC;","names":[]}
@@ -1,19 +1,19 @@
1
1
  "use client"
2
2
  import {
3
3
  usePieChart
4
- } from "./chunk-FTAFXLVL.mjs";
4
+ } from "./chunk-BGMNYKQY.mjs";
5
5
  import {
6
6
  useChartLegend
7
7
  } from "./chunk-5Q6O726L.mjs";
8
8
  import {
9
9
  useChartTooltip
10
- } from "./chunk-UK6B6KJ7.mjs";
10
+ } from "./chunk-AOGTJ4EN.mjs";
11
11
  import {
12
12
  ChartLegend
13
13
  } from "./chunk-DGOXJ373.mjs";
14
14
  import {
15
15
  ChartTooltip
16
- } from "./chunk-PSJKBKOF.mjs";
16
+ } from "./chunk-MT5JI4OR.mjs";
17
17
  import {
18
18
  ChartProvider,
19
19
  useChart
@@ -52,6 +52,7 @@ var DonutChart = forwardRef((props, ref) => {
52
52
  tooltipAnimationDuration,
53
53
  tooltipDataSource = "all",
54
54
  valueFormatter,
55
+ labelFormatter,
55
56
  unit,
56
57
  paddingAngle,
57
58
  startAngle,
@@ -87,7 +88,7 @@ var DonutChart = forwardRef((props, ref) => {
87
88
  withLabelLines,
88
89
  labelOffset,
89
90
  isPercent,
90
- valueFormatter,
91
+ labelFormatter,
91
92
  styles
92
93
  });
93
94
  const { getContainerProps } = useChart({ containerProps });
@@ -179,4 +180,4 @@ var DonutChart = forwardRef((props, ref) => {
179
180
  export {
180
181
  DonutChart
181
182
  };
182
- //# sourceMappingURL=chunk-TSAITPYC.mjs.map
183
+ //# sourceMappingURL=chunk-XUAAKVRL.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 labelFormatter,\n unit,\n paddingAngle,\n startAngle,\n endAngle,\n withLabels,\n withLabelLines,\n labelOffset,\n isPercent,\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 isPercent,\n labelFormatter,\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;AAgGC,cAoBE,YApBF;AArED,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;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,IAAI,SAAS,EAAE,eAAe,CAAC;AACzD,QAAM,EAAE,cAAc,sBAAsB,gBAAgB,IAC1D,gBAAgB;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;A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AA,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":[]}
@@ -4,6 +4,7 @@ import './chart.types.mjs';
4
4
  import '@yamada-ui/utils';
5
5
  import 'react';
6
6
  import 'recharts';
7
+ import './rechart-properties.mjs';
7
8
  import './use-chart.mjs';
8
9
  import './use-chart-legend.mjs';
9
10
  import './use-chart-tooltip.mjs';
@@ -4,6 +4,7 @@ import './chart.types.js';
4
4
  import '@yamada-ui/utils';
5
5
  import 'react';
6
6
  import 'recharts';
7
+ import './rechart-properties.js';
7
8
  import './use-chart.js';
8
9
  import './use-chart-legend.js';
9
10
  import './use-chart-tooltip.js';
@@ -228,20 +228,29 @@ var import_core4 = require("@yamada-ui/core");
228
228
  var import_utils4 = require("@yamada-ui/utils");
229
229
  var import_jsx_runtime2 = require("react/jsx-runtime");
230
230
  var ChartTooltip = (0, import_core4.forwardRef)(
231
- ({ label, className, payload = [], valueFormatter, unit, ...rest }, ref) => {
231
+ ({
232
+ label,
233
+ className,
234
+ payload = [],
235
+ valueFormatter,
236
+ labelFormatter,
237
+ unit,
238
+ ...rest
239
+ }, ref) => {
240
+ var _a;
232
241
  const { styles } = useTooltip();
233
242
  const items = payload.map(
234
243
  ({ color: colorProp, name, value: valueProp, payload: payload2 } = {}, index) => {
235
- var _a;
244
+ var _a2;
236
245
  const color = colorProp != null ? colorProp : payload2 == null ? void 0 : payload2.color;
237
246
  let value;
238
247
  if ((0, import_utils4.isArray)(valueProp)) {
239
248
  value = valueProp.map((value2) => {
240
- var _a2;
241
- return `${(_a2 = valueFormatter == null ? void 0 : valueFormatter(value2)) != null ? _a2 : value2}`;
249
+ var _a3;
250
+ return `${(_a3 = valueFormatter == null ? void 0 : valueFormatter(value2)) != null ? _a3 : value2}`;
242
251
  }).join(" - ");
243
252
  } else {
244
- value = (_a = valueFormatter == null ? void 0 : valueFormatter(valueProp)) != null ? _a : valueProp;
253
+ value = (_a2 = valueFormatter == null ? void 0 : valueFormatter(valueProp)) != null ? _a2 : valueProp;
245
254
  }
246
255
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
247
256
  import_core4.ui.div,
@@ -290,7 +299,7 @@ var ChartTooltip = (0, import_core4.forwardRef)(
290
299
  __css: styles.tooltip,
291
300
  ...rest,
292
301
  children: [
293
- label ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core4.ui.p, { className: "ui-chart__tooltip-title", __css: styles.tooltipTitle, children: label }) : null,
302
+ label ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core4.ui.p, { className: "ui-chart__tooltip-title", __css: styles.tooltipTitle, children: (_a = labelFormatter == null ? void 0 : labelFormatter(label)) != null ? _a : label }) : null,
294
303
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core4.ui.div, { className: "ui-chart__tooltip-list", __css: styles.tooltipList, children: items })
295
304
  ]
296
305
  }
@@ -381,7 +390,7 @@ var pieChartLabel = ({
381
390
  labelOffset: labelOffsetProp,
382
391
  isPercent,
383
392
  labelProps,
384
- valueFormatter,
393
+ labelFormatter,
385
394
  styles
386
395
  }) => {
387
396
  const labelOffset = labelOffsetProp != null ? labelOffsetProp : (outerRadius - innerRadius) * 0.5 + DEFAULT_LABEL_OFFSET;
@@ -391,8 +400,8 @@ var pieChartLabel = ({
391
400
  const displayLabel = () => {
392
401
  if (isPercent) {
393
402
  return parseFloat((percent * 100).toFixed(0)) > 0 && `${(percent * 100).toFixed(0)}%`;
394
- } else if (!(0, import_utils7.isUndefined)(valueFormatter)) {
395
- return valueFormatter(value);
403
+ } else if (!(0, import_utils7.isUndefined)(labelFormatter)) {
404
+ return labelFormatter(value);
396
405
  } else {
397
406
  return value;
398
407
  }
@@ -453,7 +462,7 @@ var usePieChart = ({
453
462
  paddingAngle = 0,
454
463
  startAngle = 90,
455
464
  endAngle = -270,
456
- valueFormatter,
465
+ labelFormatter,
457
466
  styles,
458
467
  ...rest
459
468
  }) => {
@@ -533,11 +542,11 @@ var usePieChart = ({
533
542
  labelOffset,
534
543
  isPercent,
535
544
  labelProps,
536
- valueFormatter,
545
+ labelFormatter,
537
546
  styles: styles.label,
538
547
  ...props
539
548
  }),
540
- [isPercent, labelOffset, labelProps, styles.label, valueFormatter]
549
+ [isPercent, labelOffset, labelProps, styles.label, labelFormatter]
541
550
  );
542
551
  const labelLine = (0, import_react4.useCallback)(
543
552
  (props) => {
@@ -666,6 +675,7 @@ var DonutChart = (0, import_core8.forwardRef)((props, ref) => {
666
675
  tooltipAnimationDuration,
667
676
  tooltipDataSource = "all",
668
677
  valueFormatter,
678
+ labelFormatter,
669
679
  unit,
670
680
  paddingAngle,
671
681
  startAngle,
@@ -701,7 +711,7 @@ var DonutChart = (0, import_core8.forwardRef)((props, ref) => {
701
711
  withLabelLines,
702
712
  labelOffset,
703
713
  isPercent,
704
- valueFormatter,
714
+ labelFormatter,
705
715
  styles
706
716
  });
707
717
  const { getContainerProps } = useChart({ containerProps });