@object-ui/plugin-charts 17.3.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 +646 -0
- package/README.md +0 -11
- package/dist/AdvancedChartImpl.d.ts +28 -7
- package/dist/ChartContainerImpl.d.ts +1 -1
- package/dist/ChartRenderer.d.ts +2 -5
- package/dist/ObjectChart.d.ts +25 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +734 -624
- package/dist/index.umd.cjs +2 -2
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import { ComponentRegistry as e, buildCategoryRank as t, buildChartSeries as n,
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import { Button as
|
|
5
|
-
import { Fragment as
|
|
6
|
-
import { Area as
|
|
7
|
-
import { SchemaRenderer as
|
|
8
|
-
import { AlertCircle as
|
|
9
|
-
import { useSafeFieldLabel as
|
|
1
|
+
import { ComponentRegistry as e, buildCategoryRank as t, buildChartSeries as n, 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
|
+
import * as h from "react";
|
|
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 He(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 U(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 qe, Je, Ye, Xe, W, G, K, Ze, Qe = R((() => {
|
|
|
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__ */
|
|
208
|
+
children: /* @__PURE__ */ E(D, {
|
|
209
209
|
data: e,
|
|
210
210
|
margin: {
|
|
211
211
|
top: 10,
|
|
@@ -214,66 +214,66 @@ function tt({ 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 tt({ 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 tt({ 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 tt({ 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,62 +329,65 @@ function tt({ 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 =
|
|
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 J({ id: e, className: t, children: n, config: r, disableSettleRemount: i,
|
|
341
|
-
let
|
|
342
|
-
|
|
340
|
+
function J({ id: e, className: t, children: n, config: r, disableSettleRemount: i, style: a, ...o }) {
|
|
341
|
+
let s = h.useId(), c = `chart-${e || s.replace(/:/g, "")}`, l = h.useRef(null), [u, d] = h.useState(0);
|
|
342
|
+
h.useEffect(() => {
|
|
343
343
|
if (i) return;
|
|
344
|
-
let e =
|
|
344
|
+
let e = l.current;
|
|
345
345
|
if (e == null || typeof ResizeObserver > "u") return;
|
|
346
346
|
let t = !1, n, r = new ResizeObserver((e) => {
|
|
347
347
|
if (t) return;
|
|
348
348
|
let i = e[0]?.contentRect;
|
|
349
349
|
i == null || i.width <= 0 || i.height <= 0 || (n != null && clearTimeout(n), n = setTimeout(() => {
|
|
350
|
-
t = !0, r.disconnect(),
|
|
350
|
+
t = !0, r.disconnect(), d((e) => e + 1);
|
|
351
351
|
}, 80));
|
|
352
352
|
});
|
|
353
353
|
return r.observe(e), () => {
|
|
354
354
|
t = !0, n != null && clearTimeout(n), r.disconnect();
|
|
355
355
|
};
|
|
356
|
-
}, [i])
|
|
356
|
+
}, [i]);
|
|
357
|
+
let f = a?.height != null || a?.minHeight != null, p = a?.width != null || a?.minWidth != null, m = {
|
|
358
|
+
...f ? {} : { minHeight: mt },
|
|
359
|
+
...p ? {} : { minWidth: 0 },
|
|
360
|
+
...a
|
|
361
|
+
};
|
|
362
|
+
return /* @__PURE__ */ T(pt.Provider, {
|
|
357
363
|
value: { config: r },
|
|
358
|
-
children: /* @__PURE__ */
|
|
359
|
-
ref:
|
|
364
|
+
children: /* @__PURE__ */ E("div", {
|
|
365
|
+
ref: l,
|
|
360
366
|
"data-slot": "chart",
|
|
361
|
-
"data-chart":
|
|
367
|
+
"data-chart": c,
|
|
362
368
|
className: Y("block w-full h-[350px] text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground", t),
|
|
363
|
-
style:
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
},
|
|
368
|
-
...a,
|
|
369
|
-
children: [/* @__PURE__ */ w(ct, {
|
|
370
|
-
id: s,
|
|
369
|
+
style: m,
|
|
370
|
+
...o,
|
|
371
|
+
children: [/* @__PURE__ */ T(X, {
|
|
372
|
+
id: c,
|
|
371
373
|
config: r
|
|
372
|
-
}), /* @__PURE__ */
|
|
374
|
+
}), /* @__PURE__ */ T(Fe, {
|
|
373
375
|
width: "100%",
|
|
374
376
|
height: "100%",
|
|
377
|
+
...f ? {} : { minHeight: mt },
|
|
375
378
|
children: n
|
|
376
|
-
},
|
|
379
|
+
}, u)]
|
|
377
380
|
})
|
|
378
381
|
});
|
|
379
382
|
}
|
|
380
|
-
function
|
|
381
|
-
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(() => {
|
|
382
385
|
if (i || !t?.length) return null;
|
|
383
|
-
let [e] = t, n = `${f || e?.dataKey || e?.name || "value"}`, r =
|
|
384
|
-
return s ? /* @__PURE__ */
|
|
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", {
|
|
385
388
|
className: Y("font-medium", c),
|
|
386
389
|
children: s(a, t)
|
|
387
|
-
}) : a ? /* @__PURE__ */
|
|
390
|
+
}) : a ? /* @__PURE__ */ T("div", {
|
|
388
391
|
className: Y("font-medium", c),
|
|
389
392
|
children: a
|
|
390
393
|
}) : null;
|
|
@@ -398,30 +401,30 @@ function it({ active: e, payload: t, className: n, indicator: r = "dot", hideLab
|
|
|
398
401
|
f
|
|
399
402
|
]);
|
|
400
403
|
if (!e || !t?.length) return null;
|
|
401
|
-
let
|
|
402
|
-
return /* @__PURE__ */
|
|
404
|
+
let ee = t.length === 1 && r !== "dot";
|
|
405
|
+
return /* @__PURE__ */ E("div", {
|
|
403
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),
|
|
404
|
-
children: [
|
|
407
|
+
children: [ee ? null : m, /* @__PURE__ */ T("div", {
|
|
405
408
|
className: "grid gap-1.5",
|
|
406
409
|
children: t.filter((e) => e.type !== "none").map((e, t) => {
|
|
407
|
-
let n = `${d || e.name || e.dataKey || "value"}`, i =
|
|
408
|
-
return /* @__PURE__ */
|
|
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", {
|
|
409
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" : ""),
|
|
410
|
-
children: l && e?.value !== void 0 && e.name ? l(e.value, e.name, e, t, e.payload) : /* @__PURE__ */
|
|
411
|
-
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" : "",
|
|
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" : ""),
|
|
412
415
|
style: {
|
|
413
416
|
"--color-bg": o,
|
|
414
417
|
"--color-border": o
|
|
415
418
|
}
|
|
416
|
-
}), /* @__PURE__ */
|
|
417
|
-
className: Y("flex flex-1 justify-between leading-none",
|
|
418
|
-
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", {
|
|
419
422
|
className: "grid gap-1.5",
|
|
420
|
-
children: [
|
|
423
|
+
children: [ee ? m : null, /* @__PURE__ */ T("span", {
|
|
421
424
|
className: "text-muted-foreground",
|
|
422
425
|
children: i?.label || e.name
|
|
423
426
|
})]
|
|
424
|
-
}), e.value && /* @__PURE__ */
|
|
427
|
+
}), e.value && /* @__PURE__ */ T("span", {
|
|
425
428
|
className: "text-foreground font-mono font-medium tabular-nums",
|
|
426
429
|
children: e.value.toLocaleString()
|
|
427
430
|
})]
|
|
@@ -431,15 +434,15 @@ function it({ active: e, payload: t, className: n, indicator: r = "dot", hideLab
|
|
|
431
434
|
})]
|
|
432
435
|
});
|
|
433
436
|
}
|
|
434
|
-
function
|
|
435
|
-
let { config: a } =
|
|
436
|
-
return n?.length ? /* @__PURE__ */
|
|
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", {
|
|
437
440
|
className: Y("flex items-center justify-center gap-4", r === "top" ? "pb-3" : "pt-3", e),
|
|
438
441
|
children: n.filter((e) => e.type !== "none").map((e) => {
|
|
439
|
-
let n = `${i || e.dataKey || "value"}`, r =
|
|
440
|
-
return /* @__PURE__ */
|
|
442
|
+
let n = `${i || e.dataKey || "value"}`, r = dt(a, e, n);
|
|
443
|
+
return /* @__PURE__ */ E("div", {
|
|
441
444
|
className: Y("[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"),
|
|
442
|
-
children: [r?.icon && !t ? /* @__PURE__ */
|
|
445
|
+
children: [r?.icon && !t ? /* @__PURE__ */ T(r.icon, {}) : /* @__PURE__ */ T("div", {
|
|
443
446
|
className: "h-2 w-2 shrink-0 rounded-[2px]",
|
|
444
447
|
style: { backgroundColor: e.color }
|
|
445
448
|
}), r?.label]
|
|
@@ -447,18 +450,18 @@ function at({ className: e, hideIcon: t = !1, payload: n, verticalAlign: r = "bo
|
|
|
447
450
|
})
|
|
448
451
|
}) : null;
|
|
449
452
|
}
|
|
450
|
-
function
|
|
453
|
+
function dt(e, t, n) {
|
|
451
454
|
if (typeof t != "object" || !t) return;
|
|
452
455
|
let r = "payload" in t && typeof t.payload == "object" && t.payload !== null ? t.payload : void 0, i = n;
|
|
453
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];
|
|
454
457
|
}
|
|
455
|
-
var Y,
|
|
456
|
-
Y = (...e) => e.filter(Boolean).join(" "),
|
|
458
|
+
var Y, ft, pt, mt, X, Z, ht, gt = L((() => {
|
|
459
|
+
Y = (...e) => e.filter(Boolean).join(" "), ft = {
|
|
457
460
|
light: "",
|
|
458
461
|
dark: ".dark"
|
|
459
|
-
},
|
|
462
|
+
}, pt = h.createContext(null), mt = 280, X = ({ id: e, config: t }) => {
|
|
460
463
|
let n = Object.entries(t).filter(([, e]) => e.theme || e.color);
|
|
461
|
-
return n.length ? /* @__PURE__ */
|
|
464
|
+
return n.length ? /* @__PURE__ */ T("style", { dangerouslySetInnerHTML: { __html: Object.entries(ft).map(([t, r]) => `
|
|
462
465
|
${r} [data-chart=${e}] {
|
|
463
466
|
${n.map(([e, n]) => {
|
|
464
467
|
let r = n.theme?.[t] || n.color;
|
|
@@ -466,48 +469,48 @@ ${n.map(([e, n]) => {
|
|
|
466
469
|
}).join("\n")}
|
|
467
470
|
}
|
|
468
471
|
`).join("\n") } }) : null;
|
|
469
|
-
}, Z =
|
|
472
|
+
}, Z = Ie, ht = k;
|
|
470
473
|
}));
|
|
471
474
|
//#endregion
|
|
472
475
|
//#region src/chartDrillEvents.ts
|
|
473
|
-
function
|
|
476
|
+
function _t(e) {
|
|
474
477
|
return e?.[0]?.dataKey || "value";
|
|
475
478
|
}
|
|
476
|
-
function
|
|
479
|
+
function vt(e, t, n) {
|
|
477
480
|
if (!e) return null;
|
|
478
481
|
let r = e.payload ?? e, i = r?.[t];
|
|
479
482
|
if (i == null) return null;
|
|
480
|
-
let a =
|
|
483
|
+
let a = _t(n);
|
|
481
484
|
return {
|
|
482
485
|
category: String(i),
|
|
483
486
|
series: a,
|
|
484
487
|
value: typeof r?.[a] == "number" ? r[a] : void 0
|
|
485
488
|
};
|
|
486
489
|
}
|
|
487
|
-
function
|
|
490
|
+
function yt(e, t) {
|
|
488
491
|
if (!e) return null;
|
|
489
492
|
let n = e.name ?? e.payload?.name ?? e.root?.name;
|
|
490
493
|
if (n == null) return null;
|
|
491
494
|
let r = e.value ?? e.size ?? e.payload?.size;
|
|
492
495
|
return {
|
|
493
496
|
category: String(n),
|
|
494
|
-
series:
|
|
497
|
+
series: _t(t),
|
|
495
498
|
value: typeof r == "number" ? r : void 0
|
|
496
499
|
};
|
|
497
500
|
}
|
|
498
|
-
function
|
|
501
|
+
function bt(e, t) {
|
|
499
502
|
if (!e) return null;
|
|
500
503
|
let n = e.payload ?? e, r = n?.name;
|
|
501
504
|
return r == null || n?.depth === 0 ? null : {
|
|
502
505
|
category: String(r),
|
|
503
|
-
series:
|
|
506
|
+
series: _t(t),
|
|
504
507
|
value: typeof n?.value == "number" ? n.value : void 0
|
|
505
508
|
};
|
|
506
509
|
}
|
|
507
|
-
var
|
|
508
|
-
function
|
|
510
|
+
var xt = L((() => {})), St = /* @__PURE__ */ R({ default: () => kt });
|
|
511
|
+
function Ct(e) {
|
|
509
512
|
let { x: t, y: n, width: r, height: i, name: a, fill: o } = e;
|
|
510
|
-
return r <= 0 || i <= 0 ? null : /* @__PURE__ */
|
|
513
|
+
return r <= 0 || i <= 0 ? null : /* @__PURE__ */ E("g", { children: [/* @__PURE__ */ T("rect", {
|
|
511
514
|
x: t,
|
|
512
515
|
y: n,
|
|
513
516
|
width: r,
|
|
@@ -515,7 +518,7 @@ function _t(e) {
|
|
|
515
518
|
fill: o,
|
|
516
519
|
stroke: "hsl(var(--background))",
|
|
517
520
|
strokeWidth: 2
|
|
518
|
-
}), r > 48 && i > 18 ? /* @__PURE__ */
|
|
521
|
+
}), r > 48 && i > 18 ? /* @__PURE__ */ T("text", {
|
|
519
522
|
x: t + 6,
|
|
520
523
|
y: n + 18,
|
|
521
524
|
fill: "#fff",
|
|
@@ -524,102 +527,127 @@ function _t(e) {
|
|
|
524
527
|
children: a
|
|
525
528
|
}) : null] });
|
|
526
529
|
}
|
|
527
|
-
function
|
|
528
|
-
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", {
|
|
529
532
|
className: "flex h-full w-full flex-col",
|
|
530
|
-
children: [/* @__PURE__ */
|
|
533
|
+
children: [/* @__PURE__ */ E("div", {
|
|
531
534
|
className: "mb-2 shrink-0",
|
|
532
|
-
children: [e ? /* @__PURE__ */
|
|
535
|
+
children: [e ? /* @__PURE__ */ T("div", {
|
|
533
536
|
className: "text-sm font-medium leading-tight text-foreground",
|
|
534
537
|
children: e
|
|
535
|
-
}) : null, t ? /* @__PURE__ */
|
|
538
|
+
}) : null, t ? /* @__PURE__ */ T("div", {
|
|
536
539
|
className: "text-xs leading-tight text-muted-foreground",
|
|
537
540
|
children: t
|
|
538
541
|
}) : null]
|
|
539
|
-
}), /* @__PURE__ */
|
|
542
|
+
}), /* @__PURE__ */ T("div", {
|
|
540
543
|
className: "min-h-0 flex-1",
|
|
541
544
|
children: n
|
|
542
545
|
})]
|
|
543
546
|
});
|
|
544
547
|
}
|
|
545
|
-
function
|
|
546
|
-
let
|
|
547
|
-
...
|
|
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 } : {},
|
|
548
551
|
..._ ? { style: { height: _ } } : {},
|
|
549
|
-
...
|
|
552
|
+
...g ? {
|
|
550
553
|
role: "img",
|
|
551
|
-
"aria-label":
|
|
554
|
+
"aria-label": g
|
|
552
555
|
} : {}
|
|
553
|
-
}, [C,
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
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({
|
|
557
570
|
category: e.activeLabel == null ? void 0 : String(e.activeLabel),
|
|
558
|
-
|
|
559
|
-
|
|
571
|
+
categoryId: i(s),
|
|
572
|
+
series: f,
|
|
573
|
+
seriesLabel: It(f, o),
|
|
574
|
+
value: typeof p == "number" ? p : void 0
|
|
560
575
|
});
|
|
561
|
-
}, [
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
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({
|
|
565
588
|
category: t == null ? void 0 : String(t),
|
|
589
|
+
categoryId: i(e.payload),
|
|
566
590
|
series: n,
|
|
591
|
+
seriesLabel: It(n, o),
|
|
567
592
|
value: typeof e.payload?.[n] == "number" ? e.payload[n] : void 0
|
|
568
593
|
});
|
|
569
594
|
}, [
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
]),
|
|
574
|
-
onClick:
|
|
595
|
+
d,
|
|
596
|
+
a,
|
|
597
|
+
o
|
|
598
|
+
]), k = d ? {
|
|
599
|
+
onClick: fe,
|
|
575
600
|
style: { cursor: "pointer" }
|
|
576
|
-
} : {},
|
|
577
|
-
|
|
601
|
+
} : {}, Fe = d ? { onClick: pe } : {}, F = d ? (e) => ({
|
|
602
|
+
...ue(e),
|
|
603
|
+
cursor: "pointer"
|
|
604
|
+
}) : () => ({}), ze = d ? {
|
|
605
|
+
onClick: w,
|
|
578
606
|
style: { cursor: "pointer" }
|
|
579
|
-
} : {},
|
|
580
|
-
if (!
|
|
581
|
-
let t =
|
|
582
|
-
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);
|
|
583
611
|
}, [
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
]),
|
|
588
|
-
if (!
|
|
589
|
-
let t =
|
|
590
|
-
t &&
|
|
591
|
-
}, [
|
|
592
|
-
if (!
|
|
593
|
-
let t =
|
|
594
|
-
t &&
|
|
595
|
-
}, [
|
|
596
|
-
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,
|
|
597
625
|
cursor: "pointer"
|
|
598
|
-
} : {},
|
|
599
|
-
onClick:
|
|
626
|
+
} : {}, Ge = d ? {
|
|
627
|
+
onClick: He,
|
|
600
628
|
style: { cursor: "pointer" }
|
|
601
|
-
} : {},
|
|
602
|
-
onClick:
|
|
629
|
+
} : {}, Ke = d ? {
|
|
630
|
+
onClick: Ue,
|
|
603
631
|
style: { cursor: "pointer" }
|
|
604
632
|
} : {};
|
|
605
|
-
|
|
606
|
-
let e = () =>
|
|
633
|
+
h.useEffect(() => {
|
|
634
|
+
let e = () => se(window.innerWidth < 640);
|
|
607
635
|
return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
608
636
|
}, []);
|
|
609
|
-
let
|
|
610
|
-
bar:
|
|
611
|
-
"horizontal-bar":
|
|
612
|
-
line:
|
|
613
|
-
area:
|
|
614
|
-
pie:
|
|
615
|
-
donut:
|
|
616
|
-
radar:
|
|
617
|
-
scatter:
|
|
618
|
-
funnel:
|
|
619
|
-
combo:
|
|
620
|
-
treemap:
|
|
621
|
-
sankey:
|
|
622
|
-
}[
|
|
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) => {
|
|
623
651
|
if (e == null || e === "") return "";
|
|
624
652
|
let t = r?.[String(e)]?.label;
|
|
625
653
|
if (t != null) return String(t);
|
|
@@ -627,7 +655,7 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
627
655
|
if (/^\d{4}-\d{2}-\d{2}/.test(n)) {
|
|
628
656
|
let e = new Date(n);
|
|
629
657
|
if (!Number.isNaN(e.getTime())) {
|
|
630
|
-
let t = (b.length > 1 ? Math.abs(new Date(String(b[b.length - 1][
|
|
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;
|
|
631
659
|
try {
|
|
632
660
|
return t <= 62 ? e.toLocaleDateString(void 0, {
|
|
633
661
|
month: "short",
|
|
@@ -644,16 +672,16 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
644
672
|
return C && n.length > 8 ? n.slice(0, 8) + "…" : n;
|
|
645
673
|
}, [
|
|
646
674
|
b,
|
|
647
|
-
|
|
675
|
+
a,
|
|
648
676
|
C,
|
|
649
677
|
r
|
|
650
|
-
]),
|
|
678
|
+
]), L = h.useMemo(() => b.some((e) => String(e[a] || "").length > 5), [b, a]), R = () => Array.isArray(c) && c.length > 0 ? c : [
|
|
651
679
|
"hsl(var(--chart-1))",
|
|
652
680
|
"hsl(var(--chart-2))",
|
|
653
681
|
"hsl(var(--chart-3))",
|
|
654
682
|
"hsl(var(--chart-4))",
|
|
655
683
|
"hsl(var(--chart-5))"
|
|
656
|
-
],
|
|
684
|
+
], z = h.useCallback((e) => {
|
|
657
685
|
if (e == null || e === "") return "";
|
|
658
686
|
let t = typeof e == "number" ? e : Number(e);
|
|
659
687
|
if (!Number.isFinite(t)) return String(e);
|
|
@@ -665,8 +693,8 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
665
693
|
} catch {
|
|
666
694
|
return String(t);
|
|
667
695
|
}
|
|
668
|
-
}, []),
|
|
669
|
-
let t =
|
|
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 = [];
|
|
670
698
|
for (let e of b) for (let r of t) {
|
|
671
699
|
let t = Number(e?.[r]);
|
|
672
700
|
Number.isFinite(t) && n.push(t);
|
|
@@ -674,11 +702,11 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
674
702
|
return n;
|
|
675
703
|
}, [
|
|
676
704
|
b,
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
]),
|
|
705
|
+
o,
|
|
706
|
+
H
|
|
707
|
+
]), K = h.useCallback((e, t = "left") => {
|
|
680
708
|
if (!e) return {};
|
|
681
|
-
let n =
|
|
709
|
+
let n = Qe(e), r = Ze(e, G(t));
|
|
682
710
|
return {
|
|
683
711
|
...r ? { ticks: r } : {},
|
|
684
712
|
...n ? { domain: n } : {},
|
|
@@ -693,17 +721,17 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
693
721
|
position: "insideLeft"
|
|
694
722
|
} } : {}
|
|
695
723
|
};
|
|
696
|
-
}, [
|
|
697
|
-
vertical:
|
|
698
|
-
horizontal:
|
|
699
|
-
},
|
|
700
|
-
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;
|
|
701
729
|
let e = {
|
|
702
730
|
solid: void 0,
|
|
703
731
|
dashed: "4 4",
|
|
704
732
|
dotted: "1 4"
|
|
705
733
|
};
|
|
706
|
-
return
|
|
734
|
+
return ie.map((t, n) => {
|
|
707
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: {
|
|
708
736
|
value: o,
|
|
709
737
|
position: "insideTopRight",
|
|
@@ -718,9 +746,9 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
718
746
|
y1: t.value,
|
|
719
747
|
y2: t.endValue
|
|
720
748
|
};
|
|
721
|
-
return /* @__PURE__ */
|
|
749
|
+
return /* @__PURE__ */ T(Ne, {
|
|
722
750
|
...e,
|
|
723
|
-
...
|
|
751
|
+
...H && !r ? { yAxisId: "left" } : {},
|
|
724
752
|
fill: i,
|
|
725
753
|
fillOpacity: .12,
|
|
726
754
|
stroke: i,
|
|
@@ -728,198 +756,199 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
728
756
|
...s
|
|
729
757
|
}, `ann-${n}`);
|
|
730
758
|
}
|
|
731
|
-
return /* @__PURE__ */
|
|
759
|
+
return /* @__PURE__ */ T(Pe, {
|
|
732
760
|
...r ? { x: t?.value } : { y: t?.value },
|
|
733
|
-
...
|
|
761
|
+
...H && !r ? { yAxisId: "left" } : {},
|
|
734
762
|
stroke: i,
|
|
735
763
|
strokeDasharray: a,
|
|
736
764
|
...s
|
|
737
765
|
}, `ann-${n}`);
|
|
738
766
|
});
|
|
739
|
-
}, [
|
|
740
|
-
dataKey:
|
|
767
|
+
}, [ie, H]), st = ae?.tooltips !== !1, ct = ae?.brush === !0 ? /* @__PURE__ */ T(ve, {
|
|
768
|
+
dataKey: a,
|
|
741
769
|
height: 24,
|
|
742
770
|
travellerWidth: 8,
|
|
743
771
|
stroke: "hsl(var(--muted-foreground))"
|
|
744
|
-
}) : null, q = (e) =>
|
|
772
|
+
}) : null, q = (e) => te ? /* @__PURE__ */ T(Ce, {
|
|
745
773
|
position: "top",
|
|
746
774
|
className: "fill-foreground",
|
|
747
775
|
fontSize: 11,
|
|
748
776
|
...e ? { formatter: e } : {}
|
|
749
|
-
}) : null,
|
|
777
|
+
}) : null, dt = h.useMemo(() => ({
|
|
750
778
|
tickLine: !1,
|
|
751
779
|
tickMargin: 10,
|
|
752
780
|
axisLine: !1,
|
|
753
781
|
interval: "preserveStartEnd",
|
|
754
782
|
minTickGap: C ? 32 : 48,
|
|
755
|
-
tickFormatter:
|
|
756
|
-
...
|
|
757
|
-
value:
|
|
783
|
+
tickFormatter: nt,
|
|
784
|
+
...p?.title ? { label: {
|
|
785
|
+
value: p.title,
|
|
758
786
|
position: "insideBottom",
|
|
759
787
|
offset: -4
|
|
760
788
|
} } : {},
|
|
761
|
-
...!C &&
|
|
789
|
+
...!C && L && {
|
|
762
790
|
angle: -35,
|
|
763
791
|
textAnchor: "end",
|
|
764
792
|
height: 60
|
|
765
793
|
}
|
|
766
794
|
}), [
|
|
767
795
|
C,
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
796
|
+
L,
|
|
797
|
+
nt,
|
|
798
|
+
p?.title
|
|
771
799
|
]);
|
|
772
|
-
if (
|
|
773
|
-
let e =
|
|
774
|
-
return /* @__PURE__ */
|
|
775
|
-
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,
|
|
776
804
|
"data-testid": "advanced-chart-single-value",
|
|
777
|
-
children: /* @__PURE__ */
|
|
805
|
+
children: /* @__PURE__ */ E("div", {
|
|
778
806
|
className: "flex flex-col gap-1 py-4",
|
|
779
|
-
children: [/* @__PURE__ */
|
|
807
|
+
children: [/* @__PURE__ */ T("span", {
|
|
780
808
|
className: "text-3xl font-semibold tabular-nums",
|
|
781
809
|
children: Number.isFinite(n) ? new Intl.NumberFormat().format(n) : String(t ?? "—")
|
|
782
|
-
}), /* @__PURE__ */
|
|
810
|
+
}), /* @__PURE__ */ T("span", {
|
|
783
811
|
className: "text-xs text-muted-foreground",
|
|
784
812
|
children: String(i)
|
|
785
813
|
})]
|
|
786
814
|
})
|
|
787
815
|
});
|
|
788
816
|
}
|
|
789
|
-
if (
|
|
790
|
-
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 ?? ""}`,
|
|
791
819
|
"data-testid": "advanced-chart-tabular-notice",
|
|
792
820
|
role: "note",
|
|
793
821
|
children: [
|
|
794
822
|
"Chart type “",
|
|
795
|
-
|
|
823
|
+
v,
|
|
796
824
|
"” is tabular — render it with the data-table / pivot components; a chart block draws series charts."
|
|
797
825
|
]
|
|
798
826
|
});
|
|
799
|
-
if (
|
|
800
|
-
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 ?? ""}`,
|
|
801
829
|
"data-testid": "advanced-chart-unknown-type",
|
|
802
830
|
role: "note",
|
|
803
831
|
children: [
|
|
804
832
|
"Chart type “",
|
|
805
|
-
|
|
833
|
+
v,
|
|
806
834
|
"” is not a spec chart type — nothing was drawn."
|
|
807
835
|
]
|
|
808
836
|
});
|
|
809
|
-
if (
|
|
810
|
-
let e =
|
|
837
|
+
if (v === "pie" || v === "donut") {
|
|
838
|
+
let e = v === "donut" ? "52%" : 0, t = R(), n = { ...r };
|
|
811
839
|
return b.forEach((e, r) => {
|
|
812
|
-
let
|
|
813
|
-
if (
|
|
814
|
-
let o = String(
|
|
840
|
+
let i = e?.[a];
|
|
841
|
+
if (i == null || i === "") return;
|
|
842
|
+
let o = String(i);
|
|
815
843
|
n[o] || (n[o] = {
|
|
816
844
|
label: o,
|
|
817
|
-
color:
|
|
845
|
+
color: Be(i, r, t)
|
|
818
846
|
});
|
|
819
|
-
}), /* @__PURE__ */
|
|
847
|
+
}), /* @__PURE__ */ T(J, {
|
|
820
848
|
config: n,
|
|
821
|
-
className:
|
|
849
|
+
className: s,
|
|
822
850
|
...S,
|
|
823
|
-
children: /* @__PURE__ */
|
|
824
|
-
/* @__PURE__ */
|
|
851
|
+
children: /* @__PURE__ */ E(De, { children: [
|
|
852
|
+
/* @__PURE__ */ T(Z, {
|
|
825
853
|
cursor: !1,
|
|
826
|
-
content: /* @__PURE__ */
|
|
854
|
+
content: /* @__PURE__ */ T(lt, { hideLabel: !0 })
|
|
827
855
|
}),
|
|
828
|
-
/* @__PURE__ */
|
|
856
|
+
/* @__PURE__ */ T(Ee, {
|
|
829
857
|
data: b,
|
|
830
|
-
dataKey:
|
|
831
|
-
nameKey:
|
|
858
|
+
dataKey: o[0]?.dataKey || "value",
|
|
859
|
+
nameKey: a || "name",
|
|
832
860
|
innerRadius: e,
|
|
833
861
|
strokeWidth: 5,
|
|
834
862
|
paddingAngle: 2,
|
|
835
863
|
outerRadius: "85%",
|
|
836
864
|
...x,
|
|
837
|
-
...
|
|
865
|
+
...ze,
|
|
838
866
|
children: b.map((e, n) => {
|
|
839
|
-
let r =
|
|
840
|
-
return /* @__PURE__ */
|
|
867
|
+
let r = Be(e?.[a], n, t);
|
|
868
|
+
return /* @__PURE__ */ T(be, { fill: Q(r) }, `cell-${n}`);
|
|
841
869
|
})
|
|
842
870
|
}),
|
|
843
|
-
|
|
871
|
+
at ? /* @__PURE__ */ T(ht, {
|
|
844
872
|
verticalAlign: "bottom",
|
|
845
873
|
wrapperStyle: {
|
|
846
874
|
fontSize: C ? "11px" : "12px",
|
|
847
875
|
paddingTop: "8px"
|
|
848
876
|
},
|
|
849
|
-
content: /* @__PURE__ */
|
|
850
|
-
nameKey:
|
|
877
|
+
content: /* @__PURE__ */ T(ut, {
|
|
878
|
+
nameKey: a,
|
|
851
879
|
className: "flex-wrap"
|
|
852
880
|
})
|
|
853
881
|
}) : null
|
|
854
882
|
] })
|
|
855
883
|
});
|
|
856
884
|
}
|
|
857
|
-
if (
|
|
858
|
-
let e =
|
|
859
|
-
t &&
|
|
860
|
-
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),
|
|
861
890
|
value: t?.payload?.[e] ?? t?.[e]
|
|
862
891
|
});
|
|
863
|
-
} : void 0,
|
|
864
|
-
onClick:
|
|
892
|
+
} : void 0, l = c ? {
|
|
893
|
+
onClick: c,
|
|
865
894
|
style: { cursor: "pointer" }
|
|
866
|
-
} : {},
|
|
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) => {
|
|
867
896
|
let r = Number(t?.[e] ?? 0);
|
|
868
897
|
return Number(n?.[e] ?? 0) - r;
|
|
869
898
|
});
|
|
870
|
-
return /* @__PURE__ */
|
|
899
|
+
return /* @__PURE__ */ T(J, {
|
|
871
900
|
config: r,
|
|
872
|
-
className:
|
|
901
|
+
className: s,
|
|
873
902
|
...S,
|
|
874
|
-
children: /* @__PURE__ */
|
|
903
|
+
children: /* @__PURE__ */ E(Se, { children: [/* @__PURE__ */ T(Z, { content: /* @__PURE__ */ T(lt, {}) }), /* @__PURE__ */ E(xe, {
|
|
875
904
|
dataKey: e,
|
|
876
|
-
data:
|
|
877
|
-
nameKey:
|
|
905
|
+
data: p,
|
|
906
|
+
nameKey: a,
|
|
878
907
|
...x,
|
|
879
|
-
...
|
|
880
|
-
children: [/* @__PURE__ */
|
|
908
|
+
...l,
|
|
909
|
+
children: [/* @__PURE__ */ T(Ce, {
|
|
881
910
|
position: "right",
|
|
882
911
|
fill: "hsl(var(--foreground))",
|
|
883
912
|
stroke: "none",
|
|
884
|
-
dataKey:
|
|
885
|
-
}),
|
|
913
|
+
dataKey: a
|
|
914
|
+
}), p.map((e, t) => /* @__PURE__ */ T(be, { fill: Q(n[t % n.length]) }, `funnel-cell-${t}`))]
|
|
886
915
|
})] })
|
|
887
916
|
});
|
|
888
917
|
}
|
|
889
|
-
if (
|
|
890
|
-
let e =
|
|
891
|
-
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] ?? ""),
|
|
892
921
|
size: Number(n?.[e]) || 0,
|
|
893
922
|
fill: Q(t[r % t.length])
|
|
894
923
|
}));
|
|
895
|
-
return /* @__PURE__ */
|
|
924
|
+
return /* @__PURE__ */ T(J, {
|
|
896
925
|
config: r,
|
|
897
|
-
className:
|
|
926
|
+
className: s,
|
|
898
927
|
...S,
|
|
899
|
-
children: /* @__PURE__ */
|
|
928
|
+
children: /* @__PURE__ */ T(Le, {
|
|
900
929
|
data: n,
|
|
901
930
|
dataKey: "size",
|
|
902
931
|
nameKey: "name",
|
|
903
932
|
...x,
|
|
904
|
-
content: /* @__PURE__ */
|
|
905
|
-
...
|
|
906
|
-
children: /* @__PURE__ */
|
|
933
|
+
content: /* @__PURE__ */ T(Ct, {}),
|
|
934
|
+
...Ge,
|
|
935
|
+
children: /* @__PURE__ */ T(Ie, {})
|
|
907
936
|
})
|
|
908
937
|
});
|
|
909
938
|
}
|
|
910
|
-
if (
|
|
911
|
-
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) => ({
|
|
912
941
|
source: 0,
|
|
913
942
|
target: n + 1,
|
|
914
943
|
value: Number(t?.[e]) || 0
|
|
915
944
|
}));
|
|
916
|
-
return c.length === 0 ? /* @__PURE__ */
|
|
945
|
+
return c.length === 0 ? /* @__PURE__ */ T("div", { className: s }) : /* @__PURE__ */ T(J, {
|
|
917
946
|
config: r,
|
|
918
|
-
className:
|
|
947
|
+
className: s,
|
|
919
948
|
...S,
|
|
920
|
-
children: /* @__PURE__ */
|
|
949
|
+
children: /* @__PURE__ */ T(A, {
|
|
921
950
|
data: {
|
|
922
|
-
nodes:
|
|
951
|
+
nodes: i,
|
|
923
952
|
links: c
|
|
924
953
|
},
|
|
925
954
|
nodePadding: 24,
|
|
@@ -928,24 +957,24 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
928
957
|
strokeOpacity: .25
|
|
929
958
|
},
|
|
930
959
|
node: { fill: "hsl(var(--chart-1))" },
|
|
931
|
-
...
|
|
932
|
-
children: /* @__PURE__ */
|
|
960
|
+
...Ke,
|
|
961
|
+
children: /* @__PURE__ */ T(Ie, {})
|
|
933
962
|
})
|
|
934
963
|
});
|
|
935
964
|
}
|
|
936
|
-
if (
|
|
965
|
+
if (v === "radar") return /* @__PURE__ */ T(J, {
|
|
937
966
|
config: r,
|
|
938
|
-
className:
|
|
967
|
+
className: s,
|
|
939
968
|
...S,
|
|
940
|
-
children: /* @__PURE__ */
|
|
969
|
+
children: /* @__PURE__ */ E(Me, {
|
|
941
970
|
data: b,
|
|
942
971
|
children: [
|
|
943
|
-
/* @__PURE__ */
|
|
944
|
-
/* @__PURE__ */
|
|
945
|
-
/* @__PURE__ */
|
|
946
|
-
/* @__PURE__ */
|
|
947
|
-
/* @__PURE__ */
|
|
948
|
-
content: /* @__PURE__ */
|
|
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, {}),
|
|
949
978
|
...C && {
|
|
950
979
|
verticalAlign: "bottom",
|
|
951
980
|
wrapperStyle: {
|
|
@@ -954,9 +983,9 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
954
983
|
}
|
|
955
984
|
}
|
|
956
985
|
}),
|
|
957
|
-
|
|
958
|
-
let t = Q(r[e.dataKey]?.color ||
|
|
959
|
-
return /* @__PURE__ */
|
|
986
|
+
o.map((e) => {
|
|
987
|
+
let t = Q(r[e.dataKey]?.color || At);
|
|
988
|
+
return /* @__PURE__ */ T(je, {
|
|
960
989
|
dataKey: e.dataKey,
|
|
961
990
|
stroke: t,
|
|
962
991
|
fill: t,
|
|
@@ -967,36 +996,36 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
967
996
|
]
|
|
968
997
|
})
|
|
969
998
|
});
|
|
970
|
-
if (
|
|
999
|
+
if (v === "scatter") return /* @__PURE__ */ T(J, {
|
|
971
1000
|
config: r,
|
|
972
|
-
className:
|
|
1001
|
+
className: s,
|
|
973
1002
|
...S,
|
|
974
|
-
children: /* @__PURE__ */
|
|
975
|
-
/* @__PURE__ */
|
|
976
|
-
/* @__PURE__ */
|
|
1003
|
+
children: /* @__PURE__ */ E(M, { children: [
|
|
1004
|
+
/* @__PURE__ */ T(ye, { vertical: !1 }),
|
|
1005
|
+
/* @__PURE__ */ T(N, {
|
|
977
1006
|
type: "number",
|
|
978
|
-
dataKey:
|
|
979
|
-
name: String(r[
|
|
1007
|
+
dataKey: a,
|
|
1008
|
+
name: String(r[a]?.label || a),
|
|
980
1009
|
tickLine: !1,
|
|
981
1010
|
axisLine: !1,
|
|
982
1011
|
minTickGap: C ? 32 : 48
|
|
983
1012
|
}),
|
|
984
|
-
/* @__PURE__ */
|
|
1013
|
+
/* @__PURE__ */ T(P, {
|
|
985
1014
|
type: "number",
|
|
986
|
-
dataKey:
|
|
987
|
-
name: String(r[
|
|
1015
|
+
dataKey: o[0]?.dataKey || "value",
|
|
1016
|
+
name: String(r[o[0]?.dataKey]?.label || o[0]?.dataKey),
|
|
988
1017
|
tickLine: !1,
|
|
989
1018
|
axisLine: !1,
|
|
990
|
-
tickFormatter:
|
|
1019
|
+
tickFormatter: z,
|
|
991
1020
|
width: 48
|
|
992
1021
|
}),
|
|
993
|
-
/* @__PURE__ */
|
|
1022
|
+
/* @__PURE__ */ T(Re, {
|
|
994
1023
|
type: "number",
|
|
995
1024
|
range: [60, 400]
|
|
996
1025
|
}),
|
|
997
|
-
/* @__PURE__ */
|
|
998
|
-
/* @__PURE__ */
|
|
999
|
-
content: /* @__PURE__ */
|
|
1026
|
+
/* @__PURE__ */ T(Z, { content: /* @__PURE__ */ T(lt, {}) }),
|
|
1027
|
+
/* @__PURE__ */ T(ht, {
|
|
1028
|
+
content: /* @__PURE__ */ T(ut, {}),
|
|
1000
1029
|
...C && {
|
|
1001
1030
|
verticalAlign: "bottom",
|
|
1002
1031
|
wrapperStyle: {
|
|
@@ -1005,54 +1034,55 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
1005
1034
|
}
|
|
1006
1035
|
}
|
|
1007
1036
|
}),
|
|
1008
|
-
|
|
1009
|
-
let n =
|
|
1010
|
-
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, {
|
|
1011
1040
|
name: r[e.dataKey]?.label || e.dataKey,
|
|
1012
1041
|
data: b,
|
|
1013
1042
|
fill: i,
|
|
1014
1043
|
fillOpacity: a?.fillOpacity,
|
|
1015
1044
|
...x,
|
|
1016
|
-
...
|
|
1045
|
+
...We
|
|
1017
1046
|
}, e.dataKey);
|
|
1018
1047
|
})
|
|
1019
1048
|
] })
|
|
1020
1049
|
});
|
|
1021
|
-
if (
|
|
1022
|
-
title:
|
|
1023
|
-
subtitle:
|
|
1024
|
-
children: /* @__PURE__ */
|
|
1050
|
+
if (v === "combo") return /* @__PURE__ */ T(wt, {
|
|
1051
|
+
title: ne,
|
|
1052
|
+
subtitle: re,
|
|
1053
|
+
children: /* @__PURE__ */ T(J, {
|
|
1025
1054
|
config: r,
|
|
1026
|
-
className:
|
|
1055
|
+
className: s,
|
|
1027
1056
|
...S,
|
|
1028
|
-
children: /* @__PURE__ */
|
|
1057
|
+
children: /* @__PURE__ */ E(O, {
|
|
1029
1058
|
data: b,
|
|
1059
|
+
...Fe,
|
|
1030
1060
|
children: [
|
|
1031
|
-
/* @__PURE__ */
|
|
1032
|
-
/* @__PURE__ */
|
|
1033
|
-
dataKey:
|
|
1034
|
-
...
|
|
1061
|
+
/* @__PURE__ */ T(ye, { ...it }),
|
|
1062
|
+
/* @__PURE__ */ T(N, {
|
|
1063
|
+
dataKey: a,
|
|
1064
|
+
...dt
|
|
1035
1065
|
}),
|
|
1036
|
-
/* @__PURE__ */
|
|
1066
|
+
/* @__PURE__ */ T(P, {
|
|
1037
1067
|
yAxisId: "left",
|
|
1038
1068
|
tickLine: !1,
|
|
1039
1069
|
axisLine: !1,
|
|
1040
|
-
tickFormatter:
|
|
1070
|
+
tickFormatter: U,
|
|
1041
1071
|
width: 48,
|
|
1042
|
-
...
|
|
1072
|
+
...K(B)
|
|
1043
1073
|
}),
|
|
1044
|
-
/* @__PURE__ */
|
|
1074
|
+
/* @__PURE__ */ T(P, {
|
|
1045
1075
|
yAxisId: "right",
|
|
1046
1076
|
orientation: "right",
|
|
1047
1077
|
tickLine: !1,
|
|
1048
1078
|
axisLine: !1,
|
|
1049
|
-
tickFormatter:
|
|
1079
|
+
tickFormatter: W,
|
|
1050
1080
|
width: 48,
|
|
1051
|
-
...
|
|
1081
|
+
...K(V, "right")
|
|
1052
1082
|
}),
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
content: /* @__PURE__ */
|
|
1083
|
+
st ? /* @__PURE__ */ T(Z, { content: /* @__PURE__ */ T(lt, {}) }) : null,
|
|
1084
|
+
at ? /* @__PURE__ */ T(ht, {
|
|
1085
|
+
content: /* @__PURE__ */ T(ut, {}),
|
|
1056
1086
|
...C && {
|
|
1057
1087
|
verticalAlign: "bottom",
|
|
1058
1088
|
wrapperStyle: {
|
|
@@ -1061,11 +1091,11 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
1061
1091
|
}
|
|
1062
1092
|
}
|
|
1063
1093
|
}) : null,
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
let n = Q(r[e.dataKey]?.color ||
|
|
1068
|
-
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, {
|
|
1069
1099
|
yAxisId: a,
|
|
1070
1100
|
type: "monotone",
|
|
1071
1101
|
dataKey: e.dataKey,
|
|
@@ -1075,8 +1105,9 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
1075
1105
|
strokeOpacity: o?.strokeOpacity,
|
|
1076
1106
|
strokeDasharray: o?.strokeDasharray,
|
|
1077
1107
|
...x,
|
|
1108
|
+
...F(e),
|
|
1078
1109
|
children: q(c)
|
|
1079
|
-
}, e.dataKey) : i === "area" ? /* @__PURE__ */
|
|
1110
|
+
}, e.dataKey) : i === "area" ? /* @__PURE__ */ T(he, {
|
|
1080
1111
|
yAxisId: a,
|
|
1081
1112
|
type: "monotone",
|
|
1082
1113
|
dataKey: e.dataKey,
|
|
@@ -1087,8 +1118,9 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
1087
1118
|
strokeDasharray: o?.strokeDasharray,
|
|
1088
1119
|
...s,
|
|
1089
1120
|
...x,
|
|
1121
|
+
...F(e),
|
|
1090
1122
|
children: q(c)
|
|
1091
|
-
}, e.dataKey) : /* @__PURE__ */
|
|
1123
|
+
}, e.dataKey) : /* @__PURE__ */ T(_e, {
|
|
1092
1124
|
yAxisId: a,
|
|
1093
1125
|
dataKey: e.dataKey,
|
|
1094
1126
|
fill: n,
|
|
@@ -1096,6 +1128,7 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
1096
1128
|
fillOpacity: o?.fillOpacity,
|
|
1097
1129
|
...s,
|
|
1098
1130
|
...x,
|
|
1131
|
+
...F(e),
|
|
1099
1132
|
children: q(c)
|
|
1100
1133
|
}, e.dataKey);
|
|
1101
1134
|
})
|
|
@@ -1103,94 +1136,94 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
1103
1136
|
})
|
|
1104
1137
|
})
|
|
1105
1138
|
});
|
|
1106
|
-
let
|
|
1107
|
-
...
|
|
1108
|
-
...
|
|
1109
|
-
...
|
|
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))
|
|
1110
1143
|
])), X = (e) => "g" + e.replace(/[^a-zA-Z0-9]/g, "");
|
|
1111
|
-
return /* @__PURE__ */
|
|
1112
|
-
title:
|
|
1113
|
-
subtitle:
|
|
1114
|
-
children: /* @__PURE__ */
|
|
1144
|
+
return /* @__PURE__ */ T(wt, {
|
|
1145
|
+
title: ne,
|
|
1146
|
+
subtitle: re,
|
|
1147
|
+
children: /* @__PURE__ */ T(J, {
|
|
1115
1148
|
config: r,
|
|
1116
|
-
className:
|
|
1149
|
+
className: s,
|
|
1117
1150
|
...S,
|
|
1118
|
-
children: /* @__PURE__ */
|
|
1151
|
+
children: /* @__PURE__ */ E(qe, {
|
|
1119
1152
|
data: b,
|
|
1120
|
-
layout:
|
|
1121
|
-
...
|
|
1153
|
+
layout: Y ? "vertical" : "horizontal",
|
|
1154
|
+
...k,
|
|
1122
1155
|
children: [
|
|
1123
|
-
/* @__PURE__ */
|
|
1156
|
+
/* @__PURE__ */ T("defs", { children: mt.map((e) => /* @__PURE__ */ E(h.Fragment, { children: [/* @__PURE__ */ E("linearGradient", {
|
|
1124
1157
|
id: `bg-${X(e)}`,
|
|
1125
1158
|
x1: "0",
|
|
1126
1159
|
y1: "0",
|
|
1127
1160
|
x2: "0",
|
|
1128
1161
|
y2: "1",
|
|
1129
|
-
children: [/* @__PURE__ */
|
|
1162
|
+
children: [/* @__PURE__ */ T("stop", {
|
|
1130
1163
|
offset: "0%",
|
|
1131
1164
|
style: { stopColor: e },
|
|
1132
1165
|
stopOpacity: .95
|
|
1133
|
-
}), /* @__PURE__ */
|
|
1166
|
+
}), /* @__PURE__ */ T("stop", {
|
|
1134
1167
|
offset: "100%",
|
|
1135
1168
|
style: { stopColor: e },
|
|
1136
1169
|
stopOpacity: .5
|
|
1137
1170
|
})]
|
|
1138
|
-
}), /* @__PURE__ */
|
|
1171
|
+
}), /* @__PURE__ */ E("linearGradient", {
|
|
1139
1172
|
id: `ag-${X(e)}`,
|
|
1140
1173
|
x1: "0",
|
|
1141
1174
|
y1: "0",
|
|
1142
1175
|
x2: "0",
|
|
1143
1176
|
y2: "1",
|
|
1144
|
-
children: [/* @__PURE__ */
|
|
1177
|
+
children: [/* @__PURE__ */ T("stop", {
|
|
1145
1178
|
offset: "0%",
|
|
1146
1179
|
style: { stopColor: e },
|
|
1147
1180
|
stopOpacity: .5
|
|
1148
|
-
}), /* @__PURE__ */
|
|
1181
|
+
}), /* @__PURE__ */ T("stop", {
|
|
1149
1182
|
offset: "95%",
|
|
1150
1183
|
style: { stopColor: e },
|
|
1151
1184
|
stopOpacity: .05
|
|
1152
1185
|
})]
|
|
1153
1186
|
})] }, X(e))) }),
|
|
1154
|
-
/* @__PURE__ */
|
|
1155
|
-
|
|
1187
|
+
/* @__PURE__ */ T(ye, { ...it }),
|
|
1188
|
+
Y ? /* @__PURE__ */ E(me, { children: [/* @__PURE__ */ T(N, {
|
|
1156
1189
|
type: "number",
|
|
1157
1190
|
tickLine: !1,
|
|
1158
1191
|
axisLine: !1,
|
|
1159
|
-
tickFormatter:
|
|
1160
|
-
...
|
|
1161
|
-
}), /* @__PURE__ */
|
|
1192
|
+
tickFormatter: U,
|
|
1193
|
+
...K(B)
|
|
1194
|
+
}), /* @__PURE__ */ T(P, {
|
|
1162
1195
|
type: "category",
|
|
1163
|
-
dataKey:
|
|
1196
|
+
dataKey: a,
|
|
1164
1197
|
tickLine: !1,
|
|
1165
1198
|
axisLine: !1,
|
|
1166
|
-
width: Math.min(140, Math.max(60, Math.max(...b.map((e) => String(e[
|
|
1167
|
-
tickFormatter:
|
|
1168
|
-
})] }) : /* @__PURE__ */
|
|
1169
|
-
/* @__PURE__ */
|
|
1170
|
-
dataKey:
|
|
1171
|
-
...
|
|
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
|
|
1172
1205
|
}),
|
|
1173
|
-
/* @__PURE__ */
|
|
1174
|
-
...
|
|
1206
|
+
/* @__PURE__ */ T(P, {
|
|
1207
|
+
...H ? { yAxisId: "left" } : {},
|
|
1175
1208
|
tickLine: !1,
|
|
1176
1209
|
axisLine: !1,
|
|
1177
|
-
tickFormatter:
|
|
1210
|
+
tickFormatter: U,
|
|
1178
1211
|
width: 48,
|
|
1179
|
-
...
|
|
1212
|
+
...K(B)
|
|
1180
1213
|
}),
|
|
1181
|
-
|
|
1214
|
+
H ? /* @__PURE__ */ T(P, {
|
|
1182
1215
|
yAxisId: "right",
|
|
1183
1216
|
orientation: "right",
|
|
1184
1217
|
tickLine: !1,
|
|
1185
1218
|
axisLine: !1,
|
|
1186
|
-
tickFormatter:
|
|
1219
|
+
tickFormatter: W,
|
|
1187
1220
|
width: 48,
|
|
1188
|
-
...
|
|
1221
|
+
...K(V, "right")
|
|
1189
1222
|
}) : null
|
|
1190
1223
|
] }),
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
content: /* @__PURE__ */
|
|
1224
|
+
st ? /* @__PURE__ */ T(Z, { content: /* @__PURE__ */ T(lt, {}) }) : null,
|
|
1225
|
+
at ? /* @__PURE__ */ T(ht, {
|
|
1226
|
+
content: /* @__PURE__ */ T(ut, {}),
|
|
1194
1227
|
...C && {
|
|
1195
1228
|
verticalAlign: "bottom",
|
|
1196
1229
|
wrapperStyle: {
|
|
@@ -1199,13 +1232,13 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
1199
1232
|
}
|
|
1200
1233
|
}
|
|
1201
1234
|
}) : null,
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
let n =
|
|
1206
|
-
if (
|
|
1207
|
-
let t =
|
|
1208
|
-
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, {
|
|
1209
1242
|
dataKey: e.dataKey,
|
|
1210
1243
|
fill: `url(#bg-${X(l)})`,
|
|
1211
1244
|
radius: 4,
|
|
@@ -1213,12 +1246,13 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
1213
1246
|
...d,
|
|
1214
1247
|
...u,
|
|
1215
1248
|
...x,
|
|
1216
|
-
|
|
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)]
|
|
1217
1251
|
}, e.dataKey);
|
|
1218
1252
|
}
|
|
1219
|
-
if (
|
|
1220
|
-
let t =
|
|
1221
|
-
return /* @__PURE__ */
|
|
1253
|
+
if (v === "line") {
|
|
1254
|
+
let t = Mt(e, "line");
|
|
1255
|
+
return /* @__PURE__ */ T(we, {
|
|
1222
1256
|
type: "monotone",
|
|
1223
1257
|
dataKey: e.dataKey,
|
|
1224
1258
|
stroke: l,
|
|
@@ -1228,12 +1262,13 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
1228
1262
|
strokeDasharray: t?.strokeDasharray,
|
|
1229
1263
|
...u,
|
|
1230
1264
|
...x,
|
|
1265
|
+
...ue(e),
|
|
1231
1266
|
children: q(f)
|
|
1232
1267
|
}, e.dataKey);
|
|
1233
1268
|
}
|
|
1234
|
-
if (
|
|
1235
|
-
let t =
|
|
1236
|
-
return /* @__PURE__ */
|
|
1269
|
+
if (v === "area") {
|
|
1270
|
+
let t = Mt(e, "area");
|
|
1271
|
+
return /* @__PURE__ */ T(he, {
|
|
1237
1272
|
type: "monotone",
|
|
1238
1273
|
dataKey: e.dataKey,
|
|
1239
1274
|
fill: `url(#ag-${X(l)})`,
|
|
@@ -1245,6 +1280,7 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
1245
1280
|
...d,
|
|
1246
1281
|
...u,
|
|
1247
1282
|
...x,
|
|
1283
|
+
...ue(e),
|
|
1248
1284
|
children: q(f)
|
|
1249
1285
|
}, e.dataKey);
|
|
1250
1286
|
}
|
|
@@ -1255,35 +1291,64 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
|
|
|
1255
1291
|
})
|
|
1256
1292
|
});
|
|
1257
1293
|
}
|
|
1258
|
-
function
|
|
1294
|
+
function Et(e) {
|
|
1259
1295
|
let t = e.chartType === "column" ? "bar" : e.chartType ?? "bar", n = Array.isArray(e.data) ? e.data : [], r = e.xAxisKey ?? "name";
|
|
1260
|
-
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
|
+
});
|
|
1261
1309
|
}
|
|
1262
|
-
function
|
|
1263
|
-
let t =
|
|
1264
|
-
return
|
|
1265
|
-
t && console.warn(`[chart] no row has the category key "${
|
|
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]);
|
|
1312
|
+
return h.useEffect(() => {
|
|
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).`);
|
|
1266
1314
|
}, [
|
|
1267
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
|
+
}, [
|
|
1268
1321
|
n,
|
|
1269
|
-
r
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
children:
|
|
1322
|
+
r,
|
|
1323
|
+
i
|
|
1324
|
+
]), t ? /* @__PURE__ */ E(Ot, {
|
|
1325
|
+
code: "missing-category-key",
|
|
1326
|
+
className: e.className,
|
|
1327
|
+
children: [
|
|
1275
1328
|
"This chart cannot plot its category axis: no row has a",
|
|
1276
1329
|
" ",
|
|
1277
|
-
/* @__PURE__ */
|
|
1330
|
+
/* @__PURE__ */ T("code", {
|
|
1278
1331
|
className: "font-mono",
|
|
1279
|
-
children:
|
|
1332
|
+
children: r
|
|
1280
1333
|
}),
|
|
1281
1334
|
" field."
|
|
1282
|
-
]
|
|
1283
|
-
}) : /* @__PURE__ */
|
|
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 });
|
|
1284
1349
|
}
|
|
1285
|
-
var
|
|
1286
|
-
|
|
1350
|
+
var At, jt, Q, Mt, Nt, Pt, Ft, It, Lt, Rt, zt = L((() => {
|
|
1351
|
+
gt(), xt(), rt(), At = "hsl(var(--primary))", jt = {
|
|
1287
1352
|
slate: "#64748b",
|
|
1288
1353
|
gray: "#6b7280",
|
|
1289
1354
|
zinc: "#71717a",
|
|
@@ -1306,11 +1371,31 @@ var St, Ct, Q, wt, Tt, Et = R((() => {
|
|
|
1306
1371
|
fuchsia: "#d946ef",
|
|
1307
1372
|
pink: "#ec4899",
|
|
1308
1373
|
rose: "#f43f5e"
|
|
1309
|
-
}, Q = (e) =>
|
|
1374
|
+
}, Q = (e) => jt[e] || e, Mt = (e, t) => e?.variant === "comparison" ? {
|
|
1310
1375
|
strokeOpacity: typeof e.opacity == "number" ? e.opacity : t === "line" || t === "scatter" ? .5 : .6,
|
|
1311
1376
|
fillOpacity: typeof e.opacity == "number" ? e.opacity : t === "bar" ? .4 : t === "area" ? .2 : .5,
|
|
1312
1377
|
strokeDasharray: e.dashArray ?? (t === "line" || t === "area" ? "4 4" : void 0)
|
|
1313
|
-
} : 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([
|
|
1314
1399
|
"bar",
|
|
1315
1400
|
"horizontal-bar",
|
|
1316
1401
|
"line",
|
|
@@ -1320,14 +1405,20 @@ var St, Ct, Q, wt, Tt, Et = R((() => {
|
|
|
1320
1405
|
"radar",
|
|
1321
1406
|
"funnel",
|
|
1322
1407
|
"combo"
|
|
1408
|
+
]), Rt = /* @__PURE__ */ new Set([
|
|
1409
|
+
"bar",
|
|
1410
|
+
"horizontal-bar",
|
|
1411
|
+
"line",
|
|
1412
|
+
"area",
|
|
1413
|
+
"combo"
|
|
1323
1414
|
]);
|
|
1324
1415
|
}));
|
|
1325
1416
|
//#endregion
|
|
1326
1417
|
//#region src/ChartRenderer.tsx
|
|
1327
|
-
|
|
1328
|
-
var
|
|
1329
|
-
fallback: /* @__PURE__ */ w
|
|
1330
|
-
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, {
|
|
1331
1422
|
data: e.data,
|
|
1332
1423
|
dataKey: e.dataKey,
|
|
1333
1424
|
xAxisKey: e.xAxisKey,
|
|
@@ -1336,8 +1427,8 @@ var Dt = h.lazy(() => Promise.resolve().then(() => (nt(), $e))), Ot = h.lazy(()
|
|
|
1336
1427
|
color: e.color
|
|
1337
1428
|
})
|
|
1338
1429
|
}), $ = ({ schema: e, onChartClick: t }) => {
|
|
1339
|
-
let n =
|
|
1340
|
-
let t =
|
|
1430
|
+
let n = g.useMemo(() => {
|
|
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;
|
|
1341
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) {
|
|
1342
1433
|
let t = e.colors || [
|
|
1343
1434
|
"hsl(var(--chart-1))",
|
|
@@ -1361,9 +1452,9 @@ var Dt = h.lazy(() => Promise.resolve().then(() => (nt(), $e))), Ot = h.lazy(()
|
|
|
1361
1452
|
spec: t
|
|
1362
1453
|
};
|
|
1363
1454
|
}, [e]);
|
|
1364
|
-
return /* @__PURE__ */
|
|
1365
|
-
fallback: /* @__PURE__ */ w
|
|
1366
|
-
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, {
|
|
1367
1458
|
chartType: n.chartType,
|
|
1368
1459
|
data: n.data,
|
|
1369
1460
|
config: n.config,
|
|
@@ -1390,15 +1481,12 @@ var Dt = h.lazy(() => Promise.resolve().then(() => (nt(), $e))), Ot = h.lazy(()
|
|
|
1390
1481
|
};
|
|
1391
1482
|
//#endregion
|
|
1392
1483
|
//#region src/ObjectChart.tsx
|
|
1393
|
-
function
|
|
1394
|
-
return e.replace(/[_-]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
|
|
1395
|
-
}
|
|
1396
|
-
function jt(e) {
|
|
1484
|
+
function Ut(e) {
|
|
1397
1485
|
return e.field || e.function || "count";
|
|
1398
1486
|
}
|
|
1399
|
-
var
|
|
1400
|
-
function
|
|
1401
|
-
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 = {};
|
|
1402
1490
|
for (let t of e) {
|
|
1403
1491
|
let e = String(t[i] ?? "Unknown");
|
|
1404
1492
|
o[e] || (o[e] = []), o[e].push(t);
|
|
@@ -1426,13 +1514,13 @@ function Nt(e, t) {
|
|
|
1426
1514
|
};
|
|
1427
1515
|
});
|
|
1428
1516
|
}
|
|
1429
|
-
async function
|
|
1517
|
+
async function Kt(e, t, n, r, i) {
|
|
1430
1518
|
if (!e.length || !t) return e;
|
|
1431
|
-
let a = i || ((e, t) => t), o = `__raw_${t}`,
|
|
1432
|
-
if (!
|
|
1519
|
+
let a = i || ((e, t) => t), o = `__raw_${t}`, s = n?.fields?.[t];
|
|
1520
|
+
if (!s) {
|
|
1433
1521
|
let n = /^\d{4}-\d{2}-\d{2}/;
|
|
1434
1522
|
return e.map((e) => {
|
|
1435
|
-
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);
|
|
1436
1524
|
return {
|
|
1437
1525
|
...e,
|
|
1438
1526
|
[t]: a(i, s),
|
|
@@ -1440,11 +1528,11 @@ async function Pt(e, t, n, r, i) {
|
|
|
1440
1528
|
};
|
|
1441
1529
|
});
|
|
1442
1530
|
}
|
|
1443
|
-
let
|
|
1444
|
-
if (
|
|
1445
|
-
let n =
|
|
1531
|
+
let c = s.type;
|
|
1532
|
+
if (c === "select" || c === "picklist" || c === "dropdown") {
|
|
1533
|
+
let n = s.options || [];
|
|
1446
1534
|
if (n.length === 0) return e.map((e) => {
|
|
1447
|
-
let n = e[t], r = String(n ?? ""), i =
|
|
1535
|
+
let n = e[t], r = String(n ?? ""), i = u(r);
|
|
1448
1536
|
return {
|
|
1449
1537
|
...e,
|
|
1450
1538
|
[t]: a(r, i),
|
|
@@ -1454,7 +1542,7 @@ async function Pt(e, t, n, r, i) {
|
|
|
1454
1542
|
let r = {};
|
|
1455
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));
|
|
1456
1544
|
return e.map((e) => {
|
|
1457
|
-
let n = e[t], i = String(n ?? ""), s = r[i] ||
|
|
1545
|
+
let n = e[t], i = String(n ?? ""), s = r[i] || u(i);
|
|
1458
1546
|
return {
|
|
1459
1547
|
...e,
|
|
1460
1548
|
[t]: a(i, s),
|
|
@@ -1462,8 +1550,8 @@ async function Pt(e, t, n, r, i) {
|
|
|
1462
1550
|
};
|
|
1463
1551
|
});
|
|
1464
1552
|
}
|
|
1465
|
-
if (
|
|
1466
|
-
let n =
|
|
1553
|
+
if (c === "lookup" || c === "master_detail") {
|
|
1554
|
+
let n = s.reference_to || s.reference;
|
|
1467
1555
|
if (!n || !r || typeof r.find != "function") return e.map((e) => ({
|
|
1468
1556
|
...e,
|
|
1469
1557
|
[o]: e[t]
|
|
@@ -1473,12 +1561,12 @@ async function Pt(e, t, n, r, i) {
|
|
|
1473
1561
|
...e,
|
|
1474
1562
|
[o]: e[t]
|
|
1475
1563
|
}));
|
|
1476
|
-
let a =
|
|
1564
|
+
let a = s.id_field || "id";
|
|
1477
1565
|
try {
|
|
1478
|
-
let
|
|
1566
|
+
let c = await r.find(n, {
|
|
1479
1567
|
$filter: { [a]: { $in: i } },
|
|
1480
1568
|
$top: i.length
|
|
1481
|
-
}), u =
|
|
1569
|
+
}), u = l(c), d = s.reference_field || s.display_field || "name", f = {};
|
|
1482
1570
|
for (let e of u) {
|
|
1483
1571
|
let t = String(e[a] ?? e.id ?? e._id ?? ""), n = e[d] || e.name || e.label || e.title || t;
|
|
1484
1572
|
t && (f[t] = String(n));
|
|
@@ -1498,26 +1586,22 @@ async function Pt(e, t, n, r, i) {
|
|
|
1498
1586
|
}));
|
|
1499
1587
|
}
|
|
1500
1588
|
}
|
|
1501
|
-
if (
|
|
1589
|
+
if (c === "date" || c === "datetime" || c === "date_time" || c === "timestamp" || c === "time") return e.map((e) => ({
|
|
1502
1590
|
...e,
|
|
1503
1591
|
[o]: e[t]
|
|
1504
1592
|
}));
|
|
1505
|
-
let
|
|
1593
|
+
let d = /^\d{4}-\d{2}-\d{2}/;
|
|
1506
1594
|
return e.map((e) => {
|
|
1507
1595
|
let n = e[t], r = String(n ?? "");
|
|
1508
1596
|
return {
|
|
1509
1597
|
...e,
|
|
1510
|
-
[t]:
|
|
1598
|
+
[t]: d.test(r) ? r : u(r),
|
|
1511
1599
|
[o]: n
|
|
1512
1600
|
};
|
|
1513
1601
|
});
|
|
1514
1602
|
}
|
|
1515
|
-
var
|
|
1516
|
-
let { schema: t } = e,
|
|
1517
|
-
ne(() => {
|
|
1518
|
-
fe.current = de;
|
|
1519
|
-
}, [de]);
|
|
1520
|
-
let [pe, me] = v([]), [E, he] = v(null), [ge, D] = v(() => !(Array.isArray(t.data) && t.data.length > 0) && (!!t.objectName || !!t.dataset)), [_e, ve] = v(null), [O, k] = v(null), [A, ye] = v(null), [be, xe] = v(null), { openRecordList: Se } = Le(), Ce = I(), we = _(() => t.aggregate ? JSON.stringify(t.aggregate) : "", [t.aggregate]), Te = _(() => t.filter ? JSON.stringify(t.filter) : "", [t.filter]), Ee = _(() => t.compareTo ? JSON.stringify(t.compareTo) : "", [t.compareTo]), De = _(() => 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({
|
|
1521
1605
|
d: t.dataset,
|
|
1522
1606
|
dim: t.dimensions ?? [],
|
|
1523
1607
|
val: t.values ?? []
|
|
@@ -1525,36 +1609,37 @@ var Ft = (e) => {
|
|
|
1525
1609
|
t.dataset,
|
|
1526
1610
|
t.dimensions,
|
|
1527
1611
|
t.values
|
|
1528
|
-
]),
|
|
1529
|
-
|
|
1612
|
+
]), ke = (e) => e !== "pie" && e !== "donut" && e !== "funnel";
|
|
1613
|
+
oe(() => {
|
|
1530
1614
|
let e = !1;
|
|
1531
1615
|
return (async () => {
|
|
1532
1616
|
try {
|
|
1533
|
-
let n = {
|
|
1617
|
+
let n = g ?? fetch, r = {
|
|
1534
1618
|
headers: { accept: "application/json" },
|
|
1535
1619
|
credentials: "include"
|
|
1536
|
-
},
|
|
1537
|
-
if (
|
|
1620
|
+
}, i = t.objectName, a, o = null, s = t.aggregate?.groupBy;
|
|
1621
|
+
if (i) a = s && typeof s == "object" && !Array.isArray(s) ? s.field : typeof s == "string" ? s : t.xAxisKey;
|
|
1538
1622
|
else if (t.dataset) {
|
|
1539
|
-
let e = Array.isArray(t.dimensions) && t.dimensions.length ? t.dimensions[0] : void 0,
|
|
1540
|
-
|
|
1623
|
+
let e = Array.isArray(t.dimensions) && t.dimensions.length ? t.dimensions[0] : void 0, s = await (await n(`/api/v1/meta/dataset/${encodeURIComponent(t.dataset)}`, r)).json().catch(() => null);
|
|
1624
|
+
o = s?.item ?? s?.data ?? s, i = o?.object, a = ((o?.dimensions || []).find((t) => t?.name === e) ?? (o?.dimensions || [])[0])?.field ?? e;
|
|
1541
1625
|
}
|
|
1542
|
-
if (!
|
|
1543
|
-
e || (
|
|
1626
|
+
if (!i || !a) {
|
|
1627
|
+
e || Ce(null);
|
|
1544
1628
|
return;
|
|
1545
1629
|
}
|
|
1546
|
-
let
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1630
|
+
let c = async (e) => {
|
|
1631
|
+
let t = await (await n(`/api/v1/meta/object/${encodeURIComponent(e)}`, r)).json().catch(() => null);
|
|
1632
|
+
return t?.item ?? t?.data ?? t;
|
|
1633
|
+
}, l = {};
|
|
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;
|
|
1635
|
+
let u = await f(c, i, [a, ...Object.values(l)]);
|
|
1636
|
+
e || Ce({
|
|
1637
|
+
metaByPath: u,
|
|
1638
|
+
colorPath: a,
|
|
1639
|
+
fieldByDim: t.dataset && Array.isArray(t.dimensions) ? l : null
|
|
1640
|
+
});
|
|
1556
1641
|
} catch {
|
|
1557
|
-
e || (
|
|
1642
|
+
e || Ce(null);
|
|
1558
1643
|
}
|
|
1559
1644
|
})(), () => {
|
|
1560
1645
|
e = !0;
|
|
@@ -1562,17 +1647,31 @@ var Ft = (e) => {
|
|
|
1562
1647
|
}, [
|
|
1563
1648
|
t.objectName,
|
|
1564
1649
|
t.dataset,
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
t.xAxisKey
|
|
1650
|
+
Oe,
|
|
1651
|
+
Te,
|
|
1652
|
+
t.xAxisKey,
|
|
1653
|
+
g
|
|
1568
1654
|
]);
|
|
1569
|
-
let
|
|
1655
|
+
let { fieldOptionColors: Ae, dimensionLabels: je } = v(() => {
|
|
1656
|
+
if (!Se) return {
|
|
1657
|
+
fieldOptionColors: null,
|
|
1658
|
+
dimensionLabels: null
|
|
1659
|
+
};
|
|
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]) => ({
|
|
1661
|
+
dim: e,
|
|
1662
|
+
path: t
|
|
1663
|
+
})) : null, w);
|
|
1664
|
+
return {
|
|
1665
|
+
fieldOptionColors: r(i),
|
|
1666
|
+
dimensionLabels: a
|
|
1667
|
+
};
|
|
1668
|
+
}, [Se, w]), Me = ie(async (e, n) => {
|
|
1570
1669
|
if (t.aggregate && typeof e.aggregate == "function") {
|
|
1571
1670
|
let r = t.aggregate.groupBy;
|
|
1572
1671
|
if (r && typeof r == "object" && !Array.isArray(r)) {
|
|
1573
1672
|
let i = t.aggregate.field, a = t.aggregate.function, o = {
|
|
1574
1673
|
function: a,
|
|
1575
|
-
alias:
|
|
1674
|
+
alias: Ut(t.aggregate)
|
|
1576
1675
|
};
|
|
1577
1676
|
a !== "count" && i && (o.field = i);
|
|
1578
1677
|
let s = await e.aggregate(t.objectName, {
|
|
@@ -1591,29 +1690,29 @@ var Ft = (e) => {
|
|
|
1591
1690
|
return Array.isArray(i) ? i : [];
|
|
1592
1691
|
}
|
|
1593
1692
|
if (typeof e.find == "function") {
|
|
1594
|
-
let r = await e.find(t.objectName, { $filter: n }), i =
|
|
1595
|
-
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;
|
|
1596
1695
|
}
|
|
1597
1696
|
return [];
|
|
1598
|
-
}, [t.objectName,
|
|
1697
|
+
}, [t.objectName, Te]), Ne = Ue(), Pe = ie(async (e, n) => {
|
|
1599
1698
|
if (!e || !t.objectName && !t.dataset) {
|
|
1600
|
-
n.current &&
|
|
1699
|
+
n.current && ve(!1);
|
|
1601
1700
|
return;
|
|
1602
1701
|
}
|
|
1603
|
-
n.current && (
|
|
1702
|
+
n.current && (ve(!0), be(null));
|
|
1604
1703
|
try {
|
|
1605
1704
|
if (t.dataset && typeof e.queryDataset == "function") {
|
|
1606
|
-
let r =
|
|
1705
|
+
let r = ne(t.filter, Ne), i = await e.queryDataset(t.dataset, {
|
|
1607
1706
|
dimensions: Array.isArray(t.dimensions) ? t.dimensions : [],
|
|
1608
1707
|
measures: Array.isArray(t.values) ? t.values : [],
|
|
1609
1708
|
...r ? { runtimeFilter: r } : {}
|
|
1610
1709
|
});
|
|
1611
|
-
n.current && (
|
|
1710
|
+
n.current && (he(Array.isArray(i?.rows) ? i.rows : []), _e(Array.isArray(i?.fields) ? i.fields : null));
|
|
1612
1711
|
return;
|
|
1613
1712
|
}
|
|
1614
|
-
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;
|
|
1615
1714
|
if (a && c.length > 0 && t.aggregate) {
|
|
1616
|
-
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) => {
|
|
1617
1716
|
if (t == null) return null;
|
|
1618
1717
|
if (e) {
|
|
1619
1718
|
let r = `${e}_${n}`;
|
|
@@ -1621,7 +1720,7 @@ var Ft = (e) => {
|
|
|
1621
1720
|
if (n === "count" && `${e}_count` in t) return Number(t[`${e}_count`]);
|
|
1622
1721
|
}
|
|
1623
1722
|
return r in t ? Number(t[r]) : "value" in t ? Number(t.value) : "count" in t ? Number(t.count) : null;
|
|
1624
|
-
}, a = `${r}${
|
|
1723
|
+
}, a = `${r}${Wt}`, o = d;
|
|
1625
1724
|
if (o && l.some((e) => e[o] != null) && c.some((e) => e[o] != null)) {
|
|
1626
1725
|
let e = /* @__PURE__ */ new Map();
|
|
1627
1726
|
for (let t of c) {
|
|
@@ -1655,138 +1754,139 @@ var Ft = (e) => {
|
|
|
1655
1754
|
l = t;
|
|
1656
1755
|
}
|
|
1657
1756
|
}
|
|
1658
|
-
if (
|
|
1757
|
+
if (d && typeof e.getObjectSchema == "function") try {
|
|
1659
1758
|
let n = await e.getObjectSchema(t.objectName);
|
|
1660
|
-
l = await
|
|
1759
|
+
l = await Kt(l, d, n, e, (e, n) => w(t.objectName, d, e, n));
|
|
1661
1760
|
} catch {}
|
|
1662
|
-
n.current &&
|
|
1761
|
+
n.current && he(l);
|
|
1663
1762
|
} catch (e) {
|
|
1664
|
-
console.error("[ObjectChart] Fetch error:", e), n.current &&
|
|
1763
|
+
console.error("[ObjectChart] Fetch error:", e), n.current && be(e instanceof Error ? e.message : "Failed to load chart data");
|
|
1665
1764
|
} finally {
|
|
1666
|
-
n.current &&
|
|
1765
|
+
n.current && ve(!1);
|
|
1667
1766
|
}
|
|
1668
1767
|
}, [
|
|
1669
1768
|
t.objectName,
|
|
1670
|
-
|
|
1671
|
-
we,
|
|
1769
|
+
Oe,
|
|
1672
1770
|
Te,
|
|
1673
1771
|
Ee,
|
|
1772
|
+
De,
|
|
1674
1773
|
t.xAxisKey,
|
|
1675
1774
|
t.chartType,
|
|
1676
|
-
|
|
1677
|
-
|
|
1775
|
+
Me,
|
|
1776
|
+
Ne,
|
|
1777
|
+
w
|
|
1678
1778
|
]);
|
|
1679
|
-
|
|
1779
|
+
oe(() => {
|
|
1680
1780
|
let e = { current: !0 };
|
|
1681
|
-
return (t.objectName || t.dataset) && !
|
|
1781
|
+
return (t.objectName || t.dataset) && !_ && !t.data ? Pe(h, e) : e.current && ve(!1), () => {
|
|
1682
1782
|
e.current = !1;
|
|
1683
1783
|
};
|
|
1684
1784
|
}, [
|
|
1685
1785
|
t.objectName,
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1786
|
+
Oe,
|
|
1787
|
+
h,
|
|
1788
|
+
_,
|
|
1689
1789
|
t.data,
|
|
1690
|
-
Te,
|
|
1691
|
-
we,
|
|
1692
1790
|
Ee,
|
|
1693
|
-
|
|
1791
|
+
Te,
|
|
1792
|
+
De,
|
|
1793
|
+
Pe
|
|
1694
1794
|
]);
|
|
1695
|
-
let
|
|
1696
|
-
if (!
|
|
1697
|
-
let e = /* @__PURE__ */ new Map(), t = `__raw_${
|
|
1698
|
-
for (let n of
|
|
1699
|
-
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];
|
|
1700
1800
|
if (r == null) continue;
|
|
1701
1801
|
let i = t in (n || {}) ? n[t] : r;
|
|
1702
1802
|
e.set(String(r), i);
|
|
1703
1803
|
}
|
|
1704
1804
|
return e;
|
|
1705
|
-
}, [
|
|
1805
|
+
}, [A, M]), Le = v(() => {
|
|
1706
1806
|
if (O) return {
|
|
1707
1807
|
...t.filter || {},
|
|
1708
|
-
...o(
|
|
1808
|
+
...o(j, O, { groupByField: M })
|
|
1709
1809
|
};
|
|
1710
1810
|
}, [
|
|
1711
1811
|
O,
|
|
1812
|
+
j,
|
|
1712
1813
|
M,
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
}, [
|
|
1719
|
-
let L = t.compareTo, R = t.aggregate ? jt(t.aggregate) : void 0, z = R ? `${R}${Mt}` : void 0, B = !!L && Oe(t.chartType) && !!z && j.some((e) => e[z] != null), V = _(() => {
|
|
1814
|
+
Ee
|
|
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(() => {
|
|
1720
1820
|
let e = Array.isArray(t.series) ? t.series : null;
|
|
1721
|
-
if (!
|
|
1722
|
-
let n = e || [{ dataKey:
|
|
1821
|
+
if (!I) return e;
|
|
1822
|
+
let n = e || [{ dataKey: Re }], r = {
|
|
1723
1823
|
vsLastWeek: "Previous week",
|
|
1724
1824
|
vsLastMonth: "Previous month",
|
|
1725
1825
|
vsLastQuarter: "Previous quarter",
|
|
1726
1826
|
vsLastYear: "Previous year",
|
|
1727
1827
|
vsYesterday: "Yesterday",
|
|
1728
1828
|
vsPreviousPeriod: "Previous period"
|
|
1729
|
-
}[a(
|
|
1829
|
+
}[a(P, t.filter)] || "Previous period";
|
|
1730
1830
|
return [...n.map((e) => ({
|
|
1731
1831
|
...e,
|
|
1732
1832
|
variant: e.variant || "current"
|
|
1733
1833
|
})), {
|
|
1734
|
-
dataKey:
|
|
1834
|
+
dataKey: F,
|
|
1735
1835
|
label: r,
|
|
1736
1836
|
variant: "comparison"
|
|
1737
1837
|
}];
|
|
1738
1838
|
}, [
|
|
1739
|
-
|
|
1839
|
+
I,
|
|
1740
1840
|
t.series,
|
|
1741
|
-
|
|
1742
|
-
|
|
1841
|
+
Re,
|
|
1842
|
+
F,
|
|
1743
1843
|
t.filter,
|
|
1744
|
-
|
|
1745
|
-
]),
|
|
1844
|
+
P
|
|
1845
|
+
]), R = t.dataset ? n(m(A, je), t.dimensions, t.values, ge, { nullCategoryLabel: we("chart.nullCategory", "(None)") }) : null, z = R ? {
|
|
1746
1846
|
...t,
|
|
1747
|
-
data:
|
|
1748
|
-
xAxisKey:
|
|
1749
|
-
series:
|
|
1847
|
+
data: R.data,
|
|
1848
|
+
xAxisKey: R.xAxisKey,
|
|
1849
|
+
series: R.series
|
|
1750
1850
|
} : {
|
|
1751
1851
|
...t,
|
|
1752
|
-
data:
|
|
1753
|
-
...
|
|
1754
|
-
},
|
|
1755
|
-
...
|
|
1756
|
-
...
|
|
1757
|
-
} : void 0,
|
|
1758
|
-
...
|
|
1759
|
-
colors:
|
|
1760
|
-
...
|
|
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 ? {
|
|
1855
|
+
...Ae || {},
|
|
1856
|
+
...B || {}
|
|
1857
|
+
} : void 0, Je = {
|
|
1858
|
+
...z,
|
|
1859
|
+
colors: V,
|
|
1860
|
+
...H ? { categoryColors: H } : {}
|
|
1761
1861
|
};
|
|
1762
|
-
if (
|
|
1862
|
+
if (D && A.length === 0) return /* @__PURE__ */ E("div", {
|
|
1763
1863
|
className: "p-2 " + (t.className || ""),
|
|
1764
1864
|
"data-testid": "chart-loading",
|
|
1765
1865
|
role: "status",
|
|
1766
1866
|
"aria-busy": "true",
|
|
1767
1867
|
"aria-live": "polite",
|
|
1768
|
-
children: [/* @__PURE__ */
|
|
1868
|
+
children: [/* @__PURE__ */ T("span", {
|
|
1769
1869
|
className: "sr-only",
|
|
1770
1870
|
children: "Loading chart data…"
|
|
1771
|
-
}), /* @__PURE__ */
|
|
1871
|
+
}), /* @__PURE__ */ T(x, { className: "h-full" })]
|
|
1772
1872
|
});
|
|
1773
|
-
if (
|
|
1873
|
+
if (ye) return /* @__PURE__ */ E("div", {
|
|
1774
1874
|
className: "flex flex-col items-center justify-center gap-2 p-4 " + (t.className || ""),
|
|
1775
1875
|
"data-testid": "chart-error",
|
|
1776
1876
|
role: "alert",
|
|
1777
1877
|
children: [
|
|
1778
|
-
/* @__PURE__ */
|
|
1779
|
-
/* @__PURE__ */
|
|
1878
|
+
/* @__PURE__ */ T(We, { className: "h-6 w-6 text-destructive opacity-60" }),
|
|
1879
|
+
/* @__PURE__ */ T("p", {
|
|
1780
1880
|
className: "text-xs text-destructive font-medium",
|
|
1781
1881
|
children: "Failed to load chart data"
|
|
1782
1882
|
}),
|
|
1783
|
-
/* @__PURE__ */
|
|
1883
|
+
/* @__PURE__ */ T("p", {
|
|
1784
1884
|
className: "text-xs text-muted-foreground max-w-xs text-center",
|
|
1785
|
-
children:
|
|
1885
|
+
children: ye
|
|
1786
1886
|
})
|
|
1787
1887
|
]
|
|
1788
1888
|
});
|
|
1789
|
-
if (!
|
|
1889
|
+
if (!h && t.objectName && A.length === 0) return /* @__PURE__ */ E("div", {
|
|
1790
1890
|
className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (t.className || ""),
|
|
1791
1891
|
"data-testid": "chart-no-datasource",
|
|
1792
1892
|
children: [
|
|
@@ -1795,22 +1895,22 @@ var Ft = (e) => {
|
|
|
1795
1895
|
"”"
|
|
1796
1896
|
]
|
|
1797
1897
|
});
|
|
1798
|
-
let
|
|
1799
|
-
let t = e.category, n = t != null &&
|
|
1800
|
-
|
|
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({
|
|
1801
1901
|
...e,
|
|
1802
1902
|
category: n,
|
|
1803
1903
|
categoryLabel: t,
|
|
1804
1904
|
scope: "cell"
|
|
1805
1905
|
});
|
|
1806
|
-
} : void 0,
|
|
1807
|
-
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 = {
|
|
1808
1908
|
type: "object-data-table",
|
|
1809
1909
|
objectName: t.objectName,
|
|
1810
1910
|
filter: e,
|
|
1811
1911
|
pagination: !0,
|
|
1812
|
-
pageSize:
|
|
1813
|
-
columns:
|
|
1912
|
+
pageSize: j?.maxRows,
|
|
1913
|
+
columns: j?.columns?.map((e) => ({
|
|
1814
1914
|
accessorKey: e,
|
|
1815
1915
|
header: e
|
|
1816
1916
|
})),
|
|
@@ -1819,63 +1919,75 @@ var Ft = (e) => {
|
|
|
1819
1919
|
mode: "record",
|
|
1820
1920
|
target: "dialog"
|
|
1821
1921
|
}
|
|
1822
|
-
}, a = /* @__PURE__ */
|
|
1922
|
+
}, a = /* @__PURE__ */ T("div", {
|
|
1823
1923
|
className: "overflow-auto",
|
|
1824
1924
|
"data-testid": "chart-drill-body",
|
|
1825
|
-
children: /* @__PURE__ */
|
|
1925
|
+
children: /* @__PURE__ */ T(ze, {
|
|
1826
1926
|
schema: i,
|
|
1827
|
-
dataSource:
|
|
1927
|
+
dataSource: h
|
|
1828
1928
|
})
|
|
1829
|
-
}), o =
|
|
1929
|
+
}), o = k && t.objectName ? /* @__PURE__ */ E(b, {
|
|
1830
1930
|
type: "button",
|
|
1831
1931
|
variant: "ghost",
|
|
1832
1932
|
size: "sm",
|
|
1833
1933
|
"data-testid": "drill-open-in-list",
|
|
1834
1934
|
onClick: () => {
|
|
1835
|
-
|
|
1935
|
+
k(t.objectName, e), xe(null);
|
|
1836
1936
|
},
|
|
1837
|
-
children: [
|
|
1937
|
+
children: [we("dashboard.openInList", "Open in list"), /* @__PURE__ */ T(Ge, { className: "ml-1 h-3.5 w-3.5" })]
|
|
1838
1938
|
}) : null;
|
|
1839
|
-
return r === "dialog" ? /* @__PURE__ */
|
|
1939
|
+
return r === "dialog" ? /* @__PURE__ */ T(S, {
|
|
1840
1940
|
open: !0,
|
|
1841
|
-
onOpenChange: (e) => !e &&
|
|
1842
|
-
children: /* @__PURE__ */
|
|
1941
|
+
onOpenChange: (e) => !e && xe(null),
|
|
1942
|
+
children: /* @__PURE__ */ E(C, {
|
|
1843
1943
|
className: "max-w-4xl",
|
|
1844
|
-
children: [/* @__PURE__ */
|
|
1944
|
+
children: [/* @__PURE__ */ E(se, {
|
|
1845
1945
|
className: "flex-row items-center justify-between gap-4 pr-8",
|
|
1846
|
-
children: [/* @__PURE__ */
|
|
1946
|
+
children: [/* @__PURE__ */ T(ce, { children: n }), o]
|
|
1847
1947
|
}), a]
|
|
1848
1948
|
})
|
|
1849
|
-
}) : /* @__PURE__ */
|
|
1949
|
+
}) : /* @__PURE__ */ T(ue, {
|
|
1850
1950
|
open: !0,
|
|
1851
|
-
onOpenChange: (e) => !e &&
|
|
1852
|
-
children: /* @__PURE__ */
|
|
1951
|
+
onOpenChange: (e) => !e && xe(null),
|
|
1952
|
+
children: /* @__PURE__ */ E(de, {
|
|
1853
1953
|
side: "right",
|
|
1854
1954
|
className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col",
|
|
1855
|
-
children: [/* @__PURE__ */
|
|
1955
|
+
children: [/* @__PURE__ */ E(fe, {
|
|
1856
1956
|
className: "flex-row items-center justify-between gap-4 pr-8",
|
|
1857
|
-
children: [/* @__PURE__ */
|
|
1858
|
-
}), /* @__PURE__ */
|
|
1957
|
+
children: [/* @__PURE__ */ T(pe, { children: n }), o]
|
|
1958
|
+
}), /* @__PURE__ */ T("div", {
|
|
1859
1959
|
className: "flex-1 overflow-hidden mt-2",
|
|
1860
1960
|
children: a
|
|
1861
1961
|
})]
|
|
1862
1962
|
})
|
|
1863
1963
|
});
|
|
1864
1964
|
})() : null;
|
|
1865
|
-
return /* @__PURE__ */
|
|
1866
|
-
className: "relative",
|
|
1965
|
+
return /* @__PURE__ */ E("div", {
|
|
1966
|
+
className: "relative h-full",
|
|
1867
1967
|
children: [
|
|
1868
|
-
/* @__PURE__ */
|
|
1869
|
-
/* @__PURE__ */
|
|
1968
|
+
/* @__PURE__ */ T(le, { active: D && A.length > 0 }),
|
|
1969
|
+
/* @__PURE__ */ T($, {
|
|
1870
1970
|
...e,
|
|
1871
|
-
schema:
|
|
1872
|
-
onChartClick:
|
|
1971
|
+
schema: Je,
|
|
1972
|
+
onChartClick: Xe
|
|
1873
1973
|
}),
|
|
1874
|
-
|
|
1974
|
+
Ze
|
|
1875
1975
|
]
|
|
1876
1976
|
});
|
|
1877
|
-
}
|
|
1878
|
-
e.
|
|
1977
|
+
}, Jt = { filter: !0 }, Yt = (e) => /* @__PURE__ */ T(F, {
|
|
1978
|
+
schema: e.schema,
|
|
1979
|
+
mapping: Jt,
|
|
1980
|
+
dataSource: e.dataSource,
|
|
1981
|
+
testId: "object-chart",
|
|
1982
|
+
errorTitle: "This chart’s data source could not be resolved",
|
|
1983
|
+
children: (t) => /* @__PURE__ */ T(qt, {
|
|
1984
|
+
...e,
|
|
1985
|
+
schema: t
|
|
1986
|
+
})
|
|
1987
|
+
});
|
|
1988
|
+
//#endregion
|
|
1989
|
+
//#region src/index.tsx
|
|
1990
|
+
e.register("object-chart", Yt, {
|
|
1879
1991
|
namespace: "plugin-charts",
|
|
1880
1992
|
label: "Object Chart",
|
|
1881
1993
|
category: "view",
|
|
@@ -1910,14 +2022,12 @@ e.register("object-chart", Ft, {
|
|
|
1910
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."
|
|
1911
2023
|
}
|
|
1912
2024
|
]
|
|
1913
|
-
});
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
var It = {
|
|
1917
|
-
"bar-chart": kt,
|
|
2025
|
+
}), rt();
|
|
2026
|
+
var Xt = {
|
|
2027
|
+
"bar-chart": Ht,
|
|
1918
2028
|
chart: $
|
|
1919
2029
|
};
|
|
1920
|
-
e.register("bar-chart",
|
|
2030
|
+
e.register("bar-chart", Ht, {
|
|
1921
2031
|
namespace: "plugin-charts",
|
|
1922
2032
|
label: "Bar Chart",
|
|
1923
2033
|
category: "plugin",
|
|
@@ -1981,7 +2091,7 @@ e.register("bar-chart", kt, {
|
|
|
1981
2091
|
height: 400,
|
|
1982
2092
|
color: "#8884d8"
|
|
1983
2093
|
}
|
|
1984
|
-
}), e.register("chart",
|
|
2094
|
+
}), e.register("chart", Yt, {
|
|
1985
2095
|
namespace: "view",
|
|
1986
2096
|
category: "view",
|
|
1987
2097
|
label: "Chart",
|
|
@@ -2148,4 +2258,4 @@ e.register("bar-chart", kt, {
|
|
|
2148
2258
|
defaultProps: { chartType: "scatter" }
|
|
2149
2259
|
});
|
|
2150
2260
|
//#endregion
|
|
2151
|
-
export {
|
|
2261
|
+
export { Ht as ChartBarRenderer, $ as ChartRenderer, qt as ObjectChart, Yt as ObjectChartBlock, Xt as chartComponents, H as normalizeChartSchema };
|