@milaboratories/miplots4 1.0.135 → 1.0.137
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/heatmap/getCells.js +48 -48
- package/dist/heatmap/getCells.js.map +1 -1
- package/dist/heatmap/utils/calculateCaptionTails.js +28 -28
- package/dist/heatmap/utils/calculateCaptionTails.js.map +1 -1
- package/dist/scatterplot-umap/ChartRenderer.d.ts +4 -3
- package/dist/scatterplot-umap/ChartRenderer.d.ts.map +1 -1
- package/dist/scatterplot-umap/ChartRenderer.js +152 -151
- package/dist/scatterplot-umap/ChartRenderer.js.map +1 -1
- package/package.json +1 -1
package/dist/heatmap/getCells.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import
|
|
1
|
+
import v from "../node_modules/lodash/lodash.js";
|
|
2
2
|
import J from "../node_modules/d3-array/src/deviation.js";
|
|
3
3
|
import q from "../node_modules/d3-array/src/mean.js";
|
|
4
4
|
import P from "../node_modules/d3-array/src/extent.js";
|
|
5
5
|
const Q = 5e5;
|
|
6
|
-
function W(
|
|
7
|
-
const r = J(
|
|
6
|
+
function W(s) {
|
|
7
|
+
const r = J(s), i = q(s);
|
|
8
8
|
return r === void 0 || i === void 0 || r === 0 ? (y) => y : (y) => (y - i) / r;
|
|
9
9
|
}
|
|
10
|
-
function Z(
|
|
11
|
-
const r = q(
|
|
10
|
+
function Z(s) {
|
|
11
|
+
const r = q(s), [i, y] = P(s);
|
|
12
12
|
return r === void 0 || i === void 0 || y === void 0 || y === i ? (m) => m : (m) => (m - r) / (y - i);
|
|
13
13
|
}
|
|
14
|
-
function k(
|
|
15
|
-
return
|
|
14
|
+
function k(s, r) {
|
|
15
|
+
return s === "standardScaling" ? W(r) : s === "meanNormalization" ? Z(r) : (i) => i;
|
|
16
16
|
}
|
|
17
|
-
function G(
|
|
18
|
-
if (!
|
|
17
|
+
function G(s) {
|
|
18
|
+
if (!s.length)
|
|
19
19
|
return [];
|
|
20
20
|
let r = [[]];
|
|
21
|
-
return
|
|
21
|
+
return s.forEach((i) => {
|
|
22
22
|
const y = [];
|
|
23
23
|
i.forEach((m) => {
|
|
24
24
|
y.push(...r.map((g) => [...g, m]));
|
|
25
25
|
}), r = y;
|
|
26
26
|
}), r;
|
|
27
27
|
}
|
|
28
|
-
function ne(
|
|
29
|
-
const D =
|
|
28
|
+
function ne(s, r, i, y, m, g, d, B, z, I, C, N) {
|
|
29
|
+
const D = s.columnNames.length ? s.getColumn(s.columnNames[0]).length : 0;
|
|
30
30
|
D > Q && console.error(`Too many cells for graph rendering (${D})`);
|
|
31
|
-
const A = m.length ? m.map((e) =>
|
|
31
|
+
const A = m.length ? m.map((e) => s.getColumnCategories(e.value)) : [["null"]], X = g.length ? g.map((e) => s.getColumnCategories(e.value)) : [["null"]], O = d.length ? d.map((e) => s.getColumnCategories(e.value)) : [["null"]], S = G(A), M = G(X), $ = G(O), j = S.map((e) => e.join("_")), E = M.map((e) => e.join("_")), b = $.map((e) => e.join("_")), t = {
|
|
32
32
|
meta: {
|
|
33
33
|
facetKeys: j,
|
|
34
34
|
xGroupKeys: E,
|
|
@@ -41,44 +41,44 @@ function ne(a, r, i, y, m, g, K, B, z, I, C, N) {
|
|
|
41
41
|
yGroupLabels: {},
|
|
42
42
|
xDataByKeys: {},
|
|
43
43
|
yDataByKeys: {},
|
|
44
|
-
facetKeyValues: j.reduce((e,
|
|
45
|
-
xGroupKeyValues: E.reduce((e,
|
|
46
|
-
yGroupKeyValues: b.reduce((e,
|
|
44
|
+
facetKeyValues: j.reduce((e, a, o) => (e[a] = S[o], e), {}),
|
|
45
|
+
xGroupKeyValues: E.reduce((e, a, o) => (e[a] = M[o], e), {}),
|
|
46
|
+
yGroupKeyValues: b.reduce((e, a, o) => (e[a] = $[o], e), {}),
|
|
47
47
|
valueExtent: [1 / 0, -1 / 0]
|
|
48
48
|
},
|
|
49
49
|
facets: {}
|
|
50
|
-
}, _ = r.valueLabels ?? r.value, w = i.valueLabels ?? i.value, R = B.filter((e) => e.axis === "x").map((e) => e.valueColumn.value), Y = B.filter((e) => e.axis === "y").map((e) => e.valueColumn.value), T = Object.values(z ?? {}).map((e) => e.value), F = Object.values(I ?? {}).map((e) => e.value), U =
|
|
51
|
-
for (let e = 0; e <
|
|
52
|
-
const
|
|
53
|
-
t.meta.xGroupLabels[o] = V, t.meta.yGroupLabels[
|
|
54
|
-
const l = String(
|
|
50
|
+
}, _ = r.valueLabels ?? r.value, w = i.valueLabels ?? i.value, R = B.filter((e) => e.axis === "x").map((e) => e.valueColumn.value), Y = B.filter((e) => e.axis === "y").map((e) => e.valueColumn.value), T = Object.values(z ?? {}).map((e) => e.value), F = Object.values(I ?? {}).map((e) => e.value), U = v.uniq([...R, ...T, _]), H = v.uniq([...Y, ...F, w]);
|
|
51
|
+
for (let e = 0; e < s.rowsCount; e++) {
|
|
52
|
+
const a = m.length ? m.map((n) => s.getColumnValue(n.value, e)).join("_") : "null", o = g.length ? g.map((n) => s.getColumnValue(n.value, e)).join("_") : "null", K = d.length ? d.map((n) => s.getColumnValue(n.value, e)).join("_") : "null", V = g.length ? g.map((n) => s.getColumnValue(n.valueLabels ?? n.value, e)).join(", ") : "", L = d.length ? d.map((n) => s.getColumnValue(n.valueLabels ?? n.value, e)).join(", ") : "";
|
|
53
|
+
t.meta.xGroupLabels[o] = V, t.meta.yGroupLabels[K] = L;
|
|
54
|
+
const l = String(s.getColumnValue(r.value, e)), u = String(s.getColumnValue(i.value, e)), f = s.getColumnValue(y.value, e) ?? N;
|
|
55
55
|
if (l === "null" || u === "null" || f === null)
|
|
56
56
|
continue;
|
|
57
|
-
if (t.facets[
|
|
57
|
+
if (t.facets[a] || (t.facets[a] = {
|
|
58
58
|
xKeys: [],
|
|
59
59
|
yKeys: [],
|
|
60
60
|
xKeysByGroups: {},
|
|
61
61
|
yKeysByGroups: {},
|
|
62
62
|
cells: {}
|
|
63
|
-
}), t.facets[
|
|
63
|
+
}), t.facets[a].xKeysByGroups[o] || (t.facets[a].xKeysByGroups[o] = []), t.facets[a].yKeysByGroups[K] || (t.facets[a].yKeysByGroups[K] = []), t.facets[a].xKeys.push(l), t.facets[a].yKeys.push(u), t.facets[a].xKeysByGroups[o].push(l), t.facets[a].yKeysByGroups[K].push(u), t.facets[a].cells[l] || (t.facets[a].cells[l] = {}), t.meta.valueExtent[0] = Math.min(f, t.meta.valueExtent[0]), t.meta.valueExtent[1] = Math.max(f, t.meta.valueExtent[1]), t.facets[a].cells[l][u] && t.facets[a].cells[l][u].value !== f)
|
|
64
64
|
throw Error(`More than 1 value for x=${l}, y=${u}`);
|
|
65
|
-
const
|
|
66
|
-
if (t.meta.xLabels[l] && String(
|
|
65
|
+
const x = s.getColumnValue(_, e);
|
|
66
|
+
if (t.meta.xLabels[l] && String(x) !== t.meta.xLabels[l])
|
|
67
67
|
throw Error(`More than 1 x-label value for x=${l}`);
|
|
68
|
-
const p =
|
|
68
|
+
const p = s.getColumnValue(w, e);
|
|
69
69
|
if (t.meta.yLabels[u] && String(p) !== t.meta.yLabels[u])
|
|
70
70
|
throw Error(`More than 1 y-label value for y=${u}`);
|
|
71
|
-
t.meta.xLabels[l] = String(
|
|
71
|
+
t.meta.xLabels[l] = String(x), t.meta.yLabels[u] = String(p), U.forEach((n) => {
|
|
72
72
|
const c = typeof t.meta.xDataByKeys[n] < "u", h = c && typeof t.meta.xDataByKeys[n][l] < "u";
|
|
73
|
-
if (c || (t.meta.xDataByKeys[n] = {}), h && t.meta.xDataByKeys[n][l] !==
|
|
73
|
+
if (c || (t.meta.xDataByKeys[n] = {}), h && t.meta.xDataByKeys[n][l] !== s.getColumnValue(n, e))
|
|
74
74
|
throw Error(`More than 1 value for x = ${l} and column = ${n}`);
|
|
75
|
-
h || (t.meta.xDataByKeys[n][l] =
|
|
75
|
+
h || (t.meta.xDataByKeys[n][l] = s.getColumnValue(n, e));
|
|
76
76
|
}), H.forEach((n) => {
|
|
77
77
|
const c = typeof t.meta.yDataByKeys[n] < "u", h = c && typeof t.meta.yDataByKeys[n][u] < "u";
|
|
78
|
-
if (c || (t.meta.yDataByKeys[n] = {}), h && t.meta.yDataByKeys[n][u] !==
|
|
78
|
+
if (c || (t.meta.yDataByKeys[n] = {}), h && t.meta.yDataByKeys[n][u] !== s.getColumnValue(n, e))
|
|
79
79
|
throw Error(`More than 1 value for y = ${u} and column = ${n}`);
|
|
80
|
-
h || (t.meta.yDataByKeys[n][u] =
|
|
81
|
-
}), t.facets[
|
|
80
|
+
h || (t.meta.yDataByKeys[n][u] = s.getColumnValue(n, e));
|
|
81
|
+
}), t.facets[a].cells[l][u] = {
|
|
82
82
|
isCell: !0,
|
|
83
83
|
idx: e,
|
|
84
84
|
id: `${l}_${u}`,
|
|
@@ -89,34 +89,34 @@ function ne(a, r, i, y, m, g, K, B, z, I, C, N) {
|
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
if (t.meta.facetKeys = t.meta.facetKeys.filter((e) => t.facets[e]), t.meta.facetKeys.forEach((e) => {
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
t.facets[e].xKeysByGroups[o] =
|
|
92
|
+
const a = t.facets[e];
|
|
93
|
+
a.xKeys = v.uniq(a.xKeys), a.yKeys = v.uniq(a.yKeys), E.forEach((o) => {
|
|
94
|
+
t.facets[e].xKeysByGroups[o] = v.uniq(
|
|
95
95
|
t.facets[e].xKeysByGroups[o]
|
|
96
96
|
);
|
|
97
97
|
}), b.forEach((o) => {
|
|
98
|
-
t.facets[e].yKeysByGroups[o] =
|
|
98
|
+
t.facets[e].yKeysByGroups[o] = v.uniq(
|
|
99
99
|
t.facets[e].yKeysByGroups[o]
|
|
100
100
|
);
|
|
101
101
|
});
|
|
102
102
|
}), C) {
|
|
103
103
|
const e = [1 / 0, -1 / 0];
|
|
104
|
-
t.meta.facetKeys.forEach((
|
|
105
|
-
const { xKeys: o, yKeys:
|
|
104
|
+
t.meta.facetKeys.forEach((a) => {
|
|
105
|
+
const { xKeys: o, yKeys: K, cells: V } = t.facets[a], L = C.direction === "row" ? o : K, l = C.direction === "row" ? K : o, u = C.direction === "row" ? (f, x) => {
|
|
106
106
|
var p;
|
|
107
|
-
return (p = V[f]) == null ? void 0 : p[
|
|
108
|
-
} : (f,
|
|
107
|
+
return (p = V[f]) == null ? void 0 : p[x];
|
|
108
|
+
} : (f, x) => {
|
|
109
109
|
var p;
|
|
110
|
-
return (p = V[
|
|
110
|
+
return (p = V[x]) == null ? void 0 : p[f];
|
|
111
111
|
};
|
|
112
112
|
l.forEach((f) => {
|
|
113
|
-
const
|
|
113
|
+
const x = [];
|
|
114
114
|
L.forEach((n) => {
|
|
115
115
|
var h;
|
|
116
116
|
const c = (h = u(n, f)) == null ? void 0 : h.value;
|
|
117
|
-
c !== void 0 &&
|
|
117
|
+
c !== void 0 && x.push(c);
|
|
118
118
|
});
|
|
119
|
-
const p = k(C.method,
|
|
119
|
+
const p = k(C.method, x);
|
|
120
120
|
L.forEach((n) => {
|
|
121
121
|
const c = u(n, f);
|
|
122
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,10 +124,10 @@ function ne(a, r, i, y, m, g, K, B, z, I, C, N) {
|
|
|
124
124
|
});
|
|
125
125
|
}), t.meta.valueExtent = e;
|
|
126
126
|
}
|
|
127
|
-
return t.meta.xKeysByGroups = E.reduce((e,
|
|
128
|
-
|
|
129
|
-
), e), {}), t.meta.yKeysByGroups = b.reduce((e,
|
|
130
|
-
|
|
127
|
+
return t.meta.xKeysByGroups = E.reduce((e, a) => (e[a] = v.uniq(
|
|
128
|
+
v.flatten(t.meta.facetKeys.map((o) => t.facets[o].xKeysByGroups[a]))
|
|
129
|
+
), e), {}), t.meta.yKeysByGroups = b.reduce((e, a) => (e[a] = v.uniq(
|
|
130
|
+
v.flatten(t.meta.facetKeys.map((o) => t.facets[o].yKeysByGroups[a]))
|
|
131
131
|
), e), {}), t.meta.valueExtent[0] === 1 / 0 && (t.meta.valueExtent[0] = 0), t.meta.valueExtent[1] === -1 / 0 && (t.meta.valueExtent[1] = 0), t;
|
|
132
132
|
}
|
|
133
133
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCells.js","sources":["../../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[xGroupKey] = 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]) {\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","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,oBACJZ,EAAeC,CAAM,IAE5BW,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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;"}
|
|
1
|
+
{"version":3,"file":"getCells.js","sources":["../../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","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,EAAk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,EAAY,CAAC,CAAC;AAAA,QAEtE,CAAC;AAAA,MACL,CAAC;AAAA,IACL,CAAC,GACDxD,EAAO,KAAK,cAAcwD;AAAA,EAC9B;AAGA,SAAAxD,EAAO,KAAK,gBAAgB2B,EAAW,OAAO,CAACE,GAA+Bc,OAC1Ed,EAAIc,CAAS,IAAIJ,EAAO;AAAA,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;"}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { MIN_STEP_FOR_VISIBLE_LABELS as _ } from "../constants.js";
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
const
|
|
2
|
+
const K = Math.cos(Math.PI / 4);
|
|
3
|
+
function E(a, f, e, s, u, y, o, m, I, d) {
|
|
4
|
+
const p = y[a], B = p > _;
|
|
5
5
|
let l = 0;
|
|
6
|
-
return
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
6
|
+
return f.forEach((x) => {
|
|
7
|
+
const r = u(a, x);
|
|
8
|
+
if (r.length === 0)
|
|
9
9
|
return 0;
|
|
10
|
-
const n =
|
|
11
|
-
const T = s[
|
|
12
|
-
return Math.max(L, d.getTextWidth(T) *
|
|
10
|
+
const n = r.length * p / 2, i = m ? d.getTextWidth(e[x] ?? x) * K - n - o(r[0]) : 0, G = I && B ? f.reduce((L, h) => {
|
|
11
|
+
const T = s[h];
|
|
12
|
+
return Math.max(L, d.getTextWidth(T) * K - p / 2 - o(h));
|
|
13
13
|
}, 0) : 0;
|
|
14
14
|
l = Math.max(l, i, G);
|
|
15
15
|
}), l;
|
|
16
16
|
}
|
|
17
|
-
function P(a,
|
|
18
|
-
const { facetKeys: o, xGroupKeys: m, yGroupKeys: I, xKeysByGroups: d, yKeysByGroups:
|
|
17
|
+
function P(a, f, e, s, u, y) {
|
|
18
|
+
const { facetKeys: o, xGroupKeys: m, yGroupKeys: I, xKeysByGroups: d, yKeysByGroups: p, xLabels: B, yLabels: l, xGroupLabels: x, yGroupLabels: r } = u.meta;
|
|
19
19
|
let n = 0, i = 0;
|
|
20
20
|
const G = a.xGroupLabels === 45, L = a.xAxisLabels === 45;
|
|
21
21
|
if (G || L)
|
|
22
|
-
if (!
|
|
22
|
+
if (!f.sharedX)
|
|
23
23
|
o.forEach((t) => {
|
|
24
24
|
n = Math.max(
|
|
25
|
-
|
|
25
|
+
E(
|
|
26
26
|
t,
|
|
27
27
|
m,
|
|
28
|
-
|
|
28
|
+
x,
|
|
29
29
|
B,
|
|
30
|
-
(b, c) =>
|
|
30
|
+
(b, c) => u.facets[b].xKeysByGroups[c],
|
|
31
31
|
s.x,
|
|
32
32
|
e.x[t],
|
|
33
33
|
G,
|
|
@@ -40,10 +40,10 @@ function P(a, h, e, s, f, y) {
|
|
|
40
40
|
else {
|
|
41
41
|
const t = o[0];
|
|
42
42
|
n = Math.max(
|
|
43
|
-
|
|
43
|
+
E(
|
|
44
44
|
t,
|
|
45
45
|
m,
|
|
46
|
-
|
|
46
|
+
x,
|
|
47
47
|
B,
|
|
48
48
|
(b, c) => d[c],
|
|
49
49
|
s.x,
|
|
@@ -55,20 +55,20 @@ function P(a, h, e, s, f, y) {
|
|
|
55
55
|
n
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
if (!
|
|
58
|
+
const h = a.yGroupLabels === 45, T = a.yAxisLabels === 45;
|
|
59
|
+
if (h || T)
|
|
60
|
+
if (!f.sharedY)
|
|
61
61
|
o.forEach((t) => {
|
|
62
62
|
i = Math.max(
|
|
63
|
-
|
|
63
|
+
E(
|
|
64
64
|
t,
|
|
65
65
|
I,
|
|
66
|
-
|
|
66
|
+
r,
|
|
67
67
|
l,
|
|
68
|
-
(b, c) =>
|
|
68
|
+
(b, c) => u.facets[b].yKeysByGroups[c],
|
|
69
69
|
s.y,
|
|
70
70
|
e.y[t],
|
|
71
|
-
|
|
71
|
+
h,
|
|
72
72
|
T,
|
|
73
73
|
y
|
|
74
74
|
),
|
|
@@ -78,15 +78,15 @@ function P(a, h, e, s, f, y) {
|
|
|
78
78
|
else {
|
|
79
79
|
const t = o[0];
|
|
80
80
|
i = Math.max(
|
|
81
|
-
|
|
81
|
+
E(
|
|
82
82
|
t,
|
|
83
83
|
I,
|
|
84
|
-
|
|
84
|
+
r,
|
|
85
85
|
l,
|
|
86
|
-
(b, c) =>
|
|
86
|
+
(b, c) => p[c],
|
|
87
87
|
s.y,
|
|
88
88
|
e.y[t],
|
|
89
|
-
|
|
89
|
+
h,
|
|
90
90
|
T,
|
|
91
91
|
y
|
|
92
92
|
),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculateCaptionTails.js","sources":["../../../src/heatmap/utils/calculateCaptionTails.ts"],"sourcesContent":["import type { TextMeasurer } from '../../utils/TextMeasurer/TextMeasurer';\nimport type { ChartsScales, LabelAngles } from '../components/types';\nimport { MIN_STEP_FOR_VISIBLE_LABELS } from '../constants';\nimport type { GroupedCellsData } from '../getCells';\nimport type { HeatmapSettingsImpl } from '../HeatmapSettingsImpl';\n\nconst COS_PI_4 = Math.cos(Math.PI / 4);\nfunction getTailByFacetKey (\n facetKey: string,\n groupKeys: string[],\n groupLabels: Record<string, string>,\n valueLabels: Record<string, string>,\n getKeysInGroup: (facetKey:string, groupKey:string) => string[],\n steps: Record<string, number>,\n scale: (v:string) => number,\n groupTitleInclined: boolean,\n labelTitleInclined: boolean,\n textMeasurer: TextMeasurer\n): number {\n const step = steps[facetKey];\n const labelsVisible = step > MIN_STEP_FOR_VISIBLE_LABELS;\n\n let maxTail = 0;\n groupKeys.forEach((groupKey) => {\n const keysInGroup = getKeysInGroup(facetKey, groupKey);\n if (keysInGroup.length === 0) {\n return 0;\n }\n const groupHalfWidth = (keysInGroup.length * step) / 2;\n const groupTail = groupTitleInclined\n ? textMeasurer.getTextWidth(groupLabels[groupKey]) * COS_PI_4 - groupHalfWidth - scale(keysInGroup[0])\n : 0;\n const labelTail = labelTitleInclined && labelsVisible\n ? groupKeys.reduce((res, key) => {\n const label = valueLabels[key];\n return Math.max(res, textMeasurer.getTextWidth(label) * COS_PI_4 - step / 2 - scale(key));\n }, 0)\n : 0;\n maxTail = Math.max(maxTail, groupTail, labelTail);\n });\n return maxTail;\n}\n\nexport function calculateCaptionTails(\n labelAngles: LabelAngles,\n facetSettings: HeatmapSettingsImpl['facetSettings'],\n scales: ChartsScales,\n steps: {\n x: Record<string, number>;\n y: Record<string, number>;\n },\n groupedCells: GroupedCellsData,\n textMeasurer: TextMeasurer\n): {xCaptionTail: number; yCaptionTail: number} {\n const {facetKeys, xGroupKeys, yGroupKeys, xKeysByGroups, yKeysByGroups, xLabels, yLabels, xGroupLabels, yGroupLabels} = groupedCells.meta;\n let xCaptionTail = 0;\n let yCaptionTail = 0;\n // tails from 45deg inclined captions of groups titles/cells labels, that take place on adjacent padding\n const xGroupTitleInclined = labelAngles.xGroupLabels === 45;\n const xLabelsInclined = labelAngles.xAxisLabels === 45;\n if (xGroupTitleInclined || xLabelsInclined) {\n if (!facetSettings.sharedX) {\n facetKeys.forEach(facetKey => {\n xCaptionTail = Math.max(\n getTailByFacetKey(\n facetKey,\n xGroupKeys,\n xGroupLabels,\n xLabels,\n (facetKey:string, groupKey:string) => groupedCells.facets[facetKey].xKeysByGroups[groupKey],\n steps.x,\n scales.x[facetKey],\n xGroupTitleInclined,\n xLabelsInclined,\n textMeasurer\n ),\n xCaptionTail\n );\n });\n } else {\n const facetKey = facetKeys[0]; // there is no difference between facets in this case\n xCaptionTail = Math.max(\n getTailByFacetKey(\n facetKey,\n xGroupKeys,\n xGroupLabels,\n xLabels,\n (facetKey:string, groupKey:string) => xKeysByGroups[groupKey],\n steps.x,\n scales.x[facetKey],\n xGroupTitleInclined,\n xLabelsInclined,\n textMeasurer\n ),\n xCaptionTail\n );\n }\n }\n const yGroupTitleInclined = labelAngles.yGroupLabels === 45;\n const yLabelsInclined = labelAngles.yAxisLabels === 45;\n if (yGroupTitleInclined || yLabelsInclined) {\n if (!facetSettings.sharedY) {\n facetKeys.forEach(facetKey => {\n yCaptionTail = Math.max(\n getTailByFacetKey(\n facetKey,\n yGroupKeys,\n yGroupLabels,\n yLabels,\n (facetKey:string, groupKey:string) => groupedCells.facets[facetKey].yKeysByGroups[groupKey],\n steps.y,\n scales.y[facetKey],\n yGroupTitleInclined,\n yLabelsInclined,\n textMeasurer\n ),\n yCaptionTail\n );\n });\n } else {\n const facetKey = facetKeys[0]; // there is no difference between facets in this case\n yCaptionTail = Math.max(\n getTailByFacetKey(\n facetKey,\n yGroupKeys,\n yGroupLabels,\n yLabels,\n (facetKey:string, groupKey:string) => yKeysByGroups[groupKey],\n steps.y,\n scales.y[facetKey],\n yGroupTitleInclined,\n yLabelsInclined,\n textMeasurer\n ),\n yCaptionTail\n );\n }\n }\n return {xCaptionTail, yCaptionTail};\n}\n"],"names":["COS_PI_4","getTailByFacetKey","facetKey","groupKeys","groupLabels","valueLabels","getKeysInGroup","steps","scale","groupTitleInclined","labelTitleInclined","textMeasurer","step","labelsVisible","MIN_STEP_FOR_VISIBLE_LABELS","maxTail","groupKey","keysInGroup","groupHalfWidth","groupTail","labelTail","res","key","label","calculateCaptionTails","labelAngles","facetSettings","scales","groupedCells","facetKeys","xGroupKeys","yGroupKeys","xKeysByGroups","yKeysByGroups","xLabels","yLabels","xGroupLabels","yGroupLabels","xCaptionTail","yCaptionTail","xGroupTitleInclined","xLabelsInclined","yGroupTitleInclined","yLabelsInclined"],"mappings":";AAMA,MAAMA,IAAW,KAAK,IAAI,KAAK,KAAK,CAAC;AACrC,SAASC,EACLC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACM;AACN,QAAMC,IAAOL,EAAML,CAAQ,GACrBW,IAAgBD,IAAOE;AAE7B,MAAIC,IAAU;AACd,SAAAZ,EAAU,QAAQ,CAACa,MAAa;AAC5B,UAAMC,IAAcX,EAAeJ,GAAUc,CAAQ;AACrD,QAAIC,EAAY,WAAW;AACvB,aAAO;AAEX,UAAMC,IAAkBD,EAAY,SAASL,IAAQ,GAC/CO,IAAYV,IACZE,EAAa,aAAaP,EAAYY,CAAQ,
|
|
1
|
+
{"version":3,"file":"calculateCaptionTails.js","sources":["../../../src/heatmap/utils/calculateCaptionTails.ts"],"sourcesContent":["import type { TextMeasurer } from '../../utils/TextMeasurer/TextMeasurer';\nimport type { ChartsScales, LabelAngles } from '../components/types';\nimport { MIN_STEP_FOR_VISIBLE_LABELS } from '../constants';\nimport type { GroupedCellsData } from '../getCells';\nimport type { HeatmapSettingsImpl } from '../HeatmapSettingsImpl';\n\nconst COS_PI_4 = Math.cos(Math.PI / 4);\nfunction getTailByFacetKey (\n facetKey: string,\n groupKeys: string[],\n groupLabels: Record<string, string>,\n valueLabels: Record<string, string>,\n getKeysInGroup: (facetKey:string, groupKey:string) => string[],\n steps: Record<string, number>,\n scale: (v:string) => number,\n groupTitleInclined: boolean,\n labelTitleInclined: boolean,\n textMeasurer: TextMeasurer\n): number {\n const step = steps[facetKey];\n const labelsVisible = step > MIN_STEP_FOR_VISIBLE_LABELS;\n\n let maxTail = 0;\n groupKeys.forEach((groupKey) => {\n const keysInGroup = getKeysInGroup(facetKey, groupKey);\n if (keysInGroup.length === 0) {\n return 0;\n }\n const groupHalfWidth = (keysInGroup.length * step) / 2;\n const groupTail = groupTitleInclined\n ? textMeasurer.getTextWidth(groupLabels[groupKey] ?? groupKey) * COS_PI_4 - groupHalfWidth - scale(keysInGroup[0])\n : 0;\n const labelTail = labelTitleInclined && labelsVisible\n ? groupKeys.reduce((res, key) => {\n const label = valueLabels[key];\n return Math.max(res, textMeasurer.getTextWidth(label) * COS_PI_4 - step / 2 - scale(key));\n }, 0)\n : 0;\n maxTail = Math.max(maxTail, groupTail, labelTail);\n });\n return maxTail;\n}\n\nexport function calculateCaptionTails(\n labelAngles: LabelAngles,\n facetSettings: HeatmapSettingsImpl['facetSettings'],\n scales: ChartsScales,\n steps: {\n x: Record<string, number>;\n y: Record<string, number>;\n },\n groupedCells: GroupedCellsData,\n textMeasurer: TextMeasurer\n): {xCaptionTail: number; yCaptionTail: number} {\n const {facetKeys, xGroupKeys, yGroupKeys, xKeysByGroups, yKeysByGroups, xLabels, yLabels, xGroupLabels, yGroupLabels} = groupedCells.meta;\n let xCaptionTail = 0;\n let yCaptionTail = 0;\n // tails from 45deg inclined captions of groups titles/cells labels, that take place on adjacent padding\n const xGroupTitleInclined = labelAngles.xGroupLabels === 45;\n const xLabelsInclined = labelAngles.xAxisLabels === 45;\n if (xGroupTitleInclined || xLabelsInclined) {\n if (!facetSettings.sharedX) {\n facetKeys.forEach(facetKey => {\n xCaptionTail = Math.max(\n getTailByFacetKey(\n facetKey,\n xGroupKeys,\n xGroupLabels,\n xLabels,\n (facetKey:string, groupKey:string) => groupedCells.facets[facetKey].xKeysByGroups[groupKey],\n steps.x,\n scales.x[facetKey],\n xGroupTitleInclined,\n xLabelsInclined,\n textMeasurer\n ),\n xCaptionTail\n );\n });\n } else {\n const facetKey = facetKeys[0]; // there is no difference between facets in this case\n xCaptionTail = Math.max(\n getTailByFacetKey(\n facetKey,\n xGroupKeys,\n xGroupLabels,\n xLabels,\n (facetKey:string, groupKey:string) => xKeysByGroups[groupKey],\n steps.x,\n scales.x[facetKey],\n xGroupTitleInclined,\n xLabelsInclined,\n textMeasurer\n ),\n xCaptionTail\n );\n }\n }\n const yGroupTitleInclined = labelAngles.yGroupLabels === 45;\n const yLabelsInclined = labelAngles.yAxisLabels === 45;\n if (yGroupTitleInclined || yLabelsInclined) {\n if (!facetSettings.sharedY) {\n facetKeys.forEach(facetKey => {\n yCaptionTail = Math.max(\n getTailByFacetKey(\n facetKey,\n yGroupKeys,\n yGroupLabels,\n yLabels,\n (facetKey:string, groupKey:string) => groupedCells.facets[facetKey].yKeysByGroups[groupKey],\n steps.y,\n scales.y[facetKey],\n yGroupTitleInclined,\n yLabelsInclined,\n textMeasurer\n ),\n yCaptionTail\n );\n });\n } else {\n const facetKey = facetKeys[0]; // there is no difference between facets in this case\n yCaptionTail = Math.max(\n getTailByFacetKey(\n facetKey,\n yGroupKeys,\n yGroupLabels,\n yLabels,\n (facetKey:string, groupKey:string) => yKeysByGroups[groupKey],\n steps.y,\n scales.y[facetKey],\n yGroupTitleInclined,\n yLabelsInclined,\n textMeasurer\n ),\n yCaptionTail\n );\n }\n }\n return {xCaptionTail, yCaptionTail};\n}\n"],"names":["COS_PI_4","getTailByFacetKey","facetKey","groupKeys","groupLabels","valueLabels","getKeysInGroup","steps","scale","groupTitleInclined","labelTitleInclined","textMeasurer","step","labelsVisible","MIN_STEP_FOR_VISIBLE_LABELS","maxTail","groupKey","keysInGroup","groupHalfWidth","groupTail","labelTail","res","key","label","calculateCaptionTails","labelAngles","facetSettings","scales","groupedCells","facetKeys","xGroupKeys","yGroupKeys","xKeysByGroups","yKeysByGroups","xLabels","yLabels","xGroupLabels","yGroupLabels","xCaptionTail","yCaptionTail","xGroupTitleInclined","xLabelsInclined","yGroupTitleInclined","yLabelsInclined"],"mappings":";AAMA,MAAMA,IAAW,KAAK,IAAI,KAAK,KAAK,CAAC;AACrC,SAASC,EACLC,GACAC,GACAC,GACAC,GACAC,GACA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AAQ;AAAA,UACjBwC;AAAA,UACAC;AAAA,UACAhC;AAAA,QAAA;AAAA,QAEJ4B;AAAA,MAAA;AAAA,IAER;AAEJ,SAAO,EAAC,cAAAD,GAAc,cAAAC,EAAA;AAC1B;"}
|
|
@@ -44,6 +44,7 @@ declare class ChartRenderer {
|
|
|
44
44
|
notCalculatedProps: Partial<SVGLayerProps>;
|
|
45
45
|
allDots: Dot[];
|
|
46
46
|
visibleLabels: Label[];
|
|
47
|
+
dataFrame: DataFrame;
|
|
47
48
|
clear(): void;
|
|
48
49
|
init(node: HTMLElement): void;
|
|
49
50
|
updateChartSizes(size: ScatterplotUmapSettingsImpl['chartSettings']['size']): void;
|
|
@@ -52,8 +53,8 @@ declare class ChartRenderer {
|
|
|
52
53
|
createMainTitle(title: ScatterplotUmapSettingsImpl['chartSettings']['title']): void;
|
|
53
54
|
updateMargins(): void;
|
|
54
55
|
updateLegendSize(legend: ScatterplotUmapSettingsImpl['chartSettings']['legend'], legendLabels: ScatterplotUmapLegendInfo, grouping: ColumnName[], layers: ScatterplotUmapLayer[]): void;
|
|
55
|
-
initSettings(
|
|
56
|
-
updateAes(
|
|
56
|
+
initSettings(dots: Dot[], chartSettings: ScatterplotUmapSettingsImpl['chartSettings'], dotExtents: DotsExtents, legendInfo: ScatterplotUmapLegendInfo, layers: ScatterplotUmapSettingsImpl['layers'], grouping: ColumnName[]): void;
|
|
57
|
+
updateAes(legendInfo: ScatterplotUmapLegendInfo, layers: ScatterplotUmapSettingsImpl['layers']): void;
|
|
57
58
|
updatePointSize(): void;
|
|
58
59
|
updateByLasso(): void;
|
|
59
60
|
createQuadtree(dots: Dot[]): KDBush;
|
|
@@ -62,7 +63,7 @@ declare class ChartRenderer {
|
|
|
62
63
|
render(dataFrame: DataFrame, settingsId: string, chartSettings: ScatterplotUmapSettingsImpl['chartSettings'], keyColumn: ColumnName | null, dots: Dot[], dotExtents: DotsExtents, dotsByGrouping: Record<string, Dot[]>, layers: ScatterplotUmapSettingsImpl['layers'], legendInfo: ScatterplotUmapLegendInfo, grouping: ColumnName[], onPolygonUpdateOutside: ScatterplotEventHandlers['onPolygonUpdate'], onTooltipHintSwitch: (v: boolean) => void, onLassoControlsStateUpdate: (v: LassoControlsState) => void): void;
|
|
63
64
|
renderWebglLayer(): void;
|
|
64
65
|
onPolygonUpdate: (p: Polygon[]) => void;
|
|
65
|
-
renderSvgLayer(
|
|
66
|
+
renderSvgLayer(): void;
|
|
66
67
|
renderError(message: string): void;
|
|
67
68
|
private computeLabels;
|
|
68
69
|
private updateLabelsPosition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartRenderer.d.ts","sourceRoot":"","sources":["../../src/scatterplot-umap/ChartRenderer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAIrE,OAAO,KAAK,EAAe,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAG7C,OAAO,KAAK,EAAc,UAAU,EAAc,MAAM,iBAAiB,CAAC;AAY1E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uCAAuC,CAAC;AAEnE,OAAO,KAAK,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAErE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAM3E,OAAO,KAAK,EAAyB,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC/G,OAAO,KAAK,EACR,UAAU,EACV,aAAa,EACb,WAAW,EAAE,UAAU,EACvB,GAAG,EACH,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,OAAO,EACP,aAAa,EAChB,MAAM,SAAS,CAAC;AAQjB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO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