@object-ui/plugin-charts 16.0.0 → 17.1.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/CHANGELOG.md +446 -1
- package/dist/AdvancedChartImpl.d.ts +65 -11
- package/dist/ChartContainerImpl.d.ts +8 -1
- package/dist/ChartRenderer.d.ts +46 -0
- package/dist/ObjectChart.d.ts +17 -1
- package/dist/index.js +1173 -741
- package/dist/index.umd.cjs +2 -2
- package/dist/normalizeChartSchema.d.ts +207 -0
- package/package.json +11 -10
package/dist/index.js
CHANGED
|
@@ -1,54 +1,211 @@
|
|
|
1
|
-
import { ComponentRegistry as e,
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import { Button as
|
|
5
|
-
import { Fragment as
|
|
6
|
-
import { Area as
|
|
7
|
-
import { SchemaRenderer as
|
|
8
|
-
import { AlertCircle as
|
|
9
|
-
import { useSafeFieldLabel as
|
|
1
|
+
import { ComponentRegistry as e, buildCategoryRank as t, buildChartSeries as n, buildDimensionLabelMap as r, buildOptionColorMap as i, compareToTrendLabelKey as a, computeDrillFilter as o, extractRecords as s, isDrillEnabled as c, relabelDimensions as l, resolveContextTokens as u, resolveDrillTitle as d, resolveFilterPlaceholders as f, shiftFilterByCompareTo as p } from "@object-ui/core";
|
|
2
|
+
import * as m from "react";
|
|
3
|
+
import h, { Suspense as g, useCallback as ee, useContext as te, useEffect as ne, useMemo as _, useRef as re, useState as v } from "react";
|
|
4
|
+
import { Button as ie, ChartSkeleton as y, Dialog as ae, DialogContent as b, DialogHeader as x, DialogTitle as S, RefreshIndicator as C, Sheet as oe, SheetContent as se, SheetHeader as ce, SheetTitle as le, Skeleton as ue } from "@object-ui/components";
|
|
5
|
+
import { Fragment as w, jsx as T, jsxs as E } from "react/jsx-runtime";
|
|
6
|
+
import { Area as de, AreaChart as fe, Bar as pe, BarChart as D, Brush as me, CartesianGrid as he, Cell as O, ComposedChart as ge, Funnel as _e, FunnelChart as ve, LabelList as ye, Legend as k, Line as be, LineChart as xe, Pie as Se, PieChart as Ce, PolarAngleAxis as we, PolarGrid as Te, PolarRadiusAxis as Ee, Radar as De, RadarChart as Oe, ReferenceArea as ke, ReferenceLine as Ae, ResponsiveContainer as A, Sankey as je, Scatter as Me, ScatterChart as j, Tooltip as M, Treemap as Ne, XAxis as N, YAxis as P, ZAxis as Pe } from "recharts";
|
|
7
|
+
import { SchemaRenderer as Fe, SchemaRendererContext as Ie, useDataScope as Le, useDrillNavigation as Re, useFilterScope as ze } from "@object-ui/react";
|
|
8
|
+
import { AlertCircle as Be, ArrowUpRight as Ve } from "lucide-react";
|
|
9
|
+
import { useSafeFieldLabel as He, useSafeTranslate as F } from "@object-ui/i18n";
|
|
10
10
|
//#region \0rolldown/runtime.js
|
|
11
|
-
var
|
|
11
|
+
var I = Object.defineProperty, L = (e, t, n) => () => {
|
|
12
12
|
if (n) throw n[0];
|
|
13
13
|
try {
|
|
14
14
|
return e && (t = e(e = 0)), t;
|
|
15
15
|
} catch (e) {
|
|
16
16
|
throw n = [e], e;
|
|
17
17
|
}
|
|
18
|
-
},
|
|
18
|
+
}, R = (e, t) => {
|
|
19
19
|
let n = {};
|
|
20
|
-
for (var r in e)
|
|
20
|
+
for (var r in e) I(n, r, {
|
|
21
21
|
get: e[r],
|
|
22
22
|
enumerable: !0
|
|
23
23
|
});
|
|
24
|
-
return t ||
|
|
25
|
-
}
|
|
26
|
-
|
|
24
|
+
return t || I(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/normalizeChartSchema.ts
|
|
28
|
+
function z(e) {
|
|
29
|
+
let t = W(e);
|
|
30
|
+
if (t) return t;
|
|
31
|
+
if (U(e)) return Object.values(e).find((e) => typeof e == "string" && e);
|
|
32
|
+
}
|
|
33
|
+
function B(e) {
|
|
34
|
+
if (!U(e)) return;
|
|
35
|
+
let t = {}, n = W(e.field);
|
|
36
|
+
n && (t.field = n);
|
|
37
|
+
let r = W(e.format);
|
|
38
|
+
r && (t.format = r);
|
|
39
|
+
let i = G(e.min);
|
|
40
|
+
i !== void 0 && (t.min = i);
|
|
41
|
+
let a = G(e.max);
|
|
42
|
+
a !== void 0 && (t.max = a);
|
|
43
|
+
let o = G(e.stepSize);
|
|
44
|
+
o !== void 0 && o > 0 && (t.stepSize = o), typeof e.showGridLines == "boolean" && (t.showGridLines = e.showGridLines), typeof e.logarithmic == "boolean" && (t.logarithmic = e.logarithmic);
|
|
45
|
+
let s = W(e.position);
|
|
46
|
+
(s === "left" || s === "right" || s === "top" || s === "bottom") && (t.position = s);
|
|
47
|
+
let c = z(e.title);
|
|
48
|
+
return c && (t.title = c), t;
|
|
49
|
+
}
|
|
50
|
+
function V(e) {
|
|
51
|
+
if (!U(e)) {
|
|
52
|
+
let t = W(e);
|
|
53
|
+
return t ? { dataKey: t } : void 0;
|
|
54
|
+
}
|
|
55
|
+
let t = W(e.dataKey) ?? W(e.name);
|
|
56
|
+
if (!t) return;
|
|
57
|
+
let n = { dataKey: t }, r = z(e.label);
|
|
58
|
+
r && (n.label = r);
|
|
59
|
+
let i = W(e.chartType) ?? W(e.type);
|
|
60
|
+
(i === "bar" || i === "line" || i === "area") && (n.chartType = i);
|
|
61
|
+
let a = W(e.variant);
|
|
62
|
+
(a === "comparison" || a === "current" || a === "primary") && (n.variant = a);
|
|
63
|
+
let o = G(e.opacity);
|
|
64
|
+
o !== void 0 && (n.opacity = o);
|
|
65
|
+
let s = W(e.dashArray);
|
|
66
|
+
s && (n.dashArray = s);
|
|
67
|
+
let c = W(e.stack);
|
|
68
|
+
c && (n.stack = c);
|
|
69
|
+
let l = W(e.yAxis);
|
|
70
|
+
(l === "left" || l === "right") && (n.yAxis = l);
|
|
71
|
+
let u = W(e.color);
|
|
72
|
+
return u && (n.color = u), n;
|
|
73
|
+
}
|
|
74
|
+
function Ue(e) {
|
|
75
|
+
if (!U(e)) return {};
|
|
76
|
+
let t = {}, n = W(e.type), r = W(e.chartType) ?? W(e.specType) ?? (n && Ze.has(n) ? n : void 0);
|
|
77
|
+
r && Je.has(r) && (t.chartType = r);
|
|
78
|
+
let i = e.xAxis, a = B(i);
|
|
79
|
+
a && (a.format || a.title || a.showGridLines !== void 0) && (t.xAxis = a);
|
|
80
|
+
let o = W(e.xAxisKey) ?? a?.field ?? W(i);
|
|
81
|
+
o && (t.xAxisKey = o);
|
|
82
|
+
let s = (Array.isArray(e.yAxis) ? e.yAxis : e.yAxis === void 0 ? [] : [e.yAxis]).map((e) => B(e) ?? (W(e) ? { field: W(e) } : void 0)).filter((e) => !!e);
|
|
83
|
+
s.length && (t.yAxes = s);
|
|
84
|
+
let c = (Array.isArray(e.series) ? e.series : Array.isArray(e.categories) ? e.categories : void 0)?.map(V).filter((e) => !!e);
|
|
85
|
+
if (!c?.length) {
|
|
86
|
+
let e = s.filter((e) => e.field).map((e, t) => ({
|
|
87
|
+
dataKey: e.field,
|
|
88
|
+
...e.title ? { label: e.title } : {},
|
|
89
|
+
...t > 0 || e.position === "right" ? { yAxis: "right" } : {}
|
|
90
|
+
}));
|
|
91
|
+
e.length && (c = e);
|
|
92
|
+
}
|
|
93
|
+
c?.length && (t.series = c), typeof e.showLegend == "boolean" && (t.showLegend = e.showLegend), typeof e.showDataLabels == "boolean" && (t.showDataLabels = e.showDataLabels);
|
|
94
|
+
let l = z(e.title);
|
|
95
|
+
l && (t.title = l);
|
|
96
|
+
let u = z(e.subtitle);
|
|
97
|
+
u && (t.subtitle = u);
|
|
98
|
+
let d = z(e.description);
|
|
99
|
+
d && (t.description = d);
|
|
100
|
+
let f = G(e.height);
|
|
101
|
+
return f !== void 0 && f > 0 && (t.height = f), Array.isArray(e.annotations) && e.annotations.length && (t.annotations = e.annotations.filter(U)), U(e.interaction) && (t.interaction = e.interaction), t;
|
|
102
|
+
}
|
|
103
|
+
function We(e) {
|
|
104
|
+
if (e === "bar" || e === "column") return "bar";
|
|
105
|
+
if (e === "line") return "line";
|
|
106
|
+
if (e === "area") return "area";
|
|
107
|
+
}
|
|
108
|
+
function Ge(e, t) {
|
|
109
|
+
if (e === "combo") return "combo";
|
|
110
|
+
let n = We(e);
|
|
111
|
+
if (!n || !t || t.length < 2) return e;
|
|
112
|
+
let r = t.map((e) => e.chartType ?? n);
|
|
113
|
+
return new Set(r).size > 1 ? "combo" : e;
|
|
114
|
+
}
|
|
115
|
+
function H(e) {
|
|
116
|
+
if (!e) return;
|
|
117
|
+
let t = e.includes("%"), n = /^([$£€¥₹])/.exec(e), r = e.includes(","), i = /\.(0+)/.exec(e)?.[1].length ?? 0, a = {
|
|
118
|
+
$: "USD",
|
|
119
|
+
"£": "GBP",
|
|
120
|
+
"€": "EUR",
|
|
121
|
+
"¥": "CNY",
|
|
122
|
+
"₹": "INR"
|
|
123
|
+
};
|
|
124
|
+
if (!t && !n && !r && i === 0) return;
|
|
125
|
+
let o = {
|
|
126
|
+
minimumFractionDigits: i,
|
|
127
|
+
maximumFractionDigits: i,
|
|
128
|
+
useGrouping: r
|
|
129
|
+
};
|
|
130
|
+
return t ? o.style = "percent" : n && (o.style = "currency", o.currency = a[n[1]] ?? "USD"), (e) => {
|
|
131
|
+
let t = typeof e == "number" ? e : Number(e);
|
|
132
|
+
if (!Number.isFinite(t)) return e == null ? "" : String(e);
|
|
133
|
+
try {
|
|
134
|
+
return new Intl.NumberFormat(void 0, o).format(t);
|
|
135
|
+
} catch {
|
|
136
|
+
return String(t);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function Ke(e, t) {
|
|
141
|
+
let n = e?.stepSize;
|
|
142
|
+
if (!n || n <= 0) return;
|
|
143
|
+
let r = t.filter((e) => Number.isFinite(e)), i = r.length ? Math.min(...r) : void 0, a = r.length ? Math.max(...r) : void 0, o = e.min ?? Math.min(0, i ?? 0), s = e.max ?? a;
|
|
144
|
+
if (s === void 0 || !Number.isFinite(o) || !Number.isFinite(s) || s < o) return;
|
|
145
|
+
let c = Math.floor(o / n) * n, l = e.max === void 0 ? Math.ceil(s / n) * n : e.max, u = Math.floor((l - c) / n + 1e-9) + 1;
|
|
146
|
+
if (u < 1 || u > Qe) return;
|
|
147
|
+
let d = [];
|
|
148
|
+
for (let e = 0; e < u; e++) d.push(Number((c + e * n).toPrecision(12)));
|
|
149
|
+
return e.max !== void 0 && d[d.length - 1] < e.max && d.push(e.max), d;
|
|
150
|
+
}
|
|
151
|
+
function qe(e) {
|
|
152
|
+
if (!e) return;
|
|
153
|
+
let { min: t, max: n } = e;
|
|
154
|
+
if (!(t === void 0 && n === void 0)) return [t ?? "auto", n ?? "auto"];
|
|
155
|
+
}
|
|
156
|
+
var Je, Ye, Xe, Ze, U, W, G, Qe, $e = L((() => {
|
|
157
|
+
Je = /* @__PURE__ */ new Set([
|
|
158
|
+
"bar",
|
|
159
|
+
"column",
|
|
160
|
+
"horizontal-bar",
|
|
161
|
+
"line",
|
|
162
|
+
"area",
|
|
163
|
+
"pie",
|
|
164
|
+
"donut",
|
|
165
|
+
"funnel",
|
|
166
|
+
"radar",
|
|
167
|
+
"scatter",
|
|
168
|
+
"treemap",
|
|
169
|
+
"sankey",
|
|
170
|
+
"combo"
|
|
171
|
+
]), Ye = /* @__PURE__ */ new Set([
|
|
172
|
+
"gauge",
|
|
173
|
+
"solid-gauge",
|
|
174
|
+
"metric",
|
|
175
|
+
"kpi",
|
|
176
|
+
"bullet"
|
|
177
|
+
]), Xe = /* @__PURE__ */ new Set(["table", "pivot"]), Ze = /* @__PURE__ */ new Set([
|
|
178
|
+
...Je,
|
|
179
|
+
...Ye,
|
|
180
|
+
...Xe
|
|
181
|
+
]), U = (e) => !!e && typeof e == "object" && !Array.isArray(e), W = (e) => typeof e == "string" && e ? e : void 0, G = (e) => typeof e == "number" && Number.isFinite(e) ? e : void 0, Qe = 200;
|
|
182
|
+
})), et = /* @__PURE__ */ R({ default: () => nt });
|
|
183
|
+
function tt(e, t = 14) {
|
|
27
184
|
return e.length > t ? `${e.slice(0, t - 1)}…` : e;
|
|
28
185
|
}
|
|
29
|
-
function
|
|
30
|
-
let r = String(n?.value ?? ""), i =
|
|
31
|
-
return /* @__PURE__ */
|
|
186
|
+
function K({ x: e, y: t, payload: n }) {
|
|
187
|
+
let r = String(n?.value ?? ""), i = tt(r);
|
|
188
|
+
return /* @__PURE__ */ T("g", {
|
|
32
189
|
transform: `translate(${e},${t})`,
|
|
33
|
-
children: /* @__PURE__ */
|
|
190
|
+
children: /* @__PURE__ */ E("text", {
|
|
34
191
|
dy: 10,
|
|
35
192
|
textAnchor: "end",
|
|
36
193
|
transform: "rotate(-32)",
|
|
37
194
|
fill: "hsl(var(--muted-foreground))",
|
|
38
195
|
fontSize: 11,
|
|
39
196
|
fontFamily: "monospace",
|
|
40
|
-
children: [r !== i && /* @__PURE__ */
|
|
197
|
+
children: [r !== i && /* @__PURE__ */ T("title", { children: r }), i]
|
|
41
198
|
})
|
|
42
199
|
});
|
|
43
200
|
}
|
|
44
|
-
function
|
|
201
|
+
function nt({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height: r = 400, className: i = "", color: a = "hsl(var(--primary))" }) {
|
|
45
202
|
let o = e.map((e) => String(e?.[n] ?? "")), s = o.length > 4 || o.some((e) => e.length > 8);
|
|
46
|
-
return /* @__PURE__ */
|
|
203
|
+
return /* @__PURE__ */ T("div", {
|
|
47
204
|
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}`,
|
|
48
|
-
children: /* @__PURE__ */
|
|
205
|
+
children: /* @__PURE__ */ T(A, {
|
|
49
206
|
width: "100%",
|
|
50
207
|
height: r,
|
|
51
|
-
children: /* @__PURE__ */
|
|
208
|
+
children: /* @__PURE__ */ E(D, {
|
|
52
209
|
data: e,
|
|
53
210
|
margin: {
|
|
54
211
|
top: 10,
|
|
@@ -57,66 +214,66 @@ function Pe({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
|
|
|
57
214
|
bottom: s ? 24 : 5
|
|
58
215
|
},
|
|
59
216
|
children: [
|
|
60
|
-
/* @__PURE__ */
|
|
217
|
+
/* @__PURE__ */ E("defs", { children: [/* @__PURE__ */ E("linearGradient", {
|
|
61
218
|
id: "barGradient",
|
|
62
219
|
x1: "0",
|
|
63
220
|
y1: "0",
|
|
64
221
|
x2: "0",
|
|
65
222
|
y2: "1",
|
|
66
223
|
children: [
|
|
67
|
-
/* @__PURE__ */
|
|
224
|
+
/* @__PURE__ */ T("stop", {
|
|
68
225
|
offset: "0%",
|
|
69
226
|
stopColor: a,
|
|
70
227
|
stopOpacity: 1
|
|
71
228
|
}),
|
|
72
|
-
/* @__PURE__ */
|
|
229
|
+
/* @__PURE__ */ T("stop", {
|
|
73
230
|
offset: "90%",
|
|
74
231
|
stopColor: a,
|
|
75
232
|
stopOpacity: .6
|
|
76
233
|
}),
|
|
77
|
-
/* @__PURE__ */
|
|
234
|
+
/* @__PURE__ */ T("stop", {
|
|
78
235
|
offset: "100%",
|
|
79
236
|
stopColor: a,
|
|
80
237
|
stopOpacity: .3
|
|
81
238
|
})
|
|
82
239
|
]
|
|
83
|
-
}), /* @__PURE__ */
|
|
240
|
+
}), /* @__PURE__ */ E("filter", {
|
|
84
241
|
id: "glow",
|
|
85
242
|
height: "130%",
|
|
86
243
|
children: [
|
|
87
|
-
/* @__PURE__ */
|
|
244
|
+
/* @__PURE__ */ T("feGaussianBlur", {
|
|
88
245
|
in: "SourceAlpha",
|
|
89
246
|
stdDeviation: "3",
|
|
90
247
|
result: "blur"
|
|
91
248
|
}),
|
|
92
|
-
/* @__PURE__ */
|
|
249
|
+
/* @__PURE__ */ T("feOffset", {
|
|
93
250
|
in: "blur",
|
|
94
251
|
dx: "0",
|
|
95
252
|
dy: "0",
|
|
96
253
|
result: "offsetBlur"
|
|
97
254
|
}),
|
|
98
|
-
/* @__PURE__ */
|
|
255
|
+
/* @__PURE__ */ T("feFlood", {
|
|
99
256
|
floodColor: a,
|
|
100
257
|
floodOpacity: "0.5",
|
|
101
258
|
result: "offsetColor"
|
|
102
259
|
}),
|
|
103
|
-
/* @__PURE__ */
|
|
260
|
+
/* @__PURE__ */ T("feComposite", {
|
|
104
261
|
in: "offsetColor",
|
|
105
262
|
in2: "offsetBlur",
|
|
106
263
|
operator: "in",
|
|
107
264
|
result: "offsetBlur"
|
|
108
265
|
}),
|
|
109
|
-
/* @__PURE__ */
|
|
266
|
+
/* @__PURE__ */ E("feMerge", { children: [/* @__PURE__ */ T("feMergeNode", { in: "offsetBlur" }), /* @__PURE__ */ T("feMergeNode", { in: "SourceGraphic" })] })
|
|
110
267
|
]
|
|
111
268
|
})] }),
|
|
112
|
-
/* @__PURE__ */
|
|
269
|
+
/* @__PURE__ */ T(he, {
|
|
113
270
|
strokeDasharray: "3 3",
|
|
114
271
|
stroke: "hsl(var(--border))",
|
|
115
272
|
vertical: !1
|
|
116
273
|
}),
|
|
117
|
-
/* @__PURE__ */
|
|
274
|
+
/* @__PURE__ */ T(N, {
|
|
118
275
|
dataKey: n,
|
|
119
|
-
tick: s ? /* @__PURE__ */
|
|
276
|
+
tick: s ? /* @__PURE__ */ T(K, {}) : {
|
|
120
277
|
fill: "hsl(var(--muted-foreground))",
|
|
121
278
|
fontSize: 12,
|
|
122
279
|
fontFamily: "monospace"
|
|
@@ -127,7 +284,7 @@ function Pe({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
|
|
|
127
284
|
height: s ? 56 : void 0,
|
|
128
285
|
dy: s ? void 0 : 10
|
|
129
286
|
}),
|
|
130
|
-
/* @__PURE__ */
|
|
287
|
+
/* @__PURE__ */ T(P, {
|
|
131
288
|
tick: {
|
|
132
289
|
fill: "hsl(var(--muted-foreground))",
|
|
133
290
|
fontSize: 12,
|
|
@@ -136,7 +293,7 @@ function Pe({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
|
|
|
136
293
|
tickLine: !1,
|
|
137
294
|
axisLine: !1
|
|
138
295
|
}),
|
|
139
|
-
/* @__PURE__ */
|
|
296
|
+
/* @__PURE__ */ T(M, {
|
|
140
297
|
cursor: {
|
|
141
298
|
fill: "hsl(var(--muted))",
|
|
142
299
|
opacity: .2
|
|
@@ -151,11 +308,11 @@ function Pe({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
|
|
|
151
308
|
},
|
|
152
309
|
itemStyle: { color: "hsl(var(--primary))" }
|
|
153
310
|
}),
|
|
154
|
-
/* @__PURE__ */
|
|
311
|
+
/* @__PURE__ */ T(k, { wrapperStyle: {
|
|
155
312
|
paddingTop: "20px",
|
|
156
313
|
fontFamily: "monospace"
|
|
157
314
|
} }),
|
|
158
|
-
/* @__PURE__ */
|
|
315
|
+
/* @__PURE__ */ T(pe, {
|
|
159
316
|
dataKey: t,
|
|
160
317
|
fill: "url(#barGradient)",
|
|
161
318
|
radius: [
|
|
@@ -172,48 +329,63 @@ function Pe({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
|
|
|
172
329
|
})
|
|
173
330
|
});
|
|
174
331
|
}
|
|
175
|
-
var
|
|
332
|
+
var rt = L((() => {}));
|
|
176
333
|
//#endregion
|
|
177
334
|
//#region src/ChartContainerImpl.tsx
|
|
178
|
-
function
|
|
179
|
-
let e =
|
|
335
|
+
function it() {
|
|
336
|
+
let e = m.useContext(ct);
|
|
180
337
|
if (!e) throw Error("useChart must be used within a <ChartContainer />");
|
|
181
338
|
return e;
|
|
182
339
|
}
|
|
183
|
-
function
|
|
184
|
-
let
|
|
185
|
-
return
|
|
340
|
+
function q({ id: e, className: t, children: n, config: r, disableSettleRemount: i, ...a }) {
|
|
341
|
+
let o = m.useId(), s = `chart-${e || o.replace(/:/g, "")}`, c = m.useRef(null), [l, u] = m.useState(0);
|
|
342
|
+
return m.useEffect(() => {
|
|
343
|
+
if (i) return;
|
|
344
|
+
let e = c.current;
|
|
345
|
+
if (e == null || typeof ResizeObserver > "u") return;
|
|
346
|
+
let t = !1, n, r = new ResizeObserver((e) => {
|
|
347
|
+
if (t) return;
|
|
348
|
+
let i = e[0]?.contentRect;
|
|
349
|
+
i == null || i.width <= 0 || i.height <= 0 || (n != null && clearTimeout(n), n = setTimeout(() => {
|
|
350
|
+
t = !0, r.disconnect(), u((e) => e + 1);
|
|
351
|
+
}, 80));
|
|
352
|
+
});
|
|
353
|
+
return r.observe(e), () => {
|
|
354
|
+
t = !0, n != null && clearTimeout(n), r.disconnect();
|
|
355
|
+
};
|
|
356
|
+
}, [i]), /* @__PURE__ */ T(ct.Provider, {
|
|
186
357
|
value: { config: r },
|
|
187
|
-
children: /* @__PURE__ */
|
|
358
|
+
children: /* @__PURE__ */ E("div", {
|
|
359
|
+
ref: c,
|
|
188
360
|
"data-slot": "chart",
|
|
189
|
-
"data-chart":
|
|
190
|
-
className:
|
|
361
|
+
"data-chart": s,
|
|
362
|
+
className: J("block w-full h-[350px] text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground", t),
|
|
191
363
|
style: {
|
|
192
364
|
minHeight: 280,
|
|
193
365
|
minWidth: 0,
|
|
194
|
-
...
|
|
366
|
+
...a.style
|
|
195
367
|
},
|
|
196
|
-
...
|
|
197
|
-
children: [/* @__PURE__ */
|
|
198
|
-
id:
|
|
368
|
+
...a,
|
|
369
|
+
children: [/* @__PURE__ */ T(lt, {
|
|
370
|
+
id: s,
|
|
199
371
|
config: r
|
|
200
|
-
}), /* @__PURE__ */
|
|
372
|
+
}), /* @__PURE__ */ T(A, {
|
|
201
373
|
width: "100%",
|
|
202
374
|
height: "100%",
|
|
203
375
|
children: n
|
|
204
|
-
})]
|
|
376
|
+
}, l)]
|
|
205
377
|
})
|
|
206
378
|
});
|
|
207
379
|
}
|
|
208
|
-
function
|
|
209
|
-
let { config:
|
|
380
|
+
function at({ active: e, payload: t, className: n, indicator: r = "dot", hideLabel: i = !1, hideIndicator: a = !1, label: o, labelFormatter: s, labelClassName: c, formatter: l, color: u, nameKey: d, labelKey: f }) {
|
|
381
|
+
let { config: p } = it(), h = m.useMemo(() => {
|
|
210
382
|
if (i || !t?.length) return null;
|
|
211
|
-
let [e] = t, n = `${
|
|
212
|
-
return s ? /* @__PURE__ */
|
|
213
|
-
className:
|
|
383
|
+
let [e] = t, n = `${f || e?.dataKey || e?.name || "value"}`, r = st(p, e, n), a = !f && typeof o == "string" ? p[o]?.label || o : r?.label;
|
|
384
|
+
return s ? /* @__PURE__ */ T("div", {
|
|
385
|
+
className: J("font-medium", c),
|
|
214
386
|
children: s(a, t)
|
|
215
|
-
}) : a ? /* @__PURE__ */
|
|
216
|
-
className:
|
|
387
|
+
}) : a ? /* @__PURE__ */ T("div", {
|
|
388
|
+
className: J("font-medium", c),
|
|
217
389
|
children: a
|
|
218
390
|
}) : null;
|
|
219
391
|
}, [
|
|
@@ -222,34 +394,34 @@ function G({ active: e, payload: t, className: n, indicator: r = "dot", hideLabe
|
|
|
222
394
|
t,
|
|
223
395
|
i,
|
|
224
396
|
c,
|
|
225
|
-
|
|
226
|
-
|
|
397
|
+
p,
|
|
398
|
+
f
|
|
227
399
|
]);
|
|
228
400
|
if (!e || !t?.length) return null;
|
|
229
401
|
let g = t.length === 1 && r !== "dot";
|
|
230
|
-
return /* @__PURE__ */
|
|
231
|
-
className:
|
|
232
|
-
children: [g ? null : h, /* @__PURE__ */
|
|
402
|
+
return /* @__PURE__ */ E("div", {
|
|
403
|
+
className: J("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),
|
|
404
|
+
children: [g ? null : h, /* @__PURE__ */ T("div", {
|
|
233
405
|
className: "grid gap-1.5",
|
|
234
406
|
children: t.filter((e) => e.type !== "none").map((e, t) => {
|
|
235
|
-
let n = `${d || e.name || e.dataKey || "value"}`, i =
|
|
236
|
-
return /* @__PURE__ */
|
|
237
|
-
className:
|
|
238
|
-
children: l && e?.value !== void 0 && e.name ? l(e.value, e.name, e, t, e.payload) : /* @__PURE__ */ w
|
|
239
|
-
className:
|
|
407
|
+
let n = `${d || e.name || e.dataKey || "value"}`, i = st(p, e, n), o = u || e.payload.fill || e.color;
|
|
408
|
+
return /* @__PURE__ */ T("div", {
|
|
409
|
+
className: J("[&>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" : ""),
|
|
410
|
+
children: l && e?.value !== void 0 && e.name ? l(e.value, e.name, e, t, e.payload) : /* @__PURE__ */ E(w, { children: [i?.icon ? /* @__PURE__ */ T(i.icon, {}) : !a && /* @__PURE__ */ T("div", {
|
|
411
|
+
className: J("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" : ""),
|
|
240
412
|
style: {
|
|
241
413
|
"--color-bg": o,
|
|
242
414
|
"--color-border": o
|
|
243
415
|
}
|
|
244
|
-
}), /* @__PURE__ */
|
|
245
|
-
className:
|
|
246
|
-
children: [/* @__PURE__ */
|
|
416
|
+
}), /* @__PURE__ */ E("div", {
|
|
417
|
+
className: J("flex flex-1 justify-between leading-none", g ? "items-end" : "items-center"),
|
|
418
|
+
children: [/* @__PURE__ */ E("div", {
|
|
247
419
|
className: "grid gap-1.5",
|
|
248
|
-
children: [g ? h : null, /* @__PURE__ */
|
|
420
|
+
children: [g ? h : null, /* @__PURE__ */ T("span", {
|
|
249
421
|
className: "text-muted-foreground",
|
|
250
422
|
children: i?.label || e.name
|
|
251
423
|
})]
|
|
252
|
-
}), e.value && /* @__PURE__ */
|
|
424
|
+
}), e.value && /* @__PURE__ */ T("span", {
|
|
253
425
|
className: "text-foreground font-mono font-medium tabular-nums",
|
|
254
426
|
children: e.value.toLocaleString()
|
|
255
427
|
})]
|
|
@@ -259,15 +431,15 @@ function G({ active: e, payload: t, className: n, indicator: r = "dot", hideLabe
|
|
|
259
431
|
})]
|
|
260
432
|
});
|
|
261
433
|
}
|
|
262
|
-
function
|
|
263
|
-
let { config: a } =
|
|
264
|
-
return n?.length ? /* @__PURE__ */
|
|
265
|
-
className:
|
|
434
|
+
function ot({ className: e, hideIcon: t = !1, payload: n, verticalAlign: r = "bottom", nameKey: i }) {
|
|
435
|
+
let { config: a } = it();
|
|
436
|
+
return n?.length ? /* @__PURE__ */ T("div", {
|
|
437
|
+
className: J("flex items-center justify-center gap-4", r === "top" ? "pb-3" : "pt-3", e),
|
|
266
438
|
children: n.filter((e) => e.type !== "none").map((e) => {
|
|
267
|
-
let n = `${i || e.dataKey || "value"}`, r =
|
|
268
|
-
return /* @__PURE__ */
|
|
269
|
-
className:
|
|
270
|
-
children: [r?.icon && !t ? /* @__PURE__ */
|
|
439
|
+
let n = `${i || e.dataKey || "value"}`, r = st(a, e, n);
|
|
440
|
+
return /* @__PURE__ */ E("div", {
|
|
441
|
+
className: J("[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"),
|
|
442
|
+
children: [r?.icon && !t ? /* @__PURE__ */ T(r.icon, {}) : /* @__PURE__ */ T("div", {
|
|
271
443
|
className: "h-2 w-2 shrink-0 rounded-[2px]",
|
|
272
444
|
style: { backgroundColor: e.color }
|
|
273
445
|
}), r?.label]
|
|
@@ -275,18 +447,18 @@ function K({ className: e, hideIcon: t = !1, payload: n, verticalAlign: r = "bot
|
|
|
275
447
|
})
|
|
276
448
|
}) : null;
|
|
277
449
|
}
|
|
278
|
-
function
|
|
450
|
+
function st(e, t, n) {
|
|
279
451
|
if (typeof t != "object" || !t) return;
|
|
280
452
|
let r = "payload" in t && typeof t.payload == "object" && t.payload !== null ? t.payload : void 0, i = n;
|
|
281
453
|
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];
|
|
282
454
|
}
|
|
283
|
-
var
|
|
284
|
-
|
|
455
|
+
var J, Y, ct, lt, X, Z, ut = L((() => {
|
|
456
|
+
J = (...e) => e.filter(Boolean).join(" "), Y = {
|
|
285
457
|
light: "",
|
|
286
458
|
dark: ".dark"
|
|
287
|
-
},
|
|
459
|
+
}, ct = m.createContext(null), lt = ({ id: e, config: t }) => {
|
|
288
460
|
let n = Object.entries(t).filter(([, e]) => e.theme || e.color);
|
|
289
|
-
return n.length ? /* @__PURE__ */
|
|
461
|
+
return n.length ? /* @__PURE__ */ T("style", { dangerouslySetInnerHTML: { __html: Object.entries(Y).map(([t, r]) => `
|
|
290
462
|
${r} [data-chart=${e}] {
|
|
291
463
|
${n.map(([e, n]) => {
|
|
292
464
|
let r = n.theme?.[t] || n.color;
|
|
@@ -294,124 +466,168 @@ ${n.map(([e, n]) => {
|
|
|
294
466
|
}).join("\n")}
|
|
295
467
|
}
|
|
296
468
|
`).join("\n") } }) : null;
|
|
297
|
-
},
|
|
469
|
+
}, X = M, Z = k;
|
|
298
470
|
}));
|
|
299
471
|
//#endregion
|
|
300
472
|
//#region src/chartDrillEvents.ts
|
|
301
|
-
function
|
|
473
|
+
function dt(e) {
|
|
302
474
|
return e?.[0]?.dataKey || "value";
|
|
303
475
|
}
|
|
304
|
-
function
|
|
476
|
+
function ft(e, t, n) {
|
|
305
477
|
if (!e) return null;
|
|
306
478
|
let r = e.payload ?? e, i = r?.[t];
|
|
307
479
|
if (i == null) return null;
|
|
308
|
-
let a =
|
|
480
|
+
let a = dt(n);
|
|
309
481
|
return {
|
|
310
482
|
category: String(i),
|
|
311
483
|
series: a,
|
|
312
484
|
value: typeof r?.[a] == "number" ? r[a] : void 0
|
|
313
485
|
};
|
|
314
486
|
}
|
|
315
|
-
function
|
|
487
|
+
function pt(e, t) {
|
|
316
488
|
if (!e) return null;
|
|
317
489
|
let n = e.name ?? e.payload?.name ?? e.root?.name;
|
|
318
490
|
if (n == null) return null;
|
|
319
491
|
let r = e.value ?? e.size ?? e.payload?.size;
|
|
320
492
|
return {
|
|
321
493
|
category: String(n),
|
|
322
|
-
series:
|
|
494
|
+
series: dt(t),
|
|
323
495
|
value: typeof r == "number" ? r : void 0
|
|
324
496
|
};
|
|
325
497
|
}
|
|
326
|
-
function
|
|
498
|
+
function mt(e, t) {
|
|
327
499
|
if (!e) return null;
|
|
328
500
|
let n = e.payload ?? e, r = n?.name;
|
|
329
501
|
return r == null || n?.depth === 0 ? null : {
|
|
330
502
|
category: String(r),
|
|
331
|
-
series:
|
|
503
|
+
series: dt(t),
|
|
332
504
|
value: typeof n?.value == "number" ? n.value : void 0
|
|
333
505
|
};
|
|
334
506
|
}
|
|
335
|
-
var
|
|
336
|
-
function
|
|
337
|
-
let
|
|
338
|
-
|
|
507
|
+
var ht = L((() => {})), gt = /* @__PURE__ */ R({ default: () => xt });
|
|
508
|
+
function _t(e) {
|
|
509
|
+
let { x: t, y: n, width: r, height: i, name: a, fill: o } = e;
|
|
510
|
+
return r <= 0 || i <= 0 ? null : /* @__PURE__ */ E("g", { children: [/* @__PURE__ */ T("rect", {
|
|
511
|
+
x: t,
|
|
512
|
+
y: n,
|
|
513
|
+
width: r,
|
|
514
|
+
height: i,
|
|
515
|
+
fill: o,
|
|
516
|
+
stroke: "hsl(var(--background))",
|
|
517
|
+
strokeWidth: 2
|
|
518
|
+
}), r > 48 && i > 18 ? /* @__PURE__ */ T("text", {
|
|
519
|
+
x: t + 6,
|
|
520
|
+
y: n + 18,
|
|
521
|
+
fill: "#fff",
|
|
522
|
+
fontSize: 12,
|
|
523
|
+
className: "pointer-events-none",
|
|
524
|
+
children: a
|
|
525
|
+
}) : null] });
|
|
526
|
+
}
|
|
527
|
+
function vt({ title: e, subtitle: t, children: n }) {
|
|
528
|
+
return !e && !t ? /* @__PURE__ */ T(w, { children: n }) : /* @__PURE__ */ E("div", {
|
|
529
|
+
className: "flex h-full w-full flex-col",
|
|
530
|
+
children: [/* @__PURE__ */ E("div", {
|
|
531
|
+
className: "mb-2 shrink-0",
|
|
532
|
+
children: [e ? /* @__PURE__ */ T("div", {
|
|
533
|
+
className: "text-sm font-medium leading-tight text-foreground",
|
|
534
|
+
children: e
|
|
535
|
+
}) : null, t ? /* @__PURE__ */ T("div", {
|
|
536
|
+
className: "text-xs leading-tight text-muted-foreground",
|
|
537
|
+
children: t
|
|
538
|
+
}) : null]
|
|
539
|
+
}), /* @__PURE__ */ T("div", {
|
|
540
|
+
className: "min-h-0 flex-1",
|
|
541
|
+
children: n
|
|
542
|
+
})]
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i = "name", series: a = [], className: o = "", colors: s, categoryColors: c, categoryOrder: l, onChartClick: u, isAnimationActive: d, xAxis: f, yAxes: p, showLegend: h, showDataLabels: g, title: ee, subtitle: te, description: ne, height: _, annotations: re, interaction: v }) {
|
|
546
|
+
let ie = e === "column" ? "bar" : e, y = Ge(ie, a), ae = We(ie), b = Array.isArray(n) ? n : [], x = d === !1 ? { isAnimationActive: !1 } : {}, S = {
|
|
547
|
+
...d === !1 ? { disableSettleRemount: !0 } : {},
|
|
548
|
+
..._ ? { style: { height: _ } } : {},
|
|
549
|
+
...ne ? {
|
|
550
|
+
role: "img",
|
|
551
|
+
"aria-label": ne
|
|
552
|
+
} : {}
|
|
553
|
+
}, [C, oe] = m.useState(!1), se = m.useCallback((e) => {
|
|
554
|
+
if (!u || !e) return;
|
|
339
555
|
let t = Array.isArray(e.activePayload) ? e.activePayload[0] : void 0;
|
|
340
|
-
|
|
556
|
+
u({
|
|
341
557
|
category: e.activeLabel == null ? void 0 : String(e.activeLabel),
|
|
342
558
|
series: t?.dataKey ? String(t.dataKey) : void 0,
|
|
343
559
|
value: typeof t?.value == "number" ? t.value : void 0
|
|
344
560
|
});
|
|
345
|
-
}, [
|
|
346
|
-
if (!
|
|
347
|
-
let t = e.payload?.[
|
|
348
|
-
|
|
561
|
+
}, [u]), ce = m.useCallback((e) => {
|
|
562
|
+
if (!u || !e) return;
|
|
563
|
+
let t = e.payload?.[i], n = a[0]?.dataKey || "value";
|
|
564
|
+
u({
|
|
349
565
|
category: t == null ? void 0 : String(t),
|
|
350
566
|
series: n,
|
|
351
567
|
value: typeof e.payload?.[n] == "number" ? e.payload[n] : void 0
|
|
352
568
|
});
|
|
353
569
|
}, [
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
]),
|
|
358
|
-
onClick:
|
|
570
|
+
u,
|
|
571
|
+
i,
|
|
572
|
+
a
|
|
573
|
+
]), le = u ? {
|
|
574
|
+
onClick: se,
|
|
359
575
|
style: { cursor: "pointer" }
|
|
360
|
-
} : {},
|
|
361
|
-
onClick:
|
|
576
|
+
} : {}, ue = u ? {
|
|
577
|
+
onClick: ce,
|
|
362
578
|
style: { cursor: "pointer" }
|
|
363
|
-
} : {},
|
|
364
|
-
if (!
|
|
365
|
-
let t =
|
|
366
|
-
t &&
|
|
579
|
+
} : {}, k = m.useCallback((e, t, n) => c && c[e == null ? "" : String(e)] || n[t % n.length], [c]), A = m.useCallback((e) => {
|
|
580
|
+
if (!u) return;
|
|
581
|
+
let t = ft(e, i, a);
|
|
582
|
+
t && u(t);
|
|
367
583
|
}, [
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
]),
|
|
372
|
-
if (!
|
|
373
|
-
let t =
|
|
374
|
-
t &&
|
|
375
|
-
}, [
|
|
376
|
-
if (!
|
|
377
|
-
let t =
|
|
378
|
-
t &&
|
|
379
|
-
}, [
|
|
380
|
-
onClick:
|
|
584
|
+
u,
|
|
585
|
+
i,
|
|
586
|
+
a
|
|
587
|
+
]), Fe = m.useCallback((e) => {
|
|
588
|
+
if (!u) return;
|
|
589
|
+
let t = pt(e, a);
|
|
590
|
+
t && u(t);
|
|
591
|
+
}, [u, a]), Ie = m.useCallback((e) => {
|
|
592
|
+
if (!u) return;
|
|
593
|
+
let t = mt(e, a);
|
|
594
|
+
t && u(t);
|
|
595
|
+
}, [u, a]), Le = u ? {
|
|
596
|
+
onClick: A,
|
|
381
597
|
cursor: "pointer"
|
|
382
|
-
} : {},
|
|
383
|
-
onClick:
|
|
598
|
+
} : {}, Re = u ? {
|
|
599
|
+
onClick: Fe,
|
|
384
600
|
style: { cursor: "pointer" }
|
|
385
|
-
} : {},
|
|
386
|
-
onClick:
|
|
601
|
+
} : {}, ze = u ? {
|
|
602
|
+
onClick: Ie,
|
|
387
603
|
style: { cursor: "pointer" }
|
|
388
604
|
} : {};
|
|
389
|
-
|
|
390
|
-
let e = () =>
|
|
605
|
+
m.useEffect(() => {
|
|
606
|
+
let e = () => oe(window.innerWidth < 640);
|
|
391
607
|
return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
392
608
|
}, []);
|
|
393
|
-
let
|
|
394
|
-
bar:
|
|
395
|
-
"horizontal-bar":
|
|
396
|
-
line:
|
|
397
|
-
area:
|
|
398
|
-
pie:
|
|
399
|
-
donut:
|
|
400
|
-
radar:
|
|
401
|
-
scatter:
|
|
402
|
-
funnel:
|
|
403
|
-
combo:
|
|
404
|
-
treemap:
|
|
405
|
-
sankey:
|
|
406
|
-
}[
|
|
609
|
+
let Be = {
|
|
610
|
+
bar: D,
|
|
611
|
+
"horizontal-bar": D,
|
|
612
|
+
line: xe,
|
|
613
|
+
area: fe,
|
|
614
|
+
pie: Ce,
|
|
615
|
+
donut: Ce,
|
|
616
|
+
radar: Oe,
|
|
617
|
+
scatter: j,
|
|
618
|
+
funnel: ve,
|
|
619
|
+
combo: ge,
|
|
620
|
+
treemap: D,
|
|
621
|
+
sankey: D
|
|
622
|
+
}[y] || D, Ve = m.useCallback((e) => {
|
|
407
623
|
if (e == null || e === "") return "";
|
|
408
|
-
let t =
|
|
624
|
+
let t = r?.[String(e)]?.label;
|
|
409
625
|
if (t != null) return String(t);
|
|
410
|
-
let
|
|
411
|
-
if (/^\d{4}-\d{2}-\d{2}/.test(
|
|
412
|
-
let e = new Date(
|
|
626
|
+
let n = typeof e == "string" ? e : String(e);
|
|
627
|
+
if (/^\d{4}-\d{2}-\d{2}/.test(n)) {
|
|
628
|
+
let e = new Date(n);
|
|
413
629
|
if (!Number.isNaN(e.getTime())) {
|
|
414
|
-
let t = (
|
|
630
|
+
let t = (b.length > 1 ? Math.abs(new Date(String(b[b.length - 1][i] ?? "")).getTime() - new Date(String(b[0][i] ?? "")).getTime()) : 0) / (1e3 * 60 * 60 * 24);
|
|
415
631
|
try {
|
|
416
632
|
return t <= 62 ? e.toLocaleDateString(void 0, {
|
|
417
633
|
month: "short",
|
|
@@ -425,19 +641,19 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
425
641
|
}
|
|
426
642
|
}
|
|
427
643
|
}
|
|
428
|
-
return
|
|
644
|
+
return C && n.length > 8 ? n.slice(0, 8) + "…" : n;
|
|
429
645
|
}, [
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
]),
|
|
646
|
+
b,
|
|
647
|
+
i,
|
|
648
|
+
C,
|
|
649
|
+
r
|
|
650
|
+
]), He = m.useMemo(() => b.some((e) => String(e[i] || "").length > 5), [b, i]), F = () => Array.isArray(s) && s.length > 0 ? s : [
|
|
435
651
|
"hsl(var(--chart-1))",
|
|
436
652
|
"hsl(var(--chart-2))",
|
|
437
653
|
"hsl(var(--chart-3))",
|
|
438
654
|
"hsl(var(--chart-4))",
|
|
439
655
|
"hsl(var(--chart-5))"
|
|
440
|
-
],
|
|
656
|
+
], I = m.useCallback((e) => {
|
|
441
657
|
if (e == null || e === "") return "";
|
|
442
658
|
let t = typeof e == "number" ? e : Number(e);
|
|
443
659
|
if (!Number.isFinite(t)) return String(e);
|
|
@@ -449,149 +665,255 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
449
665
|
} catch {
|
|
450
666
|
return String(t);
|
|
451
667
|
}
|
|
452
|
-
}, []),
|
|
668
|
+
}, []), L = p?.[0], R = p && p.length > 1 ? p[1] : L?.position === "right" ? L : void 0, z = !!p && p.length > 1, B = m.useMemo(() => H(f?.format) ?? Ve, [f?.format, Ve]), V = m.useMemo(() => H(L?.format) ?? I, [L?.format, I]), Ue = m.useMemo(() => H(R?.format) ?? I, [R?.format, I]), Ze = m.useCallback((e) => {
|
|
669
|
+
let t = a.filter((t) => z ? (t.yAxis === "right" ? "right" : "left") === e : e === "left").map((e) => e.dataKey), n = [];
|
|
670
|
+
for (let e of b) for (let r of t) {
|
|
671
|
+
let t = Number(e?.[r]);
|
|
672
|
+
Number.isFinite(t) && n.push(t);
|
|
673
|
+
}
|
|
674
|
+
return n;
|
|
675
|
+
}, [
|
|
676
|
+
b,
|
|
677
|
+
a,
|
|
678
|
+
z
|
|
679
|
+
]), U = m.useCallback((e, t = "left") => {
|
|
680
|
+
if (!e) return {};
|
|
681
|
+
let n = qe(e), r = Ke(e, Ze(t));
|
|
682
|
+
return {
|
|
683
|
+
...r ? { ticks: r } : {},
|
|
684
|
+
...n ? { domain: n } : {},
|
|
685
|
+
...n ? { allowDataOverflow: !0 } : {},
|
|
686
|
+
...e.logarithmic ? {
|
|
687
|
+
scale: "log",
|
|
688
|
+
domain: n ?? [1, "auto"]
|
|
689
|
+
} : {},
|
|
690
|
+
...e.title ? { label: {
|
|
691
|
+
value: e.title,
|
|
692
|
+
angle: -90,
|
|
693
|
+
position: "insideLeft"
|
|
694
|
+
} } : {}
|
|
695
|
+
};
|
|
696
|
+
}, [Ze]), W = L?.showGridLines !== !1, G = {
|
|
697
|
+
vertical: f?.showGridLines === !0,
|
|
698
|
+
horizontal: W
|
|
699
|
+
}, Qe = h !== !1, $e = m.useMemo(() => {
|
|
700
|
+
if (!Array.isArray(re) || re.length === 0) return null;
|
|
701
|
+
let e = {
|
|
702
|
+
solid: void 0,
|
|
703
|
+
dashed: "4 4",
|
|
704
|
+
dotted: "1 4"
|
|
705
|
+
};
|
|
706
|
+
return re.map((t, n) => {
|
|
707
|
+
let r = t?.axis === "x", i = Q(String(t?.color || "hsl(var(--muted-foreground))")), a = e[String(t?.style ?? "dashed")], o = typeof t?.label == "string" ? t.label : void 0, s = o ? { label: {
|
|
708
|
+
value: o,
|
|
709
|
+
position: "insideTopRight",
|
|
710
|
+
fill: i,
|
|
711
|
+
fontSize: 11
|
|
712
|
+
} } : {};
|
|
713
|
+
return t?.type === "region" ? /* @__PURE__ */ T(ke, {
|
|
714
|
+
...r ? {
|
|
715
|
+
x1: t.value,
|
|
716
|
+
x2: t.endValue
|
|
717
|
+
} : {
|
|
718
|
+
y1: t.value,
|
|
719
|
+
y2: t.endValue
|
|
720
|
+
},
|
|
721
|
+
...z && !r ? { yAxisId: "left" } : {},
|
|
722
|
+
fill: i,
|
|
723
|
+
fillOpacity: .12,
|
|
724
|
+
stroke: i,
|
|
725
|
+
strokeOpacity: .35,
|
|
726
|
+
...s
|
|
727
|
+
}, `ann-${n}`) : /* @__PURE__ */ T(Ae, {
|
|
728
|
+
...r ? { x: t?.value } : { y: t?.value },
|
|
729
|
+
...z && !r ? { yAxisId: "left" } : {},
|
|
730
|
+
stroke: i,
|
|
731
|
+
strokeDasharray: a,
|
|
732
|
+
...s
|
|
733
|
+
}, `ann-${n}`);
|
|
734
|
+
});
|
|
735
|
+
}, [re, z]), et = v?.tooltips !== !1, tt = v?.brush === !0 ? /* @__PURE__ */ T(me, {
|
|
736
|
+
dataKey: i,
|
|
737
|
+
height: 24,
|
|
738
|
+
travellerWidth: 8,
|
|
739
|
+
stroke: "hsl(var(--muted-foreground))"
|
|
740
|
+
}) : null, K = (e) => g ? /* @__PURE__ */ T(ye, {
|
|
741
|
+
position: "top",
|
|
742
|
+
className: "fill-foreground",
|
|
743
|
+
fontSize: 11,
|
|
744
|
+
...e ? { formatter: e } : {}
|
|
745
|
+
}) : null, nt = m.useMemo(() => ({
|
|
453
746
|
tickLine: !1,
|
|
454
747
|
tickMargin: 10,
|
|
455
748
|
axisLine: !1,
|
|
456
749
|
interval: "preserveStartEnd",
|
|
457
|
-
minTickGap:
|
|
458
|
-
tickFormatter:
|
|
459
|
-
|
|
750
|
+
minTickGap: C ? 32 : 48,
|
|
751
|
+
tickFormatter: B,
|
|
752
|
+
...f?.title ? { label: {
|
|
753
|
+
value: f.title,
|
|
754
|
+
position: "insideBottom",
|
|
755
|
+
offset: -4
|
|
756
|
+
} } : {},
|
|
757
|
+
...!C && He && {
|
|
460
758
|
angle: -35,
|
|
461
759
|
textAnchor: "end",
|
|
462
760
|
height: 60
|
|
463
761
|
}
|
|
464
762
|
}), [
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
763
|
+
C,
|
|
764
|
+
He,
|
|
765
|
+
B,
|
|
766
|
+
f?.title
|
|
468
767
|
]);
|
|
469
|
-
if (
|
|
470
|
-
let e =
|
|
471
|
-
return
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
768
|
+
if (y && Ye.has(y)) {
|
|
769
|
+
let e = a[0]?.dataKey || "value", t = b[0]?.[e], n = typeof t == "number" ? t : Number(t), i = a[0]?.label ?? r?.[e]?.label ?? e;
|
|
770
|
+
return /* @__PURE__ */ T("div", {
|
|
771
|
+
className: o,
|
|
772
|
+
"data-testid": "advanced-chart-single-value",
|
|
773
|
+
children: /* @__PURE__ */ E("div", {
|
|
774
|
+
className: "flex flex-col gap-1 py-4",
|
|
775
|
+
children: [/* @__PURE__ */ T("span", {
|
|
776
|
+
className: "text-3xl font-semibold tabular-nums",
|
|
777
|
+
children: Number.isFinite(n) ? new Intl.NumberFormat().format(n) : String(t ?? "—")
|
|
778
|
+
}), /* @__PURE__ */ T("span", {
|
|
779
|
+
className: "text-xs text-muted-foreground",
|
|
780
|
+
children: String(i)
|
|
781
|
+
})]
|
|
782
|
+
})
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
if (y && Xe.has(y)) return /* @__PURE__ */ E("div", {
|
|
786
|
+
className: `rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground ${o ?? ""}`,
|
|
787
|
+
"data-testid": "advanced-chart-tabular-notice",
|
|
788
|
+
role: "note",
|
|
789
|
+
children: [
|
|
790
|
+
"Chart type “",
|
|
791
|
+
y,
|
|
792
|
+
"” is tabular — render it with the data-table / pivot components; a chart block draws series charts."
|
|
793
|
+
]
|
|
794
|
+
});
|
|
795
|
+
if (y && !Je.has(y)) return /* @__PURE__ */ E("div", {
|
|
796
|
+
className: `rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground ${o ?? ""}`,
|
|
797
|
+
"data-testid": "advanced-chart-unknown-type",
|
|
798
|
+
role: "note",
|
|
799
|
+
children: [
|
|
800
|
+
"Chart type “",
|
|
801
|
+
y,
|
|
802
|
+
"” is not a spec chart type — nothing was drawn."
|
|
803
|
+
]
|
|
804
|
+
});
|
|
805
|
+
if (y === "pie" || y === "donut") {
|
|
806
|
+
let e = y === "donut" ? "52%" : 0, t = F(), n = { ...r };
|
|
807
|
+
return b.forEach((e, r) => {
|
|
808
|
+
let a = e?.[i];
|
|
809
|
+
if (a == null || a === "") return;
|
|
810
|
+
let o = String(a);
|
|
811
|
+
n[o] || (n[o] = {
|
|
812
|
+
label: o,
|
|
813
|
+
color: k(a, r, t)
|
|
478
814
|
});
|
|
479
|
-
}), /* @__PURE__ */
|
|
480
|
-
config:
|
|
481
|
-
className:
|
|
482
|
-
|
|
483
|
-
|
|
815
|
+
}), /* @__PURE__ */ T(q, {
|
|
816
|
+
config: n,
|
|
817
|
+
className: o,
|
|
818
|
+
...S,
|
|
819
|
+
children: /* @__PURE__ */ E(Ce, { children: [
|
|
820
|
+
/* @__PURE__ */ T(X, {
|
|
484
821
|
cursor: !1,
|
|
485
|
-
content: /* @__PURE__ */
|
|
822
|
+
content: /* @__PURE__ */ T(at, { hideLabel: !0 })
|
|
486
823
|
}),
|
|
487
|
-
/* @__PURE__ */
|
|
488
|
-
data:
|
|
489
|
-
dataKey:
|
|
490
|
-
nameKey:
|
|
824
|
+
/* @__PURE__ */ T(Se, {
|
|
825
|
+
data: b,
|
|
826
|
+
dataKey: a[0]?.dataKey || "value",
|
|
827
|
+
nameKey: i || "name",
|
|
491
828
|
innerRadius: e,
|
|
492
829
|
strokeWidth: 5,
|
|
493
830
|
paddingAngle: 2,
|
|
494
831
|
outerRadius: "85%",
|
|
495
|
-
...
|
|
496
|
-
...
|
|
497
|
-
children:
|
|
498
|
-
let
|
|
499
|
-
return /* @__PURE__ */
|
|
832
|
+
...x,
|
|
833
|
+
...ue,
|
|
834
|
+
children: b.map((e, n) => {
|
|
835
|
+
let r = k(e?.[i], n, t);
|
|
836
|
+
return /* @__PURE__ */ T(O, { fill: Q(r) }, `cell-${n}`);
|
|
500
837
|
})
|
|
501
838
|
}),
|
|
502
|
-
/* @__PURE__ */
|
|
839
|
+
/* @__PURE__ */ T(Z, {
|
|
503
840
|
verticalAlign: "bottom",
|
|
504
841
|
wrapperStyle: {
|
|
505
|
-
fontSize:
|
|
842
|
+
fontSize: C ? "11px" : "12px",
|
|
506
843
|
paddingTop: "8px"
|
|
507
844
|
},
|
|
508
|
-
content: /* @__PURE__ */
|
|
509
|
-
nameKey:
|
|
845
|
+
content: /* @__PURE__ */ T(ot, {
|
|
846
|
+
nameKey: i,
|
|
510
847
|
className: "flex-wrap"
|
|
511
848
|
})
|
|
512
849
|
})
|
|
513
850
|
] })
|
|
514
851
|
});
|
|
515
852
|
}
|
|
516
|
-
if (
|
|
517
|
-
let e =
|
|
518
|
-
t &&
|
|
519
|
-
category: t?.payload?.[
|
|
853
|
+
if (y === "funnel") {
|
|
854
|
+
let e = a[0]?.dataKey || "value", n = F(), s = u ? (t) => {
|
|
855
|
+
t && u({
|
|
856
|
+
category: t?.payload?.[i] ?? t?.[i],
|
|
520
857
|
value: t?.payload?.[e] ?? t?.[e]
|
|
521
858
|
});
|
|
522
|
-
} : void 0,
|
|
523
|
-
onClick:
|
|
859
|
+
} : void 0, c = s ? {
|
|
860
|
+
onClick: s,
|
|
524
861
|
style: { cursor: "pointer" }
|
|
525
|
-
} : {}, l = [...d].sort((t, n) => {
|
|
862
|
+
} : {}, d = t(l), f = d ? [...b].sort((e, t) => (d.get(String(e?.[i] ?? "")) ?? 2 ** 53 - 1) - (d.get(String(t?.[i] ?? "")) ?? 2 ** 53 - 1)) : [...b].sort((t, n) => {
|
|
526
863
|
let r = Number(t?.[e] ?? 0);
|
|
527
864
|
return Number(n?.[e] ?? 0) - r;
|
|
528
865
|
});
|
|
529
|
-
return /* @__PURE__ */
|
|
530
|
-
config:
|
|
531
|
-
className:
|
|
532
|
-
|
|
866
|
+
return /* @__PURE__ */ T(q, {
|
|
867
|
+
config: r,
|
|
868
|
+
className: o,
|
|
869
|
+
...S,
|
|
870
|
+
children: /* @__PURE__ */ E(ve, { children: [/* @__PURE__ */ T(X, { content: /* @__PURE__ */ T(at, {}) }), /* @__PURE__ */ E(_e, {
|
|
533
871
|
dataKey: e,
|
|
534
|
-
data:
|
|
535
|
-
nameKey:
|
|
536
|
-
|
|
537
|
-
...
|
|
538
|
-
children: [/* @__PURE__ */
|
|
872
|
+
data: f,
|
|
873
|
+
nameKey: i,
|
|
874
|
+
...x,
|
|
875
|
+
...c,
|
|
876
|
+
children: [/* @__PURE__ */ T(ye, {
|
|
539
877
|
position: "right",
|
|
540
878
|
fill: "hsl(var(--foreground))",
|
|
541
879
|
stroke: "none",
|
|
542
|
-
dataKey:
|
|
543
|
-
}),
|
|
880
|
+
dataKey: i
|
|
881
|
+
}), f.map((e, t) => /* @__PURE__ */ T(O, { fill: Q(n[t % n.length]) }, `funnel-cell-${t}`))]
|
|
544
882
|
})] })
|
|
545
883
|
});
|
|
546
884
|
}
|
|
547
|
-
if (
|
|
548
|
-
let e =
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
885
|
+
if (y === "treemap") {
|
|
886
|
+
let e = a[0]?.dataKey || "value", t = F(), n = b.map((n, r) => ({
|
|
887
|
+
name: String(n?.[i] ?? ""),
|
|
888
|
+
size: Number(n?.[e]) || 0,
|
|
889
|
+
fill: Q(t[r % t.length])
|
|
890
|
+
}));
|
|
891
|
+
return /* @__PURE__ */ T(q, {
|
|
892
|
+
config: r,
|
|
893
|
+
className: o,
|
|
894
|
+
...S,
|
|
895
|
+
children: /* @__PURE__ */ T(Ne, {
|
|
896
|
+
data: n,
|
|
558
897
|
dataKey: "size",
|
|
559
898
|
nameKey: "name",
|
|
560
|
-
|
|
561
|
-
content: /* @__PURE__ */
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
x: t,
|
|
565
|
-
y: n,
|
|
566
|
-
width: r,
|
|
567
|
-
height: i,
|
|
568
|
-
fill: o,
|
|
569
|
-
stroke: "hsl(var(--background))",
|
|
570
|
-
strokeWidth: 2
|
|
571
|
-
}), r > 48 && i > 18 ? /* @__PURE__ */ C("text", {
|
|
572
|
-
x: t + 6,
|
|
573
|
-
y: n + 18,
|
|
574
|
-
fill: "#fff",
|
|
575
|
-
fontSize: 12,
|
|
576
|
-
className: "pointer-events-none",
|
|
577
|
-
children: a
|
|
578
|
-
}) : null] });
|
|
579
|
-
}, {}),
|
|
580
|
-
...oe,
|
|
581
|
-
children: /* @__PURE__ */ C(F, {})
|
|
899
|
+
...x,
|
|
900
|
+
content: /* @__PURE__ */ T(_t, {}),
|
|
901
|
+
...Re,
|
|
902
|
+
children: /* @__PURE__ */ T(M, {})
|
|
582
903
|
})
|
|
583
904
|
});
|
|
584
905
|
}
|
|
585
|
-
if (
|
|
586
|
-
let e =
|
|
906
|
+
if (y === "sankey") {
|
|
907
|
+
let e = a[0]?.dataKey || "value", t = a[0]?.label || e, n = b.filter((t) => (Number(t?.[e]) || 0) > 0), s = [{ name: t }, ...n.map((e) => ({ name: String(e?.[i] ?? "") }))], c = n.map((t, n) => ({
|
|
587
908
|
source: 0,
|
|
588
909
|
target: n + 1,
|
|
589
910
|
value: Number(t?.[e]) || 0
|
|
590
911
|
}));
|
|
591
|
-
return c.length === 0 ? /* @__PURE__ */
|
|
592
|
-
config:
|
|
593
|
-
className:
|
|
594
|
-
|
|
912
|
+
return c.length === 0 ? /* @__PURE__ */ T("div", { className: o }) : /* @__PURE__ */ T(q, {
|
|
913
|
+
config: r,
|
|
914
|
+
className: o,
|
|
915
|
+
...S,
|
|
916
|
+
children: /* @__PURE__ */ T(je, {
|
|
595
917
|
data: {
|
|
596
918
|
nodes: s,
|
|
597
919
|
links: c
|
|
@@ -602,24 +924,25 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
602
924
|
strokeOpacity: .25
|
|
603
925
|
},
|
|
604
926
|
node: { fill: "hsl(var(--chart-1))" },
|
|
605
|
-
...
|
|
606
|
-
children: /* @__PURE__ */
|
|
927
|
+
...ze,
|
|
928
|
+
children: /* @__PURE__ */ T(M, {})
|
|
607
929
|
})
|
|
608
930
|
});
|
|
609
931
|
}
|
|
610
|
-
if (
|
|
611
|
-
config:
|
|
612
|
-
className:
|
|
613
|
-
|
|
614
|
-
|
|
932
|
+
if (y === "radar") return /* @__PURE__ */ T(q, {
|
|
933
|
+
config: r,
|
|
934
|
+
className: o,
|
|
935
|
+
...S,
|
|
936
|
+
children: /* @__PURE__ */ E(Oe, {
|
|
937
|
+
data: b,
|
|
615
938
|
children: [
|
|
616
|
-
/* @__PURE__ */
|
|
617
|
-
/* @__PURE__ */
|
|
618
|
-
/* @__PURE__ */
|
|
619
|
-
/* @__PURE__ */
|
|
620
|
-
/* @__PURE__ */
|
|
621
|
-
content: /* @__PURE__ */
|
|
622
|
-
...
|
|
939
|
+
/* @__PURE__ */ T(Te, {}),
|
|
940
|
+
/* @__PURE__ */ T(we, { dataKey: i }),
|
|
941
|
+
/* @__PURE__ */ T(Ee, {}),
|
|
942
|
+
/* @__PURE__ */ T(X, { content: /* @__PURE__ */ T(at, {}) }),
|
|
943
|
+
/* @__PURE__ */ T(Z, {
|
|
944
|
+
content: /* @__PURE__ */ T(ot, {}),
|
|
945
|
+
...C && {
|
|
623
946
|
verticalAlign: "bottom",
|
|
624
947
|
wrapperStyle: {
|
|
625
948
|
fontSize: "11px",
|
|
@@ -627,48 +950,50 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
627
950
|
}
|
|
628
951
|
}
|
|
629
952
|
}),
|
|
630
|
-
|
|
631
|
-
let t =
|
|
632
|
-
return /* @__PURE__ */
|
|
953
|
+
a.map((e) => {
|
|
954
|
+
let t = Q(r[e.dataKey]?.color || St);
|
|
955
|
+
return /* @__PURE__ */ T(De, {
|
|
633
956
|
dataKey: e.dataKey,
|
|
634
957
|
stroke: t,
|
|
635
958
|
fill: t,
|
|
636
|
-
fillOpacity: .6
|
|
959
|
+
fillOpacity: .6,
|
|
960
|
+
...x
|
|
637
961
|
}, e.dataKey);
|
|
638
962
|
})
|
|
639
963
|
]
|
|
640
964
|
})
|
|
641
965
|
});
|
|
642
|
-
if (
|
|
643
|
-
config:
|
|
644
|
-
className:
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
/* @__PURE__ */
|
|
966
|
+
if (y === "scatter") return /* @__PURE__ */ T(q, {
|
|
967
|
+
config: r,
|
|
968
|
+
className: o,
|
|
969
|
+
...S,
|
|
970
|
+
children: /* @__PURE__ */ E(j, { children: [
|
|
971
|
+
/* @__PURE__ */ T(he, { vertical: !1 }),
|
|
972
|
+
/* @__PURE__ */ T(N, {
|
|
648
973
|
type: "number",
|
|
649
|
-
dataKey:
|
|
650
|
-
name: String(
|
|
974
|
+
dataKey: i,
|
|
975
|
+
name: String(r[i]?.label || i),
|
|
651
976
|
tickLine: !1,
|
|
652
977
|
axisLine: !1,
|
|
653
|
-
minTickGap:
|
|
978
|
+
minTickGap: C ? 32 : 48
|
|
654
979
|
}),
|
|
655
|
-
/* @__PURE__ */
|
|
980
|
+
/* @__PURE__ */ T(P, {
|
|
656
981
|
type: "number",
|
|
657
|
-
dataKey:
|
|
658
|
-
name: String(
|
|
982
|
+
dataKey: a[0]?.dataKey || "value",
|
|
983
|
+
name: String(r[a[0]?.dataKey]?.label || a[0]?.dataKey),
|
|
659
984
|
tickLine: !1,
|
|
660
985
|
axisLine: !1,
|
|
661
|
-
tickFormatter:
|
|
986
|
+
tickFormatter: I,
|
|
662
987
|
width: 48
|
|
663
988
|
}),
|
|
664
|
-
/* @__PURE__ */
|
|
989
|
+
/* @__PURE__ */ T(Pe, {
|
|
665
990
|
type: "number",
|
|
666
991
|
range: [60, 400]
|
|
667
992
|
}),
|
|
668
|
-
/* @__PURE__ */
|
|
669
|
-
/* @__PURE__ */
|
|
670
|
-
content: /* @__PURE__ */
|
|
671
|
-
...
|
|
993
|
+
/* @__PURE__ */ T(X, { content: /* @__PURE__ */ T(at, {}) }),
|
|
994
|
+
/* @__PURE__ */ T(Z, {
|
|
995
|
+
content: /* @__PURE__ */ T(ot, {}),
|
|
996
|
+
...C && {
|
|
672
997
|
verticalAlign: "bottom",
|
|
673
998
|
wrapperStyle: {
|
|
674
999
|
fontSize: "11px",
|
|
@@ -676,214 +1001,285 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
676
1001
|
}
|
|
677
1002
|
}
|
|
678
1003
|
}),
|
|
679
|
-
|
|
680
|
-
let
|
|
681
|
-
return /* @__PURE__ */
|
|
682
|
-
name:
|
|
683
|
-
data:
|
|
1004
|
+
a.map((e, t) => {
|
|
1005
|
+
let n = F(), i = Q(r[e.dataKey]?.color || n[t % n.length]), a = wt(e, "scatter");
|
|
1006
|
+
return /* @__PURE__ */ T(Me, {
|
|
1007
|
+
name: r[e.dataKey]?.label || e.dataKey,
|
|
1008
|
+
data: b,
|
|
684
1009
|
fill: i,
|
|
685
1010
|
fillOpacity: a?.fillOpacity,
|
|
686
|
-
...
|
|
1011
|
+
...x,
|
|
1012
|
+
...Le
|
|
687
1013
|
}, e.dataKey);
|
|
688
1014
|
})
|
|
689
1015
|
] })
|
|
690
1016
|
});
|
|
691
|
-
if (
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
children: /* @__PURE__ */
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
type: "monotone",
|
|
733
|
-
dataKey: e.dataKey,
|
|
734
|
-
stroke: r,
|
|
735
|
-
strokeWidth: 2,
|
|
736
|
-
dot: !1,
|
|
737
|
-
strokeOpacity: o?.strokeOpacity,
|
|
738
|
-
strokeDasharray: o?.strokeDasharray,
|
|
739
|
-
...p
|
|
740
|
-
}, e.dataKey) : i === "area" ? /* @__PURE__ */ C(T, {
|
|
741
|
-
yAxisId: a,
|
|
742
|
-
type: "monotone",
|
|
743
|
-
dataKey: e.dataKey,
|
|
744
|
-
fill: r,
|
|
745
|
-
stroke: r,
|
|
746
|
-
fillOpacity: o?.fillOpacity ?? .4,
|
|
747
|
-
strokeOpacity: o?.strokeOpacity,
|
|
748
|
-
strokeDasharray: o?.strokeDasharray,
|
|
749
|
-
...p
|
|
750
|
-
}, e.dataKey) : /* @__PURE__ */ C(fe, {
|
|
751
|
-
yAxisId: a,
|
|
752
|
-
dataKey: e.dataKey,
|
|
753
|
-
fill: r,
|
|
754
|
-
radius: 4,
|
|
755
|
-
fillOpacity: o?.fillOpacity,
|
|
756
|
-
...p
|
|
757
|
-
}, e.dataKey);
|
|
758
|
-
})
|
|
759
|
-
]
|
|
760
|
-
})
|
|
761
|
-
});
|
|
762
|
-
let k = u === "horizontal-bar", P = y(), Te = s ? Object.values(s).map((e) => Z(String(e))) : [], Ee = Array.from(/* @__PURE__ */ new Set([
|
|
763
|
-
...P,
|
|
764
|
-
...Te,
|
|
765
|
-
...i.map((e, t) => Z(n[e.dataKey]?.color || P[t % P.length] || X))
|
|
766
|
-
])), z = (e) => "g" + e.replace(/[^a-zA-Z0-9]/g, "");
|
|
767
|
-
return /* @__PURE__ */ C(W, {
|
|
768
|
-
config: n,
|
|
769
|
-
className: a,
|
|
770
|
-
children: /* @__PURE__ */ w(ce, {
|
|
771
|
-
data: d,
|
|
772
|
-
layout: k ? "vertical" : "horizontal",
|
|
773
|
-
..._,
|
|
774
|
-
children: [
|
|
775
|
-
/* @__PURE__ */ C("defs", { children: Ee.map((e) => /* @__PURE__ */ w(f.Fragment, { children: [/* @__PURE__ */ w("linearGradient", {
|
|
776
|
-
id: `bg-${z(e)}`,
|
|
777
|
-
x1: "0",
|
|
778
|
-
y1: "0",
|
|
779
|
-
x2: "0",
|
|
780
|
-
y2: "1",
|
|
781
|
-
children: [/* @__PURE__ */ C("stop", {
|
|
782
|
-
offset: "0%",
|
|
783
|
-
style: { stopColor: e },
|
|
784
|
-
stopOpacity: .95
|
|
785
|
-
}), /* @__PURE__ */ C("stop", {
|
|
786
|
-
offset: "100%",
|
|
787
|
-
style: { stopColor: e },
|
|
788
|
-
stopOpacity: .5
|
|
789
|
-
})]
|
|
790
|
-
}), /* @__PURE__ */ w("linearGradient", {
|
|
791
|
-
id: `ag-${z(e)}`,
|
|
792
|
-
x1: "0",
|
|
793
|
-
y1: "0",
|
|
794
|
-
x2: "0",
|
|
795
|
-
y2: "1",
|
|
796
|
-
children: [/* @__PURE__ */ C("stop", {
|
|
797
|
-
offset: "0%",
|
|
798
|
-
style: { stopColor: e },
|
|
799
|
-
stopOpacity: .5
|
|
800
|
-
}), /* @__PURE__ */ C("stop", {
|
|
801
|
-
offset: "95%",
|
|
802
|
-
style: { stopColor: e },
|
|
803
|
-
stopOpacity: .05
|
|
804
|
-
})]
|
|
805
|
-
})] }, z(e))) }),
|
|
806
|
-
/* @__PURE__ */ C(D, { vertical: !1 }),
|
|
807
|
-
k ? /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(I, {
|
|
808
|
-
type: "number",
|
|
809
|
-
tickLine: !1,
|
|
810
|
-
axisLine: !1,
|
|
811
|
-
tickFormatter: b
|
|
812
|
-
}), /* @__PURE__ */ C(L, {
|
|
813
|
-
type: "category",
|
|
814
|
-
dataKey: r,
|
|
815
|
-
tickLine: !1,
|
|
816
|
-
axisLine: !1,
|
|
817
|
-
width: Math.min(140, Math.max(60, Math.max(...d.map((e) => String(e[r] ?? "").length)) * 7)),
|
|
818
|
-
tickFormatter: le
|
|
819
|
-
})] }) : /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(I, {
|
|
820
|
-
dataKey: r,
|
|
821
|
-
...x
|
|
822
|
-
}), /* @__PURE__ */ C(L, {
|
|
823
|
-
tickLine: !1,
|
|
824
|
-
axisLine: !1,
|
|
825
|
-
tickFormatter: b,
|
|
826
|
-
width: 48
|
|
827
|
-
})] }),
|
|
828
|
-
/* @__PURE__ */ C(J, { content: /* @__PURE__ */ C(G, {}) }),
|
|
829
|
-
/* @__PURE__ */ C(Y, {
|
|
830
|
-
content: /* @__PURE__ */ C(K, {}),
|
|
831
|
-
...m && {
|
|
832
|
-
verticalAlign: "bottom",
|
|
833
|
-
wrapperStyle: {
|
|
834
|
-
fontSize: "11px",
|
|
835
|
-
paddingTop: "8px"
|
|
1017
|
+
if (y === "combo") return /* @__PURE__ */ T(vt, {
|
|
1018
|
+
title: ee,
|
|
1019
|
+
subtitle: te,
|
|
1020
|
+
children: /* @__PURE__ */ T(q, {
|
|
1021
|
+
config: r,
|
|
1022
|
+
className: o,
|
|
1023
|
+
...S,
|
|
1024
|
+
children: /* @__PURE__ */ E(ge, {
|
|
1025
|
+
data: b,
|
|
1026
|
+
children: [
|
|
1027
|
+
/* @__PURE__ */ T(he, { ...G }),
|
|
1028
|
+
/* @__PURE__ */ T(N, {
|
|
1029
|
+
dataKey: i,
|
|
1030
|
+
...nt
|
|
1031
|
+
}),
|
|
1032
|
+
/* @__PURE__ */ T(P, {
|
|
1033
|
+
yAxisId: "left",
|
|
1034
|
+
tickLine: !1,
|
|
1035
|
+
axisLine: !1,
|
|
1036
|
+
tickFormatter: V,
|
|
1037
|
+
width: 48,
|
|
1038
|
+
...U(L)
|
|
1039
|
+
}),
|
|
1040
|
+
/* @__PURE__ */ T(P, {
|
|
1041
|
+
yAxisId: "right",
|
|
1042
|
+
orientation: "right",
|
|
1043
|
+
tickLine: !1,
|
|
1044
|
+
axisLine: !1,
|
|
1045
|
+
tickFormatter: Ue,
|
|
1046
|
+
width: 48,
|
|
1047
|
+
...U(R, "right")
|
|
1048
|
+
}),
|
|
1049
|
+
et ? /* @__PURE__ */ T(X, { content: /* @__PURE__ */ T(at, {}) }) : null,
|
|
1050
|
+
Qe ? /* @__PURE__ */ T(Z, {
|
|
1051
|
+
content: /* @__PURE__ */ T(ot, {}),
|
|
1052
|
+
...C && {
|
|
1053
|
+
verticalAlign: "bottom",
|
|
1054
|
+
wrapperStyle: {
|
|
1055
|
+
fontSize: "11px",
|
|
1056
|
+
paddingTop: "8px"
|
|
1057
|
+
}
|
|
836
1058
|
}
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
dataKey: e.dataKey,
|
|
845
|
-
fill: `url(#bg-${z(l)})`,
|
|
846
|
-
radius: 4,
|
|
847
|
-
fillOpacity: n?.fillOpacity,
|
|
848
|
-
...p,
|
|
849
|
-
children: t && d.map((e, t) => /* @__PURE__ */ C(pe, { fill: `url(#bg-${z(Z(v(e?.[r], t, a)))})` }, `cell-${t}`))
|
|
850
|
-
}, e.dataKey);
|
|
851
|
-
}
|
|
852
|
-
if (u === "line") {
|
|
853
|
-
let t = Q(e, "line");
|
|
854
|
-
return /* @__PURE__ */ C(A, {
|
|
1059
|
+
}) : null,
|
|
1060
|
+
$e,
|
|
1061
|
+
tt,
|
|
1062
|
+
a.map((e, t) => {
|
|
1063
|
+
let n = Q(r[e.dataKey]?.color || St), i = e.chartType || ae || (t === 0 ? "bar" : "line"), a = e.yAxis === "right" || e.yAxis === "left" ? e.yAxis : ae || i === "bar" ? "left" : "right", o = wt(e, i), s = e.stack ? { stackId: String(e.stack) } : {}, c = H((a === "right" ? R : L)?.format);
|
|
1064
|
+
return i === "line" ? /* @__PURE__ */ T(be, {
|
|
1065
|
+
yAxisId: a,
|
|
855
1066
|
type: "monotone",
|
|
856
1067
|
dataKey: e.dataKey,
|
|
857
|
-
stroke:
|
|
1068
|
+
stroke: n,
|
|
858
1069
|
strokeWidth: 2,
|
|
859
1070
|
dot: !1,
|
|
860
|
-
strokeOpacity:
|
|
861
|
-
strokeDasharray:
|
|
862
|
-
...
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
let t = Q(e, "area");
|
|
867
|
-
return /* @__PURE__ */ C(T, {
|
|
1071
|
+
strokeOpacity: o?.strokeOpacity,
|
|
1072
|
+
strokeDasharray: o?.strokeDasharray,
|
|
1073
|
+
...x,
|
|
1074
|
+
children: K(c)
|
|
1075
|
+
}, e.dataKey) : i === "area" ? /* @__PURE__ */ T(de, {
|
|
1076
|
+
yAxisId: a,
|
|
868
1077
|
type: "monotone",
|
|
869
1078
|
dataKey: e.dataKey,
|
|
870
|
-
fill:
|
|
871
|
-
stroke:
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
...
|
|
1079
|
+
fill: n,
|
|
1080
|
+
stroke: n,
|
|
1081
|
+
fillOpacity: o?.fillOpacity ?? .4,
|
|
1082
|
+
strokeOpacity: o?.strokeOpacity,
|
|
1083
|
+
strokeDasharray: o?.strokeDasharray,
|
|
1084
|
+
...s,
|
|
1085
|
+
...x,
|
|
1086
|
+
children: K(c)
|
|
1087
|
+
}, e.dataKey) : /* @__PURE__ */ T(pe, {
|
|
1088
|
+
yAxisId: a,
|
|
1089
|
+
dataKey: e.dataKey,
|
|
1090
|
+
fill: n,
|
|
1091
|
+
radius: 4,
|
|
1092
|
+
fillOpacity: o?.fillOpacity,
|
|
1093
|
+
...s,
|
|
1094
|
+
...x,
|
|
1095
|
+
children: K(c)
|
|
877
1096
|
}, e.dataKey);
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
]
|
|
1097
|
+
})
|
|
1098
|
+
]
|
|
1099
|
+
})
|
|
882
1100
|
})
|
|
883
1101
|
});
|
|
1102
|
+
let rt = y === "horizontal-bar", it = F(), st = c ? Object.values(c).map((e) => Q(String(e))) : [], J = Array.from(/* @__PURE__ */ new Set([
|
|
1103
|
+
...it,
|
|
1104
|
+
...st,
|
|
1105
|
+
...a.map((e, t) => Q(r[e.dataKey]?.color || it[t % it.length] || St))
|
|
1106
|
+
])), Y = (e) => "g" + e.replace(/[^a-zA-Z0-9]/g, "");
|
|
1107
|
+
return /* @__PURE__ */ T(vt, {
|
|
1108
|
+
title: ee,
|
|
1109
|
+
subtitle: te,
|
|
1110
|
+
children: /* @__PURE__ */ T(q, {
|
|
1111
|
+
config: r,
|
|
1112
|
+
className: o,
|
|
1113
|
+
...S,
|
|
1114
|
+
children: /* @__PURE__ */ E(Be, {
|
|
1115
|
+
data: b,
|
|
1116
|
+
layout: rt ? "vertical" : "horizontal",
|
|
1117
|
+
...le,
|
|
1118
|
+
children: [
|
|
1119
|
+
/* @__PURE__ */ T("defs", { children: J.map((e) => /* @__PURE__ */ E(m.Fragment, { children: [/* @__PURE__ */ E("linearGradient", {
|
|
1120
|
+
id: `bg-${Y(e)}`,
|
|
1121
|
+
x1: "0",
|
|
1122
|
+
y1: "0",
|
|
1123
|
+
x2: "0",
|
|
1124
|
+
y2: "1",
|
|
1125
|
+
children: [/* @__PURE__ */ T("stop", {
|
|
1126
|
+
offset: "0%",
|
|
1127
|
+
style: { stopColor: e },
|
|
1128
|
+
stopOpacity: .95
|
|
1129
|
+
}), /* @__PURE__ */ T("stop", {
|
|
1130
|
+
offset: "100%",
|
|
1131
|
+
style: { stopColor: e },
|
|
1132
|
+
stopOpacity: .5
|
|
1133
|
+
})]
|
|
1134
|
+
}), /* @__PURE__ */ E("linearGradient", {
|
|
1135
|
+
id: `ag-${Y(e)}`,
|
|
1136
|
+
x1: "0",
|
|
1137
|
+
y1: "0",
|
|
1138
|
+
x2: "0",
|
|
1139
|
+
y2: "1",
|
|
1140
|
+
children: [/* @__PURE__ */ T("stop", {
|
|
1141
|
+
offset: "0%",
|
|
1142
|
+
style: { stopColor: e },
|
|
1143
|
+
stopOpacity: .5
|
|
1144
|
+
}), /* @__PURE__ */ T("stop", {
|
|
1145
|
+
offset: "95%",
|
|
1146
|
+
style: { stopColor: e },
|
|
1147
|
+
stopOpacity: .05
|
|
1148
|
+
})]
|
|
1149
|
+
})] }, Y(e))) }),
|
|
1150
|
+
/* @__PURE__ */ T(he, { ...G }),
|
|
1151
|
+
rt ? /* @__PURE__ */ E(w, { children: [/* @__PURE__ */ T(N, {
|
|
1152
|
+
type: "number",
|
|
1153
|
+
tickLine: !1,
|
|
1154
|
+
axisLine: !1,
|
|
1155
|
+
tickFormatter: V,
|
|
1156
|
+
...U(L)
|
|
1157
|
+
}), /* @__PURE__ */ T(P, {
|
|
1158
|
+
type: "category",
|
|
1159
|
+
dataKey: i,
|
|
1160
|
+
tickLine: !1,
|
|
1161
|
+
axisLine: !1,
|
|
1162
|
+
width: Math.min(140, Math.max(60, Math.max(...b.map((e) => String(e[i] ?? "").length)) * 7)),
|
|
1163
|
+
tickFormatter: B
|
|
1164
|
+
})] }) : /* @__PURE__ */ E(w, { children: [
|
|
1165
|
+
/* @__PURE__ */ T(N, {
|
|
1166
|
+
dataKey: i,
|
|
1167
|
+
...nt
|
|
1168
|
+
}),
|
|
1169
|
+
/* @__PURE__ */ T(P, {
|
|
1170
|
+
...z ? { yAxisId: "left" } : {},
|
|
1171
|
+
tickLine: !1,
|
|
1172
|
+
axisLine: !1,
|
|
1173
|
+
tickFormatter: V,
|
|
1174
|
+
width: 48,
|
|
1175
|
+
...U(L)
|
|
1176
|
+
}),
|
|
1177
|
+
z ? /* @__PURE__ */ T(P, {
|
|
1178
|
+
yAxisId: "right",
|
|
1179
|
+
orientation: "right",
|
|
1180
|
+
tickLine: !1,
|
|
1181
|
+
axisLine: !1,
|
|
1182
|
+
tickFormatter: Ue,
|
|
1183
|
+
width: 48,
|
|
1184
|
+
...U(R, "right")
|
|
1185
|
+
}) : null
|
|
1186
|
+
] }),
|
|
1187
|
+
et ? /* @__PURE__ */ T(X, { content: /* @__PURE__ */ T(at, {}) }) : null,
|
|
1188
|
+
Qe ? /* @__PURE__ */ T(Z, {
|
|
1189
|
+
content: /* @__PURE__ */ T(ot, {}),
|
|
1190
|
+
...C && {
|
|
1191
|
+
verticalAlign: "bottom",
|
|
1192
|
+
wrapperStyle: {
|
|
1193
|
+
fontSize: "11px",
|
|
1194
|
+
paddingTop: "8px"
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
}) : null,
|
|
1198
|
+
$e,
|
|
1199
|
+
tt,
|
|
1200
|
+
a.map((e, t) => {
|
|
1201
|
+
let n = F(), o = e.variant === "comparison", s = o ? a.slice(0, t).find((e) => e.variant !== "comparison") || a[0] : e, c = o ? a.indexOf(s) : t, l = Q(r[s.dataKey]?.color || n[c % n.length] || St), u = z ? { yAxisId: e.yAxis === "right" ? "right" : "left" } : {}, d = e.stack ? { stackId: String(e.stack) } : {}, f = H((e.yAxis === "right" ? R : L)?.format);
|
|
1202
|
+
if (y === "bar" || y === "horizontal-bar") {
|
|
1203
|
+
let t = a.filter((e) => e.variant !== "comparison").length === 1 && !o && a.length === 1 && b.length > 1, r = wt(e, "bar");
|
|
1204
|
+
return /* @__PURE__ */ E(pe, {
|
|
1205
|
+
dataKey: e.dataKey,
|
|
1206
|
+
fill: `url(#bg-${Y(l)})`,
|
|
1207
|
+
radius: 4,
|
|
1208
|
+
fillOpacity: r?.fillOpacity,
|
|
1209
|
+
...d,
|
|
1210
|
+
...u,
|
|
1211
|
+
...x,
|
|
1212
|
+
children: [t && b.map((e, t) => /* @__PURE__ */ T(O, { fill: `url(#bg-${Y(Q(k(e?.[i], t, n)))})` }, `cell-${t}`)), K(f)]
|
|
1213
|
+
}, e.dataKey);
|
|
1214
|
+
}
|
|
1215
|
+
if (y === "line") {
|
|
1216
|
+
let t = wt(e, "line");
|
|
1217
|
+
return /* @__PURE__ */ T(be, {
|
|
1218
|
+
type: "monotone",
|
|
1219
|
+
dataKey: e.dataKey,
|
|
1220
|
+
stroke: l,
|
|
1221
|
+
strokeWidth: 2,
|
|
1222
|
+
dot: !1,
|
|
1223
|
+
strokeOpacity: t?.strokeOpacity,
|
|
1224
|
+
strokeDasharray: t?.strokeDasharray,
|
|
1225
|
+
...u,
|
|
1226
|
+
...x,
|
|
1227
|
+
children: K(f)
|
|
1228
|
+
}, e.dataKey);
|
|
1229
|
+
}
|
|
1230
|
+
if (y === "area") {
|
|
1231
|
+
let t = wt(e, "area");
|
|
1232
|
+
return /* @__PURE__ */ T(de, {
|
|
1233
|
+
type: "monotone",
|
|
1234
|
+
dataKey: e.dataKey,
|
|
1235
|
+
fill: `url(#ag-${Y(l)})`,
|
|
1236
|
+
stroke: l,
|
|
1237
|
+
strokeWidth: 2,
|
|
1238
|
+
fillOpacity: t?.fillOpacity ?? 1,
|
|
1239
|
+
strokeOpacity: t?.strokeOpacity,
|
|
1240
|
+
strokeDasharray: t?.strokeDasharray,
|
|
1241
|
+
...d,
|
|
1242
|
+
...u,
|
|
1243
|
+
...x,
|
|
1244
|
+
children: K(f)
|
|
1245
|
+
}, e.dataKey);
|
|
1246
|
+
}
|
|
1247
|
+
return null;
|
|
1248
|
+
})
|
|
1249
|
+
]
|
|
1250
|
+
})
|
|
1251
|
+
})
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
function bt(e) {
|
|
1255
|
+
let t = e.chartType === "column" ? "bar" : e.chartType ?? "bar", n = Array.isArray(e.data) ? e.data : [], r = e.xAxisKey ?? "name";
|
|
1256
|
+
return Tt.has(t) && n.length > 0 && !n.some((e) => typeof e == "object" && !!e && r in e);
|
|
1257
|
+
}
|
|
1258
|
+
function xt(e) {
|
|
1259
|
+
let t = bt(e), n = e.xAxisKey ?? "name", r = m.useMemo(() => Object.keys((Array.isArray(e.data) ? e.data[0] : void 0) ?? {}), [e.data]);
|
|
1260
|
+
return m.useEffect(() => {
|
|
1261
|
+
t && console.warn(`[chart] no row has the category key "${n}" — rendering an explanatory placeholder instead of an empty axis. Row keys: ${JSON.stringify(r)}. A dataset query must PROJECT the dimension it groups by (framework#4033).`);
|
|
1262
|
+
}, [
|
|
1263
|
+
t,
|
|
1264
|
+
n,
|
|
1265
|
+
r
|
|
1266
|
+
]), t ? /* @__PURE__ */ T("div", {
|
|
1267
|
+
className: `flex h-full min-h-[120px] w-full items-center justify-center p-4 text-center text-sm text-muted-foreground ${e.className ?? ""}`,
|
|
1268
|
+
role: "status",
|
|
1269
|
+
"data-chart-error": "missing-category-key",
|
|
1270
|
+
children: /* @__PURE__ */ E("span", { children: [
|
|
1271
|
+
"This chart cannot plot its category axis: no row has a",
|
|
1272
|
+
" ",
|
|
1273
|
+
/* @__PURE__ */ T("code", {
|
|
1274
|
+
className: "font-mono",
|
|
1275
|
+
children: n
|
|
1276
|
+
}),
|
|
1277
|
+
" field."
|
|
1278
|
+
] })
|
|
1279
|
+
}) : /* @__PURE__ */ T(yt, { ...e });
|
|
884
1280
|
}
|
|
885
|
-
var
|
|
886
|
-
|
|
1281
|
+
var St, Ct, Q, wt, Tt, Et = L((() => {
|
|
1282
|
+
ut(), ht(), $e(), St = "hsl(var(--primary))", Ct = {
|
|
887
1283
|
slate: "#64748b",
|
|
888
1284
|
gray: "#6b7280",
|
|
889
1285
|
zinc: "#71717a",
|
|
@@ -906,14 +1302,28 @@ var X, Ye, Z, Q, Xe = V((() => {
|
|
|
906
1302
|
fuchsia: "#d946ef",
|
|
907
1303
|
pink: "#ec4899",
|
|
908
1304
|
rose: "#f43f5e"
|
|
909
|
-
},
|
|
1305
|
+
}, Q = (e) => Ct[e] || e, wt = (e, t) => e?.variant === "comparison" ? {
|
|
910
1306
|
strokeOpacity: typeof e.opacity == "number" ? e.opacity : t === "line" || t === "scatter" ? .5 : .6,
|
|
911
1307
|
fillOpacity: typeof e.opacity == "number" ? e.opacity : t === "bar" ? .4 : t === "area" ? .2 : .5,
|
|
912
1308
|
strokeDasharray: e.dashArray ?? (t === "line" || t === "area" ? "4 4" : void 0)
|
|
913
|
-
} : null
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1309
|
+
} : null, Tt = /* @__PURE__ */ new Set([
|
|
1310
|
+
"bar",
|
|
1311
|
+
"horizontal-bar",
|
|
1312
|
+
"line",
|
|
1313
|
+
"area",
|
|
1314
|
+
"pie",
|
|
1315
|
+
"donut",
|
|
1316
|
+
"radar",
|
|
1317
|
+
"funnel",
|
|
1318
|
+
"combo"
|
|
1319
|
+
]);
|
|
1320
|
+
}));
|
|
1321
|
+
//#endregion
|
|
1322
|
+
//#region src/ChartRenderer.tsx
|
|
1323
|
+
$e();
|
|
1324
|
+
var Dt = h.lazy(() => Promise.resolve().then(() => (rt(), et))), Ot = h.lazy(() => Promise.resolve().then(() => (Et(), gt))), kt = ({ schema: e }) => /* @__PURE__ */ T(g, {
|
|
1325
|
+
fallback: /* @__PURE__ */ T(ue, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
|
|
1326
|
+
children: /* @__PURE__ */ T(Dt, {
|
|
917
1327
|
data: e.data,
|
|
918
1328
|
dataKey: e.dataKey,
|
|
919
1329
|
xAxisKey: e.xAxisKey,
|
|
@@ -922,33 +1332,34 @@ var X, Ye, Z, Q, Xe = V((() => {
|
|
|
922
1332
|
color: e.color
|
|
923
1333
|
})
|
|
924
1334
|
}), $ = ({ schema: e, onChartClick: t }) => {
|
|
925
|
-
let n =
|
|
926
|
-
let t = e.series, n = e.xAxisKey,
|
|
927
|
-
if (
|
|
928
|
-
let
|
|
1335
|
+
let n = h.useMemo(() => {
|
|
1336
|
+
let t = Ue(e), n = Array.isArray(e.series) ? e.series : void 0, r = (n?.length && n.every((e) => !!e && typeof e == "object" && "dataKey" in e) ? n : t.series) ?? n, i = e.xAxisKey ?? t.xAxisKey, a = e.config;
|
|
1337
|
+
if (i || (e.index ? i = e.index : e.category && (i = e.category)), r || (e.categories ? r = e.categories.map((e) => ({ dataKey: e })) : e.value && (r = [{ dataKey: e.value }])), !a && r) {
|
|
1338
|
+
let t = e.colors || [
|
|
929
1339
|
"hsl(var(--chart-1))",
|
|
930
1340
|
"hsl(var(--chart-2))",
|
|
931
1341
|
"hsl(var(--chart-3))"
|
|
932
|
-
],
|
|
933
|
-
|
|
934
|
-
|
|
1342
|
+
], n = {};
|
|
1343
|
+
r.forEach((e, r) => {
|
|
1344
|
+
n[e.dataKey] = {
|
|
935
1345
|
label: e.label || e.dataKey,
|
|
936
|
-
color:
|
|
1346
|
+
color: e.color || t[r % t.length]
|
|
937
1347
|
};
|
|
938
|
-
}),
|
|
1348
|
+
}), a = n;
|
|
939
1349
|
}
|
|
940
1350
|
return {
|
|
941
|
-
chartType: e.chartType,
|
|
1351
|
+
chartType: e.chartType ?? t.chartType,
|
|
942
1352
|
data: Array.isArray(e.data) ? e.data : [],
|
|
943
|
-
config:
|
|
944
|
-
xAxisKey:
|
|
945
|
-
series:
|
|
946
|
-
className: e.className
|
|
1353
|
+
config: a,
|
|
1354
|
+
xAxisKey: i,
|
|
1355
|
+
series: r,
|
|
1356
|
+
className: e.className,
|
|
1357
|
+
spec: t
|
|
947
1358
|
};
|
|
948
1359
|
}, [e]);
|
|
949
|
-
return /* @__PURE__ */
|
|
950
|
-
fallback: /* @__PURE__ */
|
|
951
|
-
children: /* @__PURE__ */
|
|
1360
|
+
return /* @__PURE__ */ T(g, {
|
|
1361
|
+
fallback: /* @__PURE__ */ T(ue, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
|
|
1362
|
+
children: /* @__PURE__ */ T(Ot, {
|
|
952
1363
|
chartType: n.chartType,
|
|
953
1364
|
data: n.data,
|
|
954
1365
|
config: n.config,
|
|
@@ -957,58 +1368,73 @@ var X, Ye, Z, Q, Xe = V((() => {
|
|
|
957
1368
|
className: n.className,
|
|
958
1369
|
colors: Array.isArray(e.colors) ? e.colors : void 0,
|
|
959
1370
|
categoryColors: e.categoryColors,
|
|
1371
|
+
categoryOrder: e.categoryOrder,
|
|
960
1372
|
isAnimationActive: e.isAnimationActive,
|
|
961
|
-
onChartClick: t
|
|
1373
|
+
onChartClick: t,
|
|
1374
|
+
xAxis: n.spec.xAxis,
|
|
1375
|
+
yAxes: n.spec.yAxes,
|
|
1376
|
+
showLegend: n.spec.showLegend,
|
|
1377
|
+
showDataLabels: n.spec.showDataLabels,
|
|
1378
|
+
title: n.spec.title,
|
|
1379
|
+
subtitle: n.spec.subtitle,
|
|
1380
|
+
description: n.spec.description,
|
|
1381
|
+
height: n.spec.height ?? e.height,
|
|
1382
|
+
annotations: n.spec.annotations,
|
|
1383
|
+
interaction: n.spec.interaction
|
|
962
1384
|
})
|
|
963
1385
|
});
|
|
964
1386
|
};
|
|
965
1387
|
//#endregion
|
|
966
1388
|
//#region src/ObjectChart.tsx
|
|
967
|
-
function
|
|
1389
|
+
function At(e) {
|
|
968
1390
|
return e.replace(/[_-]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
|
|
969
1391
|
}
|
|
970
|
-
function
|
|
971
|
-
|
|
1392
|
+
function jt(e) {
|
|
1393
|
+
return e.field || e.function || "count";
|
|
1394
|
+
}
|
|
1395
|
+
var Mt = "__comparison";
|
|
1396
|
+
function Nt(e, t) {
|
|
1397
|
+
let { field: n, function: r, groupBy: i } = t, a = jt(t), o = {};
|
|
972
1398
|
for (let t of e) {
|
|
973
1399
|
let e = String(t[i] ?? "Unknown");
|
|
974
|
-
|
|
1400
|
+
o[e] || (o[e] = []), o[e].push(t);
|
|
975
1401
|
}
|
|
976
|
-
return Object.entries(
|
|
977
|
-
let
|
|
1402
|
+
return Object.entries(o).map(([e, t]) => {
|
|
1403
|
+
let o = n ? t.map((e) => Number(e[n]) || 0) : [], s;
|
|
978
1404
|
switch (r) {
|
|
979
1405
|
case "count":
|
|
980
|
-
|
|
1406
|
+
s = t.length;
|
|
981
1407
|
break;
|
|
982
1408
|
case "avg":
|
|
983
|
-
|
|
1409
|
+
s = o.length > 0 ? o.reduce((e, t) => e + t, 0) / o.length : 0;
|
|
984
1410
|
break;
|
|
985
1411
|
case "min":
|
|
986
|
-
|
|
1412
|
+
s = o.length > 0 ? Math.min(...o) : 0;
|
|
987
1413
|
break;
|
|
988
1414
|
case "max":
|
|
989
|
-
|
|
1415
|
+
s = o.length > 0 ? Math.max(...o) : 0;
|
|
990
1416
|
break;
|
|
991
1417
|
default:
|
|
992
|
-
|
|
1418
|
+
s = o.reduce((e, t) => e + t, 0);
|
|
993
1419
|
break;
|
|
994
1420
|
}
|
|
995
1421
|
return {
|
|
996
1422
|
[i]: e,
|
|
997
|
-
[
|
|
1423
|
+
[a]: s
|
|
998
1424
|
};
|
|
999
1425
|
});
|
|
1000
1426
|
}
|
|
1001
|
-
async function
|
|
1427
|
+
async function Pt(e, t, n, r, i) {
|
|
1002
1428
|
if (!e.length || !t) return e;
|
|
1003
|
-
let a = i || ((e, t) => t),
|
|
1429
|
+
let a = i || ((e, t) => t), o = `__raw_${t}`, c = n?.fields?.[t];
|
|
1004
1430
|
if (!c) {
|
|
1005
1431
|
let n = /^\d{4}-\d{2}-\d{2}/;
|
|
1006
1432
|
return e.map((e) => {
|
|
1007
|
-
let r = e[t], i = String(r ?? ""),
|
|
1433
|
+
let r = e[t], i = String(r ?? ""), s = n.test(i) ? i : At(i);
|
|
1008
1434
|
return {
|
|
1009
1435
|
...e,
|
|
1010
|
-
[t]: a(i,
|
|
1011
|
-
[
|
|
1436
|
+
[t]: a(i, s),
|
|
1437
|
+
[o]: r
|
|
1012
1438
|
};
|
|
1013
1439
|
});
|
|
1014
1440
|
}
|
|
@@ -1016,21 +1442,21 @@ async function nt(e, t, n, r, i) {
|
|
|
1016
1442
|
if (l === "select" || l === "picklist" || l === "dropdown") {
|
|
1017
1443
|
let n = c.options || [];
|
|
1018
1444
|
if (n.length === 0) return e.map((e) => {
|
|
1019
|
-
let n = e[t], r = String(n ?? ""), i =
|
|
1445
|
+
let n = e[t], r = String(n ?? ""), i = At(r);
|
|
1020
1446
|
return {
|
|
1021
1447
|
...e,
|
|
1022
1448
|
[t]: a(r, i),
|
|
1023
|
-
[
|
|
1449
|
+
[o]: n
|
|
1024
1450
|
};
|
|
1025
1451
|
});
|
|
1026
1452
|
let r = {};
|
|
1027
1453
|
for (let e of n) typeof e == "string" ? r[e] = e : e && typeof e == "object" && (r[String(e.value)] = e.label || String(e.value));
|
|
1028
1454
|
return e.map((e) => {
|
|
1029
|
-
let n = e[t], i = String(n ?? ""),
|
|
1455
|
+
let n = e[t], i = String(n ?? ""), s = r[i] || At(i);
|
|
1030
1456
|
return {
|
|
1031
1457
|
...e,
|
|
1032
|
-
[t]: a(i,
|
|
1033
|
-
[
|
|
1458
|
+
[t]: a(i, s),
|
|
1459
|
+
[o]: n
|
|
1034
1460
|
};
|
|
1035
1461
|
});
|
|
1036
1462
|
}
|
|
@@ -1038,16 +1464,16 @@ async function nt(e, t, n, r, i) {
|
|
|
1038
1464
|
let n = c.reference_to || c.reference;
|
|
1039
1465
|
if (!n || !r || typeof r.find != "function") return e.map((e) => ({
|
|
1040
1466
|
...e,
|
|
1041
|
-
[
|
|
1467
|
+
[o]: e[t]
|
|
1042
1468
|
}));
|
|
1043
1469
|
let i = [...new Set(e.map((e) => e[t]).filter((e) => e != null))];
|
|
1044
1470
|
if (i.length === 0) return e.map((e) => ({
|
|
1045
1471
|
...e,
|
|
1046
|
-
[
|
|
1472
|
+
[o]: e[t]
|
|
1047
1473
|
}));
|
|
1048
1474
|
let a = c.id_field || "id";
|
|
1049
1475
|
try {
|
|
1050
|
-
let l =
|
|
1476
|
+
let l = s(await r.find(n, {
|
|
1051
1477
|
$filter: { [a]: { $in: i } },
|
|
1052
1478
|
$top: i.length
|
|
1053
1479
|
})), u = c.reference_field || c.display_field || "name", d = {};
|
|
@@ -1060,316 +1486,322 @@ async function nt(e, t, n, r, i) {
|
|
|
1060
1486
|
return {
|
|
1061
1487
|
...e,
|
|
1062
1488
|
[t]: d[r] || r,
|
|
1063
|
-
[
|
|
1489
|
+
[o]: n
|
|
1064
1490
|
};
|
|
1065
1491
|
});
|
|
1066
1492
|
} catch (n) {
|
|
1067
1493
|
return console.warn("[ObjectChart] Failed to resolve lookup labels:", n), e.map((e) => ({
|
|
1068
1494
|
...e,
|
|
1069
|
-
[
|
|
1495
|
+
[o]: e[t]
|
|
1070
1496
|
}));
|
|
1071
1497
|
}
|
|
1072
1498
|
}
|
|
1073
1499
|
if (l === "date" || l === "datetime" || l === "date_time" || l === "timestamp" || l === "time") return e.map((e) => ({
|
|
1074
1500
|
...e,
|
|
1075
|
-
[
|
|
1501
|
+
[o]: e[t]
|
|
1076
1502
|
}));
|
|
1077
1503
|
let u = /^\d{4}-\d{2}-\d{2}/;
|
|
1078
1504
|
return e.map((e) => {
|
|
1079
1505
|
let n = e[t], r = String(n ?? "");
|
|
1080
1506
|
return {
|
|
1081
1507
|
...e,
|
|
1082
|
-
[t]: u.test(r) ? r :
|
|
1083
|
-
[
|
|
1508
|
+
[t]: u.test(r) ? r : At(r),
|
|
1509
|
+
[o]: n
|
|
1084
1510
|
};
|
|
1085
1511
|
});
|
|
1086
1512
|
}
|
|
1087
|
-
var
|
|
1088
|
-
let { schema:
|
|
1089
|
-
|
|
1090
|
-
de.current =
|
|
1091
|
-
}, [
|
|
1092
|
-
let [fe,
|
|
1093
|
-
d:
|
|
1094
|
-
dim:
|
|
1095
|
-
val:
|
|
1513
|
+
var Ft = (e) => {
|
|
1514
|
+
let { schema: t } = e, m = e.onSegmentClick, h = te(Ie), g = e.dataSource || h?.dataSource, ue = Le(t.bind), { fieldOptionLabel: w } = He(), de = re(w);
|
|
1515
|
+
ne(() => {
|
|
1516
|
+
de.current = w;
|
|
1517
|
+
}, [w]);
|
|
1518
|
+
let [fe, pe] = v([]), [D, me] = v(null), [he, O] = v(() => !(Array.isArray(t.data) && t.data.length > 0) && (!!t.objectName || !!t.dataset)), [ge, _e] = v(null), [ve, ye] = v(null), [k, be] = v(null), [xe, Se] = v(null), { openRecordList: Ce } = Re(), we = F(), Te = _(() => t.aggregate ? JSON.stringify(t.aggregate) : "", [t.aggregate]), Ee = _(() => t.filter ? JSON.stringify(t.filter) : "", [t.filter]), De = _(() => t.compareTo ? JSON.stringify(t.compareTo) : "", [t.compareTo]), Oe = _(() => t.dataset ? JSON.stringify({
|
|
1519
|
+
d: t.dataset,
|
|
1520
|
+
dim: t.dimensions ?? [],
|
|
1521
|
+
val: t.values ?? []
|
|
1096
1522
|
}) : "", [
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
]),
|
|
1101
|
-
|
|
1523
|
+
t.dataset,
|
|
1524
|
+
t.dimensions,
|
|
1525
|
+
t.values
|
|
1526
|
+
]), ke = (e) => e !== "pie" && e !== "donut" && e !== "funnel";
|
|
1527
|
+
ne(() => {
|
|
1102
1528
|
let e = !1;
|
|
1103
1529
|
return (async () => {
|
|
1104
1530
|
try {
|
|
1105
|
-
let
|
|
1531
|
+
let n = {
|
|
1106
1532
|
headers: { accept: "application/json" },
|
|
1107
1533
|
credentials: "include"
|
|
1108
|
-
},
|
|
1109
|
-
if (
|
|
1110
|
-
else if (
|
|
1111
|
-
let e = Array.isArray(
|
|
1112
|
-
|
|
1534
|
+
}, a = t.objectName, o, s = null, c = t.aggregate?.groupBy;
|
|
1535
|
+
if (a) o = c && typeof c == "object" && !Array.isArray(c) ? c.field : typeof c == "string" ? c : t.xAxisKey;
|
|
1536
|
+
else if (t.dataset) {
|
|
1537
|
+
let e = Array.isArray(t.dimensions) && t.dimensions.length ? t.dimensions[0] : void 0, r = await (await fetch(`/api/v1/meta/dataset/${encodeURIComponent(t.dataset)}`, n)).json().catch(() => null);
|
|
1538
|
+
s = r?.item ?? r?.data ?? r, a = s?.object, o = ((s?.dimensions || []).find((t) => t?.name === e) ?? (s?.dimensions || [])[0])?.field ?? e;
|
|
1113
1539
|
}
|
|
1114
|
-
if (!
|
|
1115
|
-
e || (
|
|
1540
|
+
if (!a || !o) {
|
|
1541
|
+
e || (be(null), Se(null));
|
|
1116
1542
|
return;
|
|
1117
1543
|
}
|
|
1118
|
-
let
|
|
1119
|
-
if (
|
|
1544
|
+
let l = await (await fetch(`/api/v1/meta/object/${encodeURIComponent(a)}`, n)).json().catch(() => null), u = l?.item ?? l?.data ?? l, d = i(u?.fields?.[o]?.options), f = null;
|
|
1545
|
+
if (t.dataset && Array.isArray(t.dimensions)) {
|
|
1120
1546
|
let e = {};
|
|
1121
|
-
for (let
|
|
1122
|
-
let
|
|
1123
|
-
i && (e[
|
|
1547
|
+
for (let n of t.dimensions) {
|
|
1548
|
+
let t = (s?.dimensions || []).find((e) => e?.name === n)?.field ?? n, i = r(u?.fields?.[t]?.options);
|
|
1549
|
+
i && (e[n] = i);
|
|
1124
1550
|
}
|
|
1125
|
-
Object.keys(e).length > 0 && (
|
|
1551
|
+
Object.keys(e).length > 0 && (f = e);
|
|
1126
1552
|
}
|
|
1127
|
-
e || (
|
|
1553
|
+
e || (be(d), Se(f));
|
|
1128
1554
|
} catch {
|
|
1129
|
-
e || (
|
|
1555
|
+
e || (be(null), Se(null));
|
|
1130
1556
|
}
|
|
1131
1557
|
})(), () => {
|
|
1132
1558
|
e = !0;
|
|
1133
1559
|
};
|
|
1134
1560
|
}, [
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1561
|
+
t.objectName,
|
|
1562
|
+
t.dataset,
|
|
1563
|
+
Oe,
|
|
1564
|
+
Te,
|
|
1565
|
+
t.xAxisKey
|
|
1140
1566
|
]);
|
|
1141
|
-
let
|
|
1142
|
-
if (
|
|
1143
|
-
let
|
|
1144
|
-
if (
|
|
1145
|
-
let
|
|
1146
|
-
function:
|
|
1147
|
-
alias:
|
|
1567
|
+
let Ae = ee(async (e, n) => {
|
|
1568
|
+
if (t.aggregate && typeof e.aggregate == "function") {
|
|
1569
|
+
let r = t.aggregate.groupBy;
|
|
1570
|
+
if (r && typeof r == "object" && !Array.isArray(r)) {
|
|
1571
|
+
let i = t.aggregate.field, a = t.aggregate.function, o = {
|
|
1572
|
+
function: a,
|
|
1573
|
+
alias: jt(t.aggregate)
|
|
1148
1574
|
};
|
|
1149
|
-
|
|
1150
|
-
let
|
|
1151
|
-
groupBy: [
|
|
1152
|
-
aggregations: [
|
|
1153
|
-
where:
|
|
1575
|
+
a !== "count" && i && (o.field = i);
|
|
1576
|
+
let s = await e.aggregate(t.objectName, {
|
|
1577
|
+
groupBy: [r],
|
|
1578
|
+
aggregations: [o],
|
|
1579
|
+
where: n
|
|
1154
1580
|
});
|
|
1155
|
-
return Array.isArray(
|
|
1581
|
+
return Array.isArray(s) ? s : [];
|
|
1156
1582
|
}
|
|
1157
|
-
let
|
|
1158
|
-
field:
|
|
1159
|
-
function:
|
|
1160
|
-
groupBy:
|
|
1161
|
-
filter:
|
|
1583
|
+
let i = await e.aggregate(t.objectName, {
|
|
1584
|
+
field: t.aggregate.field,
|
|
1585
|
+
function: t.aggregate.function,
|
|
1586
|
+
groupBy: r,
|
|
1587
|
+
filter: n
|
|
1162
1588
|
});
|
|
1163
|
-
return Array.isArray(
|
|
1589
|
+
return Array.isArray(i) ? i : [];
|
|
1164
1590
|
}
|
|
1165
1591
|
if (typeof e.find == "function") {
|
|
1166
|
-
let
|
|
1167
|
-
return
|
|
1592
|
+
let r = s(await e.find(t.objectName, { $filter: n }));
|
|
1593
|
+
return t.aggregate && r.length > 0 && (r = Nt(r, t.aggregate)), r;
|
|
1168
1594
|
}
|
|
1169
1595
|
return [];
|
|
1170
|
-
}, [
|
|
1171
|
-
if (!e || !
|
|
1172
|
-
|
|
1596
|
+
}, [t.objectName, Te]), A = ze(), je = ee(async (e, n) => {
|
|
1597
|
+
if (!e || !t.objectName && !t.dataset) {
|
|
1598
|
+
n.current && O(!1);
|
|
1173
1599
|
return;
|
|
1174
1600
|
}
|
|
1175
|
-
|
|
1601
|
+
n.current && (O(!0), _e(null));
|
|
1176
1602
|
try {
|
|
1177
|
-
if (
|
|
1178
|
-
let
|
|
1179
|
-
dimensions: Array.isArray(
|
|
1180
|
-
measures: Array.isArray(
|
|
1181
|
-
...
|
|
1603
|
+
if (t.dataset && typeof e.queryDataset == "function") {
|
|
1604
|
+
let r = f(t.filter, A), i = await e.queryDataset(t.dataset, {
|
|
1605
|
+
dimensions: Array.isArray(t.dimensions) ? t.dimensions : [],
|
|
1606
|
+
measures: Array.isArray(t.values) ? t.values : [],
|
|
1607
|
+
...r ? { runtimeFilter: r } : {}
|
|
1182
1608
|
});
|
|
1183
|
-
|
|
1609
|
+
n.current && (pe(Array.isArray(i?.rows) ? i.rows : []), me(Array.isArray(i?.fields) ? i.fields : null));
|
|
1184
1610
|
return;
|
|
1185
1611
|
}
|
|
1186
|
-
let
|
|
1187
|
-
if (
|
|
1188
|
-
let e =
|
|
1189
|
-
if (
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1612
|
+
let r = f(t.filter, A), i = t.compareTo, a = !!i && ke(t.chartType), o = a ? u(p(t.filter, i), A) : null, [s, c] = await Promise.all([Ae(e, r), o ? Ae(e, o) : Promise.resolve([])]), l = s, d = t.aggregate?.groupBy, m = d && typeof d == "object" && !Array.isArray(d) ? d.alias || d.field : d || t.xAxisKey;
|
|
1613
|
+
if (a && c.length > 0 && t.aggregate) {
|
|
1614
|
+
let e = t.aggregate.field, n = t.aggregate.function, r = jt(t.aggregate), i = (t) => {
|
|
1615
|
+
if (t == null) return null;
|
|
1616
|
+
if (e) {
|
|
1617
|
+
let r = `${e}_${n}`;
|
|
1618
|
+
if (r in t) return Number(t[r]);
|
|
1619
|
+
if (n === "count" && `${e}_count` in t) return Number(t[`${e}_count`]);
|
|
1620
|
+
}
|
|
1621
|
+
return r in t ? Number(t[r]) : "value" in t ? Number(t.value) : "count" in t ? Number(t.count) : null;
|
|
1622
|
+
}, a = `${r}${Mt}`, o = m;
|
|
1623
|
+
if (o && l.some((e) => e[o] != null) && c.some((e) => e[o] != null)) {
|
|
1194
1624
|
let e = /* @__PURE__ */ new Map();
|
|
1195
|
-
for (let t of
|
|
1196
|
-
let
|
|
1197
|
-
e.set(
|
|
1625
|
+
for (let t of c) {
|
|
1626
|
+
let n = String(t[o] ?? "");
|
|
1627
|
+
e.set(n, i(t));
|
|
1198
1628
|
}
|
|
1199
|
-
|
|
1200
|
-
let n = String(t[
|
|
1201
|
-
return
|
|
1629
|
+
l = l.map((t) => {
|
|
1630
|
+
let n = String(t[o] ?? ""), r = e.get(n);
|
|
1631
|
+
return r == null ? t : {
|
|
1202
1632
|
...t,
|
|
1203
|
-
[
|
|
1633
|
+
[a]: r
|
|
1204
1634
|
};
|
|
1205
1635
|
});
|
|
1206
|
-
let t = new Set(
|
|
1207
|
-
for (let e of
|
|
1208
|
-
let
|
|
1209
|
-
t.has(
|
|
1210
|
-
[
|
|
1211
|
-
[
|
|
1636
|
+
let t = new Set(l.map((e) => String(e[o] ?? "")));
|
|
1637
|
+
for (let e of c) {
|
|
1638
|
+
let n = String(e[o] ?? "");
|
|
1639
|
+
t.has(n) || l.push({
|
|
1640
|
+
[o]: n,
|
|
1641
|
+
[a]: i(e)
|
|
1212
1642
|
});
|
|
1213
1643
|
}
|
|
1214
1644
|
} else {
|
|
1215
|
-
let e = Math.max(
|
|
1216
|
-
for (let
|
|
1217
|
-
let e =
|
|
1218
|
-
t.push(
|
|
1645
|
+
let e = Math.max(l.length, c.length), t = [];
|
|
1646
|
+
for (let n = 0; n < e; n++) {
|
|
1647
|
+
let e = l[n] || {}, r = c[n];
|
|
1648
|
+
t.push(r ? {
|
|
1219
1649
|
...e,
|
|
1220
|
-
[
|
|
1650
|
+
[a]: i(r)
|
|
1221
1651
|
} : e);
|
|
1222
1652
|
}
|
|
1223
|
-
|
|
1653
|
+
l = t;
|
|
1224
1654
|
}
|
|
1225
1655
|
}
|
|
1226
|
-
if (
|
|
1227
|
-
let
|
|
1228
|
-
|
|
1656
|
+
if (m && typeof e.getObjectSchema == "function") try {
|
|
1657
|
+
let n = await e.getObjectSchema(t.objectName);
|
|
1658
|
+
l = await Pt(l, m, n, e, (e, n) => de.current(t.objectName, m, e, n));
|
|
1229
1659
|
} catch {}
|
|
1230
|
-
|
|
1660
|
+
n.current && pe(l);
|
|
1231
1661
|
} catch (e) {
|
|
1232
|
-
console.error("[ObjectChart] Fetch error:", e),
|
|
1662
|
+
console.error("[ObjectChart] Fetch error:", e), n.current && _e(e instanceof Error ? e.message : "Failed to load chart data");
|
|
1233
1663
|
} finally {
|
|
1234
|
-
|
|
1664
|
+
n.current && O(!1);
|
|
1235
1665
|
}
|
|
1236
1666
|
}, [
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1667
|
+
t.objectName,
|
|
1668
|
+
Oe,
|
|
1669
|
+
Te,
|
|
1670
|
+
Ee,
|
|
1671
|
+
De,
|
|
1672
|
+
t.xAxisKey,
|
|
1673
|
+
t.chartType,
|
|
1674
|
+
Ae,
|
|
1675
|
+
A
|
|
1245
1676
|
]);
|
|
1246
|
-
|
|
1677
|
+
ne(() => {
|
|
1247
1678
|
let e = { current: !0 };
|
|
1248
|
-
return (
|
|
1679
|
+
return (t.objectName || t.dataset) && !ue && !t.data ? je(g, e) : e.current && O(!1), () => {
|
|
1249
1680
|
e.current = !1;
|
|
1250
1681
|
};
|
|
1251
1682
|
}, [
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1683
|
+
t.objectName,
|
|
1684
|
+
Oe,
|
|
1685
|
+
g,
|
|
1686
|
+
ue,
|
|
1687
|
+
t.data,
|
|
1688
|
+
Ee,
|
|
1689
|
+
Te,
|
|
1690
|
+
De,
|
|
1691
|
+
je
|
|
1261
1692
|
]);
|
|
1262
|
-
let
|
|
1263
|
-
if (!
|
|
1264
|
-
let e = /* @__PURE__ */ new Map(), t = `__raw_${
|
|
1265
|
-
for (let n of
|
|
1266
|
-
let r = n?.[
|
|
1693
|
+
let Me = ue || t.data || fe, j = Array.isArray(Me) ? Me : [], M = t.drillDown, Ne = t.aggregate?.groupBy || t.xAxisKey, N = _(() => {
|
|
1694
|
+
if (!Ne) return /* @__PURE__ */ new Map();
|
|
1695
|
+
let e = /* @__PURE__ */ new Map(), t = `__raw_${Ne}`;
|
|
1696
|
+
for (let n of j) {
|
|
1697
|
+
let r = n?.[Ne];
|
|
1267
1698
|
if (r == null) continue;
|
|
1268
1699
|
let i = t in (n || {}) ? n[t] : r;
|
|
1269
1700
|
e.set(String(r), i);
|
|
1270
1701
|
}
|
|
1271
1702
|
return e;
|
|
1272
|
-
}, [
|
|
1273
|
-
let e = Array.isArray(
|
|
1274
|
-
if (!
|
|
1275
|
-
let
|
|
1703
|
+
}, [j, Ne]), P = t.compareTo, Pe = t.aggregate ? jt(t.aggregate) : void 0, I = Pe ? `${Pe}${Mt}` : void 0, L = !!P && ke(t.chartType) && !!I && j.some((e) => e[I] != null), R = _(() => {
|
|
1704
|
+
let e = Array.isArray(t.series) ? t.series : null;
|
|
1705
|
+
if (!L) return e;
|
|
1706
|
+
let n = e || [{ dataKey: Pe }], r = {
|
|
1276
1707
|
vsLastWeek: "Previous week",
|
|
1277
1708
|
vsLastMonth: "Previous month",
|
|
1278
1709
|
vsLastQuarter: "Previous quarter",
|
|
1279
1710
|
vsLastYear: "Previous year",
|
|
1280
1711
|
vsYesterday: "Yesterday",
|
|
1281
1712
|
vsPreviousPeriod: "Previous period"
|
|
1282
|
-
}[
|
|
1283
|
-
return [...
|
|
1713
|
+
}[a(P, t.filter)] || "Previous period";
|
|
1714
|
+
return [...n.map((e) => ({
|
|
1284
1715
|
...e,
|
|
1285
1716
|
variant: e.variant || "current"
|
|
1286
1717
|
})), {
|
|
1287
|
-
dataKey:
|
|
1288
|
-
label:
|
|
1718
|
+
dataKey: I,
|
|
1719
|
+
label: r,
|
|
1289
1720
|
variant: "comparison"
|
|
1290
1721
|
}];
|
|
1291
1722
|
}, [
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1723
|
+
L,
|
|
1724
|
+
t.series,
|
|
1725
|
+
Pe,
|
|
1726
|
+
I,
|
|
1727
|
+
t.filter,
|
|
1728
|
+
P
|
|
1729
|
+
]), z = t.dataset ? n(l(j, xe), t.dimensions, t.values, D) : null, B = z ? {
|
|
1730
|
+
...t,
|
|
1731
|
+
data: z.data,
|
|
1732
|
+
xAxisKey: z.xAxisKey,
|
|
1733
|
+
series: z.series
|
|
1302
1734
|
} : {
|
|
1303
|
-
...
|
|
1304
|
-
data:
|
|
1305
|
-
...
|
|
1306
|
-
},
|
|
1307
|
-
...
|
|
1308
|
-
...
|
|
1309
|
-
} : void 0,
|
|
1310
|
-
...
|
|
1311
|
-
colors:
|
|
1312
|
-
...
|
|
1735
|
+
...t,
|
|
1736
|
+
data: j,
|
|
1737
|
+
...R ? { series: R } : {}
|
|
1738
|
+
}, V = t.colors && !Array.isArray(t.colors) && typeof t.colors == "object" ? t.colors : null, Ue = Array.isArray(t.colors) ? t.colors : void 0, We = k || V ? {
|
|
1739
|
+
...k || {},
|
|
1740
|
+
...V || {}
|
|
1741
|
+
} : void 0, Ge = {
|
|
1742
|
+
...B,
|
|
1743
|
+
colors: Ue,
|
|
1744
|
+
...We ? { categoryColors: We } : {}
|
|
1313
1745
|
};
|
|
1314
|
-
if (
|
|
1315
|
-
className: "p-2 " + (
|
|
1746
|
+
if (he && j.length === 0) return /* @__PURE__ */ E("div", {
|
|
1747
|
+
className: "p-2 " + (t.className || ""),
|
|
1316
1748
|
"data-testid": "chart-loading",
|
|
1317
1749
|
role: "status",
|
|
1318
1750
|
"aria-busy": "true",
|
|
1319
1751
|
"aria-live": "polite",
|
|
1320
|
-
children: [/* @__PURE__ */
|
|
1752
|
+
children: [/* @__PURE__ */ T("span", {
|
|
1321
1753
|
className: "sr-only",
|
|
1322
1754
|
children: "Loading chart data…"
|
|
1323
|
-
}), /* @__PURE__ */
|
|
1755
|
+
}), /* @__PURE__ */ T(y, { className: "h-full" })]
|
|
1324
1756
|
});
|
|
1325
|
-
if (
|
|
1326
|
-
className: "flex flex-col items-center justify-center gap-2 p-4 " + (
|
|
1757
|
+
if (ge) return /* @__PURE__ */ E("div", {
|
|
1758
|
+
className: "flex flex-col items-center justify-center gap-2 p-4 " + (t.className || ""),
|
|
1327
1759
|
"data-testid": "chart-error",
|
|
1328
1760
|
role: "alert",
|
|
1329
1761
|
children: [
|
|
1330
|
-
/* @__PURE__ */
|
|
1331
|
-
/* @__PURE__ */
|
|
1762
|
+
/* @__PURE__ */ T(Be, { className: "h-6 w-6 text-destructive opacity-60" }),
|
|
1763
|
+
/* @__PURE__ */ T("p", {
|
|
1332
1764
|
className: "text-xs text-destructive font-medium",
|
|
1333
1765
|
children: "Failed to load chart data"
|
|
1334
1766
|
}),
|
|
1335
|
-
/* @__PURE__ */
|
|
1767
|
+
/* @__PURE__ */ T("p", {
|
|
1336
1768
|
className: "text-xs text-muted-foreground max-w-xs text-center",
|
|
1337
|
-
children:
|
|
1769
|
+
children: ge
|
|
1338
1770
|
})
|
|
1339
1771
|
]
|
|
1340
1772
|
});
|
|
1341
|
-
if (!
|
|
1342
|
-
className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (
|
|
1773
|
+
if (!g && t.objectName && j.length === 0) return /* @__PURE__ */ E("div", {
|
|
1774
|
+
className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (t.className || ""),
|
|
1343
1775
|
"data-testid": "chart-no-datasource",
|
|
1344
1776
|
children: [
|
|
1345
1777
|
"No data source available for “",
|
|
1346
|
-
|
|
1778
|
+
t.objectName,
|
|
1347
1779
|
"”"
|
|
1348
1780
|
]
|
|
1349
1781
|
});
|
|
1350
|
-
let
|
|
1351
|
-
let t = e.category, n = t != null &&
|
|
1352
|
-
|
|
1782
|
+
let H = c(M) ? (e) => {
|
|
1783
|
+
let t = e.category, n = t != null && N.has(String(t)) ? N.get(String(t)) : t;
|
|
1784
|
+
ye({
|
|
1353
1785
|
...e,
|
|
1354
1786
|
category: n,
|
|
1355
1787
|
categoryLabel: t,
|
|
1356
1788
|
scope: "cell"
|
|
1357
1789
|
});
|
|
1358
|
-
} : void 0,
|
|
1359
|
-
let e =
|
|
1360
|
-
...
|
|
1790
|
+
} : void 0, Ke = m ?? H, qe = !m && ve && t.objectName ? (() => {
|
|
1791
|
+
let e = o(M, ve, { groupByField: Ne }), n = {
|
|
1792
|
+
...t.filter || {},
|
|
1361
1793
|
...e
|
|
1362
|
-
},
|
|
1794
|
+
}, r = d(M, ve, t.title || "Details"), i = M?.target ?? "drawer", a = /* @__PURE__ */ T("div", {
|
|
1363
1795
|
className: "overflow-auto",
|
|
1364
1796
|
"data-testid": "chart-drill-body",
|
|
1365
|
-
children: /* @__PURE__ */
|
|
1797
|
+
children: /* @__PURE__ */ T(Fe, {
|
|
1366
1798
|
schema: {
|
|
1367
1799
|
type: "object-data-table",
|
|
1368
|
-
objectName:
|
|
1369
|
-
filter:
|
|
1800
|
+
objectName: t.objectName,
|
|
1801
|
+
filter: n,
|
|
1370
1802
|
pagination: !0,
|
|
1371
|
-
pageSize:
|
|
1372
|
-
columns:
|
|
1803
|
+
pageSize: M?.maxRows,
|
|
1804
|
+
columns: M?.columns?.map((e) => ({
|
|
1373
1805
|
accessorKey: e,
|
|
1374
1806
|
header: e
|
|
1375
1807
|
})),
|
|
@@ -1379,58 +1811,58 @@ var rt = (e) => {
|
|
|
1379
1811
|
target: "dialog"
|
|
1380
1812
|
}
|
|
1381
1813
|
},
|
|
1382
|
-
dataSource:
|
|
1814
|
+
dataSource: g
|
|
1383
1815
|
})
|
|
1384
|
-
}),
|
|
1816
|
+
}), s = Ce && t.objectName ? /* @__PURE__ */ E(ie, {
|
|
1385
1817
|
type: "button",
|
|
1386
1818
|
variant: "ghost",
|
|
1387
1819
|
size: "sm",
|
|
1388
1820
|
"data-testid": "drill-open-in-list",
|
|
1389
1821
|
onClick: () => {
|
|
1390
|
-
|
|
1822
|
+
Ce(t.objectName, n), ye(null);
|
|
1391
1823
|
},
|
|
1392
|
-
children: [
|
|
1824
|
+
children: [we("dashboard.openInList", "Open in list"), /* @__PURE__ */ T(Ve, { className: "ml-1 h-3.5 w-3.5" })]
|
|
1393
1825
|
}) : null;
|
|
1394
|
-
return
|
|
1826
|
+
return i === "dialog" ? /* @__PURE__ */ T(ae, {
|
|
1395
1827
|
open: !0,
|
|
1396
|
-
onOpenChange: (e) => !e &&
|
|
1397
|
-
children: /* @__PURE__ */
|
|
1828
|
+
onOpenChange: (e) => !e && ye(null),
|
|
1829
|
+
children: /* @__PURE__ */ E(b, {
|
|
1398
1830
|
className: "max-w-4xl",
|
|
1399
|
-
children: [/* @__PURE__ */
|
|
1831
|
+
children: [/* @__PURE__ */ E(x, {
|
|
1400
1832
|
className: "flex-row items-center justify-between gap-4 pr-8",
|
|
1401
|
-
children: [/* @__PURE__ */
|
|
1402
|
-
}),
|
|
1833
|
+
children: [/* @__PURE__ */ T(S, { children: r }), s]
|
|
1834
|
+
}), a]
|
|
1403
1835
|
})
|
|
1404
|
-
}) : /* @__PURE__ */
|
|
1836
|
+
}) : /* @__PURE__ */ T(oe, {
|
|
1405
1837
|
open: !0,
|
|
1406
|
-
onOpenChange: (e) => !e &&
|
|
1407
|
-
children: /* @__PURE__ */
|
|
1838
|
+
onOpenChange: (e) => !e && ye(null),
|
|
1839
|
+
children: /* @__PURE__ */ E(se, {
|
|
1408
1840
|
side: "right",
|
|
1409
1841
|
className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col",
|
|
1410
|
-
children: [/* @__PURE__ */
|
|
1842
|
+
children: [/* @__PURE__ */ E(ce, {
|
|
1411
1843
|
className: "flex-row items-center justify-between gap-4 pr-8",
|
|
1412
|
-
children: [/* @__PURE__ */
|
|
1413
|
-
}), /* @__PURE__ */
|
|
1844
|
+
children: [/* @__PURE__ */ T(le, { children: r }), s]
|
|
1845
|
+
}), /* @__PURE__ */ T("div", {
|
|
1414
1846
|
className: "flex-1 overflow-hidden mt-2",
|
|
1415
|
-
children:
|
|
1847
|
+
children: a
|
|
1416
1848
|
})]
|
|
1417
1849
|
})
|
|
1418
1850
|
});
|
|
1419
1851
|
})() : null;
|
|
1420
|
-
return /* @__PURE__ */
|
|
1852
|
+
return /* @__PURE__ */ E("div", {
|
|
1421
1853
|
className: "relative",
|
|
1422
1854
|
children: [
|
|
1423
|
-
/* @__PURE__ */ C
|
|
1424
|
-
/* @__PURE__ */
|
|
1855
|
+
/* @__PURE__ */ T(C, { active: he && j.length > 0 }),
|
|
1856
|
+
/* @__PURE__ */ T($, {
|
|
1425
1857
|
...e,
|
|
1426
|
-
schema:
|
|
1427
|
-
onChartClick:
|
|
1858
|
+
schema: Ge,
|
|
1859
|
+
onChartClick: Ke
|
|
1428
1860
|
}),
|
|
1429
|
-
|
|
1861
|
+
qe
|
|
1430
1862
|
]
|
|
1431
1863
|
});
|
|
1432
1864
|
};
|
|
1433
|
-
e.register("object-chart",
|
|
1865
|
+
e.register("object-chart", Ft, {
|
|
1434
1866
|
namespace: "plugin-charts",
|
|
1435
1867
|
label: "Object Chart",
|
|
1436
1868
|
category: "view",
|
|
@@ -1462,11 +1894,11 @@ e.register("object-chart", rt, {
|
|
|
1462
1894
|
});
|
|
1463
1895
|
//#endregion
|
|
1464
1896
|
//#region src/index.tsx
|
|
1465
|
-
var
|
|
1466
|
-
"bar-chart":
|
|
1897
|
+
var It = {
|
|
1898
|
+
"bar-chart": kt,
|
|
1467
1899
|
chart: $
|
|
1468
1900
|
};
|
|
1469
|
-
e.register("bar-chart",
|
|
1901
|
+
e.register("bar-chart", kt, {
|
|
1470
1902
|
namespace: "plugin-charts",
|
|
1471
1903
|
label: "Bar Chart",
|
|
1472
1904
|
category: "plugin",
|
|
@@ -1530,7 +1962,7 @@ e.register("bar-chart", $e, {
|
|
|
1530
1962
|
height: 400,
|
|
1531
1963
|
color: "#8884d8"
|
|
1532
1964
|
}
|
|
1533
|
-
}), e.register("chart",
|
|
1965
|
+
}), e.register("chart", Ft, {
|
|
1534
1966
|
namespace: "view",
|
|
1535
1967
|
category: "view",
|
|
1536
1968
|
label: "Chart",
|
|
@@ -1697,4 +2129,4 @@ e.register("bar-chart", $e, {
|
|
|
1697
2129
|
defaultProps: { chartType: "scatter" }
|
|
1698
2130
|
});
|
|
1699
2131
|
//#endregion
|
|
1700
|
-
export {
|
|
2132
|
+
export { kt as ChartBarRenderer, $ as ChartRenderer, Ft as ObjectChart, It as chartComponents };
|