@carbon/charts 1.16.5 → 1.16.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +3 -4
- package/dist/angle-utils-BSzg7qin.mjs +1681 -0
- package/dist/angle-utils-BSzg7qin.mjs.map +1 -0
- package/dist/array-BRmw0x1E.mjs +32 -0
- package/dist/array-BRmw0x1E.mjs.map +1 -0
- package/dist/choropleth-BwaUZYh6.mjs +11722 -0
- package/dist/choropleth-BwaUZYh6.mjs.map +1 -0
- package/dist/color-scale-utils-DAbXVtf-.mjs +5722 -0
- package/dist/color-scale-utils-DAbXVtf-.mjs.map +1 -0
- package/dist/components/essentials/geo-projection.d.ts +7 -5
- package/dist/components/essentials/highlights.d.ts +1 -1
- package/dist/components/essentials/threshold.d.ts +1 -1
- package/dist/components/essentials/tooltip.d.ts +1 -1
- package/dist/components/index.mjs +3 -3
- package/dist/demo/index.mjs +244 -264
- package/dist/demo/index.mjs.map +1 -1
- package/dist/enums-DwsxZqjR.mjs.map +1 -1
- package/dist/index-DnyOi0rJ.mjs +1477 -0
- package/dist/index-DnyOi0rJ.mjs.map +1 -0
- package/dist/index.mjs +35 -35
- package/dist/interfaces/axis-scales.d.ts +3 -3
- package/dist/interfaces/charts.d.ts +5 -3
- package/dist/interfaces/components.d.ts +4 -3
- package/dist/interfaces/model.d.ts +30 -6
- package/dist/model/index.mjs +1321 -17
- package/dist/model/index.mjs.map +1 -1
- package/dist/services/index.mjs +16 -16
- package/dist/umd/bundle.umd.js +11 -11
- package/dist/umd/bundle.umd.js.map +1 -1
- package/package.json +2 -15
- package/dist/_baseEach-Bp7pBkX8.mjs +0 -20
- package/dist/_baseEach-Bp7pBkX8.mjs.map +0 -1
- package/dist/angle-utils-BCx3SRS2.mjs +0 -849
- package/dist/angle-utils-BCx3SRS2.mjs.map +0 -1
- package/dist/choropleth-B7eXF9sA.mjs +0 -8662
- package/dist/choropleth-B7eXF9sA.mjs.map +0 -1
- package/dist/color-scale-utils-BaTmNvWt.mjs +0 -3467
- package/dist/color-scale-utils-BaTmNvWt.mjs.map +0 -1
- package/dist/wordcloud-BsEQRUwL.mjs +0 -1169
- package/dist/wordcloud-BsEQRUwL.mjs.map +0 -1
- package/dist/zoom-E2POxw6n.mjs +0 -739
- package/dist/zoom-E2POxw6n.mjs.map +0 -1
package/dist/model/index.mjs
CHANGED
|
@@ -1,20 +1,1324 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a0 as tt, a1 as et, au as st, av as w, aw as L, ad as N, ax as at, ay as nt, az as ot, ap as P, ar as k, g as p, w as E, c as F, v as rt, ao as $, J as z, aA as H, a as R, r as Z, V as Q, ac as C, L as W, ai as it, aB as lt, aa as A } from "../color-scale-utils-DAbXVtf-.mjs";
|
|
2
|
+
import { S as b, _ as U, d as X, e as q, s as ct } from "../enums-DwsxZqjR.mjs";
|
|
3
|
+
import { b as ut, c as I, a as pt } from "../array-BRmw0x1E.mjs";
|
|
4
|
+
function ht(u, t, e, s) {
|
|
5
|
+
for (var a = -1, n = u == null ? 0 : u.length; ++a < n; ) {
|
|
6
|
+
var o = u[a];
|
|
7
|
+
t(s, o, e(o), u);
|
|
8
|
+
}
|
|
9
|
+
return s;
|
|
10
|
+
}
|
|
11
|
+
function gt(u, t, e, s) {
|
|
12
|
+
return ut(u, function(a, n, o) {
|
|
13
|
+
t(s, a, e(a), o);
|
|
14
|
+
}), s;
|
|
15
|
+
}
|
|
16
|
+
function ft(u, t) {
|
|
17
|
+
return function(e, s) {
|
|
18
|
+
var a = et(e) ? ht : gt, n = {};
|
|
19
|
+
return a(e, u, tt(s), n);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function dt(u) {
|
|
23
|
+
for (var t = -1, e = u == null ? 0 : u.length, s = {}; ++t < e; ) {
|
|
24
|
+
var a = u[t];
|
|
25
|
+
s[a[0]] = a[1];
|
|
26
|
+
}
|
|
27
|
+
return s;
|
|
28
|
+
}
|
|
29
|
+
var mt = Object.prototype, Dt = mt.hasOwnProperty, yt = ft(function(u, t, e) {
|
|
30
|
+
Dt.call(u, e) ? u[e].push(t) : st(u, e, [t]);
|
|
31
|
+
});
|
|
32
|
+
function bt(u, t) {
|
|
33
|
+
let e = 0;
|
|
34
|
+
for (let s of u)
|
|
35
|
+
s != null && (s = +s) >= s && ++e;
|
|
36
|
+
return e;
|
|
37
|
+
}
|
|
38
|
+
function vt(u) {
|
|
39
|
+
return u;
|
|
40
|
+
}
|
|
41
|
+
function xt(u = w) {
|
|
42
|
+
if (u === w) return Y;
|
|
43
|
+
if (typeof u != "function") throw new TypeError("compare is not a function");
|
|
44
|
+
return (t, e) => {
|
|
45
|
+
const s = u(t, e);
|
|
46
|
+
return s || s === 0 ? s : (u(e, e) === 0) - (u(t, t) === 0);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function Y(u, t) {
|
|
50
|
+
return (u == null || !(u >= u)) - (t == null || !(t >= t)) || (u < t ? -1 : u > t ? 1 : 0);
|
|
51
|
+
}
|
|
52
|
+
var Ct = Array.prototype, Tt = Ct.slice;
|
|
53
|
+
function B(u) {
|
|
54
|
+
return () => u;
|
|
55
|
+
}
|
|
56
|
+
function At(u, t, e) {
|
|
57
|
+
let s;
|
|
58
|
+
for (; ; ) {
|
|
59
|
+
const a = L(u, t, e);
|
|
60
|
+
if (a === s || a === 0 || !isFinite(a))
|
|
61
|
+
return [u, t];
|
|
62
|
+
a > 0 ? (u = Math.floor(u / a) * a, t = Math.ceil(t / a) * a) : a < 0 && (u = Math.ceil(u * a) / a, t = Math.floor(t * a) / a), s = a;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function Ot(u) {
|
|
66
|
+
return Math.max(1, Math.ceil(Math.log(bt(u)) / Math.LN2) + 1);
|
|
67
|
+
}
|
|
68
|
+
function Mt() {
|
|
69
|
+
var u = vt, t = N, e = Ot;
|
|
70
|
+
function s(a) {
|
|
71
|
+
Array.isArray(a) || (a = Array.from(a));
|
|
72
|
+
var n, o = a.length, r, i, l = new Array(o);
|
|
73
|
+
for (n = 0; n < o; ++n)
|
|
74
|
+
l[n] = u(a[n], n, a);
|
|
75
|
+
var c = t(l), h = c[0], g = c[1], f = e(l, h, g);
|
|
76
|
+
if (!Array.isArray(f)) {
|
|
77
|
+
const y = g, S = +f;
|
|
78
|
+
if (t === N && ([h, g] = At(h, g, S)), f = at(h, g, S), f[0] <= h && (i = L(h, g, S)), f[f.length - 1] >= g)
|
|
79
|
+
if (y >= g && t === N) {
|
|
80
|
+
const T = L(h, g, S);
|
|
81
|
+
isFinite(T) && (T > 0 ? g = (Math.floor(g / T) + 1) * T : T < 0 && (g = (Math.ceil(g * -T) + 1) / -T));
|
|
82
|
+
} else
|
|
83
|
+
f.pop();
|
|
84
|
+
}
|
|
85
|
+
for (var d = f.length, m = 0, D = d; f[m] <= h; ) ++m;
|
|
86
|
+
for (; f[D - 1] > g; ) --D;
|
|
87
|
+
(m || D < d) && (f = f.slice(m, D), d = D - m);
|
|
88
|
+
var x = new Array(d + 1), O;
|
|
89
|
+
for (n = 0; n <= d; ++n)
|
|
90
|
+
O = x[n] = [], O.x0 = n > 0 ? f[n - 1] : h, O.x1 = n < d ? f[n] : g;
|
|
91
|
+
if (isFinite(i)) {
|
|
92
|
+
if (i > 0)
|
|
93
|
+
for (n = 0; n < o; ++n)
|
|
94
|
+
(r = l[n]) != null && h <= r && r <= g && x[Math.min(d, Math.floor((r - h) / i))].push(a[n]);
|
|
95
|
+
else if (i < 0) {
|
|
96
|
+
for (n = 0; n < o; ++n)
|
|
97
|
+
if ((r = l[n]) != null && h <= r && r <= g) {
|
|
98
|
+
const y = Math.floor((h - r) * i);
|
|
99
|
+
x[Math.min(d, y + (f[y] <= r))].push(a[n]);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
} else
|
|
103
|
+
for (n = 0; n < o; ++n)
|
|
104
|
+
(r = l[n]) != null && h <= r && r <= g && x[nt(f, r, 0, d)].push(a[n]);
|
|
105
|
+
return x;
|
|
106
|
+
}
|
|
107
|
+
return s.value = function(a) {
|
|
108
|
+
return arguments.length ? (u = typeof a == "function" ? a : B(a), s) : u;
|
|
109
|
+
}, s.domain = function(a) {
|
|
110
|
+
return arguments.length ? (t = typeof a == "function" ? a : B([a[0], a[1]]), s) : t;
|
|
111
|
+
}, s.thresholds = function(a) {
|
|
112
|
+
return arguments.length ? (e = typeof a == "function" ? a : B(Array.isArray(a) ? Tt.call(a) : a), s) : e;
|
|
113
|
+
}, s;
|
|
114
|
+
}
|
|
115
|
+
function J(u, t, e = 0, s = 1 / 0, a) {
|
|
116
|
+
if (t = Math.floor(t), e = Math.floor(Math.max(0, e)), s = Math.floor(Math.min(u.length - 1, s)), !(e <= t && t <= s)) return u;
|
|
117
|
+
for (a = a === void 0 ? Y : xt(a); s > e; ) {
|
|
118
|
+
if (s - e > 600) {
|
|
119
|
+
const i = s - e + 1, l = t - e + 1, c = Math.log(i), h = 0.5 * Math.exp(2 * c / 3), g = 0.5 * Math.sqrt(c * h * (i - h) / i) * (l - i / 2 < 0 ? -1 : 1), f = Math.max(e, Math.floor(t - l * h / i + g)), d = Math.min(s, Math.floor(t + (i - l) * h / i + g));
|
|
120
|
+
J(u, t, f, d, a);
|
|
121
|
+
}
|
|
122
|
+
const n = u[t];
|
|
123
|
+
let o = e, r = s;
|
|
124
|
+
for (G(u, e, t), a(u[s], n) > 0 && G(u, e, s); o < r; ) {
|
|
125
|
+
for (G(u, o, r), ++o, --r; a(u[o], n) < 0; ) ++o;
|
|
126
|
+
for (; a(u[r], n) > 0; ) --r;
|
|
127
|
+
}
|
|
128
|
+
a(u[e], n) === 0 ? G(u, e, r) : (++r, G(u, r, s)), r <= t && (e = r + 1), t <= r && (s = r - 1);
|
|
129
|
+
}
|
|
130
|
+
return u;
|
|
131
|
+
}
|
|
132
|
+
function G(u, t, e) {
|
|
133
|
+
const s = u[t];
|
|
134
|
+
u[t] = u[e], u[e] = s;
|
|
135
|
+
}
|
|
136
|
+
function V(u, t, e) {
|
|
137
|
+
if (u = Float64Array.from(ot(u)), !(!(s = u.length) || isNaN(t = +t))) {
|
|
138
|
+
if (t <= 0 || s < 2) return P(u);
|
|
139
|
+
if (t >= 1) return k(u);
|
|
140
|
+
var s, a = (s - 1) * t, n = Math.floor(a), o = k(J(u, n).subarray(0, n + 1)), r = P(u.subarray(n + 1));
|
|
141
|
+
return o + (r - o) * (a - n);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function K(u, t) {
|
|
145
|
+
if ((o = u.length) > 1)
|
|
146
|
+
for (var e = 1, s, a, n = u[t[0]], o, r = n.length; e < o; ++e)
|
|
147
|
+
for (a = n, n = u[t[e]], s = 0; s < r; ++s)
|
|
148
|
+
n[s][1] += n[s][0] = isNaN(a[s][1]) ? a[s][0] : a[s][1];
|
|
149
|
+
}
|
|
150
|
+
function j(u) {
|
|
151
|
+
for (var t = u.length, e = new Array(t); --t >= 0; ) e[t] = t;
|
|
152
|
+
return e;
|
|
153
|
+
}
|
|
154
|
+
function Gt(u, t) {
|
|
155
|
+
return u[t];
|
|
156
|
+
}
|
|
157
|
+
function St(u) {
|
|
158
|
+
const t = [];
|
|
159
|
+
return t.key = u, t;
|
|
160
|
+
}
|
|
161
|
+
function _() {
|
|
162
|
+
var u = I([]), t = j, e = K, s = Gt;
|
|
163
|
+
function a(n) {
|
|
164
|
+
var o = Array.from(u.apply(this, arguments), St), r, i = o.length, l = -1, c;
|
|
165
|
+
for (const h of n)
|
|
166
|
+
for (r = 0, ++l; r < i; ++r)
|
|
167
|
+
(o[r][l] = [0, +s(h, o[r].key, l, n)]).data = h;
|
|
168
|
+
for (r = 0, c = pt(t(o)); r < i; ++r)
|
|
169
|
+
o[c[r]].index = r;
|
|
170
|
+
return e(o, c), o;
|
|
171
|
+
}
|
|
172
|
+
return a.keys = function(n) {
|
|
173
|
+
return arguments.length ? (u = typeof n == "function" ? n : I(Array.from(n)), a) : u;
|
|
174
|
+
}, a.value = function(n) {
|
|
175
|
+
return arguments.length ? (s = typeof n == "function" ? n : I(+n), a) : s;
|
|
176
|
+
}, a.order = function(n) {
|
|
177
|
+
return arguments.length ? (t = n == null ? j : typeof n == "function" ? n : I(Array.from(n)), a) : t;
|
|
178
|
+
}, a.offset = function(n) {
|
|
179
|
+
return arguments.length ? (e = n ?? K, a) : e;
|
|
180
|
+
}, a;
|
|
181
|
+
}
|
|
182
|
+
function Et(u, t) {
|
|
183
|
+
if ((i = u.length) > 0)
|
|
184
|
+
for (var e, s = 0, a, n, o, r, i, l = u[t[0]].length; s < l; ++s)
|
|
185
|
+
for (o = r = 0, e = 0; e < i; ++e)
|
|
186
|
+
(n = (a = u[t[e]][s])[1] - a[0]) > 0 ? (a[0] = o, a[1] = o += n) : n < 0 ? (a[1] = r, a[0] = r += n) : (a[0] = 0, a[1] = n);
|
|
187
|
+
}
|
|
188
|
+
function qt(u) {
|
|
189
|
+
const t = u.trim();
|
|
190
|
+
return ["=", "+", "-", "@", " ", "\r"].includes(t.charAt(0)) ? ` ${t}` : /[,\"\n]/.test(t) ? `"${t}"` : t;
|
|
191
|
+
}
|
|
192
|
+
class v {
|
|
193
|
+
constructor(t) {
|
|
194
|
+
this.state = {
|
|
195
|
+
options: {}
|
|
196
|
+
}, this.colorScale = {}, this.colorClassNames = {}, this.services = t;
|
|
197
|
+
}
|
|
198
|
+
formatTable({ headers: t, cells: e }) {
|
|
199
|
+
const s = this.getOptions(), {
|
|
200
|
+
code: a,
|
|
201
|
+
date: n,
|
|
202
|
+
number: o
|
|
203
|
+
} = p(s, "locale"), r = p(s, "tabularRepModal", "tableHeadingFormatter"), i = p(s, "tabularRepModal", "tableCellFormatter"), { cartesianScales: l } = this.services, c = l == null ? void 0 : l.getDomainAxisScaleType();
|
|
204
|
+
let h;
|
|
205
|
+
return c === b.TIME && (h = (f) => n(f, a, { month: "short", day: "numeric", year: "numeric" })), [
|
|
206
|
+
typeof r == "function" ? r(t) : t,
|
|
207
|
+
...typeof i == "function" ? i(e) : e.map((f) => {
|
|
208
|
+
h && (f[1] = h(f[1]));
|
|
209
|
+
for (const d in f) {
|
|
210
|
+
const m = f[d];
|
|
211
|
+
typeof m == "number" && (f[d] = o(m, a));
|
|
212
|
+
}
|
|
213
|
+
return f;
|
|
214
|
+
})
|
|
215
|
+
];
|
|
216
|
+
}
|
|
217
|
+
getAllDataFromDomain(t) {
|
|
218
|
+
if (!this.getData())
|
|
219
|
+
return null;
|
|
220
|
+
const e = this.getOptions();
|
|
221
|
+
let s = this.getData();
|
|
222
|
+
const a = this.getDataGroups(), { groupMapsTo: n } = p(e, "data"), o = p(e, "axes");
|
|
223
|
+
return t && (s = s.filter((r) => t.includes(r[n]))), o && Object.keys(o).forEach((r) => {
|
|
224
|
+
const i = o[r].mapsTo, l = o[r].scaleType;
|
|
225
|
+
if ((l === b.LINEAR || l === b.LOG) && (s = s.map((c) => ({
|
|
226
|
+
...c,
|
|
227
|
+
[i]: c[i] === null ? c[i] : Number(c[i])
|
|
228
|
+
}))), i && o[r].domain)
|
|
229
|
+
if (l === b.LABELS)
|
|
230
|
+
s = s.filter(
|
|
231
|
+
(c) => o[r].domain.includes(c[i])
|
|
232
|
+
);
|
|
233
|
+
else {
|
|
234
|
+
const [c, h] = o[r].domain;
|
|
235
|
+
s = s.filter(
|
|
236
|
+
(g) => !(i in g) || g[i] >= c && g[i] <= h
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
}), s.filter((r) => a.find((i) => i.name === r[n]));
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Charts that have group configs passed into them, only want to retrieve the display data relevant to that chart
|
|
243
|
+
* @param groups the included datasets for the particular chart
|
|
244
|
+
*/
|
|
245
|
+
getDisplayData(t) {
|
|
246
|
+
if (!this.get("data"))
|
|
247
|
+
return null;
|
|
248
|
+
const { ACTIVE: e } = E.items.status, s = this.getDataGroups(t), { groupMapsTo: a } = this.getOptions().data;
|
|
249
|
+
return this.getAllDataFromDomain(t).filter((o) => s.find(
|
|
250
|
+
(r) => r.name === o[a] && r.status === e
|
|
251
|
+
));
|
|
252
|
+
}
|
|
253
|
+
getData() {
|
|
254
|
+
return this.get("data");
|
|
255
|
+
}
|
|
256
|
+
isDataEmpty() {
|
|
257
|
+
return !this.getData().length;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Sets the data for the current instance.
|
|
261
|
+
*
|
|
262
|
+
* This method sanitizes the provided data, generates data groups,
|
|
263
|
+
* and updates the instance's state with the sanitized data and data groups.
|
|
264
|
+
*
|
|
265
|
+
* @param {any} newData - The new data to be set. This data will be cloned and sanitized.
|
|
266
|
+
* @returns {any} - The sanitized version of the provided data.
|
|
267
|
+
*/
|
|
268
|
+
setData(t) {
|
|
269
|
+
const e = this.sanitize(F(t)), s = this.generateDataGroups(e);
|
|
270
|
+
return this.set({
|
|
271
|
+
data: e,
|
|
272
|
+
dataGroups: s
|
|
273
|
+
}), e;
|
|
274
|
+
}
|
|
275
|
+
getDataGroups(t) {
|
|
276
|
+
return p(this.getOptions(), "data", "loading") ? [] : t ? this.get("dataGroups").filter((s) => t.includes(s.name)) : this.get("dataGroups");
|
|
277
|
+
}
|
|
278
|
+
getActiveDataGroups(t) {
|
|
279
|
+
const { ACTIVE: e } = E.items.status;
|
|
280
|
+
return this.getDataGroups(t).filter((s) => s.status === e);
|
|
281
|
+
}
|
|
282
|
+
getDataGroupNames(t) {
|
|
283
|
+
return this.getDataGroups(t).map((s) => s.name);
|
|
284
|
+
}
|
|
285
|
+
getActiveDataGroupNames(t) {
|
|
286
|
+
return this.getActiveDataGroups(t).map((s) => s.name);
|
|
287
|
+
}
|
|
288
|
+
aggregateBinDataByGroup(t) {
|
|
289
|
+
return yt(t, "group");
|
|
290
|
+
}
|
|
291
|
+
getBinConfigurations() {
|
|
292
|
+
const t = this.getDisplayData(), e = this.getOptions(), s = this.services.cartesianScales.getMainXAxisPosition(), a = this.services.cartesianScales.getDomainIdentifier(), n = e.axes[s], { groupMapsTo: o } = e.data, { bins: r = rt.defaultBins } = n, i = Array.isArray(r), l = Mt().value((f) => f[a]).thresholds(r)(t);
|
|
293
|
+
if (i)
|
|
294
|
+
l[l.length - 1].x1 = r[r.length - 1];
|
|
295
|
+
else {
|
|
296
|
+
const f = l[0].x1 - l[0].x0;
|
|
297
|
+
l[l.length - 1].x1 = +l[l.length - 1].x0 + f;
|
|
298
|
+
}
|
|
299
|
+
const c = i ? [r[0], r[r.length - 1]] : [l[0].x0, l[l.length - 1].x1], h = Array.from(new Set(t.map((f) => f[o]))), g = [];
|
|
300
|
+
return l.forEach((f) => {
|
|
301
|
+
const d = `${f.x0}-${f.x1}`, m = this.aggregateBinDataByGroup(f);
|
|
302
|
+
h.forEach((D) => {
|
|
303
|
+
g.push({
|
|
304
|
+
group: D,
|
|
305
|
+
key: d,
|
|
306
|
+
value: m[D] || 0,
|
|
307
|
+
bin: f.x0
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
}), {
|
|
311
|
+
bins: l,
|
|
312
|
+
binsDomain: c
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
getBinnedStackedData() {
|
|
316
|
+
const t = this.getOptions(), { groupMapsTo: e } = t.data, s = this.getActiveDataGroupNames(), { bins: a } = this.getBinConfigurations(), n = this.getDataValuesGroupedByKeys({
|
|
317
|
+
bins: a
|
|
318
|
+
});
|
|
319
|
+
return _().keys(s)(n).map((o, r) => Object.keys(o).filter((i) => !isNaN(i)).map((i) => {
|
|
320
|
+
const l = o[i];
|
|
321
|
+
return l[e] = s[r], l;
|
|
322
|
+
}));
|
|
323
|
+
}
|
|
324
|
+
getGroupedData(t) {
|
|
325
|
+
const e = this.getDisplayData(t), s = {}, { groupMapsTo: a } = this.getOptions().data;
|
|
326
|
+
return e.map((n) => {
|
|
327
|
+
const o = n[a];
|
|
328
|
+
s[o] !== null && s[o] !== void 0 ? s[o].push(n) : s[o] = [n];
|
|
329
|
+
}), Object.keys(s).map((n) => ({
|
|
330
|
+
name: n,
|
|
331
|
+
data: s[n]
|
|
332
|
+
}));
|
|
333
|
+
}
|
|
334
|
+
getStackKeys({ bins: t = null, groups: e = null } = { bins: null, groups: null }) {
|
|
335
|
+
const s = this.getOptions(), a = this.getDisplayData(e);
|
|
336
|
+
let n;
|
|
337
|
+
t ? n = t.map((i) => `${i.x0}:${i.x1}`) : n = $(
|
|
338
|
+
a.map((i) => {
|
|
339
|
+
const l = this.services.cartesianScales.getDomainIdentifier(i);
|
|
340
|
+
return i[l] instanceof Date ? z(i[l]) : i[l] && typeof i[l].toString == "function" ? i[l].toString() : i[l];
|
|
341
|
+
})
|
|
342
|
+
);
|
|
343
|
+
const o = this.services.cartesianScales.domainAxisPosition, r = s.axes[o].scaleType;
|
|
344
|
+
return r === b.TIME ? n.sort((i, l) => {
|
|
345
|
+
const c = new Date(i), h = new Date(l);
|
|
346
|
+
return c - h;
|
|
347
|
+
}) : (r === b.LOG || r === b.LINEAR) && n.sort((i, l) => i - l), n;
|
|
348
|
+
}
|
|
349
|
+
getDataValuesGroupedByKeys({ bins: t = null, groups: e = null }) {
|
|
350
|
+
const s = this.getOptions(), { groupMapsTo: a } = s.data, n = this.getDisplayData(e), o = this.getDataGroupNames(), r = this.getStackKeys({ bins: t, groups: e });
|
|
351
|
+
return t ? r.map((i) => {
|
|
352
|
+
const [l, c] = i.split(":"), h = { x0: l, x1: c }, g = t.find((f) => f.x0.toString() === l.toString());
|
|
353
|
+
return o.forEach((f) => {
|
|
354
|
+
h[f] = g.filter(
|
|
355
|
+
(d) => d[a] === f
|
|
356
|
+
).length;
|
|
357
|
+
}), h;
|
|
358
|
+
}) : r.map((i) => {
|
|
359
|
+
const l = { sharedStackKey: i };
|
|
360
|
+
return o.forEach((c) => {
|
|
361
|
+
const h = n.find((f) => {
|
|
362
|
+
const d = this.services.cartesianScales.getDomainIdentifier(f);
|
|
363
|
+
return f[a] === c && Object.prototype.hasOwnProperty.call(f, d) && (f[d] instanceof Date ? z(f[d]) === i : f[d].toString() === i);
|
|
364
|
+
}), g = this.services.cartesianScales.getRangeIdentifier(l);
|
|
365
|
+
l[c] = h ? h[g] : null;
|
|
366
|
+
}), l;
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
getStackedData({ percentage: t = !1, groups: e = null, divergent: s = !1 }) {
|
|
370
|
+
const a = this.getOptions(), { groupMapsTo: n } = a.data, o = this.getActiveDataGroupNames(e), r = this.getDataValuesGroupedByKeys({
|
|
371
|
+
groups: e
|
|
372
|
+
});
|
|
373
|
+
if (t) {
|
|
374
|
+
const l = dt(r.map((c) => [c.sharedStackKey, 0]));
|
|
375
|
+
r.forEach((c) => {
|
|
376
|
+
o.forEach((h) => {
|
|
377
|
+
l[c.sharedStackKey] += c[h];
|
|
378
|
+
});
|
|
379
|
+
}), r.forEach((c) => {
|
|
380
|
+
o.forEach((h) => {
|
|
381
|
+
const g = l[c.sharedStackKey];
|
|
382
|
+
l[c.sharedStackKey] ? c[h] = c[h] / g * 100 : c[h] = 0;
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
return (s ? _().offset(Et) : _()).keys(o)(r).map((l, c) => Object.keys(l).filter((h) => !isNaN(h)).map((h) => {
|
|
387
|
+
const g = l[h];
|
|
388
|
+
return g[n] = o[c], g;
|
|
389
|
+
}));
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Retrieves the current options from the instance's state.
|
|
393
|
+
*
|
|
394
|
+
* @returns {any} - The current options stored in the instance's state.
|
|
395
|
+
*/
|
|
396
|
+
getOptions() {
|
|
397
|
+
return this.state.options;
|
|
398
|
+
}
|
|
399
|
+
set(t, e) {
|
|
400
|
+
this.state = Object.assign({}, this.state, t);
|
|
401
|
+
const s = Object.assign(
|
|
402
|
+
{ skipUpdate: !1, animate: !0 },
|
|
403
|
+
// default configs
|
|
404
|
+
e
|
|
405
|
+
);
|
|
406
|
+
s.skipUpdate || this.update(s.animate);
|
|
407
|
+
}
|
|
408
|
+
get(t) {
|
|
409
|
+
return t ? this.state[t] : this.state;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Updates the current options for the instance.
|
|
413
|
+
*
|
|
414
|
+
* This method retrieves the existing options, updates the legend additional items,
|
|
415
|
+
* and merges the new options with the existing ones. The instance's state is then updated
|
|
416
|
+
* with the merged options.
|
|
417
|
+
*
|
|
418
|
+
* @param {any} newOptions - The new options to be set. These options will be merged with the existing options.
|
|
419
|
+
*/
|
|
420
|
+
setOptions(t) {
|
|
421
|
+
const e = this.getOptions();
|
|
422
|
+
H(e, t), this.set({
|
|
423
|
+
options: R(e, t)
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
*
|
|
428
|
+
* Updates miscellanous information within the model
|
|
429
|
+
* such as the color scales, or the legend data labels
|
|
430
|
+
*/
|
|
431
|
+
update(t = !0) {
|
|
432
|
+
this.getDisplayData() && (this.updateAllDataGroups(), this.setCustomColorScale(), this.setColorClassNames(), this.services.events.dispatchEvent(U.Model.UPDATE, { animate: t }));
|
|
433
|
+
}
|
|
434
|
+
/*
|
|
435
|
+
* Data labels
|
|
436
|
+
*/
|
|
437
|
+
toggleDataLabel(t) {
|
|
438
|
+
const { ACTIVE: e, DISABLED: s } = E.items.status, a = this.getDataGroups(), n = a.some((c) => c.status === s), o = a.filter((c) => c.status === e);
|
|
439
|
+
if (n)
|
|
440
|
+
if (o.length === 1 && o[0].name === t)
|
|
441
|
+
a.forEach((c, h) => {
|
|
442
|
+
a[h].status = e;
|
|
443
|
+
});
|
|
444
|
+
else {
|
|
445
|
+
const c = a.findIndex((h) => h.name === t);
|
|
446
|
+
a[c].status = a[c].status === s ? e : s;
|
|
447
|
+
}
|
|
448
|
+
else
|
|
449
|
+
a.forEach((c, h) => {
|
|
450
|
+
a[h].status = c.name === t ? e : s;
|
|
451
|
+
});
|
|
452
|
+
const r = a.filter((c) => c.status === e), i = this.getOptions();
|
|
453
|
+
a.some((c) => c.status === s) ? i.data.selectedGroups = r.map((c) => c.name) : i.data.selectedGroups = [], this.services.events.dispatchEvent(U.Legend.ITEMS_UPDATE, {
|
|
454
|
+
dataGroups: a
|
|
455
|
+
}), this.set({
|
|
456
|
+
dataGroups: a
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Should the data point be filled?
|
|
461
|
+
* @param group
|
|
462
|
+
* @param key
|
|
463
|
+
* @param data
|
|
464
|
+
* @param defaultFilled the default for this chart
|
|
465
|
+
*/
|
|
466
|
+
getIsFilled(t, e, s, a) {
|
|
467
|
+
const n = this.getOptions();
|
|
468
|
+
return n.getIsFilled ? n.getIsFilled(t, e, s, a) : a;
|
|
469
|
+
}
|
|
470
|
+
getFillColor(t, e, s) {
|
|
471
|
+
const a = this.getOptions(), n = p(this.colorScale, t);
|
|
472
|
+
return a.getFillColor ? a.getFillColor(t, e, s, n) : n;
|
|
473
|
+
}
|
|
474
|
+
getStrokeColor(t, e, s) {
|
|
475
|
+
const a = this.getOptions(), n = p(this.colorScale, t);
|
|
476
|
+
return a.getStrokeColor ? a.getStrokeColor(t, e, s, n) : n;
|
|
477
|
+
}
|
|
478
|
+
isUserProvidedColorScaleValid() {
|
|
479
|
+
const t = p(this.getOptions(), "color", "scale"), e = this.getDataGroups();
|
|
480
|
+
return t == null || Object.keys(t).length == 0 ? !1 : e.some(
|
|
481
|
+
(s) => Object.keys(t).includes(s.name)
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
getColorClassName(t) {
|
|
485
|
+
const e = this.colorClassNames(t.dataGroupName);
|
|
486
|
+
let s = t.originalClassName;
|
|
487
|
+
return t.classNameTypes.forEach(
|
|
488
|
+
(a) => s = t.originalClassName ? `${s} ${a}-${e}` : `${a}-${e}`
|
|
489
|
+
), s || "";
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* For charts that might hold an associated status for their dataset
|
|
493
|
+
*/
|
|
494
|
+
getStatus() {
|
|
495
|
+
return null;
|
|
496
|
+
}
|
|
497
|
+
getAllDataGroupsNames() {
|
|
498
|
+
return this.allDataGroups;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Converts data provided in the older format to tabular
|
|
502
|
+
*
|
|
503
|
+
*/
|
|
504
|
+
transformToTabularData(t) {
|
|
505
|
+
console.warn(
|
|
506
|
+
"We've updated the charting data format to be tabular by default. The current format you're using is deprecated and will be removed in v1.0, read more here https://charts.carbondesignsystem.com/"
|
|
507
|
+
);
|
|
508
|
+
const e = [], { datasets: s, labels: a } = t;
|
|
509
|
+
return s.forEach((n) => {
|
|
510
|
+
n.data.forEach((o, r) => {
|
|
511
|
+
let i;
|
|
512
|
+
const l = p(n, "label");
|
|
513
|
+
if (l === null) {
|
|
514
|
+
const h = p(a, r);
|
|
515
|
+
h ? i = h : i = "Ungrouped";
|
|
516
|
+
} else
|
|
517
|
+
i = l;
|
|
518
|
+
const c = {
|
|
519
|
+
group: i,
|
|
520
|
+
key: a[r]
|
|
521
|
+
};
|
|
522
|
+
isNaN(o) ? (c.value = o.value, c.date = o.date) : c.value = o, e.push(c);
|
|
523
|
+
});
|
|
524
|
+
}), e;
|
|
525
|
+
}
|
|
526
|
+
getTabularDataArray() {
|
|
527
|
+
return [];
|
|
528
|
+
}
|
|
529
|
+
exportToCSV() {
|
|
530
|
+
const e = this.getTabularDataArray().map(
|
|
531
|
+
(o) => o.map((r) => `"${(r === "–" ? "–" : r).split(/[,;'"`]/).map((c) => qt(c)).join("")}"`)
|
|
532
|
+
).map((o) => o.join(",")).join(`
|
|
533
|
+
`), s = this.getOptions();
|
|
534
|
+
let a = "myChart";
|
|
535
|
+
const n = p(s, "fileDownload", "fileName");
|
|
536
|
+
typeof n == "function" ? a = n("csv") : typeof n == "string" && (a = n), this.services.files.downloadCSV(e, `${a}.csv`);
|
|
537
|
+
}
|
|
538
|
+
getTabularData(t) {
|
|
539
|
+
return Array.isArray(t) ? t : this.transformToTabularData(t);
|
|
540
|
+
}
|
|
541
|
+
sanitize(t) {
|
|
542
|
+
return t = this.getTabularData(t), t;
|
|
543
|
+
}
|
|
544
|
+
/*
|
|
545
|
+
* Data groups
|
|
546
|
+
*/
|
|
547
|
+
updateAllDataGroups() {
|
|
548
|
+
this.allDataGroups ? this.getDataGroupNames().forEach((t) => {
|
|
549
|
+
this.allDataGroups.indexOf(t) === -1 && this.allDataGroups.push(t);
|
|
550
|
+
}) : this.allDataGroups = this.getDataGroupNames();
|
|
551
|
+
}
|
|
552
|
+
generateDataGroups(t) {
|
|
553
|
+
const { groupMapsTo: e } = this.getOptions().data, { ACTIVE: s, DISABLED: a } = E.items.status, n = this.getOptions(), o = $(t.map((i) => i[e]));
|
|
554
|
+
n.data.selectedGroups.length && (n.data.selectedGroups.every(
|
|
555
|
+
(l) => o.includes(l)
|
|
556
|
+
) || (n.data.selectedGroups = []));
|
|
557
|
+
const r = (i) => !n.data.selectedGroups.length || n.data.selectedGroups.includes(i) ? s : a;
|
|
558
|
+
return o.map((i) => ({
|
|
559
|
+
name: i,
|
|
560
|
+
status: r(i)
|
|
561
|
+
}));
|
|
562
|
+
}
|
|
563
|
+
/*
|
|
564
|
+
* Fill scales
|
|
565
|
+
*/
|
|
566
|
+
setCustomColorScale() {
|
|
567
|
+
if (!this.isUserProvidedColorScaleValid())
|
|
568
|
+
return;
|
|
569
|
+
const t = this.getOptions(), e = p(t, "color", "scale");
|
|
570
|
+
Object.keys(e).forEach((a) => {
|
|
571
|
+
this.allDataGroups.includes(a) || console.warn(`"${a}" does not exist in data groups.`);
|
|
572
|
+
}), this.allDataGroups.filter((a) => e[a]).forEach(
|
|
573
|
+
(a) => this.colorScale[a] = e[a]
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
/*
|
|
577
|
+
* Color palette
|
|
578
|
+
*/
|
|
579
|
+
setColorClassNames() {
|
|
580
|
+
const t = p(this.getOptions(), "color", "pairing");
|
|
581
|
+
let e = p(t, "numberOfVariants");
|
|
582
|
+
(!e || e < this.allDataGroups.length) && (e = this.allDataGroups.length);
|
|
583
|
+
let s = p(t, "option");
|
|
584
|
+
const a = Z.pairingOptions, n = e > 5 ? 14 : e, o = `${n}-color`;
|
|
585
|
+
s = s <= a[o] ? s : 1;
|
|
586
|
+
const r = this.allDataGroups.map(
|
|
587
|
+
(i, l) => `${n}-${s}-${l % 14 + 1}`
|
|
588
|
+
);
|
|
589
|
+
this.colorClassNames = Q().range(r).domain(this.allDataGroups);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
class M extends v {
|
|
593
|
+
// can't be protected as it's used by two-dimensional-axes.ts
|
|
594
|
+
constructor(t) {
|
|
595
|
+
super(t), this.axisFlavor = X.DEFAULT;
|
|
596
|
+
}
|
|
597
|
+
// get the scales information
|
|
598
|
+
// needed for getTabularArray()
|
|
599
|
+
assignRangeAndDomains() {
|
|
600
|
+
const { cartesianScales: t } = this.services, e = this.getOptions(), s = t.isDualAxes(), a = {
|
|
601
|
+
primaryDomain: t.domainAxisPosition,
|
|
602
|
+
primaryRange: t.rangeAxisPosition,
|
|
603
|
+
secondaryDomain: null,
|
|
604
|
+
secondaryRange: null
|
|
605
|
+
};
|
|
606
|
+
return s && (a.secondaryDomain = t.secondaryDomainAxisPosition, a.secondaryRange = t.secondaryRangeAxisPosition), Object.keys(a).forEach(
|
|
607
|
+
(n) => {
|
|
608
|
+
const o = a[n];
|
|
609
|
+
t.scales[o] ? a[n] = {
|
|
610
|
+
position: o,
|
|
611
|
+
label: t.getScaleLabel(o),
|
|
612
|
+
identifier: p(e, "axes", o, "mapsTo")
|
|
613
|
+
} : a[n] = null;
|
|
614
|
+
}
|
|
615
|
+
), a;
|
|
616
|
+
}
|
|
617
|
+
getTabularDataArray() {
|
|
618
|
+
const t = this.getDisplayData(), e = this.getOptions(), { groupMapsTo: s } = e.data, { primaryDomain: a, primaryRange: n, secondaryDomain: o, secondaryRange: r } = this.assignRangeAndDomains(), { number: i, code: l } = p(this.getOptions(), "locale"), c = [
|
|
619
|
+
"Group",
|
|
620
|
+
a.label,
|
|
621
|
+
n.label,
|
|
622
|
+
...o ? [o.label] : [],
|
|
623
|
+
...r ? [r.label] : []
|
|
624
|
+
], h = t.map((g) => [
|
|
625
|
+
g[s],
|
|
626
|
+
g[a.identifier] === null ? "–" : g[a.identifier],
|
|
627
|
+
g[n.identifier] === null || isNaN(g[n.identifier]) ? "–" : i(g[n.identifier], l),
|
|
628
|
+
...o ? [
|
|
629
|
+
g[o.identifier] === null ? "–" : g[o.identifier]
|
|
630
|
+
] : [],
|
|
631
|
+
...r ? [
|
|
632
|
+
g[r.identifier] === null || isNaN(g[r.identifier]) ? "–" : g[r.identifier]
|
|
633
|
+
] : []
|
|
634
|
+
]);
|
|
635
|
+
return super.formatTable({ headers: c, cells: h });
|
|
636
|
+
}
|
|
637
|
+
setData(t) {
|
|
638
|
+
let e;
|
|
639
|
+
if (t && (e = super.setData(t), p(this.getOptions(), "zoomBar", q.TOP, "enabled"))) {
|
|
640
|
+
const s = p(
|
|
641
|
+
this.getOptions(),
|
|
642
|
+
"zoomBar",
|
|
643
|
+
q.TOP,
|
|
644
|
+
"data"
|
|
645
|
+
);
|
|
646
|
+
this.setZoomBarData(s);
|
|
647
|
+
}
|
|
648
|
+
return e;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Sets the zoom bar data for the current instance.
|
|
652
|
+
*
|
|
653
|
+
* This method sanitizes the provided zoom bar data or uses the display data if no explicit
|
|
654
|
+
* zoom data is provided. It normalizes the zoom bar data by aggregating values based on unique
|
|
655
|
+
* dates and updates the instance's state with the normalized data.
|
|
656
|
+
*
|
|
657
|
+
* @param {any} [newZoomBarData] - The new zoom bar data to be set. If not provided, the display data will be used.
|
|
658
|
+
*/
|
|
659
|
+
setZoomBarData(t) {
|
|
660
|
+
const e = t ? this.sanitize(F(t)) : this.getDisplayData();
|
|
661
|
+
let s = e;
|
|
662
|
+
const { cartesianScales: a } = this.services;
|
|
663
|
+
if (e && a.domainAxisPosition && a.rangeAxisPosition) {
|
|
664
|
+
const n = a.getDomainIdentifier(), o = a.getRangeIdentifier();
|
|
665
|
+
let r = e.map((i) => i[n].getTime());
|
|
666
|
+
r = $(r).sort(), s = r.map((i) => {
|
|
667
|
+
let l = 0;
|
|
668
|
+
const c = {};
|
|
669
|
+
return e.forEach((h) => {
|
|
670
|
+
h[n].getTime() === i && (l += h[o]);
|
|
671
|
+
}), c[n] = new Date(i), c[o] = l, c;
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
this.set({ zoomBarData: s });
|
|
675
|
+
}
|
|
676
|
+
getZoomBarData() {
|
|
677
|
+
return this.get("zoomBarData");
|
|
678
|
+
}
|
|
679
|
+
sanitizeDateValues(t) {
|
|
680
|
+
const e = this.getOptions();
|
|
681
|
+
if (!e.axes)
|
|
682
|
+
return t;
|
|
683
|
+
const s = [];
|
|
684
|
+
return Object.keys(q).forEach((a) => {
|
|
685
|
+
const n = q[a], o = e.axes[n];
|
|
686
|
+
if (o && o.scaleType === b.TIME) {
|
|
687
|
+
const r = o.mapsTo;
|
|
688
|
+
(r !== null || r !== void 0) && s.push(r);
|
|
689
|
+
}
|
|
690
|
+
}), s.length > 0 && t.forEach((a) => {
|
|
691
|
+
s.forEach((n) => {
|
|
692
|
+
p(a, n, "getTime") === null && (a[n] = new Date(a[n]));
|
|
693
|
+
});
|
|
694
|
+
}), t;
|
|
695
|
+
}
|
|
696
|
+
sanitize(t) {
|
|
697
|
+
return t = super.sanitize(t), t = this.sanitizeDateValues(t), t;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
class kt extends M {
|
|
701
|
+
constructor(t) {
|
|
702
|
+
super(t);
|
|
703
|
+
}
|
|
704
|
+
getTabularDataArray() {
|
|
705
|
+
const t = this.getDisplayData(), { number: e, code: s } = p(this.getOptions(), "locale");
|
|
706
|
+
t.sort((o, r) => o.source.localeCompare(r.source));
|
|
707
|
+
const a = ["Source", "Target", "Value"], n = [
|
|
708
|
+
...t.map((o) => [
|
|
709
|
+
o.source,
|
|
710
|
+
o.target,
|
|
711
|
+
o.value === null ? "–" : e(o.value, s)
|
|
712
|
+
])
|
|
713
|
+
];
|
|
714
|
+
return super.formatTable({ headers: a, cells: n });
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
class Ft extends M {
|
|
718
|
+
constructor(t) {
|
|
719
|
+
super(t);
|
|
720
|
+
}
|
|
721
|
+
getBoxQuartiles(t) {
|
|
722
|
+
return {
|
|
723
|
+
q_25: V(t, 0.25),
|
|
724
|
+
q_50: V(t, 0.5),
|
|
725
|
+
q_75: V(t, 0.75)
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
getBoxplotData() {
|
|
729
|
+
const t = this.getOptions(), { groupMapsTo: e } = t.data, s = this.getGroupedData(), a = [];
|
|
730
|
+
for (const { name: n, data: o } of s) {
|
|
731
|
+
const r = this.services.cartesianScales.getRangeIdentifier(), i = o.map((y) => y[r]).sort(w), l = {
|
|
732
|
+
[e]: n,
|
|
733
|
+
counts: i,
|
|
734
|
+
quartiles: this.getBoxQuartiles(i),
|
|
735
|
+
outliers: null,
|
|
736
|
+
whiskers: null
|
|
737
|
+
}, c = l.quartiles.q_25, h = l.quartiles.q_75, g = (h - c) * 1.5, f = c - g, d = h + g, m = [], D = [];
|
|
738
|
+
for (const y of i)
|
|
739
|
+
y < f || y > d ? m.push(y) : D.push(y);
|
|
740
|
+
l.outliers = m;
|
|
741
|
+
const x = P(D), O = k(D);
|
|
742
|
+
l.whiskers = {
|
|
743
|
+
min: x || P([l.quartiles.q_25, l.quartiles.q_50, l.quartiles.q_75]),
|
|
744
|
+
max: O || k([l.quartiles.q_25, l.quartiles.q_50, l.quartiles.q_75])
|
|
745
|
+
}, a.push(l);
|
|
746
|
+
}
|
|
747
|
+
return a;
|
|
748
|
+
}
|
|
749
|
+
getTabularDataArray() {
|
|
750
|
+
const t = this.getOptions(), { groupMapsTo: e } = t.data, s = this.getBoxplotData(), { number: a, code: n } = p(t, "locale"), o = ["Group", "Minimum", "Q1", "Median", "Q3", "Maximum", "IQR", "Outlier(s)"], r = [
|
|
751
|
+
...s.map((i) => {
|
|
752
|
+
let l = p(i, "outliers");
|
|
753
|
+
return (l === null || l.length === 0) && (l = ["–"]), [
|
|
754
|
+
i[e],
|
|
755
|
+
p(i, "whiskers", "min") !== null ? a(p(i, "whiskers", "min"), n) : "–",
|
|
756
|
+
p(i, "quartiles", "q_25") !== null ? a(p(i, "quartiles", "q_25"), n) : "–",
|
|
757
|
+
p(i, "quartiles", "q_50") !== null ? a(p(i, "quartiles", "q_50"), n) : "–",
|
|
758
|
+
p(i, "quartiles", "q_75") !== null ? a(p(i, "quartiles", "q_75"), n) : "–",
|
|
759
|
+
p(i, "whiskers", "max") !== null ? a(p(i, "whiskers", "max"), n) : "–",
|
|
760
|
+
p(i, "quartiles", "q_75") !== null && p(i, "quartiles", "q_25") !== null ? (a(
|
|
761
|
+
p(i, "quartiles", "q_75") - p(i, "quartiles", "q_25")
|
|
762
|
+
), n) : "–",
|
|
763
|
+
l.map((c) => a(c, n)).join(",")
|
|
764
|
+
];
|
|
765
|
+
})
|
|
766
|
+
];
|
|
767
|
+
return super.formatTable({ headers: o, cells: r });
|
|
768
|
+
}
|
|
769
|
+
setColorClassNames() {
|
|
770
|
+
const e = p(this.getOptions(), "color", "pairing");
|
|
771
|
+
let s = p(e, "option");
|
|
772
|
+
const a = Z.pairingOptions;
|
|
773
|
+
s = s <= a["1-color"] ? s : 1;
|
|
774
|
+
const n = this.allDataGroups.map(() => `1-${s}-1`);
|
|
775
|
+
this.colorClassNames = Q().range(n).domain(this.allDataGroups);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
class Bt extends M {
|
|
779
|
+
constructor(t) {
|
|
780
|
+
super(t);
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* Determines the index of the performance area titles to use
|
|
784
|
+
* @param datum
|
|
785
|
+
* @returns number
|
|
786
|
+
*/
|
|
787
|
+
getMatchingRangeIndexForDatapoint(t) {
|
|
788
|
+
let e;
|
|
789
|
+
for (let s = t.ranges.length - 1; s > 0; s--) {
|
|
790
|
+
const a = t.ranges[s];
|
|
791
|
+
if (t.value >= a)
|
|
792
|
+
return e = s, e;
|
|
793
|
+
}
|
|
794
|
+
return 0;
|
|
795
|
+
}
|
|
796
|
+
getTabularDataArray() {
|
|
797
|
+
const t = this.getDisplayData(), e = this.getOptions(), { groupMapsTo: s } = e.data, a = this.services.cartesianScales.getRangeIdentifier(), { number: n, code: o } = p(e, "locale"), r = p(e, "bullet", "performanceAreaTitles"), i = ["Title", "Group", "Value", "Target", "Percentage", "Performance"], l = [
|
|
798
|
+
...t.map((c) => [
|
|
799
|
+
c.title,
|
|
800
|
+
c[s],
|
|
801
|
+
c.value === null ? "–" : n(c.value, o),
|
|
802
|
+
p(c, "marker") === null ? "–" : n(c.marker, o),
|
|
803
|
+
p(c, "marker") === null ? "–" : `${n(Math.floor(c[a] / c.marker * 100), o)}%`,
|
|
804
|
+
r[this.getMatchingRangeIndexForDatapoint(c)]
|
|
805
|
+
])
|
|
806
|
+
];
|
|
807
|
+
return super.formatTable({ headers: i, cells: l });
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
class Vt extends v {
|
|
811
|
+
constructor(t) {
|
|
812
|
+
super(t), this._colorScale = void 0, this._matrix = {};
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* @override
|
|
816
|
+
* @param value
|
|
817
|
+
* @returns string
|
|
818
|
+
*/
|
|
819
|
+
getFillColor(t) {
|
|
820
|
+
return this._colorScale(t);
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Helper function that will generate a dictionary
|
|
824
|
+
*/
|
|
825
|
+
getCombinedData() {
|
|
826
|
+
if (C(this._matrix)) {
|
|
827
|
+
const t = this.getOptions(), e = this.getDisplayData();
|
|
828
|
+
!C(e) && !C(t.geoData.objects.countries) && (t.geoData.objects.countries.geometries.forEach((s) => {
|
|
829
|
+
this._matrix[s.properties.NAME] = s;
|
|
830
|
+
}), e.forEach((s) => {
|
|
831
|
+
this._matrix[s.name] ? this._matrix[s.name].value = s.value || null : console.warn(`Data point ${s} is missing geographical data.`);
|
|
832
|
+
}));
|
|
833
|
+
}
|
|
834
|
+
return this._matrix;
|
|
835
|
+
}
|
|
836
|
+
/**
|
|
837
|
+
* Generate tabular data from display data
|
|
838
|
+
* @returns Array<Object>
|
|
839
|
+
*/
|
|
840
|
+
getTabularDataArray() {
|
|
841
|
+
const t = this.getDisplayData(), { number: e, code: s } = p(this.getOptions(), "locale"), a = ["Country ID", "Country Name", "Value"], n = [
|
|
842
|
+
...t.map((o) => [
|
|
843
|
+
o.id === null ? "–" : o.id,
|
|
844
|
+
o.name,
|
|
845
|
+
o.value === null ? "–" : e(o.value, s)
|
|
846
|
+
])
|
|
847
|
+
];
|
|
848
|
+
return super.formatTable({ headers: a, cells: n });
|
|
849
|
+
}
|
|
850
|
+
// Uses quantize scale to return class names
|
|
851
|
+
getColorClassName(t) {
|
|
852
|
+
return `${t.originalClassName} ${this._colorScale(t.value)}`;
|
|
853
|
+
}
|
|
854
|
+
setColorClassNames() {
|
|
855
|
+
const t = p(this.getOptions(), "color");
|
|
856
|
+
this._colorScale = W(this.getDisplayData(), t);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
class _t extends v {
|
|
860
|
+
constructor(t) {
|
|
861
|
+
super(t), this.parentNode = !1, this.set({ depth: 2 }, { skipUpdate: !0 });
|
|
862
|
+
}
|
|
863
|
+
setData(t) {
|
|
864
|
+
super.setData(t), this.setDataGroups(), t.length === 1 && (this.parentNode = !0), this.setZoom();
|
|
865
|
+
}
|
|
866
|
+
setOptions(t) {
|
|
867
|
+
const e = this.getOptions(), s = R({}, t, this.getZoomOptions(t));
|
|
868
|
+
H(e, s);
|
|
869
|
+
const a = this.getHierarchyLevel(), n = p(e, "circlePack", "hierarchyLevel");
|
|
870
|
+
this.set({
|
|
871
|
+
options: R(e, s),
|
|
872
|
+
depth: n && n < 4 ? n : a
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
getZoomOptions(t) {
|
|
876
|
+
if (!this.getDisplayData())
|
|
877
|
+
return {};
|
|
878
|
+
const e = this.getDisplayData(), s = t || this.getOptions(), a = e.length === 1 && p(e, 0, "children") ? p(e, 0, "children") : e;
|
|
879
|
+
let n = this.getHierarchyLevel();
|
|
880
|
+
return a.some((o) => {
|
|
881
|
+
if (o.children && o.children.some((r) => r.children))
|
|
882
|
+
return n = 3, !1;
|
|
883
|
+
}), p(s, "canvasZoom", "enabled") === !0 && n > 2 ? {
|
|
884
|
+
legend: {
|
|
885
|
+
additionalItems: [
|
|
886
|
+
{
|
|
887
|
+
type: ct.ZOOM,
|
|
888
|
+
name: "Click to zoom"
|
|
889
|
+
}
|
|
890
|
+
]
|
|
891
|
+
}
|
|
892
|
+
} : null;
|
|
893
|
+
}
|
|
894
|
+
setZoom(t) {
|
|
895
|
+
this.setOptions(this.getZoomOptions(t));
|
|
896
|
+
}
|
|
897
|
+
// update the hierarchy level
|
|
898
|
+
updateHierarchyLevel(t) {
|
|
899
|
+
this.set({ depth: t });
|
|
900
|
+
}
|
|
901
|
+
getHierarchyLevel() {
|
|
902
|
+
return this.get("depth");
|
|
903
|
+
}
|
|
904
|
+
hasParentNode() {
|
|
905
|
+
return this.parentNode;
|
|
906
|
+
}
|
|
907
|
+
// set the datagroup name on the items that are it's children
|
|
908
|
+
setDataGroups() {
|
|
909
|
+
const t = this.getData(), e = this.getOptions(), { groupMapsTo: s } = e.data, a = t.map((n) => {
|
|
910
|
+
const o = n[s];
|
|
911
|
+
return this.setChildrenDataGroup(n, o);
|
|
912
|
+
});
|
|
913
|
+
this.set(
|
|
914
|
+
{
|
|
915
|
+
data: a
|
|
916
|
+
},
|
|
917
|
+
{ skipUpdate: !0 }
|
|
918
|
+
);
|
|
919
|
+
}
|
|
920
|
+
// sets name recursively down the node tree
|
|
921
|
+
setChildrenDataGroup(t, e) {
|
|
922
|
+
return t.children ? {
|
|
923
|
+
...t,
|
|
924
|
+
dataGroupName: e,
|
|
925
|
+
children: t.children.map((s) => this.setChildrenDataGroup(s, e))
|
|
926
|
+
} : { ...t, dataGroupName: e };
|
|
927
|
+
}
|
|
928
|
+
getTabularDataArray() {
|
|
929
|
+
const t = this.getDisplayData(), { number: e, code: s } = p(this.getOptions(), "locale"), a = ["Child", "Parent", "Value"], n = [];
|
|
930
|
+
return t.forEach((o) => {
|
|
931
|
+
let r = o.value ? o.value : 0;
|
|
932
|
+
o.children && (r += this.getChildrenDatums(o.children, o.name, n, 0)), n.push(["–", o.name, e(r, s)]);
|
|
933
|
+
}), super.formatTable({ headers: a, cells: n });
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* Recursively determine the relationship between all the nested elements in the child
|
|
937
|
+
* @private
|
|
938
|
+
* @param {any} children - The children nodes to process.
|
|
939
|
+
* @param {any} parent - The parent node associated with the children.
|
|
940
|
+
* @param {string[][]} [result=[]] - An array to accumulate the resulting data.
|
|
941
|
+
* @param {number} [totalSum=0] - The running total sum of values processed.
|
|
942
|
+
* @returns {number} Sum.
|
|
943
|
+
*/
|
|
944
|
+
getChildrenDatums(t, e, s = [], a = 0) {
|
|
945
|
+
const n = e, { number: o, code: r } = p(this.getOptions(), "locale");
|
|
946
|
+
return t.forEach((i) => {
|
|
947
|
+
const l = i.name;
|
|
948
|
+
let c = 0;
|
|
949
|
+
if (i.children)
|
|
950
|
+
i.children.length > 0 && (typeof i.value == "number" && (a += i.value), c += this.getChildrenDatums(i.children, l, s, c), s.push([l, n, o(c, r)]), a += c);
|
|
951
|
+
else {
|
|
952
|
+
let h = 0;
|
|
953
|
+
typeof i.value == "number" && (h = i.value, a += i.value), s.push([i.name, n, o(h, r)]);
|
|
954
|
+
}
|
|
955
|
+
}), a;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
class wt extends v {
|
|
959
|
+
constructor(t) {
|
|
960
|
+
super(t);
|
|
961
|
+
}
|
|
962
|
+
getTabularData(t) {
|
|
963
|
+
const e = super.getTabularData(t);
|
|
964
|
+
return t !== e && e.forEach((s) => {
|
|
965
|
+
s.key && s.key !== s.group && (s.group = s.key);
|
|
966
|
+
}), e;
|
|
967
|
+
}
|
|
968
|
+
getTabularDataArray() {
|
|
969
|
+
const t = this.getDisplayData(), e = this.getOptions(), { groupMapsTo: s } = e.data, { valueMapsTo: a } = e.pie, { number: n, code: o } = p(e, "locale"), r = ["Group", "Value"], i = [
|
|
970
|
+
...t.map((l) => [
|
|
971
|
+
l[s],
|
|
972
|
+
l[a] === null ? "–" : n(l[a], o)
|
|
973
|
+
])
|
|
974
|
+
];
|
|
975
|
+
return super.formatTable({ headers: r, cells: i });
|
|
976
|
+
}
|
|
977
|
+
sanitize(t) {
|
|
978
|
+
return this.getTabularData(t).sort((s, a) => a.value - s.value);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
class Lt extends v {
|
|
982
|
+
constructor(t) {
|
|
983
|
+
super(t);
|
|
984
|
+
}
|
|
985
|
+
getDataGroups() {
|
|
986
|
+
return super.getDataGroups().filter((t) => t.name !== "delta");
|
|
987
|
+
}
|
|
988
|
+
getTabularDataArray() {
|
|
989
|
+
const t = this.getDisplayData(), e = this.getOptions(), { groupMapsTo: s } = e.data, { number: a, code: n } = p(this.getOptions(), "locale"), o = ["Group", "Value"], r = [
|
|
990
|
+
...t.map((i) => [
|
|
991
|
+
i[s],
|
|
992
|
+
i.value === null ? "–" : a(i.value, n)
|
|
993
|
+
])
|
|
994
|
+
];
|
|
995
|
+
return super.formatTable({ headers: o, cells: r });
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
class $t extends M {
|
|
999
|
+
constructor(t) {
|
|
1000
|
+
super(t), this.axisFlavor = X.HOVERABLE, this._colorScale = void 0, this._domains = [], this._ranges = [], this._matrix = {};
|
|
1001
|
+
const e = p(this.getOptions(), "axes");
|
|
1002
|
+
if (p(e, "left", "scaleType") && p(e, "left", "scaleType") !== b.LABELS || p(e, "right", "scaleType") && p(e, "right", "scaleType") !== b.LABELS || p(e, "top", "scaleType") && p(e, "top", "scaleType") !== b.LABELS || p(e, "bottom", "scaleType") && p(e, "bottom", "scaleType") !== b.LABELS)
|
|
1003
|
+
throw Error("Heatmap only supports label scaletypes.");
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Get min and maximum value of the display data
|
|
1007
|
+
* @returns Array consisting of smallest and largest values in data
|
|
1008
|
+
*/
|
|
1009
|
+
getValueDomain() {
|
|
1010
|
+
const t = N(this.getDisplayData(), (s) => s.value), e = it().domain(t).nice().domain();
|
|
1011
|
+
if (e[0] > 0)
|
|
1012
|
+
e[0] = 0;
|
|
1013
|
+
else if (e[0] === 0 && e[1] === 0)
|
|
1014
|
+
return [0, 1];
|
|
1015
|
+
return e[0] < 0 && e[1] > 0 && (Math.abs(e[0]) > e[1] ? e[1] = Math.abs(e[0]) : e[0] = -e[1]), e;
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* @override
|
|
1019
|
+
* @param value
|
|
1020
|
+
* @returns string
|
|
1021
|
+
*/
|
|
1022
|
+
getFillColor(t) {
|
|
1023
|
+
return this._colorScale(t);
|
|
1024
|
+
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Generate a list of all unique domains
|
|
1027
|
+
* @returns String[]
|
|
1028
|
+
*/
|
|
1029
|
+
getUniqueDomain() {
|
|
1030
|
+
if (C(this._domains)) {
|
|
1031
|
+
const t = this.getDisplayData(), { cartesianScales: e } = this.services, s = e.getDomainIdentifier(), a = e.getMainXAxisPosition(), n = e.getCustomDomainValuesByposition(a);
|
|
1032
|
+
if (n)
|
|
1033
|
+
return n;
|
|
1034
|
+
this._domains = Array.from(
|
|
1035
|
+
new Set(
|
|
1036
|
+
t.map((o) => o[s])
|
|
1037
|
+
)
|
|
1038
|
+
);
|
|
1039
|
+
}
|
|
1040
|
+
return this._domains;
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Generates a list of all unique ranges
|
|
1044
|
+
* @returns String[]
|
|
1045
|
+
*/
|
|
1046
|
+
getUniqueRanges() {
|
|
1047
|
+
if (C(this._ranges)) {
|
|
1048
|
+
const t = this.getDisplayData(), { cartesianScales: e } = this.services, s = e.getRangeIdentifier(), a = e.getMainYAxisPosition(), n = e.getCustomDomainValuesByposition(a);
|
|
1049
|
+
if (n)
|
|
1050
|
+
return n;
|
|
1051
|
+
this._ranges = Array.from(
|
|
1052
|
+
new Set(
|
|
1053
|
+
t.map((o) => o[s])
|
|
1054
|
+
)
|
|
1055
|
+
);
|
|
1056
|
+
}
|
|
1057
|
+
return this._ranges;
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* Generates a matrix (If doesn't exist) and returns it
|
|
1061
|
+
* @returns Object
|
|
1062
|
+
*/
|
|
1063
|
+
getMatrix() {
|
|
1064
|
+
if (C(this._matrix)) {
|
|
1065
|
+
const t = this.getUniqueDomain(), e = this.getUniqueRanges(), s = this.services.cartesianScales.getDomainIdentifier(), a = this.services.cartesianScales.getRangeIdentifier(), n = {};
|
|
1066
|
+
e.forEach((o) => {
|
|
1067
|
+
n[o] = {
|
|
1068
|
+
value: null,
|
|
1069
|
+
index: -1
|
|
1070
|
+
};
|
|
1071
|
+
}), t.forEach((o) => {
|
|
1072
|
+
this._matrix[o] = F(n);
|
|
1073
|
+
}), this.getDisplayData().forEach((o, r) => {
|
|
1074
|
+
this._matrix[o[s]][o[a]] = {
|
|
1075
|
+
value: o.value,
|
|
1076
|
+
index: r
|
|
1077
|
+
};
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
return this._matrix;
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Sets the data for the current instance.
|
|
1084
|
+
*
|
|
1085
|
+
* This method sanitizes the provided data, generates data groups,
|
|
1086
|
+
* and updates the instance's state with the sanitized data and data groups.
|
|
1087
|
+
* It also resets the `_domains`, `_ranges`, and `_matrix` attributes to their empty states.
|
|
1088
|
+
*
|
|
1089
|
+
* @param {any} newData - The new data to be set. This data will be cloned and sanitized.
|
|
1090
|
+
* @returns {any} - The sanitized version of the provided data.
|
|
1091
|
+
*/
|
|
1092
|
+
setData(t) {
|
|
1093
|
+
const e = this.sanitize(F(t)), s = this.generateDataGroups(e);
|
|
1094
|
+
return this.set({
|
|
1095
|
+
data: e,
|
|
1096
|
+
dataGroups: s
|
|
1097
|
+
}), this._domains = [], this._ranges = [], this._matrix = {}, e;
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* Converts Object matrix into a single array
|
|
1101
|
+
* @returns object[]
|
|
1102
|
+
*/
|
|
1103
|
+
getMatrixAsArray() {
|
|
1104
|
+
C(this._matrix) && this.getMatrix();
|
|
1105
|
+
const t = this.getUniqueDomain(), e = this.getUniqueRanges(), s = this.services.cartesianScales.getDomainIdentifier(), a = this.services.cartesianScales.getRangeIdentifier(), n = [];
|
|
1106
|
+
return t.forEach((o) => {
|
|
1107
|
+
e.forEach((r) => {
|
|
1108
|
+
const i = {
|
|
1109
|
+
value: this._matrix[o][r].value,
|
|
1110
|
+
index: this._matrix[o][r].index
|
|
1111
|
+
};
|
|
1112
|
+
i[s] = o, i[a] = r, n.push(i);
|
|
1113
|
+
});
|
|
1114
|
+
}), n;
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Generate tabular data from display data
|
|
1118
|
+
* @returns Array<Object>
|
|
1119
|
+
*/
|
|
1120
|
+
getTabularDataArray() {
|
|
1121
|
+
const t = this.getDisplayData(), { primaryDomain: e, primaryRange: s } = this.assignRangeAndDomains(), { number: a, code: n } = p(this.getOptions(), "locale"), o = [e.label, s.label, "Value"], r = [
|
|
1122
|
+
...t.map((i) => [
|
|
1123
|
+
i[e.identifier] === null ? "–" : i[e.identifier],
|
|
1124
|
+
i[s.identifier] === null ? "–" : i[s.identifier],
|
|
1125
|
+
i.value === null ? "–" : a(i.value, n)
|
|
1126
|
+
])
|
|
1127
|
+
];
|
|
1128
|
+
return super.formatTable({ headers: o, cells: r });
|
|
1129
|
+
}
|
|
1130
|
+
// Uses quantize scale to return class names
|
|
1131
|
+
getColorClassName(t) {
|
|
1132
|
+
return `${t.originalClassName} ${this._colorScale(t.value)}`;
|
|
1133
|
+
}
|
|
1134
|
+
setColorClassNames() {
|
|
1135
|
+
const t = this.getOptions(), e = p(t, "color", "gradient", "colors"), s = !C(e);
|
|
1136
|
+
let a = p(t, "color", "pairing", "option");
|
|
1137
|
+
const n = this.getValueDomain(), o = n[0] < 0 && n[1] > 0 ? "diverge" : "mono";
|
|
1138
|
+
(a < 1 && a > 4 && o === "mono" || a < 1 && a > 2 && o === "diverge") && (a = 1);
|
|
1139
|
+
const r = s ? e : [];
|
|
1140
|
+
if (!s) {
|
|
1141
|
+
const l = o === "diverge" ? 17 : 11;
|
|
1142
|
+
for (let c = 1; c < l + 1; c++)
|
|
1143
|
+
r.push(`fill-${o}-${a}-${c}`);
|
|
1144
|
+
}
|
|
1145
|
+
this._colorScale = lt().domain(n).range(r);
|
|
1146
|
+
const i = p(this.getOptions(), "color");
|
|
1147
|
+
this._colorScale = W(this.getDisplayData(), i);
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
class Rt extends M {
|
|
1151
|
+
getTabularDataArray() {
|
|
1152
|
+
const t = this.getOptions(), { groupMapsTo: e } = t.data, { number: s, code: a } = p(this.getOptions(), "locale"), n = this.getBinnedStackedData(), o = [
|
|
1153
|
+
A(t, "bins.rangeLabel") || "Range",
|
|
1154
|
+
...n.map((i) => A(i, `0.${e}`))
|
|
1155
|
+
], r = [
|
|
1156
|
+
...A(n, 0).map((i, l) => [
|
|
1157
|
+
`${s(Number(A(i, "data.x0")), a)} – ${s(
|
|
1158
|
+
Number(A(i, "data.x1")),
|
|
1159
|
+
a
|
|
1160
|
+
)}`,
|
|
1161
|
+
...n.map(
|
|
1162
|
+
(c) => s(A(c[l], `data.${A(c[l], e)}`), a)
|
|
1163
|
+
)
|
|
1164
|
+
])
|
|
1165
|
+
];
|
|
1166
|
+
return super.formatTable({ headers: o, cells: r });
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
class zt extends v {
|
|
1170
|
+
constructor(t) {
|
|
1171
|
+
super(t);
|
|
1172
|
+
}
|
|
1173
|
+
getMaximumDomain(t) {
|
|
1174
|
+
return t.reduce((s, a) => s + a.value, 0);
|
|
1175
|
+
}
|
|
1176
|
+
/**
|
|
1177
|
+
* Use a provided color for the bar or default to carbon color if no status provided.
|
|
1178
|
+
* Defaults to carbon color otherwise.
|
|
1179
|
+
* @param group dataset group label
|
|
1180
|
+
*/
|
|
1181
|
+
getFillColor(t) {
|
|
1182
|
+
const e = this.getOptions(), s = p(e, "color", "scale"), a = this.getStatus();
|
|
1183
|
+
return s || !a ? super.getFillColor(t) : null;
|
|
1184
|
+
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Get the associated status for the data by checking the ranges
|
|
1187
|
+
*/
|
|
1188
|
+
getStatus() {
|
|
1189
|
+
const t = this.getOptions(), e = p(this.getDisplayData()), s = (e == null ? void 0 : e.reduce((o, r) => o + r.value, 0)) ?? 0, a = p(t, "meter", "proportional") ? s : s > 100 ? 100 : s, n = p(t, "meter", "status", "ranges");
|
|
1190
|
+
if (n) {
|
|
1191
|
+
const o = n.filter(
|
|
1192
|
+
(r) => r.range[0] <= a && a <= r.range[1]
|
|
1193
|
+
);
|
|
1194
|
+
if (o.length > 0)
|
|
1195
|
+
return o[0].status;
|
|
1196
|
+
}
|
|
1197
|
+
return null;
|
|
1198
|
+
}
|
|
1199
|
+
getTabularDataArray() {
|
|
1200
|
+
const t = this.getDisplayData(), e = this.getOptions(), { groupMapsTo: s } = e.data, a = this.getStatus(), n = p(e, "meter", "proportional"), { number: o, code: r } = p(this.getOptions(), "locale");
|
|
1201
|
+
let i = [], l = [], c;
|
|
1202
|
+
if (n === null) {
|
|
1203
|
+
c = 100;
|
|
1204
|
+
const h = t[0];
|
|
1205
|
+
i = ["Group", "Value", ...a ? ["Status"] : []], l = [
|
|
1206
|
+
[
|
|
1207
|
+
h[s],
|
|
1208
|
+
h.value === null ? "–" : o(h.value, r),
|
|
1209
|
+
...a ? [a] : []
|
|
1210
|
+
]
|
|
1211
|
+
];
|
|
1212
|
+
} else {
|
|
1213
|
+
const h = p(n, "total");
|
|
1214
|
+
c = h || this.getMaximumDomain(t), i = ["Group", "Value", "Percentage of total"], l = [
|
|
1215
|
+
...t.map((g) => {
|
|
1216
|
+
let f;
|
|
1217
|
+
g.value !== null && g.value !== void 0 ? f = Number(g.value) : f = 0;
|
|
1218
|
+
const d = Number((g.value / c * 100).toFixed(2));
|
|
1219
|
+
return [
|
|
1220
|
+
g[s],
|
|
1221
|
+
g.value === null ? "–" : o(f, r),
|
|
1222
|
+
o(d, r) + " %"
|
|
1223
|
+
];
|
|
1224
|
+
})
|
|
1225
|
+
];
|
|
1226
|
+
}
|
|
1227
|
+
return super.formatTable({ headers: i, cells: l });
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
class Ut extends M {
|
|
1231
|
+
constructor(t) {
|
|
1232
|
+
super(t);
|
|
1233
|
+
}
|
|
1234
|
+
getTabularDataArray() {
|
|
1235
|
+
const t = this.getOptions(), e = this.getGroupedData(), { angle: s, value: a } = p(t, "radar", "axes"), { number: n, code: o } = p(t, "locale"), r = p(e, "0", "data").map((c) => c[s]), i = ["Group", ...r], l = [
|
|
1236
|
+
...e.map((c) => [
|
|
1237
|
+
c.name,
|
|
1238
|
+
...r.map(
|
|
1239
|
+
(h, g) => p(c, "data", g, a) !== null ? n(p(c, "data", g, a), o) : "–"
|
|
1240
|
+
)
|
|
1241
|
+
])
|
|
1242
|
+
];
|
|
1243
|
+
return super.formatTable({ headers: i, cells: l });
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
class Kt extends v {
|
|
1247
|
+
constructor(t) {
|
|
1248
|
+
super(t);
|
|
1249
|
+
}
|
|
1250
|
+
/**
|
|
1251
|
+
* Retrieves and formats tabular data from the display data.
|
|
1252
|
+
*
|
|
1253
|
+
* @returns {any[]} An object containing the headers and cells of the tabular data.
|
|
1254
|
+
*/
|
|
1255
|
+
getTabularDataArray() {
|
|
1256
|
+
const t = this.getDisplayData(), e = ["Child", "Parent"], s = [];
|
|
1257
|
+
return t.forEach((a) => {
|
|
1258
|
+
this.getChildrenDatums(a, s), s.push([a.name, "–"]);
|
|
1259
|
+
}), super.formatTable({ headers: e, cells: s });
|
|
1260
|
+
}
|
|
1261
|
+
/**
|
|
1262
|
+
* Determine the child parent relationship in nested data
|
|
1263
|
+
* @private
|
|
1264
|
+
* @param {any} datum - The datum node to process.
|
|
1265
|
+
* @param {any[]} [result=[]] - An array to accumulate the resulting data.
|
|
1266
|
+
* @returns {any[]} The accumulated result array.
|
|
1267
|
+
*/
|
|
1268
|
+
getChildrenDatums(t, e = []) {
|
|
1269
|
+
t.children && t.children.length > 0 && t.children.forEach((s) => {
|
|
1270
|
+
this.getChildrenDatums(s, e), e.push([s.name, t.name]);
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
class jt extends v {
|
|
1275
|
+
constructor(t) {
|
|
1276
|
+
super(t);
|
|
1277
|
+
}
|
|
1278
|
+
getTabularDataArray() {
|
|
1279
|
+
const t = this.getDisplayData(), { number: e, code: s } = p(this.getOptions(), "locale"), a = ["Child", "Group", "Value"], n = [];
|
|
1280
|
+
return t.forEach((o) => {
|
|
1281
|
+
Array.isArray(o.children) ? o.children.forEach((r) => {
|
|
1282
|
+
n.push([
|
|
1283
|
+
r.name,
|
|
1284
|
+
o.name,
|
|
1285
|
+
r.value === null ? "–" : e(r.value, s)
|
|
1286
|
+
]);
|
|
1287
|
+
}) : p(o.name) !== null && p(o.value) && n.push(["–", o.name, e(o.value, s)]);
|
|
1288
|
+
}), super.formatTable({ headers: a, cells: n });
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
class Ht extends v {
|
|
1292
|
+
constructor(t) {
|
|
1293
|
+
super(t);
|
|
1294
|
+
}
|
|
1295
|
+
getTabularDataArray() {
|
|
1296
|
+
const t = this.getDisplayData(), e = this.getOptions(), { fontSizeMapsTo: s, wordMapsTo: a } = e.wordCloud, { groupMapsTo: n } = e.data, { code: o, number: r } = p(e, "locale"), i = [e.tooltip.wordLabel, "Group", e.tooltip.valueLabel], l = [
|
|
1297
|
+
...t.map((c) => [
|
|
1298
|
+
c[a],
|
|
1299
|
+
c[n],
|
|
1300
|
+
r(c[s], o)
|
|
1301
|
+
])
|
|
1302
|
+
];
|
|
1303
|
+
return super.formatTable({ headers: i, cells: l });
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
2
1306
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1307
|
+
kt as AlluvialChartModel,
|
|
1308
|
+
Ft as BoxplotChartModel,
|
|
1309
|
+
Bt as BulletChartModel,
|
|
1310
|
+
v as ChartModel,
|
|
1311
|
+
Rt as ChartModelBinned,
|
|
1312
|
+
M as ChartModelCartesian,
|
|
1313
|
+
Vt as ChoroplethModel,
|
|
1314
|
+
_t as CirclePackChartModel,
|
|
1315
|
+
Lt as GaugeChartModel,
|
|
1316
|
+
$t as HeatmapModel,
|
|
1317
|
+
zt as MeterChartModel,
|
|
1318
|
+
wt as PieChartModel,
|
|
1319
|
+
Ut as RadarChartModel,
|
|
1320
|
+
Kt as TreeChartModel,
|
|
1321
|
+
jt as TreemapChartModel,
|
|
1322
|
+
Ht as WordCloudModel
|
|
19
1323
|
};
|
|
20
1324
|
//# sourceMappingURL=index.mjs.map
|