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