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