@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var _ = Object.defineProperty;
|
|
2
2
|
var k = (y, t, e) => t in y ? _(y, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : y[t] = e;
|
|
3
|
-
var
|
|
3
|
+
var h = (y, t, e) => k(y, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import { j as b } from "../node_modules/react/jsx-runtime.js";
|
|
5
5
|
import K from "../node_modules/@d3fc/d3fc-chart/src/cartesian.js";
|
|
6
6
|
import "../node_modules/@d3fc/d3fc-webgl/src/scale/scaleMapper.js";
|
|
@@ -12,13 +12,13 @@ import $ from "../node_modules/d3-zoom/src/zoom.js";
|
|
|
12
12
|
import "../node_modules/d3-zoom/src/transform.js";
|
|
13
13
|
import { createRoot as Q } from "../node_modules/react-dom/client.js";
|
|
14
14
|
import { Error as J } from "../common/Error.js";
|
|
15
|
-
import { BLACK as
|
|
15
|
+
import { BLACK as G, DEFAULT_HEIGHT as w, DEFAULT_WIDTH as D, TITLE_LINE_HEIGHT as Z, TITLE_MARGIN as tt } from "../constants.js";
|
|
16
16
|
import { splitTextByWidth as et } from "../utils/splitTextByWidth.js";
|
|
17
|
-
import { MIN_MARGIN as
|
|
17
|
+
import { MIN_MARGIN as C, DEFAULT_DOT_AES as F } from "../scatterplot/constants.js";
|
|
18
18
|
import { createAesGetter as H } from "../scatterplot/utils/createAesGetter.js";
|
|
19
19
|
import { getTicksAndFormat as it } from "../scatterplot/utils/getTicksAndFormat.js";
|
|
20
20
|
import { createLabelPositioner as st } from "../scatterplot/utils/getVisibleLabels.js";
|
|
21
|
-
import { isContinuousAes as
|
|
21
|
+
import { isContinuousAes as R } from "../types/common.js";
|
|
22
22
|
import "../types/discrete.js";
|
|
23
23
|
import "../types/scatterplot.js";
|
|
24
24
|
import "../types/heatmap.js";
|
|
@@ -27,56 +27,57 @@ import "../types/histogram.js";
|
|
|
27
27
|
import "../types/bubble.js";
|
|
28
28
|
import { getContinuousColorScale as ot } from "../utils/getContinuousColorScale.js";
|
|
29
29
|
import { getContinuousLegendTicks as at } from "../utils/getContinuousLegendTicks.js";
|
|
30
|
-
import { TextMeasurer as
|
|
30
|
+
import { TextMeasurer as A } from "../utils/TextMeasurer/TextMeasurer.js";
|
|
31
31
|
import { SVGLayer as nt } from "./components/SVGLayer.js";
|
|
32
32
|
import { PADDINGS as W, TITLE_LINE as I, LEGEND_OFFSET as rt } from "./constants.js";
|
|
33
33
|
import lt from "../node_modules/@d3fc/d3fc-pointer/src/pointer.js";
|
|
34
34
|
import ht from "../node_modules/kdbush/index.js";
|
|
35
35
|
import { DataFrameProvider as ct } from "../common/useDataFrame.js";
|
|
36
|
-
import {
|
|
36
|
+
import { DataFrame as dt } from "../DataFrame.js";
|
|
37
|
+
import { arrangeLegendParts as mt } from "../utils/arrangeLegendParts.js";
|
|
37
38
|
import { stringToNumberRgba as M, getColorWithFakeOpacity as P, GET_BLACK as O } from "./colors.js";
|
|
38
|
-
import
|
|
39
|
+
import L from "../node_modules/d3-scale/src/linear.js";
|
|
39
40
|
import V from "../node_modules/d3-scale/src/log.js";
|
|
40
41
|
import N from "../node_modules/d3-selection/src/select.js";
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import { sqrt as
|
|
44
|
-
import
|
|
42
|
+
import pt from "../node_modules/d3-scale/src/ordinal.js";
|
|
43
|
+
import gt from "../node_modules/d3-scale/src/symlog.js";
|
|
44
|
+
import { sqrt as ut } from "../node_modules/d3-scale/src/pow.js";
|
|
45
|
+
import ft from "../node_modules/d3-polygon/src/contains.js";
|
|
45
46
|
function B(y) {
|
|
46
47
|
return y / 2.35 * (y / 2.35) * 64;
|
|
47
48
|
}
|
|
48
49
|
function E(y, t, e) {
|
|
49
|
-
return e.length === 0 ? !0 : e.some((i) => i.closed && i.points.length > 2 &&
|
|
50
|
+
return e.length === 0 ? !0 : e.some((i) => i.closed && i.points.length > 2 && ft(i.points, [y, t]));
|
|
50
51
|
}
|
|
51
52
|
function U(y, t, e) {
|
|
52
|
-
const i = e.find((o) => o.type === "dots"),
|
|
53
|
+
const i = e.find((o) => o.type === "dots"), l = e.find((o) => o.type === "curve");
|
|
53
54
|
return {
|
|
54
|
-
dotFill: H(y, t, (i == null ? void 0 : i.aes.dotFill) ??
|
|
55
|
-
dotSize: H(y, t, (i == null ? void 0 : i.aes.dotSize) ??
|
|
56
|
-
lineType: H(y, t, (
|
|
55
|
+
dotFill: H(y, t, (i == null ? void 0 : i.aes.dotFill) ?? F.color, "dotFill"),
|
|
56
|
+
dotSize: H(y, t, (i == null ? void 0 : i.aes.dotSize) ?? F.size, "dotSize"),
|
|
57
|
+
lineType: H(y, t, (l == null ? void 0 : l.aes.lineShape) ?? "solid", "lineShape")
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
|
-
class
|
|
60
|
+
class ne {
|
|
60
61
|
constructor() {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
h(this, "reactRoot", null);
|
|
63
|
+
h(this, "parentNode", null);
|
|
64
|
+
h(this, "rootNode", null);
|
|
65
|
+
h(this, "canvasNode", null);
|
|
66
|
+
h(this, "svgLayerElement", null);
|
|
67
|
+
h(this, "svgLayerComponent", /* @__PURE__ */ b.jsx(b.Fragment, {}));
|
|
68
|
+
h(this, "aesGetters", {
|
|
68
69
|
dotSize: () => 2,
|
|
69
|
-
dotFill: () =>
|
|
70
|
+
dotFill: () => G,
|
|
70
71
|
lineType: () => "solid"
|
|
71
72
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
top:
|
|
75
|
-
bottom:
|
|
76
|
-
left:
|
|
77
|
-
right:
|
|
73
|
+
h(this, "tools", null);
|
|
74
|
+
h(this, "margins", {
|
|
75
|
+
top: C,
|
|
76
|
+
bottom: C,
|
|
77
|
+
left: C,
|
|
78
|
+
right: C
|
|
78
79
|
});
|
|
79
|
-
|
|
80
|
+
h(this, "chartSizes", {
|
|
80
81
|
chartWidth: D,
|
|
81
82
|
// width of single chart
|
|
82
83
|
chartHeight: w,
|
|
@@ -86,33 +87,34 @@ class oe {
|
|
|
86
87
|
totalHeight: w
|
|
87
88
|
// width of all charts in charts height, plus bottom axis, plus top title
|
|
88
89
|
});
|
|
89
|
-
|
|
90
|
-
x:
|
|
91
|
-
y:
|
|
92
|
-
xOriginal:
|
|
93
|
-
yOriginal:
|
|
90
|
+
h(this, "scales", {
|
|
91
|
+
x: L().domain([0, 10]).range([0, D]),
|
|
92
|
+
y: L().domain([0, 10]).range([w, 0]),
|
|
93
|
+
xOriginal: L().domain([0, 10]).range([0, D]),
|
|
94
|
+
yOriginal: L().domain([0, 10]).range([w, 0])
|
|
94
95
|
});
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
h(this, "polygons", []);
|
|
97
|
+
h(this, "onPolygonUpdateOutside", () => {
|
|
97
98
|
});
|
|
98
|
-
|
|
99
|
+
h(this, "onTooltipHintSwitch", () => {
|
|
99
100
|
});
|
|
100
|
-
|
|
101
|
+
h(this, "onLassoControlsStateUpdate", () => {
|
|
101
102
|
});
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
h(this, "zoomTransform", null);
|
|
104
|
+
h(this, "zoomStateKey", "");
|
|
105
|
+
h(this, "selectedDot", null);
|
|
106
|
+
h(this, "captionsSizes", {
|
|
106
107
|
xAxisCaptionsWidth: 30,
|
|
107
108
|
yAxisCaptionsWidth: 100
|
|
108
109
|
});
|
|
109
|
-
|
|
110
|
+
h(this, "mainTitle", []);
|
|
110
111
|
// can be multiline
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
h(this, "legend", { width: 0, height: 0, items: [] });
|
|
113
|
+
h(this, "notCalculatedProps", {});
|
|
114
|
+
h(this, "allDots", []);
|
|
115
|
+
h(this, "visibleLabels", []);
|
|
116
|
+
h(this, "dataFrame", new dt("", {}));
|
|
117
|
+
h(this, "onPolygonUpdate", (t) => {
|
|
116
118
|
this.polygons = t, this.updateByLasso();
|
|
117
119
|
const e = this.allDots.filter((i) => E(i.x, i.y, this.polygons)).map((i) => i.idx);
|
|
118
120
|
this.onPolygonUpdateOutside(e, t);
|
|
@@ -132,33 +134,33 @@ class oe {
|
|
|
132
134
|
(t.width !== this.chartSizes.chartWidth || t.height !== this.chartSizes.chartHeight) && (this.chartSizes.chartWidth = t.width, this.chartSizes.chartHeight = t.height, this.scales.x.range([0, this.chartSizes.chartWidth]), this.scales.y.range([this.chartSizes.chartHeight, 0]));
|
|
133
135
|
}
|
|
134
136
|
updateViewport(t, e, i) {
|
|
135
|
-
const
|
|
136
|
-
let { minX: o, minY:
|
|
137
|
-
if (t.lowerValue !== void 0 && (o = Math.max(o, t.lowerValue)), t.upperValue !== void 0 && (m = Math.min(m, t.upperValue)), e.lowerValue !== void 0 && (
|
|
138
|
-
const
|
|
139
|
-
if (
|
|
140
|
-
const f = Math.max(
|
|
141
|
-
o =
|
|
137
|
+
const l = t.scale === "log" ? V() : L();
|
|
138
|
+
let { minX: o, minY: c, maxX: m, maxY: u } = i;
|
|
139
|
+
if (t.lowerValue !== void 0 && (o = Math.max(o, t.lowerValue)), t.upperValue !== void 0 && (m = Math.min(m, t.upperValue)), e.lowerValue !== void 0 && (c = Math.max(c, e.lowerValue)), e.upperValue !== void 0 && (u = Math.min(u, e.upperValue)), t.symmetricRange !== void 0) {
|
|
140
|
+
const n = t.symmetricRange;
|
|
141
|
+
if (n >= o && n <= m) {
|
|
142
|
+
const f = Math.max(n - o, m - n);
|
|
143
|
+
o = n - f, m = n + f;
|
|
142
144
|
}
|
|
143
145
|
}
|
|
144
146
|
if (typeof e.symmetricRange < "u") {
|
|
145
|
-
const
|
|
146
|
-
if (
|
|
147
|
-
const f = Math.max(
|
|
148
|
-
|
|
147
|
+
const n = e.symmetricRange;
|
|
148
|
+
if (n >= c && n <= u) {
|
|
149
|
+
const f = Math.max(n - c, u - n);
|
|
150
|
+
c = n - f, u = n + f;
|
|
149
151
|
}
|
|
150
152
|
}
|
|
151
|
-
const S = [0, this.chartSizes.chartWidth], x =
|
|
152
|
-
|
|
153
|
-
const d = e.scale === "log" ? V() :
|
|
154
|
-
d.domain([g.invert(this.chartSizes.chartHeight), g.invert(0)]).range(
|
|
153
|
+
const S = [0, this.chartSizes.chartWidth], x = l.copy().domain([o, m]).range([W.LEFT, this.chartSizes.chartWidth - W.RIGHT]);
|
|
154
|
+
l.domain([x.invert(0), x.invert(this.chartSizes.chartWidth)]).range(S).nice(), this.scales.x = l, this.scales.xOriginal = l.copy();
|
|
155
|
+
const d = e.scale === "log" ? V() : L(), r = [this.chartSizes.chartHeight, 0], g = d.copy().domain([c, u]).range([this.chartSizes.chartHeight - W.BOTTOM, W.TOP]);
|
|
156
|
+
d.domain([g.invert(this.chartSizes.chartHeight), g.invert(0)]).range(r).nice(), this.scales.y = d, this.scales.yOriginal = d.copy();
|
|
155
157
|
}
|
|
156
158
|
updateCaptionsSize() {
|
|
157
|
-
const t = new
|
|
158
|
-
function e(
|
|
159
|
-
return Math.max(...
|
|
159
|
+
const t = new A("600 14px Arial");
|
|
160
|
+
function e(c) {
|
|
161
|
+
return Math.max(...c.map((m) => t.getTextWidth(m)));
|
|
160
162
|
}
|
|
161
|
-
const { ticks: i, format:
|
|
163
|
+
const { ticks: i, format: l } = it(this.scales.y, !1), o = e(i.map(l));
|
|
162
164
|
this.captionsSizes = {
|
|
163
165
|
xAxisCaptionsWidth: 20,
|
|
164
166
|
yAxisCaptionsWidth: o
|
|
@@ -174,90 +176,90 @@ class oe {
|
|
|
174
176
|
updateMargins() {
|
|
175
177
|
const t = Z * this.mainTitle.length, e = t > 0 ? t + tt * 2 : 0;
|
|
176
178
|
this.margins = {
|
|
177
|
-
top: Math.max(e,
|
|
178
|
-
bottom:
|
|
179
|
-
left:
|
|
180
|
-
right: this.legend.width +
|
|
179
|
+
top: Math.max(e, C),
|
|
180
|
+
bottom: C + this.captionsSizes.xAxisCaptionsWidth + I,
|
|
181
|
+
left: C + this.captionsSizes.yAxisCaptionsWidth + I,
|
|
182
|
+
right: this.legend.width + C
|
|
181
183
|
}, this.chartSizes.totalWidth = this.margins.left + this.chartSizes.chartWidth + this.margins.right, this.chartSizes.totalHeight = this.margins.top + Math.max(this.chartSizes.chartHeight, this.legend.height) + this.margins.bottom, N(this.canvasNode).style("width", this.chartSizes.chartWidth + "px").style("height", this.chartSizes.chartHeight + "px").style("top", this.margins.top + "px").style("left", this.margins.left + "px");
|
|
182
184
|
}
|
|
183
|
-
updateLegendSize(t, e, i,
|
|
185
|
+
updateLegendSize(t, e, i, l) {
|
|
184
186
|
if (!t.show) {
|
|
185
187
|
this.legend = { width: 0, height: 0, items: [] };
|
|
186
188
|
return;
|
|
187
189
|
}
|
|
188
|
-
const o = [],
|
|
190
|
+
const o = [], c = { width: 0, height: 0, left: 0, top: 0 };
|
|
189
191
|
if (i.forEach((d) => {
|
|
190
|
-
const
|
|
191
|
-
if (
|
|
192
|
+
const r = e[d.value];
|
|
193
|
+
if (r.usedAes.length === 0 || !r.aesMap)
|
|
192
194
|
return;
|
|
193
195
|
const g = {};
|
|
194
|
-
|
|
195
|
-
g[p] || (g[p] = { ...
|
|
196
|
-
|
|
196
|
+
r.values.forEach((p) => {
|
|
197
|
+
g[p] || (g[p] = { ...F }), r.usedAes.forEach((s) => {
|
|
198
|
+
s === "dotFill" && (g[p].color = r.aesMap(p, s) ?? G), s === "dotSize" && (g[p].size = Number(r.aesMap(p, s) ?? 3));
|
|
197
199
|
});
|
|
198
200
|
});
|
|
199
|
-
const
|
|
200
|
-
o.push({ ...
|
|
201
|
-
}),
|
|
202
|
-
if (d.type === "dots" &&
|
|
203
|
-
const { domain:
|
|
204
|
-
o.push({ ...
|
|
201
|
+
const n = d.label ?? d.value, f = pt().domain(r.values).range(r.values.map((p) => g[p]));
|
|
202
|
+
o.push({ ...c, id: d.value, type: "dots", title: n, scale: f, values: r.values, labels: r.labels });
|
|
203
|
+
}), l.forEach((d) => {
|
|
204
|
+
if (d.type === "dots" && R(d.aes.dotFill)) {
|
|
205
|
+
const { domain: r, range: g, columnName: n, type: f = "linear" } = d.aes.dotFill, p = n.label ?? n.value, s = ot(g, r, "linear"), a = (f === "log" ? gt() : L()).domain(r).range([this.chartSizes.chartHeight, 0]), v = at(a, r);
|
|
206
|
+
o.push({ ...c, id: "dotFill", type: "continuous", title: p, scale: s, tickPositionScale: a, values: v });
|
|
205
207
|
}
|
|
206
|
-
if (d.type === "dots" &&
|
|
207
|
-
const { columnName:
|
|
208
|
-
o.push({ ...
|
|
208
|
+
if (d.type === "dots" && R(d.aes.dotSize)) {
|
|
209
|
+
const { columnName: r, domain: g, range: n } = d.aes.dotSize, f = r.label ?? r.value, p = ut(g, n), s = p.ticks(3), a = p.tickFormat(3), v = s.reduce((z, T) => (z[String(T)] = a(T), z), {});
|
|
210
|
+
o.push({ ...c, id: r.value, type: "size", title: f, scale: p, values: s, labels: v });
|
|
209
211
|
}
|
|
210
212
|
}), !o.length) {
|
|
211
213
|
this.legend = { width: 0, height: 0, items: [] };
|
|
212
214
|
return;
|
|
213
215
|
}
|
|
214
|
-
const m =
|
|
216
|
+
const m = mt(o, this.chartSizes.chartHeight), u = m[m.length - 1], S = u.left + u.width + rt, x = this.chartSizes.chartHeight;
|
|
215
217
|
this.legend = {
|
|
216
218
|
width: S,
|
|
217
219
|
height: x,
|
|
218
220
|
items: m
|
|
219
221
|
};
|
|
220
222
|
}
|
|
221
|
-
initSettings(t, e, i,
|
|
222
|
-
const { xAxis:
|
|
223
|
-
this.updateChartSizes(
|
|
224
|
-
const
|
|
225
|
-
const
|
|
226
|
-
return
|
|
227
|
-
}),
|
|
223
|
+
initSettings(t, e, i, l, o, c) {
|
|
224
|
+
const { xAxis: m, yAxis: u, size: S, title: x, legend: d } = e;
|
|
225
|
+
this.updateChartSizes(S), this.updateViewport(m, u, i), this.updateCaptionsSize(), this.updateLegendSize(d, l, c, o), this.createMainTitle(x), this.updateMargins(), this.aesGetters = U(this.dataFrame, l, o);
|
|
226
|
+
const r = Y().data(t).value((s) => {
|
|
227
|
+
const a = M(this.aesGetters.dotFill(s.idx));
|
|
228
|
+
return a[3] = !s.dimmed && E(s.x, s.y, this.polygons) ? 1 : 0.4, P(a, a);
|
|
229
|
+
}), g = X().equals((s, a) => s === a).size((s) => B(this.aesGetters.dotSize(s.idx))).crossValue((s) => s.x).mainValue((s) => s.y).decorate((s) => r(s)), n = $().scaleExtent([0.1, 1e3]).filter((s) => s.type === "wheel" || s.metaKey || s.ctrlKey).on("start", () => {
|
|
228
230
|
this.selectedDot = null;
|
|
229
231
|
}).on("zoom", (s) => {
|
|
230
|
-
const
|
|
231
|
-
this.scales.x.domain(
|
|
232
|
+
const a = s.transform, v = a.rescaleX(this.scales.xOriginal), z = a.rescaleY(this.scales.yOriginal);
|
|
233
|
+
this.scales.x.domain(v.domain()), this.scales.y.domain(z.domain()), this.zoomTransform = a, this.zoomStateKey = `${a.x}_${a.y}_${a.k}`, this.updateLabelsPosition(this.visibleLabels), this.renderSvgLayer(), this.renderWebglLayer();
|
|
232
234
|
}).on("end", () => {
|
|
233
|
-
this.visibleLabels = this.computeLabels(this.allDots), this.renderSvgLayer(
|
|
234
|
-
}),
|
|
235
|
+
this.visibleLabels = this.computeLabels(this.allDots), this.renderSvgLayer();
|
|
236
|
+
}), f = lt().on("point", ([s]) => {
|
|
235
237
|
var z;
|
|
236
|
-
let
|
|
237
|
-
s && (
|
|
238
|
-
const
|
|
239
|
-
this.selectedDot =
|
|
240
|
-
}),
|
|
238
|
+
let a;
|
|
239
|
+
s && (a = this.getClosestDot(s.x, s.y));
|
|
240
|
+
const v = this.selectedDot && !a || !this.selectedDot && a || ((z = this.selectedDot) == null ? void 0 : z.idx) !== (a == null ? void 0 : a.idx);
|
|
241
|
+
this.selectedDot = a ?? null, v && this.renderSvgLayer();
|
|
242
|
+
}), p = K({
|
|
241
243
|
xScale: this.scales.x,
|
|
242
244
|
yScale: this.scales.y
|
|
243
245
|
}).xAxisHeight(() => "0").yAxisWidth(() => "0").svgPlotArea(j()).webglPlotArea(
|
|
244
246
|
// only render the point series on the WebGL layer
|
|
245
|
-
q().series([
|
|
247
|
+
q().series([g]).mapping((s) => s)
|
|
246
248
|
).decorate((s) => {
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
+
const a = s.enter();
|
|
250
|
+
a && !this.svgLayerElement && (a.style("grid-template-columns", "0 auto 1fr auto 0"), a.style("grid-template-rows", "0 auto 1fr auto 0"), this.svgLayerElement = a.select(".svg-plot-area.plot-area svg").node()), a.select(".svg-plot-area.plot-area").attr("class", "svg-plot-area plot-area miplots-scatterplot-plot-area").call(n).call(f);
|
|
249
251
|
});
|
|
250
252
|
this.tools = {
|
|
251
|
-
webglChart:
|
|
252
|
-
zoom:
|
|
253
|
-
fillColor:
|
|
254
|
-
pointSeries:
|
|
255
|
-
}, N(this.canvasNode).datum(
|
|
253
|
+
webglChart: p,
|
|
254
|
+
zoom: n,
|
|
255
|
+
fillColor: r,
|
|
256
|
+
pointSeries: g
|
|
257
|
+
}, N(this.canvasNode).datum(t).style("position", "absolute").style("width", this.chartSizes.chartWidth + "px").style("height", this.chartSizes.chartHeight + "px").style("top", this.margins.top + "px").style("left", this.margins.left + "px");
|
|
256
258
|
}
|
|
257
|
-
updateAes(t, e
|
|
258
|
-
this.tools !== null && (this.aesGetters = U(t, e
|
|
259
|
-
const
|
|
260
|
-
return
|
|
259
|
+
updateAes(t, e) {
|
|
260
|
+
this.tools !== null && (this.aesGetters = U(this.dataFrame, t, e), this.tools.fillColor.value((i) => {
|
|
261
|
+
const l = this.aesGetters.dotFill ?? O, o = M(l(i.idx));
|
|
262
|
+
return o[3] = !i.dimmed && E(i.x, i.y, this.polygons) ? 1 : 0.4, P(o, o);
|
|
261
263
|
}));
|
|
262
264
|
}
|
|
263
265
|
updatePointSize() {
|
|
@@ -266,8 +268,8 @@ class oe {
|
|
|
266
268
|
updateByLasso() {
|
|
267
269
|
var t;
|
|
268
270
|
this.tools !== null && ((t = this.tools) == null || t.fillColor.value((e) => {
|
|
269
|
-
const i = this.aesGetters.dotFill ?? O,
|
|
270
|
-
return
|
|
271
|
+
const i = this.aesGetters.dotFill ?? O, l = M(i(e.idx));
|
|
272
|
+
return l[3] = !e.dimmed && E(e.x, e.y, this.polygons) ? 1 : 0.4, P(l, l);
|
|
271
273
|
}), this.renderWebglLayer());
|
|
272
274
|
}
|
|
273
275
|
createQuadtree(t) {
|
|
@@ -277,51 +279,50 @@ class oe {
|
|
|
277
279
|
return e.finish();
|
|
278
280
|
}
|
|
279
281
|
getClosestDot(t, e) {
|
|
280
|
-
var
|
|
281
|
-
const i = (
|
|
282
|
+
var n, f;
|
|
283
|
+
const i = (n = this.tools) == null ? void 0 : n.qt;
|
|
282
284
|
if (!i) return null;
|
|
283
|
-
const
|
|
284
|
-
const
|
|
285
|
-
return (p === null ||
|
|
285
|
+
const l = this.allDots, o = this.scales.x.invert(t), c = this.scales.y.invert(e), m = 1 / (((f = this.zoomTransform) == null ? void 0 : f.k) || 1), u = o - m, S = o + m, x = c - m, d = c + m, r = i.range(u, x, S, d), g = r.reduce((p, s) => {
|
|
286
|
+
const a = l[s], v = this.scales.x(a.x) - t, z = this.scales.y(a.y) - e, T = Math.hypot(v, z);
|
|
287
|
+
return (p === null || T < p.distance) && (p.index = s, p.distance = T), p;
|
|
286
288
|
}, {
|
|
287
289
|
index: -1,
|
|
288
290
|
distance: 1 / 0
|
|
289
291
|
});
|
|
290
|
-
return
|
|
292
|
+
return r.length === 0 || g.index === -1 ? null : l[g.index];
|
|
291
293
|
}
|
|
292
294
|
updateDots(t) {
|
|
293
295
|
this.tools !== null && (N(this.canvasNode).datum(t), this.tools.fillColor.data(t), this.tools.qt = this.createQuadtree(t), this.allDots = t);
|
|
294
296
|
}
|
|
295
|
-
render(t, e, i,
|
|
296
|
-
if (this.tools === null)
|
|
297
|
+
render(t, e, i, l, o, c, m, u, S, x, d, r, g) {
|
|
298
|
+
if (this.dataFrame = t, this.tools === null)
|
|
297
299
|
this.initSettings(
|
|
298
|
-
t,
|
|
299
300
|
o,
|
|
300
301
|
i,
|
|
301
|
-
|
|
302
|
+
c,
|
|
302
303
|
S,
|
|
303
304
|
u,
|
|
304
305
|
x
|
|
305
306
|
);
|
|
306
307
|
else {
|
|
307
|
-
const { title:
|
|
308
|
-
this.updateChartSizes(p), this.updateLegendSize(f, S, x, u), this.createMainTitle(
|
|
308
|
+
const { title: n, legend: f, size: p } = i;
|
|
309
|
+
this.updateChartSizes(p), this.updateLegendSize(f, S, x, u), this.createMainTitle(n), this.updateMargins(), this.updateAes(S, u);
|
|
309
310
|
}
|
|
310
|
-
this.onPolygonUpdateOutside = d, this.onTooltipHintSwitch =
|
|
311
|
+
this.onPolygonUpdateOutside = d, this.onTooltipHintSwitch = r, this.onLassoControlsStateUpdate = g, this.allDots !== o && (this.updateDots(o), this.visibleLabels = this.computeLabels(o)), this.notCalculatedProps = {
|
|
311
312
|
settingsId: e,
|
|
312
313
|
chartSettings: i,
|
|
313
|
-
keyColumn:
|
|
314
|
+
keyColumn: l,
|
|
314
315
|
dotsByGrouping: m,
|
|
315
316
|
layers: u
|
|
316
|
-
}, this.renderWebglLayer(), this.renderSvgLayer(
|
|
317
|
+
}, this.renderWebglLayer(), this.renderSvgLayer();
|
|
317
318
|
}
|
|
318
319
|
renderWebglLayer() {
|
|
319
320
|
var t, e;
|
|
320
321
|
(t = this.tools) != null && t.webglChart && N(this.canvasNode).call((e = this.tools) == null ? void 0 : e.webglChart);
|
|
321
322
|
}
|
|
322
|
-
renderSvgLayer(
|
|
323
|
-
var
|
|
324
|
-
const
|
|
323
|
+
renderSvgLayer() {
|
|
324
|
+
var e;
|
|
325
|
+
const t = {
|
|
325
326
|
settingsId: this.notCalculatedProps.settingsId,
|
|
326
327
|
chartSettings: this.notCalculatedProps.chartSettings,
|
|
327
328
|
keyColumn: this.notCalculatedProps.keyColumn,
|
|
@@ -343,32 +344,32 @@ class oe {
|
|
|
343
344
|
onTooltipHintSwitch: this.onTooltipHintSwitch,
|
|
344
345
|
onLassoControlsStateUpdate: this.onLassoControlsStateUpdate
|
|
345
346
|
};
|
|
346
|
-
this.svgLayerComponent = /* @__PURE__ */ b.jsx(ct, { dataFrame:
|
|
347
|
+
this.svgLayerComponent = /* @__PURE__ */ b.jsx(ct, { dataFrame: this.dataFrame, children: /* @__PURE__ */ b.jsx(nt, { ...t }) }), (e = this.reactRoot) == null || e.render(this.svgLayerComponent);
|
|
347
348
|
}
|
|
348
349
|
renderError(t) {
|
|
349
350
|
var e;
|
|
350
351
|
(e = this.reactRoot) == null || e.render(/* @__PURE__ */ b.jsx(J, { message: t }));
|
|
351
352
|
}
|
|
352
353
|
computeLabels(t) {
|
|
353
|
-
const e = new
|
|
354
|
+
const e = new A("16px Manrope"), i = st(this.chartSizes.chartWidth, this.chartSizes.chartHeight), l = [];
|
|
354
355
|
for (let o = 0; o < t.length; o++) {
|
|
355
|
-
const
|
|
356
|
-
if (
|
|
356
|
+
const c = t[o];
|
|
357
|
+
if (c.label == null)
|
|
357
358
|
continue;
|
|
358
|
-
const m = String(
|
|
359
|
-
|
|
359
|
+
const m = String(c.label), u = e.getTextMetrics(m), S = this.scales.x(c.x), x = this.scales.y(c.y), d = u.width, r = u.actualBoundingBoxAscent + u.actualBoundingBoxDescent, g = 10, n = i(S, x, d, r, g);
|
|
360
|
+
n && l.push({
|
|
360
361
|
x: S,
|
|
361
362
|
y: x,
|
|
362
|
-
dot:
|
|
363
|
+
dot: c,
|
|
363
364
|
name: m,
|
|
364
365
|
width: d,
|
|
365
|
-
height:
|
|
366
|
+
height: r,
|
|
366
367
|
padding: g,
|
|
367
|
-
xPosition:
|
|
368
|
-
yPosition:
|
|
368
|
+
xPosition: n[0],
|
|
369
|
+
yPosition: n[1]
|
|
369
370
|
});
|
|
370
371
|
}
|
|
371
|
-
return
|
|
372
|
+
return l;
|
|
372
373
|
}
|
|
373
374
|
updateLabelsPosition(t) {
|
|
374
375
|
for (let e = 0; e < t.length; e++) {
|
|
@@ -378,6 +379,6 @@ class oe {
|
|
|
378
379
|
}
|
|
379
380
|
}
|
|
380
381
|
export {
|
|
381
|
-
|
|
382
|
+
ne as default
|
|
382
383
|
};
|
|
383
384
|
//# sourceMappingURL=ChartRenderer.js.map
|