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