@milaboratories/graph-maker 1.1.155 → 1.1.157

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.
Files changed (57) hide show
  1. package/dist/GraphMaker/components/Chart.vue.d.ts.map +1 -1
  2. package/dist/GraphMaker/components/Chart.vue.js +20 -16
  3. package/dist/GraphMaker/components/Chart.vue.js.map +1 -1
  4. package/dist/GraphMaker/components/DragAndDrop/DndDoubleChip.vue.d.ts.map +1 -1
  5. package/dist/GraphMaker/components/DragAndDrop/DndDoubleChip.vue.js +24 -23
  6. package/dist/GraphMaker/components/DragAndDrop/DndDoubleChip.vue.js.map +1 -1
  7. package/dist/GraphMaker/constantsCommon.d.ts +2 -0
  8. package/dist/GraphMaker/constantsCommon.d.ts.map +1 -1
  9. package/dist/GraphMaker/constantsCommon.js +29 -27
  10. package/dist/GraphMaker/constantsCommon.js.map +1 -1
  11. package/dist/GraphMaker/forms/AxesSettingsForm/HeatmapAxesSettingsForm.vue.d.ts.map +1 -1
  12. package/dist/GraphMaker/forms/AxesSettingsForm/HeatmapAxesSettingsForm.vue.js +215 -148
  13. package/dist/GraphMaker/forms/AxesSettingsForm/HeatmapAxesSettingsForm.vue.js.map +1 -1
  14. package/dist/GraphMaker/utils/createChartSettingsForRender/composeDendroSettings.d.ts +5 -0
  15. package/dist/GraphMaker/utils/createChartSettingsForRender/composeDendroSettings.d.ts.map +1 -1
  16. package/dist/GraphMaker/utils/createChartSettingsForRender/composeDiscreteSettings.d.ts +1 -0
  17. package/dist/GraphMaker/utils/createChartSettingsForRender/composeDiscreteSettings.d.ts.map +1 -1
  18. package/dist/GraphMaker/utils/createChartSettingsForRender/composeHeatmapSettings.d.ts +5 -0
  19. package/dist/GraphMaker/utils/createChartSettingsForRender/composeHeatmapSettings.d.ts.map +1 -1
  20. package/dist/GraphMaker/utils/createChartSettingsForRender/composeHeatmapSettings.js +24 -24
  21. package/dist/GraphMaker/utils/createChartSettingsForRender/composeHeatmapSettings.js.map +1 -1
  22. package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotSettings.d.ts +2 -0
  23. package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotSettings.d.ts.map +1 -1
  24. package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotUmapSettings.d.ts +2 -0
  25. package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotUmapSettings.d.ts.map +1 -1
  26. package/dist/node_modules/@milaboratories/miplots4/dist/MiPlots.js +22 -22
  27. package/dist/node_modules/@milaboratories/miplots4/dist/dendro/ChartRenderer.js +160 -156
  28. package/dist/node_modules/@milaboratories/miplots4/dist/dendro/ChartRenderer.js.map +1 -1
  29. package/dist/node_modules/@milaboratories/miplots4/dist/dendro/DendroSettingsImpl.js +31 -27
  30. package/dist/node_modules/@milaboratories/miplots4/dist/dendro/DendroSettingsImpl.js.map +1 -1
  31. package/dist/node_modules/@milaboratories/miplots4/dist/dendro/components/Chart.js +53 -53
  32. package/dist/node_modules/@milaboratories/miplots4/dist/dendro/components/Chart.js.map +1 -1
  33. package/dist/node_modules/@milaboratories/miplots4/dist/dendro/getHierarchyData.js +30 -24
  34. package/dist/node_modules/@milaboratories/miplots4/dist/dendro/getHierarchyData.js.map +1 -1
  35. package/dist/node_modules/@milaboratories/miplots4/dist/dendro/index.js +78 -77
  36. package/dist/node_modules/@milaboratories/miplots4/dist/dendro/index.js.map +1 -1
  37. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/ChartRenderer.js +267 -258
  38. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/ChartRenderer.js.map +1 -1
  39. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/HeatmapSettingsImpl.js +59 -54
  40. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/HeatmapSettingsImpl.js.map +1 -1
  41. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Chart.js +91 -89
  42. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Chart.js.map +1 -1
  43. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/ChartsGroup.js +17 -17
  44. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/getCells.js +98 -87
  45. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/getCells.js.map +1 -1
  46. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/index.js +98 -76
  47. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/index.js.map +1 -1
  48. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/utils/calculateCaptionTails.js +57 -57
  49. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/utils/calculateCaptionTails.js.map +1 -1
  50. package/dist/node_modules/@milaboratories/miplots4/dist/types/common.js +52 -51
  51. package/dist/node_modules/@milaboratories/miplots4/dist/types/common.js.map +1 -1
  52. package/dist/node_modules/@milaboratories/miplots4/dist/types/dendro.js +13 -8
  53. package/dist/node_modules/@milaboratories/miplots4/dist/types/dendro.js.map +1 -1
  54. package/dist/node_modules/@milaboratories/miplots4/dist/types/discrete.js +5 -5
  55. package/dist/node_modules/@milaboratories/miplots4/dist/types/heatmap.js +19 -11
  56. package/dist/node_modules/@milaboratories/miplots4/dist/types/heatmap.js.map +1 -1
  57. package/package.json +2 -2
@@ -1,38 +1,41 @@
1
1
  import v from "../node_modules/lodash/lodash.js";
2
2
  import X from "../node_modules/d3-array/src/deviation.js";
3
- import _ from "../node_modules/d3-array/src/mean.js";
3
+ import N from "../node_modules/d3-array/src/mean.js";
4
4
  import Y from "../node_modules/d3-array/src/extent.js";
5
- const Z = 5e5;
6
- function I(l) {
7
- const n = X(l), y = _(l);
8
- return n === void 0 || y === void 0 || n === 0 ? (f) => f : (f) => (f - y) / n;
5
+ const ee = 5e5;
6
+ function ae(l) {
7
+ const o = X(l), r = N(l);
8
+ return o === void 0 || r === void 0 || o === 0 ? (m) => m : (m) => (m - r) / o;
9
9
  }
10
- function J(l) {
11
- const n = _(l), [y, f] = Y(l);
12
- return n === void 0 || y === void 0 || f === void 0 || f === y ? (i) => i : (i) => (i - n) / (f - y);
10
+ function te(l) {
11
+ const o = N(l), [r, m] = Y(l);
12
+ return o === void 0 || r === void 0 || m === void 0 || m === r ? (c) => c : (c) => (c - o) / (m - r);
13
13
  }
14
- function P(l, n) {
15
- return l === "standardScaling" ? I(n) : l === "meanNormalization" ? J(n) : (y) => y;
14
+ function le(l, o) {
15
+ return l === "standardScaling" ? ae(o) : l === "meanNormalization" ? te(o) : (r) => r;
16
16
  }
17
- function b(l) {
17
+ function L(l) {
18
18
  if (!l.length)
19
19
  return [];
20
- let n = [[]];
21
- return l.forEach((y) => {
22
- const f = [];
23
- y.forEach((i) => {
24
- f.push(...n.map((x) => [...x, i]));
25
- }), n = f;
26
- }), n;
20
+ let o = [[]];
21
+ return l.forEach((r) => {
22
+ const m = [];
23
+ r.forEach((c) => {
24
+ m.push(...o.map((B) => [...B, c]));
25
+ }), o = m;
26
+ }), o;
27
27
  }
28
- function ue(l, n, y, f, i, x, B, L, z, N, E, O) {
29
- const D = l.columnNames.length ? l.getColumn(l.columnNames[0]).length : 0;
30
- D > Z && console.error(`Too many cells for graph rendering (${D})`);
31
- const T = i.length ? i.map((e) => l.getColumnCategories(e.value)) : [["null"]], k = x.length ? x.map((e) => l.getColumnCategories(e.value)) : [["null"]], A = B.length ? B.map((e) => l.getColumnCategories(e.value)) : [["null"]], $ = b(T), j = b(k), w = b(A), M = $.map((e) => e.join("_")), G = j.map((e) => e.join("_")), d = w.map((e) => e.join("_")), a = {
28
+ const z = (l, o, r = {}) => l.sort(
29
+ (m, c) => o === "asc" ? (r[m] ?? m).localeCompare(r[c] ?? c, "en", { numeric: !0 }) : (r[c] ?? c).localeCompare(r[m] ?? m, "en", { numeric: !0 })
30
+ );
31
+ function ne(l, o, r, m, c, B, G, $, O, T, d, F, K, H, J) {
32
+ const j = l.columnNames.length ? l.getColumn(l.columnNames[0]).length : 0;
33
+ j > ee && console.error(`Too many cells for graph rendering (${j})`);
34
+ const P = c.length ? c.map((e) => K[e.value] ?? l.getColumnCategories(e.value)) : [["null"]], Q = B.length ? B.map((e) => K[e.value] ?? l.getColumnCategories(e.value)) : [["null"]], U = G.length ? G.map((e) => K[e.value] ?? l.getColumnCategories(e.value)) : [["null"]], D = L(P), w = L(Q), M = L(U), S = D.map((e) => e.join("_")), b = w.map((e) => e.join("_")), V = M.map((e) => e.join("_")), a = {
32
35
  meta: {
33
- facetKeys: M,
34
- xGroupKeys: G,
35
- yGroupKeys: d,
36
+ facetKeys: S,
37
+ xGroupKeys: b,
38
+ yGroupKeys: V,
36
39
  xKeysByGroups: {},
37
40
  yKeysByGroups: {},
38
41
  xLabels: {},
@@ -41,18 +44,18 @@ function ue(l, n, y, f, i, x, B, L, z, N, E, O) {
41
44
  yGroupLabels: {},
42
45
  xDataByKeys: {},
43
46
  yDataByKeys: {},
44
- facetKeyValues: M.reduce((e, t, o) => (e[t] = $[o], e), {}),
45
- xGroupKeyValues: G.reduce((e, t, o) => (e[t] = j[o], e), {}),
46
- yGroupKeyValues: d.reduce((e, t, o) => (e[t] = w[o], e), {}),
47
+ facetKeyValues: S.reduce((e, t, s) => (e[t] = D[s], e), {}),
48
+ xGroupKeyValues: b.reduce((e, t, s) => (e[t] = w[s], e), {}),
49
+ yGroupKeyValues: V.reduce((e, t, s) => (e[t] = M[s], e), {}),
47
50
  valueExtent: [1 / 0, -1 / 0]
48
51
  },
49
52
  facets: {}
50
- }, q = n.valueLabels ?? n.value, S = y.valueLabels ?? y.value, F = L.filter((e) => e.axis === "x").map((e) => e.valueColumn.value), H = L.filter((e) => e.axis === "y").map((e) => e.valueColumn.value), Q = Object.values(z ?? {}).map((e) => e.value), R = Object.values(N ?? {}).map((e) => e.value), U = v.uniq([...F, ...Q, q]), W = v.uniq([...H, ...R, S]);
53
+ }, _ = o.valueLabels ?? o.value, q = r.valueLabels ?? r.value, W = $.filter((e) => e.axis === "x").map((e) => e.valueColumn.value), Z = $.filter((e) => e.axis === "y").map((e) => e.valueColumn.value), k = Object.values(O ?? {}).map((e) => e.value), A = Object.values(T ?? {}).map((e) => e.value), I = v.uniq([...W, ...k, _]), R = v.uniq([...Z, ...A, q]);
51
54
  for (let e = 0; e < l.rowsCount; e++) {
52
- const t = i.length ? i.map((u) => l.getColumnValue(u.value, e)).join("_") : "null", o = x.length ? x.map((u) => l.getColumnValue(u.value, e)).join("_") : "null", g = B.length ? B.map((u) => l.getColumnValue(u.value, e)).join("_") : "null", V = x.length ? x.map((u) => l.getColumnValue(u.valueLabels ?? u.value, e)).join(", ") : "", C = B.length ? B.map((u) => l.getColumnValue(u.valueLabels ?? u.value, e)).join(", ") : "";
53
- a.meta.xGroupLabels[o] = V, a.meta.yGroupLabels[g] = C;
54
- const s = String(l.getColumnValue(n.value, e)), r = String(l.getColumnValue(y.value, e)), m = l.getColumnValue(f.value, e) ?? O;
55
- if (s === "null" || r === "null" || m === null)
55
+ const t = c.length ? c.map((u) => l.getColumnValue(u.value, e)).join("_") : "null", s = B.length ? B.map((u) => l.getColumnValue(u.value, e)).join("_") : "null", i = G.length ? G.map((u) => l.getColumnValue(u.value, e)).join("_") : "null", h = B.length ? B.map((u) => l.getColumnValue(u.valueLabels ?? u.value, e)).join(", ") : "", E = G.length ? G.map((u) => l.getColumnValue(u.valueLabels ?? u.value, e)).join(", ") : "";
56
+ a.meta.xGroupLabels[s] = h, a.meta.yGroupLabels[i] = E;
57
+ const n = String(l.getColumnValue(o.value, e)), y = String(l.getColumnValue(r.value, e)), p = l.getColumnValue(m.value, e) ?? F;
58
+ if (n === "null" || y === "null" || p === null)
56
59
  continue;
57
60
  if (a.facets[t] || (a.facets[t] = {
58
61
  xKeys: [],
@@ -60,77 +63,85 @@ function ue(l, n, y, f, i, x, B, L, z, N, E, O) {
60
63
  xKeysByGroups: {},
61
64
  yKeysByGroups: {},
62
65
  cells: {}
63
- }), a.facets[t].xKeysByGroups[o] || (a.facets[t].xKeysByGroups[o] = []), a.facets[t].yKeysByGroups[g] || (a.facets[t].yKeysByGroups[g] = []), a.facets[t].xKeys.push(s), a.facets[t].yKeys.push(r), a.facets[t].xKeysByGroups[o].push(s), a.facets[t].yKeysByGroups[g].push(r), a.facets[t].cells[s] || (a.facets[t].cells[s] = {}), a.meta.valueExtent[0] = Math.min(m, a.meta.valueExtent[0]), a.meta.valueExtent[1] = Math.max(m, a.meta.valueExtent[1]), a.facets[t].cells[s][r] && a.facets[t].cells[s][r].value !== m)
64
- throw Error(`More than 1 value for x=${s}, y=${r}`);
65
- const K = l.getColumnValue(q, e);
66
- if (a.meta.xLabels[s] && String(K) !== a.meta.xLabels[s])
67
- throw Error(`More than 1 x-label value for x=${s}`);
68
- const p = l.getColumnValue(S, e);
69
- if (a.meta.yLabels[r] && String(p) !== a.meta.yLabels[r])
70
- throw Error(`More than 1 y-label value for y=${r}`);
71
- a.meta.xLabels[s] = String(K), a.meta.yLabels[r] = String(p), U.forEach((u) => {
72
- const c = typeof a.meta.xDataByKeys[u] < "u", h = c && typeof a.meta.xDataByKeys[u][s] < "u";
73
- if (c || (a.meta.xDataByKeys[u] = {}), h && a.meta.xDataByKeys[u][s] !== l.getColumnValue(u, e))
74
- throw Error(`More than 1 value for x = ${s} and column = ${u}`);
75
- h || (a.meta.xDataByKeys[u][s] = l.getColumnValue(u, e));
76
- }), W.forEach((u) => {
77
- const c = typeof a.meta.yDataByKeys[u] < "u", h = c && typeof a.meta.yDataByKeys[u][r] < "u";
78
- if (c || (a.meta.yDataByKeys[u] = {}), h && a.meta.yDataByKeys[u][r] !== l.getColumnValue(u, e))
79
- throw Error(`More than 1 value for y = ${r} and column = ${u}`);
80
- h || (a.meta.yDataByKeys[u][r] = l.getColumnValue(u, e));
81
- }), a.facets[t].cells[s][r] = {
66
+ }), a.facets[t].xKeysByGroups[s] || (a.facets[t].xKeysByGroups[s] = []), a.facets[t].yKeysByGroups[i] || (a.facets[t].yKeysByGroups[i] = []), a.facets[t].xKeys.push(n), a.facets[t].yKeys.push(y), a.facets[t].xKeysByGroups[s].push(n), a.facets[t].yKeysByGroups[i].push(y), a.facets[t].cells[n] || (a.facets[t].cells[n] = {}), a.meta.valueExtent[0] = Math.min(p, a.meta.valueExtent[0]), a.meta.valueExtent[1] = Math.max(p, a.meta.valueExtent[1]), a.facets[t].cells[n][y] && a.facets[t].cells[n][y].value !== p)
67
+ throw Error(`More than 1 value for x=${n}, y=${y}`);
68
+ const x = l.getColumnValue(_, e);
69
+ if (a.meta.xLabels[n] && String(x) !== a.meta.xLabels[n])
70
+ throw Error(`More than 1 x-label value for x=${n}`);
71
+ const g = l.getColumnValue(q, e);
72
+ if (a.meta.yLabels[y] && String(g) !== a.meta.yLabels[y])
73
+ throw Error(`More than 1 y-label value for y=${y}`);
74
+ a.meta.xLabels[n] = String(x), a.meta.yLabels[y] = String(g), I.forEach((u) => {
75
+ const f = typeof a.meta.xDataByKeys[u] < "u", C = f && typeof a.meta.xDataByKeys[u][n] < "u";
76
+ if (f || (a.meta.xDataByKeys[u] = {}), C && a.meta.xDataByKeys[u][n] !== l.getColumnValue(u, e))
77
+ throw Error(`More than 1 value for x = ${n} and column = ${u}`);
78
+ C || (a.meta.xDataByKeys[u][n] = l.getColumnValue(u, e));
79
+ }), R.forEach((u) => {
80
+ const f = typeof a.meta.yDataByKeys[u] < "u", C = f && typeof a.meta.yDataByKeys[u][y] < "u";
81
+ if (f || (a.meta.yDataByKeys[u] = {}), C && a.meta.yDataByKeys[u][y] !== l.getColumnValue(u, e))
82
+ throw Error(`More than 1 value for y = ${y} and column = ${u}`);
83
+ C || (a.meta.yDataByKeys[u][y] = l.getColumnValue(u, e));
84
+ }), a.facets[t].cells[n][y] = {
82
85
  isCell: !0,
83
86
  idx: e,
84
- id: `${s}_${r}`,
85
- x: s,
86
- y: r,
87
- value: m,
88
- normalizedValue: m
87
+ id: `${n}_${y}`,
88
+ x: n,
89
+ y,
90
+ value: p,
91
+ normalizedValue: p
89
92
  };
90
93
  }
91
94
  if (a.meta.facetKeys = a.meta.facetKeys.filter((e) => a.facets[e]), a.meta.facetKeys.forEach((e) => {
92
- const t = a.facets[e];
93
- t.xKeys = v.uniq(t.xKeys), t.yKeys = v.uniq(t.yKeys), G.forEach((o) => {
94
- a.facets[e].xKeysByGroups[o] = v.uniq(
95
- a.facets[e].xKeysByGroups[o]
95
+ const t = a.facets[e], s = v.uniq(t.xKeys), i = v.uniq(t.yKeys);
96
+ t.xKeys = K[o.value] ? v.intersection(K[o.value], s) : s, t.yKeys = K[r.value] ? v.intersection(K[r.value], i) : i, b.forEach((h) => {
97
+ a.facets[e].xKeysByGroups[h] = v.intersection(
98
+ t.xKeys,
99
+ a.facets[e].xKeysByGroups[h]
96
100
  );
97
- }), d.forEach((o) => {
98
- a.facets[e].yKeysByGroups[o] = v.uniq(
99
- a.facets[e].yKeysByGroups[o]
101
+ }), V.forEach((h) => {
102
+ a.facets[e].yKeysByGroups[h] = v.intersection(
103
+ t.yKeys,
104
+ a.facets[e].yKeysByGroups[h]
100
105
  );
101
106
  });
102
- }), E) {
107
+ }), d) {
103
108
  const e = [1 / 0, -1 / 0];
104
109
  a.meta.facetKeys.forEach((t) => {
105
- const { xKeys: o, yKeys: g, cells: V } = a.facets[t], C = E.direction === "row" ? o : g, s = E.direction === "row" ? g : o, r = E.direction === "row" ? (m, K) => {
106
- var p;
107
- return (p = V[m]) == null ? void 0 : p[K];
108
- } : (m, K) => {
109
- var p;
110
- return (p = V[K]) == null ? void 0 : p[m];
110
+ const { xKeys: s, yKeys: i, cells: h } = a.facets[t], E = d.direction === "row" ? s : i, n = d.direction === "row" ? i : s, y = d.direction === "row" ? (p, x) => {
111
+ var g;
112
+ return (g = h[p]) == null ? void 0 : g[x];
113
+ } : (p, x) => {
114
+ var g;
115
+ return (g = h[x]) == null ? void 0 : g[p];
111
116
  };
112
- s.forEach((m) => {
113
- const K = [];
114
- C.forEach((u) => {
115
- var c;
116
- const h = (c = r(u, m)) == null ? void 0 : c.value;
117
- h !== void 0 && K.push(h);
117
+ n.forEach((p) => {
118
+ const x = [];
119
+ E.forEach((u) => {
120
+ var f;
121
+ const C = (f = y(u, p)) == null ? void 0 : f.value;
122
+ C !== void 0 && x.push(C);
118
123
  });
119
- const p = P(E.method, K);
120
- C.forEach((u) => {
121
- const c = r(u, m);
122
- c !== void 0 && (c.normalizedValue = p(c.value), e[0] = Math.min(c.normalizedValue, e[0]), e[1] = Math.max(c.normalizedValue, e[1]));
124
+ const g = le(d.method, x);
125
+ E.forEach((u) => {
126
+ const f = y(u, p);
127
+ f !== void 0 && (f.normalizedValue = g(f.value), e[0] = Math.min(f.normalizedValue, e[0]), e[1] = Math.max(f.normalizedValue, e[1]));
123
128
  });
124
129
  });
125
130
  }), a.meta.valueExtent = e;
126
131
  }
127
- return a.meta.xKeysByGroups = G.reduce((e, t) => (e[t] = v.uniq(
128
- v.flatten(a.meta.facetKeys.map((o) => a.facets[o].xKeysByGroups[t]))
129
- ), e), {}), a.meta.yKeysByGroups = d.reduce((e, t) => (e[t] = v.uniq(
130
- v.flatten(a.meta.facetKeys.map((o) => a.facets[o].yKeysByGroups[t]))
131
- ), e), {}), a.meta.valueExtent[0] === 1 / 0 && (a.meta.valueExtent[0] = 0), a.meta.valueExtent[1] === -1 / 0 && (a.meta.valueExtent[1] = 0), a;
132
+ return a.meta.xKeysByGroups = b.reduce((e, t) => {
133
+ const s = z(v.uniq(
134
+ v.flatten(a.meta.facetKeys.map((i) => a.facets[i].xKeysByGroups[t]))
135
+ ), H.sorting, a.meta.xLabels);
136
+ return e[t] = K[o.value] ? v.intersection(K[o.value], s) : s, e;
137
+ }, {}), a.meta.yKeysByGroups = V.reduce((e, t) => {
138
+ const s = z(v.uniq(
139
+ v.flatten(a.meta.facetKeys.map((i) => a.facets[i].yKeysByGroups[t]))
140
+ ), J.sorting, a.meta.yLabels);
141
+ return e[t] = K[r.value] ? v.intersection(K[r.value], s) : s, e;
142
+ }, {}), a.meta.valueExtent[0] === 1 / 0 && (a.meta.valueExtent[0] = 0), a.meta.valueExtent[1] === -1 / 0 && (a.meta.valueExtent[1] = 0), a;
132
143
  }
133
144
  export {
134
- ue as getCells
145
+ ne as getCells
135
146
  };
136
147
  //# sourceMappingURL=getCells.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getCells.js","sources":["../../../../../../node_modules/@milaboratories/miplots4/src/heatmap/getCells.ts"],"sourcesContent":["import { deviation, extent, mean } from 'd3-array';\nimport lodash from 'lodash';\nimport type { DataFrame } from '../DataFrame';\nimport type { ColumnName, DataValue, NormalizationMethod } from '../types';\nimport type { HeatmapSettingsImpl } from './HeatmapSettingsImpl';\n\nconst MAX_RENDERED_CELLS_COUNT = 500000;\nfunction normalizeByStd(values:number[]) {\n const stdValue = deviation(values);\n const meanValue = mean(values);\n\n if (stdValue === undefined || meanValue === undefined || stdValue === 0) {\n return (v:number) => v;\n }\n return (v:number) => (v - meanValue) / stdValue;\n}\nfunction normalizeByMinMax(values:number[]) {\n const meanValue = mean(values);\n const [min, max] = extent(values);\n if (meanValue === undefined || min === undefined || max === undefined || max === min) {\n return (v:number) => v;\n }\n return (v:number) => (v - meanValue) / (max - min);\n}\n\nfunction getNormalizationFn(method:NormalizationMethod, values:number[]) {\n if (method === 'standardScaling') {\n return normalizeByStd(values);\n }\n if (method === 'meanNormalization') {\n return normalizeByMinMax(values);\n }\n return (v:number) => v;\n}\n\nexport type Cell = {\n isCell: true;\n idx: number;\n id: string;\n value: DataValue;\n normalizedValue: DataValue;\n x: DataValue;\n y: DataValue;\n};\n\nexport type GroupedCellsData = {\n meta: {\n facetKeys: string[];\n xGroupKeys: string[];\n yGroupKeys: string[];\n xKeysByGroups: Record<string, string[]>;\n yKeysByGroups: Record<string, string[]>;\n // for titles, if facet by more 1 columns title has several values separated by commas\n facetKeyValues: Record<string, string[]>;\n xGroupKeyValues: Record<string, string[]>;\n yGroupKeyValues: Record<string, string[]>;\n xLabels: Record<string, string>;\n yLabels: Record<string, string>;\n xGroupLabels: Record<string, string>;\n yGroupLabels: Record<string, string>;\n valueExtent: [number, number]; // for color scales\n // data for labels, annotations and dendrograms\n xDataByKeys: Record<string, Record<string, DataValue>>;\n yDataByKeys: Record<string, Record<string, DataValue>>;\n };\n //facet groups\n facets: Record<\n string,\n {\n // axis keys\n xKeys: string[];\n yKeys: string[];\n // axis keys grouped by group keys from meta\n xKeysByGroups: Record<string, string[]>;\n yKeysByGroups: Record<string, string[]>;\n // cells grouped by X, then by Y\n cells: Record<string, Record<string, Cell>>;\n }\n >;\n};\n\n// all combinations with 1 key from each list\nfunction getKeysCombinations(keysLists: string[][]) {\n if (!keysLists.length) {\n return [];\n }\n let result: string[][] = [[]];\n keysLists.forEach(keys => {\n const nextResult: string[][] = [];\n keys.forEach(key => {\n nextResult.push(...result.map(resultItem => [...resultItem, key]));\n });\n result = nextResult;\n });\n return result;\n}\n\nexport function getCells(\n data: DataFrame,\n xColumn: ColumnName,\n yColumn: ColumnName,\n valueColumn: ColumnName,\n facetBy: ColumnName[],\n xGroupBy: ColumnName[],\n yGroupBy: ColumnName[],\n annotations: HeatmapSettingsImpl['annotations'],\n dendrogramX: HeatmapSettingsImpl['dendrogramX'],\n dendrogramY: HeatmapSettingsImpl['dendrogramY'],\n normalization: HeatmapSettingsImpl['normalization'],\n NAValueAs: HeatmapSettingsImpl['NAValueAs'],\n): GroupedCellsData {\n const dataSize = data.columnNames.length ? data.getColumn(data.columnNames[0]).length : 0;\n if (dataSize > MAX_RENDERED_CELLS_COUNT) {\n console.error(`Too many cells for graph rendering (${dataSize})`);\n }\n const facetKeysLists = facetBy.length\n ? facetBy.map(column => data.getColumnCategories(column.value))\n : [['null']];\n const xGroupKeysLists = xGroupBy.length\n ? xGroupBy.map(column => data.getColumnCategories(column.value))\n : [['null']];\n const yGroupKeysLists = yGroupBy.length\n ? yGroupBy.map(column => data.getColumnCategories(column.value))\n : [['null']];\n const facetKeysCombinations = getKeysCombinations(facetKeysLists);\n const xGroupKeysCombinations = getKeysCombinations(xGroupKeysLists);\n const yGroupKeysCombinations = getKeysCombinations(yGroupKeysLists);\n\n const facetKeys = facetKeysCombinations.map(keys => keys.join('_'));\n const xGroupKeys = xGroupKeysCombinations.map(keys => keys.join('_'));\n const yGroupKeys = yGroupKeysCombinations.map(keys => keys.join('_'));\n\n const result: GroupedCellsData = {\n meta: {\n facetKeys,\n xGroupKeys,\n yGroupKeys,\n xKeysByGroups: {},\n yKeysByGroups: {},\n xLabels: {},\n yLabels: {},\n xGroupLabels: {},\n yGroupLabels: {},\n xDataByKeys: {},\n yDataByKeys: {},\n facetKeyValues: facetKeys.reduce((res: Record<string, string[]>, key, index) => {\n res[key] = facetKeysCombinations[index];\n return res;\n }, {}),\n xGroupKeyValues: xGroupKeys.reduce((res: Record<string, string[]>, key, index) => {\n res[key] = xGroupKeysCombinations[index];\n return res;\n }, {}),\n yGroupKeyValues: yGroupKeys.reduce((res: Record<string, string[]>, key, index) => {\n res[key] = yGroupKeysCombinations[index];\n return res;\n }, {}),\n valueExtent: [Infinity, -Infinity],\n },\n facets: {},\n };\n\n const xLabelsSource = xColumn.valueLabels ?? xColumn.value;\n const yLabelsSource = yColumn.valueLabels ?? yColumn.value;\n const annotationColumnsX = annotations.filter(item => item.axis === 'x').map(item => item.valueColumn.value);\n const annotationColumnsY = annotations.filter(item => item.axis === 'y').map(item => item.valueColumn.value);\n const dendrogramXColumns = Object.values(dendrogramX ?? {}).map(column => column.value);\n const dendrogramYColumns = Object.values(dendrogramY ?? {}).map(column => column.value);\n const additionalDataColumnsX = lodash.uniq([...annotationColumnsX, ...dendrogramXColumns, xLabelsSource]);\n const additionalDataColumnsY = lodash.uniq([...annotationColumnsY, ...dendrogramYColumns, yLabelsSource]);\n\n for (let i = 0; i < data.rowsCount; i++) {\n const facetKey = facetBy.length ? facetBy.map(column => data.getColumnValue(column.value, i)).join('_') : 'null';\n const xGroupKey = xGroupBy.length ? xGroupBy.map(column => data.getColumnValue(column.value, i)).join('_') : 'null';\n const yGroupKey = yGroupBy.length ? yGroupBy.map(column => data.getColumnValue(column.value, i)).join('_') : 'null';\n const xGroupLabel = xGroupBy.length ? xGroupBy.map(column => data.getColumnValue(column.valueLabels ?? column.value, i)).join(', ') : '';\n const yGroupLabel = yGroupBy.length ? yGroupBy.map(column => data.getColumnValue(column.valueLabels ?? column.value, i)).join(', ') : '';\n result.meta.xGroupLabels[xGroupKey] = xGroupLabel;\n result.meta.yGroupLabels[yGroupKey] = yGroupLabel;\n const x = String(data.getColumnValue(xColumn.value, i));\n const y = String(data.getColumnValue(yColumn.value, i));\n const value = (data.getColumnValue(valueColumn.value, i) ?? NAValueAs) as number | null;\n \n if (x === 'null' || y === 'null' || value === null) {\n continue;\n }\n\n if (!result.facets[facetKey]) {\n result.facets[facetKey] = {\n xKeys: [],\n yKeys: [],\n xKeysByGroups: {},\n yKeysByGroups: {},\n cells: {},\n };\n }\n if (!result.facets[facetKey].xKeysByGroups[xGroupKey]) {\n result.facets[facetKey].xKeysByGroups[xGroupKey] = [];\n }\n if (!result.facets[facetKey].yKeysByGroups[yGroupKey]) {\n result.facets[facetKey].yKeysByGroups[yGroupKey] = [];\n }\n result.facets[facetKey].xKeys.push(x);\n result.facets[facetKey].yKeys.push(y);\n result.facets[facetKey].xKeysByGroups[xGroupKey].push(x);\n result.facets[facetKey].yKeysByGroups[yGroupKey].push(y);\n\n if (!result.facets[facetKey].cells[x]) {\n result.facets[facetKey].cells[x] = {};\n }\n result.meta.valueExtent[0] = Math.min(value, result.meta.valueExtent[0]);\n result.meta.valueExtent[1] = Math.max(value, result.meta.valueExtent[1]);\n if (result.facets[facetKey].cells[x][y] && result.facets[facetKey].cells[x][y].value !== value) {\n throw Error(`More than 1 value for x=${x}, y=${y}`);\n }\n const xLabelsSourceValue = data.getColumnValue(xLabelsSource, i);\n if (result.meta.xLabels[x] && String(xLabelsSourceValue) !== result.meta.xLabels[x]) {\n throw Error(`More than 1 x-label value for x=${x}`);\n }\n const yLabelsSourceValue = data.getColumnValue(yLabelsSource, i);\n if (result.meta.yLabels[y] && String(yLabelsSourceValue) !== result.meta.yLabels[y]) {\n throw Error(`More than 1 y-label value for y=${y}`);\n }\n result.meta.xLabels[x] = String(xLabelsSourceValue);\n result.meta.yLabels[y] = String(yLabelsSourceValue);\n // data for labels, annotations and dendrograms by X\n additionalDataColumnsX.forEach(columnKey => {\n const isAddedColumn = typeof result.meta.xDataByKeys[columnKey] !== 'undefined';\n const isAddedValue = isAddedColumn && typeof result.meta.xDataByKeys[columnKey][x] !== 'undefined';\n if (!isAddedColumn) {\n result.meta.xDataByKeys[columnKey] = {};\n }\n if (isAddedValue && result.meta.xDataByKeys[columnKey][x] !== data.getColumnValue(columnKey, i)) {\n throw Error(`More than 1 value for x = ${x} and column = ${columnKey}`);\n }\n if (!isAddedValue) {\n result.meta.xDataByKeys[columnKey][x] = data.getColumnValue(columnKey, i);\n }\n });\n // data for labels, annotations and dendrograms by Y\n additionalDataColumnsY.forEach(columnKey => {\n const isAddedColumn = typeof result.meta.yDataByKeys[columnKey] !== 'undefined';\n const isAddedValue = isAddedColumn && typeof result.meta.yDataByKeys[columnKey][y] !== 'undefined';\n if (!isAddedColumn) {\n result.meta.yDataByKeys[columnKey] = {};\n }\n if (isAddedValue && result.meta.yDataByKeys[columnKey][y] !== data.getColumnValue(columnKey, i)) {\n throw Error(`More than 1 value for y = ${y} and column = ${columnKey}`);\n }\n if (!isAddedValue) {\n result.meta.yDataByKeys[columnKey][y] = data.getColumnValue(columnKey, i);\n }\n });\n result.facets[facetKey].cells[x][y] = {\n isCell: true,\n idx: i,\n id: `${x}_${y}`,\n x,\n y,\n value,\n normalizedValue: value,\n };\n }\n\n result.meta.facetKeys = result.meta.facetKeys.filter((key) => result.facets[key]); // filter only used;\n\n // make uniq x, y, x-group and y-group keys\n result.meta.facetKeys.forEach(facetKey => {\n const facet = result.facets[facetKey];\n facet.xKeys = lodash.uniq(facet.xKeys);\n facet.yKeys = lodash.uniq(facet.yKeys);\n xGroupKeys.forEach(xGroupKey => {\n result.facets[facetKey].xKeysByGroups[xGroupKey] = lodash.uniq(\n result.facets[facetKey].xKeysByGroups[xGroupKey]\n );\n });\n yGroupKeys.forEach(yGroupKey => {\n result.facets[facetKey].yKeysByGroups[yGroupKey] = lodash.uniq(\n result.facets[facetKey].yKeysByGroups[yGroupKey]\n );\n });\n });\n\n if (normalization) {\n const valueExtent = [Infinity, -Infinity] as [number, number];\n result.meta.facetKeys.forEach(facetKey => {\n const {xKeys, yKeys, cells} = result.facets[facetKey];\n const cellKeys = normalization.direction === 'row' ? xKeys : yKeys;\n const groupKeys = normalization.direction === 'row' ? yKeys : xKeys;\n const cellGetter = normalization.direction === 'row'\n ? (cellKey:string, groupKey:string) => cells[cellKey]?.[groupKey]\n : (cellKey:string, groupKey:string) => cells[groupKey]?.[cellKey];\n groupKeys.forEach((groupKey) => {\n const values:number[] = [];\n cellKeys.forEach((cellKey) => {\n const v = cellGetter(cellKey, groupKey)?.value;\n if (v !== undefined) {\n values.push(v as number);\n }\n });\n const normalize = getNormalizationFn(normalization.method, values);\n cellKeys.forEach((cellKey) => {\n const cell = cellGetter(cellKey, groupKey);\n if (cell !== undefined) {\n cell.normalizedValue = normalize(cell.value as number);\n valueExtent[0] = Math.min(cell.normalizedValue, valueExtent[0]);\n valueExtent[1] = Math.max(cell.normalizedValue, valueExtent[1]);\n }\n });\n });\n });\n result.meta.valueExtent = valueExtent;\n }\n\n // every facet may contain not all of available keys, but for shared axes it is necessary to have all of them\n result.meta.xKeysByGroups = xGroupKeys.reduce((res: Record<string, string[]>, xGroupKey) => {\n res[xGroupKey] = lodash.uniq(\n lodash.flatten(result.meta.facetKeys.map(facetKey => result.facets[facetKey].xKeysByGroups[xGroupKey]))\n );\n return res;\n }, {});\n result.meta.yKeysByGroups = yGroupKeys.reduce((res: Record<string, string[]>, yGroupKey) => {\n res[yGroupKey] = lodash.uniq(\n lodash.flatten(result.meta.facetKeys.map(facetKey => result.facets[facetKey].yKeysByGroups[yGroupKey]))\n );\n return res;\n }, {});\n\n // avoid render errors on empty data\n if (result.meta.valueExtent[0] === Infinity) {\n result.meta.valueExtent[0] = 0;\n }\n if (result.meta.valueExtent[1] === -Infinity) {\n result.meta.valueExtent[1] = 0;\n }\n\n return result;\n}\n"],"names":["MAX_RENDERED_CELLS_COUNT","normalizeByStd","values","stdValue","deviation","meanValue","mean","v","normalizeByMinMax","min","max","extent","getNormalizationFn","method","getKeysCombinations","keysLists","result","keys","nextResult","key","resultItem","getCells","data","xColumn","yColumn","valueColumn","facetBy","xGroupBy","yGroupBy","annotations","dendrogramX","dendrogramY","normalization","NAValueAs","dataSize","facetKeysLists","column","xGroupKeysLists","yGroupKeysLists","facetKeysCombinations","xGroupKeysCombinations","yGroupKeysCombinations","facetKeys","xGroupKeys","yGroupKeys","res","index","xLabelsSource","yLabelsSource","annotationColumnsX","item","annotationColumnsY","dendrogramXColumns","dendrogramYColumns","additionalDataColumnsX","lodash","additionalDataColumnsY","i","facetKey","xGroupKey","yGroupKey","xGroupLabel","yGroupLabel","n","x","y","value","xLabelsSourceValue","yLabelsSourceValue","columnKey","isAddedColumn","isAddedValue","facet","valueExtent","xKeys","yKeys","cells","cellKeys","groupKeys","cellGetter","cellKey","groupKey","_a","normalize","cell"],"mappings":";;;;AAMA,MAAMA,IAA2B;AACjC,SAASC,EAAeC,GAAiB;AACrC,QAAMC,IAAWC,EAAUF,CAAM,GAC3BG,IAAYC,EAAKJ,CAAM;AAE7B,SAAIC,MAAa,UAAaE,MAAc,UAAaF,MAAa,IAC3D,CAACI,MAAaA,IAElB,CAACA,OAAcA,IAAIF,KAAaF;AAC3C;AACA,SAASK,EAAkBN,GAAiB;AACxC,QAAMG,IAAYC,EAAKJ,CAAM,GACvB,CAACO,GAAKC,CAAG,IAAIC,EAAOT,CAAM;AAChC,SAAIG,MAAc,UAAaI,MAAQ,UAAaC,MAAQ,UAAaA,MAAQD,IACtE,CAACF,MAAaA,IAElB,CAACA,OAAcA,IAAIF,MAAcK,IAAMD;AAClD;AAEA,SAASG,EAAmBC,GAA4BX,GAAiB;AACrE,SAAIW,MAAW,oBACJ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A,IACpBA,EAAO,QAAQvC,EAAO,KAAK,UAAU,IAAI,CAAA0C,MAAY1C,EAAO,OAAO0C,CAAQ,EAAE,cAAcC,CAAS,CAAC,CAAC;AAAA,EAAA,GAEnGd,IACR,CAAA,CAAE,GACL7B,EAAO,KAAK,gBAAgB4B,EAAW,OAAO,CAACC,GAA+Be,OAC1Ef,EAAIe,CAAS,IAAIL,EAAO;AAAA,IACpBA,EAAO,QAAQvC,EAAO,KAAK,UAAU,IAAI,CAAA0C,MAAY1C,EAAO,OAAO0C,CAAQ,EAAE,cAAcE,CAAS,CAAC,CAAC;AAAA,EAAA,GAEnGf,IACR,CAAA,CAAE,GAGD7B,EAAO,KAAK,YAAY,CAAC,MAAM,UAC/BA,EAAO,KAAK,YAAY,CAAC,IAAI,IAE7BA,EAAO,KAAK,YAAY,CAAC,MAAM,WAC/BA,EAAO,KAAK,YAAY,CAAC,IAAI,IAG1BA;AACX;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"getCells.js","sources":["../../../../../../node_modules/@milaboratories/miplots4/src/heatmap/getCells.ts"],"sourcesContent":["import { deviation, extent, mean } from 'd3-array';\nimport lodash from 'lodash';\nimport type { DataFrame } from '../DataFrame';\nimport type { ColumnName, DataValue, NormalizationMethod } from '../types';\nimport type { HeatmapSettingsImpl } from './HeatmapSettingsImpl';\n\nconst MAX_RENDERED_CELLS_COUNT = 500000;\nfunction normalizeByStd(values:number[]) {\n const stdValue = deviation(values);\n const meanValue = mean(values);\n\n if (stdValue === undefined || meanValue === undefined || stdValue === 0) {\n return (v:number) => v;\n }\n return (v:number) => (v - meanValue) / stdValue;\n}\nfunction normalizeByMinMax(values:number[]) {\n const meanValue = mean(values);\n const [min, max] = extent(values);\n if (meanValue === undefined || min === undefined || max === undefined || max === min) {\n return (v:number) => v;\n }\n return (v:number) => (v - meanValue) / (max - min);\n}\n\nfunction getNormalizationFn(method:NormalizationMethod, values:number[]) {\n if (method === 'standardScaling') {\n return normalizeByStd(values);\n }\n if (method === 'meanNormalization') {\n return normalizeByMinMax(values);\n }\n return (v:number) => v;\n}\n\nexport type Cell = {\n isCell: true;\n idx: number;\n id: string;\n value: DataValue;\n normalizedValue: DataValue;\n x: DataValue;\n y: DataValue;\n};\n\nexport type GroupedCellsData = {\n meta: {\n facetKeys: string[];\n xGroupKeys: string[];\n yGroupKeys: string[];\n xKeysByGroups: Record<string, string[]>;\n yKeysByGroups: Record<string, string[]>;\n // for titles, if facet by more 1 columns title has several values separated by commas\n facetKeyValues: Record<string, string[]>;\n xGroupKeyValues: Record<string, string[]>;\n yGroupKeyValues: Record<string, string[]>;\n xLabels: Record<string, string>;\n yLabels: Record<string, string>;\n xGroupLabels: Record<string, string>;\n yGroupLabels: Record<string, string>;\n valueExtent: [number, number]; // for color scales\n // data for labels, annotations and dendrograms\n xDataByKeys: Record<string, Record<string, DataValue>>;\n yDataByKeys: Record<string, Record<string, DataValue>>;\n };\n //facet groups\n facets: Record<\n string,\n {\n // axis keys\n xKeys: string[];\n yKeys: string[];\n // axis keys grouped by group keys from meta\n xKeysByGroups: Record<string, string[]>;\n yKeysByGroups: Record<string, string[]>;\n // cells grouped by X, then by Y\n cells: Record<string, Record<string, Cell>>;\n }\n >;\n};\n\n// all combinations with 1 key from each list\nfunction getKeysCombinations(keysLists: string[][]) {\n if (!keysLists.length) {\n return [];\n }\n let result: string[][] = [[]];\n keysLists.forEach(keys => {\n const nextResult: string[][] = [];\n keys.forEach(key => {\n nextResult.push(...result.map(resultItem => [...resultItem, key]));\n });\n result = nextResult;\n });\n return result;\n}\nconst sortByLabels = (arr: string[], direction: 'asc' | 'desc', labels: Record<string, string> = {}) => {\n return arr.sort((a, b) => direction === 'asc'\n ? (labels[a] ?? a).localeCompare((labels[b] ?? b), 'en', { numeric: true })\n : (labels[b] ?? b).localeCompare((labels[a] ?? a), 'en', { numeric: true })\n );\n};\n\nexport function getCells(\n data: DataFrame,\n xColumn: ColumnName,\n yColumn: ColumnName,\n valueColumn: ColumnName,\n facetBy: ColumnName[],\n xGroupBy: ColumnName[],\n yGroupBy: ColumnName[],\n annotations: HeatmapSettingsImpl['annotations'],\n dendrogramX: HeatmapSettingsImpl['dendrogramX'],\n dendrogramY: HeatmapSettingsImpl['dendrogramY'],\n normalization: HeatmapSettingsImpl['normalization'],\n NAValueAs: HeatmapSettingsImpl['NAValueAs'],\n keysOrder: HeatmapSettingsImpl['keysOrder'],\n xAxis: HeatmapSettingsImpl['chartSettings']['xAxis'],\n yAxis: HeatmapSettingsImpl['chartSettings']['yAxis'],\n): GroupedCellsData {\n const dataSize = data.columnNames.length ? data.getColumn(data.columnNames[0]).length : 0;\n if (dataSize > MAX_RENDERED_CELLS_COUNT) {\n console.error(`Too many cells for graph rendering (${dataSize})`);\n }\n const facetKeysLists = facetBy.length\n ? facetBy.map(column => keysOrder[column.value] ?? data.getColumnCategories(column.value))\n : [['null']];\n const xGroupKeysLists = xGroupBy.length\n ? xGroupBy.map(column => keysOrder[column.value] ?? data.getColumnCategories(column.value))\n : [['null']];\n const yGroupKeysLists = yGroupBy.length\n ? yGroupBy.map(column => keysOrder[column.value] ?? data.getColumnCategories(column.value))\n : [['null']];\n const facetKeysCombinations = getKeysCombinations(facetKeysLists);\n const xGroupKeysCombinations = getKeysCombinations(xGroupKeysLists);\n const yGroupKeysCombinations = getKeysCombinations(yGroupKeysLists);\n\n const facetKeys = facetKeysCombinations.map(keys => keys.join('_'));\n const xGroupKeys = xGroupKeysCombinations.map(keys => keys.join('_'));\n const yGroupKeys = yGroupKeysCombinations.map(keys => keys.join('_'));\n\n const result: GroupedCellsData = {\n meta: {\n facetKeys,\n xGroupKeys,\n yGroupKeys,\n xKeysByGroups: {},\n yKeysByGroups: {},\n xLabels: {},\n yLabels: {},\n xGroupLabels: {},\n yGroupLabels: {},\n xDataByKeys: {},\n yDataByKeys: {},\n facetKeyValues: facetKeys.reduce((res: Record<string, string[]>, key, index) => {\n res[key] = facetKeysCombinations[index];\n return res;\n }, {}),\n xGroupKeyValues: xGroupKeys.reduce((res: Record<string, string[]>, key, index) => {\n res[key] = xGroupKeysCombinations[index];\n return res;\n }, {}),\n yGroupKeyValues: yGroupKeys.reduce((res: Record<string, string[]>, key, index) => {\n res[key] = yGroupKeysCombinations[index];\n return res;\n }, {}),\n valueExtent: [Infinity, -Infinity],\n },\n facets: {},\n };\n\n const xLabelsSource = xColumn.valueLabels ?? xColumn.value;\n const yLabelsSource = yColumn.valueLabels ?? yColumn.value;\n const annotationColumnsX = annotations.filter(item => item.axis === 'x').map(item => item.valueColumn.value);\n const annotationColumnsY = annotations.filter(item => item.axis === 'y').map(item => item.valueColumn.value);\n const dendrogramXColumns = Object.values(dendrogramX ?? {}).map(column => column.value);\n const dendrogramYColumns = Object.values(dendrogramY ?? {}).map(column => column.value);\n const additionalDataColumnsX = lodash.uniq([...annotationColumnsX, ...dendrogramXColumns, xLabelsSource]);\n const additionalDataColumnsY = lodash.uniq([...annotationColumnsY, ...dendrogramYColumns, yLabelsSource]);\n\n for (let i = 0; i < data.rowsCount; i++) {\n const facetKey = facetBy.length ? facetBy.map(column => data.getColumnValue(column.value, i)).join('_') : 'null';\n const xGroupKey = xGroupBy.length ? xGroupBy.map(column => data.getColumnValue(column.value, i)).join('_') : 'null';\n const yGroupKey = yGroupBy.length ? yGroupBy.map(column => data.getColumnValue(column.value, i)).join('_') : 'null';\n const xGroupLabel = xGroupBy.length ? xGroupBy.map(column => data.getColumnValue(column.valueLabels ?? column.value, i)).join(', ') : '';\n const yGroupLabel = yGroupBy.length ? yGroupBy.map(column => data.getColumnValue(column.valueLabels ?? column.value, i)).join(', ') : '';\n result.meta.xGroupLabels[xGroupKey] = xGroupLabel;\n result.meta.yGroupLabels[yGroupKey] = yGroupLabel;\n const x = String(data.getColumnValue(xColumn.value, i));\n const y = String(data.getColumnValue(yColumn.value, i));\n const value = (data.getColumnValue(valueColumn.value, i) ?? NAValueAs) as number | null;\n \n if (x === 'null' || y === 'null' || value === null) {\n continue;\n }\n\n if (!result.facets[facetKey]) {\n result.facets[facetKey] = {\n xKeys: [],\n yKeys: [],\n xKeysByGroups: {},\n yKeysByGroups: {},\n cells: {},\n };\n }\n if (!result.facets[facetKey].xKeysByGroups[xGroupKey]) {\n result.facets[facetKey].xKeysByGroups[xGroupKey] = [];\n }\n if (!result.facets[facetKey].yKeysByGroups[yGroupKey]) {\n result.facets[facetKey].yKeysByGroups[yGroupKey] = [];\n }\n result.facets[facetKey].xKeys.push(x);\n result.facets[facetKey].yKeys.push(y);\n result.facets[facetKey].xKeysByGroups[xGroupKey].push(x);\n result.facets[facetKey].yKeysByGroups[yGroupKey].push(y);\n\n if (!result.facets[facetKey].cells[x]) {\n result.facets[facetKey].cells[x] = {};\n }\n result.meta.valueExtent[0] = Math.min(value, result.meta.valueExtent[0]);\n result.meta.valueExtent[1] = Math.max(value, result.meta.valueExtent[1]);\n if (result.facets[facetKey].cells[x][y] && result.facets[facetKey].cells[x][y].value !== value) {\n throw Error(`More than 1 value for x=${x}, y=${y}`);\n }\n const xLabelsSourceValue = data.getColumnValue(xLabelsSource, i);\n if (result.meta.xLabels[x] && String(xLabelsSourceValue) !== result.meta.xLabels[x]) {\n throw Error(`More than 1 x-label value for x=${x}`);\n }\n const yLabelsSourceValue = data.getColumnValue(yLabelsSource, i);\n if (result.meta.yLabels[y] && String(yLabelsSourceValue) !== result.meta.yLabels[y]) {\n throw Error(`More than 1 y-label value for y=${y}`);\n }\n result.meta.xLabels[x] = String(xLabelsSourceValue);\n result.meta.yLabels[y] = String(yLabelsSourceValue);\n // data for labels, annotations and dendrograms by X\n additionalDataColumnsX.forEach(columnKey => {\n const isAddedColumn = typeof result.meta.xDataByKeys[columnKey] !== 'undefined';\n const isAddedValue = isAddedColumn && typeof result.meta.xDataByKeys[columnKey][x] !== 'undefined';\n if (!isAddedColumn) {\n result.meta.xDataByKeys[columnKey] = {};\n }\n if (isAddedValue && result.meta.xDataByKeys[columnKey][x] !== data.getColumnValue(columnKey, i)) {\n throw Error(`More than 1 value for x = ${x} and column = ${columnKey}`);\n }\n if (!isAddedValue) {\n result.meta.xDataByKeys[columnKey][x] = data.getColumnValue(columnKey, i);\n }\n });\n // data for labels, annotations and dendrograms by Y\n additionalDataColumnsY.forEach(columnKey => {\n const isAddedColumn = typeof result.meta.yDataByKeys[columnKey] !== 'undefined';\n const isAddedValue = isAddedColumn && typeof result.meta.yDataByKeys[columnKey][y] !== 'undefined';\n if (!isAddedColumn) {\n result.meta.yDataByKeys[columnKey] = {};\n }\n if (isAddedValue && result.meta.yDataByKeys[columnKey][y] !== data.getColumnValue(columnKey, i)) {\n throw Error(`More than 1 value for y = ${y} and column = ${columnKey}`);\n }\n if (!isAddedValue) {\n result.meta.yDataByKeys[columnKey][y] = data.getColumnValue(columnKey, i);\n }\n });\n result.facets[facetKey].cells[x][y] = {\n isCell: true,\n idx: i,\n id: `${x}_${y}`,\n x,\n y,\n value,\n normalizedValue: value,\n };\n }\n\n result.meta.facetKeys = result.meta.facetKeys.filter((key) => result.facets[key]); // filter only used;\n\n // make uniq x, y, x-group and y-group keys\n result.meta.facetKeys.forEach(facetKey => {\n const facet = result.facets[facetKey];\n const uniqueXKeys = lodash.uniq(facet.xKeys);\n const uniqueYKeys = lodash.uniq(facet.yKeys);\n facet.xKeys = keysOrder[xColumn.value] ? lodash.intersection(keysOrder[xColumn.value], uniqueXKeys) : uniqueXKeys;\n facet.yKeys = keysOrder[yColumn.value] ? lodash.intersection(keysOrder[yColumn.value], uniqueYKeys) : uniqueYKeys;\n xGroupKeys.forEach(xGroupKey => {\n result.facets[facetKey].xKeysByGroups[xGroupKey] = lodash.intersection(\n facet.xKeys,\n result.facets[facetKey].xKeysByGroups[xGroupKey]\n );\n });\n yGroupKeys.forEach(yGroupKey => {\n result.facets[facetKey].yKeysByGroups[yGroupKey] = lodash.intersection(\n facet.yKeys,\n result.facets[facetKey].yKeysByGroups[yGroupKey]\n );\n });\n });\n\n if (normalization) {\n const valueExtent = [Infinity, -Infinity] as [number, number];\n result.meta.facetKeys.forEach(facetKey => {\n const {xKeys, yKeys, cells} = result.facets[facetKey];\n const cellKeys = normalization.direction === 'row' ? xKeys : yKeys;\n const groupKeys = normalization.direction === 'row' ? yKeys : xKeys;\n const cellGetter = normalization.direction === 'row'\n ? (cellKey:string, groupKey:string) => cells[cellKey]?.[groupKey]\n : (cellKey:string, groupKey:string) => cells[groupKey]?.[cellKey];\n groupKeys.forEach((groupKey) => {\n const values:number[] = [];\n cellKeys.forEach((cellKey) => {\n const v = cellGetter(cellKey, groupKey)?.value;\n if (v !== undefined) {\n values.push(v as number);\n }\n });\n const normalize = getNormalizationFn(normalization.method, values);\n cellKeys.forEach((cellKey) => {\n const cell = cellGetter(cellKey, groupKey);\n if (cell !== undefined) {\n cell.normalizedValue = normalize(cell.value as number);\n valueExtent[0] = Math.min(cell.normalizedValue, valueExtent[0]);\n valueExtent[1] = Math.max(cell.normalizedValue, valueExtent[1]);\n }\n });\n });\n });\n result.meta.valueExtent = valueExtent;\n }\n\n // every facet may contain not all of available keys, but for shared axes it is necessary to have all of them\n result.meta.xKeysByGroups = xGroupKeys.reduce((res: Record<string, string[]>, xGroupKey) => {\n const existingXKeys = sortByLabels(lodash.uniq(\n lodash.flatten(result.meta.facetKeys.map(facetKey => result.facets[facetKey].xKeysByGroups[xGroupKey]))\n ), xAxis.sorting, result.meta.xLabels);\n res[xGroupKey] = keysOrder[xColumn.value] ? lodash.intersection(keysOrder[xColumn.value], existingXKeys) : existingXKeys;\n return res;\n }, {});\n result.meta.yKeysByGroups = yGroupKeys.reduce((res: Record<string, string[]>, yGroupKey) => {\n const existingYKeys = sortByLabels(lodash.uniq(\n lodash.flatten(result.meta.facetKeys.map(facetKey => result.facets[facetKey].yKeysByGroups[yGroupKey]))\n ), yAxis.sorting, result.meta.yLabels);\n res[yGroupKey] = keysOrder[yColumn.value] ? lodash.intersection(keysOrder[yColumn.value], existingYKeys) : existingYKeys;\n return res;\n }, {});\n\n // avoid render errors on empty data\n if (result.meta.valueExtent[0] === Infinity) {\n result.meta.valueExtent[0] = 0;\n }\n if (result.meta.valueExtent[1] === -Infinity) {\n result.meta.valueExtent[1] = 0;\n }\n\n return result;\n}\n"],"names":["MAX_RENDERED_CELLS_COUNT","normalizeByStd","values","stdValue","deviation","meanValue","mean","v","normalizeByMinMax","min","max","extent","getNormalizationFn","method","getKeysCombinations","keysLists","result","keys","nextResult","key","resultItem","sortByLabels","arr","direction","labels","a","b","getCells","data","xColumn","yColumn","valueColumn","facetBy","xGroupBy","yGroupBy","annotations","dendrogramX","dendrogramY","normalization","NAValueAs","keysOrder","xAxis","yAxis","dataSize","facetKeysLists","column","xGroupKeysLists","yGroupKeysLists","facetKeysCombinations","xGroupKeysCombinations","yGroupKeysCombinations","facetKeys","xGroupKeys","yGroupKeys","res","index","xLabelsSource","yLabelsSource","annotationColumnsX","item","annotationColumnsY","dendrogramXColumns","dendrogramYColumns","additionalDataColumnsX","lodash","additionalDataColumnsY","i","facetKey","xGroupKey","yGroupKey","xGroupLabel","yGroupLabel","n","x","y","value","xLabelsSourceValue","yLabelsSourceValue","columnKey","isAddedColumn","isAddedValue","r","facet","uniqueXKeys","uniqueYKeys","valueExtent","xKeys","yKeys","cells","cellKeys","groupKeys","cellGetter","cellKey","groupKey","_a","normalize","cell","existingXKeys","existingYKeys"],"mappings":";;;;AAMA,MAAMA,KAA2B;AACjC,SAASC,GAAeC,GAAiB;AACrC,QAAMC,IAAWC,EAAUF,CAAM,GAC3BG,IAAYC,EAAKJ,CAAM;AAE7B,SAAIC,MAAa,UAAaE,MAAc,UAAaF,MAAa,IAC3D,CAACI,MAAaA,IAElB,CAACA,OAAcA,IAAIF,KAAaF;AAC3C;AACA,SAASK,GAAkBN,GAAiB;AACxC,QAAMG,IAAYC,EAAKJ,CAAM,GACvB,CAACO,GAAKC,CAAG,IAAIC,EAAOT,CAAM;AAChC,SAAIG,MAAc,UAAaI,MAAQ,UAAaC,MAAQ,UAAaA,MAAQD,IACtE,CAACF,MAAaA,IAElB,CAACA,OAAcA,IAAIF,M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IAAI,CAAAmD,MAAYnD,EAAO,OAAOmD,CAAQ,EAAE,cAAcE,CAAS,CAAC,CAAC;AAAA,IAAA,GACvG3B,EAAM,SAAS1B,EAAO,KAAK,OAAO;AACrC,WAAAsC,EAAIe,CAAS,IAAI7B,EAAUV,EAAQ,KAAK,IAAIkC,EAAO,aAAaxB,EAAUV,EAAQ,KAAK,GAAGoE,CAAa,IAAIA,GACpG5C;AAAAA,EACX,GAAG,CAAA,CAAE,GAGDtC,EAAO,KAAK,YAAY,CAAC,MAAM,UAC/BA,EAAO,KAAK,YAAY,CAAC,IAAI,IAE7BA,EAAO,KAAK,YAAY,CAAC,MAAM,WAC/BA,EAAO,KAAK,YAAY,CAAC,IAAI,IAG1BA;AACX;","x_google_ignoreList":[0]}
@@ -1,15 +1,15 @@
1
- import { renderToString as E } from "../node_modules/react-dom/server.browser.js";
2
- import { AbstractChart as q } from "../AbstractChart.js";
3
- import { isColumnName as y } from "../utils/index.js";
4
- import N from "./ChartRenderer.js";
1
+ import { renderToString as V } from "../node_modules/react-dom/server.browser.js";
2
+ import { AbstractChart as N } from "../AbstractChart.js";
3
+ import { isColumnName as B } from "../utils/index.js";
4
+ import q from "./ChartRenderer.js";
5
5
  import { getCells as I } from "./getCells.js";
6
6
  import { getDendrograms as P } from "./getDendrograms.js";
7
- import { HeatmapSettingsImpl as X } from "./HeatmapSettingsImpl.js";
8
- var $ = Object.defineProperty, F = (s, t, e) => t in s ? $(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, f = (s, t, e) => F(s, typeof t != "symbol" ? t + "" : t, e);
9
- class tt extends q {
7
+ import { HeatmapSettingsImpl as w } from "./HeatmapSettingsImpl.js";
8
+ var $ = Object.defineProperty, F = (h, t, e) => t in h ? $(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e, A = (h, t, e) => F(h, typeof t != "symbol" ? t + "" : t, e);
9
+ class tt extends N {
10
10
  constructor(t, e, a) {
11
- super(t, e), f(this, "settings"), f(this, "chartRenderer", new N()), f(this, "onTooltipHintSwitch", () => {
12
- }), f(this, "calculatedData", null), this.settings = new X(e), a && (this.onTooltipHintSwitch = a[0]);
11
+ super(t, e), A(this, "settings"), A(this, "chartRenderer", new q()), A(this, "onTooltipHintSwitch", () => {
12
+ }), A(this, "calculatedData", null), this.settings = new w(e), a && (this.onTooltipHintSwitch = a[0]);
13
13
  }
14
14
  mount(t) {
15
15
  try {
@@ -24,7 +24,7 @@ class tt extends q {
24
24
  updateSettingsAndData(t, e) {
25
25
  try {
26
26
  const a = this.settings, r = this.data;
27
- this.settings = new X(e), this.data = t, this._needUpdateCalculatedDataBySettings(a, this.settings) || this._needUpdateCalculatedDataByData(r, this.data) ? this._updateData() : this._updateAesInData(), this._updateChart();
27
+ this.settings = new w(e), this.data = t, this._needUpdateCalculatedDataBySettings(a, this.settings) || this._needUpdateCalculatedDataByData(r, this.data) ? this._updateData() : this._updateAesInData(), this._updateChart();
28
28
  } catch (a) {
29
29
  a instanceof Error && (this.chartRenderer.renderError(a.message), console.error(a));
30
30
  }
@@ -33,42 +33,42 @@ class tt extends q {
33
33
  console.warn("no chart state for heatmap");
34
34
  }
35
35
  export() {
36
- return this._updateChart(), E(this.chartRenderer.component);
36
+ return this._updateChart(), V(this.chartRenderer.component);
37
37
  }
38
38
  _needUpdateCalculatedDataBySettings(t, e) {
39
- var a, r, n, i, l, d, u, o, c, p, v, g;
39
+ var a, r, n, o, i, c, m, s, d, g, l, v;
40
40
  const {
41
- xColumn: D,
42
- yColumn: S,
43
- valueColumn: A,
44
- xGroupBy: w,
41
+ xColumn: p,
42
+ yColumn: f,
43
+ valueColumn: D,
44
+ xGroupBy: _,
45
45
  yGroupBy: x,
46
- facetBy: j,
47
- annotations: R,
48
- chartSettings: T,
49
- facetSettings: B,
50
- dendrogramX: _,
51
- dendrogramY: Y,
52
- normalization: C,
53
- NAValueAs: k
54
- } = e, G = Object.values(((a = t.dendrogramX) == null ? void 0 : a.aes) || {}).filter(
55
- y
56
- ), O = Object.values((_ == null ? void 0 : _.aes) || {}).filter(y), U = Object.values(((r = t.dendrogramY) == null ? void 0 : r.aes) || {}).filter(
57
- y
58
- ), z = Object.values((Y == null ? void 0 : Y.aes) || {}).filter(y);
59
- function h(m, b) {
60
- return m.length !== b.length || m.some((H, V) => H.value !== b[V].value);
46
+ facetBy: u,
47
+ annotations: O,
48
+ chartSettings: k,
49
+ facetSettings: b,
50
+ dendrogramX: Y,
51
+ dendrogramY: X,
52
+ normalization: S,
53
+ NAValueAs: R
54
+ } = e, j = Object.values(((a = t.dendrogramX) == null ? void 0 : a.aes) || {}).filter(
55
+ B
56
+ ), T = Object.values((Y == null ? void 0 : Y.aes) || {}).filter(B), E = Object.values(((r = t.dendrogramY) == null ? void 0 : r.aes) || {}).filter(
57
+ B
58
+ ), U = Object.values((X == null ? void 0 : X.aes) || {}).filter(B);
59
+ function y(C, G) {
60
+ return C.length !== G.length || C.some((z, H) => z.value !== G[H].value);
61
61
  }
62
- return t.xColumn.value !== D.value || t.yColumn.value !== S.value || t.valueColumn.value !== A.value || h(t.xGroupBy, w) || h(t.yGroupBy, x) || h(t.facetBy, j) || h(
63
- t.annotations.map((m) => m.valueColumn),
64
- R.map((m) => m.valueColumn)
65
- ) || h(G, O) || h(U, z) || (e.dendrogramX || t.dendrogramX) && (((n = t.dendrogramX) == null ? void 0 : n.distance) !== ((i = e.dendrogramX) == null ? void 0 : i.distance) || ((l = t.dendrogramX) == null ? void 0 : l.linkage) !== ((d = e.dendrogramX) == null ? void 0 : d.linkage)) || (e.dendrogramY || t.dendrogramY) && (((u = t.dendrogramY) == null ? void 0 : u.distance) !== ((o = e.dendrogramY) == null ? void 0 : o.distance) || ((c = t.dendrogramY) == null ? void 0 : c.linkage) !== ((p = e.dendrogramY) == null ? void 0 : p.linkage)) || t.chartSettings.valueType !== T.valueType || t.facetSettings.sharedX !== B.sharedX || t.facetSettings.sharedY !== B.sharedY || ((v = t.normalization) == null ? void 0 : v.method) !== (C == null ? void 0 : C.method) || ((g = t.normalization) == null ? void 0 : g.direction) !== (C == null ? void 0 : C.direction) || t.NAValueAs !== k;
62
+ return t.xColumn.value !== p.value || t.yColumn.value !== f.value || t.valueColumn.value !== D.value || y(t.xGroupBy, _) || y(t.yGroupBy, x) || y(t.facetBy, u) || y(
63
+ t.annotations.map((C) => C.valueColumn),
64
+ O.map((C) => C.valueColumn)
65
+ ) || y(j, T) || y(E, U) || (e.dendrogramX || t.dendrogramX) && (((n = t.dendrogramX) == null ? void 0 : n.distance) !== ((o = e.dendrogramX) == null ? void 0 : o.distance) || ((i = t.dendrogramX) == null ? void 0 : i.linkage) !== ((c = e.dendrogramX) == null ? void 0 : c.linkage)) || (e.dendrogramY || t.dendrogramY) && (((m = t.dendrogramY) == null ? void 0 : m.distance) !== ((s = e.dendrogramY) == null ? void 0 : s.distance) || ((d = t.dendrogramY) == null ? void 0 : d.linkage) !== ((g = e.dendrogramY) == null ? void 0 : g.linkage)) || t.chartSettings.valueType !== k.valueType || t.facetSettings.sharedX !== b.sharedX || t.facetSettings.sharedY !== b.sharedY || ((l = t.normalization) == null ? void 0 : l.method) !== (S == null ? void 0 : S.method) || ((v = t.normalization) == null ? void 0 : v.direction) !== (S == null ? void 0 : S.direction) || t.NAValueAs !== R;
66
66
  }
67
67
  _needUpdateCalculatedDataByData(t, e) {
68
68
  const a = Object.keys(t.data), r = Object.keys(e.data);
69
69
  return t.id !== e.id || a.length !== r.length || a.some((n) => {
70
- var i;
71
- return t.data[n].length !== ((i = e.data[n]) == null ? void 0 : i.length);
70
+ var o;
71
+ return t.data[n].length !== ((o = e.data[n]) == null ? void 0 : o.length);
72
72
  });
73
73
  }
74
74
  _updateData() {
@@ -78,67 +78,89 @@ class tt extends q {
78
78
  valueColumn: a,
79
79
  xGroupBy: r,
80
80
  yGroupBy: n,
81
- facetBy: i,
82
- chartSettings: l,
83
- facetSettings: d,
84
- annotations: u,
85
- dendrogramX: o,
86
- dendrogramY: c,
87
- normalization: p,
88
- NAValueAs: v
89
- } = this.settings, g = I(
81
+ facetBy: o,
82
+ chartSettings: i,
83
+ facetSettings: c,
84
+ annotations: m,
85
+ dendrogramX: s,
86
+ dendrogramY: d,
87
+ normalization: g,
88
+ NAValueAs: l,
89
+ keysOrder: v
90
+ } = this.settings, p = I(
90
91
  this.data,
91
92
  t,
92
93
  e,
93
94
  a,
94
- i,
95
+ o,
95
96
  r,
96
97
  n,
97
- u,
98
- o,
99
- c,
100
- p,
101
- v
102
- ), D = P(g, o, c, d), S = l.valueType === "discrete" ? this.data.getColumnCategories(a.value) : [];
98
+ m,
99
+ s,
100
+ d,
101
+ g,
102
+ l,
103
+ v,
104
+ i.xAxis,
105
+ i.yAxis
106
+ ), f = P(p, s, d, c), D = i.valueType === "discrete" ? this.data.getColumnCategories(a.value) : [];
103
107
  this.calculatedData = {
104
- groupedCellsData: g,
105
- dendrogramsData: D,
106
- cellUniqValues: S
108
+ groupedCellsData: p,
109
+ dendrogramsData: f,
110
+ cellUniqValues: D
107
111
  };
108
112
  }
109
113
  _updateAesInData() {
110
114
  }
111
115
  _updateChart() {
116
+ var t, e;
112
117
  if (!this.calculatedData)
113
118
  return;
114
119
  const {
115
- id: t,
116
- valueColumn: e,
117
- chartSettings: a,
118
- facetSettings: r,
119
- aes: n,
120
- annotations: i,
121
- dendrogramX: l,
122
- dendrogramY: d,
123
- inheritedDendrogramAes: u,
124
- normalization: o
125
- } = this.settings;
120
+ id: a,
121
+ valueColumn: r,
122
+ chartSettings: n,
123
+ facetSettings: o,
124
+ aes: i,
125
+ annotations: c,
126
+ dendrogramX: m,
127
+ dendrogramY: s,
128
+ inheritedDendrogramAes: d,
129
+ normalization: g,
130
+ keysOrder: l,
131
+ xColumn: v,
132
+ yColumn: p,
133
+ xGroupBy: f,
134
+ yGroupBy: D
135
+ } = this.settings, _ = {
136
+ x: ((t = l[v.value]) == null ? void 0 : t.length) > 0,
137
+ y: ((e = l[p.value]) == null ? void 0 : e.length) > 0,
138
+ xGroup: f.some((x) => {
139
+ var u;
140
+ return ((u = l[x.value]) == null ? void 0 : u.length) > 0;
141
+ }),
142
+ yGroup: D.some((x) => {
143
+ var u;
144
+ return ((u = l[x.value]) == null ? void 0 : u.length) > 0;
145
+ })
146
+ };
126
147
  this.chartRenderer.render(
127
148
  this.data,
128
- t,
129
149
  a,
130
- r,
131
150
  n,
132
- this.calculatedData.groupedCellsData,
151
+ o,
133
152
  i,
134
- e,
135
- l,
136
- d,
153
+ this.calculatedData.groupedCellsData,
154
+ c,
155
+ r,
156
+ m,
157
+ s,
137
158
  this.calculatedData.dendrogramsData,
138
- u,
159
+ d,
139
160
  this.calculatedData.cellUniqValues,
140
- o,
141
- this.onTooltipHintSwitch
161
+ g,
162
+ this.onTooltipHintSwitch,
163
+ _
142
164
  );
143
165
  }
144
166
  }