drizzle-cube 0.1.29 → 0.1.31

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.
@@ -1,2404 +0,0 @@
1
- import { jsx as i, jsxs as w, Fragment as $e } from "react/jsx-runtime";
2
- import { useState as O } from "react";
3
- import { ResponsiveContainer as _e, Tooltip as yt, ComposedChart as st, CartesianGrid as ye, XAxis as pe, YAxis as ve, Legend as B, Bar as pt, Cell as Le, Line as q, LineChart as vt, Area as gt, PieChart as bt, Pie as wt, ScatterChart as Nt, Scatter as He, RadarChart as At, PolarGrid as St, PolarAngleAxis as kt, PolarRadiusAxis as Mt, Radar as $t, RadialBarChart as Lt, RadialBar as Tt, Treemap as Ft } from "recharts";
4
- import { u as W } from "./providers-B7MVnAAt.js";
5
- function G({ children: e, height: t = "100%" }) {
6
- try {
7
- if (t === "100%")
8
- return /* @__PURE__ */ i("div", { className: "w-full h-full flex-1 flex flex-col relative", style: { minHeight: "250px", overflow: "hidden" }, children: /* @__PURE__ */ i(_e, { width: "100%", height: "100%", debounce: 50, style: { marginTop: "16px" }, children: e }) });
9
- const r = {
10
- height: typeof t == "number" ? `${t}px` : t,
11
- width: "100%",
12
- minHeight: "200px"
13
- };
14
- return /* @__PURE__ */ i("div", { className: "w-full flex flex-col relative", style: { ...r, overflow: "hidden" }, children: /* @__PURE__ */ i(_e, { width: "100%", height: "100%", debounce: 50, style: { marginTop: "16px" }, children: e }) });
15
- } catch (r) {
16
- return /* @__PURE__ */ w(
17
- "div",
18
- {
19
- className: "flex flex-col items-center justify-center w-full h-full p-4 text-center border-2 border-dashed border-yellow-300 rounded-lg bg-yellow-50",
20
- style: { height: t },
21
- children: [
22
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold text-yellow-600 mb-1", children: "Chart Container Error" }),
23
- /* @__PURE__ */ i("div", { className: "text-xs text-gray-600", children: r instanceof Error ? r.message : "Failed to create responsive container" })
24
- ]
25
- }
26
- );
27
- }
28
- }
29
- function V({ formatter: e, labelFormatter: t }) {
30
- return /* @__PURE__ */ i(
31
- yt,
32
- {
33
- formatter: e,
34
- labelFormatter: t,
35
- contentStyle: {
36
- backgroundColor: "white",
37
- border: "1px solid #e5e7eb",
38
- borderRadius: "0.5rem",
39
- fontSize: "0.875rem",
40
- color: "#1f2937",
41
- boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
42
- padding: "8px 12px"
43
- }
44
- }
45
- );
46
- }
47
- const L = [
48
- "#3b82f6",
49
- // blue
50
- "#10b981",
51
- // green
52
- "#f59e0b",
53
- // yellow
54
- "#ef4444",
55
- // red
56
- "#8b5cf6",
57
- // purple
58
- "#f97316",
59
- // orange
60
- "#06b6d4",
61
- // cyan
62
- "#84cc16"
63
- // lime
64
- ], ie = [
65
- "#440154",
66
- // dark purple
67
- "#414487",
68
- // purple-blue
69
- "#2a788e",
70
- // teal
71
- "#22a884",
72
- // green-teal
73
- "#7ad151",
74
- // green
75
- "#fde725"
76
- // yellow
77
- ], Oe = "#10b981", jt = "#ef4444", ge = {
78
- top: 5,
79
- right: 30,
80
- left: 20,
81
- bottom: 5
82
- };
83
- function Ne(e, t) {
84
- return t[e] || e;
85
- }
86
- function R(e, t) {
87
- if (!e) return String(e || "Unknown");
88
- const r = String(e);
89
- if (r.match(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}/)) {
90
- let n = r;
91
- r.includes(" ") && (n = r.replace(" ", "T").replace("+00", "Z").replace(/\+\d{2}:\d{2}$/, "Z")), !n.endsWith("Z") && !n.includes("+") && (n = n + "Z");
92
- const s = new Date(n);
93
- if (isNaN(s.getTime()))
94
- return r;
95
- const a = s.getUTCFullYear(), l = String(s.getUTCMonth() + 1).padStart(2, "0"), c = String(s.getUTCDate()).padStart(2, "0"), u = s.getUTCHours(), o = s.getUTCMinutes();
96
- if (t)
97
- switch (t.toLowerCase()) {
98
- case "year":
99
- return `${a}`;
100
- case "quarter":
101
- const m = Math.floor(s.getUTCMonth() / 3) + 1;
102
- return `${a}-Q${m}`;
103
- case "month":
104
- return `${a}-${l}`;
105
- case "week":
106
- return `${a}-${l}-${c}`;
107
- case "day":
108
- return `${a}-${l}-${c}`;
109
- case "hour":
110
- return `${a}-${l}-${c} ${String(u).padStart(2, "0")}:00`;
111
- case "minute":
112
- return `${a}-${l}-${c} ${String(u).padStart(2, "0")}:${String(o).padStart(2, "0")}`;
113
- }
114
- const d = s.getUTCSeconds(), f = s.getUTCMilliseconds();
115
- if (c === "01" && u === 0 && o === 0 && d === 0 && f === 0) {
116
- if (l === "01" || l === "04" || l === "07" || l === "10") {
117
- const m = Math.floor(s.getUTCMonth() / 3) + 1;
118
- return `${a}-Q${m}`;
119
- }
120
- return `${a}-${l}`;
121
- }
122
- return u === 0 && o === 0 && d === 0 && f === 0 ? `${a}-${l}-${c}` : o === 0 && d === 0 && f === 0 ? `${a}-${l}-${c} ${String(u).padStart(2, "0")}:00` : `${a}-${l}-${c} ${String(u).padStart(2, "0")}:${String(o).padStart(2, "0")}`;
123
- }
124
- return r;
125
- }
126
- function H(e, t) {
127
- try {
128
- if (e != null && e.timeDimensions) {
129
- const n = e.timeDimensions.find((s) => t === s.dimension || t.startsWith(s.dimension.replace(".", "_")) || t === `${s.dimension}_${s.granularity}`);
130
- if (n != null && n.granularity)
131
- return n.granularity;
132
- }
133
- const r = t.match(/_([a-z]+)$/);
134
- if (r) {
135
- const n = r[1];
136
- if (["year", "quarter", "month", "week", "day", "hour", "minute", "second"].includes(n))
137
- return n;
138
- }
139
- return;
140
- } catch {
141
- return;
142
- }
143
- }
144
- function zt(e, t, r, n, s = {}) {
145
- if (!e || e.length === 0) return [];
146
- const a = H(n, t);
147
- return e.map((l) => {
148
- const c = {
149
- name: R(l[t], a) || l[t] || "Unknown"
150
- };
151
- return r.forEach((u) => {
152
- const o = Ne(u, s);
153
- c[o] = typeof l[u] == "string" ? parseFloat(l[u]) : l[u] || 0;
154
- }), c;
155
- });
156
- }
157
- function ee(e, t, r, n, s, a = {}) {
158
- var A;
159
- if (!e || e.length === 0)
160
- return { data: [], seriesKeys: [], hasDimensions: !1 };
161
- const l = n || {}, c = [
162
- ...l.dimensions || [],
163
- ...((A = l.timeDimensions) == null ? void 0 : A.map((x) => x.dimension)) || []
164
- ], u = l.measures || [], o = r.filter((x) => u.includes(x)), d = (s || []).filter((x) => c.includes(x));
165
- if (d.length > 0) {
166
- const x = {};
167
- e.forEach((S) => {
168
- const T = H(n, t), h = R(S[t], T) || S[t] || "Unknown";
169
- x[h] || (x[h] = { name: String(h) }), o.forEach((b) => {
170
- const y = Ne(b, a);
171
- x[h][y] = (x[h][y] || 0) + (typeof S[b] == "string" ? parseFloat(S[b]) : S[b] || 0);
172
- }), d.forEach((b) => {
173
- const y = S[b];
174
- if (y != null) {
175
- const p = String(y), v = o[0] || u.find(
176
- (k) => k.includes("totalCost") || k.includes("count") || k.includes("sum")
177
- ) || u[0];
178
- if (v) {
179
- const k = typeof S[v] == "string" ? parseFloat(S[v]) : S[v] || 0;
180
- x[h][p] = (x[h][p] || 0) + k;
181
- }
182
- }
183
- });
184
- });
185
- const N = Object.values(x), g = Array.from(new Set(
186
- e.flatMap(
187
- (S) => d.map((T) => {
188
- const h = S[T];
189
- return h != null ? String(h) : null;
190
- }).filter((T) => T !== null)
191
- )
192
- ));
193
- return {
194
- data: N,
195
- seriesKeys: g,
196
- hasDimensions: !0
197
- };
198
- }
199
- const f = zt(e, t, r, n, a), m = r.map((x) => Ne(x, a));
200
- return {
201
- data: f,
202
- seriesKeys: m,
203
- hasDimensions: !1
204
- };
205
- }
206
- function Te(e) {
207
- if (!e || typeof e != "string")
208
- return [];
209
- const t = e.trim();
210
- if (!t)
211
- return [];
212
- try {
213
- const r = t.split(",").map((n) => n.trim()).filter((n) => n !== "").map((n) => {
214
- const s = parseFloat(n);
215
- if (isNaN(s))
216
- throw new Error(`Invalid numeric value: ${n}`);
217
- return s;
218
- });
219
- return r.length > 0 ? r : [];
220
- } catch (r) {
221
- return console.warn("Failed to parse target values:", r), [];
222
- }
223
- }
224
- function Fe(e, t) {
225
- if (e.length === 0 || t <= 0)
226
- return [];
227
- if (e.length === 1)
228
- return new Array(t).fill(e[0]);
229
- const r = [], n = Math.floor(t / e.length), s = t % e.length;
230
- let a = 0;
231
- for (let l = 0; l < e.length; l++) {
232
- const c = n + (l < s ? 1 : 0);
233
- for (let u = 0; u < c; u++)
234
- r[a++] = e[l];
235
- }
236
- return r;
237
- }
238
- function Ur(e, t) {
239
- return t === 0 ? e === 0 ? 0 : e > 0 ? 100 : -100 : (e - t) / t * 100;
240
- }
241
- function qr(e, t = 1) {
242
- return `${e >= 0 ? "+" : ""}${e.toFixed(t)}%`;
243
- }
244
- function Kr({
245
- data: e,
246
- chartConfig: t,
247
- displayConfig: r = {},
248
- queryObject: n,
249
- height: s = "100%",
250
- colorPalette: a
251
- }) {
252
- const [l, c] = O(null), { labelMap: u, getFieldLabel: o } = W();
253
- try {
254
- const d = {
255
- showLegend: (r == null ? void 0 : r.showLegend) ?? !0,
256
- showGrid: (r == null ? void 0 : r.showGrid) ?? !0,
257
- showTooltip: (r == null ? void 0 : r.showTooltip) ?? !0,
258
- stacked: (r == null ? void 0 : r.stacked) ?? !1
259
- };
260
- if (!e || e.length === 0)
261
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-gray-500", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
262
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
263
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No data points to display in bar chart" })
264
- ] }) });
265
- let f, m, A = [];
266
- if (t != null && t.xAxis && (t != null && t.yAxis))
267
- f = t.xAxis[0], m = Array.isArray(t.yAxis) ? t.yAxis : [t.yAxis], A = t.series || [];
268
- else if (t != null && t.x && (t != null && t.y))
269
- f = t.x, m = Array.isArray(t.y) ? t.y : [t.y];
270
- else
271
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
272
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
273
- /* @__PURE__ */ i("div", { className: "text-xs", children: "Invalid or missing chart axis configuration" })
274
- ] }) });
275
- if (!f || !m || m.length === 0)
276
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
277
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
278
- /* @__PURE__ */ i("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
279
- ] }) });
280
- const { data: x, seriesKeys: N } = ee(
281
- e,
282
- f,
283
- m,
284
- n,
285
- A,
286
- u
287
- ), g = d.stacked === !0, S = N.length === 1 && x.some((v) => {
288
- const k = v[N[0]];
289
- return typeof k == "number" && k < 0;
290
- }), T = d.showLegend, h = {
291
- ...ge,
292
- left: 40
293
- // Increased from 20 to 40 for Y-axis label space
294
- }, b = Te((r == null ? void 0 : r.target) || ""), y = Fe(b, x.length);
295
- let p = x;
296
- return y.length > 0 && (p = x.map((v, k) => ({
297
- ...v,
298
- __target: y[k] || null
299
- }))), !x || x.length === 0 ? /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-gray-500", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
300
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
301
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No valid data points for bar chart after transformation" })
302
- ] }) }) : /* @__PURE__ */ i(G, { height: s, children: /* @__PURE__ */ w(st, { data: p, margin: h, children: [
303
- d.showGrid && /* @__PURE__ */ i(ye, { strokeDasharray: "3 3" }),
304
- /* @__PURE__ */ i(
305
- pe,
306
- {
307
- dataKey: "name",
308
- tick: { fontSize: 12 },
309
- angle: -45,
310
- textAnchor: "end",
311
- height: 60
312
- }
313
- ),
314
- /* @__PURE__ */ i(
315
- ve,
316
- {
317
- tick: { fontSize: 12 },
318
- label: { value: o(m[0]), angle: -90, position: "left", style: { textAnchor: "middle", fontSize: "12px" } }
319
- }
320
- ),
321
- d.showTooltip && /* @__PURE__ */ i(
322
- V,
323
- {
324
- formatter: (v, k) => k === "Target" ? [`${v}`, "Target Value"] : [v, k]
325
- }
326
- ),
327
- T && /* @__PURE__ */ i(
328
- B,
329
- {
330
- wrapperStyle: { fontSize: "12px", paddingTop: "25px" },
331
- iconType: "rect",
332
- iconSize: 8,
333
- layout: "horizontal",
334
- align: "center",
335
- verticalAlign: "bottom",
336
- onMouseEnter: (v) => c(String(v.dataKey || "")),
337
- onMouseLeave: () => c(null)
338
- }
339
- ),
340
- N.map((v, k) => /* @__PURE__ */ i(
341
- pt,
342
- {
343
- dataKey: v,
344
- stackId: g ? "stack" : void 0,
345
- fill: S ? Oe : (a == null ? void 0 : a.colors) && a.colors[k % a.colors.length] || L[k % L.length],
346
- fillOpacity: l ? l === v ? 1 : 0.3 : 1,
347
- children: S && x.map(($, F) => {
348
- const M = $[v], E = typeof M == "number" && M < 0 ? jt : Oe;
349
- return /* @__PURE__ */ i(
350
- Le,
351
- {
352
- fill: E,
353
- fillOpacity: l ? l === v ? 1 : 0.3 : 1
354
- },
355
- `cell-${F}`
356
- );
357
- })
358
- },
359
- v
360
- )),
361
- y.length > 0 && /* @__PURE__ */ w($e, { children: [
362
- /* @__PURE__ */ i(
363
- q,
364
- {
365
- type: "monotone",
366
- dataKey: "__target",
367
- stroke: "#ffffff",
368
- strokeWidth: 2,
369
- dot: !1,
370
- activeDot: !1,
371
- connectNulls: !1
372
- }
373
- ),
374
- /* @__PURE__ */ i(
375
- q,
376
- {
377
- type: "monotone",
378
- dataKey: "__target",
379
- name: "Target",
380
- stroke: "#8B5CF6",
381
- strokeWidth: 2,
382
- strokeDasharray: "2 3",
383
- dot: !1,
384
- activeDot: !1,
385
- connectNulls: !1
386
- }
387
- )
388
- ] })
389
- ] }) });
390
- } catch (d) {
391
- return /* @__PURE__ */ i("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
392
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Bar Chart Error" }),
393
- /* @__PURE__ */ i("div", { className: "text-xs mb-2", children: d instanceof Error ? d.message : "Unknown rendering error" }),
394
- /* @__PURE__ */ i("div", { className: "text-xs text-gray-600", children: "Check the data and configuration" })
395
- ] }) });
396
- }
397
- }
398
- function Br({
399
- data: e,
400
- chartConfig: t,
401
- displayConfig: r = {},
402
- queryObject: n,
403
- height: s = "100%",
404
- colorPalette: a
405
- }) {
406
- const [l, c] = O(null), { labelMap: u, getFieldLabel: o } = W();
407
- try {
408
- const d = {
409
- showLegend: (r == null ? void 0 : r.showLegend) ?? !0,
410
- showGrid: (r == null ? void 0 : r.showGrid) ?? !0,
411
- showTooltip: (r == null ? void 0 : r.showTooltip) ?? !0
412
- };
413
- if (!e || e.length === 0)
414
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-gray-500", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
415
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
416
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No data points to display in line chart" })
417
- ] }) });
418
- let f, m, A = [];
419
- if (t != null && t.xAxis && (t != null && t.yAxis))
420
- f = t.xAxis[0], m = Array.isArray(t.yAxis) ? t.yAxis : [t.yAxis], A = t.series || [];
421
- else if (t != null && t.x && (t != null && t.y))
422
- f = t.x, m = Array.isArray(t.y) ? t.y : [t.y];
423
- else
424
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
425
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
426
- /* @__PURE__ */ i("div", { className: "text-xs", children: "Invalid or missing chart axis configuration" })
427
- ] }) });
428
- if (!f || !m || m.length === 0)
429
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
430
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
431
- /* @__PURE__ */ i("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
432
- ] }) });
433
- const { data: x, seriesKeys: N } = ee(
434
- e,
435
- f,
436
- m,
437
- n,
438
- A,
439
- u
440
- ), g = d.showLegend, S = {
441
- ...ge,
442
- left: 40
443
- // Increased from 20 to 40 for Y-axis label space
444
- }, T = Te((r == null ? void 0 : r.target) || ""), h = Fe(T, x.length);
445
- let b = x;
446
- return h.length > 0 && (b = x.map((y, p) => ({
447
- ...y,
448
- __target: h[p] || null
449
- }))), !x || x.length === 0 ? /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-gray-500", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
450
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
451
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No valid data points for line chart after transformation" })
452
- ] }) }) : /* @__PURE__ */ i(G, { height: s, children: /* @__PURE__ */ w(vt, { data: b, margin: S, children: [
453
- d.showGrid && /* @__PURE__ */ i(ye, { strokeDasharray: "3 3" }),
454
- /* @__PURE__ */ i(
455
- pe,
456
- {
457
- dataKey: "name",
458
- tick: { fontSize: 12 },
459
- angle: -45,
460
- textAnchor: "end",
461
- height: 60
462
- }
463
- ),
464
- /* @__PURE__ */ i(
465
- ve,
466
- {
467
- tick: { fontSize: 12 },
468
- label: { value: o(m[0]), angle: -90, position: "left", style: { textAnchor: "middle", fontSize: "12px" } }
469
- }
470
- ),
471
- d.showTooltip && /* @__PURE__ */ i(
472
- V,
473
- {
474
- formatter: (y, p) => p === "Target" ? [`${y}`, "Target Value"] : [y, p]
475
- }
476
- ),
477
- g && /* @__PURE__ */ i(
478
- B,
479
- {
480
- wrapperStyle: { fontSize: "12px", paddingTop: "25px" },
481
- iconType: "line",
482
- iconSize: 8,
483
- layout: "horizontal",
484
- align: "center",
485
- verticalAlign: "bottom",
486
- onMouseEnter: (y) => c(String(y.dataKey || "")),
487
- onMouseLeave: () => c(null)
488
- }
489
- ),
490
- N.map((y, p) => /* @__PURE__ */ i(
491
- q,
492
- {
493
- type: "monotone",
494
- dataKey: y,
495
- stroke: (a == null ? void 0 : a.colors) && a.colors[p % a.colors.length] || L[p % L.length],
496
- strokeWidth: 2,
497
- dot: { r: 3 },
498
- activeDot: { r: 5 },
499
- strokeOpacity: l ? l === y ? 1 : 0.3 : 1
500
- },
501
- y
502
- )),
503
- h.length > 0 && /* @__PURE__ */ w($e, { children: [
504
- /* @__PURE__ */ i(
505
- q,
506
- {
507
- type: "monotone",
508
- dataKey: "__target",
509
- stroke: "#ffffff",
510
- strokeWidth: 2,
511
- dot: !1,
512
- activeDot: !1,
513
- connectNulls: !1
514
- }
515
- ),
516
- /* @__PURE__ */ i(
517
- q,
518
- {
519
- type: "monotone",
520
- dataKey: "__target",
521
- name: "Target",
522
- stroke: "#8B5CF6",
523
- strokeWidth: 2,
524
- strokeDasharray: "2 3",
525
- dot: !1,
526
- activeDot: !1,
527
- connectNulls: !1
528
- }
529
- )
530
- ] })
531
- ] }) });
532
- } catch (d) {
533
- return /* @__PURE__ */ i("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
534
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Line Chart Error" }),
535
- /* @__PURE__ */ i("div", { className: "text-xs mb-2", children: d instanceof Error ? d.message : "Unknown rendering error" }),
536
- /* @__PURE__ */ i("div", { className: "text-xs text-gray-600", children: "Check the data and configuration" })
537
- ] }) });
538
- }
539
- }
540
- function Wr({
541
- data: e,
542
- chartConfig: t,
543
- displayConfig: r = {},
544
- queryObject: n,
545
- height: s = "100%",
546
- colorPalette: a
547
- }) {
548
- const [l, c] = O(null), { labelMap: u, getFieldLabel: o } = W();
549
- try {
550
- const d = {
551
- showLegend: (r == null ? void 0 : r.showLegend) ?? !0,
552
- showGrid: (r == null ? void 0 : r.showGrid) ?? !0,
553
- showTooltip: (r == null ? void 0 : r.showTooltip) ?? !0,
554
- stacked: (r == null ? void 0 : r.stacked) ?? !1
555
- };
556
- if (!e || e.length === 0)
557
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-gray-500", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
558
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
559
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No data points to display in area chart" })
560
- ] }) });
561
- let f, m, A = [];
562
- if (t != null && t.xAxis && (t != null && t.yAxis))
563
- f = t.xAxis[0], m = Array.isArray(t.yAxis) ? t.yAxis : [t.yAxis], A = t.series || [];
564
- else if (t != null && t.x && (t != null && t.y))
565
- f = t.x, m = Array.isArray(t.y) ? t.y : [t.y];
566
- else
567
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
568
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
569
- /* @__PURE__ */ i("div", { className: "text-xs", children: "Invalid or missing chart axis configuration" })
570
- ] }) });
571
- if (!f || !m || m.length === 0)
572
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
573
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
574
- /* @__PURE__ */ i("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
575
- ] }) });
576
- const { data: x, seriesKeys: N } = ee(
577
- e,
578
- f,
579
- m,
580
- n,
581
- A,
582
- u
583
- ), g = d.showLegend, S = {
584
- ...ge,
585
- left: 40
586
- // Increased from 20 to 40 for Y-axis label space
587
- }, T = Te((r == null ? void 0 : r.target) || ""), h = Fe(T, x.length);
588
- let b = x;
589
- return h.length > 0 && (b = x.map((y, p) => ({
590
- ...y,
591
- __target: h[p] || null
592
- }))), !x || x.length === 0 ? /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-gray-500", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
593
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
594
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No valid data points for area chart after transformation" })
595
- ] }) }) : /* @__PURE__ */ i(G, { height: s, children: /* @__PURE__ */ w(st, { data: b, margin: S, children: [
596
- d.showGrid && /* @__PURE__ */ i(ye, { strokeDasharray: "3 3" }),
597
- /* @__PURE__ */ i(
598
- pe,
599
- {
600
- dataKey: "name",
601
- tick: { fontSize: 12 },
602
- angle: -45,
603
- textAnchor: "end",
604
- height: 60
605
- }
606
- ),
607
- /* @__PURE__ */ i(
608
- ve,
609
- {
610
- tick: { fontSize: 12 },
611
- label: { value: o(m[0]), angle: -90, position: "left", style: { textAnchor: "middle", fontSize: "12px" } }
612
- }
613
- ),
614
- d.showTooltip && /* @__PURE__ */ i(
615
- V,
616
- {
617
- formatter: (y, p) => p === "Target" ? [`${y}`, "Target Value"] : [y, p]
618
- }
619
- ),
620
- g && /* @__PURE__ */ i(
621
- B,
622
- {
623
- wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
624
- iconType: "rect",
625
- iconSize: 8,
626
- layout: "horizontal",
627
- align: "center",
628
- verticalAlign: "bottom",
629
- onMouseEnter: (y) => c(String(y.dataKey || "")),
630
- onMouseLeave: () => c(null)
631
- }
632
- ),
633
- N.map((y, p) => /* @__PURE__ */ i(
634
- gt,
635
- {
636
- type: "monotone",
637
- dataKey: y,
638
- stackId: d.stacked ? "stack" : void 0,
639
- stroke: (a == null ? void 0 : a.colors) && a.colors[p % a.colors.length] || L[p % L.length],
640
- fill: (a == null ? void 0 : a.colors) && a.colors[p % a.colors.length] || L[p % L.length],
641
- fillOpacity: l ? l === y ? 0.6 : 0.1 : 0.3,
642
- strokeWidth: 2,
643
- strokeOpacity: l ? l === y ? 1 : 0.3 : 1
644
- },
645
- y
646
- )),
647
- h.length > 0 && /* @__PURE__ */ w($e, { children: [
648
- /* @__PURE__ */ i(
649
- q,
650
- {
651
- type: "monotone",
652
- dataKey: "__target",
653
- stroke: "#ffffff",
654
- strokeWidth: 2,
655
- dot: !1,
656
- activeDot: !1,
657
- connectNulls: !1
658
- }
659
- ),
660
- /* @__PURE__ */ i(
661
- q,
662
- {
663
- type: "monotone",
664
- dataKey: "__target",
665
- name: "Target",
666
- stroke: "#8B5CF6",
667
- strokeWidth: 2,
668
- strokeDasharray: "2 3",
669
- dot: !1,
670
- activeDot: !1,
671
- connectNulls: !1
672
- }
673
- )
674
- ] })
675
- ] }) });
676
- } catch (d) {
677
- return /* @__PURE__ */ i("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
678
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Area Chart Error" }),
679
- /* @__PURE__ */ i("div", { className: "text-xs mb-2", children: d instanceof Error ? d.message : "Unknown rendering error" }),
680
- /* @__PURE__ */ i("div", { className: "text-xs text-gray-600", children: "Check the data and configuration" })
681
- ] }) });
682
- }
683
- }
684
- function Yr({
685
- data: e,
686
- chartConfig: t,
687
- displayConfig: r = {},
688
- queryObject: n,
689
- height: s = "100%",
690
- colorPalette: a
691
- }) {
692
- const [l, c] = O(null), { labelMap: u } = W();
693
- try {
694
- const o = {
695
- showLegend: (r == null ? void 0 : r.showLegend) ?? !0,
696
- showTooltip: (r == null ? void 0 : r.showTooltip) ?? !0
697
- };
698
- if (!e || e.length === 0)
699
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-gray-500", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
700
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
701
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No data points to display in pie chart" })
702
- ] }) });
703
- let d, f, m, A = [];
704
- if (t != null && t.xAxis && (t != null && t.yAxis))
705
- f = t.xAxis[0], m = Array.isArray(t.yAxis) ? t.yAxis : [t.yAxis], A = t.series || [];
706
- else if (t != null && t.x && (t != null && t.y))
707
- f = t.x, m = Array.isArray(t.y) ? t.y : [t.y];
708
- else
709
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
710
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
711
- /* @__PURE__ */ i("div", { className: "text-xs", children: "chartConfig.x/y or chartConfig.xAxis/yAxis required for pie chart" })
712
- ] }) });
713
- if (!f || !m || m.length === 0)
714
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
715
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
716
- /* @__PURE__ */ i("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
717
- ] }) });
718
- if (A.length > 0) {
719
- const { data: N } = ee(
720
- e,
721
- f,
722
- m,
723
- n,
724
- A,
725
- u
726
- );
727
- if (d = [], N.length > 0) {
728
- const g = N[0];
729
- Object.keys(g).forEach((S) => {
730
- S !== "name" && typeof g[S] == "number" && d.push({
731
- name: String(S),
732
- value: g[S]
733
- });
734
- });
735
- }
736
- } else {
737
- const N = H(n, f);
738
- d = e.map((g) => {
739
- let S = R(g[f], N) || String(g[f]) || "Unknown";
740
- return typeof g[f] == "boolean" ? S = g[f] ? "Active" : "Inactive" : (S === "true" || S === "false") && (S = S === "true" ? "Active" : "Inactive"), {
741
- name: S,
742
- value: typeof g[m[0]] == "string" ? parseFloat(g[m[0]]) : g[m[0]] || 0
743
- };
744
- });
745
- }
746
- const x = d.length;
747
- return d = d.filter(
748
- (N) => N.value != null && !isNaN(N.value) && N.value !== 0 && N.value > 0
749
- ), d.length === 0 ? /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-gray-500", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
750
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
751
- /* @__PURE__ */ i("div", { className: "text-xs", children: x > 0 ? `Filtered out ${x} data points (zero or invalid values)` : "No data points to display in pie chart" })
752
- ] }) }) : /* @__PURE__ */ i(G, { height: s, children: /* @__PURE__ */ w(bt, { children: [
753
- /* @__PURE__ */ i(
754
- wt,
755
- {
756
- data: d,
757
- cx: "50%",
758
- cy: "50%",
759
- outerRadius: "70%",
760
- dataKey: "value",
761
- label: o.showLegend ? void 0 : ({ name: N, percent: g }) => `${N} ${(g * 100).toFixed(0)}%`,
762
- children: d.map((N, g) => /* @__PURE__ */ i(
763
- Le,
764
- {
765
- fill: (a == null ? void 0 : a.colors) && a.colors[g % a.colors.length] || L[g % L.length],
766
- fillOpacity: l ? l === d[g].name ? 1 : 0.3 : 1
767
- },
768
- `cell-${g}`
769
- ))
770
- }
771
- ),
772
- o.showTooltip && /* @__PURE__ */ i(V, {}),
773
- o.showLegend && /* @__PURE__ */ i(
774
- B,
775
- {
776
- wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
777
- iconType: "circle",
778
- iconSize: 8,
779
- layout: "horizontal",
780
- align: "center",
781
- verticalAlign: "bottom",
782
- onMouseEnter: (N) => c(String(N.value || "")),
783
- onMouseLeave: () => c(null)
784
- }
785
- )
786
- ] }) });
787
- } catch (o) {
788
- return /* @__PURE__ */ i("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
789
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Pie Chart Error" }),
790
- /* @__PURE__ */ i("div", { className: "text-xs mb-2", children: o instanceof Error ? o.message : "Unknown rendering error" }),
791
- /* @__PURE__ */ i("div", { className: "text-xs text-gray-600", children: "Check the data and configuration" })
792
- ] }) });
793
- }
794
- }
795
- function Xr({
796
- data: e,
797
- chartConfig: t,
798
- displayConfig: r = {},
799
- queryObject: n,
800
- height: s = "100%",
801
- colorPalette: a
802
- }) {
803
- const [l, c] = O(null), { getFieldLabel: u } = W();
804
- try {
805
- const o = {
806
- showLegend: (r == null ? void 0 : r.showLegend) ?? !0,
807
- showGrid: (r == null ? void 0 : r.showGrid) ?? !0,
808
- showTooltip: (r == null ? void 0 : r.showTooltip) ?? !0
809
- };
810
- if (!e || e.length === 0)
811
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-gray-500", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
812
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
813
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No data points to display in scatter chart" })
814
- ] }) });
815
- let d, f, m = [];
816
- if (t != null && t.xAxis && (t != null && t.yAxis))
817
- d = t.xAxis[0], f = Array.isArray(t.yAxis) ? t.yAxis[0] : t.yAxis, m = t.series || [];
818
- else if (t != null && t.x && (t != null && t.y))
819
- d = t.x, f = Array.isArray(t.y) ? t.y[0] : t.y;
820
- else
821
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
822
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
823
- /* @__PURE__ */ i("div", { className: "text-xs", children: "Invalid or missing chart axis configuration" })
824
- ] }) });
825
- if (!d || !f)
826
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
827
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
828
- /* @__PURE__ */ i("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
829
- ] }) });
830
- let A, x = {};
831
- if (m.length > 0) {
832
- const h = m[0];
833
- e.forEach((y) => {
834
- const p = String(y[h] || "Default");
835
- x[p] || (x[p] = []);
836
- const v = H(n, d), k = R(y[d], v) || y[d], $ = typeof y[f] == "string" ? parseFloat(y[f]) : y[f] || 0;
837
- x[p].push({
838
- x: typeof k == "string" ? parseFloat(k) || 0 : k,
839
- y: $,
840
- name: `${p} (${k}, ${$})`
841
- });
842
- });
843
- const b = Object.keys(x);
844
- A = x[b[0]] || [];
845
- } else {
846
- const h = H(n, d);
847
- A = e.map((b) => {
848
- const y = R(b[d], h) || b[d], p = typeof b[f] == "string" ? parseFloat(b[f]) : b[f] || 0;
849
- return {
850
- x: typeof y == "string" ? parseFloat(y) || 0 : y,
851
- y: p,
852
- name: `(${y}, ${p})`
853
- };
854
- });
855
- }
856
- if (!A || A.length === 0)
857
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-gray-500", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
858
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
859
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No valid data points for scatter chart after transformation" })
860
- ] }) });
861
- const N = Object.keys(x), g = N.length > 1, S = o.showLegend && g, T = {
862
- ...ge,
863
- left: 40
864
- // Increased from 20 to 40 for Y-axis label space
865
- };
866
- return /* @__PURE__ */ i(G, { height: s, children: /* @__PURE__ */ w(Nt, { data: A, margin: T, children: [
867
- o.showGrid && /* @__PURE__ */ i(ye, { strokeDasharray: "3 3" }),
868
- /* @__PURE__ */ i(
869
- pe,
870
- {
871
- type: "number",
872
- dataKey: "x",
873
- name: u(d),
874
- tick: { fontSize: 12 }
875
- }
876
- ),
877
- /* @__PURE__ */ i(
878
- ve,
879
- {
880
- type: "number",
881
- dataKey: "y",
882
- name: u(f),
883
- tick: { fontSize: 12 },
884
- label: { value: u(f), angle: -90, position: "left", style: { textAnchor: "middle", fontSize: "12px" } }
885
- }
886
- ),
887
- o.showTooltip && /* @__PURE__ */ i(V, {}),
888
- S && /* @__PURE__ */ i(
889
- B,
890
- {
891
- wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
892
- iconType: "circle",
893
- iconSize: 8,
894
- layout: "horizontal",
895
- align: "center",
896
- verticalAlign: "bottom",
897
- onMouseEnter: (h) => c(String(h.dataKey || "")),
898
- onMouseLeave: () => c(null)
899
- }
900
- ),
901
- g ? (
902
- // Multiple series
903
- N.map((h, b) => /* @__PURE__ */ i(
904
- He,
905
- {
906
- name: h,
907
- data: x[h],
908
- fill: (a == null ? void 0 : a.colors) && a.colors[b % a.colors.length] || L[b % L.length],
909
- fillOpacity: l ? l === h ? 1 : 0.3 : 1
910
- },
911
- h
912
- ))
913
- ) : (
914
- // Single series
915
- /* @__PURE__ */ i(
916
- He,
917
- {
918
- name: "Data",
919
- data: A,
920
- fill: (a == null ? void 0 : a.colors) && a.colors[0] || L[0]
921
- }
922
- )
923
- )
924
- ] }) });
925
- } catch (o) {
926
- return /* @__PURE__ */ i("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
927
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Scatter Chart Error" }),
928
- /* @__PURE__ */ i("div", { className: "text-xs mb-2", children: o instanceof Error ? o.message : "Unknown rendering error" }),
929
- /* @__PURE__ */ i("div", { className: "text-xs text-gray-600", children: "Check the data and configuration" })
930
- ] }) });
931
- }
932
- }
933
- function Qr({
934
- data: e,
935
- chartConfig: t,
936
- displayConfig: r = {},
937
- queryObject: n,
938
- height: s = "100%",
939
- colorPalette: a
940
- }) {
941
- const [l, c] = O(null);
942
- try {
943
- const u = {
944
- showLegend: (r == null ? void 0 : r.showLegend) ?? !0,
945
- showTooltip: (r == null ? void 0 : r.showTooltip) ?? !0,
946
- showGrid: (r == null ? void 0 : r.showGrid) ?? !0
947
- };
948
- if (!e || e.length === 0)
949
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-gray-500", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
950
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
951
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No data points to display in radar chart" })
952
- ] }) });
953
- let o, d = [];
954
- if (t != null && t.xAxis && (t != null && t.yAxis)) {
955
- const f = t.xAxis[0], m = Array.isArray(t.yAxis) ? t.yAxis : [t.yAxis], A = t.series || [], { data: x, seriesKeys: N } = ee(
956
- e,
957
- f,
958
- m,
959
- n,
960
- A
961
- );
962
- o = x, d = N;
963
- } else {
964
- const f = e[0], m = Object.keys(f), A = m.find(
965
- (N) => typeof f[N] == "string" || N.toLowerCase().includes("subject") || N.toLowerCase().includes("name") || N.toLowerCase().includes("category")
966
- ) || m[0], x = m.filter(
967
- (N) => typeof f[N] == "number" && N !== A
968
- );
969
- if (x.length === 0)
970
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
971
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
972
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No numeric fields found for radar chart values" })
973
- ] }) });
974
- if (A) {
975
- const N = H(n, A);
976
- o = e.map((g) => {
977
- const S = {
978
- name: R(g[A], N) || String(g[A]) || "Unknown"
979
- };
980
- return x.forEach((T) => {
981
- const h = T.split(".").pop() || T;
982
- S[h] = typeof g[T] == "string" ? parseFloat(g[T]) : g[T] || 0;
983
- }), S;
984
- }), d = x.map((g) => g.split(".").pop() || g);
985
- } else
986
- o = e.map((N) => ({
987
- name: String(N[m[0]] || "Unknown"),
988
- value: typeof N[x[0]] == "string" ? parseFloat(N[x[0]]) : N[x[0]] || 0
989
- })), d = ["value"];
990
- }
991
- return !o || o.length === 0 ? /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-gray-500", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
992
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
993
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No valid data points for radar chart after transformation" })
994
- ] }) }) : /* @__PURE__ */ i(G, { height: s, children: /* @__PURE__ */ w(At, { data: o, margin: { top: 20, right: 80, bottom: 20, left: 80 }, children: [
995
- u.showGrid && /* @__PURE__ */ i(St, {}),
996
- /* @__PURE__ */ i(
997
- kt,
998
- {
999
- dataKey: "name",
1000
- tick: { fontSize: 12 },
1001
- className: "text-gray-600"
1002
- }
1003
- ),
1004
- /* @__PURE__ */ i(
1005
- Mt,
1006
- {
1007
- tick: { fontSize: 10 },
1008
- className: "text-gray-600"
1009
- }
1010
- ),
1011
- u.showTooltip && /* @__PURE__ */ i(V, {}),
1012
- u.showLegend && d.length > 1 && /* @__PURE__ */ i(
1013
- B,
1014
- {
1015
- wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
1016
- iconType: "rect",
1017
- iconSize: 8,
1018
- layout: "horizontal",
1019
- align: "center",
1020
- verticalAlign: "bottom",
1021
- onMouseEnter: (f) => c(String(f.dataKey || "")),
1022
- onMouseLeave: () => c(null)
1023
- }
1024
- ),
1025
- d.map((f, m) => /* @__PURE__ */ i(
1026
- $t,
1027
- {
1028
- name: f,
1029
- dataKey: f,
1030
- stroke: (a == null ? void 0 : a.colors) && a.colors[m % a.colors.length] || L[m % L.length],
1031
- fill: (a == null ? void 0 : a.colors) && a.colors[m % a.colors.length] || L[m % L.length],
1032
- fillOpacity: l ? l === f ? 0.6 : 0.1 : 0.3,
1033
- strokeOpacity: l ? l === f ? 1 : 0.3 : 1,
1034
- strokeWidth: 2
1035
- },
1036
- f
1037
- ))
1038
- ] }) });
1039
- } catch (u) {
1040
- return /* @__PURE__ */ i("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
1041
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Radar Chart Error" }),
1042
- /* @__PURE__ */ i("div", { className: "text-xs mb-2", children: u instanceof Error ? u.message : "Unknown rendering error" }),
1043
- /* @__PURE__ */ i("div", { className: "text-xs text-gray-600", children: "Check the data and configuration" })
1044
- ] }) });
1045
- }
1046
- }
1047
- function Zr({
1048
- data: e,
1049
- chartConfig: t,
1050
- displayConfig: r = {},
1051
- queryObject: n,
1052
- height: s = "100%",
1053
- colorPalette: a
1054
- }) {
1055
- const [l, c] = O(null);
1056
- try {
1057
- const u = {
1058
- showLegend: (r == null ? void 0 : r.showLegend) ?? !0,
1059
- showTooltip: (r == null ? void 0 : r.showTooltip) ?? !0
1060
- };
1061
- if (!e || e.length === 0)
1062
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-gray-500", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
1063
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
1064
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No data points to display in radial bar chart" })
1065
- ] }) });
1066
- let o;
1067
- if (t != null && t.xAxis && (t != null && t.yAxis)) {
1068
- const d = t.xAxis[0], f = Array.isArray(t.yAxis) ? t.yAxis[0] : t.yAxis, m = H(n, d);
1069
- o = e.map((A, x) => ({
1070
- name: R(A[d], m) || String(A[d]) || "Unknown",
1071
- value: typeof A[f] == "string" ? parseFloat(A[f]) : A[f] || 0,
1072
- fill: (a == null ? void 0 : a.colors) && a.colors[x % a.colors.length] || L[x % L.length]
1073
- }));
1074
- } else {
1075
- const d = e[0], f = Object.keys(d), m = f.find(
1076
- (x) => typeof d[x] == "string" || x.toLowerCase().includes("name") || x.toLowerCase().includes("label") || x.toLowerCase().includes("category")
1077
- ) || f[0], A = f.find(
1078
- (x) => typeof d[x] == "number" && x !== m
1079
- ) || f[1];
1080
- if (!A)
1081
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
1082
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
1083
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No numeric field found for radial bar chart values" })
1084
- ] }) });
1085
- o = e.map((x, N) => {
1086
- let g = x[m];
1087
- return typeof g == "boolean" ? g = g ? "Active" : "Inactive" : g === "true" || g === "false" ? g = g === "true" ? "Active" : "Inactive" : g = String(g), {
1088
- name: g,
1089
- value: typeof x[A] == "string" ? parseFloat(x[A]) : x[A] || 0,
1090
- fill: (a == null ? void 0 : a.colors) && a.colors[N % a.colors.length] || L[N % L.length]
1091
- };
1092
- });
1093
- }
1094
- return o = o.filter((d) => d.value != null && d.value !== 0), o.length === 0 ? /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-gray-500", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
1095
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
1096
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No valid data points for radial bar chart after transformation" })
1097
- ] }) }) : /* @__PURE__ */ i(G, { height: s, children: /* @__PURE__ */ w(
1098
- Lt,
1099
- {
1100
- data: o,
1101
- innerRadius: "10%",
1102
- outerRadius: "80%",
1103
- margin: { top: 20, right: 30, bottom: 20, left: 30 },
1104
- children: [
1105
- u.showTooltip && /* @__PURE__ */ i(V, {}),
1106
- u.showLegend && /* @__PURE__ */ i(
1107
- B,
1108
- {
1109
- wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
1110
- iconType: "circle",
1111
- iconSize: 8,
1112
- layout: "horizontal",
1113
- align: "center",
1114
- verticalAlign: "bottom",
1115
- onMouseEnter: (d) => c(String(d.value || "")),
1116
- onMouseLeave: () => c(null)
1117
- }
1118
- ),
1119
- /* @__PURE__ */ i(
1120
- Tt,
1121
- {
1122
- dataKey: "value",
1123
- cornerRadius: 4,
1124
- label: { position: "insideStart", fill: "#fff", fontSize: 12 },
1125
- children: o.map((d, f) => /* @__PURE__ */ i(
1126
- Le,
1127
- {
1128
- fill: d.fill,
1129
- fillOpacity: l ? l === d.name ? 1 : 0.3 : 1
1130
- },
1131
- `cell-${f}`
1132
- ))
1133
- }
1134
- )
1135
- ]
1136
- }
1137
- ) });
1138
- } catch (u) {
1139
- return /* @__PURE__ */ i("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
1140
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Radial Bar Chart Error" }),
1141
- /* @__PURE__ */ i("div", { className: "text-xs mb-2", children: u instanceof Error ? u.message : "Unknown rendering error" }),
1142
- /* @__PURE__ */ i("div", { className: "text-xs text-gray-600", children: "Check the data and configuration" })
1143
- ] }) });
1144
- }
1145
- }
1146
- function ce(e, t) {
1147
- return e == null || t == null ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
1148
- }
1149
- function Et(e, t) {
1150
- return e == null || t == null ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN;
1151
- }
1152
- function it(e) {
1153
- let t, r, n;
1154
- e.length !== 2 ? (t = ce, r = (c, u) => ce(e(c), u), n = (c, u) => e(c) - u) : (t = e === ce || e === Et ? e : Dt, r = e, n = e);
1155
- function s(c, u, o = 0, d = c.length) {
1156
- if (o < d) {
1157
- if (t(u, u) !== 0) return d;
1158
- do {
1159
- const f = o + d >>> 1;
1160
- r(c[f], u) < 0 ? o = f + 1 : d = f;
1161
- } while (o < d);
1162
- }
1163
- return o;
1164
- }
1165
- function a(c, u, o = 0, d = c.length) {
1166
- if (o < d) {
1167
- if (t(u, u) !== 0) return d;
1168
- do {
1169
- const f = o + d >>> 1;
1170
- r(c[f], u) <= 0 ? o = f + 1 : d = f;
1171
- } while (o < d);
1172
- }
1173
- return o;
1174
- }
1175
- function l(c, u, o = 0, d = c.length) {
1176
- const f = s(c, u, o, d - 1);
1177
- return f > o && n(c[f - 1], u) > -n(c[f], u) ? f - 1 : f;
1178
- }
1179
- return { left: s, center: l, right: a };
1180
- }
1181
- function Dt() {
1182
- return 0;
1183
- }
1184
- function Rt(e) {
1185
- return e === null ? NaN : +e;
1186
- }
1187
- const It = it(ce), at = It.right;
1188
- it(Rt).center;
1189
- class Ge extends Map {
1190
- constructor(t, r = Ot) {
1191
- if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: r } }), t != null) for (const [n, s] of t) this.set(n, s);
1192
- }
1193
- get(t) {
1194
- return super.get(Ve(this, t));
1195
- }
1196
- has(t) {
1197
- return super.has(Ve(this, t));
1198
- }
1199
- set(t, r) {
1200
- return super.set(_t(this, t), r);
1201
- }
1202
- delete(t) {
1203
- return super.delete(Ht(this, t));
1204
- }
1205
- }
1206
- function Ve({ _intern: e, _key: t }, r) {
1207
- const n = t(r);
1208
- return e.has(n) ? e.get(n) : r;
1209
- }
1210
- function _t({ _intern: e, _key: t }, r) {
1211
- const n = t(r);
1212
- return e.has(n) ? e.get(n) : (e.set(n, r), r);
1213
- }
1214
- function Ht({ _intern: e, _key: t }, r) {
1215
- const n = t(r);
1216
- return e.has(n) && (r = e.get(n), e.delete(n)), r;
1217
- }
1218
- function Ot(e) {
1219
- return e !== null && typeof e == "object" ? e.valueOf() : e;
1220
- }
1221
- const Gt = Math.sqrt(50), Vt = Math.sqrt(10), Ut = Math.sqrt(2);
1222
- function ue(e, t, r) {
1223
- const n = (t - e) / Math.max(0, r), s = Math.floor(Math.log10(n)), a = n / Math.pow(10, s), l = a >= Gt ? 10 : a >= Vt ? 5 : a >= Ut ? 2 : 1;
1224
- let c, u, o;
1225
- return s < 0 ? (o = Math.pow(10, -s) / l, c = Math.round(e * o), u = Math.round(t * o), c / o < e && ++c, u / o > t && --u, o = -o) : (o = Math.pow(10, s) * l, c = Math.round(e / o), u = Math.round(t / o), c * o < e && ++c, u * o > t && --u), u < c && 0.5 <= r && r < 2 ? ue(e, t, r * 2) : [c, u, o];
1226
- }
1227
- function qt(e, t, r) {
1228
- if (t = +t, e = +e, r = +r, !(r > 0)) return [];
1229
- if (e === t) return [e];
1230
- const n = t < e, [s, a, l] = n ? ue(t, e, r) : ue(e, t, r);
1231
- if (!(a >= s)) return [];
1232
- const c = a - s + 1, u = new Array(c);
1233
- if (n)
1234
- if (l < 0) for (let o = 0; o < c; ++o) u[o] = (a - o) / -l;
1235
- else for (let o = 0; o < c; ++o) u[o] = (a - o) * l;
1236
- else if (l < 0) for (let o = 0; o < c; ++o) u[o] = (s + o) / -l;
1237
- else for (let o = 0; o < c; ++o) u[o] = (s + o) * l;
1238
- return u;
1239
- }
1240
- function Ae(e, t, r) {
1241
- return t = +t, e = +e, r = +r, ue(e, t, r)[2];
1242
- }
1243
- function Kt(e, t, r) {
1244
- t = +t, e = +e, r = +r;
1245
- const n = t < e, s = n ? Ae(t, e, r) : Ae(e, t, r);
1246
- return (n ? -1 : 1) * (s < 0 ? 1 / -s : s);
1247
- }
1248
- function je(e, t, r) {
1249
- e.prototype = t.prototype = r, r.constructor = e;
1250
- }
1251
- function lt(e, t) {
1252
- var r = Object.create(e.prototype);
1253
- for (var n in t) r[n] = t[n];
1254
- return r;
1255
- }
1256
- function te() {
1257
- }
1258
- var J = 0.7, de = 1 / J, Q = "\\s*([+-]?\\d+)\\s*", P = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", I = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", Bt = /^#([0-9a-f]{3,8})$/, Wt = new RegExp(`^rgb\\(${Q},${Q},${Q}\\)$`), Yt = new RegExp(`^rgb\\(${I},${I},${I}\\)$`), Xt = new RegExp(`^rgba\\(${Q},${Q},${Q},${P}\\)$`), Qt = new RegExp(`^rgba\\(${I},${I},${I},${P}\\)$`), Zt = new RegExp(`^hsl\\(${P},${I},${I}\\)$`), Jt = new RegExp(`^hsla\\(${P},${I},${I},${P}\\)$`), Ue = {
1259
- aliceblue: 15792383,
1260
- antiquewhite: 16444375,
1261
- aqua: 65535,
1262
- aquamarine: 8388564,
1263
- azure: 15794175,
1264
- beige: 16119260,
1265
- bisque: 16770244,
1266
- black: 0,
1267
- blanchedalmond: 16772045,
1268
- blue: 255,
1269
- blueviolet: 9055202,
1270
- brown: 10824234,
1271
- burlywood: 14596231,
1272
- cadetblue: 6266528,
1273
- chartreuse: 8388352,
1274
- chocolate: 13789470,
1275
- coral: 16744272,
1276
- cornflowerblue: 6591981,
1277
- cornsilk: 16775388,
1278
- crimson: 14423100,
1279
- cyan: 65535,
1280
- darkblue: 139,
1281
- darkcyan: 35723,
1282
- darkgoldenrod: 12092939,
1283
- darkgray: 11119017,
1284
- darkgreen: 25600,
1285
- darkgrey: 11119017,
1286
- darkkhaki: 12433259,
1287
- darkmagenta: 9109643,
1288
- darkolivegreen: 5597999,
1289
- darkorange: 16747520,
1290
- darkorchid: 10040012,
1291
- darkred: 9109504,
1292
- darksalmon: 15308410,
1293
- darkseagreen: 9419919,
1294
- darkslateblue: 4734347,
1295
- darkslategray: 3100495,
1296
- darkslategrey: 3100495,
1297
- darkturquoise: 52945,
1298
- darkviolet: 9699539,
1299
- deeppink: 16716947,
1300
- deepskyblue: 49151,
1301
- dimgray: 6908265,
1302
- dimgrey: 6908265,
1303
- dodgerblue: 2003199,
1304
- firebrick: 11674146,
1305
- floralwhite: 16775920,
1306
- forestgreen: 2263842,
1307
- fuchsia: 16711935,
1308
- gainsboro: 14474460,
1309
- ghostwhite: 16316671,
1310
- gold: 16766720,
1311
- goldenrod: 14329120,
1312
- gray: 8421504,
1313
- green: 32768,
1314
- greenyellow: 11403055,
1315
- grey: 8421504,
1316
- honeydew: 15794160,
1317
- hotpink: 16738740,
1318
- indianred: 13458524,
1319
- indigo: 4915330,
1320
- ivory: 16777200,
1321
- khaki: 15787660,
1322
- lavender: 15132410,
1323
- lavenderblush: 16773365,
1324
- lawngreen: 8190976,
1325
- lemonchiffon: 16775885,
1326
- lightblue: 11393254,
1327
- lightcoral: 15761536,
1328
- lightcyan: 14745599,
1329
- lightgoldenrodyellow: 16448210,
1330
- lightgray: 13882323,
1331
- lightgreen: 9498256,
1332
- lightgrey: 13882323,
1333
- lightpink: 16758465,
1334
- lightsalmon: 16752762,
1335
- lightseagreen: 2142890,
1336
- lightskyblue: 8900346,
1337
- lightslategray: 7833753,
1338
- lightslategrey: 7833753,
1339
- lightsteelblue: 11584734,
1340
- lightyellow: 16777184,
1341
- lime: 65280,
1342
- limegreen: 3329330,
1343
- linen: 16445670,
1344
- magenta: 16711935,
1345
- maroon: 8388608,
1346
- mediumaquamarine: 6737322,
1347
- mediumblue: 205,
1348
- mediumorchid: 12211667,
1349
- mediumpurple: 9662683,
1350
- mediumseagreen: 3978097,
1351
- mediumslateblue: 8087790,
1352
- mediumspringgreen: 64154,
1353
- mediumturquoise: 4772300,
1354
- mediumvioletred: 13047173,
1355
- midnightblue: 1644912,
1356
- mintcream: 16121850,
1357
- mistyrose: 16770273,
1358
- moccasin: 16770229,
1359
- navajowhite: 16768685,
1360
- navy: 128,
1361
- oldlace: 16643558,
1362
- olive: 8421376,
1363
- olivedrab: 7048739,
1364
- orange: 16753920,
1365
- orangered: 16729344,
1366
- orchid: 14315734,
1367
- palegoldenrod: 15657130,
1368
- palegreen: 10025880,
1369
- paleturquoise: 11529966,
1370
- palevioletred: 14381203,
1371
- papayawhip: 16773077,
1372
- peachpuff: 16767673,
1373
- peru: 13468991,
1374
- pink: 16761035,
1375
- plum: 14524637,
1376
- powderblue: 11591910,
1377
- purple: 8388736,
1378
- rebeccapurple: 6697881,
1379
- red: 16711680,
1380
- rosybrown: 12357519,
1381
- royalblue: 4286945,
1382
- saddlebrown: 9127187,
1383
- salmon: 16416882,
1384
- sandybrown: 16032864,
1385
- seagreen: 3050327,
1386
- seashell: 16774638,
1387
- sienna: 10506797,
1388
- silver: 12632256,
1389
- skyblue: 8900331,
1390
- slateblue: 6970061,
1391
- slategray: 7372944,
1392
- slategrey: 7372944,
1393
- snow: 16775930,
1394
- springgreen: 65407,
1395
- steelblue: 4620980,
1396
- tan: 13808780,
1397
- teal: 32896,
1398
- thistle: 14204888,
1399
- tomato: 16737095,
1400
- turquoise: 4251856,
1401
- violet: 15631086,
1402
- wheat: 16113331,
1403
- white: 16777215,
1404
- whitesmoke: 16119285,
1405
- yellow: 16776960,
1406
- yellowgreen: 10145074
1407
- };
1408
- je(te, C, {
1409
- copy(e) {
1410
- return Object.assign(new this.constructor(), this, e);
1411
- },
1412
- displayable() {
1413
- return this.rgb().displayable();
1414
- },
1415
- hex: qe,
1416
- // Deprecated! Use color.formatHex.
1417
- formatHex: qe,
1418
- formatHex8: Pt,
1419
- formatHsl: Ct,
1420
- formatRgb: Ke,
1421
- toString: Ke
1422
- });
1423
- function qe() {
1424
- return this.rgb().formatHex();
1425
- }
1426
- function Pt() {
1427
- return this.rgb().formatHex8();
1428
- }
1429
- function Ct() {
1430
- return ot(this).formatHsl();
1431
- }
1432
- function Ke() {
1433
- return this.rgb().formatRgb();
1434
- }
1435
- function C(e) {
1436
- var t, r;
1437
- return e = (e + "").trim().toLowerCase(), (t = Bt.exec(e)) ? (r = t[1].length, t = parseInt(t[1], 16), r === 6 ? Be(t) : r === 3 ? new j(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, (t & 15) << 4 | t & 15, 1) : r === 8 ? ae(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (t & 255) / 255) : r === 4 ? ae(t >> 12 & 15 | t >> 8 & 240, t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, ((t & 15) << 4 | t & 15) / 255) : null) : (t = Wt.exec(e)) ? new j(t[1], t[2], t[3], 1) : (t = Yt.exec(e)) ? new j(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, 1) : (t = Xt.exec(e)) ? ae(t[1], t[2], t[3], t[4]) : (t = Qt.exec(e)) ? ae(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, t[4]) : (t = Zt.exec(e)) ? Xe(t[1], t[2] / 100, t[3] / 100, 1) : (t = Jt.exec(e)) ? Xe(t[1], t[2] / 100, t[3] / 100, t[4]) : Ue.hasOwnProperty(e) ? Be(Ue[e]) : e === "transparent" ? new j(NaN, NaN, NaN, 0) : null;
1438
- }
1439
- function Be(e) {
1440
- return new j(e >> 16 & 255, e >> 8 & 255, e & 255, 1);
1441
- }
1442
- function ae(e, t, r, n) {
1443
- return n <= 0 && (e = t = r = NaN), new j(e, t, r, n);
1444
- }
1445
- function er(e) {
1446
- return e instanceof te || (e = C(e)), e ? (e = e.rgb(), new j(e.r, e.g, e.b, e.opacity)) : new j();
1447
- }
1448
- function Se(e, t, r, n) {
1449
- return arguments.length === 1 ? er(e) : new j(e, t, r, n ?? 1);
1450
- }
1451
- function j(e, t, r, n) {
1452
- this.r = +e, this.g = +t, this.b = +r, this.opacity = +n;
1453
- }
1454
- je(j, Se, lt(te, {
1455
- brighter(e) {
1456
- return e = e == null ? de : Math.pow(de, e), new j(this.r * e, this.g * e, this.b * e, this.opacity);
1457
- },
1458
- darker(e) {
1459
- return e = e == null ? J : Math.pow(J, e), new j(this.r * e, this.g * e, this.b * e, this.opacity);
1460
- },
1461
- rgb() {
1462
- return this;
1463
- },
1464
- clamp() {
1465
- return new j(K(this.r), K(this.g), K(this.b), fe(this.opacity));
1466
- },
1467
- displayable() {
1468
- return -0.5 <= this.r && this.r < 255.5 && -0.5 <= this.g && this.g < 255.5 && -0.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1;
1469
- },
1470
- hex: We,
1471
- // Deprecated! Use color.formatHex.
1472
- formatHex: We,
1473
- formatHex8: tr,
1474
- formatRgb: Ye,
1475
- toString: Ye
1476
- }));
1477
- function We() {
1478
- return `#${U(this.r)}${U(this.g)}${U(this.b)}`;
1479
- }
1480
- function tr() {
1481
- return `#${U(this.r)}${U(this.g)}${U(this.b)}${U((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
1482
- }
1483
- function Ye() {
1484
- const e = fe(this.opacity);
1485
- return `${e === 1 ? "rgb(" : "rgba("}${K(this.r)}, ${K(this.g)}, ${K(this.b)}${e === 1 ? ")" : `, ${e})`}`;
1486
- }
1487
- function fe(e) {
1488
- return isNaN(e) ? 1 : Math.max(0, Math.min(1, e));
1489
- }
1490
- function K(e) {
1491
- return Math.max(0, Math.min(255, Math.round(e) || 0));
1492
- }
1493
- function U(e) {
1494
- return e = K(e), (e < 16 ? "0" : "") + e.toString(16);
1495
- }
1496
- function Xe(e, t, r, n) {
1497
- return n <= 0 ? e = t = r = NaN : r <= 0 || r >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new D(e, t, r, n);
1498
- }
1499
- function ot(e) {
1500
- if (e instanceof D) return new D(e.h, e.s, e.l, e.opacity);
1501
- if (e instanceof te || (e = C(e)), !e) return new D();
1502
- if (e instanceof D) return e;
1503
- e = e.rgb();
1504
- var t = e.r / 255, r = e.g / 255, n = e.b / 255, s = Math.min(t, r, n), a = Math.max(t, r, n), l = NaN, c = a - s, u = (a + s) / 2;
1505
- return c ? (t === a ? l = (r - n) / c + (r < n) * 6 : r === a ? l = (n - t) / c + 2 : l = (t - r) / c + 4, c /= u < 0.5 ? a + s : 2 - a - s, l *= 60) : c = u > 0 && u < 1 ? 0 : l, new D(l, c, u, e.opacity);
1506
- }
1507
- function rr(e, t, r, n) {
1508
- return arguments.length === 1 ? ot(e) : new D(e, t, r, n ?? 1);
1509
- }
1510
- function D(e, t, r, n) {
1511
- this.h = +e, this.s = +t, this.l = +r, this.opacity = +n;
1512
- }
1513
- je(D, rr, lt(te, {
1514
- brighter(e) {
1515
- return e = e == null ? de : Math.pow(de, e), new D(this.h, this.s, this.l * e, this.opacity);
1516
- },
1517
- darker(e) {
1518
- return e = e == null ? J : Math.pow(J, e), new D(this.h, this.s, this.l * e, this.opacity);
1519
- },
1520
- rgb() {
1521
- var e = this.h % 360 + (this.h < 0) * 360, t = isNaN(e) || isNaN(this.s) ? 0 : this.s, r = this.l, n = r + (r < 0.5 ? r : 1 - r) * t, s = 2 * r - n;
1522
- return new j(
1523
- be(e >= 240 ? e - 240 : e + 120, s, n),
1524
- be(e, s, n),
1525
- be(e < 120 ? e + 240 : e - 120, s, n),
1526
- this.opacity
1527
- );
1528
- },
1529
- clamp() {
1530
- return new D(Qe(this.h), le(this.s), le(this.l), fe(this.opacity));
1531
- },
1532
- displayable() {
1533
- return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1;
1534
- },
1535
- formatHsl() {
1536
- const e = fe(this.opacity);
1537
- return `${e === 1 ? "hsl(" : "hsla("}${Qe(this.h)}, ${le(this.s) * 100}%, ${le(this.l) * 100}%${e === 1 ? ")" : `, ${e})`}`;
1538
- }
1539
- }));
1540
- function Qe(e) {
1541
- return e = (e || 0) % 360, e < 0 ? e + 360 : e;
1542
- }
1543
- function le(e) {
1544
- return Math.max(0, Math.min(1, e || 0));
1545
- }
1546
- function be(e, t, r) {
1547
- return (e < 60 ? t + (r - t) * e / 60 : e < 180 ? r : e < 240 ? t + (r - t) * (240 - e) / 60 : t) * 255;
1548
- }
1549
- const ze = (e) => () => e;
1550
- function nr(e, t) {
1551
- return function(r) {
1552
- return e + r * t;
1553
- };
1554
- }
1555
- function sr(e, t, r) {
1556
- return e = Math.pow(e, r), t = Math.pow(t, r) - e, r = 1 / r, function(n) {
1557
- return Math.pow(e + n * t, r);
1558
- };
1559
- }
1560
- function ir(e) {
1561
- return (e = +e) == 1 ? ct : function(t, r) {
1562
- return r - t ? sr(t, r, e) : ze(isNaN(t) ? r : t);
1563
- };
1564
- }
1565
- function ct(e, t) {
1566
- var r = t - e;
1567
- return r ? nr(e, r) : ze(isNaN(e) ? t : e);
1568
- }
1569
- const Ze = function e(t) {
1570
- var r = ir(t);
1571
- function n(s, a) {
1572
- var l = r((s = Se(s)).r, (a = Se(a)).r), c = r(s.g, a.g), u = r(s.b, a.b), o = ct(s.opacity, a.opacity);
1573
- return function(d) {
1574
- return s.r = l(d), s.g = c(d), s.b = u(d), s.opacity = o(d), s + "";
1575
- };
1576
- }
1577
- return n.gamma = e, n;
1578
- }(1);
1579
- function ar(e, t) {
1580
- t || (t = []);
1581
- var r = e ? Math.min(t.length, e.length) : 0, n = t.slice(), s;
1582
- return function(a) {
1583
- for (s = 0; s < r; ++s) n[s] = e[s] * (1 - a) + t[s] * a;
1584
- return n;
1585
- };
1586
- }
1587
- function lr(e) {
1588
- return ArrayBuffer.isView(e) && !(e instanceof DataView);
1589
- }
1590
- function or(e, t) {
1591
- var r = t ? t.length : 0, n = e ? Math.min(r, e.length) : 0, s = new Array(n), a = new Array(r), l;
1592
- for (l = 0; l < n; ++l) s[l] = Ee(e[l], t[l]);
1593
- for (; l < r; ++l) a[l] = t[l];
1594
- return function(c) {
1595
- for (l = 0; l < n; ++l) a[l] = s[l](c);
1596
- return a;
1597
- };
1598
- }
1599
- function cr(e, t) {
1600
- var r = /* @__PURE__ */ new Date();
1601
- return e = +e, t = +t, function(n) {
1602
- return r.setTime(e * (1 - n) + t * n), r;
1603
- };
1604
- }
1605
- function me(e, t) {
1606
- return e = +e, t = +t, function(r) {
1607
- return e * (1 - r) + t * r;
1608
- };
1609
- }
1610
- function ur(e, t) {
1611
- var r = {}, n = {}, s;
1612
- (e === null || typeof e != "object") && (e = {}), (t === null || typeof t != "object") && (t = {});
1613
- for (s in t)
1614
- s in e ? r[s] = Ee(e[s], t[s]) : n[s] = t[s];
1615
- return function(a) {
1616
- for (s in r) n[s] = r[s](a);
1617
- return n;
1618
- };
1619
- }
1620
- var ke = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, we = new RegExp(ke.source, "g");
1621
- function dr(e) {
1622
- return function() {
1623
- return e;
1624
- };
1625
- }
1626
- function fr(e) {
1627
- return function(t) {
1628
- return e(t) + "";
1629
- };
1630
- }
1631
- function mr(e, t) {
1632
- var r = ke.lastIndex = we.lastIndex = 0, n, s, a, l = -1, c = [], u = [];
1633
- for (e = e + "", t = t + ""; (n = ke.exec(e)) && (s = we.exec(t)); )
1634
- (a = s.index) > r && (a = t.slice(r, a), c[l] ? c[l] += a : c[++l] = a), (n = n[0]) === (s = s[0]) ? c[l] ? c[l] += s : c[++l] = s : (c[++l] = null, u.push({ i: l, x: me(n, s) })), r = we.lastIndex;
1635
- return r < t.length && (a = t.slice(r), c[l] ? c[l] += a : c[++l] = a), c.length < 2 ? u[0] ? fr(u[0].x) : dr(t) : (t = u.length, function(o) {
1636
- for (var d = 0, f; d < t; ++d) c[(f = u[d]).i] = f.x(o);
1637
- return c.join("");
1638
- });
1639
- }
1640
- function Ee(e, t) {
1641
- var r = typeof t, n;
1642
- return t == null || r === "boolean" ? ze(t) : (r === "number" ? me : r === "string" ? (n = C(t)) ? (t = n, Ze) : mr : t instanceof C ? Ze : t instanceof Date ? cr : lr(t) ? ar : Array.isArray(t) ? or : typeof t.valueOf != "function" && typeof t.toString != "function" || isNaN(t) ? ur : me)(e, t);
1643
- }
1644
- function xr(e, t) {
1645
- return e = +e, t = +t, function(r) {
1646
- return Math.round(e * (1 - r) + t * r);
1647
- };
1648
- }
1649
- function hr(e) {
1650
- return Math.abs(e = Math.round(e)) >= 1e21 ? e.toLocaleString("en").replace(/,/g, "") : e.toString(10);
1651
- }
1652
- function xe(e, t) {
1653
- if ((r = (e = t ? e.toExponential(t - 1) : e.toExponential()).indexOf("e")) < 0) return null;
1654
- var r, n = e.slice(0, r);
1655
- return [
1656
- n.length > 1 ? n[0] + n.slice(2) : n,
1657
- +e.slice(r + 1)
1658
- ];
1659
- }
1660
- function Z(e) {
1661
- return e = xe(Math.abs(e)), e ? e[1] : NaN;
1662
- }
1663
- function yr(e, t) {
1664
- return function(r, n) {
1665
- for (var s = r.length, a = [], l = 0, c = e[0], u = 0; s > 0 && c > 0 && (u + c + 1 > n && (c = Math.max(1, n - u)), a.push(r.substring(s -= c, s + c)), !((u += c + 1) > n)); )
1666
- c = e[l = (l + 1) % e.length];
1667
- return a.reverse().join(t);
1668
- };
1669
- }
1670
- function pr(e) {
1671
- return function(t) {
1672
- return t.replace(/[0-9]/g, function(r) {
1673
- return e[+r];
1674
- });
1675
- };
1676
- }
1677
- var vr = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
1678
- function he(e) {
1679
- if (!(t = vr.exec(e))) throw new Error("invalid format: " + e);
1680
- var t;
1681
- return new De({
1682
- fill: t[1],
1683
- align: t[2],
1684
- sign: t[3],
1685
- symbol: t[4],
1686
- zero: t[5],
1687
- width: t[6],
1688
- comma: t[7],
1689
- precision: t[8] && t[8].slice(1),
1690
- trim: t[9],
1691
- type: t[10]
1692
- });
1693
- }
1694
- he.prototype = De.prototype;
1695
- function De(e) {
1696
- this.fill = e.fill === void 0 ? " " : e.fill + "", this.align = e.align === void 0 ? ">" : e.align + "", this.sign = e.sign === void 0 ? "-" : e.sign + "", this.symbol = e.symbol === void 0 ? "" : e.symbol + "", this.zero = !!e.zero, this.width = e.width === void 0 ? void 0 : +e.width, this.comma = !!e.comma, this.precision = e.precision === void 0 ? void 0 : +e.precision, this.trim = !!e.trim, this.type = e.type === void 0 ? "" : e.type + "";
1697
- }
1698
- De.prototype.toString = function() {
1699
- return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (this.width === void 0 ? "" : Math.max(1, this.width | 0)) + (this.comma ? "," : "") + (this.precision === void 0 ? "" : "." + Math.max(0, this.precision | 0)) + (this.trim ? "~" : "") + this.type;
1700
- };
1701
- function gr(e) {
1702
- e: for (var t = e.length, r = 1, n = -1, s; r < t; ++r)
1703
- switch (e[r]) {
1704
- case ".":
1705
- n = s = r;
1706
- break;
1707
- case "0":
1708
- n === 0 && (n = r), s = r;
1709
- break;
1710
- default:
1711
- if (!+e[r]) break e;
1712
- n > 0 && (n = 0);
1713
- break;
1714
- }
1715
- return n > 0 ? e.slice(0, n) + e.slice(s + 1) : e;
1716
- }
1717
- var ut;
1718
- function br(e, t) {
1719
- var r = xe(e, t);
1720
- if (!r) return e + "";
1721
- var n = r[0], s = r[1], a = s - (ut = Math.max(-8, Math.min(8, Math.floor(s / 3))) * 3) + 1, l = n.length;
1722
- return a === l ? n : a > l ? n + new Array(a - l + 1).join("0") : a > 0 ? n.slice(0, a) + "." + n.slice(a) : "0." + new Array(1 - a).join("0") + xe(e, Math.max(0, t + a - 1))[0];
1723
- }
1724
- function Je(e, t) {
1725
- var r = xe(e, t);
1726
- if (!r) return e + "";
1727
- var n = r[0], s = r[1];
1728
- return s < 0 ? "0." + new Array(-s).join("0") + n : n.length > s + 1 ? n.slice(0, s + 1) + "." + n.slice(s + 1) : n + new Array(s - n.length + 2).join("0");
1729
- }
1730
- const Pe = {
1731
- "%": (e, t) => (e * 100).toFixed(t),
1732
- b: (e) => Math.round(e).toString(2),
1733
- c: (e) => e + "",
1734
- d: hr,
1735
- e: (e, t) => e.toExponential(t),
1736
- f: (e, t) => e.toFixed(t),
1737
- g: (e, t) => e.toPrecision(t),
1738
- o: (e) => Math.round(e).toString(8),
1739
- p: (e, t) => Je(e * 100, t),
1740
- r: Je,
1741
- s: br,
1742
- X: (e) => Math.round(e).toString(16).toUpperCase(),
1743
- x: (e) => Math.round(e).toString(16)
1744
- };
1745
- function Ce(e) {
1746
- return e;
1747
- }
1748
- var et = Array.prototype.map, tt = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
1749
- function wr(e) {
1750
- var t = e.grouping === void 0 || e.thousands === void 0 ? Ce : yr(et.call(e.grouping, Number), e.thousands + ""), r = e.currency === void 0 ? "" : e.currency[0] + "", n = e.currency === void 0 ? "" : e.currency[1] + "", s = e.decimal === void 0 ? "." : e.decimal + "", a = e.numerals === void 0 ? Ce : pr(et.call(e.numerals, String)), l = e.percent === void 0 ? "%" : e.percent + "", c = e.minus === void 0 ? "−" : e.minus + "", u = e.nan === void 0 ? "NaN" : e.nan + "";
1751
- function o(f) {
1752
- f = he(f);
1753
- var m = f.fill, A = f.align, x = f.sign, N = f.symbol, g = f.zero, S = f.width, T = f.comma, h = f.precision, b = f.trim, y = f.type;
1754
- y === "n" ? (T = !0, y = "g") : Pe[y] || (h === void 0 && (h = 12), b = !0, y = "g"), (g || m === "0" && A === "=") && (g = !0, m = "0", A = "=");
1755
- var p = N === "$" ? r : N === "#" && /[boxX]/.test(y) ? "0" + y.toLowerCase() : "", v = N === "$" ? n : /[%p]/.test(y) ? l : "", k = Pe[y], $ = /[defgprs%]/.test(y);
1756
- h = h === void 0 ? 6 : /[gprs]/.test(y) ? Math.max(1, Math.min(21, h)) : Math.max(0, Math.min(20, h));
1757
- function F(M) {
1758
- var E = p, z = v, Y, Ie, re;
1759
- if (y === "c")
1760
- z = k(M) + z, M = "";
1761
- else {
1762
- M = +M;
1763
- var ne = M < 0 || 1 / M < 0;
1764
- if (M = isNaN(M) ? u : k(Math.abs(M), h), b && (M = gr(M)), ne && +M == 0 && x !== "+" && (ne = !1), E = (ne ? x === "(" ? x : c : x === "-" || x === "(" ? "" : x) + E, z = (y === "s" ? tt[8 + ut / 3] : "") + z + (ne && x === "(" ? ")" : ""), $) {
1765
- for (Y = -1, Ie = M.length; ++Y < Ie; )
1766
- if (re = M.charCodeAt(Y), 48 > re || re > 57) {
1767
- z = (re === 46 ? s + M.slice(Y + 1) : M.slice(Y)) + z, M = M.slice(0, Y);
1768
- break;
1769
- }
1770
- }
1771
- }
1772
- T && !g && (M = t(M, 1 / 0));
1773
- var se = E.length + M.length + z.length, _ = se < S ? new Array(S - se + 1).join(m) : "";
1774
- switch (T && g && (M = t(_ + M, _.length ? S - z.length : 1 / 0), _ = ""), A) {
1775
- case "<":
1776
- M = E + M + z + _;
1777
- break;
1778
- case "=":
1779
- M = E + _ + M + z;
1780
- break;
1781
- case "^":
1782
- M = _.slice(0, se = _.length >> 1) + E + M + z + _.slice(se);
1783
- break;
1784
- default:
1785
- M = _ + E + M + z;
1786
- break;
1787
- }
1788
- return a(M);
1789
- }
1790
- return F.toString = function() {
1791
- return f + "";
1792
- }, F;
1793
- }
1794
- function d(f, m) {
1795
- var A = o((f = he(f), f.type = "f", f)), x = Math.max(-8, Math.min(8, Math.floor(Z(m) / 3))) * 3, N = Math.pow(10, -x), g = tt[8 + x / 3];
1796
- return function(S) {
1797
- return A(N * S) + g;
1798
- };
1799
- }
1800
- return {
1801
- format: o,
1802
- formatPrefix: d
1803
- };
1804
- }
1805
- var oe, dt, ft;
1806
- Nr({
1807
- thousands: ",",
1808
- grouping: [3],
1809
- currency: ["$", ""]
1810
- });
1811
- function Nr(e) {
1812
- return oe = wr(e), dt = oe.format, ft = oe.formatPrefix, oe;
1813
- }
1814
- function Ar(e) {
1815
- return Math.max(0, -Z(Math.abs(e)));
1816
- }
1817
- function Sr(e, t) {
1818
- return Math.max(0, Math.max(-8, Math.min(8, Math.floor(Z(t) / 3))) * 3 - Z(Math.abs(e)));
1819
- }
1820
- function kr(e, t) {
1821
- return e = Math.abs(e), t = Math.abs(t) - e, Math.max(0, Z(t) - Z(e)) + 1;
1822
- }
1823
- function Re(e, t) {
1824
- switch (arguments.length) {
1825
- case 0:
1826
- break;
1827
- case 1:
1828
- this.range(e);
1829
- break;
1830
- default:
1831
- this.range(t).domain(e);
1832
- break;
1833
- }
1834
- return this;
1835
- }
1836
- const rt = Symbol("implicit");
1837
- function mt() {
1838
- var e = new Ge(), t = [], r = [], n = rt;
1839
- function s(a) {
1840
- let l = e.get(a);
1841
- if (l === void 0) {
1842
- if (n !== rt) return n;
1843
- e.set(a, l = t.push(a) - 1);
1844
- }
1845
- return r[l % r.length];
1846
- }
1847
- return s.domain = function(a) {
1848
- if (!arguments.length) return t.slice();
1849
- t = [], e = new Ge();
1850
- for (const l of a)
1851
- e.has(l) || e.set(l, t.push(l) - 1);
1852
- return s;
1853
- }, s.range = function(a) {
1854
- return arguments.length ? (r = Array.from(a), s) : r.slice();
1855
- }, s.unknown = function(a) {
1856
- return arguments.length ? (n = a, s) : n;
1857
- }, s.copy = function() {
1858
- return mt(t, r).unknown(n);
1859
- }, Re.apply(s, arguments), s;
1860
- }
1861
- function Mr(e) {
1862
- return function() {
1863
- return e;
1864
- };
1865
- }
1866
- function $r(e) {
1867
- return +e;
1868
- }
1869
- var nt = [0, 1];
1870
- function X(e) {
1871
- return e;
1872
- }
1873
- function Me(e, t) {
1874
- return (t -= e = +e) ? function(r) {
1875
- return (r - e) / t;
1876
- } : Mr(isNaN(t) ? NaN : 0.5);
1877
- }
1878
- function Lr(e, t) {
1879
- var r;
1880
- return e > t && (r = e, e = t, t = r), function(n) {
1881
- return Math.max(e, Math.min(t, n));
1882
- };
1883
- }
1884
- function Tr(e, t, r) {
1885
- var n = e[0], s = e[1], a = t[0], l = t[1];
1886
- return s < n ? (n = Me(s, n), a = r(l, a)) : (n = Me(n, s), a = r(a, l)), function(c) {
1887
- return a(n(c));
1888
- };
1889
- }
1890
- function Fr(e, t, r) {
1891
- var n = Math.min(e.length, t.length) - 1, s = new Array(n), a = new Array(n), l = -1;
1892
- for (e[n] < e[0] && (e = e.slice().reverse(), t = t.slice().reverse()); ++l < n; )
1893
- s[l] = Me(e[l], e[l + 1]), a[l] = r(t[l], t[l + 1]);
1894
- return function(c) {
1895
- var u = at(e, c, 1, n) - 1;
1896
- return a[u](s[u](c));
1897
- };
1898
- }
1899
- function jr(e, t) {
1900
- return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());
1901
- }
1902
- function zr() {
1903
- var e = nt, t = nt, r = Ee, n, s, a, l = X, c, u, o;
1904
- function d() {
1905
- var m = Math.min(e.length, t.length);
1906
- return l !== X && (l = Lr(e[0], e[m - 1])), c = m > 2 ? Fr : Tr, u = o = null, f;
1907
- }
1908
- function f(m) {
1909
- return m == null || isNaN(m = +m) ? a : (u || (u = c(e.map(n), t, r)))(n(l(m)));
1910
- }
1911
- return f.invert = function(m) {
1912
- return l(s((o || (o = c(t, e.map(n), me)))(m)));
1913
- }, f.domain = function(m) {
1914
- return arguments.length ? (e = Array.from(m, $r), d()) : e.slice();
1915
- }, f.range = function(m) {
1916
- return arguments.length ? (t = Array.from(m), d()) : t.slice();
1917
- }, f.rangeRound = function(m) {
1918
- return t = Array.from(m), r = xr, d();
1919
- }, f.clamp = function(m) {
1920
- return arguments.length ? (l = m ? !0 : X, d()) : l !== X;
1921
- }, f.interpolate = function(m) {
1922
- return arguments.length ? (r = m, d()) : r;
1923
- }, f.unknown = function(m) {
1924
- return arguments.length ? (a = m, f) : a;
1925
- }, function(m, A) {
1926
- return n = m, s = A, d();
1927
- };
1928
- }
1929
- function Er() {
1930
- return zr()(X, X);
1931
- }
1932
- function Dr(e, t, r, n) {
1933
- var s = Kt(e, t, r), a;
1934
- switch (n = he(n ?? ",f"), n.type) {
1935
- case "s": {
1936
- var l = Math.max(Math.abs(e), Math.abs(t));
1937
- return n.precision == null && !isNaN(a = Sr(s, l)) && (n.precision = a), ft(n, l);
1938
- }
1939
- case "":
1940
- case "e":
1941
- case "g":
1942
- case "p":
1943
- case "r": {
1944
- n.precision == null && !isNaN(a = kr(s, Math.max(Math.abs(e), Math.abs(t)))) && (n.precision = a - (n.type === "e"));
1945
- break;
1946
- }
1947
- case "f":
1948
- case "%": {
1949
- n.precision == null && !isNaN(a = Ar(s)) && (n.precision = a - (n.type === "%") * 2);
1950
- break;
1951
- }
1952
- }
1953
- return dt(n);
1954
- }
1955
- function xt(e) {
1956
- var t = e.domain;
1957
- return e.ticks = function(r) {
1958
- var n = t();
1959
- return qt(n[0], n[n.length - 1], r ?? 10);
1960
- }, e.tickFormat = function(r, n) {
1961
- var s = t();
1962
- return Dr(s[0], s[s.length - 1], r ?? 10, n);
1963
- }, e.nice = function(r) {
1964
- r == null && (r = 10);
1965
- var n = t(), s = 0, a = n.length - 1, l = n[s], c = n[a], u, o, d = 10;
1966
- for (c < l && (o = l, l = c, c = o, o = s, s = a, a = o); d-- > 0; ) {
1967
- if (o = Ae(l, c, r), o === u)
1968
- return n[s] = l, n[a] = c, t(n);
1969
- if (o > 0)
1970
- l = Math.floor(l / o) * o, c = Math.ceil(c / o) * o;
1971
- else if (o < 0)
1972
- l = Math.ceil(l * o) / o, c = Math.floor(c * o) / o;
1973
- else
1974
- break;
1975
- u = o;
1976
- }
1977
- return e;
1978
- }, e;
1979
- }
1980
- function Rr() {
1981
- var e = Er();
1982
- return e.copy = function() {
1983
- return jr(e, Rr());
1984
- }, Re.apply(e, arguments), xt(e);
1985
- }
1986
- function ht() {
1987
- var e = 0, t = 1, r = 1, n = [0.5], s = [0, 1], a;
1988
- function l(u) {
1989
- return u != null && u <= u ? s[at(n, u, 0, r)] : a;
1990
- }
1991
- function c() {
1992
- var u = -1;
1993
- for (n = new Array(r); ++u < r; ) n[u] = ((u + 1) * t - (u - r) * e) / (r + 1);
1994
- return l;
1995
- }
1996
- return l.domain = function(u) {
1997
- return arguments.length ? ([e, t] = u, e = +e, t = +t, c()) : [e, t];
1998
- }, l.range = function(u) {
1999
- return arguments.length ? (r = (s = Array.from(u)).length - 1, c()) : s.slice();
2000
- }, l.invertExtent = function(u) {
2001
- var o = s.indexOf(u);
2002
- return o < 0 ? [NaN, NaN] : o < 1 ? [e, n[0]] : o >= r ? [n[r - 1], t] : [n[o - 1], n[o]];
2003
- }, l.unknown = function(u) {
2004
- return arguments.length && (a = u), l;
2005
- }, l.thresholds = function() {
2006
- return n.slice();
2007
- }, l.copy = function() {
2008
- return ht().domain([e, t]).range(s).unknown(a);
2009
- }, Re.apply(xt(l), arguments);
2010
- }
2011
- function Jr({
2012
- data: e,
2013
- chartConfig: t,
2014
- displayConfig: r = {},
2015
- queryObject: n,
2016
- height: s = "100%",
2017
- colorPalette: a
2018
- }) {
2019
- const [l, c] = O(null), { getFieldLabel: u } = W();
2020
- try {
2021
- const o = {
2022
- showTooltip: (r == null ? void 0 : r.showTooltip) ?? !0,
2023
- showLegend: (r == null ? void 0 : r.showLegend) ?? !0
2024
- };
2025
- if (!e || e.length === 0)
2026
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-gray-500", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
2027
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
2028
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No data points to display in treemap chart" })
2029
- ] }) });
2030
- let d, f = !1, m;
2031
- if (t != null && t.xAxis && (t != null && t.yAxis)) {
2032
- const h = t.xAxis[0], b = Array.isArray(t.yAxis) ? t.yAxis[0] : t.yAxis;
2033
- m = Array.isArray(t.series) ? t.series[0] : t.series;
2034
- const y = H(n, h);
2035
- if (m) {
2036
- const p = e.map((v) => {
2037
- const k = v[m];
2038
- return typeof k == "string" ? parseFloat(k) : k;
2039
- }).filter((v) => !isNaN(v));
2040
- if (f = p.length === e.length && p.every((v) => typeof v == "number"), f) {
2041
- const v = Math.min(...p), k = Math.max(...p), $ = ht().domain([v, k]).range(ie);
2042
- d = e.map((F) => {
2043
- const M = typeof F[m] == "string" ? parseFloat(F[m]) : F[m], E = $(M);
2044
- return {
2045
- name: R(F[h], y) || String(F[h]) || "Unknown",
2046
- size: typeof F[b] == "string" ? parseFloat(F[b]) : F[b] || 0,
2047
- fill: E,
2048
- series: String(F[m])
2049
- };
2050
- });
2051
- } else {
2052
- const v = [...new Set(e.map(($) => String($[m])))], k = mt().domain(v).range((a == null ? void 0 : a.colors) || L);
2053
- d = e.map(($) => ({
2054
- name: R($[h], y) || String($[h]) || "Unknown",
2055
- size: typeof $[b] == "string" ? parseFloat($[b]) : $[b] || 0,
2056
- fill: k(String($[m])),
2057
- series: String($[m])
2058
- }));
2059
- }
2060
- } else
2061
- d = e.map((p, v) => ({
2062
- name: R(p[h], y) || String(p[h]) || "Unknown",
2063
- size: typeof p[b] == "string" ? parseFloat(p[b]) : p[b] || 0,
2064
- fill: (a == null ? void 0 : a.colors) && a.colors[v % a.colors.length] || L[v % L.length]
2065
- }));
2066
- } else {
2067
- const h = e[0], b = Object.keys(h), y = b.find(
2068
- (v) => typeof h[v] == "string" || v.toLowerCase().includes("name") || v.toLowerCase().includes("label") || v.toLowerCase().includes("category")
2069
- ) || b[0], p = b.find((v) => v.toLowerCase().includes("size")) || b.find(
2070
- (v) => typeof h[v] == "number" && v !== y
2071
- ) || b[1];
2072
- if (!p)
2073
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
2074
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
2075
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No numeric field found for treemap chart size" })
2076
- ] }) });
2077
- d = e.map((v, k) => {
2078
- let $ = v[y];
2079
- return typeof $ == "boolean" ? $ = $ ? "Active" : "Inactive" : $ === "true" || $ === "false" ? $ = $ === "true" ? "Active" : "Inactive" : $ = String($), {
2080
- name: $,
2081
- size: typeof v[p] == "string" ? parseFloat(v[p]) : v[p] || 0,
2082
- fill: (a == null ? void 0 : a.colors) && a.colors[k % a.colors.length] || L[k % L.length]
2083
- };
2084
- });
2085
- }
2086
- if (d = d.filter((h) => h.size != null && h.size > 0), d.length === 0)
2087
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-gray-500", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
2088
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
2089
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No valid data points for treemap chart after transformation" })
2090
- ] }) });
2091
- const A = (h) => {
2092
- var M;
2093
- const { x: b, y, width: p, height: v, index: k, name: $, size: F } = h;
2094
- return p < 20 || v < 20 ? null : /* @__PURE__ */ w("g", { children: [
2095
- /* @__PURE__ */ i(
2096
- "rect",
2097
- {
2098
- x: b,
2099
- y,
2100
- width: p,
2101
- height: v,
2102
- style: {
2103
- fill: ((M = d[k]) == null ? void 0 : M.fill) || (a == null ? void 0 : a.colors) && a.colors[k % a.colors.length] || L[k % L.length],
2104
- fillOpacity: l !== null ? l === k ? 1 : 0.6 : 0.8,
2105
- stroke: "#fff",
2106
- strokeWidth: 2,
2107
- cursor: "pointer"
2108
- },
2109
- onMouseEnter: () => c(k),
2110
- onMouseLeave: () => c(null)
2111
- }
2112
- ),
2113
- /* @__PURE__ */ i(
2114
- "foreignObject",
2115
- {
2116
- x: b,
2117
- y,
2118
- width: p,
2119
- height: v,
2120
- style: { pointerEvents: "none", overflow: "visible" },
2121
- children: /* @__PURE__ */ w(
2122
- "div",
2123
- {
2124
- style: {
2125
- width: "100%",
2126
- height: "100%",
2127
- display: "flex",
2128
- flexDirection: "column",
2129
- alignItems: "center",
2130
- justifyContent: "center",
2131
- padding: "4px",
2132
- boxSizing: "border-box",
2133
- color: "#ffffff",
2134
- textShadow: "0 1px 2px rgba(0,0,0,0.8)",
2135
- fontFamily: "system-ui, -apple-system, sans-serif",
2136
- overflow: "hidden"
2137
- },
2138
- children: [
2139
- p > 40 && v > 30 && /* @__PURE__ */ i(
2140
- "div",
2141
- {
2142
- style: {
2143
- fontSize: `${Math.max(10, Math.min(p / 8, v / 8, 16))}px`,
2144
- fontWeight: "600",
2145
- textAlign: "center",
2146
- lineHeight: "1.2",
2147
- marginBottom: p > 60 && v > 45 ? "4px" : "0",
2148
- wordBreak: "break-word",
2149
- hyphens: "auto"
2150
- },
2151
- children: $
2152
- }
2153
- ),
2154
- p > 60 && v > 45 && /* @__PURE__ */ i(
2155
- "div",
2156
- {
2157
- style: {
2158
- fontSize: `${Math.max(8, Math.min(p / 10, v / 10, 14))}px`,
2159
- textAlign: "center",
2160
- opacity: 0.9
2161
- },
2162
- children: typeof F == "number" ? F.toLocaleString() : F
2163
- }
2164
- )
2165
- ]
2166
- }
2167
- )
2168
- }
2169
- )
2170
- ] });
2171
- }, N = d.some((h) => "series" in h) ? [...new Set(d.map((h) => h.series).filter(Boolean))] : [];
2172
- let g = [];
2173
- if (o.showLegend && m)
2174
- if (f) {
2175
- const h = Math.min(...e.map((y) => {
2176
- const p = y[m];
2177
- return typeof p == "string" ? parseFloat(p) : p;
2178
- })), b = Math.max(...e.map((y) => {
2179
- const p = y[m];
2180
- return typeof p == "string" ? parseFloat(p) : p;
2181
- }));
2182
- g = ie.map((y, p) => {
2183
- const v = p / (ie.length - 1);
2184
- return {
2185
- value: (h + (b - h) * v).toFixed(2),
2186
- type: "rect",
2187
- color: y
2188
- };
2189
- });
2190
- } else N.length > 1 && (g = N.map((h, b) => ({
2191
- value: h,
2192
- type: "rect",
2193
- color: L[b % L.length]
2194
- })));
2195
- const S = o.showLegend && g.length > 0, T = S ? typeof s == "string" && s.includes("%") ? s : typeof s == "number" ? s + 60 : `calc(${s} + 60px)` : s;
2196
- return /* @__PURE__ */ w("div", { className: "w-full", style: { height: T }, children: [
2197
- /* @__PURE__ */ i(G, { height: S ? "calc(100% - 50px)" : "100%", children: /* @__PURE__ */ i(
2198
- Ft,
2199
- {
2200
- data: d,
2201
- dataKey: "size",
2202
- aspectRatio: 4 / 3,
2203
- stroke: "#fff",
2204
- content: /* @__PURE__ */ i(A, {}),
2205
- children: o.showTooltip && /* @__PURE__ */ i(V, {})
2206
- }
2207
- ) }),
2208
- S && /* @__PURE__ */ i("div", { className: "flex justify-center items-center mt-4 pb-2", children: f ? (
2209
- // Gradient legend for numeric series
2210
- /* @__PURE__ */ w("div", { className: "flex flex-col items-center", children: [
2211
- /* @__PURE__ */ i("div", { className: "text-xs font-semibold text-gray-700 mb-2", children: m ? u(m) : "" }),
2212
- /* @__PURE__ */ w("div", { className: "flex items-center gap-2", children: [
2213
- /* @__PURE__ */ i("span", { className: "text-xs text-gray-600", children: Math.min(...e.map((h) => {
2214
- const b = h[m];
2215
- return typeof b == "string" ? parseFloat(b) : b;
2216
- })).toFixed(2) }),
2217
- /* @__PURE__ */ i(
2218
- "div",
2219
- {
2220
- className: "h-4 rounded",
2221
- style: {
2222
- width: "200px",
2223
- background: `linear-gradient(to right, ${ie.join(", ")})`
2224
- }
2225
- }
2226
- ),
2227
- /* @__PURE__ */ i("span", { className: "text-xs text-gray-600", children: Math.max(...e.map((h) => {
2228
- const b = h[m];
2229
- return typeof b == "string" ? parseFloat(b) : b;
2230
- })).toFixed(2) })
2231
- ] })
2232
- ] })
2233
- ) : (
2234
- // Discrete legend for categorical series
2235
- /* @__PURE__ */ i("div", { className: "flex flex-wrap justify-center gap-4", children: g.map((h, b) => /* @__PURE__ */ w("div", { className: "flex items-center gap-2", children: [
2236
- /* @__PURE__ */ i(
2237
- "div",
2238
- {
2239
- className: "w-3 h-3 rounded-sm",
2240
- style: { backgroundColor: h.color }
2241
- }
2242
- ),
2243
- /* @__PURE__ */ i("span", { className: "text-xs text-gray-600", children: h.value })
2244
- ] }, b)) })
2245
- ) })
2246
- ] });
2247
- } catch (o) {
2248
- return /* @__PURE__ */ i("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
2249
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "TreeMap Chart Error" }),
2250
- /* @__PURE__ */ i("div", { className: "text-xs mb-2", children: o instanceof Error ? o.message : "Unknown rendering error" }),
2251
- /* @__PURE__ */ i("div", { className: "text-xs text-gray-600", children: "Check the data and configuration" })
2252
- ] }) });
2253
- }
2254
- }
2255
- function Pr({
2256
- data: e,
2257
- chartConfig: t,
2258
- height: r = 300
2259
- }) {
2260
- const { getFieldLabel: n } = W();
2261
- if (!e || e.length === 0)
2262
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-gray-500", style: { height: r }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
2263
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
2264
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No data to display in table" })
2265
- ] }) });
2266
- const s = Object.keys(e[0] || {}), a = t != null && t.xAxis && t.xAxis.length > 0 ? t.xAxis.filter((l) => s.includes(l)) : s;
2267
- return a.length === 0 ? /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-gray-500", style: { height: r }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
2268
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No columns available" }),
2269
- /* @__PURE__ */ i("div", { className: "text-xs", children: "Data structure is invalid" })
2270
- ] }) }) : /* @__PURE__ */ i("div", { className: "w-full overflow-auto", style: { height: r }, children: /* @__PURE__ */ w("table", { className: "min-w-full divide-y divide-gray-200", children: [
2271
- /* @__PURE__ */ i("thead", { className: "bg-gray-50 sticky top-0", children: /* @__PURE__ */ i("tr", { children: a.map((l) => /* @__PURE__ */ i(
2272
- "th",
2273
- {
2274
- className: "px-3 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",
2275
- children: n(l)
2276
- },
2277
- l
2278
- )) }) }),
2279
- /* @__PURE__ */ i("tbody", { className: "bg-white divide-y divide-gray-200", children: e.map((l, c) => /* @__PURE__ */ i("tr", { className: "hover:bg-gray-50", children: a.map((u) => /* @__PURE__ */ i(
2280
- "td",
2281
- {
2282
- className: "px-3 py-2 whitespace-nowrap text-sm text-gray-900",
2283
- children: Ir(l[u])
2284
- },
2285
- u
2286
- )) }, c)) })
2287
- ] }) });
2288
- }
2289
- function Ir(e) {
2290
- return e == null ? "" : typeof e == "number" ? e.toLocaleString() : typeof e == "boolean" ? e ? "Yes" : "No" : String(e);
2291
- }
2292
- function Cr(e) {
2293
- const t = _r(e);
2294
- return {
2295
- portlets: e,
2296
- layouts: t
2297
- };
2298
- }
2299
- function _r(e) {
2300
- const t = e.map((r) => ({
2301
- i: r.id,
2302
- x: r.x,
2303
- y: r.y,
2304
- w: r.w,
2305
- h: r.h,
2306
- minW: 3,
2307
- minH: 3
2308
- }));
2309
- return {
2310
- lg: t,
2311
- md: t.map((r) => ({ ...r, w: Math.min(r.w, 8) })),
2312
- sm: t.map((r) => ({ ...r, w: Math.min(r.w, 6) })),
2313
- xs: t.map((r) => ({ ...r, w: Math.min(r.w, 4) })),
2314
- xxs: t.map((r) => ({ ...r, w: 2 }))
2315
- };
2316
- }
2317
- function en(e, t = {}) {
2318
- const { formatNumbers: r = !0, precision: n = 2 } = t;
2319
- return r ? e.map((s) => {
2320
- const a = {};
2321
- for (const [l, c] of Object.entries(s))
2322
- typeof c == "number" ? a[l] = Number(c.toFixed(n)) : a[l] = c;
2323
- return a;
2324
- }) : e;
2325
- }
2326
- function tn() {
2327
- return `portlet-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
2328
- }
2329
- function rn(e, t = 6, r = 4) {
2330
- return e.length === 0 ? { x: 0, y: 0 } : { x: 0, y: Math.max(...e.map((s) => s.y + s.h)) };
2331
- }
2332
- function nn(e) {
2333
- try {
2334
- const t = JSON.parse(e);
2335
- return typeof t != "object" || t === null ? { valid: !1, error: "Query must be a JSON object" } : !t.measures && !t.dimensions ? { valid: !1, error: "Query must have at least measures or dimensions" } : { valid: !0, query: t };
2336
- } catch {
2337
- return { valid: !1, error: "Invalid JSON format" };
2338
- }
2339
- }
2340
- function sn() {
2341
- return {
2342
- title: "Sample Chart",
2343
- query: JSON.stringify({
2344
- measures: ["count"],
2345
- dimensions: ["category"]
2346
- }, null, 2),
2347
- chartType: "bar",
2348
- chartConfig: {
2349
- x: "category",
2350
- y: ["count"]
2351
- },
2352
- displayConfig: {
2353
- showLegend: !0,
2354
- showGrid: !0,
2355
- showTooltip: !0
2356
- },
2357
- w: 6,
2358
- h: 4,
2359
- x: 0,
2360
- y: 0
2361
- };
2362
- }
2363
- export {
2364
- Wr as A,
2365
- Kr as B,
2366
- ge as C,
2367
- Pr as D,
2368
- nn as E,
2369
- sn as F,
2370
- Oe as G,
2371
- Br as L,
2372
- jt as N,
2373
- Yr as P,
2374
- Qr as R,
2375
- Xr as S,
2376
- Jr as T,
2377
- Zr as a,
2378
- Ze as b,
2379
- Cr as c,
2380
- mr as d,
2381
- C as e,
2382
- en as f,
2383
- jr as g,
2384
- Re as h,
2385
- me as i,
2386
- X as j,
2387
- H as k,
2388
- xt as l,
2389
- R as m,
2390
- Rr as n,
2391
- ie as o,
2392
- mt as p,
2393
- ht as q,
2394
- L as r,
2395
- G as s,
2396
- zr as t,
2397
- Te as u,
2398
- qr as v,
2399
- Ur as w,
2400
- _r as x,
2401
- tn as y,
2402
- rn as z
2403
- };
2404
- //# sourceMappingURL=charts-BM1k01Jw.js.map