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