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