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