@milaboratories/miplots4 1.0.128 → 1.0.129
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/ChartRenderer.d.ts.map +1 -1
- package/dist/heatmap/ChartRenderer.js +251 -233
- package/dist/heatmap/ChartRenderer.js.map +1 -1
- package/dist/heatmap/components/Captions/GroupCaptions.d.ts.map +1 -1
- package/dist/heatmap/components/Captions/GroupCaptions.js +45 -36
- package/dist/heatmap/components/Captions/GroupCaptions.js.map +1 -1
- package/dist/heatmap/components/Chart.d.ts.map +1 -1
- package/dist/heatmap/components/Chart.js +71 -69
- package/dist/heatmap/components/Chart.js.map +1 -1
- package/dist/heatmap/components/Dendrograms.d.ts +3 -1
- package/dist/heatmap/components/Dendrograms.d.ts.map +1 -1
- package/dist/heatmap/components/Dendrograms.js +54 -48
- package/dist/heatmap/components/Dendrograms.js.map +1 -1
- package/dist/heatmap/components/types.d.ts +2 -2
- package/dist/heatmap/components/types.d.ts.map +1 -1
- package/dist/heatmap/getDendrograms.d.ts +2 -2
- package/dist/heatmap/getDendrograms.d.ts.map +1 -1
- package/dist/heatmap/getDendrograms.js +36 -36
- package/dist/heatmap/getDendrograms.js.map +1 -1
- package/dist/heatmap/utils/calculateCaptionTails.d.ts +2 -2
- package/dist/heatmap/utils/calculateCaptionTails.d.ts.map +1 -1
- package/dist/heatmap/utils/calculateCaptionTails.js +89 -54
- package/dist/heatmap/utils/calculateCaptionTails.js.map +1 -1
- package/dist/heatmap/utils/calculateChartSideElementSizes.js +19 -19
- package/dist/heatmap/utils/calculateChartSideElementSizes.js.map +1 -1
- package/dist/scatterplot/ChartRenderer.d.ts.map +1 -1
- package/dist/scatterplot/ChartRenderer.js +191 -178
- package/dist/scatterplot/ChartRenderer.js.map +1 -1
- package/dist/scatterplot/components/ChartsGroup.js +3 -3
- package/dist/scatterplot/components/ChartsGroup.js.map +1 -1
- package/dist/scatterplot-umap/components/Lasso.d.ts.map +1 -1
- package/dist/scatterplot-umap/components/Lasso.js +148 -124
- package/dist/scatterplot-umap/components/Lasso.js.map +1 -1
- package/dist/scatterplot-umap/components/LowerSVG.js +12 -12
- package/dist/scatterplot-umap/components/LowerSVG.js.map +1 -1
- package/dist/scatterplot-umap/index.d.ts.map +1 -1
- package/dist/scatterplot-umap/index.js +60 -60
- package/dist/scatterplot-umap/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,89 +1,101 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var b = (
|
|
4
|
-
import { j as
|
|
5
|
-
import { Error as
|
|
6
|
-
import { MIN_MARGIN as
|
|
1
|
+
var st = Object.defineProperty;
|
|
2
|
+
var et = (d, e, t) => e in d ? st(d, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[e] = t;
|
|
3
|
+
var b = (d, e, t) => et(d, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { j as O } from "../node_modules/react/jsx-runtime.js";
|
|
5
|
+
import { Error as ot } from "../common/Error.js";
|
|
6
|
+
import { MIN_MARGIN as w, TITLE_LINE as q, LEGEND_OFFSET as it, DEFAULT_AES as K, CHART_SIDE_ELEMENTS as nt, MIN_PADDING as rt } from "./constants.js";
|
|
7
7
|
import { calculateChartSideElementSizes as at } from "./utils/calculateChartSideElementSizes.js";
|
|
8
|
-
import { calculateSideElementsBBoxes as
|
|
9
|
-
import { createDiscreteColorScale as
|
|
10
|
-
import { calculateAnnotationTitleSizes as
|
|
11
|
-
import { calculateCaptionTails as
|
|
12
|
-
import { getChartEdgeSides as
|
|
13
|
-
import { getContinuousLegendTicks as
|
|
14
|
-
import
|
|
15
|
-
import { DEFAULT_HEIGHT as
|
|
16
|
-
import { createRoot as
|
|
17
|
-
import { ChartsGroup as
|
|
18
|
-
import { TextMeasurer as
|
|
19
|
-
import { arrangeLegendParts as
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
8
|
+
import { calculateSideElementsBBoxes as ht } from "./utils/calculateSideElementsBBoxes.js";
|
|
9
|
+
import { createDiscreteColorScale as V, createContinuousColorScale as lt } from "./utils/createColorScales.js";
|
|
10
|
+
import { calculateAnnotationTitleSizes as ct } from "./utils/calculateAnnotationTitleSizes.js";
|
|
11
|
+
import { calculateCaptionTails as ut } from "./utils/calculateCaptionTails.js";
|
|
12
|
+
import { getChartEdgeSides as pt } from "../utils/getChartEdgeSides.js";
|
|
13
|
+
import { getContinuousLegendTicks as J } from "../utils/getContinuousLegendTicks.js";
|
|
14
|
+
import dt from "../node_modules/lodash/lodash.js";
|
|
15
|
+
import { DEFAULT_HEIGHT as X, DEFAULT_WIDTH as Y, TITLE_LINE_HEIGHT as mt, TITLE_MARGIN as gt } from "../constants.js";
|
|
16
|
+
import { createRoot as xt } from "../node_modules/react-dom/client.js";
|
|
17
|
+
import { ChartsGroup as Ct } from "./components/ChartsGroup.js";
|
|
18
|
+
import { TextMeasurer as St } from "../utils/TextMeasurer.js";
|
|
19
|
+
import { arrangeLegendParts as ft } from "../utils/arrangeLegendParts.js";
|
|
20
|
+
import R from "../node_modules/d3-scale/src/ordinal.js";
|
|
21
|
+
import I from "../node_modules/d3-scale/src/linear.js";
|
|
22
|
+
import yt from "../node_modules/d3-array/src/extent.js";
|
|
23
|
+
import Q from "../node_modules/d3-hierarchy/src/cluster.js";
|
|
24
|
+
const Lt = Math.cos(Math.PI / 4), bt = 5;
|
|
25
|
+
function Z(d, e, t) {
|
|
26
|
+
function s(h) {
|
|
27
|
+
h[t] = e(h.data.height), h.children && h.children.forEach(s);
|
|
27
28
|
}
|
|
28
|
-
s(
|
|
29
|
+
s(d);
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
-
function
|
|
32
|
-
|
|
31
|
+
function $(d, e, t, s = t) {
|
|
32
|
+
function h(i) {
|
|
33
|
+
i[s] = i[t] + e, i.children && i.children.forEach(h);
|
|
33
34
|
}
|
|
34
|
-
|
|
35
|
+
h(d);
|
|
35
36
|
}
|
|
36
|
-
const
|
|
37
|
+
const At = (d, e) => {
|
|
37
38
|
const t = Math.min(...e), s = Math.max(...e);
|
|
38
39
|
if (t === s) {
|
|
39
|
-
const
|
|
40
|
-
for (let l = 1; l <
|
|
41
|
-
|
|
42
|
-
return
|
|
40
|
+
const r = d % 2 === 0 ? [] : [t];
|
|
41
|
+
for (let l = 1; l < d / 2 + 1; l++)
|
|
42
|
+
r.push(t + l), r.unshift(t - l);
|
|
43
|
+
return r;
|
|
43
44
|
}
|
|
44
|
-
if (
|
|
45
|
+
if (d < 2)
|
|
45
46
|
return [t, s];
|
|
46
|
-
const
|
|
47
|
-
for (let
|
|
48
|
-
|
|
49
|
-
return
|
|
47
|
+
const h = (s - t) / (d - 1), i = [];
|
|
48
|
+
for (let r = 0; r < d - 1; r++)
|
|
49
|
+
i.push(t + h * r);
|
|
50
|
+
return i.push(s), i;
|
|
50
51
|
};
|
|
51
|
-
function
|
|
52
|
+
function tt(d, e, t) {
|
|
52
53
|
let s = t;
|
|
53
|
-
return
|
|
54
|
+
return d && (d.colorRange && (s = d.colorRange), d.method === "standardScaling" && (s = [-2, 2]), d.method === "meanNormalization" && (s = [-0.75, 0.75])), At(e, s);
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
function F(d, e, t) {
|
|
57
|
+
let s = 0;
|
|
58
|
+
for (const h of d) {
|
|
59
|
+
const i = t.getTextWidth(e[h]);
|
|
60
|
+
i > s && (s = i);
|
|
61
|
+
}
|
|
62
|
+
return s;
|
|
63
|
+
}
|
|
64
|
+
function U(d, e) {
|
|
65
|
+
return e === 90 ? d : e === 45 ? d * Lt + (d > 0 ? 2 * bt : 0) : q;
|
|
66
|
+
}
|
|
67
|
+
class Xt {
|
|
56
68
|
constructor() {
|
|
57
69
|
b(this, "reactRoot", null);
|
|
58
70
|
b(this, "parentNode", null);
|
|
59
71
|
b(this, "rootNode", null);
|
|
60
|
-
b(this, "component", /* @__PURE__ */
|
|
72
|
+
b(this, "component", /* @__PURE__ */ O.jsx(O.Fragment, {}));
|
|
61
73
|
b(this, "chartsDimensions", {});
|
|
62
74
|
b(this, "chartSizes", {
|
|
63
|
-
chartWidth:
|
|
75
|
+
chartWidth: Y,
|
|
64
76
|
// width of single chart
|
|
65
|
-
chartHeight:
|
|
77
|
+
chartHeight: X,
|
|
66
78
|
// height of single chart
|
|
67
|
-
chartsWidth:
|
|
79
|
+
chartsWidth: Y,
|
|
68
80
|
// width of all charts in charts row
|
|
69
|
-
chartsHeight:
|
|
81
|
+
chartsHeight: X,
|
|
70
82
|
// width of all charts in charts column, without axes
|
|
71
|
-
totalWidth:
|
|
83
|
+
totalWidth: Y,
|
|
72
84
|
// width of all charts in charts row, plus left axis, plus legend
|
|
73
|
-
totalHeight:
|
|
85
|
+
totalHeight: X
|
|
74
86
|
// width of all charts in charts height, plus bottom axis, plus top title
|
|
75
87
|
});
|
|
76
88
|
b(this, "margins", {
|
|
77
|
-
top:
|
|
78
|
-
bottom:
|
|
79
|
-
left:
|
|
80
|
-
right:
|
|
89
|
+
top: w,
|
|
90
|
+
bottom: w,
|
|
91
|
+
left: w,
|
|
92
|
+
right: w
|
|
81
93
|
});
|
|
82
94
|
b(this, "captionsSizes", {
|
|
83
95
|
xAxisCaptions: 100,
|
|
84
96
|
yAxisCaptions: 100,
|
|
85
|
-
xGroupCaptions:
|
|
86
|
-
yGroupCaptions:
|
|
97
|
+
xGroupCaptions: q,
|
|
98
|
+
yGroupCaptions: q,
|
|
87
99
|
xCaptionTail: 0,
|
|
88
100
|
yCaptionTail: 0
|
|
89
101
|
});
|
|
@@ -97,11 +109,11 @@ class kt {
|
|
|
97
109
|
b(this, "rowsCount", 1);
|
|
98
110
|
b(this, "scales", {
|
|
99
111
|
// scales grouped by facet
|
|
100
|
-
x: { null:
|
|
101
|
-
y: { null:
|
|
112
|
+
x: { null: R().domain(["null"]).range([1]) },
|
|
113
|
+
y: { null: R().domain(["null"]).range([1]) }
|
|
102
114
|
});
|
|
103
115
|
b(this, "step", { x: {}, y: {} });
|
|
104
|
-
b(this, "colorScale",
|
|
116
|
+
b(this, "colorScale", I().domain([0, 1]).range(["white", "black"]));
|
|
105
117
|
b(this, "annotationColorScales", {});
|
|
106
118
|
b(this, "dendrogramAesScales", {});
|
|
107
119
|
b(this, "legend", {
|
|
@@ -119,257 +131,263 @@ class kt {
|
|
|
119
131
|
});
|
|
120
132
|
}
|
|
121
133
|
init(e) {
|
|
122
|
-
this.parentNode === null && (this.parentNode = e, this.rootNode = document.createElement("div"), this.parentNode.appendChild(this.rootNode), this.reactRoot =
|
|
134
|
+
this.parentNode === null && (this.parentNode = e, this.rootNode = document.createElement("div"), this.parentNode.appendChild(this.rootNode), this.reactRoot = xt(this.rootNode));
|
|
123
135
|
}
|
|
124
136
|
updateMargins(e) {
|
|
125
137
|
this.margins = {
|
|
126
|
-
top: e.show ?
|
|
127
|
-
bottom:
|
|
128
|
-
left:
|
|
129
|
-
right: this.legend.width +
|
|
138
|
+
top: e.show ? mt + gt * 2 : w,
|
|
139
|
+
bottom: w,
|
|
140
|
+
left: w,
|
|
141
|
+
right: this.legend.width + w
|
|
130
142
|
}, this.chartSizes.totalWidth = this.margins.left + this.chartSizes.chartsWidth + this.margins.right, this.chartSizes.totalHeight = this.margins.top + Math.max(this.chartSizes.chartsHeight + this.margins.bottom, this.legend.height);
|
|
131
143
|
}
|
|
132
|
-
updateLegendSize(e, t, s,
|
|
144
|
+
updateLegendSize(e, t, s, h, i) {
|
|
133
145
|
if (!t.show) {
|
|
134
146
|
this.legend = { width: 0, height: 0, items: [] };
|
|
135
147
|
return;
|
|
136
148
|
}
|
|
137
|
-
const
|
|
149
|
+
const r = this.chartSizes.chartHeight, l = [], u = { width: 0, height: 0, left: 0, top: 0 }, A = (c) => c.reduce((a, n) => (a[n] = String(n), a), {});
|
|
138
150
|
if (e === "continuous") {
|
|
139
|
-
const
|
|
151
|
+
const c = this.colorScale, a = J(c, i), n = I([a[0], a[a.length - 1]], [r, 0]), o = h.label ?? h.value;
|
|
140
152
|
l.push({
|
|
141
|
-
...
|
|
153
|
+
...u,
|
|
142
154
|
type: "continuous",
|
|
143
155
|
id: "heatmapValue",
|
|
144
|
-
scale:
|
|
145
|
-
values:
|
|
146
|
-
title:
|
|
147
|
-
tickPositionScale:
|
|
156
|
+
scale: c,
|
|
157
|
+
values: a,
|
|
158
|
+
title: o,
|
|
159
|
+
tickPositionScale: n
|
|
148
160
|
});
|
|
149
161
|
} else if (e === "discrete") {
|
|
150
|
-
const
|
|
151
|
-
l.push({ ...
|
|
162
|
+
const c = this.colorScale, a = h.label ?? h.value, n = c.domain(), o = A(n);
|
|
163
|
+
l.push({ ...u, type: "discreteColor", id: "heatmapValue", title: a, scale: c, values: n, labels: o });
|
|
152
164
|
}
|
|
153
|
-
if (s.forEach((
|
|
154
|
-
const
|
|
155
|
-
if (
|
|
156
|
-
const
|
|
157
|
-
l.push({ ...
|
|
165
|
+
if (s.forEach((c) => {
|
|
166
|
+
const a = c.valueColumn.label ?? c.valueColumn.value;
|
|
167
|
+
if (c.type === "continuous") {
|
|
168
|
+
const n = this.annotationColorScales[c.id].scale, o = J(n, i), x = I([o[0], o[o.length - 1]], [r, 0]);
|
|
169
|
+
l.push({ ...u, type: "continuous", id: c.id, tickPositionScale: x, title: a, scale: n, values: o });
|
|
158
170
|
}
|
|
159
|
-
if (
|
|
160
|
-
const
|
|
161
|
-
l.push({ ...
|
|
171
|
+
if (c.type === "discrete") {
|
|
172
|
+
const n = this.annotationColorScales[c.id].scale, o = n.domain(), x = A(o);
|
|
173
|
+
l.push({ ...u, type: "discreteColor", id: c.id, title: a, scale: n, values: o, labels: x });
|
|
162
174
|
}
|
|
163
175
|
}), !l.length) {
|
|
164
176
|
this.legend = { width: 0, height: 0, items: [] };
|
|
165
177
|
return;
|
|
166
178
|
}
|
|
167
|
-
const
|
|
179
|
+
const f = ft(l, this.chartSizes.chartHeight), m = f[f.length - 1], y = m.left + m.width + it;
|
|
168
180
|
this.legend = {
|
|
169
|
-
width:
|
|
170
|
-
height:
|
|
171
|
-
items:
|
|
181
|
+
width: y,
|
|
182
|
+
height: r,
|
|
183
|
+
items: f
|
|
172
184
|
};
|
|
173
185
|
}
|
|
174
|
-
updateCaptionsSize(e, t, s,
|
|
175
|
-
const
|
|
186
|
+
updateCaptionsSize(e, t, s, h) {
|
|
187
|
+
const i = new St("bold 16px Manrope"), { xGroupKeys: r, yGroupKeys: l, xGroupLabels: u, yGroupLabels: A, xKeysByGroups: f, yKeysByGroups: m, xLabels: y, yLabels: c } = e.meta;
|
|
176
188
|
this.labelAngles = {
|
|
177
189
|
xAxisLabels: t.axisLabelsAngle,
|
|
178
190
|
yAxisLabels: s.axisLabelsAngle,
|
|
179
191
|
xGroupLabels: t.groupLabelsAngle,
|
|
180
192
|
yGroupLabels: s.groupLabelsAngle
|
|
181
193
|
};
|
|
182
|
-
|
|
183
|
-
let v = 0;
|
|
184
|
-
for (const w of H) {
|
|
185
|
-
const G = n.getTextWidth(R[w]);
|
|
186
|
-
G > v && (v = G);
|
|
187
|
-
}
|
|
188
|
-
return v;
|
|
189
|
-
}
|
|
190
|
-
const o = F.flatten(Object.values(S)), a = F.flatten(Object.values(d)), C = h(o, f), m = h(a, u), p = h(i, c), g = h(l, z), { xCaptionTail: y, yCaptionTail: A } = ct(
|
|
194
|
+
const a = r.reduce((C, S) => Math.max(C, F(f[S], y, i)), 0), n = l.reduce((C, S) => Math.max(C, F(m[S], c, i)), 0), o = F(r, u, i), x = F(l, A, i), { xCaptionTail: p, yCaptionTail: g } = ut(
|
|
191
195
|
this.labelAngles,
|
|
192
|
-
|
|
196
|
+
h,
|
|
197
|
+
this.scales,
|
|
193
198
|
this.step,
|
|
194
199
|
e,
|
|
195
|
-
|
|
196
|
-
)
|
|
200
|
+
i
|
|
201
|
+
);
|
|
197
202
|
this.captionsSizes = {
|
|
198
|
-
xCaptionTail:
|
|
199
|
-
yCaptionTail:
|
|
200
|
-
xGroupCaptions:
|
|
201
|
-
yGroupCaptions:
|
|
202
|
-
xAxisCaptions:
|
|
203
|
-
yAxisCaptions:
|
|
203
|
+
xCaptionTail: p,
|
|
204
|
+
yCaptionTail: g,
|
|
205
|
+
xGroupCaptions: U(o, this.labelAngles.xGroupLabels),
|
|
206
|
+
yGroupCaptions: U(x, this.labelAngles.yGroupLabels),
|
|
207
|
+
xAxisCaptions: U(a, this.labelAngles.xAxisLabels),
|
|
208
|
+
yAxisCaptions: U(n, this.labelAngles.yAxisLabels)
|
|
204
209
|
};
|
|
205
210
|
}
|
|
206
|
-
updateChartDimensions(e, t, s,
|
|
207
|
-
const
|
|
208
|
-
this.columnsCount =
|
|
209
|
-
const { width:
|
|
211
|
+
updateChartDimensions(e, t, s, h, i, r, l, u, A, f) {
|
|
212
|
+
const m = t.length, y = Math.min(i.nRows ?? m, m), c = Math.min(i.nCols ?? m, m);
|
|
213
|
+
this.columnsCount = i.nRows ? Math.ceil(m / y) : c, this.rowsCount = Math.ceil(m / this.columnsCount);
|
|
214
|
+
const { width: a, height: n } = e, { sharedX: o, sharedY: x } = i;
|
|
210
215
|
this.chartsDimensions = {};
|
|
211
|
-
let
|
|
212
|
-
t.forEach((
|
|
213
|
-
const N = E % this.columnsCount + 1, M =
|
|
214
|
-
|
|
216
|
+
let p = 0, g = 0;
|
|
217
|
+
t.forEach((z, E) => {
|
|
218
|
+
const N = E % this.columnsCount + 1, M = pt(E, t.length, this.columnsCount, this.rowsCount), B = this.step.x[z], v = this.step.y[z], _ = at(
|
|
219
|
+
r,
|
|
215
220
|
l,
|
|
216
221
|
this.captionsSizes,
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
222
|
+
u,
|
|
223
|
+
A,
|
|
224
|
+
f,
|
|
220
225
|
M,
|
|
221
|
-
|
|
222
|
-
|
|
226
|
+
o,
|
|
227
|
+
x,
|
|
223
228
|
t,
|
|
224
229
|
s,
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
),
|
|
229
|
-
function
|
|
230
|
+
h,
|
|
231
|
+
B,
|
|
232
|
+
v
|
|
233
|
+
), P = ct(u, M, o, x);
|
|
234
|
+
function H(D) {
|
|
230
235
|
return Math.max(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
236
|
+
nt[D].reduce((L, G) => L + _[D][G], 0),
|
|
237
|
+
P[D],
|
|
238
|
+
rt
|
|
234
239
|
);
|
|
235
240
|
}
|
|
236
|
-
const
|
|
237
|
-
left:
|
|
238
|
-
right:
|
|
239
|
-
top:
|
|
240
|
-
bottom:
|
|
241
|
+
const T = {
|
|
242
|
+
left: H("left"),
|
|
243
|
+
right: H("right"),
|
|
244
|
+
top: H("top"),
|
|
245
|
+
bottom: H("bottom")
|
|
241
246
|
};
|
|
242
|
-
|
|
243
|
-
const
|
|
244
|
-
this.chartsDimensions[
|
|
245
|
-
left:
|
|
246
|
-
top:
|
|
247
|
-
inner: { width:
|
|
248
|
-
outer: { width:
|
|
249
|
-
padding:
|
|
250
|
-
sideElementBBoxes:
|
|
247
|
+
T.left < this.captionsSizes.xCaptionTail && (T.left = this.captionsSizes.xCaptionTail), T.bottom < this.captionsSizes.yCaptionTail && (T.bottom = this.captionsSizes.yCaptionTail);
|
|
248
|
+
const W = ht(_, a, n), j = a + T.left + T.right, k = n + T.top + T.bottom;
|
|
249
|
+
this.chartsDimensions[z] = {
|
|
250
|
+
left: p,
|
|
251
|
+
top: g,
|
|
252
|
+
inner: { width: a, height: n },
|
|
253
|
+
outer: { width: j, height: k },
|
|
254
|
+
padding: T,
|
|
255
|
+
sideElementBBoxes: W,
|
|
251
256
|
chartEdgeSides: M
|
|
252
|
-
},
|
|
257
|
+
}, p += j, N === this.columnsCount && (p = 0, g += k);
|
|
253
258
|
});
|
|
254
|
-
const
|
|
255
|
-
this.chartSizes.chartsWidth =
|
|
259
|
+
const C = t.slice(0, this.columnsCount).reduce((z, E) => z + this.chartsDimensions[E].outer.width, 0), S = t.filter((z, E) => E % this.columnsCount === 0).reduce((z, E) => z + this.chartsDimensions[E].outer.height, 0);
|
|
260
|
+
this.chartSizes.chartsWidth = C, this.chartSizes.chartsHeight = S;
|
|
256
261
|
}
|
|
257
262
|
updateChartsSizes(e) {
|
|
258
263
|
const { width: t, height: s } = e;
|
|
259
264
|
this.chartSizes.chartWidth = t, this.chartSizes.chartHeight = s;
|
|
260
265
|
}
|
|
261
266
|
// update scales for cell positions, x and y for each facet
|
|
262
|
-
updateScales(e, t, s,
|
|
263
|
-
const { width:
|
|
264
|
-
(
|
|
265
|
-
),
|
|
266
|
-
(
|
|
267
|
+
updateScales(e, t, s, h, i, r, l, u, A) {
|
|
268
|
+
const { width: f, height: m } = i, { meta: y, facets: c } = t, { sharedX: a, sharedY: n } = h, o = (p, g = {}) => p.sort(
|
|
269
|
+
(C, S) => r.sorting === "asc" ? (g[C] ?? C).localeCompare(g[S] ?? S, "en", { numeric: !0 }) : (g[S] ?? S).localeCompare(g[C] ?? C, "en", { numeric: !0 })
|
|
270
|
+
), x = (p, g = {}) => p.sort(
|
|
271
|
+
(C, S) => l.sorting === "asc" ? (g[C] ?? C).localeCompare(g[S] ?? S, "en", { numeric: !0 }) : (g[S] ?? S).localeCompare(g[C] ?? C, "en", { numeric: !0 })
|
|
267
272
|
);
|
|
268
|
-
e.forEach((
|
|
269
|
-
const
|
|
270
|
-
let
|
|
271
|
-
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}),
|
|
273
|
+
e.forEach((p) => {
|
|
274
|
+
const g = c[p], C = o(y.xGroupKeys), S = x(y.yGroupKeys), { xKeysByGroups: z } = a ? y : g, { yKeysByGroups: E } = n ? y : g, N = C.map((L) => z[L].length), M = S.map((L) => E[L].length), B = N.reduce((L, G) => L + G, 0), v = M.reduce((L, G) => L + G, 0), _ = (f - (N.filter((L) => L > 0).length - 1) * s) / B, P = (m - (M.filter((L) => L > 0).length - 1) * s) / v, H = [], T = [];
|
|
275
|
+
let W = 0;
|
|
276
|
+
C.forEach((L) => {
|
|
277
|
+
const G = u ? z[L] : o(z[L], y.xLabels);
|
|
278
|
+
T.push(...G), G.forEach(() => {
|
|
279
|
+
H.push(W), W += _;
|
|
280
|
+
}), G.length > 0 && (W += s);
|
|
276
281
|
});
|
|
277
|
-
const
|
|
278
|
-
let
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}),
|
|
284
|
-
}), this.scales.x[
|
|
282
|
+
const j = [], k = [];
|
|
283
|
+
let D = 0;
|
|
284
|
+
S.forEach((L) => {
|
|
285
|
+
const G = A ? E[L] : x(E[L], y.yLabels);
|
|
286
|
+
k.push(...G), G.forEach(() => {
|
|
287
|
+
j.push(D), D += P;
|
|
288
|
+
}), G.length > 0 && (D += s);
|
|
289
|
+
}), this.scales.x[p] = R().domain(T).range(H), this.scales.y[p] = R().domain(k).range(j), this.step.x[p] = _, this.step.y[p] = P;
|
|
285
290
|
});
|
|
286
291
|
}
|
|
287
|
-
updateAesScale(e, t, s,
|
|
292
|
+
updateAesScale(e, t, s, h, i, r, l) {
|
|
288
293
|
if (e === "continuous")
|
|
289
|
-
s.valueColors ? this.colorScale =
|
|
294
|
+
s.valueColors ? this.colorScale = I().domain(s.valuesByColors ?? tt(l, s.valueColors.length, t)).range(s.valueColors) : s.colorsList && (this.colorScale = I().domain(tt(l, s.colorsList.length, t)).range(s.colorsList));
|
|
290
295
|
else if (s.colorsMap) {
|
|
291
|
-
const
|
|
292
|
-
this.colorScale =
|
|
293
|
-
} else s.colorsList && (this.colorScale =
|
|
294
|
-
const { xDataByKeys:
|
|
295
|
-
|
|
296
|
-
const { colors:
|
|
297
|
-
if (
|
|
298
|
-
const
|
|
299
|
-
this.annotationColorScales[
|
|
296
|
+
const f = Object.entries(s.colorsMap);
|
|
297
|
+
this.colorScale = R().domain(f.map((m) => m[0])).range(f.map((m) => m[1])).unknown("#ccc");
|
|
298
|
+
} else s.colorsList && (this.colorScale = V(s.colorsList, r.map(String)));
|
|
299
|
+
const { xDataByKeys: u, yDataByKeys: A } = i.meta;
|
|
300
|
+
h.forEach((f) => {
|
|
301
|
+
const { colors: m, type: y, axis: c, valueColumn: a } = f, n = (c === "x" ? u : A)[a.value];
|
|
302
|
+
if (y === "discrete") {
|
|
303
|
+
const o = dt.uniq(Object.values(n).map(String)).sort();
|
|
304
|
+
this.annotationColorScales[f.id] = {
|
|
300
305
|
type: "discrete",
|
|
301
|
-
scale:
|
|
306
|
+
scale: V(m, o)
|
|
302
307
|
};
|
|
303
308
|
} else {
|
|
304
|
-
const
|
|
305
|
-
if (!
|
|
309
|
+
const o = Object.values(n).map(Number);
|
|
310
|
+
if (!o.length)
|
|
306
311
|
return;
|
|
307
|
-
const [
|
|
308
|
-
this.annotationColorScales[
|
|
312
|
+
const [x = o[0], p = o[0]] = yt(o);
|
|
313
|
+
this.annotationColorScales[f.id] = {
|
|
309
314
|
type: "continuous",
|
|
310
|
-
scale: lt(
|
|
315
|
+
scale: lt(m, x, p, 0, 0.5, 1)
|
|
311
316
|
};
|
|
312
317
|
}
|
|
313
318
|
});
|
|
314
319
|
}
|
|
315
|
-
updateDendrogram(e, t, s,
|
|
316
|
-
e.forEach((
|
|
317
|
-
this.dendrograms[
|
|
318
|
-
const { xKeysByGroups:
|
|
319
|
-
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
o
|
|
323
|
-
);
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
o
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
320
|
+
updateDendrogram(e, t, s, h, i, r, l) {
|
|
321
|
+
e.forEach((u) => {
|
|
322
|
+
this.dendrograms[u] = { x: { treesByGroupKey: {}, data: r }, y: { treesByGroupKey: {}, data: l } };
|
|
323
|
+
const { xKeysByGroups: A, yKeysByGroups: f } = h[u], { hierarchyByGroupX: m, hierarchyByGroupY: y } = i[u];
|
|
324
|
+
if (r) {
|
|
325
|
+
const c = t.reduce((a, n) => {
|
|
326
|
+
var o;
|
|
327
|
+
return Math.max(a, (o = m[n]) == null ? void 0 : o.data.height);
|
|
328
|
+
}, 0);
|
|
329
|
+
this.dendrograms[u].x.treesByGroupKey = t.reduce((a, n) => {
|
|
330
|
+
const o = m[n], x = A[n];
|
|
331
|
+
Q().separation(() => 1).size([x.length * this.step.x[u], r.size])(
|
|
332
|
+
o
|
|
333
|
+
);
|
|
334
|
+
const p = o, g = I().domain(r.position === "top" ? [0, c] : [c, 0]).range([r.size, 0]);
|
|
335
|
+
return Z(p, g, "y"), $(p, this.scales.x[u](x[0]), "x"), a[n] = p, a;
|
|
336
|
+
}, {}), this.dendrograms[u].x.data = r;
|
|
337
|
+
}
|
|
338
|
+
if (l) {
|
|
339
|
+
const c = s.reduce((a, n) => {
|
|
340
|
+
var o;
|
|
341
|
+
return Math.max(a, (o = y[n]) == null ? void 0 : o.data.height);
|
|
342
|
+
}, 0);
|
|
343
|
+
this.dendrograms[u].y.treesByGroupKey = s.reduce((a, n) => {
|
|
344
|
+
const o = y[n], x = f[n];
|
|
345
|
+
Q().separation(() => 1).size([x.length * this.step.y[u], l.size])(
|
|
346
|
+
o
|
|
347
|
+
);
|
|
348
|
+
const p = o, g = I().domain(l.position === "left" ? [0, c] : [c, 0]).range([l.size, 0]);
|
|
349
|
+
return $(p, this.scales.y[u](x[0]), "x", "y"), Z(p, g, "x"), a[n] = p, a;
|
|
350
|
+
}, {}), this.dendrograms[u].y.data = l;
|
|
351
|
+
}
|
|
334
352
|
});
|
|
335
353
|
}
|
|
336
354
|
updateDendrogramAesScales(e) {
|
|
337
355
|
if (!e)
|
|
338
356
|
return;
|
|
339
357
|
const t = Object.keys(e);
|
|
340
|
-
this.dendrogramAesScales = t.reduce((s,
|
|
341
|
-
const
|
|
342
|
-
return s[
|
|
343
|
-
|
|
344
|
-
...
|
|
345
|
-
...
|
|
358
|
+
this.dendrogramAesScales = t.reduce((s, h) => {
|
|
359
|
+
const i = e[h], r = Object.keys(i);
|
|
360
|
+
return s[h] = R().domain(r).range(
|
|
361
|
+
r.map((l) => ({
|
|
362
|
+
...K,
|
|
363
|
+
...i[l]
|
|
346
364
|
}))
|
|
347
|
-
).unknown(
|
|
365
|
+
).unknown(K), s;
|
|
348
366
|
}, {});
|
|
349
367
|
}
|
|
350
|
-
render(e, t, s,
|
|
351
|
-
var
|
|
352
|
-
const { meta:
|
|
353
|
-
this.updateChartsSizes(N), this.updateAesScale(M,
|
|
368
|
+
render(e, t, s, h, i, r, l, u, A, f, m, y, c, a) {
|
|
369
|
+
var v;
|
|
370
|
+
const { meta: n, facets: o } = i, { facetKeys: x, xGroupKeys: p, yGroupKeys: g, valueExtent: C } = n, { xAxis: S, yAxis: z, title: E, size: N, valueType: M } = t;
|
|
371
|
+
this.updateChartsSizes(N), this.updateAesScale(M, C, h, r, i, y, c), this.updateScales(x, i, h.groupGap, s, N, t.xAxis, t.yAxis, u, A), this.updateCaptionsSize(i, S, z, s), this.updateChartDimensions(
|
|
354
372
|
N,
|
|
355
|
-
|
|
356
|
-
m,
|
|
373
|
+
x,
|
|
357
374
|
p,
|
|
375
|
+
g,
|
|
358
376
|
s,
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
), this.updateLegendSize(M, t.legend,
|
|
365
|
-
const
|
|
366
|
-
|
|
377
|
+
S,
|
|
378
|
+
z,
|
|
379
|
+
r,
|
|
380
|
+
u,
|
|
381
|
+
A
|
|
382
|
+
), this.updateLegendSize(M, t.legend, r, l, C), this.updateMargins(E), this.updateDendrogram(x, p, g, o, f, u, A), this.updateDendrogramAesScales(m);
|
|
383
|
+
const B = /* @__PURE__ */ O.jsx(
|
|
384
|
+
Ct,
|
|
367
385
|
{
|
|
368
|
-
aes:
|
|
369
|
-
annotations:
|
|
386
|
+
aes: h,
|
|
387
|
+
annotations: r,
|
|
370
388
|
annotationColorScales: this.annotationColorScales,
|
|
371
389
|
captionsSizes: this.captionsSizes,
|
|
372
|
-
cellsMeta:
|
|
390
|
+
cellsMeta: n,
|
|
373
391
|
columnsCount: this.columnsCount,
|
|
374
392
|
chartsDimensions: this.chartsDimensions,
|
|
375
393
|
chartSettings: t,
|
|
@@ -377,28 +395,28 @@ class kt {
|
|
|
377
395
|
colorScale: this.colorScale,
|
|
378
396
|
dendrogramAesScales: this.dendrogramAesScales,
|
|
379
397
|
dendrograms: this.dendrograms,
|
|
380
|
-
facetKeys:
|
|
398
|
+
facetKeys: x,
|
|
381
399
|
facetSettings: s,
|
|
382
|
-
groupedCells:
|
|
400
|
+
groupedCells: o,
|
|
383
401
|
labelAngles: this.labelAngles,
|
|
384
402
|
legend: this.legend,
|
|
385
403
|
margins: this.margins,
|
|
386
404
|
scales: this.scales,
|
|
387
405
|
settingsId: e,
|
|
388
406
|
step: this.step,
|
|
389
|
-
xGroupKeys:
|
|
390
|
-
yGroupKeys:
|
|
391
|
-
onTooltipHintSwitch:
|
|
407
|
+
xGroupKeys: p,
|
|
408
|
+
yGroupKeys: g,
|
|
409
|
+
onTooltipHintSwitch: a
|
|
392
410
|
}
|
|
393
411
|
);
|
|
394
|
-
this.component =
|
|
412
|
+
this.component = B, (v = this.reactRoot) == null || v.render(B);
|
|
395
413
|
}
|
|
396
414
|
renderError(e) {
|
|
397
415
|
var t;
|
|
398
|
-
(t = this.reactRoot) == null || t.render(/* @__PURE__ */
|
|
416
|
+
(t = this.reactRoot) == null || t.render(/* @__PURE__ */ O.jsx(ot, { message: e }));
|
|
399
417
|
}
|
|
400
418
|
}
|
|
401
419
|
export {
|
|
402
|
-
|
|
420
|
+
Xt as default
|
|
403
421
|
};
|
|
404
422
|
//# sourceMappingURL=ChartRenderer.js.map
|