@yamada-ui/charts 2.0.0-next-20240820160301 → 2.0.0-next-20240908154823
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +7 -13
- package/dist/area-chart-split.js +4 -2
- package/dist/area-chart-split.js.map +1 -1
- package/dist/area-chart-split.mjs +1 -1
- package/dist/area-chart.d.mts +1 -2
- package/dist/area-chart.d.ts +1 -2
- package/dist/area-chart.js +57 -50
- package/dist/area-chart.js.map +1 -1
- package/dist/area-chart.mjs +12 -12
- package/dist/bar-chart.d.mts +1 -2
- package/dist/bar-chart.d.ts +1 -2
- package/dist/bar-chart.js +15 -9
- package/dist/bar-chart.js.map +1 -1
- package/dist/bar-chart.mjs +11 -11
- package/dist/chart-legend.mjs +3 -3
- package/dist/chart-tooltip.d.mts +3 -1
- package/dist/chart-tooltip.d.ts +3 -1
- package/dist/chart-tooltip.js +9 -1
- package/dist/chart-tooltip.js.map +1 -1
- package/dist/chart-tooltip.mjs +3 -3
- package/dist/chart.types.d.mts +12 -5
- package/dist/chart.types.d.ts +12 -5
- package/dist/chart.types.js.map +1 -1
- package/dist/{chunk-STBYN5JW.mjs → chunk-3AOICU4Q.mjs} +2 -2
- package/dist/chunk-3HQ2UC3I.mjs +45 -0
- package/dist/chunk-3HQ2UC3I.mjs.map +1 -0
- package/dist/{chunk-FALZDKAW.mjs → chunk-3VKCTSPC.mjs} +10 -11
- package/dist/chunk-3VKCTSPC.mjs.map +1 -0
- package/dist/{chunk-S5NKKKV5.mjs → chunk-5PSRSNGH.mjs} +7 -8
- package/dist/chunk-5PSRSNGH.mjs.map +1 -0
- package/dist/{chunk-F34FV5DY.mjs → chunk-6YUJLLGN.mjs} +59 -3
- package/dist/chunk-6YUJLLGN.mjs.map +1 -0
- package/dist/{chunk-KBBHISBO.mjs → chunk-BYL7HWNN.mjs} +13 -14
- package/dist/chunk-BYL7HWNN.mjs.map +1 -0
- package/dist/chunk-D5IRVU4W.mjs +46 -0
- package/dist/chunk-D5IRVU4W.mjs.map +1 -0
- package/dist/{chunk-DGOXJ373.mjs → chunk-EL2VTGFB.mjs} +2 -2
- package/dist/{chunk-6L73M52L.mjs → chunk-FPFCMFCJ.mjs} +7 -9
- package/dist/chunk-FPFCMFCJ.mjs.map +1 -0
- package/dist/{chunk-Q7CCSKX3.mjs → chunk-JTQ5QCML.mjs} +4 -4
- package/dist/chunk-JTQ5QCML.mjs.map +1 -0
- package/dist/chunk-KVE6VXTJ.mjs +37 -0
- package/dist/chunk-KVE6VXTJ.mjs.map +1 -0
- package/dist/{chunk-PNE3JG54.mjs → chunk-MGTMKKSH.mjs} +5 -3
- package/dist/chunk-MGTMKKSH.mjs.map +1 -0
- package/dist/chunk-PG7ZV76C.mjs +155 -0
- package/dist/chunk-PG7ZV76C.mjs.map +1 -0
- package/dist/{chunk-D7EZKGCJ.mjs → chunk-PPBHLDVN.mjs} +2 -2
- package/dist/{chunk-AODYT4HF.mjs → chunk-RKO6KM3T.mjs} +13 -14
- package/dist/chunk-RKO6KM3T.mjs.map +1 -0
- package/dist/chunk-SBPKRYF2.mjs +199 -0
- package/dist/chunk-SBPKRYF2.mjs.map +1 -0
- package/dist/{chunk-FCMP6QEZ.mjs → chunk-SWATR7CU.mjs} +14 -15
- package/dist/chunk-SWATR7CU.mjs.map +1 -0
- package/dist/{chunk-MT5JI4OR.mjs → chunk-T5DNDBW6.mjs} +11 -3
- package/dist/chunk-T5DNDBW6.mjs.map +1 -0
- package/dist/{chunk-5Q6O726L.mjs → chunk-TCSYDMC7.mjs} +2 -2
- package/dist/{chunk-UHQ6WE5D.mjs → chunk-TMHSYM3V.mjs} +17 -13
- package/dist/chunk-TMHSYM3V.mjs.map +1 -0
- package/dist/{chunk-AOGTJ4EN.mjs → chunk-VMBRDEM2.mjs} +2 -2
- package/dist/{chunk-XUAAKVRL.mjs → chunk-WMG5U5AU.mjs} +26 -13
- package/dist/chunk-WMG5U5AU.mjs.map +1 -0
- package/dist/{chunk-6BNJZIBK.mjs → chunk-X7XFG7TS.mjs} +10 -12
- package/dist/chunk-X7XFG7TS.mjs.map +1 -0
- package/dist/{chunk-MOFNE6PO.mjs → chunk-XRF3TNSQ.mjs} +6 -30
- package/dist/chunk-XRF3TNSQ.mjs.map +1 -0
- package/dist/{chunk-VK4VQQYY.mjs → chunk-YNJ423BR.mjs} +2 -2
- package/dist/{chunk-BGMNYKQY.mjs → chunk-ZQWVMOT6.mjs} +9 -7
- package/dist/chunk-ZQWVMOT6.mjs.map +1 -0
- package/dist/donut-chart.d.mts +3 -3
- package/dist/donut-chart.d.ts +3 -3
- package/dist/donut-chart.js +109 -58
- package/dist/donut-chart.js.map +1 -1
- package/dist/donut-chart.mjs +9 -8
- package/dist/index.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +599 -167
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -22
- package/dist/index.mjs.map +1 -1
- package/dist/line-chart.d.mts +1 -2
- package/dist/line-chart.d.ts +1 -2
- package/dist/line-chart.js +15 -10
- package/dist/line-chart.js.map +1 -1
- package/dist/line-chart.mjs +11 -11
- package/dist/pie-chart.d.mts +2 -3
- package/dist/pie-chart.d.ts +2 -3
- package/dist/pie-chart.js +13 -7
- package/dist/pie-chart.js.map +1 -1
- package/dist/pie-chart.mjs +8 -8
- package/dist/radar-chart.d.mts +3 -3
- package/dist/radar-chart.d.ts +3 -3
- package/dist/radar-chart.js +90 -70
- package/dist/radar-chart.js.map +1 -1
- package/dist/radar-chart.mjs +9 -8
- package/dist/radial-chart.d.mts +53 -0
- package/dist/radial-chart.d.ts +53 -0
- package/dist/radial-chart.js +767 -0
- package/dist/radial-chart.js.map +1 -0
- package/dist/radial-chart.mjs +18 -0
- package/dist/radial-chart.mjs.map +1 -0
- package/dist/rechart-properties.d.mts +5 -1
- package/dist/rechart-properties.d.ts +5 -1
- package/dist/rechart-properties.js +60 -1
- package/dist/rechart-properties.js.map +1 -1
- package/dist/rechart-properties.mjs +7 -1
- package/dist/use-area-chart.d.mts +1 -2
- package/dist/use-area-chart.d.ts +1 -2
- package/dist/use-area-chart.js +7 -9
- package/dist/use-area-chart.js.map +1 -1
- package/dist/use-area-chart.mjs +2 -2
- package/dist/use-bar-chart.d.mts +1 -2
- package/dist/use-bar-chart.d.ts +1 -2
- package/dist/use-bar-chart.js +4 -5
- package/dist/use-bar-chart.js.map +1 -1
- package/dist/use-bar-chart.mjs +2 -2
- package/dist/use-chart-axis.d.mts +0 -1
- package/dist/use-chart-axis.d.ts +0 -1
- package/dist/use-chart-axis.js.map +1 -1
- package/dist/use-chart-axis.mjs +2 -2
- package/dist/use-chart-grid.d.mts +0 -1
- package/dist/use-chart-grid.d.ts +0 -1
- package/dist/use-chart-grid.js.map +1 -1
- package/dist/use-chart-grid.mjs +2 -2
- package/dist/use-chart-label-list.d.mts +22 -0
- package/dist/use-chart-label-list.d.ts +22 -0
- package/dist/use-chart-label-list.js +93 -0
- package/dist/use-chart-label-list.js.map +1 -0
- package/dist/use-chart-label-list.mjs +10 -0
- package/dist/use-chart-label-list.mjs.map +1 -0
- package/dist/use-chart-label.d.mts +20 -0
- package/dist/use-chart-label.d.ts +20 -0
- package/dist/use-chart-label.js +82 -0
- package/dist/use-chart-label.js.map +1 -0
- package/dist/use-chart-label.mjs +10 -0
- package/dist/use-chart-label.mjs.map +1 -0
- package/dist/use-chart-legend.d.mts +0 -1
- package/dist/use-chart-legend.d.ts +0 -1
- package/dist/use-chart-legend.js.map +1 -1
- package/dist/use-chart-legend.mjs +2 -2
- package/dist/use-chart-reference-line.d.mts +0 -1
- package/dist/use-chart-reference-line.d.ts +0 -1
- package/dist/use-chart-reference-line.js +1 -1
- package/dist/use-chart-reference-line.js.map +1 -1
- package/dist/use-chart-reference-line.mjs +2 -2
- package/dist/use-chart-tooltip.d.mts +0 -1
- package/dist/use-chart-tooltip.d.ts +0 -1
- package/dist/use-chart-tooltip.js.map +1 -1
- package/dist/use-chart-tooltip.mjs +2 -2
- package/dist/use-chart.d.mts +0 -1
- package/dist/use-chart.d.ts +0 -1
- package/dist/use-chart.js.map +1 -1
- package/dist/use-chart.mjs +2 -2
- package/dist/use-line-chart.d.mts +1 -2
- package/dist/use-line-chart.d.ts +1 -2
- package/dist/use-line-chart.js +4 -6
- package/dist/use-line-chart.js.map +1 -1
- package/dist/use-line-chart.mjs +2 -2
- package/dist/use-pie-chart.d.mts +1 -2
- package/dist/use-pie-chart.d.ts +1 -2
- package/dist/use-pie-chart.js +3 -4
- package/dist/use-pie-chart.js.map +1 -1
- package/dist/use-pie-chart.mjs +2 -2
- package/dist/use-polar-grid.d.mts +24 -0
- package/dist/use-polar-grid.d.ts +24 -0
- package/dist/use-polar-grid.js +90 -0
- package/dist/use-polar-grid.js.map +1 -0
- package/dist/use-polar-grid.mjs +10 -0
- package/dist/use-polar-grid.mjs.map +1 -0
- package/dist/use-radar-chart.d.mts +3 -13
- package/dist/use-radar-chart.d.ts +3 -13
- package/dist/use-radar-chart.js +3 -35
- package/dist/use-radar-chart.js.map +1 -1
- package/dist/use-radar-chart.mjs +2 -2
- package/dist/use-radial-chart.d.mts +80 -0
- package/dist/use-radial-chart.d.ts +80 -0
- package/dist/use-radial-chart.js +228 -0
- package/dist/use-radial-chart.js.map +1 -0
- package/dist/use-radial-chart.mjs +10 -0
- package/dist/use-radial-chart.mjs.map +1 -0
- package/package.json +4 -4
- package/dist/chunk-6BNJZIBK.mjs.map +0 -1
- package/dist/chunk-6L73M52L.mjs.map +0 -1
- package/dist/chunk-AODYT4HF.mjs.map +0 -1
- package/dist/chunk-BGMNYKQY.mjs.map +0 -1
- package/dist/chunk-F34FV5DY.mjs.map +0 -1
- package/dist/chunk-FALZDKAW.mjs.map +0 -1
- package/dist/chunk-FCMP6QEZ.mjs.map +0 -1
- package/dist/chunk-KBBHISBO.mjs.map +0 -1
- package/dist/chunk-MOFNE6PO.mjs.map +0 -1
- package/dist/chunk-MT5JI4OR.mjs.map +0 -1
- package/dist/chunk-PNE3JG54.mjs.map +0 -1
- package/dist/chunk-Q7CCSKX3.mjs.map +0 -1
- package/dist/chunk-S5NKKKV5.mjs.map +0 -1
- package/dist/chunk-UHQ6WE5D.mjs.map +0 -1
- package/dist/chunk-XUAAKVRL.mjs.map +0 -1
- /package/dist/{chunk-STBYN5JW.mjs.map → chunk-3AOICU4Q.mjs.map} +0 -0
- /package/dist/{chunk-DGOXJ373.mjs.map → chunk-EL2VTGFB.mjs.map} +0 -0
- /package/dist/{chunk-D7EZKGCJ.mjs.map → chunk-PPBHLDVN.mjs.map} +0 -0
- /package/dist/{chunk-5Q6O726L.mjs.map → chunk-TCSYDMC7.mjs.map} +0 -0
- /package/dist/{chunk-AOGTJ4EN.mjs.map → chunk-VMBRDEM2.mjs.map} +0 -0
- /package/dist/{chunk-VK4VQQYY.mjs.map → chunk-YNJ423BR.mjs.map} +0 -0
@@ -3,13 +3,13 @@ import {
|
|
3
3
|
dotProperties,
|
4
4
|
lineChartProperties,
|
5
5
|
lineProperties
|
6
|
-
} from "./chunk-
|
6
|
+
} from "./chunk-6YUJLLGN.mjs";
|
7
7
|
import {
|
8
8
|
getComponentProps
|
9
9
|
} from "./chunk-QL3DB7OJ.mjs";
|
10
10
|
|
11
11
|
// src/use-line-chart.ts
|
12
|
-
import { useTheme } from "@yamada-ui/core";
|
12
|
+
import { getVar, useTheme } from "@yamada-ui/core";
|
13
13
|
import { cx } from "@yamada-ui/utils";
|
14
14
|
import { useCallback, useMemo, useState } from "react";
|
15
15
|
var useLineChart = ({
|
@@ -42,7 +42,6 @@ var useLineChart = ({
|
|
42
42
|
} = (_a = rest.lineProps) != null ? _a : {};
|
43
43
|
const lineColors = useMemo(
|
44
44
|
() => series.map(({ color }, index) => ({
|
45
|
-
__prefix: "ui",
|
46
45
|
name: `line-${index}`,
|
47
46
|
token: "colors",
|
48
47
|
value: color != null ? color : "transparent"
|
@@ -51,7 +50,6 @@ var useLineChart = ({
|
|
51
50
|
);
|
52
51
|
const referenceLineColors = useMemo(
|
53
52
|
() => referenceLineProps ? referenceLineProps.map(({ color }, index) => ({
|
54
|
-
__prefix: "ui",
|
55
53
|
name: `reference-line-${index}`,
|
56
54
|
token: "colors",
|
57
55
|
value: color != null ? color : "transparent"
|
@@ -62,7 +60,7 @@ var useLineChart = ({
|
|
62
60
|
() => [
|
63
61
|
...lineColors,
|
64
62
|
...referenceLineColors,
|
65
|
-
{
|
63
|
+
{ name: "fill-opacity", value: fillOpacity }
|
66
64
|
],
|
67
65
|
[fillOpacity, lineColors, referenceLineColors]
|
68
66
|
);
|
@@ -78,8 +76,8 @@ var useLineChart = ({
|
|
78
76
|
);
|
79
77
|
const [lineProps, lineClassName] = useMemo(() => {
|
80
78
|
const resolvedLineProps = {
|
81
|
-
fillOpacity: "
|
82
|
-
strokeOpacity: "
|
79
|
+
fillOpacity: "$fill-opacity",
|
80
|
+
strokeOpacity: "$fill-opacity",
|
83
81
|
...computedLineProps
|
84
82
|
};
|
85
83
|
return getComponentProps(
|
@@ -122,7 +120,7 @@ var useLineChart = ({
|
|
122
120
|
dimLine: dimLine2 = {},
|
123
121
|
...computedProps
|
124
122
|
} = props;
|
125
|
-
const color = `
|
123
|
+
const color = getVar(`line-${index}`)(theme);
|
126
124
|
const dimmed = shouldHighlight && highlightedArea !== dataKey;
|
127
125
|
const computedDimLine = { ...dimLineProps, ...dimLine2 };
|
128
126
|
const resolvedProps = {
|
@@ -262,4 +260,4 @@ var useLineChart = ({
|
|
262
260
|
export {
|
263
261
|
useLineChart
|
264
262
|
};
|
265
|
-
//# sourceMappingURL=chunk-
|
263
|
+
//# sourceMappingURL=chunk-FPFCMFCJ.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/use-line-chart.ts"],"sourcesContent":["import { getVar, useTheme } from \"@yamada-ui/core\"\nimport type { CSSUIObject, CSSUIProps } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport type { ComponentPropsWithoutRef } from \"react\"\nimport { useCallback, useMemo, useState } from \"react\"\nimport type * as Recharts from \"recharts\"\nimport { getComponentProps } from \"./chart-utils\"\nimport type {\n ChartLayoutType,\n LineProps,\n LineChartProps,\n ReferenceLineProps,\n ChartPropGetter,\n ChartCurveType,\n RequiredChartPropGetter,\n} from \"./chart.types\"\nimport {\n dotProperties,\n lineChartProperties,\n lineProperties,\n} from \"./rechart-properties\"\n\nexport type UseLineChartOptions = {\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: LineProps[]\n /**\n * Props for the lines.\n */\n lineProps?: Partial<LineProps>\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 `LineChart` component.\n */\n chartProps?: LineChartProps\n /**\n * Chart orientation.\n *\n * @default 'horizontal'\n */\n layoutType?: ChartLayoutType\n /**\n * Determines whether dots should be displayed.\n *\n * @default true\n */\n withDots?: boolean\n /**\n * Determines whether activeDots should be displayed.\n *\n * @default true\n */\n withActiveDots?: boolean\n /**\n * Type of the curve.\n *\n * @default `monotone`\n */\n curveType?: ChartCurveType\n /**\n * Stroke width for the chart lines.\n *\n * @default 2\n */\n strokeWidth?: number\n /**\n * Determines whether points with `null` values should be connected.\n *\n * @default true\n */\n connectNulls?: boolean\n /**\n * Reference lines that should be displayed on the chart.\n */\n referenceLineProps?: ReferenceLineProps[]\n /**\n * Controls fill opacity of all lines.\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\ntype UseLineChartProps = UseLineChartOptions & {\n styles: Dict<CSSUIObject>\n}\n\nexport const useLineChart = ({\n data,\n series,\n layoutType = \"horizontal\",\n withDots = true,\n withActiveDots = true,\n curveType = \"monotone\",\n strokeWidth = 2,\n connectNulls = true,\n referenceLineProps,\n fillOpacity = 1,\n syncId,\n xAxisLabel,\n yAxisLabel,\n styles,\n ...rest\n}: UseLineChartProps) => {\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 dimLine = {},\n ...computedLineProps\n } = rest.lineProps ?? {}\n\n const lineColors: CSSUIProps[\"vars\"] = useMemo(\n () =>\n series.map(({ color }, index) => ({\n name: `line-${index}`,\n token: \"colors\",\n value: color ?? \"transparent\",\n })),\n [series],\n )\n\n const referenceLineColors: CSSUIProps[\"vars\"] = useMemo(\n () =>\n referenceLineProps\n ? referenceLineProps.map(({ color }, index) => ({\n name: `reference-line-${index}`,\n token: \"colors\",\n value: color ?? \"transparent\",\n }))\n : [],\n [referenceLineProps],\n )\n\n const lineVars: CSSUIProps[\"vars\"] = useMemo(\n () => [\n ...lineColors,\n ...referenceLineColors,\n { name: \"fill-opacity\", value: fillOpacity },\n ],\n [fillOpacity, lineColors, referenceLineColors],\n )\n\n const [chartProps, lineChartClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [rest.chartProps ?? {}, lineChartProperties],\n styles.chart,\n )(theme),\n [rest.chartProps, styles.chart, theme],\n )\n\n const [lineProps, lineClassName] = useMemo(() => {\n const resolvedLineProps = {\n fillOpacity: \"$fill-opacity\",\n strokeOpacity: \"$fill-opacity\",\n ...computedLineProps,\n }\n\n return getComponentProps<Dict, string>(\n [resolvedLineProps, lineProperties],\n styles.line,\n )(theme)\n }, [computedLineProps, styles.line, theme])\n\n const [dimLineProps, dimLineClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [dimLine, lineProperties],\n styles.dimLine,\n )(theme),\n [dimLine, styles.dimLine, 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 linePropList = useMemo(\n () =>\n series.map((props, index) => {\n const {\n dataKey,\n dot = {},\n activeDot = {},\n dimDot = {},\n dimLine = {},\n ...computedProps\n } = props\n const color = getVar(`line-${index}`)(theme)\n const dimmed = shouldHighlight && highlightedArea !== dataKey\n const computedDimLine = { ...dimLineProps, ...dimLine }\n const resolvedProps = {\n ...lineProps,\n ...computedProps,\n ...(dimmed ? computedDimLine : {}),\n }\n\n const rest = getComponentProps<Dict, string>(\n [resolvedProps, lineProperties],\n lineClassName,\n dimmed ? dimLineClassName : undefined,\n )(theme, true)\n\n let resolvedActiveDot: Recharts.DotProps | boolean\n\n if (withActiveDots) {\n const computedActiveDot = { ...activeDotProps, ...activeDot }\n\n const [rest, className] = getComponentProps(\n [computedActiveDot, dotProperties],\n activeDotClassName,\n )(theme)\n\n resolvedActiveDot = {\n className: cx(\n \"ui-line-chart__dot\",\n \"ui-line-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-line-chart__dot\", className),\n fill: color,\n ...rest,\n } as Recharts.DotProps\n } else {\n resolvedDot = false\n }\n\n return {\n ...rest,\n color,\n dataKey,\n activeDot: resolvedActiveDot,\n dot: resolvedDot,\n }\n }),\n [\n series,\n shouldHighlight,\n highlightedArea,\n dimLineProps,\n lineProps,\n lineClassName,\n dimLineClassName,\n theme,\n withActiveDots,\n withDots,\n activeDotProps,\n activeDotClassName,\n dimDotProps,\n dotProps,\n dotClassName,\n dimDotClassName,\n ],\n )\n\n const getLineChartProps: ChartPropGetter<\n \"div\",\n ComponentPropsWithoutRef<typeof Recharts.LineChart>,\n ComponentPropsWithoutRef<typeof Recharts.LineChart>\n > = useCallback(\n ({ className, ...props } = {}, ref = null) => ({\n ref,\n className: cx(className, lineChartClassName),\n data,\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 lineChartClassName,\n data,\n layoutType,\n syncId,\n xAxisLabel,\n yAxisLabel,\n chartProps,\n ],\n )\n\n const getLineProps: RequiredChartPropGetter<\n \"div\",\n {\n index: number\n },\n Omit<Recharts.LineProps, \"ref\">\n > = useCallback(\n ({ index, className: classNameProp, ...props }, ref = null) => {\n const { color, className, dataKey, activeDot, dot, ...rest } =\n linePropList[index]\n\n return {\n ref,\n className: cx(classNameProp, className),\n activeDot,\n dot,\n name: dataKey as string,\n type: curveType,\n dataKey,\n fill: color,\n strokeWidth,\n stroke: color,\n isAnimationActive: false,\n connectNulls,\n ...(props as Omit<Recharts.LineProps, \"dataKey\">),\n ...rest,\n }\n },\n [connectNulls, curveType, linePropList, strokeWidth],\n )\n\n return {\n getLineProps,\n getLineChartProps,\n lineVars,\n setHighlightedArea,\n }\n}\n\nexport type UseLineChartReturn = ReturnType<typeof useLineChart>\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,QAAQ,gBAAgB;AAEjC,SAAS,UAAU;AAGnB,SAAS,aAAa,SAAS,gBAAgB;AAoGxC,IAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,WAAW;AAAA,EACX,iBAAiB;AAAA,EACjB,YAAY;AAAA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AAI;AAAA,QACJ,GAAGI;AAAA,MACL;AAAA,IACF;AAAA,IACA,CAAC,cAAc,WAAW,cAAc,WAAW;AAAA,EACrD;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["_a","dot","activeDot","dimDot","dimLine","rest"]}
|
@@ -1,13 +1,13 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
referenceLineProperties
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-6YUJLLGN.mjs";
|
5
5
|
import {
|
6
6
|
getComponentProps
|
7
7
|
} from "./chunk-QL3DB7OJ.mjs";
|
8
8
|
|
9
9
|
// src/use-chart-reference-line.ts
|
10
|
-
import { getCSS, useTheme } from "@yamada-ui/core";
|
10
|
+
import { getCSS, getVar, useTheme } from "@yamada-ui/core";
|
11
11
|
import { isObject, cx } from "@yamada-ui/utils";
|
12
12
|
import { useCallback, useMemo } from "react";
|
13
13
|
var useChartReferenceLine = ({
|
@@ -22,7 +22,7 @@ var useChartReferenceLine = ({
|
|
22
22
|
[props, referenceLineProperties],
|
23
23
|
styleClassName
|
24
24
|
)(theme);
|
25
|
-
const color = `
|
25
|
+
const color = getVar(`reference-line-${index}`)(theme);
|
26
26
|
const label = {
|
27
27
|
value: labelProp,
|
28
28
|
fill: color,
|
@@ -53,4 +53,4 @@ var useChartReferenceLine = ({
|
|
53
53
|
export {
|
54
54
|
useChartReferenceLine
|
55
55
|
};
|
56
|
-
//# sourceMappingURL=chunk-
|
56
|
+
//# sourceMappingURL=chunk-JTQ5QCML.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/use-chart-reference-line.ts"],"sourcesContent":["import { getCSS, getVar, useTheme } from \"@yamada-ui/core\"\nimport type { CSSUIObject } from \"@yamada-ui/core\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport { isObject, cx } from \"@yamada-ui/utils\"\nimport { useCallback, useMemo } from \"react\"\nimport type * as Recharts from \"recharts\"\nimport { getComponentProps } from \"./chart-utils\"\nimport type { ReferenceLineProps, RequiredChartPropGetter } from \"./chart.types\"\nimport { referenceLineProperties } from \"./rechart-properties\"\n\nexport type UseChartReferenceLineOptions = {\n /**\n * Reference lines that should be displayed on the chart.\n */\n referenceLineProps?: ReferenceLineProps[]\n}\n\ntype UseChartReferenceLineProps = UseChartReferenceLineOptions & {\n styles: Dict<CSSUIObject>\n}\n\nexport const useChartReferenceLine = ({\n referenceLineProps = [],\n styles,\n}: UseChartReferenceLineProps) => {\n const { theme } = useTheme()\n const styleClassName = getCSS(styles.referenceLine)(theme)\n const propList = useMemo(\n () =>\n referenceLineProps.map((props, index) => {\n const [{ label: labelProp, ...rest }, propClassName] =\n getComponentProps(\n [props, referenceLineProperties],\n styleClassName,\n )(theme)\n\n const color = getVar(`reference-line-${index}`)(theme)\n const label: Recharts.ReferenceLineProps[\"label\"] = {\n value: labelProp as string,\n fill: color,\n position: \"insideBottomLeft\",\n ...(isObject(labelProp) ? labelProp : {}),\n }\n\n return { propClassName, color, label, ...rest }\n }),\n [referenceLineProps, styleClassName, theme],\n )\n\n const getReferenceLineProps: RequiredChartPropGetter<\n \"div\",\n {\n index: number\n },\n Omit<Recharts.ReferenceLineProps, \"ref\">\n > = useCallback(\n ({ index, className, ...props }, ref = null) => {\n const { propClassName, color, label, ...rest } = propList[index]\n\n return {\n ref,\n className: cx(className, propClassName),\n stroke: color,\n label,\n ...(props as Recharts.ReferenceLineProps),\n ...rest,\n }\n },\n [propList],\n )\n\n return { getReferenceLineProps }\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,QAAQ,QAAQ,gBAAgB;AAGzC,SAAS,UAAU,UAAU;AAC7B,SAAS,aAAa,eAAe;AAiB9B,IAAM,wBAAwB,CAAC;AAAA,EACpC,qBAAqB,CAAC;AAAA,EACtB;AACF,MAAkC;AAChC,QAAM,EAAE,MAAM,IAAI,SAAS;AAC3B,QAAM,iBAAiB,OAAO,OAAO,aAAa,EAAE,KAAK;AACzD,QAAM,WAAW;AAAA,IACf,MACE,mBAAmB,IAAI,CAAC,OAAO,UAAU;AACvC,YAAM,CAAC,EAAE,OAAO,WAAW,GAAG,KAAK,GAAG,aAAa,IACjD;AAAA,QACE,CAAC,OAAO,uBAAuB;AAAA,QAC/B;AAAA,MACF,EAAE,KAAK;AAET,YAAM,QAAQ,OAAO,kBAAkB,KAAK,EAAE,EAAE,KAAK;AACrD,YAAM,QAA8C;AAAA,QAClD,OAAO;AAAA,QACP,MAAM;AAAA,QACN,UAAU;AAAA,QACV,GAAI,SAAS,SAAS,IAAI,YAAY,CAAC;AAAA,MACzC;AAEA,aAAO,EAAE,eAAe,OAAO,OAAO,GAAG,KAAK;AAAA,IAChD,CAAC;AAAA,IACH,CAAC,oBAAoB,gBAAgB,KAAK;AAAA,EAC5C;AAEA,QAAM,wBAMF;AAAA,IACF,CAAC,EAAE,OAAO,WAAW,GAAG,MAAM,GAAG,MAAM,SAAS;AAC9C,YAAM,EAAE,eAAe,OAAO,OAAO,GAAG,KAAK,IAAI,SAAS,KAAK;AAE/D,aAAO;AAAA,QACL;AAAA,QACA,WAAW,GAAG,WAAW,aAAa;AAAA,QACtC,QAAQ;AAAA,QACR;AAAA,QACA,GAAI;AAAA,QACJ,GAAG;AAAA,MACL;AAAA,IACF;AAAA,IACA,CAAC,QAAQ;AAAA,EACX;AAEA,SAAO,EAAE,sBAAsB;AACjC;","names":[]}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
"use client"
|
2
|
+
import {
|
3
|
+
labelProperties
|
4
|
+
} from "./chunk-6YUJLLGN.mjs";
|
5
|
+
import {
|
6
|
+
getComponentProps
|
7
|
+
} from "./chunk-QL3DB7OJ.mjs";
|
8
|
+
|
9
|
+
// src/use-chart-label.ts
|
10
|
+
import { useTheme } from "@yamada-ui/core";
|
11
|
+
import { cx } from "@yamada-ui/utils";
|
12
|
+
import { useCallback } from "react";
|
13
|
+
var useChartLabel = ({ styles, ...rest }) => {
|
14
|
+
var _a;
|
15
|
+
const { theme } = useTheme();
|
16
|
+
const [labelProps, labelClassName] = getComponentProps(
|
17
|
+
[(_a = rest.labelProps) != null ? _a : {}, labelProperties],
|
18
|
+
styles.label
|
19
|
+
)(theme);
|
20
|
+
const getLabelProps = useCallback(
|
21
|
+
({ className, ...props } = {}, ref = null) => {
|
22
|
+
return {
|
23
|
+
ref,
|
24
|
+
className: cx(className, labelClassName),
|
25
|
+
...props,
|
26
|
+
...labelProps
|
27
|
+
};
|
28
|
+
},
|
29
|
+
[labelClassName, labelProps]
|
30
|
+
);
|
31
|
+
return { getLabelProps };
|
32
|
+
};
|
33
|
+
|
34
|
+
export {
|
35
|
+
useChartLabel
|
36
|
+
};
|
37
|
+
//# sourceMappingURL=chunk-KVE6VXTJ.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/use-chart-label.ts"],"sourcesContent":["import { useTheme, type CSSUIObject } from \"@yamada-ui/core\"\nimport { cx, type Dict } from \"@yamada-ui/utils\"\nimport { useCallback } from \"react\"\nimport type * as Recharts from \"recharts\"\nimport { getComponentProps } from \"./chart-utils\"\nimport type { ChartPropGetter, LabelProps } from \"./chart.types\"\nimport { labelProperties } from \"./rechart-properties\"\n\nexport type UseChartLabelOptions = {\n /**\n * Props passed down to recharts 'Label' component.\n */\n labelProps?: LabelProps\n}\n\nexport type UseChartLabelProps = UseChartLabelOptions & {\n styles: Dict<CSSUIObject>\n}\n\nexport const useChartLabel = ({ styles, ...rest }: UseChartLabelProps) => {\n const { theme } = useTheme()\n\n const [labelProps, labelClassName] = getComponentProps<Dict, string>(\n [rest.labelProps ?? {}, labelProperties],\n styles.label,\n )(theme)\n\n const getLabelProps: ChartPropGetter<\n \"div\",\n Omit<Recharts.LabelProps, \"ref\">,\n Omit<Recharts.LabelProps, \"ref\">\n > = useCallback(\n ({ className, ...props } = {}, ref = null) => {\n return {\n ref,\n className: cx(className, labelClassName),\n ...props,\n ...labelProps,\n }\n },\n [labelClassName, labelProps],\n )\n\n return { getLabelProps }\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,gBAAkC;AAC3C,SAAS,UAAqB;AAC9B,SAAS,mBAAmB;AAiBrB,IAAM,gBAAgB,CAAC,EAAE,QAAQ,GAAG,KAAK,MAA0B;AAnB1E;AAoBE,QAAM,EAAE,MAAM,IAAI,SAAS;AAE3B,QAAM,CAAC,YAAY,cAAc,IAAI;AAAA,IACnC,EAAC,UAAK,eAAL,YAAmB,CAAC,GAAG,eAAe;AAAA,IACvC,OAAO;AAAA,EACT,EAAE,KAAK;AAEP,QAAM,gBAIF;AAAA,IACF,CAAC,EAAE,WAAW,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,SAAS;AAC5C,aAAO;AAAA,QACL;AAAA,QACA,WAAW,GAAG,WAAW,cAAc;AAAA,QACvC,GAAG;AAAA,QACH,GAAG;AAAA,MACL;AAAA,IACF;AAAA,IACA,CAAC,gBAAgB,UAAU;AAAA,EAC7B;AAEA,SAAO,EAAE,cAAc;AACzB;","names":[]}
|
@@ -1,14 +1,16 @@
|
|
1
1
|
"use client"
|
2
2
|
|
3
3
|
// src/area-chart-split.tsx
|
4
|
+
import { getVar, useTheme } from "@yamada-ui/core";
|
4
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
5
6
|
var AreaSplit = ({ offset, id, fillOpacity }) => {
|
7
|
+
const { theme } = useTheme();
|
6
8
|
return /* @__PURE__ */ jsxs("linearGradient", { id, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
7
9
|
/* @__PURE__ */ jsx(
|
8
10
|
"stop",
|
9
11
|
{
|
10
12
|
offset,
|
11
|
-
stopColor:
|
13
|
+
stopColor: getVar(`area-split-0`)(theme),
|
12
14
|
stopOpacity: fillOpacity != null ? fillOpacity : 0.4
|
13
15
|
}
|
14
16
|
),
|
@@ -16,7 +18,7 @@ var AreaSplit = ({ offset, id, fillOpacity }) => {
|
|
16
18
|
"stop",
|
17
19
|
{
|
18
20
|
offset,
|
19
|
-
stopColor:
|
21
|
+
stopColor: getVar(`area-split-1`)(theme),
|
20
22
|
stopOpacity: fillOpacity != null ? fillOpacity : 0.4
|
21
23
|
}
|
22
24
|
)
|
@@ -26,4 +28,4 @@ var AreaSplit = ({ offset, id, fillOpacity }) => {
|
|
26
28
|
export {
|
27
29
|
AreaSplit
|
28
30
|
};
|
29
|
-
//# sourceMappingURL=chunk-
|
31
|
+
//# sourceMappingURL=chunk-MGTMKKSH.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/area-chart-split.tsx"],"sourcesContent":["import { getVar, useTheme } from \"@yamada-ui/core\"\n\nexport type AreaSplitProps = {\n offset: number\n id?: string\n fillOpacity: number | string | undefined\n}\n\nexport const AreaSplit = ({ offset, id, fillOpacity }: AreaSplitProps) => {\n const { theme } = useTheme()\n\n return (\n <linearGradient id={id} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n <stop\n offset={offset}\n stopColor={getVar(`area-split-0`)(theme)}\n stopOpacity={fillOpacity ?? 0.4}\n />\n <stop\n offset={offset}\n stopColor={getVar(`area-split-1`)(theme)}\n stopOpacity={fillOpacity ?? 0.4}\n />\n </linearGradient>\n )\n}\n"],"mappings":";;;AAAA,SAAS,QAAQ,gBAAgB;AAY7B,SACE,KADF;AAJG,IAAM,YAAY,CAAC,EAAE,QAAQ,IAAI,YAAY,MAAsB;AACxE,QAAM,EAAE,MAAM,IAAI,SAAS;AAE3B,SACE,qBAAC,oBAAe,IAAQ,IAAG,KAAI,IAAG,KAAI,IAAG,KAAI,IAAG,KAC9C;AAAA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,WAAW,OAAO,cAAc,EAAE,KAAK;AAAA,QACvC,aAAa,oCAAe;AAAA;AAAA,IAC9B;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,WAAW,OAAO,cAAc,EAAE,KAAK;AAAA,QACvC,aAAa,oCAAe;AAAA;AAAA,IAC9B;AAAA,KACF;AAEJ;","names":[]}
|
@@ -0,0 +1,155 @@
|
|
1
|
+
"use client"
|
2
|
+
import {
|
3
|
+
radialBarProperties,
|
4
|
+
radialChartProperties
|
5
|
+
} from "./chunk-6YUJLLGN.mjs";
|
6
|
+
import {
|
7
|
+
getClassName,
|
8
|
+
getComponentProps
|
9
|
+
} from "./chunk-QL3DB7OJ.mjs";
|
10
|
+
|
11
|
+
// src/use-radial-chart.ts
|
12
|
+
import { getVar, useTheme } from "@yamada-ui/core";
|
13
|
+
import { cx } from "@yamada-ui/utils";
|
14
|
+
import { useCallback, useMemo, useState } from "react";
|
15
|
+
var useRadialChart = ({
|
16
|
+
data: dataProp,
|
17
|
+
dataKey = "value",
|
18
|
+
innerRadius = "10%",
|
19
|
+
outerRadius = "80%",
|
20
|
+
startAngle = 90,
|
21
|
+
endAngle = -180,
|
22
|
+
fillOpacity = 1,
|
23
|
+
styles,
|
24
|
+
...rest
|
25
|
+
}) => {
|
26
|
+
var _a;
|
27
|
+
const { theme } = useTheme();
|
28
|
+
const [highlightedArea, setHighlightedArea] = useState(null);
|
29
|
+
const shouldHighlight = highlightedArea !== null;
|
30
|
+
const {
|
31
|
+
background: backgroundProps = {},
|
32
|
+
dimRadialBar: dimRadialBarProps = {},
|
33
|
+
...computedRadialBarProps
|
34
|
+
} = (_a = rest.radialBarProps) != null ? _a : {};
|
35
|
+
const radialVars = useMemo(
|
36
|
+
() => dataProp.map(({ color }, index) => ({
|
37
|
+
name: `radial-bar-${index}`,
|
38
|
+
token: "colors",
|
39
|
+
value: color != null ? color : "transparent"
|
40
|
+
})),
|
41
|
+
[dataProp]
|
42
|
+
);
|
43
|
+
const dimRadialBarClassName = useMemo(() => {
|
44
|
+
const resolvedDimRadialBar = {
|
45
|
+
fillOpacity: 0.3,
|
46
|
+
strokeOpacity: 0,
|
47
|
+
...dimRadialBarProps
|
48
|
+
};
|
49
|
+
return getClassName(resolvedDimRadialBar)(theme);
|
50
|
+
}, [dimRadialBarProps, theme]);
|
51
|
+
const [chartProps, chartClassName] = useMemo(
|
52
|
+
() => {
|
53
|
+
var _a2;
|
54
|
+
return getComponentProps(
|
55
|
+
[(_a2 = rest.chartProps) != null ? _a2 : {}, radialChartProperties],
|
56
|
+
styles.chart
|
57
|
+
)(theme);
|
58
|
+
},
|
59
|
+
[rest.chartProps, styles.chart, theme]
|
60
|
+
);
|
61
|
+
const background = useMemo(
|
62
|
+
() => getComponentProps(
|
63
|
+
[backgroundProps, radialBarProperties],
|
64
|
+
styles.background
|
65
|
+
)(theme, true),
|
66
|
+
[backgroundProps, styles.background, theme]
|
67
|
+
);
|
68
|
+
const [radialBarProps, radialBarClassName] = useMemo(
|
69
|
+
() => getComponentProps(
|
70
|
+
[computedRadialBarProps != null ? computedRadialBarProps : {}, radialBarProperties],
|
71
|
+
styles.radialBar
|
72
|
+
)(theme),
|
73
|
+
[computedRadialBarProps, styles.radialBar, theme]
|
74
|
+
);
|
75
|
+
const data = useMemo(
|
76
|
+
() => dataProp.map((props, index) => {
|
77
|
+
const {
|
78
|
+
name,
|
79
|
+
value,
|
80
|
+
color,
|
81
|
+
dimRadialBar = {},
|
82
|
+
...computedProps
|
83
|
+
} = props;
|
84
|
+
const dimmed = shouldHighlight && highlightedArea !== name;
|
85
|
+
const resolvedProps = {
|
86
|
+
...computedProps,
|
87
|
+
...dimmed ? dimRadialBar : { fillOpacity }
|
88
|
+
};
|
89
|
+
const className = getClassName(
|
90
|
+
resolvedProps,
|
91
|
+
dimmed ? dimRadialBarClassName : void 0
|
92
|
+
)(theme);
|
93
|
+
return {
|
94
|
+
className,
|
95
|
+
fill: getVar(`radial-bar-${index}`)(theme),
|
96
|
+
name,
|
97
|
+
value,
|
98
|
+
color
|
99
|
+
};
|
100
|
+
}),
|
101
|
+
[
|
102
|
+
dataProp,
|
103
|
+
dimRadialBarClassName,
|
104
|
+
fillOpacity,
|
105
|
+
highlightedArea,
|
106
|
+
shouldHighlight,
|
107
|
+
theme
|
108
|
+
]
|
109
|
+
);
|
110
|
+
const getRadialChartProps = useCallback(
|
111
|
+
({ className, ...props } = {}, ref = null) => ({
|
112
|
+
ref,
|
113
|
+
className: cx(className, chartClassName),
|
114
|
+
data,
|
115
|
+
innerRadius,
|
116
|
+
outerRadius,
|
117
|
+
startAngle,
|
118
|
+
endAngle,
|
119
|
+
...props,
|
120
|
+
...chartProps
|
121
|
+
}),
|
122
|
+
[
|
123
|
+
chartClassName,
|
124
|
+
chartProps,
|
125
|
+
data,
|
126
|
+
endAngle,
|
127
|
+
innerRadius,
|
128
|
+
outerRadius,
|
129
|
+
startAngle
|
130
|
+
]
|
131
|
+
);
|
132
|
+
const getRadialBarProps = useCallback(
|
133
|
+
({ className, ...props }, ref = null) => ({
|
134
|
+
ref,
|
135
|
+
className: cx(className, radialBarClassName),
|
136
|
+
dataKey,
|
137
|
+
isAnimationActive: false,
|
138
|
+
background,
|
139
|
+
...props,
|
140
|
+
...radialBarProps
|
141
|
+
}),
|
142
|
+
[background, dataKey, radialBarClassName, radialBarProps]
|
143
|
+
);
|
144
|
+
return {
|
145
|
+
radialVars,
|
146
|
+
setHighlightedArea,
|
147
|
+
getRadialChartProps,
|
148
|
+
getRadialBarProps
|
149
|
+
};
|
150
|
+
};
|
151
|
+
|
152
|
+
export {
|
153
|
+
useRadialChart
|
154
|
+
};
|
155
|
+
//# sourceMappingURL=chunk-PG7ZV76C.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/use-radial-chart.ts"],"sourcesContent":["import type { CSSUIProps, CSSUIObject } from \"@yamada-ui/core\"\nimport { getVar, useTheme } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport { useCallback, useMemo, useState } from \"react\"\nimport type { ComponentPropsWithoutRef } from \"react\"\nimport type * as Recharts from \"recharts\"\nimport { getClassName, getComponentProps } from \"./chart-utils\"\nimport type {\n ChartPropGetter,\n RadialBarProps,\n RadialChartProps,\n RequiredChartPropGetter,\n} from \"./chart.types\"\nimport {\n radialBarProperties,\n radialChartProperties,\n} from \"./rechart-properties\"\n\nexport type UseRadialChartOptions = {\n /**\n * Chart data.\n */\n data: Dict[]\n /**\n * The key of a group of data which should be unique in an chart.\n *\n * @default 'value'\n */\n dataKey?: string\n /**\n * Props passed down to recharts `RadialBarChart` component.\n */\n chartProps?: RadialChartProps\n /**\n * Props for the radialBar.\n */\n radialBarProps?: Partial<RadialBarProps>\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 '10%'\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 angle at which chart starts.\n *\n * @default 90\n */\n startAngle?: number\n /**\n * Controls angle at which chart ends.\n *\n * @default -180\n */\n endAngle?: number\n /**\n * Controls fill opacity of all pies.\n *\n * @default 1\n */\n fillOpacity?: number | [number, number]\n}\n\ntype UseRadialChartProps = UseRadialChartOptions & {\n styles: Dict<CSSUIObject>\n}\n\nexport const useRadialChart = ({\n data: dataProp,\n dataKey = \"value\",\n innerRadius = \"10%\",\n outerRadius = \"80%\",\n startAngle = 90,\n endAngle = -180,\n fillOpacity = 1,\n styles,\n ...rest\n}: UseRadialChartProps) => {\n const { theme } = useTheme()\n const [highlightedArea, setHighlightedArea] = useState<string | null>(null)\n const shouldHighlight = highlightedArea !== null\n const {\n background: backgroundProps = {},\n dimRadialBar: dimRadialBarProps = {},\n ...computedRadialBarProps\n } = rest.radialBarProps ?? {}\n\n const radialVars: CSSUIProps[\"vars\"] = useMemo(\n () =>\n dataProp.map(({ color }, index) => ({\n name: `radial-bar-${index}`,\n token: \"colors\",\n value: color ?? \"transparent\",\n })),\n [dataProp],\n )\n\n const dimRadialBarClassName = useMemo(() => {\n const resolvedDimRadialBar = {\n fillOpacity: 0.3,\n strokeOpacity: 0,\n ...dimRadialBarProps,\n }\n\n return getClassName(resolvedDimRadialBar)(theme)\n }, [dimRadialBarProps, theme])\n\n const [chartProps, chartClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [rest.chartProps ?? {}, radialChartProperties],\n styles.chart,\n )(theme),\n [rest.chartProps, styles.chart, theme],\n )\n\n const background = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [backgroundProps, radialBarProperties],\n styles.background,\n )(theme, true),\n [backgroundProps, styles.background, theme],\n )\n\n const [radialBarProps, radialBarClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [computedRadialBarProps ?? {}, radialBarProperties],\n styles.radialBar,\n )(theme),\n [computedRadialBarProps, styles.radialBar, theme],\n )\n\n const data = useMemo(\n () =>\n dataProp.map((props, index) => {\n const {\n name,\n value,\n color,\n dimRadialBar = {},\n ...computedProps\n } = props\n const dimmed = shouldHighlight && highlightedArea !== name\n const resolvedProps = {\n ...computedProps,\n ...(dimmed ? dimRadialBar : { fillOpacity }),\n }\n\n const className = getClassName(\n resolvedProps,\n dimmed ? dimRadialBarClassName : undefined,\n )(theme)\n\n return {\n className,\n fill: getVar(`radial-bar-${index}`)(theme),\n name,\n value,\n color,\n }\n }),\n [\n dataProp,\n dimRadialBarClassName,\n fillOpacity,\n highlightedArea,\n shouldHighlight,\n theme,\n ],\n )\n\n const getRadialChartProps: ChartPropGetter<\n \"div\",\n ComponentPropsWithoutRef<typeof Recharts.RadialBarChart>,\n ComponentPropsWithoutRef<typeof Recharts.RadialBarChart>\n > = useCallback(\n ({ className, ...props } = {}, ref = null) => ({\n ref,\n className: cx(className, chartClassName),\n data,\n innerRadius,\n outerRadius,\n startAngle,\n endAngle,\n ...props,\n ...chartProps,\n }),\n [\n chartClassName,\n chartProps,\n data,\n endAngle,\n innerRadius,\n outerRadius,\n startAngle,\n ],\n )\n\n const getRadialBarProps: RequiredChartPropGetter<\n \"div\",\n Partial<Recharts.RadialBarProps>,\n Omit<Recharts.RadialBarProps, \"ref\">\n > = useCallback(\n ({ className, ...props }, ref = null) => ({\n ref,\n className: cx(className, radialBarClassName),\n dataKey,\n isAnimationActive: false,\n background,\n ...props,\n ...radialBarProps,\n }),\n [background, dataKey, radialBarClassName, radialBarProps],\n )\n\n return {\n radialVars,\n setHighlightedArea,\n getRadialChartProps,\n getRadialBarProps,\n }\n}\n\nexport type UseRadialChartReturn = ReturnType<typeof useRadialChart>\n"],"mappings":";;;;;;;;;;;AACA,SAAS,QAAQ,gBAAgB;AACjC,SAAS,UAAU;AAEnB,SAAS,aAAa,SAAS,gBAAgB;AA0ExC,IAAM,iBAAiB,CAAC;AAAA,EAC7B,MAAM;AAAA,EACN,UAAU;AAAA,EACV,cAAc;AAAA,EACd,cAAc;AAAA,EACd,aAAa;AAAA,EACb,WAAW;AAAA,EACX,cAAc;AAAA,EACd;AAAA,EACA,GAAG;AACL,MAA2B;AAxF3B;AAyFE,QAAM,EAAE,MAAM,IAAI,SAAS;AAC3B,QAAM,CAAC,iBAAiB,kBAAkB,IAAI,SAAwB,IAAI;AAC1E,QAAM,kBAAkB,oBAAoB;AAC5C,QAAM;AAAA,IACJ,YAAY,kBAAkB,CAAC;AAAA,IAC/B,cAAc,oBAAoB,CAAC;AAAA,IACnC,GAAG;AAAA,EACL,KAAI,UAAK,mBAAL,YAAuB,CAAC;AAE5B,QAAM,aAAiC;AAAA,IACrC,MACE,SAAS,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW;AAAA,MAClC,MAAM,cAAc,KAAK;AAAA,MACzB,OAAO;AAAA,MACP,OAAO,wBAAS;AAAA,IAClB,EAAE;AAAA,IACJ,CAAC,QAAQ;AAAA,EACX;AAEA,QAAM,wBAAwB,QAAQ,MAAM;AAC1C,UAAM,uBAAuB;AAAA,MAC3B,aAAa;AAAA,MACb,eAAe;AAAA,MACf,GAAG;AAAA,IACL;AAEA,WAAO,aAAa,oBAAoB,EAAE,KAAK;AAAA,E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AAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,sBAIF;AAAA,IACF,CAAC,EAAE,WAAW,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,UAAU;AAAA,MAC7C;AAAA,MACA,WAAW,GAAG,WAAW,cAAc;AAAA,MACvC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,oBAIF;AAAA,IACF,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,UAAU;AAAA,MACxC;AAAA,MACA,WAAW,GAAG,WAAW,kBAAkB;AAAA,MAC3C;AAAA,MACA,mBAAmB;AAAA,MACnB;AAAA,MACA,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAAA,IACA,CAAC,YAAY,SAAS,oBAAoB,cAAc;AAAA,EAC1D;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["_a"]}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
gridProperties
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-6YUJLLGN.mjs";
|
5
5
|
import {
|
6
6
|
getComponentProps
|
7
7
|
} from "./chunk-QL3DB7OJ.mjs";
|
@@ -39,4 +39,4 @@ var useChartGrid = ({
|
|
39
39
|
export {
|
40
40
|
useChartGrid
|
41
41
|
};
|
42
|
-
//# sourceMappingURL=chunk-
|
42
|
+
//# sourceMappingURL=chunk-PPBHLDVN.mjs.map
|
@@ -1,32 +1,32 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
useBarChart
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-5PSRSNGH.mjs";
|
5
5
|
import {
|
6
6
|
useChartAxis
|
7
|
-
} from "./chunk-
|
7
|
+
} from "./chunk-YNJ423BR.mjs";
|
8
8
|
import {
|
9
9
|
useChartGrid
|
10
|
-
} from "./chunk-
|
10
|
+
} from "./chunk-PPBHLDVN.mjs";
|
11
11
|
import {
|
12
12
|
useChartReferenceLine
|
13
|
-
} from "./chunk-
|
14
|
-
import {
|
15
|
-
useChartLegend
|
16
|
-
} from "./chunk-5Q6O726L.mjs";
|
13
|
+
} from "./chunk-JTQ5QCML.mjs";
|
17
14
|
import {
|
18
15
|
useChartTooltip
|
19
|
-
} from "./chunk-
|
16
|
+
} from "./chunk-VMBRDEM2.mjs";
|
17
|
+
import {
|
18
|
+
useChartLegend
|
19
|
+
} from "./chunk-TCSYDMC7.mjs";
|
20
20
|
import {
|
21
21
|
ChartLegend
|
22
|
-
} from "./chunk-
|
22
|
+
} from "./chunk-EL2VTGFB.mjs";
|
23
23
|
import {
|
24
24
|
ChartTooltip
|
25
|
-
} from "./chunk-
|
25
|
+
} from "./chunk-T5DNDBW6.mjs";
|
26
26
|
import {
|
27
27
|
ChartProvider,
|
28
28
|
useChart
|
29
|
-
} from "./chunk-
|
29
|
+
} from "./chunk-3AOICU4Q.mjs";
|
30
30
|
|
31
31
|
// src/bar-chart.tsx
|
32
32
|
import {
|
@@ -165,8 +165,7 @@ var BarChart = forwardRef((props, ref) => {
|
|
165
165
|
{
|
166
166
|
ref,
|
167
167
|
className: cx("ui-bar-chart", className),
|
168
|
-
|
169
|
-
__css: { ...styles.container },
|
168
|
+
__css: { maxW: "full", vars: barVars, ...styles.container },
|
170
169
|
...rest,
|
171
170
|
children: /* @__PURE__ */ jsx(
|
172
171
|
ResponsiveContainer,
|
@@ -246,4 +245,4 @@ var BarChart = forwardRef((props, ref) => {
|
|
246
245
|
export {
|
247
246
|
BarChart
|
248
247
|
};
|
249
|
-
//# sourceMappingURL=chunk-
|
248
|
+
//# sourceMappingURL=chunk-RKO6KM3T.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/bar-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 Legend,\n BarChart as ReChartsBarChart,\n CartesianGrid,\n Tooltip,\n XAxis,\n YAxis,\n ResponsiveContainer,\n ReferenceLine,\n Label,\n} from \"recharts\"\nimport { ChartLegend } from \"./chart-legend\"\nimport { ChartTooltip } from \"./chart-tooltip\"\nimport { useBarChart } from \"./use-bar-chart\"\nimport type { UseBarChartOptions } from \"./use-bar-chart\"\nimport type { UseChartProps } from \"./use-chart\"\nimport { ChartProvider, useChart } from \"./use-chart\"\nimport type { UseChartAxisOptions } from \"./use-chart-axis\"\nimport { useChartAxis } from \"./use-chart-axis\"\nimport { useChartGrid, type UseChartGridOptions } from \"./use-chart-grid\"\nimport type { UseChartLegendProps } from \"./use-chart-legend\"\nimport { useChartLegend } from \"./use-chart-legend\"\nimport {\n useChartReferenceLine,\n type UseChartReferenceLineOptions,\n} from \"./use-chart-reference-line\"\nimport type { UseChartTooltipOptions } from \"./use-chart-tooltip\"\nimport { useChartTooltip } from \"./use-chart-tooltip\"\n\ntype BarChartOptions = {\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\nexport type BarChartProps = HTMLUIProps<\"div\"> &\n ThemeProps<\"BarChart\"> &\n BarChartOptions &\n UseBarChartOptions &\n UseChartProps &\n UseChartAxisOptions &\n UseChartReferenceLineOptions &\n UseChartGridOptions &\n UseChartTooltipOptions &\n UseChartLegendProps\n\n/**\n * `BarChart` is a component for drawing bar charts to compare multiple sets of data.\n *\n * @see Docs https://yamada-ui.com/components/data-display/bar-chart\n */\nexport const BarChart = forwardRef<BarChartProps, \"div\">((props, ref) => {\n const [styles, mergedProps] = useMultiComponentStyle(\"BarChart\", props)\n const {\n className,\n series,\n dataKey,\n layoutType,\n tickLine,\n gridAxis,\n withXAxis,\n withYAxis,\n barProps,\n xAxisProps,\n yAxisProps,\n xAxisLabel,\n yAxisLabel,\n xAxisLabelProps,\n yAxisLabelProps,\n type = \"default\",\n withTooltip = true,\n withLegend = false,\n containerProps,\n unit,\n yAxisTickFormatter,\n xAxisTickFormatter,\n valueFormatter,\n labelFormatter,\n tooltipProps,\n tooltipAnimationDuration,\n legendProps,\n data,\n referenceLineProps = [],\n gridProps,\n strokeDasharray,\n fillOpacity,\n chartProps,\n syncId,\n cell,\n ...rest\n } = omitThemeProps(mergedProps)\n\n const { bars, barVars, getBarChartProps, setHighlightedArea } = useBarChart({\n data,\n series,\n cell,\n type,\n layoutType,\n chartProps,\n barProps,\n referenceLineProps,\n fillOpacity,\n syncId,\n xAxisLabel,\n yAxisLabel,\n styles,\n })\n const { getContainerProps } = useChart({ containerProps })\n const {\n getXAxisProps,\n getYAxisProps,\n getXAxisLabelProps,\n getYAxisLabelProps,\n } = useChartAxis({\n dataKey,\n type,\n layoutType,\n tickLine,\n gridAxis,\n withXAxis,\n withYAxis,\n xAxisProps,\n yAxisProps,\n xAxisLabel,\n yAxisLabel,\n xAxisLabelProps,\n yAxisLabelProps,\n unit,\n yAxisTickFormatter,\n xAxisTickFormatter,\n styles,\n })\n const { getReferenceLineProps } = useChartReferenceLine({\n referenceLineProps,\n styles,\n })\n const { getGridProps } = useChartGrid({\n gridProps,\n gridAxis,\n strokeDasharray,\n styles,\n })\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 referenceLinesItems = useMemo(\n () =>\n referenceLineProps.map((_, index) => (\n <ReferenceLine\n key={`referenceLine-${index}`}\n {...getReferenceLineProps({\n index,\n className: \"ui-bar-chart__reference-line\",\n })}\n />\n )),\n [getReferenceLineProps, referenceLineProps],\n )\n\n return (\n <ChartProvider value={{ styles }}>\n <ui.div\n ref={ref}\n className={cx(\"ui-bar-chart\", className)}\n __css={{ maxW: \"full\", vars: barVars, ...styles.container }}\n {...rest}\n >\n <ResponsiveContainer\n {...getContainerProps({ className: \"ui-bar-chart__container\" })}\n >\n <ReChartsBarChart\n {...getBarChartProps({ className: \"ui-bar-chart__chart\" })}\n >\n <CartesianGrid\n {...getGridProps({ className: \"ui-bar-chart__grid\" })}\n />\n\n <XAxis {...getXAxisProps({ className: \"ui-bar-chart__x-axis\" })}>\n <Label\n {...getXAxisLabelProps({\n className: \"ui-bar-chart__x-axis-label\",\n })}\n />\n </XAxis>\n\n <YAxis {...getYAxisProps({ className: \"ui-bar-chart__y-axis\" })}>\n <Label\n {...getYAxisLabelProps({\n className: \"ui-bar-chart__y-axis-label\",\n })}\n />\n </YAxis>\n\n {withLegend ? (\n <Legend\n content={({ payload }) => (\n <ChartLegend\n className=\"ui-bar-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-bar-chart__tooltip\"\n label={label}\n payload={payload}\n valueFormatter={valueFormatter}\n labelFormatter={labelFormatter}\n unit={unit}\n {...computedTooltipProps}\n />\n )}\n {...getTooltipProps()}\n />\n ) : null}\n\n {bars}\n {referenceLinesItems}\n </ReChartsBarChart>\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,YAAY;AAAA,EACZ;AAAA,EACA;AAA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