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