@object-ui/plugin-charts 4.0.7 → 4.0.8
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/dist/index.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { ComponentRegistry as e,
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import { Skeleton as
|
|
5
|
-
import { Fragment as
|
|
6
|
-
import { Area as
|
|
7
|
-
import { SchemaRendererContext as
|
|
8
|
-
import { AlertCircle as
|
|
9
|
-
import { useSafeFieldLabel as
|
|
1
|
+
import { ComponentRegistry as e, computeDrillFilter as t, extractRecords as n, isDrillEnabled as r, resolveDateMacros as i, resolveDrillTitle as a } from "@object-ui/core";
|
|
2
|
+
import * as o from "react";
|
|
3
|
+
import s, { Suspense as c, useCallback as l, useContext as u, useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
|
|
4
|
+
import { Dialog as h, DialogContent as g, DialogHeader as _, DialogTitle as v, Sheet as ee, SheetContent as te, SheetHeader as ne, SheetTitle as re, Skeleton as y } from "@object-ui/components";
|
|
5
|
+
import { Fragment as ie, jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
6
|
+
import { Area as S, AreaChart as C, Bar as w, BarChart as T, CartesianGrid as E, Cell as D, Funnel as ae, FunnelChart as O, LabelList as k, Legend as A, Line as j, LineChart as M, Pie as N, PieChart as P, PolarAngleAxis as F, PolarGrid as I, PolarRadiusAxis as L, Radar as R, RadarChart as oe, ResponsiveContainer as se, Scatter as ce, ScatterChart as le, Tooltip as ue, XAxis as z, YAxis as B, ZAxis as de } from "recharts";
|
|
7
|
+
import { SchemaRenderer as fe, SchemaRendererContext as pe, useDataScope as me } from "@object-ui/react";
|
|
8
|
+
import { AlertCircle as he } from "lucide-react";
|
|
9
|
+
import { useSafeFieldLabel as ge } from "@object-ui/i18n";
|
|
10
10
|
//#region \0rolldown/runtime.js
|
|
11
|
-
var
|
|
11
|
+
var _e = Object.defineProperty, V = (e, t) => () => (e && (t = e(e = 0)), t), ve = (e, t) => {
|
|
12
12
|
let n = {};
|
|
13
|
-
for (var r in e)
|
|
13
|
+
for (var r in e) _e(n, r, {
|
|
14
14
|
get: e[r],
|
|
15
15
|
enumerable: !0
|
|
16
16
|
});
|
|
17
|
-
return t ||
|
|
18
|
-
},
|
|
19
|
-
function
|
|
20
|
-
return /* @__PURE__ */
|
|
17
|
+
return t || _e(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
18
|
+
}, ye = /* @__PURE__ */ ve({ default: () => be });
|
|
19
|
+
function be({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height: r = 400, className: i = "", color: a = "hsl(var(--primary))" }) {
|
|
20
|
+
return /* @__PURE__ */ b("div", {
|
|
21
21
|
className: `p-2 sm:p-3 md:p-4 rounded-xl border border-border bg-card/40 backdrop-blur-sm shadow-lg shadow-background/5 ${i}`,
|
|
22
|
-
children: /* @__PURE__ */
|
|
22
|
+
children: /* @__PURE__ */ b(se, {
|
|
23
23
|
width: "100%",
|
|
24
24
|
height: r,
|
|
25
|
-
children: /* @__PURE__ */
|
|
25
|
+
children: /* @__PURE__ */ x(T, {
|
|
26
26
|
data: e,
|
|
27
27
|
margin: {
|
|
28
28
|
top: 10,
|
|
@@ -31,64 +31,64 @@ function le({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
|
|
|
31
31
|
bottom: 5
|
|
32
32
|
},
|
|
33
33
|
children: [
|
|
34
|
-
/* @__PURE__ */
|
|
34
|
+
/* @__PURE__ */ x("defs", { children: [/* @__PURE__ */ x("linearGradient", {
|
|
35
35
|
id: "barGradient",
|
|
36
36
|
x1: "0",
|
|
37
37
|
y1: "0",
|
|
38
38
|
x2: "0",
|
|
39
39
|
y2: "1",
|
|
40
40
|
children: [
|
|
41
|
-
/* @__PURE__ */
|
|
41
|
+
/* @__PURE__ */ b("stop", {
|
|
42
42
|
offset: "0%",
|
|
43
43
|
stopColor: a,
|
|
44
44
|
stopOpacity: 1
|
|
45
45
|
}),
|
|
46
|
-
/* @__PURE__ */
|
|
46
|
+
/* @__PURE__ */ b("stop", {
|
|
47
47
|
offset: "90%",
|
|
48
48
|
stopColor: a,
|
|
49
49
|
stopOpacity: .6
|
|
50
50
|
}),
|
|
51
|
-
/* @__PURE__ */
|
|
51
|
+
/* @__PURE__ */ b("stop", {
|
|
52
52
|
offset: "100%",
|
|
53
53
|
stopColor: a,
|
|
54
54
|
stopOpacity: .3
|
|
55
55
|
})
|
|
56
56
|
]
|
|
57
|
-
}), /* @__PURE__ */
|
|
57
|
+
}), /* @__PURE__ */ x("filter", {
|
|
58
58
|
id: "glow",
|
|
59
59
|
height: "130%",
|
|
60
60
|
children: [
|
|
61
|
-
/* @__PURE__ */
|
|
61
|
+
/* @__PURE__ */ b("feGaussianBlur", {
|
|
62
62
|
in: "SourceAlpha",
|
|
63
63
|
stdDeviation: "3",
|
|
64
64
|
result: "blur"
|
|
65
65
|
}),
|
|
66
|
-
/* @__PURE__ */
|
|
66
|
+
/* @__PURE__ */ b("feOffset", {
|
|
67
67
|
in: "blur",
|
|
68
68
|
dx: "0",
|
|
69
69
|
dy: "0",
|
|
70
70
|
result: "offsetBlur"
|
|
71
71
|
}),
|
|
72
|
-
/* @__PURE__ */
|
|
72
|
+
/* @__PURE__ */ b("feFlood", {
|
|
73
73
|
floodColor: a,
|
|
74
74
|
floodOpacity: "0.5",
|
|
75
75
|
result: "offsetColor"
|
|
76
76
|
}),
|
|
77
|
-
/* @__PURE__ */
|
|
77
|
+
/* @__PURE__ */ b("feComposite", {
|
|
78
78
|
in: "offsetColor",
|
|
79
79
|
in2: "offsetBlur",
|
|
80
80
|
operator: "in",
|
|
81
81
|
result: "offsetBlur"
|
|
82
82
|
}),
|
|
83
|
-
/* @__PURE__ */
|
|
83
|
+
/* @__PURE__ */ x("feMerge", { children: [/* @__PURE__ */ b("feMergeNode", { in: "offsetBlur" }), /* @__PURE__ */ b("feMergeNode", { in: "SourceGraphic" })] })
|
|
84
84
|
]
|
|
85
85
|
})] }),
|
|
86
|
-
/* @__PURE__ */
|
|
86
|
+
/* @__PURE__ */ b(E, {
|
|
87
87
|
strokeDasharray: "3 3",
|
|
88
88
|
stroke: "hsl(var(--border))",
|
|
89
89
|
vertical: !1
|
|
90
90
|
}),
|
|
91
|
-
/* @__PURE__ */
|
|
91
|
+
/* @__PURE__ */ b(z, {
|
|
92
92
|
dataKey: n,
|
|
93
93
|
tick: {
|
|
94
94
|
fill: "hsl(var(--muted-foreground))",
|
|
@@ -99,7 +99,7 @@ function le({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
|
|
|
99
99
|
axisLine: { stroke: "hsl(var(--border))" },
|
|
100
100
|
dy: 10
|
|
101
101
|
}),
|
|
102
|
-
/* @__PURE__ */
|
|
102
|
+
/* @__PURE__ */ b(B, {
|
|
103
103
|
tick: {
|
|
104
104
|
fill: "hsl(var(--muted-foreground))",
|
|
105
105
|
fontSize: 12,
|
|
@@ -108,7 +108,7 @@ function le({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
|
|
|
108
108
|
tickLine: !1,
|
|
109
109
|
axisLine: !1
|
|
110
110
|
}),
|
|
111
|
-
/* @__PURE__ */
|
|
111
|
+
/* @__PURE__ */ b(ue, {
|
|
112
112
|
cursor: {
|
|
113
113
|
fill: "hsl(var(--muted))",
|
|
114
114
|
opacity: .2
|
|
@@ -123,11 +123,11 @@ function le({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
|
|
|
123
123
|
},
|
|
124
124
|
itemStyle: { color: "hsl(var(--primary))" }
|
|
125
125
|
}),
|
|
126
|
-
/* @__PURE__ */
|
|
126
|
+
/* @__PURE__ */ b(A, { wrapperStyle: {
|
|
127
127
|
paddingTop: "20px",
|
|
128
128
|
fontFamily: "monospace"
|
|
129
129
|
} }),
|
|
130
|
-
/* @__PURE__ */
|
|
130
|
+
/* @__PURE__ */ b(w, {
|
|
131
131
|
dataKey: t,
|
|
132
132
|
fill: "url(#barGradient)",
|
|
133
133
|
radius: [
|
|
@@ -144,79 +144,79 @@ function le({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
|
|
|
144
144
|
})
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
-
var
|
|
147
|
+
var xe = V((() => {}));
|
|
148
148
|
//#endregion
|
|
149
149
|
//#region src/ChartContainerImpl.tsx
|
|
150
|
-
function
|
|
151
|
-
let e =
|
|
150
|
+
function Se() {
|
|
151
|
+
let e = o.useContext(we);
|
|
152
152
|
if (!e) throw Error("useChart must be used within a <ChartContainer />");
|
|
153
153
|
return e;
|
|
154
154
|
}
|
|
155
|
-
function
|
|
156
|
-
let
|
|
157
|
-
return /* @__PURE__ */
|
|
158
|
-
value: { config:
|
|
159
|
-
children: /* @__PURE__ */
|
|
155
|
+
function H({ id: e, className: t, children: n, config: r, ...i }) {
|
|
156
|
+
let a = o.useId(), s = `chart-${e || a.replace(/:/g, "")}`;
|
|
157
|
+
return /* @__PURE__ */ b(we.Provider, {
|
|
158
|
+
value: { config: r },
|
|
159
|
+
children: /* @__PURE__ */ x("div", {
|
|
160
160
|
"data-slot": "chart",
|
|
161
161
|
"data-chart": s,
|
|
162
|
-
className:
|
|
163
|
-
...
|
|
164
|
-
children: [/* @__PURE__ */
|
|
162
|
+
className: K("flex w-full h-[350px] justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground", t),
|
|
163
|
+
...i,
|
|
164
|
+
children: [/* @__PURE__ */ b(Te, {
|
|
165
165
|
id: s,
|
|
166
|
-
config:
|
|
167
|
-
}), /* @__PURE__ */
|
|
166
|
+
config: r
|
|
167
|
+
}), /* @__PURE__ */ b(se, {
|
|
168
168
|
width: "100%",
|
|
169
169
|
height: "100%",
|
|
170
|
-
children:
|
|
170
|
+
children: n
|
|
171
171
|
})]
|
|
172
172
|
})
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
|
-
function
|
|
176
|
-
let { config:
|
|
177
|
-
if (
|
|
178
|
-
let [e] = t, n =
|
|
179
|
-
return c ? /* @__PURE__ */
|
|
180
|
-
className:
|
|
175
|
+
function U({ active: e, payload: t, className: n, indicator: r = "dot", hideLabel: i = !1, hideIndicator: a = !1, label: s, labelFormatter: c, labelClassName: l, formatter: u, color: d, nameKey: f, labelKey: p }) {
|
|
176
|
+
let { config: m } = Se(), h = o.useMemo(() => {
|
|
177
|
+
if (i || !t?.length) return null;
|
|
178
|
+
let [e] = t, n = G(m, e, `${p || e?.dataKey || e?.name || "value"}`), r = !p && typeof s == "string" ? m[s]?.label || s : n?.label;
|
|
179
|
+
return c ? /* @__PURE__ */ b("div", {
|
|
180
|
+
className: K("font-medium", l),
|
|
181
181
|
children: c(r, t)
|
|
182
|
-
}) : r ? /* @__PURE__ */
|
|
183
|
-
className:
|
|
182
|
+
}) : r ? /* @__PURE__ */ b("div", {
|
|
183
|
+
className: K("font-medium", l),
|
|
184
184
|
children: r
|
|
185
185
|
}) : null;
|
|
186
186
|
}, [
|
|
187
187
|
s,
|
|
188
188
|
c,
|
|
189
189
|
t,
|
|
190
|
-
|
|
190
|
+
i,
|
|
191
191
|
l,
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
m,
|
|
193
|
+
p
|
|
194
194
|
]);
|
|
195
195
|
if (!e || !t?.length) return null;
|
|
196
|
-
let
|
|
197
|
-
return /* @__PURE__ */
|
|
198
|
-
className:
|
|
199
|
-
children: [
|
|
196
|
+
let g = t.length === 1 && r !== "dot";
|
|
197
|
+
return /* @__PURE__ */ x("div", {
|
|
198
|
+
className: K("border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl", n),
|
|
199
|
+
children: [g ? null : h, /* @__PURE__ */ b("div", {
|
|
200
200
|
className: "grid gap-1.5",
|
|
201
201
|
children: t.filter((e) => e.type !== "none").map((e, t) => {
|
|
202
|
-
let n =
|
|
203
|
-
return /* @__PURE__ */
|
|
204
|
-
className:
|
|
205
|
-
children: u && e?.value !== void 0 && e.name ? u(e.value, e.name, e, t, e.payload) : /* @__PURE__ */
|
|
206
|
-
className:
|
|
202
|
+
let n = G(m, e, `${f || e.name || e.dataKey || "value"}`), i = d || e.payload.fill || e.color;
|
|
203
|
+
return /* @__PURE__ */ b("div", {
|
|
204
|
+
className: K("[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5", r === "dot" ? "items-center" : ""),
|
|
205
|
+
children: u && e?.value !== void 0 && e.name ? u(e.value, e.name, e, t, e.payload) : /* @__PURE__ */ x(ie, { children: [n?.icon ? /* @__PURE__ */ b(n.icon, {}) : !a && /* @__PURE__ */ b("div", {
|
|
206
|
+
className: K("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)", r === "dot" ? "h-2.5 w-2.5" : "", r === "line" ? "w-1" : "", r === "dashed" ? "w-0 border-[1.5px] border-dashed bg-transparent" : "", g && r === "dashed" ? "my-0.5" : ""),
|
|
207
207
|
style: {
|
|
208
|
-
"--color-bg":
|
|
209
|
-
"--color-border":
|
|
208
|
+
"--color-bg": i,
|
|
209
|
+
"--color-border": i
|
|
210
210
|
}
|
|
211
|
-
}), /* @__PURE__ */
|
|
212
|
-
className:
|
|
213
|
-
children: [/* @__PURE__ */
|
|
211
|
+
}), /* @__PURE__ */ x("div", {
|
|
212
|
+
className: K("flex flex-1 justify-between leading-none", g ? "items-end" : "items-center"),
|
|
213
|
+
children: [/* @__PURE__ */ x("div", {
|
|
214
214
|
className: "grid gap-1.5",
|
|
215
|
-
children: [
|
|
215
|
+
children: [g ? h : null, /* @__PURE__ */ b("span", {
|
|
216
216
|
className: "text-muted-foreground",
|
|
217
217
|
children: n?.label || e.name
|
|
218
218
|
})]
|
|
219
|
-
}), e.value && /* @__PURE__ */
|
|
219
|
+
}), e.value && /* @__PURE__ */ b("span", {
|
|
220
220
|
className: "text-foreground font-mono font-medium tabular-nums",
|
|
221
221
|
children: e.value.toLocaleString()
|
|
222
222
|
})]
|
|
@@ -226,15 +226,15 @@ function z({ active: e, payload: t, className: r, indicator: i = "dot", hideLabe
|
|
|
226
226
|
})]
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
|
-
function
|
|
230
|
-
let { config: a } =
|
|
231
|
-
return n?.length ? /* @__PURE__ */
|
|
232
|
-
className:
|
|
229
|
+
function W({ className: e, hideIcon: t = !1, payload: n, verticalAlign: r = "bottom", nameKey: i }) {
|
|
230
|
+
let { config: a } = Se();
|
|
231
|
+
return n?.length ? /* @__PURE__ */ b("div", {
|
|
232
|
+
className: K("flex items-center justify-center gap-4", r === "top" ? "pb-3" : "pt-3", e),
|
|
233
233
|
children: n.filter((e) => e.type !== "none").map((e) => {
|
|
234
|
-
let n =
|
|
235
|
-
return /* @__PURE__ */
|
|
236
|
-
className:
|
|
237
|
-
children: [n?.icon && !t ? /* @__PURE__ */
|
|
234
|
+
let n = G(a, e, `${i || e.dataKey || "value"}`);
|
|
235
|
+
return /* @__PURE__ */ x("div", {
|
|
236
|
+
className: K("[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"),
|
|
237
|
+
children: [n?.icon && !t ? /* @__PURE__ */ b(n.icon, {}) : /* @__PURE__ */ b("div", {
|
|
238
238
|
className: "h-2 w-2 shrink-0 rounded-[2px]",
|
|
239
239
|
style: { backgroundColor: e.color }
|
|
240
240
|
}), n?.label]
|
|
@@ -242,18 +242,18 @@ function B({ className: e, hideIcon: t = !1, payload: n, verticalAlign: r = "bot
|
|
|
242
242
|
})
|
|
243
243
|
}) : null;
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function G(e, t, n) {
|
|
246
246
|
if (typeof t != "object" || !t) return;
|
|
247
247
|
let r = "payload" in t && typeof t.payload == "object" && t.payload !== null ? t.payload : void 0, i = n;
|
|
248
248
|
return n in t && typeof t[n] == "string" ? i = t[n] : r && n in r && typeof r[n] == "string" && (i = r[n]), i in e ? e[i] : e[n];
|
|
249
249
|
}
|
|
250
|
-
var
|
|
251
|
-
|
|
250
|
+
var K, Ce, we, Te, q, J, Ee = V((() => {
|
|
251
|
+
K = (...e) => e.filter(Boolean).join(" "), Ce = {
|
|
252
252
|
light: "",
|
|
253
253
|
dark: ".dark"
|
|
254
|
-
},
|
|
254
|
+
}, we = o.createContext(null), Te = ({ id: e, config: t }) => {
|
|
255
255
|
let n = Object.entries(t).filter(([, e]) => e.theme || e.color);
|
|
256
|
-
return n.length ? /* @__PURE__ */
|
|
256
|
+
return n.length ? /* @__PURE__ */ b("style", { dangerouslySetInnerHTML: { __html: Object.entries(Ce).map(([t, r]) => `
|
|
257
257
|
${r} [data-chart=${e}] {
|
|
258
258
|
${n.map(([e, n]) => {
|
|
259
259
|
let r = n.theme?.[t] || n.color;
|
|
@@ -261,24 +261,77 @@ ${n.map(([e, n]) => {
|
|
|
261
261
|
}).join("\n")}
|
|
262
262
|
}
|
|
263
263
|
`).join("\n") } }) : null;
|
|
264
|
-
},
|
|
265
|
-
})),
|
|
266
|
-
function
|
|
267
|
-
let
|
|
268
|
-
|
|
269
|
-
let
|
|
264
|
+
}, q = ue, J = A;
|
|
265
|
+
})), De = /* @__PURE__ */ ve({ default: () => Oe });
|
|
266
|
+
function Oe({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r = "name", series: i = [], className: a = "", onChartClick: s }) {
|
|
267
|
+
let c = Array.isArray(t) ? t : [], [l, u] = o.useState(!1), d = o.useCallback((e) => {
|
|
268
|
+
if (!s || !e) return;
|
|
269
|
+
let t = Array.isArray(e.activePayload) ? e.activePayload[0] : void 0;
|
|
270
|
+
s({
|
|
271
|
+
category: e.activeLabel == null ? void 0 : String(e.activeLabel),
|
|
272
|
+
series: t?.dataKey ? String(t.dataKey) : void 0,
|
|
273
|
+
value: typeof t?.value == "number" ? t.value : void 0
|
|
274
|
+
});
|
|
275
|
+
}, [s]), f = o.useCallback((e) => {
|
|
276
|
+
if (!s || !e) return;
|
|
277
|
+
let t = e.payload?.[r], n = i[0]?.dataKey || "value";
|
|
278
|
+
s({
|
|
279
|
+
category: t == null ? void 0 : String(t),
|
|
280
|
+
series: n,
|
|
281
|
+
value: typeof e.payload?.[n] == "number" ? e.payload[n] : void 0
|
|
282
|
+
});
|
|
283
|
+
}, [
|
|
284
|
+
s,
|
|
285
|
+
r,
|
|
286
|
+
i
|
|
287
|
+
]), p = s ? {
|
|
288
|
+
onClick: d,
|
|
289
|
+
style: { cursor: "pointer" }
|
|
290
|
+
} : {}, m = s ? {
|
|
291
|
+
onClick: f,
|
|
292
|
+
style: { cursor: "pointer" }
|
|
293
|
+
} : {};
|
|
294
|
+
o.useEffect(() => {
|
|
295
|
+
let e = () => u(window.innerWidth < 640);
|
|
270
296
|
return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
271
297
|
}, []);
|
|
272
|
-
let
|
|
273
|
-
bar:
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
298
|
+
let h = {
|
|
299
|
+
bar: T,
|
|
300
|
+
"horizontal-bar": T,
|
|
301
|
+
line: M,
|
|
302
|
+
area: C,
|
|
303
|
+
pie: P,
|
|
304
|
+
donut: P,
|
|
305
|
+
radar: oe,
|
|
306
|
+
scatter: le,
|
|
307
|
+
funnel: O,
|
|
308
|
+
combo: T
|
|
309
|
+
}[e] || T, g = o.useCallback((e) => {
|
|
310
|
+
if (e == null || e === "") return "";
|
|
311
|
+
let t = typeof e == "string" ? e : String(e);
|
|
312
|
+
if (/^\d{4}-\d{2}-\d{2}/.test(t)) {
|
|
313
|
+
let e = new Date(t);
|
|
314
|
+
if (!Number.isNaN(e.getTime())) {
|
|
315
|
+
let t = (c.length > 1 ? Math.abs(new Date(String(c[c.length - 1][r] ?? "")).getTime() - new Date(String(c[0][r] ?? "")).getTime()) : 0) / (1e3 * 60 * 60 * 24);
|
|
316
|
+
try {
|
|
317
|
+
return t <= 62 ? e.toLocaleDateString(void 0, {
|
|
318
|
+
month: "short",
|
|
319
|
+
day: "numeric"
|
|
320
|
+
}) : e.toLocaleDateString(void 0, {
|
|
321
|
+
month: "short",
|
|
322
|
+
year: "numeric"
|
|
323
|
+
});
|
|
324
|
+
} catch {
|
|
325
|
+
return e.toISOString().slice(0, 10);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return l && t.length > 8 ? t.slice(0, 8) + "…" : t;
|
|
330
|
+
}, [
|
|
331
|
+
c,
|
|
332
|
+
r,
|
|
333
|
+
l
|
|
334
|
+
]), _ = o.useMemo(() => c.some((e) => String(e[r] || "").length > 5), [c, r]), v = () => [
|
|
282
335
|
"hsl(var(--chart-1))",
|
|
283
336
|
"hsl(var(--chart-2))",
|
|
284
337
|
"hsl(var(--chart-3))",
|
|
@@ -287,34 +340,35 @@ function pe({ chartType: e = "bar", data: t = [], config: r = {}, xAxisKey: i =
|
|
|
287
340
|
];
|
|
288
341
|
if (e === "pie" || e === "donut") {
|
|
289
342
|
let t = e === "donut" ? 60 : 0;
|
|
290
|
-
return /* @__PURE__ */
|
|
291
|
-
config:
|
|
292
|
-
className:
|
|
293
|
-
children: /* @__PURE__ */
|
|
294
|
-
/* @__PURE__ */
|
|
343
|
+
return /* @__PURE__ */ b(H, {
|
|
344
|
+
config: n,
|
|
345
|
+
className: a,
|
|
346
|
+
children: /* @__PURE__ */ x(P, { children: [
|
|
347
|
+
/* @__PURE__ */ b(q, {
|
|
295
348
|
cursor: !1,
|
|
296
|
-
content: /* @__PURE__ */
|
|
349
|
+
content: /* @__PURE__ */ b(U, { hideLabel: !0 })
|
|
297
350
|
}),
|
|
298
|
-
/* @__PURE__ */
|
|
299
|
-
data:
|
|
300
|
-
dataKey:
|
|
301
|
-
nameKey:
|
|
351
|
+
/* @__PURE__ */ b(N, {
|
|
352
|
+
data: c,
|
|
353
|
+
dataKey: i[0]?.dataKey || "value",
|
|
354
|
+
nameKey: r || "name",
|
|
302
355
|
innerRadius: t,
|
|
303
356
|
strokeWidth: 5,
|
|
304
357
|
paddingAngle: 2,
|
|
305
358
|
outerRadius: 80,
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
359
|
+
...m,
|
|
360
|
+
children: c.map((e, t) => {
|
|
361
|
+
let i = n[e[r]]?.color;
|
|
362
|
+
if (!i) {
|
|
363
|
+
let e = v();
|
|
364
|
+
i = e[t % e.length];
|
|
311
365
|
}
|
|
312
|
-
return /* @__PURE__ */
|
|
366
|
+
return /* @__PURE__ */ b(D, { fill: X(i) }, `cell-${t}`);
|
|
313
367
|
})
|
|
314
368
|
}),
|
|
315
|
-
/* @__PURE__ */
|
|
316
|
-
content: /* @__PURE__ */
|
|
317
|
-
...
|
|
369
|
+
/* @__PURE__ */ b(J, {
|
|
370
|
+
content: /* @__PURE__ */ b(W, { nameKey: r }),
|
|
371
|
+
...l && {
|
|
318
372
|
verticalAlign: "bottom",
|
|
319
373
|
wrapperStyle: {
|
|
320
374
|
fontSize: "11px",
|
|
@@ -325,19 +379,47 @@ function pe({ chartType: e = "bar", data: t = [], config: r = {}, xAxisKey: i =
|
|
|
325
379
|
] })
|
|
326
380
|
});
|
|
327
381
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
382
|
+
if (e === "funnel") {
|
|
383
|
+
let e = i[0]?.dataKey || "value", t = v(), o = s ? (t) => {
|
|
384
|
+
t && s({
|
|
385
|
+
category: t?.payload?.[r] ?? t?.[r],
|
|
386
|
+
value: t?.payload?.[e] ?? t?.[e]
|
|
387
|
+
});
|
|
388
|
+
} : void 0;
|
|
389
|
+
return /* @__PURE__ */ b(H, {
|
|
390
|
+
config: n,
|
|
391
|
+
className: a,
|
|
392
|
+
children: /* @__PURE__ */ x(O, { children: [/* @__PURE__ */ b(q, { content: /* @__PURE__ */ b(U, {}) }), /* @__PURE__ */ x(ae, {
|
|
393
|
+
dataKey: e,
|
|
394
|
+
data: c,
|
|
395
|
+
nameKey: r,
|
|
396
|
+
isAnimationActive: !0,
|
|
397
|
+
...o ? {
|
|
398
|
+
onClick: o,
|
|
399
|
+
style: { cursor: "pointer" }
|
|
400
|
+
} : {},
|
|
401
|
+
children: [/* @__PURE__ */ b(k, {
|
|
402
|
+
position: "right",
|
|
403
|
+
fill: "hsl(var(--foreground))",
|
|
404
|
+
stroke: "none",
|
|
405
|
+
dataKey: r
|
|
406
|
+
}), c.map((e, n) => /* @__PURE__ */ b(D, { fill: X(t[n % t.length]) }, `funnel-cell-${n}`))]
|
|
407
|
+
})] })
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
if (e === "radar") return /* @__PURE__ */ b(H, {
|
|
411
|
+
config: n,
|
|
412
|
+
className: a,
|
|
413
|
+
children: /* @__PURE__ */ x(oe, {
|
|
414
|
+
data: c,
|
|
333
415
|
children: [
|
|
334
|
-
/* @__PURE__ */
|
|
335
|
-
/* @__PURE__ */
|
|
336
|
-
/* @__PURE__ */
|
|
337
|
-
/* @__PURE__ */
|
|
338
|
-
/* @__PURE__ */
|
|
339
|
-
content: /* @__PURE__ */
|
|
340
|
-
...
|
|
416
|
+
/* @__PURE__ */ b(I, {}),
|
|
417
|
+
/* @__PURE__ */ b(F, { dataKey: r }),
|
|
418
|
+
/* @__PURE__ */ b(L, {}),
|
|
419
|
+
/* @__PURE__ */ b(q, { content: /* @__PURE__ */ b(U, {}) }),
|
|
420
|
+
/* @__PURE__ */ b(J, {
|
|
421
|
+
content: /* @__PURE__ */ b(W, {}),
|
|
422
|
+
...l && {
|
|
341
423
|
verticalAlign: "bottom",
|
|
342
424
|
wrapperStyle: {
|
|
343
425
|
fontSize: "11px",
|
|
@@ -345,9 +427,9 @@ function pe({ chartType: e = "bar", data: t = [], config: r = {}, xAxisKey: i =
|
|
|
345
427
|
}
|
|
346
428
|
}
|
|
347
429
|
}),
|
|
348
|
-
|
|
349
|
-
let t =
|
|
350
|
-
return /* @__PURE__ */
|
|
430
|
+
i.map((e) => {
|
|
431
|
+
let t = X(n[e.dataKey]?.color || Y);
|
|
432
|
+
return /* @__PURE__ */ b(R, {
|
|
351
433
|
dataKey: e.dataKey,
|
|
352
434
|
stroke: t,
|
|
353
435
|
fill: t,
|
|
@@ -356,34 +438,35 @@ function pe({ chartType: e = "bar", data: t = [], config: r = {}, xAxisKey: i =
|
|
|
356
438
|
})
|
|
357
439
|
]
|
|
358
440
|
})
|
|
359
|
-
})
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
/* @__PURE__ */
|
|
441
|
+
});
|
|
442
|
+
if (e === "scatter") return /* @__PURE__ */ b(H, {
|
|
443
|
+
config: n,
|
|
444
|
+
className: a,
|
|
445
|
+
children: /* @__PURE__ */ x(le, { children: [
|
|
446
|
+
/* @__PURE__ */ b(E, { vertical: !1 }),
|
|
447
|
+
/* @__PURE__ */ b(z, {
|
|
365
448
|
type: "number",
|
|
366
|
-
dataKey:
|
|
367
|
-
name: String(r
|
|
449
|
+
dataKey: r,
|
|
450
|
+
name: String(n[r]?.label || r),
|
|
368
451
|
tickLine: !1,
|
|
369
452
|
axisLine: !1,
|
|
370
|
-
interval:
|
|
453
|
+
interval: l ? Math.ceil(c.length / 5) : 0
|
|
371
454
|
}),
|
|
372
|
-
/* @__PURE__ */
|
|
455
|
+
/* @__PURE__ */ b(B, {
|
|
373
456
|
type: "number",
|
|
374
|
-
dataKey:
|
|
375
|
-
name: String(
|
|
457
|
+
dataKey: i[0]?.dataKey || "value",
|
|
458
|
+
name: String(n[i[0]?.dataKey]?.label || i[0]?.dataKey),
|
|
376
459
|
tickLine: !1,
|
|
377
460
|
axisLine: !1
|
|
378
461
|
}),
|
|
379
|
-
/* @__PURE__ */
|
|
462
|
+
/* @__PURE__ */ b(de, {
|
|
380
463
|
type: "number",
|
|
381
464
|
range: [60, 400]
|
|
382
465
|
}),
|
|
383
|
-
/* @__PURE__ */
|
|
384
|
-
/* @__PURE__ */
|
|
385
|
-
content: /* @__PURE__ */
|
|
386
|
-
...
|
|
466
|
+
/* @__PURE__ */ b(q, { content: /* @__PURE__ */ b(U, {}) }),
|
|
467
|
+
/* @__PURE__ */ b(J, {
|
|
468
|
+
content: /* @__PURE__ */ b(W, {}),
|
|
469
|
+
...l && {
|
|
387
470
|
verticalAlign: "bottom",
|
|
388
471
|
wrapperStyle: {
|
|
389
472
|
fontSize: "11px",
|
|
@@ -391,50 +474,51 @@ function pe({ chartType: e = "bar", data: t = [], config: r = {}, xAxisKey: i =
|
|
|
391
474
|
}
|
|
392
475
|
}
|
|
393
476
|
}),
|
|
394
|
-
|
|
395
|
-
let
|
|
396
|
-
return /* @__PURE__ */
|
|
397
|
-
name:
|
|
398
|
-
data:
|
|
477
|
+
i.map((e, t) => {
|
|
478
|
+
let r = v(), i = X(n[e.dataKey]?.color || r[t % r.length]);
|
|
479
|
+
return /* @__PURE__ */ b(ce, {
|
|
480
|
+
name: n[e.dataKey]?.label || e.dataKey,
|
|
481
|
+
data: c,
|
|
399
482
|
fill: i
|
|
400
483
|
}, e.dataKey);
|
|
401
484
|
})
|
|
402
485
|
] })
|
|
403
|
-
})
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
486
|
+
});
|
|
487
|
+
if (e === "combo") return /* @__PURE__ */ b(H, {
|
|
488
|
+
config: n,
|
|
489
|
+
className: a,
|
|
490
|
+
children: /* @__PURE__ */ x(T, {
|
|
491
|
+
data: c,
|
|
408
492
|
children: [
|
|
409
|
-
/* @__PURE__ */
|
|
410
|
-
/* @__PURE__ */
|
|
411
|
-
dataKey:
|
|
493
|
+
/* @__PURE__ */ b(E, { vertical: !1 }),
|
|
494
|
+
/* @__PURE__ */ b(z, {
|
|
495
|
+
dataKey: r,
|
|
412
496
|
tickLine: !1,
|
|
413
497
|
tickMargin: 10,
|
|
414
498
|
axisLine: !1,
|
|
415
|
-
interval:
|
|
416
|
-
tickFormatter:
|
|
417
|
-
...!
|
|
499
|
+
interval: l ? Math.ceil(c.length / 5) : 0,
|
|
500
|
+
tickFormatter: g,
|
|
501
|
+
...!l && _ && {
|
|
418
502
|
angle: -35,
|
|
419
503
|
textAnchor: "end",
|
|
420
504
|
height: 60
|
|
421
505
|
}
|
|
422
506
|
}),
|
|
423
|
-
/* @__PURE__ */
|
|
507
|
+
/* @__PURE__ */ b(B, {
|
|
424
508
|
yAxisId: "left",
|
|
425
509
|
tickLine: !1,
|
|
426
510
|
axisLine: !1
|
|
427
511
|
}),
|
|
428
|
-
/* @__PURE__ */
|
|
512
|
+
/* @__PURE__ */ b(B, {
|
|
429
513
|
yAxisId: "right",
|
|
430
514
|
orientation: "right",
|
|
431
515
|
tickLine: !1,
|
|
432
516
|
axisLine: !1
|
|
433
517
|
}),
|
|
434
|
-
/* @__PURE__ */
|
|
435
|
-
/* @__PURE__ */
|
|
436
|
-
content: /* @__PURE__ */
|
|
437
|
-
...
|
|
518
|
+
/* @__PURE__ */ b(q, { content: /* @__PURE__ */ b(U, {}) }),
|
|
519
|
+
/* @__PURE__ */ b(J, {
|
|
520
|
+
content: /* @__PURE__ */ b(W, {}),
|
|
521
|
+
...l && {
|
|
438
522
|
verticalAlign: "bottom",
|
|
439
523
|
wrapperStyle: {
|
|
440
524
|
fontSize: "11px",
|
|
@@ -442,55 +526,70 @@ function pe({ chartType: e = "bar", data: t = [], config: r = {}, xAxisKey: i =
|
|
|
442
526
|
}
|
|
443
527
|
}
|
|
444
528
|
}),
|
|
445
|
-
|
|
446
|
-
let
|
|
447
|
-
return i === "line" ? /* @__PURE__ */
|
|
529
|
+
i.map((e, t) => {
|
|
530
|
+
let r = X(n[e.dataKey]?.color || Y), i = e.chartType || (t === 0 ? "bar" : "line"), a = i === "bar" ? "left" : "right";
|
|
531
|
+
return i === "line" ? /* @__PURE__ */ b(j, {
|
|
448
532
|
yAxisId: a,
|
|
449
533
|
type: "monotone",
|
|
450
534
|
dataKey: e.dataKey,
|
|
451
|
-
stroke:
|
|
535
|
+
stroke: r,
|
|
452
536
|
strokeWidth: 2,
|
|
453
537
|
dot: !1
|
|
454
|
-
}, e.dataKey) : i === "area" ? /* @__PURE__ */
|
|
538
|
+
}, e.dataKey) : i === "area" ? /* @__PURE__ */ b(S, {
|
|
455
539
|
yAxisId: a,
|
|
456
540
|
type: "monotone",
|
|
457
541
|
dataKey: e.dataKey,
|
|
458
|
-
fill:
|
|
459
|
-
stroke:
|
|
542
|
+
fill: r,
|
|
543
|
+
stroke: r,
|
|
460
544
|
fillOpacity: .4
|
|
461
|
-
}, e.dataKey) : /* @__PURE__ */
|
|
545
|
+
}, e.dataKey) : /* @__PURE__ */ b(w, {
|
|
462
546
|
yAxisId: a,
|
|
463
547
|
dataKey: e.dataKey,
|
|
464
|
-
fill:
|
|
548
|
+
fill: r,
|
|
465
549
|
radius: 4
|
|
466
550
|
}, e.dataKey);
|
|
467
551
|
})
|
|
468
552
|
]
|
|
469
553
|
})
|
|
470
|
-
})
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
554
|
+
});
|
|
555
|
+
let ee = e === "horizontal-bar";
|
|
556
|
+
return /* @__PURE__ */ b(H, {
|
|
557
|
+
config: n,
|
|
558
|
+
className: a,
|
|
559
|
+
children: /* @__PURE__ */ x(h, {
|
|
560
|
+
data: c,
|
|
561
|
+
layout: ee ? "vertical" : "horizontal",
|
|
562
|
+
...p,
|
|
475
563
|
children: [
|
|
476
|
-
/* @__PURE__ */
|
|
477
|
-
/* @__PURE__ */
|
|
478
|
-
|
|
564
|
+
/* @__PURE__ */ b(E, { vertical: !1 }),
|
|
565
|
+
ee ? /* @__PURE__ */ x(ie, { children: [/* @__PURE__ */ b(z, {
|
|
566
|
+
type: "number",
|
|
567
|
+
tickLine: !1,
|
|
568
|
+
axisLine: !1
|
|
569
|
+
}), /* @__PURE__ */ b(B, {
|
|
570
|
+
type: "category",
|
|
571
|
+
dataKey: r,
|
|
572
|
+
tickLine: !1,
|
|
573
|
+
axisLine: !1,
|
|
574
|
+
width: Math.min(140, Math.max(60, Math.max(...c.map((e) => String(e[r] ?? "").length)) * 7)),
|
|
575
|
+
tickFormatter: g
|
|
576
|
+
})] }) : /* @__PURE__ */ b(z, {
|
|
577
|
+
dataKey: r,
|
|
479
578
|
tickLine: !1,
|
|
480
579
|
tickMargin: 10,
|
|
481
580
|
axisLine: !1,
|
|
482
|
-
interval:
|
|
483
|
-
tickFormatter:
|
|
484
|
-
...!
|
|
581
|
+
interval: l ? Math.ceil(c.length / 5) : 0,
|
|
582
|
+
tickFormatter: g,
|
|
583
|
+
...!l && _ && {
|
|
485
584
|
angle: -35,
|
|
486
585
|
textAnchor: "end",
|
|
487
586
|
height: 60
|
|
488
587
|
}
|
|
489
588
|
}),
|
|
490
|
-
/* @__PURE__ */
|
|
491
|
-
/* @__PURE__ */
|
|
492
|
-
content: /* @__PURE__ */
|
|
493
|
-
...
|
|
589
|
+
/* @__PURE__ */ b(q, { content: /* @__PURE__ */ b(U, {}) }),
|
|
590
|
+
/* @__PURE__ */ b(J, {
|
|
591
|
+
content: /* @__PURE__ */ b(W, {}),
|
|
592
|
+
...l && {
|
|
494
593
|
verticalAlign: "bottom",
|
|
495
594
|
wrapperStyle: {
|
|
496
595
|
fontSize: "11px",
|
|
@@ -498,24 +597,24 @@ function pe({ chartType: e = "bar", data: t = [], config: r = {}, xAxisKey: i =
|
|
|
498
597
|
}
|
|
499
598
|
}
|
|
500
599
|
}),
|
|
501
|
-
|
|
502
|
-
let
|
|
503
|
-
if (e === "bar") {
|
|
504
|
-
let e =
|
|
505
|
-
return /* @__PURE__ */
|
|
600
|
+
i.map((t, r) => {
|
|
601
|
+
let a = v(), o = X(n[t.dataKey]?.color || a[r % a.length] || Y);
|
|
602
|
+
if (e === "bar" || e === "horizontal-bar") {
|
|
603
|
+
let e = i.length === 1 && c.length > 1;
|
|
604
|
+
return /* @__PURE__ */ b(w, {
|
|
506
605
|
dataKey: t.dataKey,
|
|
507
606
|
fill: o,
|
|
508
607
|
radius: 4,
|
|
509
|
-
children: e &&
|
|
608
|
+
children: e && c.map((e, t) => /* @__PURE__ */ b(D, { fill: X(a[t % a.length]) }, `cell-${t}`))
|
|
510
609
|
}, t.dataKey);
|
|
511
610
|
}
|
|
512
|
-
return e === "line" ? /* @__PURE__ */
|
|
611
|
+
return e === "line" ? /* @__PURE__ */ b(j, {
|
|
513
612
|
type: "monotone",
|
|
514
613
|
dataKey: t.dataKey,
|
|
515
614
|
stroke: o,
|
|
516
615
|
strokeWidth: 2,
|
|
517
616
|
dot: !1
|
|
518
|
-
}, t.dataKey) : e === "area" ? /* @__PURE__ */
|
|
617
|
+
}, t.dataKey) : e === "area" ? /* @__PURE__ */ b(S, {
|
|
519
618
|
type: "monotone",
|
|
520
619
|
dataKey: t.dataKey,
|
|
521
620
|
fill: o,
|
|
@@ -527,8 +626,8 @@ function pe({ chartType: e = "bar", data: t = [], config: r = {}, xAxisKey: i =
|
|
|
527
626
|
})
|
|
528
627
|
});
|
|
529
628
|
}
|
|
530
|
-
var
|
|
531
|
-
|
|
629
|
+
var Y, ke, X, Ae = V((() => {
|
|
630
|
+
Ee(), Y = "hsl(var(--primary))", ke = {
|
|
532
631
|
slate: "#64748b",
|
|
533
632
|
gray: "#6b7280",
|
|
534
633
|
zinc: "#71717a",
|
|
@@ -551,10 +650,10 @@ var J, me, Y, he = F((() => {
|
|
|
551
650
|
fuchsia: "#d946ef",
|
|
552
651
|
pink: "#ec4899",
|
|
553
652
|
rose: "#f43f5e"
|
|
554
|
-
},
|
|
555
|
-
})),
|
|
556
|
-
fallback: /* @__PURE__ */
|
|
557
|
-
children: /* @__PURE__ */
|
|
653
|
+
}, X = (e) => ke[e] || e;
|
|
654
|
+
})), je = s.lazy(() => Promise.resolve().then(() => (xe(), ye))), Me = s.lazy(() => Promise.resolve().then(() => (Ae(), De))), Ne = ({ schema: e }) => /* @__PURE__ */ b(c, {
|
|
655
|
+
fallback: /* @__PURE__ */ b(y, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
|
|
656
|
+
children: /* @__PURE__ */ b(je, {
|
|
558
657
|
data: e.data,
|
|
559
658
|
dataKey: e.dataKey,
|
|
560
659
|
xAxisKey: e.xAxisKey,
|
|
@@ -562,8 +661,8 @@ var J, me, Y, he = F((() => {
|
|
|
562
661
|
className: e.className,
|
|
563
662
|
color: e.color
|
|
564
663
|
})
|
|
565
|
-
}), Z = ({ schema: e }) => {
|
|
566
|
-
let
|
|
664
|
+
}), Z = ({ schema: e, onChartClick: t }) => {
|
|
665
|
+
let n = s.useMemo(() => {
|
|
567
666
|
let t = e.series, n = e.xAxisKey, r = e.config;
|
|
568
667
|
if (n || (e.index ? n = e.index : e.category && (n = e.category)), t || (e.categories ? t = e.categories.map((e) => ({ dataKey: e })) : e.value && (t = [{ dataKey: e.value }])), !r && t) {
|
|
569
668
|
let n = e.colors || [
|
|
@@ -587,15 +686,16 @@ var J, me, Y, he = F((() => {
|
|
|
587
686
|
className: e.className
|
|
588
687
|
};
|
|
589
688
|
}, [e]);
|
|
590
|
-
return /* @__PURE__ */
|
|
591
|
-
fallback: /* @__PURE__ */
|
|
592
|
-
children: /* @__PURE__ */
|
|
593
|
-
chartType:
|
|
594
|
-
data:
|
|
595
|
-
config:
|
|
596
|
-
xAxisKey:
|
|
597
|
-
series:
|
|
598
|
-
className:
|
|
689
|
+
return /* @__PURE__ */ b(c, {
|
|
690
|
+
fallback: /* @__PURE__ */ b(y, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
|
|
691
|
+
children: /* @__PURE__ */ b(Me, {
|
|
692
|
+
chartType: n.chartType,
|
|
693
|
+
data: n.data,
|
|
694
|
+
config: n.config,
|
|
695
|
+
xAxisKey: n.xAxisKey,
|
|
696
|
+
series: n.series,
|
|
697
|
+
className: n.className,
|
|
698
|
+
onChartClick: t
|
|
599
699
|
})
|
|
600
700
|
});
|
|
601
701
|
};
|
|
@@ -604,7 +704,7 @@ var J, me, Y, he = F((() => {
|
|
|
604
704
|
function Q(e) {
|
|
605
705
|
return e.replace(/[_-]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
|
|
606
706
|
}
|
|
607
|
-
function
|
|
707
|
+
function Pe(e, t) {
|
|
608
708
|
let { field: n, function: r, groupBy: i } = t, a = {};
|
|
609
709
|
for (let t of e) {
|
|
610
710
|
let e = String(t[i] ?? "Unknown");
|
|
@@ -635,154 +735,243 @@ function ve(e, t) {
|
|
|
635
735
|
};
|
|
636
736
|
});
|
|
637
737
|
}
|
|
638
|
-
async function
|
|
639
|
-
if (!e.length || !
|
|
640
|
-
let o = a || ((e, t) => t), s = r?.fields?.[
|
|
641
|
-
if (!
|
|
642
|
-
let
|
|
643
|
-
return {
|
|
644
|
-
|
|
645
|
-
[n]: o(t, r)
|
|
646
|
-
};
|
|
647
|
-
});
|
|
648
|
-
let c = s.type;
|
|
649
|
-
if (c === "select" || c === "picklist" || c === "dropdown") {
|
|
650
|
-
let t = s.options || [];
|
|
651
|
-
if (t.length === 0) return e.map((e) => {
|
|
652
|
-
let t = String(e[n] ?? ""), r = Q(t);
|
|
738
|
+
async function Fe(e, t, r, i, a) {
|
|
739
|
+
if (!e.length || !t) return e;
|
|
740
|
+
let o = a || ((e, t) => t), s = `__raw_${t}`, c = r?.fields?.[t];
|
|
741
|
+
if (!c) {
|
|
742
|
+
let n = /^\d{4}-\d{2}-\d{2}/;
|
|
743
|
+
return e.map((e) => {
|
|
744
|
+
let r = e[t], i = String(r ?? ""), a = n.test(i) ? i : Q(i);
|
|
653
745
|
return {
|
|
654
746
|
...e,
|
|
655
|
-
[
|
|
747
|
+
[t]: o(i, a),
|
|
748
|
+
[s]: r
|
|
749
|
+
};
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
let l = c.type;
|
|
753
|
+
if (l === "select" || l === "picklist" || l === "dropdown") {
|
|
754
|
+
let n = c.options || [];
|
|
755
|
+
if (n.length === 0) return e.map((e) => {
|
|
756
|
+
let n = e[t], r = String(n ?? ""), i = Q(r);
|
|
757
|
+
return {
|
|
758
|
+
...e,
|
|
759
|
+
[t]: o(r, i),
|
|
760
|
+
[s]: n
|
|
656
761
|
};
|
|
657
762
|
});
|
|
658
763
|
let r = {};
|
|
659
|
-
for (let e of
|
|
764
|
+
for (let e of n) typeof e == "string" ? r[e] = e : e && typeof e == "object" && (r[String(e.value)] = e.label || String(e.value));
|
|
660
765
|
return e.map((e) => {
|
|
661
|
-
let t = String(
|
|
766
|
+
let n = e[t], i = String(n ?? ""), a = r[i] || Q(i);
|
|
662
767
|
return {
|
|
663
768
|
...e,
|
|
664
|
-
[
|
|
769
|
+
[t]: o(i, a),
|
|
770
|
+
[s]: n
|
|
665
771
|
};
|
|
666
772
|
});
|
|
667
773
|
}
|
|
668
|
-
if (
|
|
669
|
-
let r =
|
|
670
|
-
if (!r || !i || typeof i.find != "function") return e
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
774
|
+
if (l === "lookup" || l === "master_detail") {
|
|
775
|
+
let r = c.reference_to || c.reference;
|
|
776
|
+
if (!r || !i || typeof i.find != "function") return e.map((e) => ({
|
|
777
|
+
...e,
|
|
778
|
+
[s]: e[t]
|
|
779
|
+
}));
|
|
780
|
+
let a = [...new Set(e.map((e) => e[t]).filter((e) => e != null))];
|
|
781
|
+
if (a.length === 0) return e.map((e) => ({
|
|
782
|
+
...e,
|
|
783
|
+
[s]: e[t]
|
|
784
|
+
}));
|
|
785
|
+
let o = c.id_field || "id";
|
|
674
786
|
try {
|
|
675
|
-
let
|
|
787
|
+
let l = n(await i.find(r, {
|
|
676
788
|
$filter: { [o]: { $in: a } },
|
|
677
789
|
$top: a.length
|
|
678
|
-
})),
|
|
679
|
-
for (let e of
|
|
680
|
-
let t = String(e[o] ?? e.id ?? e._id ?? ""), n = e[
|
|
681
|
-
t && (
|
|
790
|
+
})), u = c.reference_field || c.display_field || "name", d = {};
|
|
791
|
+
for (let e of l) {
|
|
792
|
+
let t = String(e[o] ?? e.id ?? e._id ?? ""), n = e[u] || e.name || e.label || e.title || t;
|
|
793
|
+
t && (d[t] = String(n));
|
|
682
794
|
}
|
|
683
795
|
return e.map((e) => {
|
|
684
|
-
let t = String(
|
|
796
|
+
let n = e[t], r = String(n ?? "");
|
|
685
797
|
return {
|
|
686
798
|
...e,
|
|
687
|
-
[
|
|
799
|
+
[t]: d[r] || r,
|
|
800
|
+
[s]: n
|
|
688
801
|
};
|
|
689
802
|
});
|
|
690
|
-
} catch (
|
|
691
|
-
return console.warn("[ObjectChart] Failed to resolve lookup labels:",
|
|
803
|
+
} catch (n) {
|
|
804
|
+
return console.warn("[ObjectChart] Failed to resolve lookup labels:", n), e.map((e) => ({
|
|
805
|
+
...e,
|
|
806
|
+
[s]: e[t]
|
|
807
|
+
}));
|
|
692
808
|
}
|
|
693
809
|
}
|
|
694
|
-
return e.map((e) => ({
|
|
810
|
+
if (l === "date" || l === "datetime" || l === "date_time" || l === "timestamp" || l === "time") return e.map((e) => ({
|
|
695
811
|
...e,
|
|
696
|
-
[
|
|
812
|
+
[s]: e[t]
|
|
697
813
|
}));
|
|
814
|
+
let u = /^\d{4}-\d{2}-\d{2}/;
|
|
815
|
+
return e.map((e) => {
|
|
816
|
+
let n = e[t], r = String(n ?? "");
|
|
817
|
+
return {
|
|
818
|
+
...e,
|
|
819
|
+
[t]: u.test(r) ? r : Q(r),
|
|
820
|
+
[s]: n
|
|
821
|
+
};
|
|
822
|
+
});
|
|
698
823
|
}
|
|
699
824
|
var $ = (e) => {
|
|
700
|
-
let { schema:
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
}, [
|
|
704
|
-
let [
|
|
705
|
-
if (!(!e || !
|
|
706
|
-
|
|
825
|
+
let { schema: o } = e, s = u(pe), c = e.dataSource || s?.dataSource, y = me(o.bind), { fieldOptionLabel: S } = ge(), C = p(S);
|
|
826
|
+
d(() => {
|
|
827
|
+
C.current = S;
|
|
828
|
+
}, [S]);
|
|
829
|
+
let [w, T] = m([]), [E, D] = m(!1), [ae, O] = m(null), [k, A] = m(null), j = f(() => o.aggregate ? JSON.stringify(o.aggregate) : "", [o.aggregate]), M = f(() => o.filter ? JSON.stringify(o.filter) : "", [o.filter]), N = l(async (e, t) => {
|
|
830
|
+
if (!(!e || !o.objectName)) {
|
|
831
|
+
t.current && (D(!0), O(null));
|
|
707
832
|
try {
|
|
708
|
-
let i;
|
|
709
|
-
if (
|
|
710
|
-
let t = await e.aggregate(
|
|
711
|
-
field:
|
|
712
|
-
function:
|
|
713
|
-
groupBy:
|
|
714
|
-
filter:
|
|
833
|
+
let r, a = i(o.filter);
|
|
834
|
+
if (o.aggregate && typeof e.aggregate == "function") {
|
|
835
|
+
let t = await e.aggregate(o.objectName, {
|
|
836
|
+
field: o.aggregate.field,
|
|
837
|
+
function: o.aggregate.function,
|
|
838
|
+
groupBy: o.aggregate.groupBy,
|
|
839
|
+
filter: a
|
|
715
840
|
});
|
|
716
|
-
|
|
717
|
-
} else if (typeof e.find == "function")
|
|
841
|
+
r = Array.isArray(t) ? t : [];
|
|
842
|
+
} else if (typeof e.find == "function") r = n(await e.find(o.objectName, { $filter: a })), o.aggregate && r.length > 0 && (r = Pe(r, o.aggregate));
|
|
718
843
|
else return;
|
|
719
|
-
let
|
|
720
|
-
if (
|
|
721
|
-
let t = await e.getObjectSchema(
|
|
722
|
-
|
|
844
|
+
let s = o.aggregate?.groupBy || o.xAxisKey;
|
|
845
|
+
if (s && typeof e.getObjectSchema == "function") try {
|
|
846
|
+
let t = await e.getObjectSchema(o.objectName);
|
|
847
|
+
r = await Fe(r, s, t, e, (e, t) => C.current(o.objectName, s, e, t));
|
|
723
848
|
} catch {}
|
|
724
|
-
|
|
849
|
+
t.current && T(r);
|
|
725
850
|
} catch (e) {
|
|
726
|
-
console.error("[ObjectChart] Fetch error:", e),
|
|
851
|
+
console.error("[ObjectChart] Fetch error:", e), t.current && O(e instanceof Error ? e.message : "Failed to load chart data");
|
|
727
852
|
} finally {
|
|
728
|
-
|
|
853
|
+
t.current && D(!1);
|
|
729
854
|
}
|
|
730
855
|
}
|
|
731
856
|
}, [
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
857
|
+
o.objectName,
|
|
858
|
+
j,
|
|
859
|
+
M,
|
|
860
|
+
o.xAxisKey
|
|
736
861
|
]);
|
|
737
|
-
|
|
862
|
+
d(() => {
|
|
738
863
|
let e = { current: !0 };
|
|
739
|
-
return
|
|
864
|
+
return o.objectName && !y && !o.data && N(c, e), () => {
|
|
740
865
|
e.current = !1;
|
|
741
866
|
};
|
|
742
867
|
}, [
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
868
|
+
o.objectName,
|
|
869
|
+
c,
|
|
870
|
+
y,
|
|
871
|
+
o.data,
|
|
872
|
+
M,
|
|
873
|
+
j,
|
|
874
|
+
N
|
|
750
875
|
]);
|
|
751
|
-
let
|
|
752
|
-
|
|
753
|
-
|
|
876
|
+
let P = y || o.data || w, F = Array.isArray(P) ? P : [], I = o.drillDown, L = o.aggregate?.groupBy || o.xAxisKey, R = f(() => {
|
|
877
|
+
if (!L) return /* @__PURE__ */ new Map();
|
|
878
|
+
let e = /* @__PURE__ */ new Map(), t = `__raw_${L}`;
|
|
879
|
+
for (let n of F) {
|
|
880
|
+
let r = n?.[L];
|
|
881
|
+
if (r == null) continue;
|
|
882
|
+
let i = t in (n || {}) ? n[t] : r;
|
|
883
|
+
e.set(String(r), i);
|
|
884
|
+
}
|
|
885
|
+
return e;
|
|
886
|
+
}, [F, L]), oe = {
|
|
887
|
+
...o,
|
|
888
|
+
data: F
|
|
754
889
|
};
|
|
755
|
-
|
|
756
|
-
className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (
|
|
890
|
+
if (E && F.length === 0) return /* @__PURE__ */ b("div", {
|
|
891
|
+
className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (o.className || ""),
|
|
757
892
|
"data-testid": "chart-loading",
|
|
758
893
|
children: "Loading chart data…"
|
|
759
|
-
})
|
|
760
|
-
|
|
894
|
+
});
|
|
895
|
+
if (ae) return /* @__PURE__ */ x("div", {
|
|
896
|
+
className: "flex flex-col items-center justify-center gap-2 p-4 " + (o.className || ""),
|
|
761
897
|
"data-testid": "chart-error",
|
|
762
898
|
role: "alert",
|
|
763
899
|
children: [
|
|
764
|
-
/* @__PURE__ */
|
|
765
|
-
/* @__PURE__ */
|
|
900
|
+
/* @__PURE__ */ b(he, { className: "h-6 w-6 text-destructive opacity-60" }),
|
|
901
|
+
/* @__PURE__ */ b("p", {
|
|
766
902
|
className: "text-xs text-destructive font-medium",
|
|
767
903
|
children: "Failed to load chart data"
|
|
768
904
|
}),
|
|
769
|
-
/* @__PURE__ */
|
|
905
|
+
/* @__PURE__ */ b("p", {
|
|
770
906
|
className: "text-xs text-muted-foreground max-w-xs text-center",
|
|
771
|
-
children:
|
|
907
|
+
children: ae
|
|
772
908
|
})
|
|
773
909
|
]
|
|
774
|
-
})
|
|
775
|
-
|
|
910
|
+
});
|
|
911
|
+
if (!c && o.objectName && F.length === 0) return /* @__PURE__ */ x("div", {
|
|
912
|
+
className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (o.className || ""),
|
|
776
913
|
"data-testid": "chart-no-datasource",
|
|
777
914
|
children: [
|
|
778
915
|
"No data source available for “",
|
|
779
|
-
|
|
916
|
+
o.objectName,
|
|
780
917
|
"”"
|
|
781
918
|
]
|
|
782
|
-
}) : /* @__PURE__ */ p(Z, {
|
|
783
|
-
...e,
|
|
784
|
-
schema: D
|
|
785
919
|
});
|
|
920
|
+
let se = r(I) ? (e) => {
|
|
921
|
+
let t = e.category, n = t != null && R.has(String(t)) ? R.get(String(t)) : t;
|
|
922
|
+
A({
|
|
923
|
+
...e,
|
|
924
|
+
category: n,
|
|
925
|
+
categoryLabel: t,
|
|
926
|
+
scope: "cell"
|
|
927
|
+
});
|
|
928
|
+
} : void 0, ce = k && o.objectName ? (() => {
|
|
929
|
+
let e = t(I, k, { groupByField: L }), n = {
|
|
930
|
+
...o.filter || {},
|
|
931
|
+
...e
|
|
932
|
+
}, r = a(I, k, o.title || "Details"), i = I?.target ?? "drawer", s = /* @__PURE__ */ b("div", {
|
|
933
|
+
className: "overflow-auto",
|
|
934
|
+
"data-testid": "chart-drill-body",
|
|
935
|
+
children: /* @__PURE__ */ b(fe, {
|
|
936
|
+
schema: {
|
|
937
|
+
type: "object-data-table",
|
|
938
|
+
objectName: o.objectName,
|
|
939
|
+
filter: n,
|
|
940
|
+
pagination: !0,
|
|
941
|
+
pageSize: I?.maxRows,
|
|
942
|
+
columns: I?.columns?.map((e) => ({
|
|
943
|
+
accessorKey: e,
|
|
944
|
+
header: e
|
|
945
|
+
}))
|
|
946
|
+
},
|
|
947
|
+
dataSource: c
|
|
948
|
+
})
|
|
949
|
+
});
|
|
950
|
+
return i === "dialog" ? /* @__PURE__ */ b(h, {
|
|
951
|
+
open: !0,
|
|
952
|
+
onOpenChange: (e) => !e && A(null),
|
|
953
|
+
children: /* @__PURE__ */ x(g, {
|
|
954
|
+
className: "max-w-4xl",
|
|
955
|
+
children: [/* @__PURE__ */ b(_, { children: /* @__PURE__ */ b(v, { children: r }) }), s]
|
|
956
|
+
})
|
|
957
|
+
}) : /* @__PURE__ */ b(ee, {
|
|
958
|
+
open: !0,
|
|
959
|
+
onOpenChange: (e) => !e && A(null),
|
|
960
|
+
children: /* @__PURE__ */ x(te, {
|
|
961
|
+
side: "right",
|
|
962
|
+
className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col",
|
|
963
|
+
children: [/* @__PURE__ */ b(ne, { children: /* @__PURE__ */ b(re, { children: r }) }), /* @__PURE__ */ b("div", {
|
|
964
|
+
className: "flex-1 overflow-hidden mt-2",
|
|
965
|
+
children: s
|
|
966
|
+
})]
|
|
967
|
+
})
|
|
968
|
+
});
|
|
969
|
+
})() : null;
|
|
970
|
+
return /* @__PURE__ */ x(ie, { children: [/* @__PURE__ */ b(Z, {
|
|
971
|
+
...e,
|
|
972
|
+
schema: oe,
|
|
973
|
+
onChartClick: se
|
|
974
|
+
}), ce] });
|
|
786
975
|
};
|
|
787
976
|
e.register("object-chart", $, {
|
|
788
977
|
namespace: "plugin-charts",
|
|
@@ -816,11 +1005,11 @@ e.register("object-chart", $, {
|
|
|
816
1005
|
});
|
|
817
1006
|
//#endregion
|
|
818
1007
|
//#region src/index.tsx
|
|
819
|
-
var
|
|
820
|
-
"bar-chart":
|
|
1008
|
+
var Ie = {
|
|
1009
|
+
"bar-chart": Ne,
|
|
821
1010
|
chart: Z
|
|
822
1011
|
};
|
|
823
|
-
e.register("bar-chart",
|
|
1012
|
+
e.register("bar-chart", Ne, {
|
|
824
1013
|
namespace: "plugin-charts",
|
|
825
1014
|
label: "Bar Chart",
|
|
826
1015
|
category: "plugin",
|
|
@@ -1050,4 +1239,4 @@ e.register("bar-chart", X, {
|
|
|
1050
1239
|
defaultProps: { chartType: "scatter" }
|
|
1051
1240
|
});
|
|
1052
1241
|
//#endregion
|
|
1053
|
-
export {
|
|
1242
|
+
export { Ne as ChartBarRenderer, Z as ChartRenderer, $ as ObjectChart, Ie as chartComponents };
|