@antscorp/antsomi-genai 1.0.7 → 1.0.9-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AreaChartRenderer-C8tA8BiZ.mjs +236 -0
- package/dist/BarChartRenderer-CXj4kwVD.mjs +293 -0
- package/dist/ChatInput-D9mdvDEs.mjs +21165 -0
- package/dist/HeatMapRenderer-ZiAp7nH8.mjs +240 -0
- package/dist/LineChartRenderer-DOASMHic.mjs +15967 -0
- package/dist/Loading-C4QAie1z.mjs +7 -0
- package/dist/MoreIcon-98tDxP84.mjs +9 -0
- package/dist/PieChartRenderer-BSbTNG_K.mjs +125 -0
- package/dist/ScatterChartRenderer-Bj0RGRfu.mjs +126 -0
- package/dist/ScoreCardRenderer-C3en9i7a.mjs +93 -0
- package/dist/SunburstChartRenderer-BN8gHoEI.mjs +69 -0
- package/dist/TextualContent-DTquCfn-.mjs +4530 -0
- package/dist/TreeMapRenderer-CeIfZL9x.mjs +63 -0
- package/dist/diverging-CIe4rj3l.mjs +3372 -0
- package/dist/flatten-TwtFbzbo.mjs +12 -0
- package/dist/index-1IIcNwAB.mjs +17173 -0
- package/dist/index-7MEyhQNc.mjs +501 -0
- package/dist/index-B4z0IGIj.mjs +90 -0
- package/dist/index-BSRxrmjG.mjs +56728 -0
- package/dist/index-BjeHsrX3.mjs +39 -0
- package/dist/index-BmJXKdY_.mjs +203 -0
- package/dist/index-CD6T3LTh.mjs +4 -0
- package/dist/index-CwPsQNhO.mjs +574 -0
- package/dist/index-D-954mab.mjs +643 -0
- package/dist/index-DQqESLsb.mjs +29 -0
- package/dist/index-DvmERaJf.mjs +208 -0
- package/dist/index-IC-XskMj.mjs +121 -0
- package/dist/index-UJczijvA.mjs +42 -0
- package/dist/index.d.ts +91 -437
- package/dist/index.es.js +3 -6
- package/dist/isEmpty-DZQaXQ4W.mjs +36 -0
- package/dist/main.css +1 -1
- package/dist/queyKeys-BqMK4i7F.mjs +6 -0
- package/dist/styles.module-2M4d5uE1.mjs +19 -0
- package/dist/styles.module-CLxy8V0b.mjs +1784 -0
- package/dist/toNumber-CHl49cGq.mjs +0 -1
- package/dist/useErrorHandler-DkczKIg-.mjs +44 -0
- package/package.json +31 -27
- package/dist/Component-7EZmYnN8.mjs +0 -261
- package/dist/Component-7EZmYnN8.mjs.map +0 -1
- package/dist/Component-BW_rCSr4.mjs +0 -142
- package/dist/Component-BW_rCSr4.mjs.map +0 -1
- package/dist/Component-BazCM_HQ.mjs +0 -313
- package/dist/Component-BazCM_HQ.mjs.map +0 -1
- package/dist/Component-BbKfqO_w.mjs +0 -86
- package/dist/Component-BbKfqO_w.mjs.map +0 -1
- package/dist/Component-C27lY-IH.mjs +0 -21
- package/dist/Component-C27lY-IH.mjs.map +0 -1
- package/dist/Component-CxKtGeEY.mjs +0 -100
- package/dist/Component-CxKtGeEY.mjs.map +0 -1
- package/dist/Component-DR98dVu0.mjs +0 -141
- package/dist/Component-DR98dVu0.mjs.map +0 -1
- package/dist/Component-JSY63syJ.mjs +0 -241
- package/dist/Component-JSY63syJ.mjs.map +0 -1
- package/dist/Component-kVKgBeH8.mjs +0 -83
- package/dist/Component-kVKgBeH8.mjs.map +0 -1
- package/dist/Component-y4AnEpp8.mjs +0 -19142
- package/dist/Component-y4AnEpp8.mjs.map +0 -1
- package/dist/index--IQFOK8F.mjs +0 -6
- package/dist/index--IQFOK8F.mjs.map +0 -1
- package/dist/index-Bxh4AxQk.mjs +0 -36
- package/dist/index-Bxh4AxQk.mjs.map +0 -1
- package/dist/index-C19D3Esg.mjs +0 -32847
- package/dist/index-C19D3Esg.mjs.map +0 -1
- package/dist/index-CJSY_hg5.mjs +0 -39
- package/dist/index-CJSY_hg5.mjs.map +0 -1
- package/dist/index-CQ-Xd6-Q.mjs +0 -16
- package/dist/index-CQ-Xd6-Q.mjs.map +0 -1
- package/dist/index-CTRdxsjR.mjs +0 -549
- package/dist/index-CTRdxsjR.mjs.map +0 -1
- package/dist/index-Cv-G3hqI.mjs +0 -6
- package/dist/index-Cv-G3hqI.mjs.map +0 -1
- package/dist/index-CzUSEK5y.mjs +0 -249
- package/dist/index-CzUSEK5y.mjs.map +0 -1
- package/dist/index-DaouEtYW.mjs +0 -58
- package/dist/index-DaouEtYW.mjs.map +0 -1
- package/dist/index-DyF-ciJy.mjs +0 -144
- package/dist/index-DyF-ciJy.mjs.map +0 -1
- package/dist/index-Efp6ricm.mjs +0 -6729
- package/dist/index-Efp6ricm.mjs.map +0 -1
- package/dist/index-ErWxfrxC.mjs +0 -773
- package/dist/index-ErWxfrxC.mjs.map +0 -1
- package/dist/index-T6M4_4_u.mjs +0 -6
- package/dist/index-T6M4_4_u.mjs.map +0 -1
- package/dist/index.es.js.map +0 -1
- package/dist/toNumber-CHl49cGq.mjs.map +0 -1
- package/dist/useGetSchema-IqknBZGf.mjs +0 -102
- package/dist/useGetSchema-IqknBZGf.mjs.map +0 -1
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { U as h, k as Z, b as se, j as q } from "./index-1IIcNwAB.mjs";
|
|
2
|
+
import { getSizeOfText as le, Report as ue } from "@antscorp/antsomi-charts";
|
|
3
|
+
import { useMemo as me } from "react";
|
|
4
|
+
import "@tanstack/react-query";
|
|
5
|
+
import "@antscorp/antsomi-constants";
|
|
6
|
+
import "axios";
|
|
7
|
+
import "@antscorp/antsomi-ui";
|
|
8
|
+
import { C as ce } from "./Loading-C4QAie1z.mjs";
|
|
9
|
+
import { t as k } from "./toNumber-CHl49cGq.mjs";
|
|
10
|
+
import { f as fe } from "./flatten-TwtFbzbo.mjs";
|
|
11
|
+
import { i as ge } from "./isEmpty-DZQaXQ4W.mjs";
|
|
12
|
+
function j(...S) {
|
|
13
|
+
return fe(S);
|
|
14
|
+
}
|
|
15
|
+
const I = 16, he = (S) => {
|
|
16
|
+
const [O, D, p] = S || [];
|
|
17
|
+
return {
|
|
18
|
+
time: O.value,
|
|
19
|
+
dimension: D.value,
|
|
20
|
+
aggregations: [
|
|
21
|
+
{
|
|
22
|
+
name: p.name,
|
|
23
|
+
type: p.aggregationType,
|
|
24
|
+
value: p.value
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
};
|
|
28
|
+
}, pe = (S) => {
|
|
29
|
+
const { data: O, settings: D, opts: p } = S, { mode: C = "EDIT", style: u } = D, F = h.helpers.safeParseListField(D.metric), c = h.helpers.safeParseListField(D.dimension), A = h.helpers.safeParseListField(D.timeDimension), E = p?.renderMetric ? h.helpers.safeParseListField(p.renderMetric) : F, { rows: J } = O, { general: Q, columns: Y = [], xAxis: W, areaChart: V } = u, G = (Q.missingData || "lineToZero") === "lineToZero" ? 0 : null, ee = W.range || "rangeByDateRange";
|
|
30
|
+
let g = [], N = 0;
|
|
31
|
+
const m = [], l = {};
|
|
32
|
+
let _ = [];
|
|
33
|
+
const T = [];
|
|
34
|
+
let x = !0;
|
|
35
|
+
if (C === "EDIT" && !E.every((s) => F.some((n) => n.key === s.key)))
|
|
36
|
+
return;
|
|
37
|
+
J.forEach((s, n) => {
|
|
38
|
+
const e = he(s) || {}, t = { time: e.time };
|
|
39
|
+
if (c.length === 0)
|
|
40
|
+
for (const r of E) {
|
|
41
|
+
N < 1 && r.name && m.push({
|
|
42
|
+
key: r.key || "",
|
|
43
|
+
name: r.name,
|
|
44
|
+
label: r.aliasLabel || r.label,
|
|
45
|
+
isActive: !0,
|
|
46
|
+
yAxisId: "",
|
|
47
|
+
color: ""
|
|
48
|
+
});
|
|
49
|
+
let a = 0;
|
|
50
|
+
if (e.aggregations.length > 0) {
|
|
51
|
+
const y = e.aggregations.find(($) => $.name === r.name);
|
|
52
|
+
y?.value && (a = +y.value[0] || 0);
|
|
53
|
+
}
|
|
54
|
+
a = +h.helpers.convertValueFromDataType({
|
|
55
|
+
value: a,
|
|
56
|
+
field: r
|
|
57
|
+
}), t[r.key] = a && +a > 0 ? a : G;
|
|
58
|
+
const i = `${r.key}_cumulative`, f = k(g[n - 1]?.[i]) || 0;
|
|
59
|
+
t[i] = Number.parseFloat(f.toString()) + a;
|
|
60
|
+
const w = l[r.key] ? l[r.key] : 0;
|
|
61
|
+
l[r.key] = w + a;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
if (N < 1 && typeof e.dimension < "u" && e.dimension.length > 0) {
|
|
65
|
+
const r = e.dimension;
|
|
66
|
+
c.length > 0 && c[0].dataType && r.length > 0 && (["IMAGE", "HYPERLINK"].includes(c[0].dataType) ? _ = r.reduce((a, i) => {
|
|
67
|
+
if (i.toString().indexOf("—")) {
|
|
68
|
+
const f = h.helpers.formattedHyperlink(i.toString(), "—");
|
|
69
|
+
if (f.length > 0) {
|
|
70
|
+
if (c[0].dataType === "IMAGE")
|
|
71
|
+
return j(a, f[0]);
|
|
72
|
+
if (c[0].dataType === "HYPERLINK")
|
|
73
|
+
return j(a, f[1]);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return j(a, i.toString());
|
|
77
|
+
}, []) : _ = r.map((a) => a.toString()));
|
|
78
|
+
}
|
|
79
|
+
_.length > 0 && _.forEach((r, a) => {
|
|
80
|
+
E.forEach((i, f) => {
|
|
81
|
+
const w = V && (V.numberOfSeries || V.numberOfSeries === 0) ? V.numberOfSeries : I, y = Math.min(w, I), $ = V.showOther ? V.showOther : !1;
|
|
82
|
+
if (i.name) {
|
|
83
|
+
let o = 0;
|
|
84
|
+
if (e.aggregations.length > 0) {
|
|
85
|
+
const d = e.aggregations.find((P) => P.name === i.name);
|
|
86
|
+
o = k(d?.value[a]) || 0;
|
|
87
|
+
}
|
|
88
|
+
x = x && o >= 0;
|
|
89
|
+
const L = !!o && E.find((d) => d.name === i.name);
|
|
90
|
+
L && (o = +h.helpers.convertValueFromDataType({
|
|
91
|
+
value: o,
|
|
92
|
+
field: L
|
|
93
|
+
})), t[`D${a}_${i.key}`] = o || G;
|
|
94
|
+
const H = `D${a}_${i.key}_cumulative`, te = g.at(n - 1)?.[H] || 0;
|
|
95
|
+
if (t[H] = Number.parseFloat(te.toString()) + o, T[f] || (T[f] = []), $ && (a >= y - 1 || a === _.length - 1)) {
|
|
96
|
+
const d = T[f][n] || 0, P = d.normalValue || 0, z = d.negativeValue || 0, M = d.positiveValue || 0;
|
|
97
|
+
T[f][n] = {
|
|
98
|
+
normalValue: k(P) + o,
|
|
99
|
+
negativeValue: k(z) + (o < 0 && o || 0),
|
|
100
|
+
positiveValue: k(M) + (o > 0 && o || 0)
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const ae = l[i.key] ? l[i.key] : 0;
|
|
104
|
+
l[i.key] = ae + o, t[`D${a}_${i.key}_positive`] = o > 0 && o || 0, t[`D${a}_${i.key}_negative`] = o < 0 && o || 0;
|
|
105
|
+
const U = `D${a}_${i.key}_cumulative_positive`, ie = g.at(n - 1)?.[U] || 0, X = `D${a}_${i.key}_cumulative_negative`, ne = g.at(n - 1)?.[X] || 0;
|
|
106
|
+
if (t[U] = k(ie) + (o > 0 && o || 0), t[X] = k(ne) + (o < 0 && o || 0), N < 1) {
|
|
107
|
+
const d = `D[0-9]+_${i.key}`, z = m.filter((re) => new RegExp(d).test(re.key)).length, M = c.at(0);
|
|
108
|
+
let R = "";
|
|
109
|
+
M && (R = h.helpers.convertValueFromDataType({
|
|
110
|
+
value: r,
|
|
111
|
+
field: M
|
|
112
|
+
}).toString(), R = h.helpers.formatValue({
|
|
113
|
+
value: R,
|
|
114
|
+
field: M
|
|
115
|
+
}).toString());
|
|
116
|
+
const oe = _.length, B = Math.min(oe, y);
|
|
117
|
+
z <= I && B > 0 && (!$ && a < B || $ && (a < B - 1 || a === 0)) && m.push({
|
|
118
|
+
key: `D${a}_${i.key}`,
|
|
119
|
+
name: `D${a}_${i.name}`,
|
|
120
|
+
label: R,
|
|
121
|
+
isActive: !0,
|
|
122
|
+
yAxisId: "",
|
|
123
|
+
color: ""
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
const b = A.at(0);
|
|
131
|
+
ee === "rangeByData" ? m.map((i) => i.key).some((i) => t[i] !== 0) && (t.time = e.time, b && (t.time = h.helpers.formatValue({
|
|
132
|
+
value: e.time,
|
|
133
|
+
field: b
|
|
134
|
+
}).toString()), g.push(t)) : (t.time = e.time, b && (t.time = h.helpers.formatValue({
|
|
135
|
+
value: e.time,
|
|
136
|
+
field: b
|
|
137
|
+
}).toString()), g.push(t)), N++;
|
|
138
|
+
}), E.length > 0 && c.length > 0 && E.forEach((s, n) => {
|
|
139
|
+
const e = `D00${n}_${s.key}`, t = V.showOther, b = V.numberOfSeries || I;
|
|
140
|
+
if (t && b > 1 && _ && _.length > 1) {
|
|
141
|
+
m.push({
|
|
142
|
+
label: "Other",
|
|
143
|
+
key: e,
|
|
144
|
+
name: `D00${n}_${s.name}`,
|
|
145
|
+
isActive: !0,
|
|
146
|
+
showOtherInfo: { index: n },
|
|
147
|
+
color: "",
|
|
148
|
+
yAxisId: ""
|
|
149
|
+
});
|
|
150
|
+
let r = 0, a = 0, i = 0;
|
|
151
|
+
g = g.map((f, w) => {
|
|
152
|
+
const y = T[n][w] || 0, $ = y.normalValue || 0, o = y.negativeValue || 0, L = y.positiveValue || 0;
|
|
153
|
+
return r += $, a += o, i += L, {
|
|
154
|
+
...f,
|
|
155
|
+
[e]: $,
|
|
156
|
+
[`${e}_negative`]: o,
|
|
157
|
+
[`${e}_positive`]: L,
|
|
158
|
+
[`${e}_cumulative`]: r,
|
|
159
|
+
[`${e}_cumulative_negative`]: a,
|
|
160
|
+
[`${e}_cumulative_positive`]: i
|
|
161
|
+
};
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
const v = {};
|
|
166
|
+
if (!ge(l)) {
|
|
167
|
+
let s = 0, n = 0;
|
|
168
|
+
for (const e in l)
|
|
169
|
+
l[e] && (s ? s > l[e] && (s = l[e]) : s = l[e], n < l[e] && (n = l[e]));
|
|
170
|
+
if (s !== n) {
|
|
171
|
+
let e = 0;
|
|
172
|
+
for (const t in l)
|
|
173
|
+
l[t] && (Y[e].chartType && Y[e].chartType, s < 10 ** 6 && n > 10 ** 6 ? l[t] < 10 ** 6 ? v[t] = "left" : v[t] = "right" : l[t] - s <= 0 || l[t] - s < l[t] - n ? v[t] = "left" : v[t] = "right"), e++;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (m.length > 0 && u.colorBy && u.colorBy.colors && u.colorBy.colors.length > 0) {
|
|
177
|
+
const { colors: s } = u.colorBy;
|
|
178
|
+
m.forEach((n, e) => {
|
|
179
|
+
let t = "";
|
|
180
|
+
n.name && (c.length > 0 ? Z.test(n.name) && (t = n.name.replace(Z, "")) : t = n.name), t ? v[t] ? m[e].yAxisId = v[t] : (m[e].yAxisId = "left", v[t] = "left") : m[e].yAxisId = "left", s[e] ? m[e].color = s[e] : m[e].color = s[0];
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
const K = {
|
|
184
|
+
width: 0,
|
|
185
|
+
height: 0
|
|
186
|
+
};
|
|
187
|
+
if (g.at(0)?.time) {
|
|
188
|
+
const { width: s, height: n } = le({
|
|
189
|
+
str: g.at(0)?.time || "",
|
|
190
|
+
fontFamily: u.grid.fontFamily.label,
|
|
191
|
+
fontSize: u.grid.axisFontSize.name
|
|
192
|
+
});
|
|
193
|
+
K.width = s, K.height = n;
|
|
194
|
+
}
|
|
195
|
+
return p?.updateValidateData?.({
|
|
196
|
+
data: !1
|
|
197
|
+
}), {
|
|
198
|
+
xAxisSize: K,
|
|
199
|
+
isDiverging: !x,
|
|
200
|
+
data: g,
|
|
201
|
+
coordinateAxis: v,
|
|
202
|
+
arrYAxis: m
|
|
203
|
+
};
|
|
204
|
+
}, Ce = (S) => {
|
|
205
|
+
const { part: O, width: D, height: p } = S, { data: C, chartSettings: u, isLoading: F, error: c } = se({
|
|
206
|
+
part: O,
|
|
207
|
+
id: `area-${O.datasource_id}`,
|
|
208
|
+
enabled: !0
|
|
209
|
+
}), A = me(() => !C || !u ? null : pe({
|
|
210
|
+
data: C,
|
|
211
|
+
settings: u
|
|
212
|
+
}), [C, u]);
|
|
213
|
+
if (c instanceof Error)
|
|
214
|
+
throw c;
|
|
215
|
+
if (F)
|
|
216
|
+
return /* @__PURE__ */ q.jsx(ce, {});
|
|
217
|
+
if (!A || !u)
|
|
218
|
+
throw Error("No data to render AreaChart");
|
|
219
|
+
return /* @__PURE__ */ q.jsx(
|
|
220
|
+
ue.AreaChart,
|
|
221
|
+
{
|
|
222
|
+
width: D,
|
|
223
|
+
height: p,
|
|
224
|
+
arrYAxis: A.arrYAxis,
|
|
225
|
+
coordinateAxis: A.coordinateAxis,
|
|
226
|
+
data: A.data,
|
|
227
|
+
renderMetric: u.metric,
|
|
228
|
+
timeDimension: u.timeDimension,
|
|
229
|
+
dimension: u.dimension,
|
|
230
|
+
style: u.style
|
|
231
|
+
}
|
|
232
|
+
);
|
|
233
|
+
};
|
|
234
|
+
export {
|
|
235
|
+
Ce as AreaChartRenderer
|
|
236
|
+
};
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { U as D, b as Z, j as w, C as ee } from "./index-1IIcNwAB.mjs";
|
|
2
|
+
import { Report as te } from "@antscorp/antsomi-charts";
|
|
3
|
+
import { useMemo as ae } from "react";
|
|
4
|
+
import "@tanstack/react-query";
|
|
5
|
+
import "@antscorp/antsomi-constants";
|
|
6
|
+
import "axios";
|
|
7
|
+
import "@antscorp/antsomi-ui";
|
|
8
|
+
import { C as ie } from "./Loading-C4QAie1z.mjs";
|
|
9
|
+
import { i as ne } from "./isEmpty-DZQaXQ4W.mjs";
|
|
10
|
+
function re(P) {
|
|
11
|
+
const N = /D[0-9]+_/, $ = (e) => e.aliasAggregation || e.aggregation || "", n = {
|
|
12
|
+
summary: 0,
|
|
13
|
+
summaryNegative: 0,
|
|
14
|
+
maxValues: {},
|
|
15
|
+
objMaxValues: {},
|
|
16
|
+
objMinValues: {}
|
|
17
|
+
}, { data: V, settings: j } = P, { style: R, dimension: k, breakdownDimension: I } = j, y = j.metric.map((e, i) => ({
|
|
18
|
+
...e,
|
|
19
|
+
key: `${e.name}_${i}`
|
|
20
|
+
})), { axes: W, showOtherBars: _ = !1, showOtherSeries: A = !1 } = R, z = W.mode || "double", T = I.length, O = 6, L = 512;
|
|
21
|
+
let l = [], u = [];
|
|
22
|
+
const m = {}, H = [], C = [];
|
|
23
|
+
let Y = 0, G = 0, U = [], d = R.maxBars;
|
|
24
|
+
const g = R.maxSeries || O, { rows: F } = V;
|
|
25
|
+
if (F.length <= 0)
|
|
26
|
+
return { arrYAxis: [], data: [] };
|
|
27
|
+
const X = [];
|
|
28
|
+
for (const e of y)
|
|
29
|
+
e.name && X.push(e.name);
|
|
30
|
+
const q = F.length > 0 ? Math.max(...V.rows.map((e) => +e.dimension.length)) : 0;
|
|
31
|
+
let B = 0, K = 0, M = 0;
|
|
32
|
+
for (let e = 0, i = V.rows.length; e < i; e++)
|
|
33
|
+
if (T && y[0].name) {
|
|
34
|
+
let t = V.rows[e].dimension.length;
|
|
35
|
+
if (t = t < O ? t : O, typeof g == "number" && g > 0 && (t = +g < t ? g : t), B += t || 0, K = +t, B > L) {
|
|
36
|
+
M = e;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
} else if (typeof V.rows[e].aggregations < "u") {
|
|
40
|
+
let t = V.rows[e].aggregations.length;
|
|
41
|
+
if (t = t < O ? t : O, typeof g == "number" && g > 0 && (t = +g < t ? g : t), B += t || 0, K = +t, B > L) {
|
|
42
|
+
M = e;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (M && d ? d = M < +d || +d < 0 ? M : d : M && (d = M), F.forEach((e, i) => {
|
|
47
|
+
let t = 0, o = 0, v = 0;
|
|
48
|
+
const p = typeof d == "number" && d > 0 ? G < d : !0;
|
|
49
|
+
if (typeof e.segment < "u" && e.segment && y.length > 0) {
|
|
50
|
+
let s = {
|
|
51
|
+
id: e.segment.id ? e.segment.id : `null_${i}`,
|
|
52
|
+
originalId: e.segment.id || "",
|
|
53
|
+
name: e.segment.name !== void 0 && e.segment.name !== null ? e.segment.name : "null"
|
|
54
|
+
}, S = 0;
|
|
55
|
+
if (k.length > 0 && (s.name = D.helpers.formatValue({
|
|
56
|
+
value: s.name,
|
|
57
|
+
field: k[0]
|
|
58
|
+
}).toString()), k.length > 0 && k[0].dataType && s.name)
|
|
59
|
+
switch (k[0].dataType) {
|
|
60
|
+
case "IMAGE": {
|
|
61
|
+
const a = D.helpers.formattedHyperlink(s.name.toString(), "—");
|
|
62
|
+
a.length > 0 && (s.id = a[0], s.name = a[0]);
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
case "HYPERLINK": {
|
|
66
|
+
const a = D.helpers.formattedHyperlink(s.name.toString(), "—");
|
|
67
|
+
a.length > 0 && (s.id = a[1], s.name = a[1]);
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (T && y[0].name) {
|
|
72
|
+
if (e.dimension && typeof e.dimension < "u" && typeof e.dimension == "object") {
|
|
73
|
+
let a = [];
|
|
74
|
+
if (e.aggregations?.length > 0) {
|
|
75
|
+
const r = y[0].aliasAggregation || y[0].aggregation || "", c = e.aggregations.find((b) => b.name === y[0].name && b.aggregationType === r);
|
|
76
|
+
c?.value && (a = [...c.value]);
|
|
77
|
+
}
|
|
78
|
+
if (a.length > 0 && (a = a.map((r) => D.helpers.convertValueFromDataType({
|
|
79
|
+
value: r,
|
|
80
|
+
field: y[0]
|
|
81
|
+
}))), e.dimension.forEach((r, c) => {
|
|
82
|
+
let b = !0;
|
|
83
|
+
typeof g == "number" && q !== g && (g === 1 && t >= 1 || g > 1 && t >= g - +A || !A && t >= g) && (b = !1);
|
|
84
|
+
let x = r.name.toString() || "";
|
|
85
|
+
if (k.length > 0 && k[0].dataType && x)
|
|
86
|
+
switch (k[0].dataType) {
|
|
87
|
+
case "IMAGE": {
|
|
88
|
+
const h = D.helpers.formattedHyperlink(x, "—");
|
|
89
|
+
h.length > 0 && (x = h[0]);
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
case "HYPERLINK": {
|
|
93
|
+
const h = D.helpers.formattedHyperlink(x, "—");
|
|
94
|
+
h.length > 0 && (x = h[1]);
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
x = D.helpers.convertValueFromDataType({
|
|
99
|
+
value: x,
|
|
100
|
+
field: I[0]
|
|
101
|
+
}).toString(), x = D.helpers.formatValue({
|
|
102
|
+
value: x,
|
|
103
|
+
field: I[0]
|
|
104
|
+
}).toString();
|
|
105
|
+
const E = r.id.toString() || r.name.toString() && D.helpers.changeSpecialCharacterToSnake(r.name.toString()) || "";
|
|
106
|
+
if (E) {
|
|
107
|
+
H.indexOf(E) < 0 && H.length < L && (C.push(r), b && (H.push(E), l.push({
|
|
108
|
+
yAxisId: "",
|
|
109
|
+
name: `D${E}`,
|
|
110
|
+
label: x,
|
|
111
|
+
key: y[0].key,
|
|
112
|
+
isActive: !0
|
|
113
|
+
}), U = [...U, `D${E}`])), ++t;
|
|
114
|
+
const h = a[c] ? +a[c] : 0;
|
|
115
|
+
b && (s[`D${E}`] = h), b || (S += h), (b || !b && A) && (h < 0 ? v += h : o += h);
|
|
116
|
+
}
|
|
117
|
+
}), A)
|
|
118
|
+
S && (s["D-1"] = S);
|
|
119
|
+
else {
|
|
120
|
+
const { "D-1": r, ...c } = s;
|
|
121
|
+
s = c;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
} else if (typeof e.aggregations < "u") {
|
|
125
|
+
for (const a of y)
|
|
126
|
+
if (a.name && a.key) {
|
|
127
|
+
let r = 0;
|
|
128
|
+
if (X.indexOf(a.name) >= 0) {
|
|
129
|
+
const b = a.name, x = $(a);
|
|
130
|
+
if (b && e.aggregations.length > 0) {
|
|
131
|
+
const E = e.aggregations.find((h) => h.name === b && x === h.aggregationType);
|
|
132
|
+
E?.value && (r = E.value[0] ? E.value[0] : 0);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
r = +D.helpers.convertValueFromDataType({
|
|
136
|
+
value: r,
|
|
137
|
+
field: a
|
|
138
|
+
}), s[a.key] = r;
|
|
139
|
+
const c = m[a.key] ? m[a.key] : 0;
|
|
140
|
+
m[a.key] = c + r, Y < 1 && l.push({
|
|
141
|
+
yAxisId: "",
|
|
142
|
+
key: a.key,
|
|
143
|
+
name: a.name,
|
|
144
|
+
label: a.aliasLabel || a.label,
|
|
145
|
+
isActive: !0
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
for (const a of Object.keys(s))
|
|
150
|
+
a.startsWith("D") && (+s[a] < 0 ? s[`${a}PERCENT`] = v === 0 ? 0 : +s[a] / v * -100 : s[`${a}PERCENT`] = o === 0 ? 0 : +s[a] / o * 100);
|
|
151
|
+
u.push(s), (p || _) && (n.summary = Math.max(o, n.summary), n.summaryNegative = Math.min(v, n.summaryNegative), G++, Y++);
|
|
152
|
+
}
|
|
153
|
+
}), d)
|
|
154
|
+
if (_ && +d > 1 && +d < u.length) {
|
|
155
|
+
const e = {
|
|
156
|
+
id: "",
|
|
157
|
+
name: "",
|
|
158
|
+
originalId: ""
|
|
159
|
+
}, i = {
|
|
160
|
+
id: "",
|
|
161
|
+
name: "",
|
|
162
|
+
originalId: ""
|
|
163
|
+
};
|
|
164
|
+
let t = 0, o = 0;
|
|
165
|
+
if (u = u.reduce((v, p, s) => {
|
|
166
|
+
let S = v;
|
|
167
|
+
if (s + 1 < +d)
|
|
168
|
+
S = [...S, p];
|
|
169
|
+
else if (C.length > 0)
|
|
170
|
+
for (const a of C) {
|
|
171
|
+
const c = `D${a.id || a.name && D.helpers.changeSpecialCharacterToSnake(a.name.toString()) || ""}`;
|
|
172
|
+
i[c] = i[c] ? (+i[c] || 0) + (+p[c] || 0) : p[c] || 0;
|
|
173
|
+
}
|
|
174
|
+
else if (V.rows[0].aggregations) {
|
|
175
|
+
for (const a of y)
|
|
176
|
+
if (a.name && a.key) {
|
|
177
|
+
const r = a.key;
|
|
178
|
+
e[r] = e[r] ? +e[r] + +p[r] : p[r];
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return S;
|
|
182
|
+
}, []), Object.keys(i).length > 0) {
|
|
183
|
+
for (const a of Object.values(i))
|
|
184
|
+
+a < 0 ? o += +a : t += +a;
|
|
185
|
+
t > n.summary && (n.summary = t), o < n.summaryNegative && (n.summaryNegative = o);
|
|
186
|
+
const v = Object.entries(i).sort(([, a], [, r]) => Number.parseFloat(a.toString()) - Number.parseFloat(r.toString())), p = v.length - (+g || K), s = v.slice(p < 0 ? 0 : p);
|
|
187
|
+
let S = 0;
|
|
188
|
+
for (const [, a] of v.slice(0, p))
|
|
189
|
+
S += +a;
|
|
190
|
+
for (const [a, r] of s)
|
|
191
|
+
e[a] = r, a === "D-1" && (e[a] = +r + S), a.startsWith("D") && (+e[a] < 0 ? e[`${a}PERCENT`] = o === 0 ? 0 : +e[a] / o * -100 : e[`${a}PERCENT`] = t === 0 ? 0 : +e[a] / t * 100);
|
|
192
|
+
p + +A < 0 && (e["D-1"] = S, +e["D-1PERCENT"] < 0 ? e["D-1PERCENT"] = o === 0 ? 0 : +e["D-1PERCENT"] / o * -100 : e["D-1PERCENT"] = t === 0 ? 0 : +e["D-1PERCENT"] / t * 100);
|
|
193
|
+
}
|
|
194
|
+
e.name = "Other", e.id = "-1", u = [...u, e];
|
|
195
|
+
} else
|
|
196
|
+
u = u.slice(0, +d);
|
|
197
|
+
_ || (u = u.filter((e) => +e.id != -1)), A && (typeof g == "number" && g > 1 || typeof g != "number") ? l.some((e) => e.name === "D-1") || l.push({
|
|
198
|
+
yAxisId: "",
|
|
199
|
+
name: "D-1",
|
|
200
|
+
label: "Other",
|
|
201
|
+
key: y[0].key,
|
|
202
|
+
isActive: !0
|
|
203
|
+
}) : l = l.filter((e) => e.name !== "D-1");
|
|
204
|
+
const f = {};
|
|
205
|
+
if (!ne(m))
|
|
206
|
+
if (z === "single")
|
|
207
|
+
for (const e in m)
|
|
208
|
+
m[e] && (f[e] = "left");
|
|
209
|
+
else {
|
|
210
|
+
let e, i = 0;
|
|
211
|
+
for (const t in m)
|
|
212
|
+
m[t] && ((typeof e > "u" || e > m[t]) && (e = m[t]), i < m[t] && (i = m[t]));
|
|
213
|
+
if (e && e !== i)
|
|
214
|
+
for (const t in m)
|
|
215
|
+
m[t] && (e < 1e6 && i > 1e6 ? m[t] < 1e6 ? f[t] = "left" : f[t] = "right" : m[t] - e > 0 && (m[t] - e < m[t] - i ? f[t] = "left" : f[t] = "right"));
|
|
216
|
+
else {
|
|
217
|
+
let t = !0;
|
|
218
|
+
for (const o in m)
|
|
219
|
+
m[o] && (f[o] = t ? "left" : "right", t = !t);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
l.length > 0 && l.forEach((e, i) => {
|
|
223
|
+
T ? e.name && f[e.name.toString()] ? l[i].yAxisId = f[e.name.toString()] : (f[e.name.toString()] = "left", l[i].yAxisId = "left") : e.key && f[e.key.toString()] ? l[i].yAxisId = f[e.key.toString()] : (f[e.key.toString()] = "left", l[i].yAxisId = "left");
|
|
224
|
+
});
|
|
225
|
+
const J = Object.keys(f).length > 0 ? Object.keys(f).every((e) => f[e] === "left") : !0, Q = Object.keys(f).length > 0 ? Object.keys(f).every((e) => f[e] === "right") : !0;
|
|
226
|
+
if (u.length > 0) {
|
|
227
|
+
const e = l.findIndex((i) => i.name === "D-1");
|
|
228
|
+
e >= 0 && e < l.length && (l = [
|
|
229
|
+
...l.slice(0, e),
|
|
230
|
+
...l.slice(e + 1),
|
|
231
|
+
l[e]
|
|
232
|
+
]), n.maxValues = {}, n.objMaxValues = {}, n.objMinValues = {};
|
|
233
|
+
for (const [i, t] of Object.entries(f)) {
|
|
234
|
+
n.maxValues[t] || (n.maxValues[t] = { value: 0, metricKey: "" }), n.objMaxValues[t]?.[i] || (n.objMaxValues[t] = {
|
|
235
|
+
...typeof n.objMaxValues[t] < "u" ? n.objMaxValues[t] : {},
|
|
236
|
+
[i]: 0
|
|
237
|
+
}), n.objMinValues[t]?.[i] || (n.objMinValues[t] = {
|
|
238
|
+
...typeof n.objMinValues[t] < "u" ? n.objMinValues[t] : {},
|
|
239
|
+
[i]: 0
|
|
240
|
+
});
|
|
241
|
+
for (const o of u)
|
|
242
|
+
+o[i] > +n.maxValues[t].value ? n.maxValues[t] = {
|
|
243
|
+
value: +o[i],
|
|
244
|
+
metricKey: i.replace(N, "")
|
|
245
|
+
} : +o[i] >= n.maxValues[t].value && (n.maxValues[t] = {
|
|
246
|
+
value: +o[i],
|
|
247
|
+
metricKey: i.replace(N, "")
|
|
248
|
+
}), +o[i] > n.objMaxValues[t][i] && (n.objMaxValues[t][i] = +o[i]), +o[i] < n.objMinValues[t][i] && (n.objMinValues[t][i] = +o[i]);
|
|
249
|
+
}
|
|
250
|
+
T && (l = l.filter(({ name: i }) => u.some((t) => !!t[i.toString()]))), T && (l = l.filter(({ name: i }) => u.some((t) => !!t[i.toString()])));
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
data: u,
|
|
254
|
+
arrYAxis: l,
|
|
255
|
+
arrDimensions: C,
|
|
256
|
+
isAllBarOnLeft: J,
|
|
257
|
+
isAllBarOnRight: Q,
|
|
258
|
+
coordinateAxis: f,
|
|
259
|
+
...n
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
const he = (P) => {
|
|
263
|
+
const { part: N, width: $, height: n } = P, { data: V, chartSettings: j, isLoading: R, error: k } = Z({
|
|
264
|
+
part: N,
|
|
265
|
+
id: `bar-${N.datasource_id}`,
|
|
266
|
+
enabled: !0
|
|
267
|
+
}), I = ae(() => !V || !j ? null : re({
|
|
268
|
+
data: V,
|
|
269
|
+
settings: j
|
|
270
|
+
}), [V, j]);
|
|
271
|
+
if (k instanceof Error)
|
|
272
|
+
throw k;
|
|
273
|
+
if (R)
|
|
274
|
+
return /* @__PURE__ */ w.jsx(ie, {});
|
|
275
|
+
if (!I || !j)
|
|
276
|
+
throw Error("No data to render BarChart");
|
|
277
|
+
return /* @__PURE__ */ w.jsx(
|
|
278
|
+
te.BarChart,
|
|
279
|
+
{
|
|
280
|
+
height: n,
|
|
281
|
+
width: $,
|
|
282
|
+
data: I.data,
|
|
283
|
+
arrYAxis: I.arrYAxis,
|
|
284
|
+
metric: j.metric,
|
|
285
|
+
dimension: j.dimension,
|
|
286
|
+
coordinateAxis: I.coordinateAxis,
|
|
287
|
+
colors: ee
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
};
|
|
291
|
+
export {
|
|
292
|
+
he as BarChartRenderer
|
|
293
|
+
};
|