@yamada-ui/charts 2.0.0-next-20240703154117 → 2.0.0-next-20240705212157
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/area-chart.js +112 -16
- package/dist/area-chart.js.map +1 -1
- package/dist/area-chart.mjs +11 -11
- package/dist/bar-chart.js +112 -16
- 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.mjs +3 -3
- package/dist/chart.types.d.mts +2 -1
- package/dist/chart.types.d.ts +2 -1
- package/dist/chart.types.js.map +1 -1
- package/dist/{chunk-LM2DQK2P.mjs → chunk-5Q6O726L.mjs} +2 -2
- package/dist/{chunk-SEBQBOCB.mjs → chunk-B7M3YMES.mjs} +2 -2
- package/dist/{chunk-LGMALZCN.mjs → chunk-D7EZKGCJ.mjs} +2 -2
- package/dist/{chunk-NEGDEVRX.mjs → chunk-DGOXJ373.mjs} +2 -2
- package/dist/{chunk-LAYNVROX.mjs → chunk-DWLZIGGL.mjs} +44 -14
- package/dist/chunk-DWLZIGGL.mjs.map +1 -0
- package/dist/{chunk-AIM5FCJI.mjs → chunk-F2RBOLDY.mjs} +7 -7
- package/dist/{chunk-OSNFBRHL.mjs → chunk-F34FV5DY.mjs} +13 -2
- package/dist/{chunk-OSNFBRHL.mjs.map → chunk-F34FV5DY.mjs.map} +1 -1
- package/dist/{chunk-JXZPTLLZ.mjs → chunk-HZSEVGCR.mjs} +19 -3
- package/dist/chunk-HZSEVGCR.mjs.map +1 -0
- package/dist/{chunk-OS3525CT.mjs → chunk-IOVOXWUL.mjs} +44 -14
- package/dist/chunk-IOVOXWUL.mjs.map +1 -0
- package/dist/{chunk-SAP2SGIZ.mjs → chunk-K6OUXJQK.mjs} +44 -14
- package/dist/chunk-K6OUXJQK.mjs.map +1 -0
- package/dist/{chunk-D3YZFAFO.mjs → chunk-MVKJVXAK.mjs} +19 -3
- package/dist/chunk-MVKJVXAK.mjs.map +1 -0
- package/dist/{chunk-JSDS6QWX.mjs → chunk-OSSQ2IHJ.mjs} +7 -7
- package/dist/{chunk-K6OJ62SA.mjs → chunk-P4MMHTAP.mjs} +7 -7
- package/dist/{chunk-LBC2B6UX.mjs → chunk-PSJKBKOF.mjs} +2 -2
- package/dist/{chunk-MWPICUEW.mjs → chunk-Q7CCSKX3.mjs} +2 -2
- package/dist/{chunk-XIFDRM7J.mjs → chunk-STBYN5JW.mjs} +2 -2
- package/dist/{chunk-RN6PXJAD.mjs → chunk-UK6B6KJ7.mjs} +2 -2
- package/dist/{chunk-P7AFSM5W.mjs → chunk-XHDDK4ZU.mjs} +56 -14
- package/dist/chunk-XHDDK4ZU.mjs.map +1 -0
- package/dist/{chunk-IIBF2GUV.mjs → chunk-XZVWGY4J.mjs} +18 -3
- package/dist/chunk-XZVWGY4J.mjs.map +1 -0
- package/dist/{chunk-MFYRHF3O.mjs → chunk-YGKNNA34.mjs} +2 -2
- package/dist/donut-chart.js.map +1 -1
- package/dist/donut-chart.mjs +8 -8
- package/dist/index.js +209 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -20
- package/dist/line-chart.js +111 -16
- package/dist/line-chart.js.map +1 -1
- package/dist/line-chart.mjs +11 -11
- package/dist/pie-chart.js.map +1 -1
- package/dist/pie-chart.mjs +8 -8
- package/dist/radar-chart.js.map +1 -1
- package/dist/radar-chart.mjs +8 -8
- package/dist/rechart-properties.d.mts +2 -1
- package/dist/rechart-properties.d.ts +2 -1
- package/dist/rechart-properties.js +12 -0
- package/dist/rechart-properties.js.map +1 -1
- package/dist/rechart-properties.mjs +3 -1
- package/dist/use-area-chart.d.mts +9 -1
- package/dist/use-area-chart.d.ts +9 -1
- package/dist/use-area-chart.js +17 -1
- package/dist/use-area-chart.js.map +1 -1
- package/dist/use-area-chart.mjs +2 -2
- package/dist/use-bar-chart.d.mts +9 -1
- package/dist/use-bar-chart.d.ts +9 -1
- package/dist/use-bar-chart.js +17 -1
- package/dist/use-bar-chart.js.map +1 -1
- package/dist/use-bar-chart.mjs +2 -2
- package/dist/use-chart-axis.d.mts +20 -2
- package/dist/use-chart-axis.d.ts +20 -2
- package/dist/use-chart-axis.js +63 -12
- package/dist/use-chart-axis.js.map +1 -1
- package/dist/use-chart-axis.mjs +2 -2
- package/dist/use-chart-grid.js.map +1 -1
- package/dist/use-chart-grid.mjs +2 -2
- package/dist/use-chart-legend.js.map +1 -1
- package/dist/use-chart-legend.mjs +2 -2
- package/dist/use-chart-reference-line.js.map +1 -1
- package/dist/use-chart-reference-line.mjs +2 -2
- package/dist/use-chart-tooltip.js.map +1 -1
- package/dist/use-chart-tooltip.mjs +2 -2
- package/dist/use-chart.js.map +1 -1
- package/dist/use-chart.mjs +2 -2
- package/dist/use-line-chart.d.mts +9 -1
- package/dist/use-line-chart.d.ts +9 -1
- package/dist/use-line-chart.js +16 -1
- package/dist/use-line-chart.js.map +1 -1
- package/dist/use-line-chart.mjs +2 -2
- package/dist/use-pie-chart.js.map +1 -1
- package/dist/use-pie-chart.mjs +2 -2
- package/dist/use-radar-chart.js.map +1 -1
- package/dist/use-radar-chart.mjs +2 -2
- package/package.json +3 -3
- package/dist/chunk-D3YZFAFO.mjs.map +0 -1
- package/dist/chunk-IIBF2GUV.mjs.map +0 -1
- package/dist/chunk-JXZPTLLZ.mjs.map +0 -1
- package/dist/chunk-LAYNVROX.mjs.map +0 -1
- package/dist/chunk-OS3525CT.mjs.map +0 -1
- package/dist/chunk-P7AFSM5W.mjs.map +0 -1
- package/dist/chunk-SAP2SGIZ.mjs.map +0 -1
- /package/dist/{chunk-LM2DQK2P.mjs.map → chunk-5Q6O726L.mjs.map} +0 -0
- /package/dist/{chunk-SEBQBOCB.mjs.map → chunk-B7M3YMES.mjs.map} +0 -0
- /package/dist/{chunk-LGMALZCN.mjs.map → chunk-D7EZKGCJ.mjs.map} +0 -0
- /package/dist/{chunk-NEGDEVRX.mjs.map → chunk-DGOXJ373.mjs.map} +0 -0
- /package/dist/{chunk-AIM5FCJI.mjs.map → chunk-F2RBOLDY.mjs.map} +0 -0
- /package/dist/{chunk-JSDS6QWX.mjs.map → chunk-OSSQ2IHJ.mjs.map} +0 -0
- /package/dist/{chunk-K6OJ62SA.mjs.map → chunk-P4MMHTAP.mjs.map} +0 -0
- /package/dist/{chunk-LBC2B6UX.mjs.map → chunk-PSJKBKOF.mjs.map} +0 -0
- /package/dist/{chunk-MWPICUEW.mjs.map → chunk-Q7CCSKX3.mjs.map} +0 -0
- /package/dist/{chunk-XIFDRM7J.mjs.map → chunk-STBYN5JW.mjs.map} +0 -0
- /package/dist/{chunk-RN6PXJAD.mjs.map → chunk-UK6B6KJ7.mjs.map} +0 -0
- /package/dist/{chunk-MFYRHF3O.mjs.map → chunk-YGKNNA34.mjs.map} +0 -0
@@ -1,32 +1,32 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
useBarChart
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-MVKJVXAK.mjs";
|
5
5
|
import {
|
6
6
|
useChartAxis
|
7
|
-
} from "./chunk-
|
7
|
+
} from "./chunk-XHDDK4ZU.mjs";
|
8
8
|
import {
|
9
9
|
useChartGrid
|
10
|
-
} from "./chunk-
|
10
|
+
} from "./chunk-D7EZKGCJ.mjs";
|
11
11
|
import {
|
12
12
|
useChartReferenceLine
|
13
|
-
} from "./chunk-
|
13
|
+
} from "./chunk-Q7CCSKX3.mjs";
|
14
14
|
import {
|
15
15
|
useChartLegend
|
16
|
-
} from "./chunk-
|
16
|
+
} from "./chunk-5Q6O726L.mjs";
|
17
17
|
import {
|
18
18
|
useChartTooltip
|
19
|
-
} from "./chunk-
|
19
|
+
} from "./chunk-UK6B6KJ7.mjs";
|
20
20
|
import {
|
21
21
|
ChartLegend
|
22
|
-
} from "./chunk-
|
22
|
+
} from "./chunk-DGOXJ373.mjs";
|
23
23
|
import {
|
24
24
|
ChartTooltip
|
25
|
-
} from "./chunk-
|
25
|
+
} from "./chunk-PSJKBKOF.mjs";
|
26
26
|
import {
|
27
27
|
ChartProvider,
|
28
28
|
useChart
|
29
|
-
} from "./chunk-
|
29
|
+
} from "./chunk-STBYN5JW.mjs";
|
30
30
|
|
31
31
|
// src/bar-chart.tsx
|
32
32
|
import {
|
@@ -46,7 +46,8 @@ import {
|
|
46
46
|
XAxis,
|
47
47
|
YAxis,
|
48
48
|
ResponsiveContainer,
|
49
|
-
ReferenceLine
|
49
|
+
ReferenceLine,
|
50
|
+
Label
|
50
51
|
} from "recharts";
|
51
52
|
import { jsx, jsxs } from "react/jsx-runtime";
|
52
53
|
var BarChart = forwardRef((props, ref) => {
|
@@ -63,6 +64,10 @@ var BarChart = forwardRef((props, ref) => {
|
|
63
64
|
barProps,
|
64
65
|
xAxisProps,
|
65
66
|
yAxisProps,
|
67
|
+
xAxisLabel,
|
68
|
+
yAxisLabel,
|
69
|
+
xAxisLabelProps,
|
70
|
+
yAxisLabelProps,
|
66
71
|
type = "default",
|
67
72
|
withTooltip = true,
|
68
73
|
withLegend = false,
|
@@ -91,10 +96,17 @@ var BarChart = forwardRef((props, ref) => {
|
|
91
96
|
referenceLineProps,
|
92
97
|
fillOpacity,
|
93
98
|
syncId,
|
99
|
+
xAxisLabel,
|
100
|
+
yAxisLabel,
|
94
101
|
styles
|
95
102
|
});
|
96
103
|
const { getContainerProps } = useChart({ containerProps });
|
97
|
-
const {
|
104
|
+
const {
|
105
|
+
getXAxisProps,
|
106
|
+
getYAxisProps,
|
107
|
+
getXAxisLabelProps,
|
108
|
+
getYAxisLabelProps
|
109
|
+
} = useChartAxis({
|
98
110
|
dataKey,
|
99
111
|
type,
|
100
112
|
layoutType,
|
@@ -104,6 +116,10 @@ var BarChart = forwardRef((props, ref) => {
|
|
104
116
|
withYAxis,
|
105
117
|
xAxisProps,
|
106
118
|
yAxisProps,
|
119
|
+
xAxisLabel,
|
120
|
+
yAxisLabel,
|
121
|
+
xAxisLabelProps,
|
122
|
+
yAxisLabelProps,
|
107
123
|
unit,
|
108
124
|
valueFormatter,
|
109
125
|
styles
|
@@ -174,8 +190,22 @@ var BarChart = forwardRef((props, ref) => {
|
|
174
190
|
...getGridProps({ className: "ui-bar-chart__grid" })
|
175
191
|
}
|
176
192
|
),
|
177
|
-
/* @__PURE__ */ jsx(XAxis, { ...getXAxisProps({ className: "ui-bar-chart__x-axis" })
|
178
|
-
|
193
|
+
/* @__PURE__ */ jsx(XAxis, { ...getXAxisProps({ className: "ui-bar-chart__x-axis" }), children: /* @__PURE__ */ jsx(
|
194
|
+
Label,
|
195
|
+
{
|
196
|
+
...getXAxisLabelProps({
|
197
|
+
className: "ui-bar-chart__x-axis-label"
|
198
|
+
})
|
199
|
+
}
|
200
|
+
) }),
|
201
|
+
/* @__PURE__ */ jsx(YAxis, { ...getYAxisProps({ className: "ui-bar-chart__y-axis" }), children: /* @__PURE__ */ jsx(
|
202
|
+
Label,
|
203
|
+
{
|
204
|
+
...getYAxisLabelProps({
|
205
|
+
className: "ui-bar-chart__y-axis-label"
|
206
|
+
})
|
207
|
+
}
|
208
|
+
) }),
|
179
209
|
withLegend ? /* @__PURE__ */ jsx(
|
180
210
|
Legend,
|
181
211
|
{
|
@@ -222,4 +252,4 @@ var BarChart = forwardRef((props, ref) => {
|
|
222
252
|
export {
|
223
253
|
BarChart
|
224
254
|
};
|
225
|
-
//# sourceMappingURL=chunk-
|
255
|
+
//# sourceMappingURL=chunk-IOVOXWUL.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 Bar,\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/feedback/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 valueFormatter,\n tooltipProps,\n tooltipAnimationDuration,\n legendProps,\n data,\n referenceLineProps = [],\n gridProps,\n strokeDasharray,\n fillOpacity,\n chartProps,\n syncId,\n ...rest\n } = omitThemeProps(mergedProps)\n\n const { getBarChartProps, getBarProps, barVars, setHighlightedArea } =\n useBarChart({\n data,\n series,\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 valueFormatter,\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 bars = useMemo(\n () =>\n series.map(({ dataKey }, index) => {\n return (\n <Bar\n key={`bar-${dataKey}`}\n {...getBarProps({ index, className: \"ui-bar-chart__bar\" })}\n />\n )\n }),\n [getBarProps, series],\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 var={barVars}\n __css={{ ...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 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;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAsJG,cAmCA,YAnCA;AApGH,IAAM,WAAW,WAAiC,CAAC,OAAO,QAAQ;AACvE,QAAM,CAAC,QAAQ,WAAW,IAAI,uBAAuB,YAAY,KAAK;AACtE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;A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AA;AAAA,oBACE,GAAG,mBAAmB;AAAA,sBACrB,WAAW;AAAA,oBACb,CAAC;AAAA;AAAA,gBACH,GACF;AAAA,gBAEC,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,gBACA;AAAA;AAAA;AAAA,UACH;AAAA;AAAA,MACF;AAAA;AAAA,EACF,GACF;AAEJ,CAAC;","names":["dataKey"]}
|
@@ -1,32 +1,32 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
useLineChart
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-XZVWGY4J.mjs";
|
5
5
|
import {
|
6
6
|
useChartAxis
|
7
|
-
} from "./chunk-
|
7
|
+
} from "./chunk-XHDDK4ZU.mjs";
|
8
8
|
import {
|
9
9
|
useChartGrid
|
10
|
-
} from "./chunk-
|
10
|
+
} from "./chunk-D7EZKGCJ.mjs";
|
11
11
|
import {
|
12
12
|
useChartReferenceLine
|
13
|
-
} from "./chunk-
|
13
|
+
} from "./chunk-Q7CCSKX3.mjs";
|
14
14
|
import {
|
15
15
|
useChartLegend
|
16
|
-
} from "./chunk-
|
16
|
+
} from "./chunk-5Q6O726L.mjs";
|
17
17
|
import {
|
18
18
|
useChartTooltip
|
19
|
-
} from "./chunk-
|
19
|
+
} from "./chunk-UK6B6KJ7.mjs";
|
20
20
|
import {
|
21
21
|
ChartLegend
|
22
|
-
} from "./chunk-
|
22
|
+
} from "./chunk-DGOXJ373.mjs";
|
23
23
|
import {
|
24
24
|
ChartTooltip
|
25
|
-
} from "./chunk-
|
25
|
+
} from "./chunk-PSJKBKOF.mjs";
|
26
26
|
import {
|
27
27
|
ChartProvider,
|
28
28
|
useChart
|
29
|
-
} from "./chunk-
|
29
|
+
} from "./chunk-STBYN5JW.mjs";
|
30
30
|
|
31
31
|
// src/line-chart.tsx
|
32
32
|
import {
|
@@ -46,7 +46,8 @@ import {
|
|
46
46
|
XAxis,
|
47
47
|
YAxis,
|
48
48
|
ReferenceLine,
|
49
|
-
Line
|
49
|
+
Line,
|
50
|
+
Label
|
50
51
|
} from "recharts";
|
51
52
|
import { jsx, jsxs } from "react/jsx-runtime";
|
52
53
|
var LineChart = forwardRef((props, ref) => {
|
@@ -65,6 +66,10 @@ var LineChart = forwardRef((props, ref) => {
|
|
65
66
|
withYAxis,
|
66
67
|
xAxisProps,
|
67
68
|
yAxisProps,
|
69
|
+
xAxisLabel,
|
70
|
+
yAxisLabel,
|
71
|
+
xAxisLabelProps,
|
72
|
+
yAxisLabelProps,
|
68
73
|
unit,
|
69
74
|
valueFormatter,
|
70
75
|
referenceLineProps,
|
@@ -100,10 +105,17 @@ var LineChart = forwardRef((props, ref) => {
|
|
100
105
|
connectNulls,
|
101
106
|
fillOpacity,
|
102
107
|
syncId,
|
108
|
+
xAxisLabel,
|
109
|
+
yAxisLabel,
|
103
110
|
styles
|
104
111
|
});
|
105
112
|
const { getContainerProps } = useChart({ containerProps });
|
106
|
-
const {
|
113
|
+
const {
|
114
|
+
getXAxisProps,
|
115
|
+
getYAxisProps,
|
116
|
+
getXAxisLabelProps,
|
117
|
+
getYAxisLabelProps
|
118
|
+
} = useChartAxis({
|
107
119
|
dataKey,
|
108
120
|
type,
|
109
121
|
layoutType,
|
@@ -113,6 +125,10 @@ var LineChart = forwardRef((props, ref) => {
|
|
113
125
|
withYAxis,
|
114
126
|
xAxisProps,
|
115
127
|
yAxisProps,
|
128
|
+
xAxisLabel,
|
129
|
+
yAxisLabel,
|
130
|
+
xAxisLabelProps,
|
131
|
+
yAxisLabelProps,
|
116
132
|
unit,
|
117
133
|
valueFormatter,
|
118
134
|
styles
|
@@ -181,8 +197,22 @@ var LineChart = forwardRef((props, ref) => {
|
|
181
197
|
...getGridProps({ className: "ui-line-chart__grid" })
|
182
198
|
}
|
183
199
|
),
|
184
|
-
/* @__PURE__ */ jsx(XAxis, { ...getXAxisProps({ className: "ui-line-chart__x-axis" })
|
185
|
-
|
200
|
+
/* @__PURE__ */ jsx(XAxis, { ...getXAxisProps({ className: "ui-line-chart__x-axis" }), children: /* @__PURE__ */ jsx(
|
201
|
+
Label,
|
202
|
+
{
|
203
|
+
...getXAxisLabelProps({
|
204
|
+
className: "ui-line-chart__x-axis-label"
|
205
|
+
})
|
206
|
+
}
|
207
|
+
) }),
|
208
|
+
/* @__PURE__ */ jsx(YAxis, { ...getYAxisProps({ className: "ui-line-chart__y-axis" }), children: /* @__PURE__ */ jsx(
|
209
|
+
Label,
|
210
|
+
{
|
211
|
+
...getYAxisLabelProps({
|
212
|
+
className: "ui-line-chart__y-axis-label"
|
213
|
+
})
|
214
|
+
}
|
215
|
+
) }),
|
186
216
|
withLegend ? /* @__PURE__ */ jsx(
|
187
217
|
Legend,
|
188
218
|
{
|
@@ -229,4 +259,4 @@ var LineChart = forwardRef((props, ref) => {
|
|
229
259
|
export {
|
230
260
|
LineChart
|
231
261
|
};
|
232
|
-
//# sourceMappingURL=chunk-
|
262
|
+
//# sourceMappingURL=chunk-K6OUXJQK.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/line-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 LineChart as ReChartsLineChart,\n Legend,\n CartesianGrid,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n ReferenceLine,\n Line,\n Label,\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 { UseChartAxisOptions } from \"./use-chart-axis\"\nimport { useChartAxis } from \"./use-chart-axis\"\nimport type { UseChartGridOptions } from \"./use-chart-grid\"\nimport { useChartGrid } from \"./use-chart-grid\"\nimport type { UseChartLegendProps } from \"./use-chart-legend\"\nimport { useChartLegend } from \"./use-chart-legend\"\nimport type { UseChartReferenceLineOptions } from \"./use-chart-reference-line\"\nimport { useChartReferenceLine } from \"./use-chart-reference-line\"\nimport {\n useChartTooltip,\n type UseChartTooltipOptions,\n} from \"./use-chart-tooltip\"\nimport { useLineChart } from \"./use-line-chart\"\nimport type { UseLineChartOptions } from \"./use-line-chart\"\n\ntype LineChartOptions = {\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 LineChartProps = HTMLUIProps<\"div\"> &\n ThemeProps<\"LineChart\"> &\n LineChartOptions &\n UseChartProps &\n UseChartAxisOptions &\n UseChartReferenceLineOptions &\n UseChartGridOptions &\n UseChartTooltipOptions &\n UseChartLegendProps &\n UseLineChartOptions\n\n/**\n * `LineChart` is a component for drawing line charts to compare multiple sets of data.\n *\n * @see Docs https://yamada-ui.com/components/feedback/line-chart\n */\nexport const LineChart = forwardRef<LineChartProps, \"div\">((props, ref) => {\n const [styles, mergedProps] = useMultiComponentStyle(\"LineChart\", props)\n const {\n className,\n containerProps,\n gridProps,\n gridAxis,\n strokeDasharray,\n dataKey,\n type,\n layoutType,\n tickLine,\n withXAxis,\n withYAxis,\n xAxisProps,\n yAxisProps,\n xAxisLabel,\n yAxisLabel,\n xAxisLabelProps,\n yAxisLabelProps,\n unit,\n valueFormatter,\n referenceLineProps,\n tooltipProps,\n tooltipAnimationDuration,\n legendProps,\n withLegend = false,\n withTooltip = true,\n series,\n data,\n chartProps,\n lineProps,\n withDots,\n withActiveDots,\n curveType,\n strokeWidth,\n connectNulls,\n fillOpacity,\n syncId,\n ...rest\n } = omitThemeProps(mergedProps)\n\n const { getLineProps, getLineChartProps, lineVars, setHighlightedArea } =\n useLineChart({\n layoutType,\n series,\n referenceLineProps,\n data,\n chartProps,\n lineProps,\n withDots,\n withActiveDots,\n curveType,\n strokeWidth,\n connectNulls,\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 valueFormatter,\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 lines = useMemo(\n () =>\n series.map(({ dataKey }, index) => (\n <Line\n key={`line-${dataKey}`}\n {...getLineProps({ index, className: \"ui-line-chart__line\" })}\n />\n )),\n [getLineProps, series],\n )\n\n const referenceLinesItems = useMemo(\n () =>\n referenceLineProps?.map((_, index) => (\n <ReferenceLine\n key={`referenceLine-${index}`}\n {...getReferenceLineProps({\n index,\n className: \"ui-line-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-line-chart\", className)}\n var={lineVars}\n __css={{ ...styles.container }}\n {...rest}\n >\n <ResponsiveContainer\n {...getContainerProps({ className: \"ui-line-chart__container\" })}\n >\n <ReChartsLineChart\n {...getLineChartProps({ className: \"ui-line-chart__chart\" })}\n >\n <CartesianGrid\n {...getGridProps({ className: \"ui-line-chart__grid\" })}\n />\n\n <XAxis {...getXAxisProps({ className: \"ui-line-chart__x-axis\" })}>\n <Label\n {...getXAxisLabelProps({\n className: \"ui-line-chart__x-axis-label\",\n })}\n />\n </XAxis>\n\n <YAxis {...getYAxisProps({ className: \"ui-line-chart__y-axis\" })}>\n <Label\n {...getYAxisLabelProps({\n className: \"ui-line-chart__y-axis-label\",\n })}\n />\n </YAxis>\n\n {withLegend ? (\n <Legend\n content={({ payload }) => (\n <ChartLegend\n className=\"ui-line-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 {lines}\n {referenceLinesItems}\n </ReChartsLineChart>\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;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,E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BAAC;AAAA;AAAA,oBACE,GAAG,aAAa,EAAE,WAAW,sBAAsB,CAAC;AAAA;AAAA,gBACvD;AAAA,gBAEA,oBAAC,SAAO,GAAG,cAAc,EAAE,WAAW,wBAAwB,CAAC,GAC7D;AAAA,kBAAC;AAAA;AAAA,oBACE,GAAG,mBAAmB;AAAA,sBACrB,WAAW;AAAA,oBACb,CAAC;AAAA;AAAA,gBACH,GACF;AAAA,gBAEA,oBAAC,SAAO,GAAG,cAAc,EAAE,WAAW,wBAAwB,CAAC,GAC7D;AAAA,kBAAC;AAAA;AAAA,oBACE,GAAG,mBAAmB;AAAA,sBACrB,WAAW;AAAA,oBACb,CAAC;AAAA;AAAA,gBACH,GACF;AAAA,gBAEC,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,gBACA;AAAA;AAAA;AAAA,UACH;AAAA;AAAA,MACF;AAAA;AAAA,EACF,GACF;AAEJ,CAAC;","names":["dataKey"]}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
import {
|
3
3
|
barChartProperties,
|
4
4
|
barProperties
|
5
|
-
} from "./chunk-
|
5
|
+
} from "./chunk-F34FV5DY.mjs";
|
6
6
|
import {
|
7
7
|
getComponentProps
|
8
8
|
} from "./chunk-QL3DB7OJ.mjs";
|
@@ -24,6 +24,8 @@ var useBarChart = ({
|
|
24
24
|
referenceLineProps = [],
|
25
25
|
fillOpacity = 1,
|
26
26
|
syncId,
|
27
|
+
xAxisLabel,
|
28
|
+
yAxisLabel,
|
27
29
|
styles,
|
28
30
|
...rest
|
29
31
|
}) => {
|
@@ -189,10 +191,24 @@ var useBarChart = ({
|
|
189
191
|
stackOffset: type === "percent" ? "expand" : void 0,
|
190
192
|
layout: layoutType,
|
191
193
|
syncId,
|
194
|
+
margin: {
|
195
|
+
bottom: xAxisLabel ? 30 : void 0,
|
196
|
+
left: yAxisLabel ? 10 : void 0,
|
197
|
+
right: yAxisLabel ? 5 : void 0
|
198
|
+
},
|
192
199
|
...props,
|
193
200
|
...chartProps
|
194
201
|
}),
|
195
|
-
[
|
202
|
+
[
|
203
|
+
barChartClassName,
|
204
|
+
data,
|
205
|
+
type,
|
206
|
+
layoutType,
|
207
|
+
syncId,
|
208
|
+
xAxisLabel,
|
209
|
+
yAxisLabel,
|
210
|
+
chartProps
|
211
|
+
]
|
196
212
|
);
|
197
213
|
return {
|
198
214
|
barVars,
|
@@ -205,4 +221,4 @@ var useBarChart = ({
|
|
205
221
|
export {
|
206
222
|
useBarChart
|
207
223
|
};
|
208
|
-
//# sourceMappingURL=chunk-
|
224
|
+
//# sourceMappingURL=chunk-MVKJVXAK.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/use-bar-chart.ts"],"sourcesContent":["import { type CSSUIObject, useTheme, type CSSUIProps } from \"@yamada-ui/core\"\nimport { type Dict, cx } from \"@yamada-ui/utils\"\nimport {\n type ComponentPropsWithoutRef,\n useCallback,\n useState,\n useId,\n useMemo,\n} from \"react\"\nimport type * as Recharts 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\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 ...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 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 barVars,\n getBarProps,\n getBarChartProps,\n setHighlightedArea,\n }\n}\n\nexport type UseBarChartReturn = ReturnType<typeof useBarChart>\n"],"mappings":";;;;;;;;;;AAAA,SAA2B,gBAAiC;AAC5D,SAAoB,UAAU;AAC9B;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAwEA,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,GAAG;AACL,MAAwB;AA5FxB;AA6FE,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,OAAO,wBAAS;AAAA,IAClB,EAAE;AAAA,IACJ,CAAC,MAAM;AAAA,EACT;AAEA,QAAM,sBAAyC;AAAA,IAC7C,MACE,mBAAmB,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW;AAAA,MAC5C,UAAU;AAAA,MACV,MAAM,kBAAkB,KAAK;AAAA,MAC7B,OAAO;AAAA,MACP,OAAO,wBAAS;AAAA,IAClB,EAAE;AAAA,IACJ,CAAC,kBAAkB;AA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;AAEA,QAAM,cAMF;AAAA,IACF,CAAC,EAAE,OAAO,WAAW,eAAe,GAAG,MAAM,GAAG,MAAM,SAAS;AAC7D,YAAM,EAAE,IAAI,WAAW,WAAAH,YAAW,YAAAC,aAAY,OAAO,SAAS,GAAGE,MAAK,IACpE,aAAa,KAAK;AAEpB,aAAO;AAAA,QACL;AAAA,QACA,WAAW,GAAG,eAAe,SAAS;AAAA,QACtC,WAAAH;AAAA,QACA,YAAAC;AAAA,QACA;AAAA,QACA,MAAM;AAAA,QACN;AAAA,QACA,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,mBAAmB;AAAA,QACnB,SAAS,UAAU,UAAU;AAAA,QAC7B,GAAI;AAAA,QACJ,GAAGE;AAAA,MACL;AAAA,IACF;AAAA,IACA,CAAC,cAAc,OAAO;AAAA,EACxB;AAEA,QAAM,mBAIF;AAAA,IACF,CAAC,EAAE,WAAW,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,UAAU;AAAA,MAC7C;AAAA,MACA,WAAW,GAAG,WAAW,iBAAiB;AAAA,MAC1C;AAAA,MACA,aAAa,SAAS,YAAY,WAAW;AAAA,MAC7C,QAAQ;AAAA,MACR;AAAA,MACA,QAAQ;AAAA,QACN,QAAQ,aAAa,KAAK;AAAA,QAC1B,MAAM,aAAa,KAAK;AAAA,QACxB,OAAO,aAAa,IAAI;AAAA,MAC1B;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,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["activeBar","background","dimBar","rest"]}
|
@@ -1,23 +1,23 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
useRadarChart
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-B7M3YMES.mjs";
|
5
5
|
import {
|
6
6
|
useChartLegend
|
7
|
-
} from "./chunk-
|
7
|
+
} from "./chunk-5Q6O726L.mjs";
|
8
8
|
import {
|
9
9
|
useChartTooltip
|
10
|
-
} from "./chunk-
|
10
|
+
} from "./chunk-UK6B6KJ7.mjs";
|
11
11
|
import {
|
12
12
|
ChartLegend
|
13
|
-
} from "./chunk-
|
13
|
+
} from "./chunk-DGOXJ373.mjs";
|
14
14
|
import {
|
15
15
|
ChartTooltip
|
16
|
-
} from "./chunk-
|
16
|
+
} from "./chunk-PSJKBKOF.mjs";
|
17
17
|
import {
|
18
18
|
ChartProvider,
|
19
19
|
useChart
|
20
|
-
} from "./chunk-
|
20
|
+
} from "./chunk-STBYN5JW.mjs";
|
21
21
|
|
22
22
|
// src/radar-chart.tsx
|
23
23
|
import {
|
@@ -203,4 +203,4 @@ var RadarChart = forwardRef((props, ref) => {
|
|
203
203
|
export {
|
204
204
|
RadarChart
|
205
205
|
};
|
206
|
-
//# sourceMappingURL=chunk-
|
206
|
+
//# sourceMappingURL=chunk-OSSQ2IHJ.mjs.map
|
@@ -1,23 +1,23 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
usePieChart
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-YGKNNA34.mjs";
|
5
5
|
import {
|
6
6
|
useChartLegend
|
7
|
-
} from "./chunk-
|
7
|
+
} from "./chunk-5Q6O726L.mjs";
|
8
8
|
import {
|
9
9
|
useChartTooltip
|
10
|
-
} from "./chunk-
|
10
|
+
} from "./chunk-UK6B6KJ7.mjs";
|
11
11
|
import {
|
12
12
|
ChartLegend
|
13
|
-
} from "./chunk-
|
13
|
+
} from "./chunk-DGOXJ373.mjs";
|
14
14
|
import {
|
15
15
|
ChartTooltip
|
16
|
-
} from "./chunk-
|
16
|
+
} from "./chunk-PSJKBKOF.mjs";
|
17
17
|
import {
|
18
18
|
ChartProvider,
|
19
19
|
useChart
|
20
|
-
} from "./chunk-
|
20
|
+
} from "./chunk-STBYN5JW.mjs";
|
21
21
|
|
22
22
|
// src/donut-chart.tsx
|
23
23
|
import {
|
@@ -176,4 +176,4 @@ var DonutChart = forwardRef((props, ref) => {
|
|
176
176
|
export {
|
177
177
|
DonutChart
|
178
178
|
};
|
179
|
-
//# sourceMappingURL=chunk-
|
179
|
+
//# sourceMappingURL=chunk-P4MMHTAP.mjs.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
useTooltip
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-STBYN5JW.mjs";
|
5
5
|
|
6
6
|
// src/chart-tooltip.tsx
|
7
7
|
import { forwardRef, ui } from "@yamada-ui/core";
|
@@ -81,4 +81,4 @@ var ChartTooltip = forwardRef(
|
|
81
81
|
export {
|
82
82
|
ChartTooltip
|
83
83
|
};
|
84
|
-
//# sourceMappingURL=chunk-
|
84
|
+
//# sourceMappingURL=chunk-PSJKBKOF.mjs.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
referenceLineProperties
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-F34FV5DY.mjs";
|
5
5
|
import {
|
6
6
|
getComponentProps
|
7
7
|
} from "./chunk-QL3DB7OJ.mjs";
|
@@ -53,4 +53,4 @@ var useChartReferenceLine = ({
|
|
53
53
|
export {
|
54
54
|
useChartReferenceLine
|
55
55
|
};
|
56
|
-
//# sourceMappingURL=chunk-
|
56
|
+
//# sourceMappingURL=chunk-Q7CCSKX3.mjs.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
containerProperties
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-F34FV5DY.mjs";
|
5
5
|
import {
|
6
6
|
getComponentProps
|
7
7
|
} from "./chunk-QL3DB7OJ.mjs";
|
@@ -53,4 +53,4 @@ export {
|
|
53
53
|
useLegend,
|
54
54
|
useTooltip
|
55
55
|
};
|
56
|
-
//# sourceMappingURL=chunk-
|
56
|
+
//# sourceMappingURL=chunk-STBYN5JW.mjs.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
tooltipProperties
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-F34FV5DY.mjs";
|
5
5
|
import {
|
6
6
|
getClassName
|
7
7
|
} from "./chunk-QL3DB7OJ.mjs";
|
@@ -44,4 +44,4 @@ var useChartTooltip = ({
|
|
44
44
|
export {
|
45
45
|
useChartTooltip
|
46
46
|
};
|
47
|
-
//# sourceMappingURL=chunk-
|
47
|
+
//# sourceMappingURL=chunk-UK6B6KJ7.mjs.map
|
@@ -1,8 +1,9 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
|
+
labelProperties,
|
3
4
|
xAxisProperties,
|
4
5
|
yAxisProperties
|
5
|
-
} from "./chunk-
|
6
|
+
} from "./chunk-F34FV5DY.mjs";
|
6
7
|
import {
|
7
8
|
getComponentProps
|
8
9
|
} from "./chunk-QL3DB7OJ.mjs";
|
@@ -19,12 +20,14 @@ var useChartAxis = ({
|
|
19
20
|
gridAxis = "x",
|
20
21
|
withXAxis = true,
|
21
22
|
withYAxis = true,
|
22
|
-
|
23
|
-
|
23
|
+
xAxisLabel: xAxisLabelProp,
|
24
|
+
yAxisLabel: yAxisLabelProp,
|
24
25
|
unit,
|
25
26
|
valueFormatter,
|
26
|
-
styles
|
27
|
+
styles,
|
28
|
+
...rest
|
27
29
|
}) => {
|
30
|
+
var _a, _b, _c, _d;
|
28
31
|
const { theme } = useTheme();
|
29
32
|
const xAxisKey = useMemo(
|
30
33
|
() => layoutType === "vertical" ? { type: "number" } : { dataKey },
|
@@ -41,14 +44,24 @@ var useChartAxis = ({
|
|
41
44
|
const yTickLine = getTickLine(withYTickLine);
|
42
45
|
const yAxisTickFormatter = type === "percent" && layoutType !== "vertical" ? valueToPercent : valueFormatter;
|
43
46
|
const xAxisTickFormatter = type === "percent" && layoutType === "vertical" ? valueToPercent : valueFormatter;
|
44
|
-
const
|
45
|
-
|
47
|
+
const xAxisLabel = layoutType === "vertical" ? yAxisLabelProp : xAxisLabelProp;
|
48
|
+
const yAxisLabel = layoutType === "vertical" ? xAxisLabelProp : yAxisLabelProp;
|
49
|
+
const [xAxisProps, xAxisClassName] = getComponentProps(
|
50
|
+
[(_a = rest.xAxisProps) != null ? _a : {}, xAxisProperties],
|
46
51
|
styles.xAxis
|
47
52
|
)(theme);
|
48
|
-
const [
|
49
|
-
[
|
53
|
+
const [yAxisProps, yAxisClassName] = getComponentProps(
|
54
|
+
[(_b = rest.yAxisProps) != null ? _b : {}, yAxisProperties],
|
50
55
|
styles.yAxis
|
51
56
|
)(theme);
|
57
|
+
const [xAxisLabelProps, xAxisLabelClassName] = getComponentProps(
|
58
|
+
[(_c = rest.xAxisLabelProps) != null ? _c : {}, labelProperties],
|
59
|
+
styles.xAxisLabel
|
60
|
+
)(theme);
|
61
|
+
const [yAxisLabelProps, yAxisLabelClassName] = getComponentProps(
|
62
|
+
[(_d = rest.yAxisLabelProps) != null ? _d : {}, labelProperties],
|
63
|
+
styles.yAxisLabel
|
64
|
+
)(theme);
|
52
65
|
const getXAxisProps = useCallback(
|
53
66
|
({ className, ...props } = {}) => ({
|
54
67
|
className: cx(className, xAxisClassName),
|
@@ -64,7 +77,7 @@ var useChartAxis = ({
|
|
64
77
|
minTickGap: 5,
|
65
78
|
tickFormatter: xAxisTickFormatter,
|
66
79
|
...props,
|
67
|
-
...
|
80
|
+
...xAxisProps
|
68
81
|
}),
|
69
82
|
[
|
70
83
|
xAxisClassName,
|
@@ -72,7 +85,7 @@ var useChartAxis = ({
|
|
72
85
|
xAxisKey,
|
73
86
|
xTickLine,
|
74
87
|
xAxisTickFormatter,
|
75
|
-
|
88
|
+
xAxisProps
|
76
89
|
]
|
77
90
|
);
|
78
91
|
const getYAxisProps = useCallback(
|
@@ -90,7 +103,7 @@ var useChartAxis = ({
|
|
90
103
|
unit,
|
91
104
|
tickFormatter: yAxisTickFormatter,
|
92
105
|
...props,
|
93
|
-
...
|
106
|
+
...yAxisProps
|
94
107
|
}),
|
95
108
|
[
|
96
109
|
yAxisClassName,
|
@@ -99,10 +112,39 @@ var useChartAxis = ({
|
|
99
112
|
yTickLine,
|
100
113
|
unit,
|
101
114
|
yAxisTickFormatter,
|
102
|
-
|
115
|
+
yAxisProps
|
103
116
|
]
|
104
117
|
);
|
105
|
-
|
118
|
+
const getXAxisLabelProps = useCallback(
|
119
|
+
({ className, ...props } = {}) => ({
|
120
|
+
className: cx(className, xAxisLabelClassName),
|
121
|
+
value: xAxisLabel,
|
122
|
+
position: "insideBottom",
|
123
|
+
offset: -20,
|
124
|
+
...props,
|
125
|
+
...xAxisLabelProps
|
126
|
+
}),
|
127
|
+
[xAxisLabel, xAxisLabelClassName, xAxisLabelProps]
|
128
|
+
);
|
129
|
+
const getYAxisLabelProps = useCallback(
|
130
|
+
({ className, ...props } = {}) => ({
|
131
|
+
className: cx(className, yAxisLabelClassName),
|
132
|
+
value: yAxisLabel,
|
133
|
+
position: "insideLeft",
|
134
|
+
angle: -90,
|
135
|
+
textAnchor: "middle",
|
136
|
+
offset: -5,
|
137
|
+
...props,
|
138
|
+
...yAxisLabelProps
|
139
|
+
}),
|
140
|
+
[yAxisLabel, yAxisLabelClassName, yAxisLabelProps]
|
141
|
+
);
|
142
|
+
return {
|
143
|
+
getXAxisProps,
|
144
|
+
getYAxisProps,
|
145
|
+
getXAxisLabelProps,
|
146
|
+
getYAxisLabelProps
|
147
|
+
};
|
106
148
|
};
|
107
149
|
var valueToPercent = (value) => {
|
108
150
|
return `${(value * 100).toFixed(0)}%`;
|
@@ -111,4 +153,4 @@ var valueToPercent = (value) => {
|
|
111
153
|
export {
|
112
154
|
useChartAxis
|
113
155
|
};
|
114
|
-
//# sourceMappingURL=chunk-
|
156
|
+
//# sourceMappingURL=chunk-XHDDK4ZU.mjs.map
|