@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.
Files changed (175) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +28 -0
  3. package/dist/area-chart-gradient.d.mts +11 -0
  4. package/dist/area-chart-gradient.d.ts +11 -0
  5. package/dist/area-chart-gradient.js +47 -0
  6. package/dist/area-chart-gradient.js.map +1 -0
  7. package/dist/area-chart-gradient.mjs +8 -0
  8. package/dist/area-chart-gradient.mjs.map +1 -0
  9. package/dist/area-chart-split.d.mts +10 -0
  10. package/dist/area-chart-split.d.ts +10 -0
  11. package/dist/area-chart-split.js +52 -0
  12. package/dist/area-chart-split.js.map +1 -0
  13. package/dist/area-chart-split.mjs +8 -0
  14. package/dist/area-chart-split.mjs.map +1 -0
  15. package/dist/area-chart.d.mts +36 -0
  16. package/dist/area-chart.d.ts +36 -0
  17. package/dist/area-chart.js +1249 -0
  18. package/dist/area-chart.js.map +1 -0
  19. package/dist/area-chart.mjs +21 -0
  20. package/dist/area-chart.mjs.map +1 -0
  21. package/dist/bar-chart.d.mts +33 -0
  22. package/dist/bar-chart.d.ts +33 -0
  23. package/dist/bar-chart.js +1053 -0
  24. package/dist/bar-chart.js.map +1 -0
  25. package/dist/bar-chart.mjs +19 -0
  26. package/dist/bar-chart.mjs.map +1 -0
  27. package/dist/chart-legend.d.mts +12 -0
  28. package/dist/chart-legend.d.ts +12 -0
  29. package/dist/chart-legend.js +87 -0
  30. package/dist/chart-legend.js.map +1 -0
  31. package/dist/chart-legend.mjs +11 -0
  32. package/dist/chart-legend.mjs.map +1 -0
  33. package/dist/chart-tooltip.d.mts +12 -0
  34. package/dist/chart-tooltip.d.ts +12 -0
  35. package/dist/chart-tooltip.js +120 -0
  36. package/dist/chart-tooltip.js.map +1 -0
  37. package/dist/chart-tooltip.mjs +11 -0
  38. package/dist/chart-tooltip.mjs.map +1 -0
  39. package/dist/chart-utils.d.mts +9 -0
  40. package/dist/chart-utils.d.ts +9 -0
  41. package/dist/chart-utils.js +45 -0
  42. package/dist/chart-utils.js.map +1 -0
  43. package/dist/chart-utils.mjs +10 -0
  44. package/dist/chart-utils.mjs.map +1 -0
  45. package/dist/chart.types.d.mts +65 -0
  46. package/dist/chart.types.d.ts +65 -0
  47. package/dist/chart.types.js +20 -0
  48. package/dist/chart.types.js.map +1 -0
  49. package/dist/chart.types.mjs +2 -0
  50. package/dist/chart.types.mjs.map +1 -0
  51. package/dist/chunk-32BO2QEP.mjs +83 -0
  52. package/dist/chunk-32BO2QEP.mjs.map +1 -0
  53. package/dist/chunk-3CY3IFRN.mjs +42 -0
  54. package/dist/chunk-3CY3IFRN.mjs.map +1 -0
  55. package/dist/chunk-3IBGJT6F.mjs +341 -0
  56. package/dist/chunk-3IBGJT6F.mjs.map +1 -0
  57. package/dist/chunk-5QCKM3B3.mjs +438 -0
  58. package/dist/chunk-5QCKM3B3.mjs.map +1 -0
  59. package/dist/chunk-AURFFNDQ.mjs +114 -0
  60. package/dist/chunk-AURFFNDQ.mjs.map +1 -0
  61. package/dist/chunk-FGDWJUA3.mjs +56 -0
  62. package/dist/chunk-FGDWJUA3.mjs.map +1 -0
  63. package/dist/chunk-GZLE5XDS.mjs +227 -0
  64. package/dist/chunk-GZLE5XDS.mjs.map +1 -0
  65. package/dist/chunk-HE6SM47L.mjs +234 -0
  66. package/dist/chunk-HE6SM47L.mjs.map +1 -0
  67. package/dist/chunk-LXZCGIND.mjs +33 -0
  68. package/dist/chunk-LXZCGIND.mjs.map +1 -0
  69. package/dist/chunk-MSIOYYWR.mjs +24 -0
  70. package/dist/chunk-MSIOYYWR.mjs.map +1 -0
  71. package/dist/chunk-PNE3JG54.mjs +29 -0
  72. package/dist/chunk-PNE3JG54.mjs.map +1 -0
  73. package/dist/chunk-QL3DB7OJ.mjs +21 -0
  74. package/dist/chunk-QL3DB7OJ.mjs.map +1 -0
  75. package/dist/chunk-RG5JQJXE.mjs +249 -0
  76. package/dist/chunk-RG5JQJXE.mjs.map +1 -0
  77. package/dist/chunk-RTTZPOUT.mjs +50 -0
  78. package/dist/chunk-RTTZPOUT.mjs.map +1 -0
  79. package/dist/chunk-RXWD2EJ2.mjs +56 -0
  80. package/dist/chunk-RXWD2EJ2.mjs.map +1 -0
  81. package/dist/chunk-TKLHZBVY.mjs +206 -0
  82. package/dist/chunk-TKLHZBVY.mjs.map +1 -0
  83. package/dist/chunk-WDSR6B47.mjs +324 -0
  84. package/dist/chunk-WDSR6B47.mjs.map +1 -0
  85. package/dist/chunk-WF3BD34Y.mjs +74 -0
  86. package/dist/chunk-WF3BD34Y.mjs.map +1 -0
  87. package/dist/chunk-YBAGOHS5.mjs +204 -0
  88. package/dist/chunk-YBAGOHS5.mjs.map +1 -0
  89. package/dist/chunk-YRY7MUCR.mjs +258 -0
  90. package/dist/chunk-YRY7MUCR.mjs.map +1 -0
  91. package/dist/index.d.mts +23 -0
  92. package/dist/index.d.ts +23 -0
  93. package/dist/index.js +2725 -0
  94. package/dist/index.js.map +1 -0
  95. package/dist/index.mjs +36 -0
  96. package/dist/index.mjs.map +1 -0
  97. package/dist/line-chart.d.mts +33 -0
  98. package/dist/line-chart.d.ts +33 -0
  99. package/dist/line-chart.js +1114 -0
  100. package/dist/line-chart.js.map +1 -0
  101. package/dist/line-chart.mjs +19 -0
  102. package/dist/line-chart.mjs.map +1 -0
  103. package/dist/radar-chart.d.mts +52 -0
  104. package/dist/radar-chart.d.ts +52 -0
  105. package/dist/radar-chart.js +940 -0
  106. package/dist/radar-chart.js.map +1 -0
  107. package/dist/radar-chart.mjs +16 -0
  108. package/dist/radar-chart.mjs.map +1 -0
  109. package/dist/rechart-properties.d.mts +24 -0
  110. package/dist/rechart-properties.d.ts +24 -0
  111. package/dist/rechart-properties.js +479 -0
  112. package/dist/rechart-properties.js.map +1 -0
  113. package/dist/rechart-properties.mjs +44 -0
  114. package/dist/rechart-properties.mjs.map +1 -0
  115. package/dist/use-area-chart.d.mts +118 -0
  116. package/dist/use-area-chart.d.ts +118 -0
  117. package/dist/use-area-chart.js +418 -0
  118. package/dist/use-area-chart.js.map +1 -0
  119. package/dist/use-area-chart.mjs +10 -0
  120. package/dist/use-area-chart.mjs.map +1 -0
  121. package/dist/use-bar-chart.d.mts +68 -0
  122. package/dist/use-bar-chart.d.ts +68 -0
  123. package/dist/use-bar-chart.js +288 -0
  124. package/dist/use-bar-chart.js.map +1 -0
  125. package/dist/use-bar-chart.mjs +10 -0
  126. package/dist/use-bar-chart.mjs.map +1 -0
  127. package/dist/use-chart-axis.d.mts +73 -0
  128. package/dist/use-chart-axis.d.ts +73 -0
  129. package/dist/use-chart-axis.js +227 -0
  130. package/dist/use-chart-axis.js.map +1 -0
  131. package/dist/use-chart-axis.mjs +10 -0
  132. package/dist/use-chart-axis.mjs.map +1 -0
  133. package/dist/use-chart-grid.d.mts +32 -0
  134. package/dist/use-chart-grid.d.ts +32 -0
  135. package/dist/use-chart-grid.js +92 -0
  136. package/dist/use-chart-grid.js.map +1 -0
  137. package/dist/use-chart-grid.mjs +10 -0
  138. package/dist/use-chart-grid.mjs.map +1 -0
  139. package/dist/use-chart-legend.d.mts +18 -0
  140. package/dist/use-chart-legend.d.ts +18 -0
  141. package/dist/use-chart-legend.js +81 -0
  142. package/dist/use-chart-legend.js.map +1 -0
  143. package/dist/use-chart-legend.mjs +9 -0
  144. package/dist/use-chart-legend.mjs.map +1 -0
  145. package/dist/use-chart-reference-line.d.mts +22 -0
  146. package/dist/use-chart-reference-line.d.ts +22 -0
  147. package/dist/use-chart-reference-line.js +105 -0
  148. package/dist/use-chart-reference-line.js.map +1 -0
  149. package/dist/use-chart-reference-line.mjs +10 -0
  150. package/dist/use-chart-reference-line.mjs.map +1 -0
  151. package/dist/use-chart-tooltip.d.mts +35 -0
  152. package/dist/use-chart-tooltip.d.ts +35 -0
  153. package/dist/use-chart-tooltip.js +121 -0
  154. package/dist/use-chart-tooltip.js.map +1 -0
  155. package/dist/use-chart-tooltip.mjs +9 -0
  156. package/dist/use-chart-tooltip.mjs.map +1 -0
  157. package/dist/use-chart.d.mts +33 -0
  158. package/dist/use-chart.d.ts +33 -0
  159. package/dist/use-chart.js +104 -0
  160. package/dist/use-chart.js.map +1 -0
  161. package/dist/use-chart.mjs +18 -0
  162. package/dist/use-chart.mjs.map +1 -0
  163. package/dist/use-line-chart.d.mts +92 -0
  164. package/dist/use-line-chart.d.ts +92 -0
  165. package/dist/use-line-chart.js +342 -0
  166. package/dist/use-line-chart.js.map +1 -0
  167. package/dist/use-line-chart.mjs +10 -0
  168. package/dist/use-line-chart.mjs.map +1 -0
  169. package/dist/use-radar-chart.d.mts +93 -0
  170. package/dist/use-radar-chart.d.ts +93 -0
  171. package/dist/use-radar-chart.js +471 -0
  172. package/dist/use-radar-chart.js.map +1 -0
  173. package/dist/use-radar-chart.mjs +10 -0
  174. package/dist/use-radar-chart.mjs.map +1 -0
  175. package/package.json +84 -0
@@ -0,0 +1,1249 @@
1
+ "use client"
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/area-chart.tsx
22
+ var area_chart_exports = {};
23
+ __export(area_chart_exports, {
24
+ AreaChart: () => AreaChart
25
+ });
26
+ module.exports = __toCommonJS(area_chart_exports);
27
+ var import_core9 = require("@yamada-ui/core");
28
+ var import_utils11 = require("@yamada-ui/utils");
29
+ var import_react8 = require("react");
30
+ var import_recharts = require("recharts");
31
+
32
+ // src/area-chart-gradient.tsx
33
+ var import_jsx_runtime = require("react/jsx-runtime");
34
+ var AreaGradient = ({
35
+ color,
36
+ id,
37
+ withGradient,
38
+ fillOpacity
39
+ }) => {
40
+ if (withGradient) {
41
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("linearGradient", { id, x1: "0", y1: "0", x2: "0", y2: "1", children: [
42
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", { offset: "0%", stopColor: color, stopOpacity: fillOpacity }),
43
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", { offset: "100%", stopColor: color, stopOpacity: 0.01 })
44
+ ] });
45
+ } else {
46
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("linearGradient", { id, x1: "0", y1: "0", x2: "0", y2: "1", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", { stopColor: color, stopOpacity: fillOpacity }) });
47
+ }
48
+ };
49
+
50
+ // src/area-chart-split.tsx
51
+ var import_jsx_runtime2 = require("react/jsx-runtime");
52
+ var AreaSplit = ({ offset, id, fillOpacity }) => {
53
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("linearGradient", { id, x1: "0", y1: "0", x2: "0", y2: "1", children: [
54
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
55
+ "stop",
56
+ {
57
+ offset,
58
+ stopColor: "var(--ui-area-split-0)",
59
+ stopOpacity: fillOpacity != null ? fillOpacity : 0.4
60
+ }
61
+ ),
62
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
63
+ "stop",
64
+ {
65
+ offset,
66
+ stopColor: "var(--ui-area-split-1)",
67
+ stopOpacity: fillOpacity != null ? fillOpacity : 0.4
68
+ }
69
+ )
70
+ ] });
71
+ };
72
+
73
+ // src/chart-legend.tsx
74
+ var import_core3 = require("@yamada-ui/core");
75
+ var import_utils3 = require("@yamada-ui/utils");
76
+
77
+ // src/use-chart.ts
78
+ var import_core2 = require("@yamada-ui/core");
79
+ var import_utils2 = require("@yamada-ui/utils");
80
+ var import_react = require("react");
81
+
82
+ // src/chart-utils.ts
83
+ var import_core = require("@yamada-ui/core");
84
+ var import_utils = require("@yamada-ui/utils");
85
+ var getClassName = (...styles) => (theme) => (0, import_utils.cx)(
86
+ ...styles.map(
87
+ (style) => (0, import_utils.isString)(style) ? style : (0, import_core.getCSS)(style)(theme)
88
+ )
89
+ );
90
+ var getComponentProps = ([obj, keys], ...props) => (theme, isContain) => {
91
+ const [pickedProps, omittedProps] = (0, import_utils.splitObject)(obj, keys);
92
+ const className = getClassName(...props, omittedProps)(theme);
93
+ return !isContain ? [pickedProps, className] : { ...pickedProps, className };
94
+ };
95
+
96
+ // src/rechart-properties.ts
97
+ var areaChartProperties = [
98
+ "layout",
99
+ "syncId",
100
+ "syncMethod",
101
+ "width",
102
+ "height",
103
+ "data",
104
+ "margin",
105
+ "stackOffset",
106
+ "onClick",
107
+ "onMouseEnter",
108
+ "onMouseMove",
109
+ "onMouseLeave"
110
+ ];
111
+ var referenceLineProperties = [
112
+ "xAxisId",
113
+ "yAxisId",
114
+ "x",
115
+ "y",
116
+ "ifOverflow",
117
+ "viewBox",
118
+ "xAxis",
119
+ "yAxis",
120
+ "label",
121
+ "isFront",
122
+ "strokeWidth",
123
+ "segment"
124
+ ];
125
+ var containerProperties = [
126
+ "aspect",
127
+ "width",
128
+ "height",
129
+ "minWidth",
130
+ "minHeight",
131
+ "debounce",
132
+ "onResize"
133
+ ];
134
+ var gridProperties = [
135
+ "x",
136
+ "y",
137
+ "width",
138
+ "height",
139
+ "horizontal",
140
+ "vertical",
141
+ "horizontalPoints",
142
+ "horizontalCoordinatesGenerator",
143
+ "verticalPoints",
144
+ "verticalCoordinatesGenerator",
145
+ "fill",
146
+ "fillOpacity",
147
+ "strokeDasharray"
148
+ ];
149
+ var xAxisProperties = [
150
+ "hide",
151
+ "dataKey",
152
+ "xAxisId",
153
+ "width",
154
+ "height",
155
+ "orientation",
156
+ "type",
157
+ "allowDecimals",
158
+ "allowDataOverflow",
159
+ "allowDuplicatedCategory",
160
+ "angle",
161
+ "tickCount",
162
+ "domain",
163
+ "includeHidden",
164
+ "interval",
165
+ "padding",
166
+ "minTickGap",
167
+ "axisLine",
168
+ "tickLine",
169
+ "tickSize",
170
+ "tickFormatter",
171
+ "ticks",
172
+ "tick",
173
+ "mirror",
174
+ "reversed",
175
+ "label",
176
+ "scale",
177
+ "unit",
178
+ "name",
179
+ "onClick",
180
+ "onMouseDown",
181
+ "onMouseUp",
182
+ "onMouseMove",
183
+ "onMouseOver",
184
+ "onMouseOut",
185
+ "onMouseEnter",
186
+ "onMouseLeave",
187
+ "tickMargin"
188
+ ];
189
+ var yAxisProperties = [
190
+ "hide",
191
+ "dataKey",
192
+ "yAxisId",
193
+ "width",
194
+ "height",
195
+ "orientation",
196
+ "type",
197
+ "tickCount",
198
+ "domain",
199
+ "includeHidden",
200
+ "interval",
201
+ "padding",
202
+ "minTickGap",
203
+ "allowDecimals",
204
+ "allowDataOverflow",
205
+ "allowDuplicatedCategory",
206
+ "axisLine",
207
+ "tickLine",
208
+ "tickSize",
209
+ "tickFormatter",
210
+ "ticks",
211
+ "tick",
212
+ "mirror",
213
+ "reversed",
214
+ "label",
215
+ "scale",
216
+ "unit",
217
+ "name",
218
+ "onClick",
219
+ "onMouseDown",
220
+ "onMouseUp",
221
+ "onMouseMove",
222
+ "onMouseOver",
223
+ "onMouseOut",
224
+ "onMouseEnter",
225
+ "onMouseLeave",
226
+ "tickMargin"
227
+ ];
228
+ var legendProperties = [
229
+ "width",
230
+ "height",
231
+ "layout",
232
+ "align",
233
+ "verticalAlign",
234
+ "iconSize",
235
+ "iconType",
236
+ "payload",
237
+ "chartWidth",
238
+ "chartHeight",
239
+ "margin",
240
+ "content",
241
+ "formatter",
242
+ "wrapperStyle",
243
+ "onClick",
244
+ "onMouseDown",
245
+ "onMouseUp",
246
+ "onMouseMove",
247
+ "onMouseOver",
248
+ "onMouseOut",
249
+ "onMouseEnter",
250
+ "onMouseLeave"
251
+ ];
252
+ var tooltipProperties = [
253
+ "offset",
254
+ "filterNull",
255
+ "itemStyle",
256
+ "wrapperStyle",
257
+ "contentStyle",
258
+ "labelStyle",
259
+ "cursor",
260
+ "viewBox",
261
+ "allowEscapeViewBox",
262
+ "active",
263
+ "position",
264
+ "coordinate",
265
+ "payload",
266
+ "label",
267
+ "content",
268
+ "formatter",
269
+ "labelFormatter",
270
+ "itemSorter",
271
+ "isAnimationActive",
272
+ "animationDuration",
273
+ "animationEasing"
274
+ ];
275
+ var areaProperties = [
276
+ "type",
277
+ "dataKey",
278
+ "xAxisId",
279
+ "yAxisId",
280
+ "legendType",
281
+ "dot",
282
+ "activeDot",
283
+ "label",
284
+ "stroke",
285
+ "strokeWidth",
286
+ "layout",
287
+ "baseLine",
288
+ "points",
289
+ "stackId",
290
+ "connectNulls",
291
+ "unit",
292
+ "name",
293
+ "isAnimationActive",
294
+ "animationBegin",
295
+ "animationDuration",
296
+ "animationEasing",
297
+ "id",
298
+ "onAnimationStart",
299
+ "onAnimationEnd",
300
+ "onClick",
301
+ "onMouseDown",
302
+ "onMouseUp",
303
+ "onMouseMove",
304
+ "onMouseOver",
305
+ "onMouseOut",
306
+ "onMouseEnter",
307
+ "onMouseLeave"
308
+ ];
309
+ var dotProperties = [
310
+ "cx",
311
+ "cy",
312
+ "r",
313
+ "onClick",
314
+ "onMouseDown",
315
+ "onMouseUp",
316
+ "onMouseMove",
317
+ "onMouseOver",
318
+ "onMouseOut",
319
+ "onMouseEnter",
320
+ "onMouseLeave"
321
+ ];
322
+
323
+ // src/use-chart.ts
324
+ var [ChartProvider, useChartContext] = (0, import_utils2.createContext)({
325
+ name: "ChartContext",
326
+ errorMessage: `useChartContext returned is 'undefined'. Seems you forgot to wrap the components in "<LineChart />" or "<BarChart />" etc.`
327
+ });
328
+ var useChart = ({ containerProps = {} }) => {
329
+ const { theme } = (0, import_core2.useTheme)();
330
+ const [reChartsProps, propClassName] = getComponentProps([
331
+ containerProps,
332
+ containerProperties
333
+ ])(theme);
334
+ const getContainerProps = (0, import_react.useCallback)(
335
+ ({ className, ...props } = {}, ref = null) => ({
336
+ ref,
337
+ className: (0, import_utils2.cx)("ui-chart__container", className, propClassName),
338
+ ...props,
339
+ ...reChartsProps
340
+ }),
341
+ [propClassName, reChartsProps]
342
+ );
343
+ return {
344
+ getContainerProps
345
+ };
346
+ };
347
+ var useLegend = ({} = {}) => {
348
+ const { styles } = useChartContext();
349
+ return {
350
+ styles
351
+ };
352
+ };
353
+ var useTooltip = ({} = {}) => {
354
+ const { styles } = useChartContext();
355
+ return {
356
+ styles
357
+ };
358
+ };
359
+
360
+ // src/chart-legend.tsx
361
+ var import_jsx_runtime3 = require("react/jsx-runtime");
362
+ var ChartLegend = (0, import_core3.forwardRef)(
363
+ ({ className, payload = [], onHighlight, ...rest }, ref) => {
364
+ const { styles } = useLegend();
365
+ const items = payload.map(({ dataKey, color }, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
366
+ import_core3.ui.div,
367
+ {
368
+ className: "ui-chart__legend-item",
369
+ onMouseEnter: () => onHighlight(dataKey),
370
+ onMouseLeave: () => onHighlight(null),
371
+ __css: styles.legendItem,
372
+ children: [
373
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
374
+ import_core3.ui.div,
375
+ {
376
+ className: "ui-chart__legend-swatch",
377
+ background: color,
378
+ __css: styles.legendSwatch
379
+ }
380
+ ),
381
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.span, { className: "ui-chart__legend-label", children: dataKey })
382
+ ]
383
+ },
384
+ `legend-${index}`
385
+ ));
386
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
387
+ import_core3.ui.div,
388
+ {
389
+ ref,
390
+ className: (0, import_utils3.cx)("ui-chart__legend", className),
391
+ __css: styles.legend,
392
+ ...rest,
393
+ children: items
394
+ }
395
+ );
396
+ }
397
+ );
398
+
399
+ // src/chart-tooltip.tsx
400
+ var import_core4 = require("@yamada-ui/core");
401
+ var import_utils4 = require("@yamada-ui/utils");
402
+ var import_jsx_runtime4 = require("react/jsx-runtime");
403
+ var ChartTooltip = (0, import_core4.forwardRef)(
404
+ ({ label, className, payload = [], valueFormatter, unit, ...rest }, ref) => {
405
+ const { styles } = useTooltip();
406
+ const items = payload.map(
407
+ ({ color, name, value: valueProp } = {}, index) => {
408
+ var _a;
409
+ let value;
410
+ if ((0, import_utils4.isArray)(valueProp)) {
411
+ value = valueProp.map((value2) => {
412
+ var _a2;
413
+ return `${(_a2 = valueFormatter == null ? void 0 : valueFormatter(value2)) != null ? _a2 : value2}`;
414
+ }).join(" - ");
415
+ } else {
416
+ value = (_a = valueFormatter == null ? void 0 : valueFormatter(valueProp)) != null ? _a : valueProp;
417
+ }
418
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
419
+ import_core4.ui.div,
420
+ {
421
+ className: "ui-chart__tooltip-item",
422
+ __css: styles.tooltipItem,
423
+ children: [
424
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
425
+ import_core4.ui.div,
426
+ {
427
+ className: "ui-chart__tooltip-swatch",
428
+ background: color,
429
+ __css: styles.tooltipSwatch
430
+ }
431
+ ),
432
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
433
+ import_core4.ui.span,
434
+ {
435
+ className: "ui-chart__tooltip-label",
436
+ __css: styles.tooltipLabel,
437
+ children: name
438
+ }
439
+ ),
440
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
441
+ import_core4.ui.span,
442
+ {
443
+ className: "ui-chart__tooltip-value",
444
+ __css: styles.tooltipValue,
445
+ children: [
446
+ value,
447
+ unit ? unit : ""
448
+ ]
449
+ }
450
+ )
451
+ ]
452
+ },
453
+ `tooltip-payload-${index}`
454
+ );
455
+ }
456
+ );
457
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
458
+ import_core4.ui.div,
459
+ {
460
+ ref,
461
+ className: (0, import_utils4.cx)("ui-chart__tooltip", className),
462
+ __css: styles.tooltip,
463
+ ...rest,
464
+ children: [
465
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core4.ui.p, { className: "ui-chart__tooltip-title", __css: styles.tooltipTitle, children: label }),
466
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core4.ui.div, { className: "ui-chart__tooltip-list", __css: styles.tooltipList, children: items })
467
+ ]
468
+ }
469
+ );
470
+ }
471
+ );
472
+
473
+ // src/use-area-chart.ts
474
+ var import_core5 = require("@yamada-ui/core");
475
+ var import_utils5 = require("@yamada-ui/utils");
476
+ var import_react2 = require("react");
477
+ var useAreaChart = ({
478
+ data,
479
+ series,
480
+ type,
481
+ layoutType = "horizontal",
482
+ withGradient: withGradientProp,
483
+ withDots = true,
484
+ withActiveDots = true,
485
+ curveType = "monotone",
486
+ strokeWidth = 2,
487
+ connectNulls = true,
488
+ fillOpacity = 0.4,
489
+ splitColors = ["#ee6a5d", "#5fce7d"],
490
+ splitOffset,
491
+ referenceLineProps,
492
+ styles,
493
+ ...rest
494
+ }) => {
495
+ var _a;
496
+ const uuid = (0, import_react2.useId)();
497
+ const { theme } = (0, import_core5.useTheme)();
498
+ const [highlightedArea, setHighlightedArea] = (0, import_react2.useState)(null);
499
+ const splitId = `${uuid}-split`;
500
+ const stacked = type === "stacked" || type === "percent";
501
+ const withGradient = typeof withGradientProp === "boolean" ? withGradientProp : type === "default";
502
+ const shouldHighlight = highlightedArea !== null;
503
+ const {
504
+ dot = {},
505
+ activeDot = {},
506
+ dimDot,
507
+ dimArea,
508
+ ...computedAreaProps
509
+ } = (_a = rest.areaProps) != null ? _a : {};
510
+ const areaColors = (0, import_react2.useMemo)(
511
+ () => series.map(({ color }, index) => ({
512
+ __prefix: "ui",
513
+ name: `area-${index}`,
514
+ token: "colors",
515
+ value: color != null ? color : "transparent"
516
+ })),
517
+ [series]
518
+ );
519
+ const areaSplitColors = (0, import_react2.useMemo)(
520
+ () => splitColors.map((color, index) => ({
521
+ __prefix: "ui",
522
+ name: `area-split-${index}`,
523
+ token: "colors",
524
+ value: color != null ? color : "transparent"
525
+ })),
526
+ [splitColors]
527
+ );
528
+ const referenceLineColors = (0, import_react2.useMemo)(
529
+ () => referenceLineProps ? referenceLineProps.map(({ color }, index) => ({
530
+ __prefix: "ui",
531
+ name: `reference-line-${index}`,
532
+ token: "colors",
533
+ value: color != null ? color : "transparent"
534
+ })) : [],
535
+ [referenceLineProps]
536
+ );
537
+ const areaVars = (0, import_react2.useMemo)(() => {
538
+ return [
539
+ ...areaColors,
540
+ ...areaSplitColors,
541
+ ...referenceLineColors,
542
+ { __prefix: "ui", name: "fill-opacity", value: fillOpacity }
543
+ ];
544
+ }, [areaColors, areaSplitColors, referenceLineColors, fillOpacity]);
545
+ const [areaChartProps, areaChartClassName] = (0, import_react2.useMemo)(
546
+ () => {
547
+ var _a2;
548
+ return getComponentProps(
549
+ [(_a2 = rest.areaChartProps) != null ? _a2 : {}, areaChartProperties],
550
+ styles.chart
551
+ )(theme);
552
+ },
553
+ [rest.areaChartProps, styles.chart, theme]
554
+ );
555
+ const [areaProps, areaClassName] = (0, import_react2.useMemo)(() => {
556
+ const resolvedAreaProps = {
557
+ fillOpacity: 1,
558
+ strokeOpacity: 1,
559
+ ...computedAreaProps
560
+ };
561
+ return getComponentProps(
562
+ [resolvedAreaProps, areaProperties],
563
+ styles.area
564
+ )(theme);
565
+ }, [computedAreaProps, styles.area, theme]);
566
+ const [dimAreaProps, dimAreaClassName] = (0, import_react2.useMemo)(() => {
567
+ const resolvedDimArea = {
568
+ fillOpacity: 0,
569
+ strokeOpacity: 0.3,
570
+ ...dimArea
571
+ };
572
+ return getComponentProps([resolvedDimArea, areaProperties])(
573
+ theme
574
+ );
575
+ }, [dimArea, theme]);
576
+ const [dotProps, dotClassName] = (0, import_react2.useMemo)(() => {
577
+ const resolvedDot = { fillOpacity: 1, strokeWidth: 2, ...dot };
578
+ return getComponentProps(
579
+ [resolvedDot, dotProperties],
580
+ styles.dot
581
+ )(theme);
582
+ }, [dot, styles.dot, theme]);
583
+ const [activeDotProps, activeDotClassName] = (0, import_react2.useMemo)(
584
+ () => getComponentProps(
585
+ [activeDot, dotProperties],
586
+ styles.activeDot
587
+ )(theme),
588
+ [activeDot, styles.activeDot, theme]
589
+ );
590
+ const [dimDotProps, dimDotClassName] = (0, import_react2.useMemo)(() => {
591
+ const resolvedDimDot = { fillOpacity: 0, strokeOpacity: 0, ...dimDot };
592
+ return getComponentProps([resolvedDimDot, dotProperties])(
593
+ theme
594
+ );
595
+ }, [dimDot, theme]);
596
+ const defaultSplitOffset = (0, import_react2.useMemo)(() => {
597
+ if (series.length === 1) {
598
+ const dataKey = series[0].dataKey;
599
+ const dataMax = Math.max(...data.map((item) => item[dataKey]));
600
+ const dataMin = Math.min(...data.map((item) => item[dataKey]));
601
+ if (dataMax <= 0)
602
+ return 0;
603
+ if (dataMin >= 0)
604
+ return 1;
605
+ return dataMax / (dataMax - dataMin);
606
+ }
607
+ return 0.5;
608
+ }, [data, series]);
609
+ const areaPropsList = (0, import_react2.useMemo)(
610
+ () => series.map((props, index) => {
611
+ const {
612
+ dataKey,
613
+ dot: dot2 = {},
614
+ activeDot: activeDot2 = {},
615
+ dimDot: dimDot2 = {},
616
+ dimArea: dimArea2 = {},
617
+ strokeDasharray,
618
+ ...computedProps
619
+ } = props;
620
+ const id = `${uuid}-${dataKey}`;
621
+ const color = `var(--ui-area-${index})`;
622
+ const dimmed = shouldHighlight && highlightedArea !== dataKey;
623
+ const computedDimArea = { ...dimAreaProps, ...dimArea2 };
624
+ const resolvedProps = {
625
+ ...areaProps,
626
+ ...computedProps,
627
+ ...dimmed ? computedDimArea : {}
628
+ };
629
+ const rest2 = getComponentProps(
630
+ [resolvedProps, areaProperties],
631
+ areaClassName,
632
+ dimmed ? dimAreaClassName : void 0
633
+ )(theme, true);
634
+ let resolvedActiveDot;
635
+ if (withActiveDots) {
636
+ const computedActiveDot = { ...activeDotProps, ...activeDot2 };
637
+ const [rest3, className] = getComponentProps(
638
+ [computedActiveDot, dotProperties],
639
+ activeDotClassName
640
+ )(theme);
641
+ resolvedActiveDot = {
642
+ className: (0, import_utils5.cx)("ui-area-chart__active-dot", className),
643
+ stroke: color,
644
+ r: 4,
645
+ ...rest3
646
+ };
647
+ } else {
648
+ resolvedActiveDot = false;
649
+ }
650
+ let resolvedDot;
651
+ if (withDots) {
652
+ const computedDimDot = { ...dimDotProps, ...dimDot2 };
653
+ const computedDot = {
654
+ ...dotProps,
655
+ ...dot2,
656
+ ...dimmed ? computedDimDot : {}
657
+ };
658
+ const [rest3, className] = getComponentProps(
659
+ [computedDot, dotProperties],
660
+ dotClassName,
661
+ dimmed ? dimDotClassName : void 0
662
+ )(theme);
663
+ resolvedDot = {
664
+ className: (0, import_utils5.cx)("ui-area-chart__dot", className),
665
+ fill: color,
666
+ r: 4,
667
+ ...rest3
668
+ };
669
+ } else {
670
+ resolvedDot = false;
671
+ }
672
+ return {
673
+ ...rest2,
674
+ id,
675
+ color,
676
+ strokeDasharray,
677
+ dataKey,
678
+ activeDot: resolvedActiveDot,
679
+ dot: resolvedDot
680
+ };
681
+ }),
682
+ [
683
+ series,
684
+ uuid,
685
+ shouldHighlight,
686
+ highlightedArea,
687
+ dimAreaProps,
688
+ dimDotProps,
689
+ areaProps,
690
+ areaClassName,
691
+ dimAreaClassName,
692
+ theme,
693
+ withActiveDots,
694
+ withDots,
695
+ activeDotProps,
696
+ activeDotClassName,
697
+ dotProps,
698
+ dotClassName,
699
+ dimDotClassName
700
+ ]
701
+ );
702
+ const getAreaChartProps = (0, import_react2.useCallback)(
703
+ ({ className, ...props } = {}, ref = null) => ({
704
+ ref,
705
+ className: (0, import_utils5.cx)(className, areaChartClassName),
706
+ data,
707
+ stackOffset: type === "percent" ? "expand" : void 0,
708
+ layout: layoutType,
709
+ ...props,
710
+ ...areaChartProps
711
+ }),
712
+ [areaChartClassName, data, type, layoutType, areaChartProps]
713
+ );
714
+ const getAreaSplitProps = (0, import_react2.useCallback)(
715
+ (props = {}) => ({
716
+ id: splitId,
717
+ offset: splitOffset != null ? splitOffset : defaultSplitOffset,
718
+ fillOpacity: "var(--ui-fill-opacity)",
719
+ ...props
720
+ }),
721
+ [defaultSplitOffset, splitId, splitOffset]
722
+ );
723
+ const getAreaProps = (0, import_react2.useCallback)(
724
+ ({ index, className: classNameProp, ...props }, ref = null) => {
725
+ const {
726
+ id,
727
+ color,
728
+ className,
729
+ dataKey,
730
+ strokeDasharray,
731
+ activeDot: activeDot2,
732
+ dot: dot2,
733
+ ...rest2
734
+ } = areaPropsList[index];
735
+ return {
736
+ ref,
737
+ className: (0, import_utils5.cx)(classNameProp, className),
738
+ id,
739
+ activeDot: activeDot2,
740
+ dot: dot2,
741
+ name: dataKey,
742
+ type: curveType,
743
+ dataKey,
744
+ fill: type === "split" ? `url(#${splitId})` : `url(#${id})`,
745
+ strokeWidth,
746
+ stroke: color,
747
+ isAnimationActive: false,
748
+ connectNulls,
749
+ stackId: stacked ? "stack" : void 0,
750
+ strokeDasharray,
751
+ ...props,
752
+ ...rest2
753
+ };
754
+ },
755
+ [
756
+ areaPropsList,
757
+ connectNulls,
758
+ curveType,
759
+ splitId,
760
+ stacked,
761
+ strokeWidth,
762
+ type
763
+ ]
764
+ );
765
+ const getAreaGradientProps = (0, import_react2.useCallback)(
766
+ (props = {}) => ({
767
+ withGradient,
768
+ fillOpacity: "var(--ui-fill-opacity)",
769
+ ...props
770
+ }),
771
+ [withGradient]
772
+ );
773
+ return {
774
+ getAreaChartProps,
775
+ getAreaSplitProps,
776
+ getAreaProps,
777
+ getAreaGradientProps,
778
+ areaVars,
779
+ setHighlightedArea
780
+ };
781
+ };
782
+
783
+ // src/use-chart-axis.ts
784
+ var import_core6 = require("@yamada-ui/core");
785
+ var import_utils6 = require("@yamada-ui/utils");
786
+ var import_react3 = require("react");
787
+ var useChartAxis = ({
788
+ dataKey,
789
+ type,
790
+ layoutType = "horizontal",
791
+ tickLine = "y",
792
+ gridAxis = "x",
793
+ withXAxis = true,
794
+ withYAxis = true,
795
+ xAxisProps: _xAxisProps = {},
796
+ yAxisProps: _yAxisProps = {},
797
+ unit,
798
+ valueFormatter,
799
+ styles
800
+ }) => {
801
+ const { theme } = (0, import_core6.useTheme)();
802
+ const xAxisKey = (0, import_react3.useMemo)(
803
+ () => layoutType === "vertical" ? { type: "number" } : { dataKey },
804
+ [dataKey, layoutType]
805
+ );
806
+ const yAxisKey = (0, import_react3.useMemo)(
807
+ () => layoutType === "vertical" ? { dataKey, type: "category" } : { type: "number" },
808
+ [dataKey, layoutType]
809
+ );
810
+ const withXTickLine = gridAxis !== "none" && (tickLine === "x" || tickLine === "xy");
811
+ const withYTickLine = gridAxis !== "none" && (tickLine === "y" || tickLine === "xy");
812
+ const getTickLine = (withTickLine) => withTickLine ? { stroke: "currentColor" } : false;
813
+ const xTickLine = getTickLine(withXTickLine);
814
+ const yTickLine = getTickLine(withYTickLine);
815
+ const yAxisTickFormatter = type === "percent" && layoutType !== "vertical" ? valueToPercent : valueFormatter;
816
+ const xAxisTickFormatter = type === "percent" && layoutType === "vertical" ? valueToPercent : valueFormatter;
817
+ const [xAxisReChartsProps, xAxisClassName] = getComponentProps(
818
+ [_xAxisProps, xAxisProperties],
819
+ styles.xAxis
820
+ )(theme);
821
+ const [yAxisReChartsProps, yAxisClassName] = getComponentProps(
822
+ [_yAxisProps, yAxisProperties],
823
+ styles.yAxis
824
+ )(theme);
825
+ const getXAxisProps = (0, import_react3.useCallback)(
826
+ ({ className, ...props } = {}) => ({
827
+ className: (0, import_utils6.cx)(className, xAxisClassName),
828
+ hide: !withXAxis,
829
+ ...xAxisKey,
830
+ tick: {
831
+ transform: "translate(0, 10)",
832
+ fill: "currentColor"
833
+ },
834
+ stroke: "",
835
+ interval: "preserveStartEnd",
836
+ tickLine: xTickLine,
837
+ minTickGap: 5,
838
+ tickFormatter: xAxisTickFormatter,
839
+ ...props,
840
+ ...xAxisReChartsProps
841
+ }),
842
+ [
843
+ xAxisClassName,
844
+ withXAxis,
845
+ xAxisKey,
846
+ xTickLine,
847
+ xAxisTickFormatter,
848
+ xAxisReChartsProps
849
+ ]
850
+ );
851
+ const getYAxisProps = (0, import_react3.useCallback)(
852
+ ({ className, ...props } = {}) => ({
853
+ className: (0, import_utils6.cx)(className, yAxisClassName),
854
+ hide: !withYAxis,
855
+ axisLine: false,
856
+ ...yAxisKey,
857
+ tickLine: yTickLine,
858
+ tick: {
859
+ transform: "translate(-10, 0)",
860
+ fill: "currentColor"
861
+ },
862
+ allowDecimals: true,
863
+ unit,
864
+ tickFormatter: yAxisTickFormatter,
865
+ ...props,
866
+ ...yAxisReChartsProps
867
+ }),
868
+ [
869
+ yAxisClassName,
870
+ withYAxis,
871
+ yAxisKey,
872
+ yTickLine,
873
+ unit,
874
+ yAxisTickFormatter,
875
+ yAxisReChartsProps
876
+ ]
877
+ );
878
+ return { getXAxisProps, getYAxisProps };
879
+ };
880
+ var valueToPercent = (value) => {
881
+ return `${(value * 100).toFixed(0)}%`;
882
+ };
883
+
884
+ // src/use-chart-grid.ts
885
+ var import_core7 = require("@yamada-ui/core");
886
+ var import_utils7 = require("@yamada-ui/utils");
887
+ var import_react4 = require("react");
888
+ var useChartGrid = ({
889
+ gridProps = {},
890
+ gridAxis = "x",
891
+ strokeDasharray = "5 5",
892
+ styles
893
+ }) => {
894
+ const { theme } = (0, import_core7.useTheme)();
895
+ const [reChartsProps, propClassName] = getComponentProps(
896
+ [gridProps, gridProperties],
897
+ styles.grid
898
+ )(theme);
899
+ const getGridProps = (0, import_react4.useCallback)(
900
+ ({ className, ...props } = {}, ref = null) => ({
901
+ ref,
902
+ className: (0, import_utils7.cx)("ui-chart__grid", className, propClassName),
903
+ strokeDasharray,
904
+ vertical: gridAxis === "y" || gridAxis === "xy",
905
+ horizontal: gridAxis === "x" || gridAxis === "xy",
906
+ ...props,
907
+ ...reChartsProps
908
+ }),
909
+ [propClassName, strokeDasharray, gridAxis, reChartsProps]
910
+ );
911
+ return { getGridProps };
912
+ };
913
+
914
+ // src/use-chart-legend.ts
915
+ var import_utils8 = require("@yamada-ui/utils");
916
+ var import_react5 = require("react");
917
+ var useChartLegend = ({
918
+ legendProps: _legendProps = {}
919
+ }) => {
920
+ const [rest, legendProps] = (0, import_utils8.splitObject)(
921
+ _legendProps,
922
+ legendProperties
923
+ );
924
+ const getLegendProps = (0, import_react5.useCallback)(
925
+ (props, ref = null) => {
926
+ return {
927
+ ref,
928
+ verticalAlign: "top",
929
+ ...props,
930
+ ...rest
931
+ };
932
+ },
933
+ [rest]
934
+ );
935
+ return { legendProps, getLegendProps };
936
+ };
937
+
938
+ // src/use-chart-reference-line.ts
939
+ var import_core8 = require("@yamada-ui/core");
940
+ var import_utils9 = require("@yamada-ui/utils");
941
+ var import_react6 = require("react");
942
+ var useChartReferenceLine = ({
943
+ referenceLineProps = [],
944
+ styles
945
+ }) => {
946
+ const { theme } = (0, import_core8.useTheme)();
947
+ const styleClassName = (0, import_core8.getCSS)(styles.referenceLine)(theme);
948
+ const propList = (0, import_react6.useMemo)(
949
+ () => referenceLineProps.map((props, index) => {
950
+ const [{ label: labelProp, ...rest }, propClassName] = getComponentProps(
951
+ [props, referenceLineProperties],
952
+ styleClassName
953
+ )(theme);
954
+ const color = `var(--ui-reference-line-${index})`;
955
+ const label = {
956
+ value: labelProp,
957
+ fill: color,
958
+ position: "insideBottomLeft",
959
+ ...(0, import_utils9.isObject)(labelProp) ? labelProp : {}
960
+ };
961
+ return { propClassName, color, label, ...rest };
962
+ }),
963
+ [referenceLineProps, styleClassName, theme]
964
+ );
965
+ const getReferenceLineProps = (0, import_react6.useCallback)(
966
+ ({ index, className, ...props }, ref = null) => {
967
+ const { propClassName, color, label, ...rest } = propList[index];
968
+ return {
969
+ ref,
970
+ className: (0, import_utils9.cx)(className, propClassName),
971
+ stroke: color,
972
+ label,
973
+ ...props,
974
+ ...rest
975
+ };
976
+ },
977
+ [propList]
978
+ );
979
+ return { getReferenceLineProps };
980
+ };
981
+
982
+ // src/use-chart-tooltip.ts
983
+ var import_utils10 = require("@yamada-ui/utils");
984
+ var import_react7 = require("react");
985
+ var useChartTooltip = ({
986
+ tooltipProps: _tooltipProps = {},
987
+ tooltipAnimationDuration = 0,
988
+ styles
989
+ }) => {
990
+ const { cursor, ...rest } = _tooltipProps;
991
+ const resolvedCursor = (0, import_react7.useMemo)(
992
+ () => ({ ...styles.cursor, ...cursor }),
993
+ [cursor, styles]
994
+ );
995
+ const tooltipVars = (0, import_react7.useMemo)(
996
+ () => [
997
+ {
998
+ __prefix: "ui",
999
+ name: "cursor-fill",
1000
+ token: "colors",
1001
+ value: resolvedCursor.fill
1002
+ },
1003
+ {
1004
+ __prefix: "ui",
1005
+ name: "cursor-stroke",
1006
+ token: "colors",
1007
+ value: resolvedCursor.stroke
1008
+ },
1009
+ {
1010
+ __prefix: "ui",
1011
+ name: "cursor-stroke-width",
1012
+ token: "colors",
1013
+ value: resolvedCursor.strokeWidth
1014
+ },
1015
+ {
1016
+ __prefix: "ui",
1017
+ name: "cursor-stroke-dasharray",
1018
+ token: "colors",
1019
+ value: resolvedCursor.strokeDasharray
1020
+ }
1021
+ ],
1022
+ [resolvedCursor]
1023
+ );
1024
+ const [tooltipProps, tooltipUIProps] = (0, import_utils10.splitObject)(
1025
+ rest,
1026
+ tooltipProperties
1027
+ );
1028
+ const getTooltipProps = (0, import_react7.useCallback)(
1029
+ (props, ref = null) => ({
1030
+ ref,
1031
+ animationDuration: tooltipAnimationDuration,
1032
+ isAnimationActive: (tooltipAnimationDuration || 0) > 0,
1033
+ cursor: {
1034
+ fill: "var(--ui-cursor-fill)",
1035
+ stroke: "var(--ui-cursor-stroke)",
1036
+ strokeWidth: "var(--ui-cursor-stroke-width)",
1037
+ strokeDasharray: "var(--ui-cursor-stroke-dasharray)"
1038
+ },
1039
+ ...props,
1040
+ ...tooltipProps
1041
+ }),
1042
+ [tooltipAnimationDuration, tooltipProps]
1043
+ );
1044
+ return { tooltipProps: tooltipUIProps, getTooltipProps, tooltipVars };
1045
+ };
1046
+
1047
+ // src/area-chart.tsx
1048
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1049
+ var AreaChart = (0, import_core9.forwardRef)((props, ref) => {
1050
+ const [styles, mergedProps] = (0, import_core9.useMultiComponentStyle)("AreaChart", props);
1051
+ const {
1052
+ className,
1053
+ series,
1054
+ dataKey,
1055
+ layoutType,
1056
+ tickLine,
1057
+ gridAxis,
1058
+ withXAxis,
1059
+ withYAxis,
1060
+ xAxisProps,
1061
+ yAxisProps,
1062
+ type = "default",
1063
+ withTooltip = true,
1064
+ withLegend = false,
1065
+ referenceLineProps = [],
1066
+ containerProps,
1067
+ unit,
1068
+ gridProps,
1069
+ strokeDasharray,
1070
+ valueFormatter,
1071
+ tooltipProps,
1072
+ tooltipAnimationDuration,
1073
+ legendProps,
1074
+ data,
1075
+ areaChartProps,
1076
+ areaProps,
1077
+ withGradient,
1078
+ withDots,
1079
+ withActiveDots,
1080
+ curveType,
1081
+ strokeWidth,
1082
+ connectNulls,
1083
+ fillOpacity,
1084
+ splitColors,
1085
+ splitOffset,
1086
+ ...rest
1087
+ } = (0, import_core9.omitThemeProps)(mergedProps);
1088
+ const {
1089
+ getAreaChartProps,
1090
+ getAreaSplitProps,
1091
+ getAreaProps,
1092
+ getAreaGradientProps,
1093
+ areaVars,
1094
+ setHighlightedArea
1095
+ } = useAreaChart({
1096
+ layoutType,
1097
+ type,
1098
+ series,
1099
+ referenceLineProps,
1100
+ data,
1101
+ areaChartProps,
1102
+ areaProps,
1103
+ withGradient,
1104
+ withDots,
1105
+ withActiveDots,
1106
+ curveType,
1107
+ strokeWidth,
1108
+ connectNulls,
1109
+ fillOpacity,
1110
+ splitColors,
1111
+ splitOffset,
1112
+ styles
1113
+ });
1114
+ const { getContainerProps } = useChart({ containerProps });
1115
+ const { getXAxisProps, getYAxisProps } = useChartAxis({
1116
+ dataKey,
1117
+ type,
1118
+ layoutType,
1119
+ tickLine,
1120
+ gridAxis,
1121
+ withXAxis,
1122
+ withYAxis,
1123
+ xAxisProps,
1124
+ yAxisProps,
1125
+ unit,
1126
+ valueFormatter,
1127
+ styles
1128
+ });
1129
+ const { getReferenceLineProps } = useChartReferenceLine({
1130
+ referenceLineProps,
1131
+ styles
1132
+ });
1133
+ const { getGridProps } = useChartGrid({
1134
+ gridProps,
1135
+ gridAxis,
1136
+ strokeDasharray,
1137
+ styles
1138
+ });
1139
+ const {
1140
+ tooltipProps: computedTooltipProps,
1141
+ getTooltipProps,
1142
+ tooltipVars
1143
+ } = useChartTooltip({
1144
+ tooltipProps,
1145
+ tooltipAnimationDuration,
1146
+ styles
1147
+ });
1148
+ const { legendProps: computedLegendProps, getLegendProps } = useChartLegend({
1149
+ legendProps
1150
+ });
1151
+ const areas = (0, import_react8.useMemo)(
1152
+ () => series.map(({ dataKey: dataKey2 }, index) => {
1153
+ const { id, stroke, ...rest2 } = getAreaProps({
1154
+ index,
1155
+ className: "ui-area-chart__area"
1156
+ });
1157
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react8.Fragment, { children: [
1158
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AreaGradient, { ...getAreaGradientProps({ id, color: stroke }) }) }),
1159
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_recharts.Area, { id, stroke, ...rest2 })
1160
+ ] }, `area-${dataKey2}`);
1161
+ }),
1162
+ [getAreaGradientProps, getAreaProps, series]
1163
+ );
1164
+ const referenceLinesItems = (0, import_react8.useMemo)(
1165
+ () => referenceLineProps.map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1166
+ import_recharts.ReferenceLine,
1167
+ {
1168
+ ...getReferenceLineProps({
1169
+ index,
1170
+ className: "ui-area-chart__reference-line"
1171
+ })
1172
+ },
1173
+ `referenceLine-${index}`
1174
+ )),
1175
+ [getReferenceLineProps, referenceLineProps]
1176
+ );
1177
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ChartProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1178
+ import_core9.ui.div,
1179
+ {
1180
+ ref,
1181
+ className: (0, import_utils11.cx)("ui-area-chart", className),
1182
+ var: [...areaVars, ...tooltipVars],
1183
+ __css: { maxW: "full", ...styles.container },
1184
+ ...rest,
1185
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1186
+ import_recharts.ResponsiveContainer,
1187
+ {
1188
+ ...getContainerProps({ className: "ui-area-chart__container" }),
1189
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1190
+ import_recharts.AreaChart,
1191
+ {
1192
+ ...getAreaChartProps({ className: "ui-area-chart__chart" }),
1193
+ children: [
1194
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1195
+ import_recharts.CartesianGrid,
1196
+ {
1197
+ ...getGridProps({ className: "ui-area-chart__grid" })
1198
+ }
1199
+ ),
1200
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_recharts.XAxis, { ...getXAxisProps({ className: "ui-area-chart__x-axis" }) }),
1201
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_recharts.YAxis, { ...getYAxisProps({ className: "ui-area-chart__y-axis" }) }),
1202
+ withLegend ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1203
+ import_recharts.Legend,
1204
+ {
1205
+ content: ({ payload }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1206
+ ChartLegend,
1207
+ {
1208
+ className: "ui-area-chart__legend",
1209
+ payload,
1210
+ onHighlight: setHighlightedArea,
1211
+ ...computedLegendProps
1212
+ }
1213
+ ),
1214
+ ...getLegendProps()
1215
+ }
1216
+ ) : null,
1217
+ withTooltip ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1218
+ import_recharts.Tooltip,
1219
+ {
1220
+ content: ({ label, payload }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1221
+ ChartTooltip,
1222
+ {
1223
+ className: "ui-area-chart__tooltip",
1224
+ label,
1225
+ payload,
1226
+ valueFormatter,
1227
+ unit,
1228
+ ...computedTooltipProps
1229
+ }
1230
+ ),
1231
+ ...getTooltipProps()
1232
+ }
1233
+ ) : null,
1234
+ type === "split" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AreaSplit, { ...getAreaSplitProps() }) }) : null,
1235
+ areas,
1236
+ referenceLinesItems
1237
+ ]
1238
+ }
1239
+ )
1240
+ }
1241
+ )
1242
+ }
1243
+ ) });
1244
+ });
1245
+ // Annotate the CommonJS export names for ESM import in node:
1246
+ 0 && (module.exports = {
1247
+ AreaChart
1248
+ });
1249
+ //# sourceMappingURL=area-chart.js.map