@yamada-ui/charts 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +28 -0
- package/dist/area-chart-gradient.d.mts +11 -0
- package/dist/area-chart-gradient.d.ts +11 -0
- package/dist/area-chart-gradient.js +47 -0
- package/dist/area-chart-gradient.js.map +1 -0
- package/dist/area-chart-gradient.mjs +8 -0
- package/dist/area-chart-gradient.mjs.map +1 -0
- package/dist/area-chart-split.d.mts +10 -0
- package/dist/area-chart-split.d.ts +10 -0
- package/dist/area-chart-split.js +52 -0
- package/dist/area-chart-split.js.map +1 -0
- package/dist/area-chart-split.mjs +8 -0
- package/dist/area-chart-split.mjs.map +1 -0
- package/dist/area-chart.d.mts +36 -0
- package/dist/area-chart.d.ts +36 -0
- package/dist/area-chart.js +1249 -0
- package/dist/area-chart.js.map +1 -0
- package/dist/area-chart.mjs +21 -0
- package/dist/area-chart.mjs.map +1 -0
- package/dist/bar-chart.d.mts +33 -0
- package/dist/bar-chart.d.ts +33 -0
- package/dist/bar-chart.js +1053 -0
- package/dist/bar-chart.js.map +1 -0
- package/dist/bar-chart.mjs +19 -0
- package/dist/bar-chart.mjs.map +1 -0
- package/dist/chart-legend.d.mts +12 -0
- package/dist/chart-legend.d.ts +12 -0
- package/dist/chart-legend.js +87 -0
- package/dist/chart-legend.js.map +1 -0
- package/dist/chart-legend.mjs +11 -0
- package/dist/chart-legend.mjs.map +1 -0
- package/dist/chart-tooltip.d.mts +12 -0
- package/dist/chart-tooltip.d.ts +12 -0
- package/dist/chart-tooltip.js +120 -0
- package/dist/chart-tooltip.js.map +1 -0
- package/dist/chart-tooltip.mjs +11 -0
- package/dist/chart-tooltip.mjs.map +1 -0
- package/dist/chart-utils.d.mts +9 -0
- package/dist/chart-utils.d.ts +9 -0
- package/dist/chart-utils.js +45 -0
- package/dist/chart-utils.js.map +1 -0
- package/dist/chart-utils.mjs +10 -0
- package/dist/chart-utils.mjs.map +1 -0
- package/dist/chart.types.d.mts +65 -0
- package/dist/chart.types.d.ts +65 -0
- package/dist/chart.types.js +20 -0
- package/dist/chart.types.js.map +1 -0
- package/dist/chart.types.mjs +2 -0
- package/dist/chart.types.mjs.map +1 -0
- package/dist/chunk-32BO2QEP.mjs +83 -0
- package/dist/chunk-32BO2QEP.mjs.map +1 -0
- package/dist/chunk-3CY3IFRN.mjs +42 -0
- package/dist/chunk-3CY3IFRN.mjs.map +1 -0
- package/dist/chunk-3IBGJT6F.mjs +341 -0
- package/dist/chunk-3IBGJT6F.mjs.map +1 -0
- package/dist/chunk-5QCKM3B3.mjs +438 -0
- package/dist/chunk-5QCKM3B3.mjs.map +1 -0
- package/dist/chunk-AURFFNDQ.mjs +114 -0
- package/dist/chunk-AURFFNDQ.mjs.map +1 -0
- package/dist/chunk-FGDWJUA3.mjs +56 -0
- package/dist/chunk-FGDWJUA3.mjs.map +1 -0
- package/dist/chunk-GZLE5XDS.mjs +227 -0
- package/dist/chunk-GZLE5XDS.mjs.map +1 -0
- package/dist/chunk-HE6SM47L.mjs +234 -0
- package/dist/chunk-HE6SM47L.mjs.map +1 -0
- package/dist/chunk-LXZCGIND.mjs +33 -0
- package/dist/chunk-LXZCGIND.mjs.map +1 -0
- package/dist/chunk-MSIOYYWR.mjs +24 -0
- package/dist/chunk-MSIOYYWR.mjs.map +1 -0
- package/dist/chunk-PNE3JG54.mjs +29 -0
- package/dist/chunk-PNE3JG54.mjs.map +1 -0
- package/dist/chunk-QL3DB7OJ.mjs +21 -0
- package/dist/chunk-QL3DB7OJ.mjs.map +1 -0
- package/dist/chunk-RG5JQJXE.mjs +249 -0
- package/dist/chunk-RG5JQJXE.mjs.map +1 -0
- package/dist/chunk-RTTZPOUT.mjs +50 -0
- package/dist/chunk-RTTZPOUT.mjs.map +1 -0
- package/dist/chunk-RXWD2EJ2.mjs +56 -0
- package/dist/chunk-RXWD2EJ2.mjs.map +1 -0
- package/dist/chunk-TKLHZBVY.mjs +206 -0
- package/dist/chunk-TKLHZBVY.mjs.map +1 -0
- package/dist/chunk-WDSR6B47.mjs +324 -0
- package/dist/chunk-WDSR6B47.mjs.map +1 -0
- package/dist/chunk-WF3BD34Y.mjs +74 -0
- package/dist/chunk-WF3BD34Y.mjs.map +1 -0
- package/dist/chunk-YBAGOHS5.mjs +204 -0
- package/dist/chunk-YBAGOHS5.mjs.map +1 -0
- package/dist/chunk-YRY7MUCR.mjs +258 -0
- package/dist/chunk-YRY7MUCR.mjs.map +1 -0
- package/dist/index.d.mts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +2725 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +36 -0
- package/dist/index.mjs.map +1 -0
- package/dist/line-chart.d.mts +33 -0
- package/dist/line-chart.d.ts +33 -0
- package/dist/line-chart.js +1114 -0
- package/dist/line-chart.js.map +1 -0
- package/dist/line-chart.mjs +19 -0
- package/dist/line-chart.mjs.map +1 -0
- package/dist/radar-chart.d.mts +52 -0
- package/dist/radar-chart.d.ts +52 -0
- package/dist/radar-chart.js +940 -0
- package/dist/radar-chart.js.map +1 -0
- package/dist/radar-chart.mjs +16 -0
- package/dist/radar-chart.mjs.map +1 -0
- package/dist/rechart-properties.d.mts +24 -0
- package/dist/rechart-properties.d.ts +24 -0
- package/dist/rechart-properties.js +479 -0
- package/dist/rechart-properties.js.map +1 -0
- package/dist/rechart-properties.mjs +44 -0
- package/dist/rechart-properties.mjs.map +1 -0
- package/dist/use-area-chart.d.mts +118 -0
- package/dist/use-area-chart.d.ts +118 -0
- package/dist/use-area-chart.js +418 -0
- package/dist/use-area-chart.js.map +1 -0
- package/dist/use-area-chart.mjs +10 -0
- package/dist/use-area-chart.mjs.map +1 -0
- package/dist/use-bar-chart.d.mts +68 -0
- package/dist/use-bar-chart.d.ts +68 -0
- package/dist/use-bar-chart.js +288 -0
- package/dist/use-bar-chart.js.map +1 -0
- package/dist/use-bar-chart.mjs +10 -0
- package/dist/use-bar-chart.mjs.map +1 -0
- package/dist/use-chart-axis.d.mts +73 -0
- package/dist/use-chart-axis.d.ts +73 -0
- package/dist/use-chart-axis.js +227 -0
- package/dist/use-chart-axis.js.map +1 -0
- package/dist/use-chart-axis.mjs +10 -0
- package/dist/use-chart-axis.mjs.map +1 -0
- package/dist/use-chart-grid.d.mts +32 -0
- package/dist/use-chart-grid.d.ts +32 -0
- package/dist/use-chart-grid.js +92 -0
- package/dist/use-chart-grid.js.map +1 -0
- package/dist/use-chart-grid.mjs +10 -0
- package/dist/use-chart-grid.mjs.map +1 -0
- package/dist/use-chart-legend.d.mts +18 -0
- package/dist/use-chart-legend.d.ts +18 -0
- package/dist/use-chart-legend.js +81 -0
- package/dist/use-chart-legend.js.map +1 -0
- package/dist/use-chart-legend.mjs +9 -0
- package/dist/use-chart-legend.mjs.map +1 -0
- package/dist/use-chart-reference-line.d.mts +22 -0
- package/dist/use-chart-reference-line.d.ts +22 -0
- package/dist/use-chart-reference-line.js +105 -0
- package/dist/use-chart-reference-line.js.map +1 -0
- package/dist/use-chart-reference-line.mjs +10 -0
- package/dist/use-chart-reference-line.mjs.map +1 -0
- package/dist/use-chart-tooltip.d.mts +35 -0
- package/dist/use-chart-tooltip.d.ts +35 -0
- package/dist/use-chart-tooltip.js +121 -0
- package/dist/use-chart-tooltip.js.map +1 -0
- package/dist/use-chart-tooltip.mjs +9 -0
- package/dist/use-chart-tooltip.mjs.map +1 -0
- package/dist/use-chart.d.mts +33 -0
- package/dist/use-chart.d.ts +33 -0
- package/dist/use-chart.js +104 -0
- package/dist/use-chart.js.map +1 -0
- package/dist/use-chart.mjs +18 -0
- package/dist/use-chart.mjs.map +1 -0
- package/dist/use-line-chart.d.mts +92 -0
- package/dist/use-line-chart.d.ts +92 -0
- package/dist/use-line-chart.js +342 -0
- package/dist/use-line-chart.js.map +1 -0
- package/dist/use-line-chart.mjs +10 -0
- package/dist/use-line-chart.mjs.map +1 -0
- package/dist/use-radar-chart.d.mts +93 -0
- package/dist/use-radar-chart.d.ts +93 -0
- package/dist/use-radar-chart.js +471 -0
- package/dist/use-radar-chart.js.map +1 -0
- package/dist/use-radar-chart.mjs +10 -0
- package/dist/use-radar-chart.mjs.map +1 -0
- package/package.json +84 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
"use client"
|
2
|
+
import {
|
3
|
+
referenceLineProperties
|
4
|
+
} from "./chunk-5QCKM3B3.mjs";
|
5
|
+
import {
|
6
|
+
getComponentProps
|
7
|
+
} from "./chunk-QL3DB7OJ.mjs";
|
8
|
+
|
9
|
+
// src/use-chart-reference-line.ts
|
10
|
+
import { getCSS, useTheme } from "@yamada-ui/core";
|
11
|
+
import { isObject, cx } from "@yamada-ui/utils";
|
12
|
+
import { useCallback, useMemo } from "react";
|
13
|
+
var useChartReferenceLine = ({
|
14
|
+
referenceLineProps = [],
|
15
|
+
styles
|
16
|
+
}) => {
|
17
|
+
const { theme } = useTheme();
|
18
|
+
const styleClassName = getCSS(styles.referenceLine)(theme);
|
19
|
+
const propList = useMemo(
|
20
|
+
() => referenceLineProps.map((props, index) => {
|
21
|
+
const [{ label: labelProp, ...rest }, propClassName] = getComponentProps(
|
22
|
+
[props, referenceLineProperties],
|
23
|
+
styleClassName
|
24
|
+
)(theme);
|
25
|
+
const color = `var(--ui-reference-line-${index})`;
|
26
|
+
const label = {
|
27
|
+
value: labelProp,
|
28
|
+
fill: color,
|
29
|
+
position: "insideBottomLeft",
|
30
|
+
...isObject(labelProp) ? labelProp : {}
|
31
|
+
};
|
32
|
+
return { propClassName, color, label, ...rest };
|
33
|
+
}),
|
34
|
+
[referenceLineProps, styleClassName, theme]
|
35
|
+
);
|
36
|
+
const getReferenceLineProps = useCallback(
|
37
|
+
({ index, className, ...props }, ref = null) => {
|
38
|
+
const { propClassName, color, label, ...rest } = propList[index];
|
39
|
+
return {
|
40
|
+
ref,
|
41
|
+
className: cx(className, propClassName),
|
42
|
+
stroke: color,
|
43
|
+
label,
|
44
|
+
...props,
|
45
|
+
...rest
|
46
|
+
};
|
47
|
+
},
|
48
|
+
[propList]
|
49
|
+
);
|
50
|
+
return { getReferenceLineProps };
|
51
|
+
};
|
52
|
+
|
53
|
+
export {
|
54
|
+
useChartReferenceLine
|
55
|
+
};
|
56
|
+
//# sourceMappingURL=chunk-FGDWJUA3.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/use-chart-reference-line.ts"],"sourcesContent":["import { getCSS, 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 = `var(--ui-reference-line-${index})`\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,gBAAgB;AAGjC,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,2BAA2B,KAAK;AAC9C,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,227 @@
|
|
1
|
+
"use client"
|
2
|
+
import {
|
3
|
+
useBarChart
|
4
|
+
} from "./chunk-TKLHZBVY.mjs";
|
5
|
+
import {
|
6
|
+
useChartReferenceLine
|
7
|
+
} from "./chunk-FGDWJUA3.mjs";
|
8
|
+
import {
|
9
|
+
useChartLegend
|
10
|
+
} from "./chunk-LXZCGIND.mjs";
|
11
|
+
import {
|
12
|
+
useChartTooltip
|
13
|
+
} from "./chunk-WF3BD34Y.mjs";
|
14
|
+
import {
|
15
|
+
useChartAxis
|
16
|
+
} from "./chunk-AURFFNDQ.mjs";
|
17
|
+
import {
|
18
|
+
useChartGrid
|
19
|
+
} from "./chunk-3CY3IFRN.mjs";
|
20
|
+
import {
|
21
|
+
ChartLegend
|
22
|
+
} from "./chunk-RTTZPOUT.mjs";
|
23
|
+
import {
|
24
|
+
ChartTooltip
|
25
|
+
} from "./chunk-32BO2QEP.mjs";
|
26
|
+
import {
|
27
|
+
ChartProvider,
|
28
|
+
useChart
|
29
|
+
} from "./chunk-RXWD2EJ2.mjs";
|
30
|
+
|
31
|
+
// src/bar-chart.tsx
|
32
|
+
import {
|
33
|
+
ui,
|
34
|
+
forwardRef,
|
35
|
+
useMultiComponentStyle,
|
36
|
+
omitThemeProps
|
37
|
+
} from "@yamada-ui/core";
|
38
|
+
import { cx } from "@yamada-ui/utils";
|
39
|
+
import { useMemo } from "react";
|
40
|
+
import {
|
41
|
+
Legend,
|
42
|
+
BarChart as ReChartsBarChart,
|
43
|
+
Bar,
|
44
|
+
CartesianGrid,
|
45
|
+
Tooltip,
|
46
|
+
XAxis,
|
47
|
+
YAxis,
|
48
|
+
ResponsiveContainer,
|
49
|
+
ReferenceLine
|
50
|
+
} from "recharts";
|
51
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
52
|
+
var BarChart = forwardRef((props, ref) => {
|
53
|
+
const [styles, mergedProps] = useMultiComponentStyle("BarChart", props);
|
54
|
+
const {
|
55
|
+
className,
|
56
|
+
series,
|
57
|
+
dataKey,
|
58
|
+
layoutType,
|
59
|
+
tickLine,
|
60
|
+
gridAxis,
|
61
|
+
withXAxis,
|
62
|
+
withYAxis,
|
63
|
+
barProps,
|
64
|
+
xAxisProps,
|
65
|
+
yAxisProps,
|
66
|
+
type = "default",
|
67
|
+
withTooltip = true,
|
68
|
+
withLegend = false,
|
69
|
+
containerProps,
|
70
|
+
unit,
|
71
|
+
valueFormatter,
|
72
|
+
tooltipProps,
|
73
|
+
tooltipAnimationDuration,
|
74
|
+
legendProps,
|
75
|
+
data,
|
76
|
+
referenceLineProps = [],
|
77
|
+
gridProps,
|
78
|
+
strokeDasharray,
|
79
|
+
fillOpacity,
|
80
|
+
barChartProps,
|
81
|
+
...rest
|
82
|
+
} = omitThemeProps(mergedProps);
|
83
|
+
const { getBarChartProps, getBarProps, barVars, setHighlightedArea } = useBarChart({
|
84
|
+
data,
|
85
|
+
series,
|
86
|
+
type,
|
87
|
+
layoutType,
|
88
|
+
barChartProps,
|
89
|
+
barProps,
|
90
|
+
referenceLineProps,
|
91
|
+
fillOpacity,
|
92
|
+
styles
|
93
|
+
});
|
94
|
+
const { getContainerProps } = useChart({ containerProps });
|
95
|
+
const { getXAxisProps, getYAxisProps } = useChartAxis({
|
96
|
+
dataKey,
|
97
|
+
type,
|
98
|
+
layoutType,
|
99
|
+
tickLine,
|
100
|
+
gridAxis,
|
101
|
+
withXAxis,
|
102
|
+
withYAxis,
|
103
|
+
xAxisProps,
|
104
|
+
yAxisProps,
|
105
|
+
unit,
|
106
|
+
valueFormatter,
|
107
|
+
styles
|
108
|
+
});
|
109
|
+
const { getReferenceLineProps } = useChartReferenceLine({
|
110
|
+
referenceLineProps,
|
111
|
+
styles
|
112
|
+
});
|
113
|
+
const { getGridProps } = useChartGrid({
|
114
|
+
gridProps,
|
115
|
+
gridAxis,
|
116
|
+
strokeDasharray,
|
117
|
+
styles
|
118
|
+
});
|
119
|
+
const {
|
120
|
+
tooltipProps: computedTooltipProps,
|
121
|
+
getTooltipProps,
|
122
|
+
tooltipVars
|
123
|
+
} = useChartTooltip({
|
124
|
+
tooltipProps,
|
125
|
+
tooltipAnimationDuration,
|
126
|
+
styles
|
127
|
+
});
|
128
|
+
const { legendProps: computedLegendProps, getLegendProps } = useChartLegend({
|
129
|
+
legendProps
|
130
|
+
});
|
131
|
+
const bars = useMemo(
|
132
|
+
() => series.map(({ dataKey: dataKey2 }, index) => {
|
133
|
+
return /* @__PURE__ */ jsx(
|
134
|
+
Bar,
|
135
|
+
{
|
136
|
+
...getBarProps({ index, className: "ui-bar-chart__bar" })
|
137
|
+
},
|
138
|
+
`bar-${dataKey2}`
|
139
|
+
);
|
140
|
+
}),
|
141
|
+
[getBarProps, series]
|
142
|
+
);
|
143
|
+
const referenceLinesItems = useMemo(
|
144
|
+
() => referenceLineProps.map((_, index) => /* @__PURE__ */ jsx(
|
145
|
+
ReferenceLine,
|
146
|
+
{
|
147
|
+
...getReferenceLineProps({
|
148
|
+
index,
|
149
|
+
className: "ui-bar-chart__reference-line"
|
150
|
+
})
|
151
|
+
},
|
152
|
+
`referenceLine-${index}`
|
153
|
+
)),
|
154
|
+
[getReferenceLineProps, referenceLineProps]
|
155
|
+
);
|
156
|
+
return /* @__PURE__ */ jsx(ChartProvider, { value: { styles }, children: /* @__PURE__ */ jsx(
|
157
|
+
ui.div,
|
158
|
+
{
|
159
|
+
ref,
|
160
|
+
className: cx("ui-bar-chart", className),
|
161
|
+
var: [...barVars, ...tooltipVars],
|
162
|
+
__css: { maxW: "full", ...styles.container },
|
163
|
+
...rest,
|
164
|
+
children: /* @__PURE__ */ jsx(
|
165
|
+
ResponsiveContainer,
|
166
|
+
{
|
167
|
+
...getContainerProps({ className: "ui-bar-chart__container" }),
|
168
|
+
children: /* @__PURE__ */ jsxs(
|
169
|
+
ReChartsBarChart,
|
170
|
+
{
|
171
|
+
...getBarChartProps({ className: "ui-bar-chart__chart" }),
|
172
|
+
children: [
|
173
|
+
/* @__PURE__ */ jsx(
|
174
|
+
CartesianGrid,
|
175
|
+
{
|
176
|
+
...getGridProps({ className: "ui-area-chart__grid" })
|
177
|
+
}
|
178
|
+
),
|
179
|
+
/* @__PURE__ */ jsx(XAxis, { ...getXAxisProps({ className: "ui-bar-chart__x-axis" }) }),
|
180
|
+
/* @__PURE__ */ jsx(YAxis, { ...getYAxisProps({ className: "ui-bar-chart__y-axis" }) }),
|
181
|
+
withLegend ? /* @__PURE__ */ jsx(
|
182
|
+
Legend,
|
183
|
+
{
|
184
|
+
content: ({ payload }) => /* @__PURE__ */ jsx(
|
185
|
+
ChartLegend,
|
186
|
+
{
|
187
|
+
className: "ui-bar-chart__legend",
|
188
|
+
payload,
|
189
|
+
onHighlight: setHighlightedArea,
|
190
|
+
...computedLegendProps
|
191
|
+
}
|
192
|
+
),
|
193
|
+
...getLegendProps()
|
194
|
+
}
|
195
|
+
) : null,
|
196
|
+
withTooltip ? /* @__PURE__ */ jsx(
|
197
|
+
Tooltip,
|
198
|
+
{
|
199
|
+
content: ({ label, payload }) => /* @__PURE__ */ jsx(
|
200
|
+
ChartTooltip,
|
201
|
+
{
|
202
|
+
className: "ui-bar-chart__tooltip",
|
203
|
+
label,
|
204
|
+
payload,
|
205
|
+
valueFormatter,
|
206
|
+
unit,
|
207
|
+
...computedTooltipProps
|
208
|
+
}
|
209
|
+
),
|
210
|
+
...getTooltipProps()
|
211
|
+
}
|
212
|
+
) : null,
|
213
|
+
bars,
|
214
|
+
referenceLinesItems
|
215
|
+
]
|
216
|
+
}
|
217
|
+
)
|
218
|
+
}
|
219
|
+
)
|
220
|
+
}
|
221
|
+
) });
|
222
|
+
});
|
223
|
+
|
224
|
+
export {
|
225
|
+
BarChart
|
226
|
+
};
|
227
|
+
//# sourceMappingURL=chunk-GZLE5XDS.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} 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\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 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 barChartProps,\n ...rest\n } = omitThemeProps(mergedProps)\n\n const { getBarChartProps, getBarProps, barVars, setHighlightedArea } =\n useBarChart({\n data,\n series,\n type,\n layoutType,\n barChartProps,\n barProps,\n referenceLineProps,\n fillOpacity,\n styles,\n })\n const { getContainerProps } = useChart({ containerProps })\n const { getXAxisProps, getYAxisProps } = useChartAxis({\n dataKey,\n type,\n layoutType,\n tickLine,\n gridAxis,\n withXAxis,\n withYAxis,\n xAxisProps,\n yAxisProps,\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 {\n tooltipProps: computedTooltipProps,\n getTooltipProps,\n tooltipVars,\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, ...tooltipVars]}\n __css={{ maxW: \"full\", ...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-area-chart__grid\" })}\n />\n <XAxis {...getXAxisProps({ className: \"ui-bar-chart__x-axis\" })} />\n <YAxis {...getYAxisProps({ className: \"ui-bar-chart__y-axis\" })} />\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,OACK;AAmIG,cAmCA,YAnCA;AAtFH,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;AAAA,IACA,OAAO;AAAA,IACP,cAAc;AAAA,IACd,aAAa;AAAA,IACb;AAAA,IACA;AAAA,I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AAO,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"]}
|
@@ -0,0 +1,234 @@
|
|
1
|
+
"use client"
|
2
|
+
import {
|
3
|
+
useLineChart
|
4
|
+
} from "./chunk-RG5JQJXE.mjs";
|
5
|
+
import {
|
6
|
+
useChartReferenceLine
|
7
|
+
} from "./chunk-FGDWJUA3.mjs";
|
8
|
+
import {
|
9
|
+
useChartLegend
|
10
|
+
} from "./chunk-LXZCGIND.mjs";
|
11
|
+
import {
|
12
|
+
useChartTooltip
|
13
|
+
} from "./chunk-WF3BD34Y.mjs";
|
14
|
+
import {
|
15
|
+
useChartAxis
|
16
|
+
} from "./chunk-AURFFNDQ.mjs";
|
17
|
+
import {
|
18
|
+
useChartGrid
|
19
|
+
} from "./chunk-3CY3IFRN.mjs";
|
20
|
+
import {
|
21
|
+
ChartLegend
|
22
|
+
} from "./chunk-RTTZPOUT.mjs";
|
23
|
+
import {
|
24
|
+
ChartTooltip
|
25
|
+
} from "./chunk-32BO2QEP.mjs";
|
26
|
+
import {
|
27
|
+
ChartProvider,
|
28
|
+
useChart
|
29
|
+
} from "./chunk-RXWD2EJ2.mjs";
|
30
|
+
|
31
|
+
// src/line-chart.tsx
|
32
|
+
import {
|
33
|
+
ui,
|
34
|
+
forwardRef,
|
35
|
+
useMultiComponentStyle,
|
36
|
+
omitThemeProps
|
37
|
+
} from "@yamada-ui/core";
|
38
|
+
import { cx } from "@yamada-ui/utils";
|
39
|
+
import { useMemo } from "react";
|
40
|
+
import {
|
41
|
+
LineChart as ReChartsLineChart,
|
42
|
+
Legend,
|
43
|
+
CartesianGrid,
|
44
|
+
ResponsiveContainer,
|
45
|
+
Tooltip,
|
46
|
+
XAxis,
|
47
|
+
YAxis,
|
48
|
+
ReferenceLine,
|
49
|
+
Line
|
50
|
+
} from "recharts";
|
51
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
52
|
+
var LineChart = forwardRef((props, ref) => {
|
53
|
+
const [styles, mergedProps] = useMultiComponentStyle("LineChart", props);
|
54
|
+
const {
|
55
|
+
className,
|
56
|
+
containerProps,
|
57
|
+
gridProps,
|
58
|
+
gridAxis,
|
59
|
+
strokeDasharray,
|
60
|
+
dataKey,
|
61
|
+
type,
|
62
|
+
layoutType,
|
63
|
+
tickLine,
|
64
|
+
withXAxis,
|
65
|
+
withYAxis,
|
66
|
+
xAxisProps,
|
67
|
+
yAxisProps,
|
68
|
+
unit,
|
69
|
+
valueFormatter,
|
70
|
+
referenceLineProps,
|
71
|
+
tooltipProps,
|
72
|
+
tooltipAnimationDuration,
|
73
|
+
legendProps,
|
74
|
+
withLegend = false,
|
75
|
+
withTooltip = true,
|
76
|
+
series,
|
77
|
+
data,
|
78
|
+
lineChartProps,
|
79
|
+
lineProps,
|
80
|
+
withDots,
|
81
|
+
withActiveDots,
|
82
|
+
curveType,
|
83
|
+
strokeWidth,
|
84
|
+
connectNulls,
|
85
|
+
fillOpacity,
|
86
|
+
...rest
|
87
|
+
} = omitThemeProps(mergedProps);
|
88
|
+
const { getLineProps, getLineChartProps, lineVars, setHighlightedArea } = useLineChart({
|
89
|
+
layoutType,
|
90
|
+
series,
|
91
|
+
referenceLineProps,
|
92
|
+
data,
|
93
|
+
lineChartProps,
|
94
|
+
lineProps,
|
95
|
+
withDots,
|
96
|
+
withActiveDots,
|
97
|
+
curveType,
|
98
|
+
strokeWidth,
|
99
|
+
connectNulls,
|
100
|
+
fillOpacity,
|
101
|
+
styles
|
102
|
+
});
|
103
|
+
const { getContainerProps } = useChart({ containerProps });
|
104
|
+
const { getXAxisProps, getYAxisProps } = useChartAxis({
|
105
|
+
dataKey,
|
106
|
+
type,
|
107
|
+
layoutType,
|
108
|
+
tickLine,
|
109
|
+
gridAxis,
|
110
|
+
withXAxis,
|
111
|
+
withYAxis,
|
112
|
+
xAxisProps,
|
113
|
+
yAxisProps,
|
114
|
+
unit,
|
115
|
+
valueFormatter,
|
116
|
+
styles
|
117
|
+
});
|
118
|
+
const { getReferenceLineProps } = useChartReferenceLine({
|
119
|
+
referenceLineProps,
|
120
|
+
styles
|
121
|
+
});
|
122
|
+
const { getGridProps } = useChartGrid({
|
123
|
+
gridProps,
|
124
|
+
gridAxis,
|
125
|
+
strokeDasharray,
|
126
|
+
styles
|
127
|
+
});
|
128
|
+
const {
|
129
|
+
tooltipProps: computedTooltipProps,
|
130
|
+
getTooltipProps,
|
131
|
+
tooltipVars
|
132
|
+
} = useChartTooltip({
|
133
|
+
tooltipProps,
|
134
|
+
tooltipAnimationDuration,
|
135
|
+
styles
|
136
|
+
});
|
137
|
+
const { legendProps: computedLegendProps, getLegendProps } = useChartLegend({
|
138
|
+
legendProps
|
139
|
+
});
|
140
|
+
const lines = useMemo(
|
141
|
+
() => series.map(({ dataKey: dataKey2 }, index) => /* @__PURE__ */ jsx(
|
142
|
+
Line,
|
143
|
+
{
|
144
|
+
...getLineProps({ index, className: "ui-line-chart__line" })
|
145
|
+
},
|
146
|
+
`line-${dataKey2}`
|
147
|
+
)),
|
148
|
+
[getLineProps, series]
|
149
|
+
);
|
150
|
+
const referenceLinesItems = useMemo(
|
151
|
+
() => referenceLineProps == null ? void 0 : referenceLineProps.map((_, index) => /* @__PURE__ */ jsx(
|
152
|
+
ReferenceLine,
|
153
|
+
{
|
154
|
+
...getReferenceLineProps({
|
155
|
+
index,
|
156
|
+
className: "ui-line-chart__reference-line"
|
157
|
+
})
|
158
|
+
},
|
159
|
+
`referenceLine-${index}`
|
160
|
+
)),
|
161
|
+
[getReferenceLineProps, referenceLineProps]
|
162
|
+
);
|
163
|
+
return /* @__PURE__ */ jsx(ChartProvider, { value: { styles }, children: /* @__PURE__ */ jsx(
|
164
|
+
ui.div,
|
165
|
+
{
|
166
|
+
ref,
|
167
|
+
className: cx("ui-line-chart", className),
|
168
|
+
var: [...lineVars, ...tooltipVars],
|
169
|
+
__css: { maxW: "full", ...styles.container },
|
170
|
+
...rest,
|
171
|
+
children: /* @__PURE__ */ jsx(
|
172
|
+
ResponsiveContainer,
|
173
|
+
{
|
174
|
+
...getContainerProps({ className: "ui-line-chart__container" }),
|
175
|
+
children: /* @__PURE__ */ jsxs(
|
176
|
+
ReChartsLineChart,
|
177
|
+
{
|
178
|
+
...getLineChartProps({ className: "ui-line-chart__chart" }),
|
179
|
+
children: [
|
180
|
+
/* @__PURE__ */ jsx(
|
181
|
+
CartesianGrid,
|
182
|
+
{
|
183
|
+
...getGridProps({ className: "ui-line-chart__grid" })
|
184
|
+
}
|
185
|
+
),
|
186
|
+
/* @__PURE__ */ jsx(XAxis, { ...getXAxisProps({ className: "ui-line-chart__x-axis" }) }),
|
187
|
+
/* @__PURE__ */ jsx(YAxis, { ...getYAxisProps({ className: "ui-line-chart__y-axis" }) }),
|
188
|
+
withLegend ? /* @__PURE__ */ jsx(
|
189
|
+
Legend,
|
190
|
+
{
|
191
|
+
content: ({ payload }) => /* @__PURE__ */ jsx(
|
192
|
+
ChartLegend,
|
193
|
+
{
|
194
|
+
className: "ui-line-chart__legend",
|
195
|
+
payload,
|
196
|
+
onHighlight: setHighlightedArea,
|
197
|
+
...computedLegendProps
|
198
|
+
}
|
199
|
+
),
|
200
|
+
...getLegendProps()
|
201
|
+
}
|
202
|
+
) : null,
|
203
|
+
withTooltip ? /* @__PURE__ */ jsx(
|
204
|
+
Tooltip,
|
205
|
+
{
|
206
|
+
content: ({ label, payload }) => /* @__PURE__ */ jsx(
|
207
|
+
ChartTooltip,
|
208
|
+
{
|
209
|
+
className: "ui-line-chart__tooltip",
|
210
|
+
label,
|
211
|
+
payload,
|
212
|
+
valueFormatter,
|
213
|
+
unit,
|
214
|
+
...computedTooltipProps
|
215
|
+
}
|
216
|
+
),
|
217
|
+
...getTooltipProps()
|
218
|
+
}
|
219
|
+
) : null,
|
220
|
+
lines,
|
221
|
+
referenceLinesItems
|
222
|
+
]
|
223
|
+
}
|
224
|
+
)
|
225
|
+
}
|
226
|
+
)
|
227
|
+
}
|
228
|
+
) });
|
229
|
+
});
|
230
|
+
|
231
|
+
export {
|
232
|
+
LineChart
|
233
|
+
};
|
234
|
+
//# sourceMappingURL=chunk-HE6SM47L.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} 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\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 unit,\n valueFormatter,\n referenceLineProps,\n tooltipProps,\n tooltipAnimationDuration,\n legendProps,\n withLegend = false,\n withTooltip = true,\n series,\n data,\n lineChartProps,\n lineProps,\n withDots,\n withActiveDots,\n curveType,\n strokeWidth,\n connectNulls,\n fillOpacity,\n ...rest\n } = omitThemeProps(mergedProps)\n\n const { getLineProps, getLineChartProps, lineVars, setHighlightedArea } =\n useLineChart({\n layoutType,\n series,\n referenceLineProps,\n data,\n lineChartProps,\n lineProps,\n withDots,\n withActiveDots,\n curveType,\n strokeWidth,\n connectNulls,\n fillOpacity,\n styles,\n })\n const { getContainerProps } = useChart({ containerProps })\n const { getXAxisProps, getYAxisProps } = useChartAxis({\n dataKey,\n type,\n layoutType,\n tickLine,\n gridAxis,\n withXAxis,\n withYAxis,\n xAxisProps,\n yAxisProps,\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 {\n tooltipProps: computedTooltipProps,\n getTooltipProps,\n tooltipVars,\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, ...tooltipVars]}\n __css={{ maxW: \"full\", ...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 <XAxis {...getXAxisProps({ className: \"ui-line-chart__x-axis\" })} />\n <YAxis {...getYAxisProps({ className: \"ui-line-chart__y-axis\" })} />\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,U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AAAA,kBAAC;AAAA;AAAA,oBACE,GAAG,aAAa,EAAE,WAAW,sBAAsB,CAAC;AAAA;AAAA,gBACvD;AAAA,gBACA,oBAAC,SAAO,GAAG,cAAc,EAAE,WAAW,wBAAwB,CAAC,GAAG;AAAA,gBAClE,oBAAC,SAAO,GAAG,cAAc,EAAE,WAAW,wBAAwB,CAAC,GAAG;AAAA,gBAEjE,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"]}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
"use client"
|
2
|
+
import {
|
3
|
+
legendProperties
|
4
|
+
} from "./chunk-5QCKM3B3.mjs";
|
5
|
+
|
6
|
+
// src/use-chart-legend.ts
|
7
|
+
import { splitObject } from "@yamada-ui/utils";
|
8
|
+
import { useCallback } from "react";
|
9
|
+
var useChartLegend = ({
|
10
|
+
legendProps: _legendProps = {}
|
11
|
+
}) => {
|
12
|
+
const [rest, legendProps] = splitObject(
|
13
|
+
_legendProps,
|
14
|
+
legendProperties
|
15
|
+
);
|
16
|
+
const getLegendProps = useCallback(
|
17
|
+
(props, ref = null) => {
|
18
|
+
return {
|
19
|
+
ref,
|
20
|
+
verticalAlign: "top",
|
21
|
+
...props,
|
22
|
+
...rest
|
23
|
+
};
|
24
|
+
},
|
25
|
+
[rest]
|
26
|
+
);
|
27
|
+
return { legendProps, getLegendProps };
|
28
|
+
};
|
29
|
+
|
30
|
+
export {
|
31
|
+
useChartLegend
|
32
|
+
};
|
33
|
+
//# sourceMappingURL=chunk-LXZCGIND.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/use-chart-legend.ts"],"sourcesContent":["import type { Dict } from \"@yamada-ui/utils\"\nimport { splitObject } from \"@yamada-ui/utils\"\nimport { useCallback } from \"react\"\nimport type * as Recharts from \"recharts\"\nimport type { ChartPropGetter, LegendProps } from \"./chart.types\"\nimport { legendProperties } from \"./rechart-properties\"\n\nexport type UseChartLegendProps = {\n /**\n * Props passed down to recharts 'Legend' component.\n */\n legendProps?: LegendProps\n}\n\nexport const useChartLegend = ({\n legendProps: _legendProps = {},\n}: UseChartLegendProps) => {\n const [rest, legendProps] = splitObject<Dict, string>(\n _legendProps,\n legendProperties,\n )\n\n const getLegendProps: ChartPropGetter<\n \"div\",\n Partial<Recharts.LegendProps>,\n Omit<Recharts.LegendProps, \"ref\">\n > = useCallback(\n (props, ref = null) => {\n return {\n ref,\n verticalAlign: \"top\",\n ...props,\n ...rest,\n }\n },\n [rest],\n )\n\n return { legendProps, getLegendProps }\n}\n"],"mappings":";;;;;;AACA,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAYrB,IAAM,iBAAiB,CAAC;AAAA,EAC7B,aAAa,eAAe,CAAC;AAC/B,MAA2B;AACzB,QAAM,CAAC,MAAM,WAAW,IAAI;AAAA,IAC1B;AAAA,IACA;AAAA,EACF;AAEA,QAAM,iBAIF;AAAA,IACF,CAAC,OAAO,MAAM,SAAS;AACrB,aAAO;AAAA,QACL;AAAA,QACA,eAAe;AAAA,QACf,GAAG;AAAA,QACH,GAAG;AAAA,MACL;AAAA,IACF;AAAA,IACA,CAAC,IAAI;AAAA,EACP;AAEA,SAAO,EAAE,aAAa,eAAe;AACvC;","names":[]}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"use client"
|
2
|
+
|
3
|
+
// src/area-chart-gradient.tsx
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
5
|
+
var AreaGradient = ({
|
6
|
+
color,
|
7
|
+
id,
|
8
|
+
withGradient,
|
9
|
+
fillOpacity
|
10
|
+
}) => {
|
11
|
+
if (withGradient) {
|
12
|
+
return /* @__PURE__ */ jsxs("linearGradient", { id, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
13
|
+
/* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: color, stopOpacity: fillOpacity }),
|
14
|
+
/* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: color, stopOpacity: 0.01 })
|
15
|
+
] });
|
16
|
+
} else {
|
17
|
+
return /* @__PURE__ */ jsx("linearGradient", { id, x1: "0", y1: "0", x2: "0", y2: "1", children: /* @__PURE__ */ jsx("stop", { stopColor: color, stopOpacity: fillOpacity }) });
|
18
|
+
}
|
19
|
+
};
|
20
|
+
|
21
|
+
export {
|
22
|
+
AreaGradient
|
23
|
+
};
|
24
|
+
//# sourceMappingURL=chunk-MSIOYYWR.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/area-chart-gradient.tsx"],"sourcesContent":["export type AreaGradientProps = {\n id?: string\n color?: string\n withGradient?: boolean\n fillOpacity: number | string\n}\n\nexport const AreaGradient = ({\n color,\n id,\n withGradient,\n fillOpacity,\n}: AreaGradientProps) => {\n if (withGradient) {\n return (\n <linearGradient id={id} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n <stop offset=\"0%\" stopColor={color} stopOpacity={fillOpacity} />\n <stop offset=\"100%\" stopColor={color} stopOpacity={0.01} />\n </linearGradient>\n )\n } else {\n return (\n <linearGradient id={id} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n <stop stopColor={color} stopOpacity={fillOpacity} />\n </linearGradient>\n )\n }\n}\n"],"mappings":";;;AAeM,SACE,KADF;AARC,IAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAyB;AACvB,MAAI,cAAc;AAChB,WACE,qBAAC,oBAAe,IAAQ,IAAG,KAAI,IAAG,KAAI,IAAG,KAAI,IAAG,KAC9C;AAAA,0BAAC,UAAK,QAAO,MAAK,WAAW,OAAO,aAAa,aAAa;AAAA,MAC9D,oBAAC,UAAK,QAAO,QAAO,WAAW,OAAO,aAAa,MAAM;AAAA,OAC3D;AAAA,EAEJ,OAAO;AACL,WACE,oBAAC,oBAAe,IAAQ,IAAG,KAAI,IAAG,KAAI,IAAG,KAAI,IAAG,KAC9C,8BAAC,UAAK,WAAW,OAAO,aAAa,aAAa,GACpD;AAAA,EAEJ;AACF;","names":[]}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"use client"
|
2
|
+
|
3
|
+
// src/area-chart-split.tsx
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
5
|
+
var AreaSplit = ({ offset, id, fillOpacity }) => {
|
6
|
+
return /* @__PURE__ */ jsxs("linearGradient", { id, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
7
|
+
/* @__PURE__ */ jsx(
|
8
|
+
"stop",
|
9
|
+
{
|
10
|
+
offset,
|
11
|
+
stopColor: "var(--ui-area-split-0)",
|
12
|
+
stopOpacity: fillOpacity != null ? fillOpacity : 0.4
|
13
|
+
}
|
14
|
+
),
|
15
|
+
/* @__PURE__ */ jsx(
|
16
|
+
"stop",
|
17
|
+
{
|
18
|
+
offset,
|
19
|
+
stopColor: "var(--ui-area-split-1)",
|
20
|
+
stopOpacity: fillOpacity != null ? fillOpacity : 0.4
|
21
|
+
}
|
22
|
+
)
|
23
|
+
] });
|
24
|
+
};
|
25
|
+
|
26
|
+
export {
|
27
|
+
AreaSplit
|
28
|
+
};
|
29
|
+
//# sourceMappingURL=chunk-PNE3JG54.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/area-chart-split.tsx"],"sourcesContent":["export type AreaSplitProps = {\n offset: number\n id?: string\n fillOpacity: number | string | undefined\n}\n\nexport const AreaSplit = ({ offset, id, fillOpacity }: AreaSplitProps) => {\n return (\n <linearGradient id={id} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n <stop\n offset={offset}\n stopColor=\"var(--ui-area-split-0)\"\n stopOpacity={fillOpacity ?? 0.4}\n />\n <stop\n offset={offset}\n stopColor=\"var(--ui-area-split-1)\"\n stopOpacity={fillOpacity ?? 0.4}\n />\n </linearGradient>\n )\n}\n"],"mappings":";;;AAQI,SACE,KADF;AAFG,IAAM,YAAY,CAAC,EAAE,QAAQ,IAAI,YAAY,MAAsB;AACxE,SACE,qBAAC,oBAAe,IAAQ,IAAG,KAAI,IAAG,KAAI,IAAG,KAAI,IAAG,KAC9C;AAAA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,WAAU;AAAA,QACV,aAAa,oCAAe;AAAA;AAAA,IAC9B;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,WAAU;AAAA,QACV,aAAa,oCAAe;AAAA;AAAA,IAC9B;AAAA,KACF;AAEJ;","names":[]}
|