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