@milaboratories/graph-maker 1.1.169 → 1.1.171
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/components/Chart.vue.d.ts.map +1 -1
- package/dist/GraphMaker/components/Chart.vue.js +44 -34
- package/dist/GraphMaker/components/Chart.vue.js.map +1 -1
- package/dist/GraphMaker/components/DragAndDrop/DnDBasketChip.vue.d.ts +0 -2
- package/dist/GraphMaker/components/DragAndDrop/DnDBasketChip.vue.d.ts.map +1 -1
- package/dist/GraphMaker/components/DragAndDrop/DnDBasketChip.vue.js +26 -33
- package/dist/GraphMaker/components/DragAndDrop/DnDBasketChip.vue.js.map +1 -1
- package/dist/GraphMaker/components/DragAndDrop/DnDRangeChip.vue.d.ts.map +1 -1
- package/dist/GraphMaker/components/DragAndDrop/DnDRangeChip.vue.js +14 -17
- package/dist/GraphMaker/components/DragAndDrop/DnDRangeChip.vue.js.map +1 -1
- package/dist/GraphMaker/components/DragAndDrop/DndBasket.vue.d.ts.map +1 -1
- package/dist/GraphMaker/components/DragAndDrop/DndBasket.vue.js +49 -50
- package/dist/GraphMaker/components/DragAndDrop/DndBasket.vue.js.map +1 -1
- package/dist/GraphMaker/components/DragAndDrop/DndDoubleChip.vue.d.ts +5 -2
- package/dist/GraphMaker/components/DragAndDrop/DndDoubleChip.vue.d.ts.map +1 -1
- package/dist/GraphMaker/components/DragAndDrop/DndDoubleChip.vue.js +46 -43
- package/dist/GraphMaker/components/DragAndDrop/DndDoubleChip.vue.js.map +1 -1
- package/dist/GraphMaker/components/DragAndDrop/types.d.ts +6 -3
- package/dist/GraphMaker/components/DragAndDrop/types.d.ts.map +1 -1
- package/dist/GraphMaker/forms/AxesSettingsForm/DiscreteAxesSettingsForm.vue.js +3 -2
- package/dist/GraphMaker/forms/AxesSettingsForm/DiscreteAxesSettingsForm.vue.js.map +1 -1
- package/dist/GraphMaker/forms/DataMappingForm/DendroForm.vue.d.ts.map +1 -1
- package/dist/GraphMaker/forms/DataMappingForm/DendroForm.vue.js +40 -43
- package/dist/GraphMaker/forms/DataMappingForm/DendroForm.vue.js.map +1 -1
- package/dist/GraphMaker/forms/DataMappingForm/DiscreteForm.vue.js +9 -8
- package/dist/GraphMaker/forms/DataMappingForm/DiscreteForm.vue.js.map +1 -1
- package/dist/GraphMaker/forms/DataMappingForm/useBaskets.d.ts.map +1 -1
- package/dist/GraphMaker/forms/DataMappingForm/useBaskets.js +15 -18
- package/dist/GraphMaker/forms/DataMappingForm/useBaskets.js.map +1 -1
- package/dist/GraphMaker/forms/LayersForm/Layer/scatterplot/Scatter.vue.js +8 -7
- package/dist/GraphMaker/forms/LayersForm/Layer/scatterplot/Scatter.vue.js.map +1 -1
- package/dist/GraphMaker/forms/LayersForm/Layer/scatterplot-umap/Scatter.vue.js +3 -2
- package/dist/GraphMaker/forms/LayersForm/Layer/scatterplot-umap/Scatter.vue.js.map +1 -1
- package/dist/GraphMaker/forms/StatisticsForm/DiscreteStatisticsForm.vue.js +3 -2
- package/dist/GraphMaker/forms/StatisticsForm/DiscreteStatisticsForm.vue.js.map +1 -1
- package/dist/GraphMaker/index.vue.d.ts.map +1 -1
- package/dist/GraphMaker/index.vue.js +49 -48
- package/dist/GraphMaker/index.vue.js.map +1 -1
- package/dist/GraphMaker/store.d.ts +3 -2
- package/dist/GraphMaker/store.d.ts.map +1 -1
- package/dist/GraphMaker/store.js +132 -116
- package/dist/GraphMaker/store.js.map +1 -1
- package/dist/GraphMaker/types.d.ts +8 -1
- package/dist/GraphMaker/types.d.ts.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeBubbleSettings.js +3 -2
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeBubbleSettings.js.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeDiscreteSettings.js +3 -2
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeDiscreteSettings.js.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeHeatmapSettings.js +3 -2
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeHeatmapSettings.js.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeHistogramSettings.js +3 -2
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeHistogramSettings.js.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotSettings.js +3 -2
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotSettings.js.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotUmapSettings.js +7 -6
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotUmapSettings.js.map +1 -1
- package/dist/GraphMaker/utils/getUsedAesInMapping.js +15 -14
- package/dist/GraphMaker/utils/getUsedAesInMapping.js.map +1 -1
- package/dist/GraphMaker/utils/loadDefaultSources.js +16 -15
- package/dist/GraphMaker/utils/loadDefaultSources.js.map +1 -1
- package/dist/GraphMaker/utils/loadUniqueValuesToSave.d.ts +5 -3
- package/dist/GraphMaker/utils/loadUniqueValuesToSave.d.ts.map +1 -1
- package/dist/GraphMaker/utils/loadUniqueValuesToSave.js +66 -72
- package/dist/GraphMaker/utils/loadUniqueValuesToSave.js.map +1 -1
- package/dist/node_modules/@milaboratories/helpers/dist/utils.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/components/Lasso.js +98 -103
- 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 +2 -2
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/components/LowerSVG.js.map +1 -1
- package/dist/node_modules/@milaboratories/pl-model-common/dist/bmodel/code.js +6 -0
- package/dist/node_modules/@milaboratories/pl-model-common/dist/bmodel/code.js.map +1 -0
- package/dist/node_modules/@platforma-sdk/model/dist/render/util/label.js +1 -0
- package/dist/node_modules/@platforma-sdk/model/dist/render/util/label.js.map +1 -1
- package/package.json +3 -3
package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/components/Lasso.js
CHANGED
|
@@ -1,137 +1,132 @@
|
|
|
1
1
|
import { j as l } from "../../node_modules/react/jsx-runtime.js";
|
|
2
|
-
import { SCATTERPLOT_LASSO_EVENTS as
|
|
3
|
-
import { BLACK as
|
|
2
|
+
import { SCATTERPLOT_LASSO_EVENTS as p } from "../constants.js";
|
|
3
|
+
import { BLACK as U } from "../../constants.js";
|
|
4
4
|
import { r as n } from "../../_virtual/index.js";
|
|
5
5
|
import fe from "../../node_modules/d3-drag/src/drag.js";
|
|
6
|
-
import
|
|
7
|
-
const
|
|
8
|
-
function
|
|
6
|
+
import B from "../../node_modules/d3-selection/src/select.js";
|
|
7
|
+
const x = "#845CFF", q = "#CFD1DB", de = 20, H = 3, he = 6, pe = 10;
|
|
8
|
+
function Ee({
|
|
9
9
|
scales: r,
|
|
10
|
-
chartSizes:
|
|
11
|
-
zoomStateKey:
|
|
12
|
-
defaultPolygons:
|
|
13
|
-
onPolygonsApply:
|
|
14
|
-
onLassoControlsStateUpdate:
|
|
10
|
+
chartSizes: j,
|
|
11
|
+
zoomStateKey: G,
|
|
12
|
+
defaultPolygons: K,
|
|
13
|
+
onPolygonsApply: k,
|
|
14
|
+
onLassoControlsStateUpdate: I
|
|
15
15
|
}) {
|
|
16
16
|
n.useEffect(() => {
|
|
17
17
|
function e() {
|
|
18
|
-
M.current
|
|
18
|
+
h.current.length > 0 ? R() : M.current === null ? (v([]), k([])) : (v([...d.current.filter((s, u) => u !== M.current)]), z(null), k(d.current));
|
|
19
19
|
}
|
|
20
20
|
function t(s) {
|
|
21
|
-
|
|
21
|
+
Y(s.detail);
|
|
22
22
|
}
|
|
23
23
|
function a() {
|
|
24
|
-
|
|
24
|
+
X(E.current - 1);
|
|
25
25
|
}
|
|
26
26
|
function c() {
|
|
27
|
-
|
|
27
|
+
X(E.current + 1);
|
|
28
28
|
}
|
|
29
|
-
return document.addEventListener(
|
|
30
|
-
document.removeEventListener(
|
|
29
|
+
return document.addEventListener(p.delete, e), document.addEventListener(p.selectMode, t), document.addEventListener(p.back, a), document.addEventListener(p.forward, c), () => {
|
|
30
|
+
document.removeEventListener(p.delete, e), document.removeEventListener(p.selectMode, t), document.removeEventListener(p.back, a), document.removeEventListener(p.forward, c);
|
|
31
31
|
};
|
|
32
32
|
}, []);
|
|
33
|
-
const [
|
|
33
|
+
const [y, J] = n.useState("pen"), [m, Q] = n.useState(K), d = n.useRef(K), [V, W] = n.useState(null), [S, Z] = n.useState(null), M = n.useRef(null), [o, _] = n.useState([]), h = n.useRef(o), [P, ee] = n.useState([{ newPolygonPoints: o, closedPolygons: m }]), [L, N] = n.useState(0), w = n.useRef(P), E = n.useRef(L), [f, te] = n.useState(null), C = n.useRef(null), [T, O] = n.useState(!1), g = n.useRef(null), A = n.useRef(null), D = n.useCallback(function() {
|
|
34
34
|
const e = {
|
|
35
35
|
newPolygonPoints: [...h.current],
|
|
36
36
|
closedPolygons: [...d.current]
|
|
37
|
-
}, t = w.current.slice(0,
|
|
38
|
-
t.push(e), t.length >
|
|
39
|
-
}, []),
|
|
37
|
+
}, t = w.current.slice(0, E.current + 1);
|
|
38
|
+
t.push(e), t.length > pe && t.shift(), ee(t), N(t.length - 1), w.current = t, E.current = t.length - 1;
|
|
39
|
+
}, []), X = n.useCallback(function(e) {
|
|
40
40
|
if (e > w.current.length - 1 || e < 0)
|
|
41
41
|
return;
|
|
42
|
-
|
|
42
|
+
Y("selection");
|
|
43
43
|
const t = w.current[e];
|
|
44
|
-
|
|
44
|
+
v(t.closedPolygons, !1), b(t.newPolygonPoints, !1), N(e), E.current = e;
|
|
45
45
|
}, []);
|
|
46
|
-
function
|
|
47
|
-
|
|
46
|
+
function v(e, t = !0) {
|
|
47
|
+
Q(e), d.current = e, t && D();
|
|
48
48
|
}
|
|
49
|
-
function
|
|
50
|
-
h.current = e, _(e), t &&
|
|
49
|
+
function b(e, t = !0) {
|
|
50
|
+
h.current = e, _(e), t && D();
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function z(e) {
|
|
53
53
|
Z(e), M.current = e;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
56
|
-
if (
|
|
55
|
+
function Y(e) {
|
|
56
|
+
if (J(e), e === "selection" && (z(null), A.current = null, g.current = null), e === "pen") {
|
|
57
57
|
if (h.current.length > 2) {
|
|
58
58
|
const t = { points: h.current, closed: !0 };
|
|
59
|
-
|
|
59
|
+
v([...d.current, t]), k([...d.current, t]);
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
R();
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
function
|
|
65
|
-
C.current = null,
|
|
64
|
+
function R(e = !0) {
|
|
65
|
+
C.current = null, b([], e);
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
e.key === "Escape" &&
|
|
67
|
+
function $(e) {
|
|
68
|
+
e.key === "Escape" && R();
|
|
69
69
|
}
|
|
70
|
-
n.useEffect(() => (document.addEventListener("keydown",
|
|
70
|
+
n.useEffect(() => (document.addEventListener("keydown", $), () => document.removeEventListener("keydown", $)), []), n.useEffect(() => {
|
|
71
71
|
var e;
|
|
72
|
-
(e =
|
|
73
|
-
}, [
|
|
72
|
+
(e = A.current) == null || e.attr("cx", (t) => r.x(t.p[0])).attr("cy", (t) => r.y(t.p[1]));
|
|
73
|
+
}, [G, j.chartWidth, j.chartHeight]);
|
|
74
74
|
const ne = n.useCallback(function() {
|
|
75
|
-
if (
|
|
75
|
+
if (O(!1), !C.current || y === "pen")
|
|
76
76
|
return;
|
|
77
77
|
const e = [...C.current], t = r.x.invert(e[0]), a = r.y.invert(e[1]);
|
|
78
78
|
if (!h.current.length) {
|
|
79
|
-
|
|
79
|
+
b([[t, a]]);
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
82
|
const c = h.current;
|
|
83
|
-
if (!
|
|
84
|
-
|
|
83
|
+
if (!T || c.length < 3)
|
|
84
|
+
b([...c, [t, a]]);
|
|
85
85
|
else {
|
|
86
86
|
const s = { points: [...c], closed: !0 };
|
|
87
|
-
|
|
87
|
+
R(!1), v([...m, s]), setTimeout(() => k([...m, s]), 0);
|
|
88
88
|
}
|
|
89
|
-
}, [
|
|
89
|
+
}, [y, T]), re = n.useCallback(function(e) {
|
|
90
90
|
const t = [e.nativeEvent.offsetX, e.nativeEvent.offsetY], a = h.current, c = h.current[0];
|
|
91
91
|
if (c) {
|
|
92
|
-
const s = r.x(c[0]),
|
|
93
|
-
|
|
92
|
+
const s = r.x(c[0]), u = r.y(c[1]), i = a.length > 1 ? Math.sqrt((t[0] - s) ** 2 + (t[1] - u) ** 2) : 1 / 0;
|
|
93
|
+
O(i < de);
|
|
94
94
|
} else
|
|
95
|
-
|
|
95
|
+
O(!1);
|
|
96
96
|
te(t), C.current = t;
|
|
97
97
|
}, []);
|
|
98
98
|
function se() {
|
|
99
|
-
g.current &&
|
|
99
|
+
g.current && B(g.current).data([]).exit().remove();
|
|
100
100
|
}
|
|
101
101
|
function ce(e) {
|
|
102
|
-
e !== g.current && e && (se(), g.current = e, le(
|
|
102
|
+
e !== g.current && e && (se(), g.current = e, le(S));
|
|
103
103
|
}
|
|
104
104
|
const le = n.useCallback(function(e) {
|
|
105
|
-
if (
|
|
105
|
+
if (y !== "selection" && e !== null) {
|
|
106
106
|
const t = fe().on("drag", function(s) {
|
|
107
|
-
const
|
|
108
|
-
i[0] = s.x, i[1] = s.y, i.p = [r.x.invert(i[0]), r.y.invert(i[1])],
|
|
109
|
-
const oe = d.current.map((
|
|
110
|
-
...
|
|
111
|
-
points:
|
|
107
|
+
const u = B(this), i = u.data()[0];
|
|
108
|
+
i[0] = s.x, i[1] = s.y, i.p = [r.x.invert(i[0]), r.y.invert(i[1])], u.attr("cx", i[0]).attr("cy", i[1]);
|
|
109
|
+
const oe = d.current.map((F, ue) => e !== ue ? F : {
|
|
110
|
+
...F,
|
|
111
|
+
points: F.points.map(
|
|
112
112
|
(ie, ae) => ae === i.idx ? [r.x.invert(i[0]), r.y.invert(i[1])] : ie
|
|
113
113
|
)
|
|
114
114
|
});
|
|
115
|
-
|
|
115
|
+
v(oe, !1);
|
|
116
116
|
}).on("end", function() {
|
|
117
|
-
|
|
118
|
-
}), a = d.current[e].points.map((s,
|
|
119
|
-
|
|
117
|
+
D(), k(d.current);
|
|
118
|
+
}), a = d.current[e].points.map((s, u) => ({ idx: u, p: s })), c = B(g.current).selectAll("circle").data(a, (s) => s.idx).join("circle");
|
|
119
|
+
A.current = c, c.attr("cx", (s) => r.x(s.p[0])).attr("cy", (s) => r.y(s.p[1])).attr("r", H).attr("fill", "white").attr("stroke", x), c.call(t);
|
|
120
120
|
}
|
|
121
121
|
}, []);
|
|
122
122
|
return n.useEffect(() => {
|
|
123
|
-
|
|
124
|
-
mode:
|
|
125
|
-
backEnabled:
|
|
126
|
-
forwardEnabled:
|
|
127
|
-
deleteEnabled:
|
|
128
|
-
} : {
|
|
129
|
-
mode: p,
|
|
130
|
-
backEnabled: m > 0,
|
|
131
|
-
forwardEnabled: m < b.length - 1,
|
|
132
|
-
deleteEnabled: !1
|
|
123
|
+
I({
|
|
124
|
+
mode: y,
|
|
125
|
+
backEnabled: L > 0,
|
|
126
|
+
forwardEnabled: L < P.length - 1,
|
|
127
|
+
deleteEnabled: S !== null || m.length > 0 || o.length > 0
|
|
133
128
|
});
|
|
134
|
-
}, [
|
|
129
|
+
}, [y, S, m, o, L, P]), /* @__PURE__ */ l.jsx(l.Fragment, { children: /* @__PURE__ */ l.jsxs("g", { children: [
|
|
135
130
|
/* @__PURE__ */ l.jsx("defs", { children: /* @__PURE__ */ l.jsx(
|
|
136
131
|
"pattern",
|
|
137
132
|
{
|
|
@@ -140,55 +135,55 @@ function ke({
|
|
|
140
135
|
height: "5",
|
|
141
136
|
patternTransform: "rotate(45 0 0)",
|
|
142
137
|
patternUnits: "userSpaceOnUse",
|
|
143
|
-
children: /* @__PURE__ */ l.jsx("line", { x1: "0", y1: "0", x2: "0", y2: "10", stroke:
|
|
138
|
+
children: /* @__PURE__ */ l.jsx("line", { x1: "0", y1: "0", x2: "0", y2: "10", stroke: x, strokeWidth: "1" })
|
|
144
139
|
}
|
|
145
140
|
) }),
|
|
146
141
|
/* @__PURE__ */ l.jsx(
|
|
147
142
|
"rect",
|
|
148
143
|
{
|
|
149
144
|
fill: "transparent",
|
|
150
|
-
width:
|
|
151
|
-
height:
|
|
145
|
+
width: j.chartWidth,
|
|
146
|
+
height: j.chartHeight,
|
|
152
147
|
onMouseMove: re,
|
|
153
148
|
onClick: ne
|
|
154
149
|
}
|
|
155
150
|
),
|
|
156
|
-
|
|
157
|
-
const a = t ===
|
|
151
|
+
m.map((e, t) => {
|
|
152
|
+
const a = t === V, c = t === S, s = e.points.map((u) => [r.x(u[0]), r.y(u[1])]).map((u, i) => (i === 0 ? "M" : "L") + u[0] + "," + u[1]).join("") + "z";
|
|
158
153
|
return /* @__PURE__ */ l.jsxs("g", { children: [
|
|
159
154
|
/* @__PURE__ */ l.jsx(
|
|
160
155
|
"path",
|
|
161
156
|
{
|
|
162
157
|
d: s,
|
|
163
158
|
fill: a && !c ? "url(#diagonalStripes)" : "transparent",
|
|
164
|
-
stroke: c || a ?
|
|
165
|
-
onMouseOver: () =>
|
|
166
|
-
onMouseLeave: () =>
|
|
167
|
-
onClick: () =>
|
|
168
|
-
style: { pointerEvents:
|
|
159
|
+
stroke: c || a ? x : U,
|
|
160
|
+
onMouseOver: () => W(t),
|
|
161
|
+
onMouseLeave: () => W(null),
|
|
162
|
+
onClick: () => z(t),
|
|
163
|
+
style: { pointerEvents: y === "selection" || c ? "none" : "auto" }
|
|
169
164
|
}
|
|
170
165
|
),
|
|
171
|
-
c && /* @__PURE__ */ l.jsx("g", { ref: (
|
|
166
|
+
c && /* @__PURE__ */ l.jsx("g", { ref: (u) => ce(u) })
|
|
172
167
|
] }, t);
|
|
173
168
|
}),
|
|
174
169
|
/* @__PURE__ */ l.jsx(
|
|
175
170
|
"polyline",
|
|
176
171
|
{
|
|
177
|
-
points:
|
|
178
|
-
stroke:
|
|
172
|
+
points: o.map((e) => `${r.x(e[0])},${r.y(e[1])}`).join(" "),
|
|
173
|
+
stroke: U,
|
|
179
174
|
fill: "none",
|
|
180
175
|
style: { pointerEvents: "none" }
|
|
181
176
|
}
|
|
182
177
|
),
|
|
183
|
-
|
|
178
|
+
o.length > 1 && f && /* @__PURE__ */ l.jsxs("g", { style: { pointerEvents: "none" }, children: [
|
|
184
179
|
/* @__PURE__ */ l.jsx(
|
|
185
180
|
"circle",
|
|
186
181
|
{
|
|
187
|
-
cx: r.x(
|
|
188
|
-
cy: r.y(
|
|
189
|
-
r:
|
|
182
|
+
cx: r.x(o[0][0]),
|
|
183
|
+
cy: r.y(o[0][1]),
|
|
184
|
+
r: he,
|
|
190
185
|
fill: "none",
|
|
191
|
-
stroke:
|
|
186
|
+
stroke: q,
|
|
192
187
|
strokeDasharray: "3 3"
|
|
193
188
|
}
|
|
194
189
|
),
|
|
@@ -197,32 +192,32 @@ function ke({
|
|
|
197
192
|
{
|
|
198
193
|
x1: f[0],
|
|
199
194
|
y1: f[1],
|
|
200
|
-
x2: r.x(
|
|
201
|
-
y2: r.y(
|
|
202
|
-
stroke:
|
|
195
|
+
x2: r.x(o[0][0]),
|
|
196
|
+
y2: r.y(o[0][1]),
|
|
197
|
+
stroke: q,
|
|
203
198
|
strokeDasharray: "3 3"
|
|
204
199
|
}
|
|
205
200
|
)
|
|
206
201
|
] }),
|
|
207
|
-
|
|
202
|
+
o.length > 0 && f && /* @__PURE__ */ l.jsxs("g", { style: { pointerEvents: "none" }, children: [
|
|
208
203
|
/* @__PURE__ */ l.jsx(
|
|
209
204
|
"line",
|
|
210
205
|
{
|
|
211
|
-
x1: r.x(
|
|
212
|
-
y1: r.y(
|
|
206
|
+
x1: r.x(o[o.length - 1][0]),
|
|
207
|
+
y1: r.y(o[o.length - 1][1]),
|
|
213
208
|
x2: f[0],
|
|
214
209
|
y2: f[1],
|
|
215
|
-
stroke:
|
|
210
|
+
stroke: x
|
|
216
211
|
}
|
|
217
212
|
),
|
|
218
|
-
|
|
213
|
+
o.map((e, t) => /* @__PURE__ */ l.jsx(
|
|
219
214
|
"circle",
|
|
220
215
|
{
|
|
221
216
|
cx: r.x(e[0]),
|
|
222
217
|
cy: r.y(e[1]),
|
|
223
|
-
r:
|
|
218
|
+
r: H,
|
|
224
219
|
fill: "white",
|
|
225
|
-
stroke: t > 0 ?
|
|
220
|
+
stroke: t > 0 ? x : U
|
|
226
221
|
},
|
|
227
222
|
t
|
|
228
223
|
)),
|
|
@@ -231,26 +226,26 @@ function ke({
|
|
|
231
226
|
{
|
|
232
227
|
cx: f[0],
|
|
233
228
|
cy: f[1],
|
|
234
|
-
r:
|
|
229
|
+
r: H,
|
|
235
230
|
fill: "white",
|
|
236
|
-
stroke:
|
|
231
|
+
stroke: x
|
|
237
232
|
}
|
|
238
233
|
)
|
|
239
234
|
] }),
|
|
240
|
-
|
|
235
|
+
T && f && /* @__PURE__ */ l.jsx(
|
|
241
236
|
"circle",
|
|
242
237
|
{
|
|
243
238
|
cx: f[0] + 5,
|
|
244
239
|
cy: f[1] - 5,
|
|
245
240
|
r: 2,
|
|
246
241
|
fill: "none",
|
|
247
|
-
stroke:
|
|
242
|
+
stroke: x,
|
|
248
243
|
strokeWidth: 0.5
|
|
249
244
|
}
|
|
250
245
|
)
|
|
251
246
|
] }) });
|
|
252
247
|
}
|
|
253
248
|
export {
|
|
254
|
-
|
|
249
|
+
Ee as Lasso
|
|
255
250
|
};
|
|
256
251
|
//# sourceMappingURL=Lasso.js.map
|
package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/components/Lasso.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Lasso.js","sources":["../../../../../../../node_modules/@milaboratories/miplots4/src/scatterplot-umap/components/Lasso.tsx"],"sourcesContent":["import {SCATTERPLOT_LASSO_EVENTS} from '../constants';\nimport type {LassoControlsState, LassoMode} from '../types';\nimport type {Polygon} from '../types';\nimport type {Selection} from 'd3-selection';\nimport {select} from 'd3-selection';\nimport {BLACK} from '../../constants';\nimport type {ChartScales, ChartSizes, Point} from '../types';\nimport type {MouseEvent} from 'react';\nimport React, {useCallback, useEffect, useRef, useState} from 'react';\nimport {drag} from 'd3-drag';\n\nconst SELECTION_COLOR = '#845CFF';\nconst START_GREY = '#CFD1DB';\nconst CLOSING_DISTANCE = 20;\nconst R = 3;\nconst R_START = 6;\nconst MAX_HISTORY_LENGTH = 10;\n\ntype CircleData = { // moving point for editing\n idx: number;\n p: Point;\n};\ntype CirclesSelection = Selection<SVGCircleElement, CircleData, SVGGElement | null, CircleData>;\n\ntype HistoryFrame = {\n newPolygonPoints: Point[],\n closedPolygons: Polygon[]\n}\n\n// Mode = 'selection': creating new polygons, pan with button\n// Mode = 'pen': selecting polygon to edit or delete, any zooming actions\nexport function Lasso({\n scales,\n chartSizes,\n zoomStateKey,\n defaultPolygons,\n onPolygonsApply,\n onLassoControlsStateUpdate,\n}: {\n scales: ChartScales;\n chartSizes: ChartSizes;\n zoomStateKey: string;\n defaultPolygons: Polygon[];\n onPolygonsApply: (data: Polygon[]) => void;\n onLassoControlsStateUpdate: (v: LassoControlsState) => void;\n}) {\n useEffect(() => {\n // Events from outer controls\n function onPolygonDelete() {\n if (selectedPolygonRef.current === null) {\n return;\n }\n updatePolygons([...closedPolygonsRef.current.filter((_p, idx) => idx !== selectedPolygonRef.current)]);\n updateSelectedPolygon(null);\n onPolygonsApply(closedPolygonsRef.current);\n }\n\n function onModeSelect(e: CustomEvent<LassoMode>) {\n updateMode(e.detail);\n }\n function onClickBack() {\n loadHistoryItem(historyIndexRef.current - 1);\n }\n function onClickForward() {\n loadHistoryItem(historyIndexRef.current + 1);\n }\n document.addEventListener(SCATTERPLOT_LASSO_EVENTS.delete, onPolygonDelete);\n document.addEventListener(SCATTERPLOT_LASSO_EVENTS.selectMode, onModeSelect as EventListener);\n document.addEventListener(SCATTERPLOT_LASSO_EVENTS.back, onClickBack);\n document.addEventListener(SCATTERPLOT_LASSO_EVENTS.forward, onClickForward);\n return () => {\n document.removeEventListener(SCATTERPLOT_LASSO_EVENTS.delete, onPolygonDelete);\n document.removeEventListener(SCATTERPLOT_LASSO_EVENTS.selectMode, onModeSelect as EventListener);\n document.removeEventListener(SCATTERPLOT_LASSO_EVENTS.back, onClickBack);\n document.removeEventListener(SCATTERPLOT_LASSO_EVENTS.forward, onClickForward);\n };\n }, []);\n\n // inner state\n const [lassoMode, setLassoMode] = useState<LassoMode>('pen');\n\n const [closedPolygons, setClosedPolygons] = useState<Polygon[]>(defaultPolygons);\n const closedPolygonsRef = useRef<Polygon[]>(defaultPolygons);\n\n const [hoveredPolygon, setHoveredPolygon] = useState<number | null>(null);\n\n const [selectedPolygon, setSelectedPolygon] = useState<number | null>(null);\n const selectedPolygonRef = useRef<number | null>(null);\n\n const [newPolygonPoints, setNewPolygonPoints] = useState<Point[]>([]);\n const newPolygonPointsRef = useRef(newPolygonPoints);\n\n const [history, setHistory] = useState<HistoryFrame[]>([{newPolygonPoints, closedPolygons}]);\n const [historyIndex, setHistoryIndex] = useState(0);\n const historyRef = useRef(history);\n const historyIndexRef = useRef(historyIndex);\n\n const [movingPoint, setMovingPoint] = useState<null | Point>(null);\n const movingPointRef = useRef<null | Point>(null);\n\n const [closeToStartPoint, setCloseToStartPoint] = useState(false);\n\n const selectedCirclesContainerRef = useRef<SVGGElement | null>(null);\n const selectedCirclesSelectionRef = useRef<CirclesSelection | null>(null);\n\n const saveCurrentStateToHistory = useCallback(function () {\n const newHistoryItem = {\n newPolygonPoints: [...newPolygonPointsRef.current],\n closedPolygons: [...closedPolygonsRef.current]\n };\n const newHistory = historyRef.current.slice(0, historyIndexRef.current + 1);\n newHistory.push(newHistoryItem);\n if (newHistory.length > MAX_HISTORY_LENGTH) {\n newHistory.shift();\n }\n setHistory(newHistory);\n setHistoryIndex(newHistory.length - 1);\n historyRef.current = newHistory;\n historyIndexRef.current = newHistory.length - 1;\n }, []);\n\n const loadHistoryItem = useCallback(function (index:number) {\n if (index > historyRef.current.length - 1 || index < 0) {\n return;\n }\n updateMode('selection');\n const historyState = historyRef.current[index];\n updatePolygons(historyState.closedPolygons, false);\n updateNewPolygon(historyState.newPolygonPoints, false);\n setHistoryIndex(index);\n historyIndexRef.current = index;\n }, []);\n function updatePolygons(p: Polygon[], saveToHistory = true) {\n setClosedPolygons(p);\n closedPolygonsRef.current = p;\n if (saveToHistory) {\n saveCurrentStateToHistory();\n }\n }\n\n function updateNewPolygon(points:Point[], saveToHistory = true) {\n newPolygonPointsRef.current = points;\n setNewPolygonPoints(points);\n if (saveToHistory) {\n saveCurrentStateToHistory();\n }\n }\n\n function updateSelectedPolygon(idx: number | null) {\n setSelectedPolygon(idx);\n selectedPolygonRef.current = idx;\n }\n\n function updateMode(v: LassoMode) {\n setLassoMode(v);\n if (v === 'selection') {\n updateSelectedPolygon(null);\n selectedCirclesSelectionRef.current = null;\n selectedCirclesContainerRef.current = null;\n }\n if (v === 'pen') {\n if (newPolygonPointsRef.current.length > 2) {\n const polygon:Polygon = {points: newPolygonPointsRef.current, closed: true};\n updatePolygons([...closedPolygonsRef.current, polygon]);\n onPolygonsApply([...closedPolygonsRef.current, polygon]);\n }\n clearNotFinishedPolygon();\n }\n }\n function clearNotFinishedPolygon(saveToHistory = true) {\n movingPointRef.current = null;\n updateNewPolygon([], saveToHistory);\n }\n\n function onKeyDown(e: KeyboardEvent) {\n const escape = e.key === 'Escape';\n if (!escape) {\n return;\n }\n clearNotFinishedPolygon();\n }\n\n useEffect(() => {\n document.addEventListener('keydown', onKeyDown);\n return () => document.removeEventListener('keydown', onKeyDown);\n }, []);\n\n useEffect(() => {\n selectedCirclesSelectionRef.current?.attr('cx', d => scales.x(d.p[0])).attr('cy', d => scales.y(d.p[1]));\n }, [zoomStateKey, chartSizes.chartWidth, chartSizes.chartHeight]);\n\n const onNewPointAddByClick = useCallback(function () {\n setCloseToStartPoint(false);\n if (!movingPointRef.current || lassoMode === 'pen') {\n return;\n }\n const currentCoords = [...movingPointRef.current] as Point;\n const x = scales.x.invert(currentCoords[0]);\n const y = scales.y.invert(currentCoords[1]);\n\n if (!newPolygonPointsRef.current.length) {\n updateNewPolygon([[x, y]]);\n return;\n }\n\n const points = newPolygonPointsRef.current;\n const tooFar = !closeToStartPoint;\n if (tooFar || points.length < 3) {\n updateNewPolygon([...points, [x, y]]);\n } else {\n const polygon:Polygon = {points: [...points], closed: true};\n clearNotFinishedPolygon(false);\n updatePolygons([...closedPolygons, polygon]);\n // to avoid freezing of ui updating in case of big amount of points to apply polygons and change opacity\n setTimeout(() => onPolygonsApply([...closedPolygons, polygon]), 0);\n }\n }, [lassoMode, closeToStartPoint]);\n\n const onMouseMove = useCallback(function(e: MouseEvent<SVGRectElement>) {\n const p: Point = [e.nativeEvent.offsetX, e.nativeEvent.offsetY];\n const points = newPolygonPointsRef.current;\n const startPoint = newPolygonPointsRef.current[0];\n if (startPoint) {\n const startX = scales.x(startPoint[0]);\n const startY = scales.y(startPoint[1]);\n const distance = points.length > 1\n ? Math.sqrt((p[0] - startX) ** 2 + (p[1] - startY) ** 2)\n : Infinity;\n setCloseToStartPoint(distance < CLOSING_DISTANCE);\n } else {\n setCloseToStartPoint(false);\n }\n\n setMovingPoint(p);\n movingPointRef.current = p;\n }, []);\n\n function clearSelectedCircles() {\n if (selectedCirclesContainerRef.current) {\n select(selectedCirclesContainerRef.current).data([]).exit().remove();\n }\n }\n\n function updateSelectedCircles(el: SVGGElement | null) {\n if (el !== selectedCirclesContainerRef.current && el) {\n clearSelectedCircles();\n selectedCirclesContainerRef.current = el;\n onPolygonSelect(selectedPolygon);\n }\n }\n\n const onPolygonSelect = useCallback(function (idx: number | null) {\n if (lassoMode === 'selection') {\n return;\n }\n if (idx !== null) {\n const d = drag<SVGCircleElement, CircleData, SVGGElement | null>()\n .on('drag', function (e) {\n const el = select<SVGCircleElement, CircleData>(this);\n const d = el.data()[0] as number[] & CircleData;\n d[0] = e.x;\n d[1] = e.y;\n d.p = [scales.x.invert(d[0]), scales.y.invert(d[1])];\n el.attr('cx', d[0]).attr('cy', d[1]);\n const editedPolygons = closedPolygonsRef.current.map((polygon, polygonIdx) => {\n return idx !== polygonIdx ? polygon : {\n ...polygon,\n points: polygon.points.map((el, pointIdx) =>\n pointIdx === d.idx ? ([scales.x.invert(d[0]), scales.y.invert(d[1])] as Point) : el\n ),\n };\n });\n updatePolygons(editedPolygons, false);\n })\n .on('end', function () {\n saveCurrentStateToHistory();\n onPolygonsApply(closedPolygonsRef.current);\n });\n const draggablePointsData = closedPolygonsRef.current[idx].points.map((p, idx) => ({idx, p}));\n const selectedCircles = select(selectedCirclesContainerRef.current)\n .selectAll<SVGCircleElement, CircleData>('circle')\n .data(draggablePointsData, (d) => d.idx)\n .join('circle');\n selectedCirclesSelectionRef.current = selectedCircles;\n\n selectedCircles\n .attr('cx', d => scales.x(d.p[0]))\n .attr('cy', d => scales.y(d.p[1]))\n .attr('r', R)\n .attr('fill', 'white')\n .attr('stroke', SELECTION_COLOR);\n selectedCircles.call(d);\n }\n }, []);\n\n useEffect(() => {\n if (lassoMode === 'pen') {\n onLassoControlsStateUpdate({\n mode: lassoMode,\n backEnabled: historyIndex > 0,\n forwardEnabled: historyIndex < history.length - 1,\n deleteEnabled: selectedPolygon !== null,\n });\n } else {\n onLassoControlsStateUpdate({\n mode: lassoMode,\n backEnabled: historyIndex > 0,\n forwardEnabled: historyIndex < history.length - 1,\n deleteEnabled: false,\n });\n }\n }, [lassoMode, selectedPolygon, historyIndex, history]);\n\n return (\n <>\n <g>\n <defs>\n <pattern\n id=\"diagonalStripes\"\n width=\"5\"\n height=\"5\"\n patternTransform=\"rotate(45 0 0)\"\n patternUnits=\"userSpaceOnUse\"\n >\n <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"10\" stroke={SELECTION_COLOR} strokeWidth=\"1\" />\n </pattern>\n </defs>\n <rect\n fill=\"transparent\"\n width={chartSizes.chartWidth}\n height={chartSizes.chartHeight}\n onMouseMove={onMouseMove}\n onClick={onNewPointAddByClick}\n />\n {closedPolygons.map((p, idx) => {\n const isHovered = idx === hoveredPolygon;\n const isSelected = idx === selectedPolygon;\n const points = p.points.map(p => [scales.x(p[0]), scales.y(p[1])]);\n const pathD =\n points\n .map((p, idx) => {\n return (idx === 0 ? 'M' : 'L') + p[0] + ',' + p[1];\n })\n .join('') + 'z';\n return (\n <g key={idx}>\n <path\n d={pathD}\n fill={isHovered && !isSelected ? 'url(#diagonalStripes)' : 'transparent'}\n stroke={isSelected || isHovered ? SELECTION_COLOR : BLACK}\n onMouseOver={() => setHoveredPolygon(idx)}\n onMouseLeave={() => setHoveredPolygon(null)}\n onClick={() => updateSelectedPolygon(idx)}\n style={{pointerEvents: lassoMode === 'selection' || isSelected ? 'none' : 'auto'}}\n />\n {isSelected && <g ref={el => updateSelectedCircles(el)} />}\n </g>\n );\n })}\n <polyline\n points={newPolygonPoints.map((p) => `${scales.x(p[0])},${scales.y(p[1])}`).join(' ')}\n stroke={BLACK}\n fill=\"none\"\n style={{pointerEvents: 'none'}}\n />\n {newPolygonPoints.length > 1 && movingPoint && (\n <g style={{pointerEvents: 'none'}}>\n <circle\n cx={scales.x(newPolygonPoints[0][0])}\n cy={scales.y(newPolygonPoints[0][1])}\n r={R_START}\n fill=\"none\"\n stroke={START_GREY}\n strokeDasharray=\"3 3\"\n />\n <line\n x1={movingPoint[0]}\n y1={movingPoint[1]}\n x2={scales.x(newPolygonPoints[0][0])}\n y2={scales.y(newPolygonPoints[0][1])}\n stroke={START_GREY}\n strokeDasharray=\"3 3\"\n />\n </g>\n )}\n {newPolygonPoints.length > 0 && movingPoint && (\n <g style={{pointerEvents: 'none'}}>\n <line\n x1={scales.x(newPolygonPoints[newPolygonPoints.length - 1][0])}\n y1={scales.y(newPolygonPoints[newPolygonPoints.length - 1][1])}\n x2={movingPoint[0]}\n y2={movingPoint[1]}\n stroke={SELECTION_COLOR}\n />\n {newPolygonPoints.map((p, idx) => (\n <circle\n key={idx}\n cx={scales.x(p[0])}\n cy={scales.y(p[1])}\n r={R}\n fill=\"white\"\n stroke={idx > 0 ? SELECTION_COLOR : BLACK}\n />\n ))}\n <circle\n cx={movingPoint[0]}\n cy={movingPoint[1]}\n r={R}\n fill=\"white\"\n stroke={SELECTION_COLOR}\n />\n </g>\n )}\n {closeToStartPoint && movingPoint && (\n <circle\n cx={movingPoint[0] + 5}\n cy={movingPoint[1] - 5}\n r={2}\n fill=\"none\"\n stroke={SELECTION_COLOR}\n strokeWidth={0.5}\n />\n )}\n </g>\n </>\n );\n}\n"],"names":["SELECTION_COLOR","START_GREY","CLOSING_DISTANCE","R","R_START","MAX_HISTORY_LENGTH","Lasso","scales","chartSizes","zoomStateKey","defaultPolygons","onPolygonsApply","onLassoControlsStateUpdate","useEffect","onPolygonDelete","selectedPolygonRef","updatePolygons","closedPolygonsRef","_p","idx","updateSelectedPolygon","onModeSelect","e","updateMode","onClickBack","loadHistoryItem","historyIndexRef","onClickForward","SCATTERPLOT_LASSO_EVENTS","lassoMode","setLassoMode","useState","closedPolygons","setClosedPolygons","useRef","hoveredPolygon","setHoveredPolygon","selectedPolygon","setSelectedPolygon","newPolygonPoints","setNewPolygonPoints","newPolygonPointsRef","history","setHistory","historyIndex","setHistoryIndex","historyRef","movingPoint","setMovingPoint","movingPointRef","closeToStartPoint","setCloseToStartPoint","selectedCirclesContainerRef","selectedCirclesSelectionRef","saveCurrentStateToHistory","useCallback","newHistoryItem","newHistory","index","historyState","updateNewPolygon","p","saveToHistory","points","v","polygon","clearNotFinishedPolygon","onKeyDown","_a","d","onNewPointAddByClick","currentCoords","x","y","onMouseMove","startPoint","startX","startY","distance","clearSelectedCircles","select","updateSelectedCircles","el","onPolygonSelect","drag","editedPolygons","polygonIdx","pointIdx","draggablePointsData","selectedCircles","jsx","Fragment","c","isHovered","isSelected","pathD","BLACK","jsxs"],"mappings":";;;;;;AAWA,MAAMA,IAAkB,WAClBC,IAAa,WACbC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;AAAA,MACDuE,gBAAAA,EAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACG,IAAI3C,EAAY,CAAC;AAAA,UACjB,IAAIA,EAAY,CAAC;AAAA,UACjB,GAAG5C;AAAAA,UACH,MAAK;AAAA,UACL,QAAQH;AAAAA,QAAA;AAAA,MAAA;AAAA,IAAA,GAEhB;AAAA,IAEHkD,KAAqBH,KAClB2C,gBAAAA,EAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QACG,IAAI3C,EAAY,CAAC,IAAI;AAAA,QACrB,IAAIA,EAAY,CAAC,IAAI;AAAA,QACrB,GAAG;AAAA,QACH,MAAK;AAAA,QACL,QAAQ/C;AAAAA,QACR,aAAa;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,EACjB,CAER,EAAA,CACJ;AAER;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"Lasso.js","sources":["../../../../../../../node_modules/@milaboratories/miplots4/src/scatterplot-umap/components/Lasso.tsx"],"sourcesContent":["import {SCATTERPLOT_LASSO_EVENTS} from '../constants';\nimport type {LassoControlsState, LassoMode} from '../types';\nimport type {Polygon} from '../types';\nimport type {Selection} from 'd3-selection';\nimport {select} from 'd3-selection';\nimport {BLACK} from '../../constants';\nimport type {ChartScales, ChartSizes, Point} from '../types';\nimport type {MouseEvent} from 'react';\nimport React, {useCallback, useEffect, useRef, useState} from 'react';\nimport {drag} from 'd3-drag';\n\nconst SELECTION_COLOR = '#845CFF';\nconst START_GREY = '#CFD1DB';\nconst CLOSING_DISTANCE = 20;\nconst R = 3;\nconst R_START = 6;\nconst MAX_HISTORY_LENGTH = 10;\n\ntype CircleData = { // moving point for editing\n idx: number;\n p: Point;\n};\ntype CirclesSelection = Selection<SVGCircleElement, CircleData, SVGGElement | null, CircleData>;\n\ntype HistoryFrame = {\n newPolygonPoints: Point[],\n closedPolygons: Polygon[]\n}\n\n// Mode = 'selection': creating new polygons, pan with button\n// Mode = 'pen': selecting polygon to edit or delete, any zooming actions\nexport function Lasso({\n scales,\n chartSizes,\n zoomStateKey,\n defaultPolygons,\n onPolygonsApply,\n onLassoControlsStateUpdate,\n}: {\n scales: ChartScales;\n chartSizes: ChartSizes;\n zoomStateKey: string;\n defaultPolygons: Polygon[];\n onPolygonsApply: (data: Polygon[]) => void;\n onLassoControlsStateUpdate: (v: LassoControlsState) => void;\n}) {\n useEffect(() => {\n // Events from outer controls\n function onPolygonDelete() {\n if (newPolygonPointsRef.current.length > 0) {\n clearNotFinishedPolygon();\n } else if (selectedPolygonRef.current === null) {\n updatePolygons([]);\n onPolygonsApply([]);\n } else {\n updatePolygons([...closedPolygonsRef.current.filter((_p, idx) => idx !== selectedPolygonRef.current)]);\n updateSelectedPolygon(null);\n onPolygonsApply(closedPolygonsRef.current);\n }\n }\n\n function onModeSelect(e: CustomEvent<LassoMode>) {\n updateMode(e.detail);\n }\n function onClickBack() {\n loadHistoryItem(historyIndexRef.current - 1);\n }\n function onClickForward() {\n loadHistoryItem(historyIndexRef.current + 1);\n }\n document.addEventListener(SCATTERPLOT_LASSO_EVENTS.delete, onPolygonDelete);\n document.addEventListener(SCATTERPLOT_LASSO_EVENTS.selectMode, onModeSelect as EventListener);\n document.addEventListener(SCATTERPLOT_LASSO_EVENTS.back, onClickBack);\n document.addEventListener(SCATTERPLOT_LASSO_EVENTS.forward, onClickForward);\n return () => {\n document.removeEventListener(SCATTERPLOT_LASSO_EVENTS.delete, onPolygonDelete);\n document.removeEventListener(SCATTERPLOT_LASSO_EVENTS.selectMode, onModeSelect as EventListener);\n document.removeEventListener(SCATTERPLOT_LASSO_EVENTS.back, onClickBack);\n document.removeEventListener(SCATTERPLOT_LASSO_EVENTS.forward, onClickForward);\n };\n }, []);\n\n // inner state\n const [lassoMode, setLassoMode] = useState<LassoMode>('pen');\n\n const [closedPolygons, setClosedPolygons] = useState<Polygon[]>(defaultPolygons);\n const closedPolygonsRef = useRef<Polygon[]>(defaultPolygons);\n\n const [hoveredPolygon, setHoveredPolygon] = useState<number | null>(null);\n\n const [selectedPolygon, setSelectedPolygon] = useState<number | null>(null);\n const selectedPolygonRef = useRef<number | null>(null);\n\n const [newPolygonPoints, setNewPolygonPoints] = useState<Point[]>([]);\n const newPolygonPointsRef = useRef(newPolygonPoints);\n\n const [history, setHistory] = useState<HistoryFrame[]>([{newPolygonPoints, closedPolygons}]);\n const [historyIndex, setHistoryIndex] = useState(0);\n const historyRef = useRef(history);\n const historyIndexRef = useRef(historyIndex);\n\n const [movingPoint, setMovingPoint] = useState<null | Point>(null);\n const movingPointRef = useRef<null | Point>(null);\n\n const [closeToStartPoint, setCloseToStartPoint] = useState(false);\n\n const selectedCirclesContainerRef = useRef<SVGGElement | null>(null);\n const selectedCirclesSelectionRef = useRef<CirclesSelection | null>(null);\n\n const saveCurrentStateToHistory = useCallback(function () {\n const newHistoryItem = {\n newPolygonPoints: [...newPolygonPointsRef.current],\n closedPolygons: [...closedPolygonsRef.current]\n };\n const newHistory = historyRef.current.slice(0, historyIndexRef.current + 1);\n newHistory.push(newHistoryItem);\n if (newHistory.length > MAX_HISTORY_LENGTH) {\n newHistory.shift();\n }\n setHistory(newHistory);\n setHistoryIndex(newHistory.length - 1);\n historyRef.current = newHistory;\n historyIndexRef.current = newHistory.length - 1;\n }, []);\n\n const loadHistoryItem = useCallback(function (index:number) {\n if (index > historyRef.current.length - 1 || index < 0) {\n return;\n }\n updateMode('selection');\n const historyState = historyRef.current[index];\n updatePolygons(historyState.closedPolygons, false);\n updateNewPolygon(historyState.newPolygonPoints, false);\n setHistoryIndex(index);\n historyIndexRef.current = index;\n }, []);\n function updatePolygons(p: Polygon[], saveToHistory = true) {\n setClosedPolygons(p);\n closedPolygonsRef.current = p;\n if (saveToHistory) {\n saveCurrentStateToHistory();\n }\n }\n\n function updateNewPolygon(points:Point[], saveToHistory = true) {\n newPolygonPointsRef.current = points;\n setNewPolygonPoints(points);\n if (saveToHistory) {\n saveCurrentStateToHistory();\n }\n }\n\n function updateSelectedPolygon(idx: number | null) {\n setSelectedPolygon(idx);\n selectedPolygonRef.current = idx;\n }\n\n function updateMode(v: LassoMode) {\n setLassoMode(v);\n if (v === 'selection') {\n updateSelectedPolygon(null);\n selectedCirclesSelectionRef.current = null;\n selectedCirclesContainerRef.current = null;\n }\n if (v === 'pen') {\n if (newPolygonPointsRef.current.length > 2) {\n const polygon:Polygon = {points: newPolygonPointsRef.current, closed: true};\n updatePolygons([...closedPolygonsRef.current, polygon]);\n onPolygonsApply([...closedPolygonsRef.current, polygon]);\n }\n clearNotFinishedPolygon();\n }\n }\n function clearNotFinishedPolygon(saveToHistory = true) {\n movingPointRef.current = null;\n updateNewPolygon([], saveToHistory);\n }\n\n function onKeyDown(e: KeyboardEvent) {\n const escape = e.key === 'Escape';\n if (!escape) {\n return;\n }\n clearNotFinishedPolygon();\n }\n\n useEffect(() => {\n document.addEventListener('keydown', onKeyDown);\n return () => document.removeEventListener('keydown', onKeyDown);\n }, []);\n\n useEffect(() => {\n selectedCirclesSelectionRef.current?.attr('cx', d => scales.x(d.p[0])).attr('cy', d => scales.y(d.p[1]));\n }, [zoomStateKey, chartSizes.chartWidth, chartSizes.chartHeight]);\n\n const onNewPointAddByClick = useCallback(function () {\n setCloseToStartPoint(false);\n if (!movingPointRef.current || lassoMode === 'pen') {\n return;\n }\n const currentCoords = [...movingPointRef.current] as Point;\n const x = scales.x.invert(currentCoords[0]);\n const y = scales.y.invert(currentCoords[1]);\n\n if (!newPolygonPointsRef.current.length) {\n updateNewPolygon([[x, y]]);\n return;\n }\n\n const points = newPolygonPointsRef.current;\n const tooFar = !closeToStartPoint;\n if (tooFar || points.length < 3) {\n updateNewPolygon([...points, [x, y]]);\n } else {\n const polygon:Polygon = {points: [...points], closed: true};\n clearNotFinishedPolygon(false);\n updatePolygons([...closedPolygons, polygon]);\n // to avoid freezing of ui updating in case of big amount of points to apply polygons and change opacity\n setTimeout(() => onPolygonsApply([...closedPolygons, polygon]), 0);\n }\n }, [lassoMode, closeToStartPoint]);\n\n const onMouseMove = useCallback(function(e: MouseEvent<SVGRectElement>) {\n const p: Point = [e.nativeEvent.offsetX, e.nativeEvent.offsetY];\n const points = newPolygonPointsRef.current;\n const startPoint = newPolygonPointsRef.current[0];\n if (startPoint) {\n const startX = scales.x(startPoint[0]);\n const startY = scales.y(startPoint[1]);\n const distance = points.length > 1\n ? Math.sqrt((p[0] - startX) ** 2 + (p[1] - startY) ** 2)\n : Infinity;\n setCloseToStartPoint(distance < CLOSING_DISTANCE);\n } else {\n setCloseToStartPoint(false);\n }\n\n setMovingPoint(p);\n movingPointRef.current = p;\n }, []);\n\n function clearSelectedCircles() {\n if (selectedCirclesContainerRef.current) {\n select(selectedCirclesContainerRef.current).data([]).exit().remove();\n }\n }\n\n function updateSelectedCircles(el: SVGGElement | null) {\n if (el !== selectedCirclesContainerRef.current && el) {\n clearSelectedCircles();\n selectedCirclesContainerRef.current = el;\n onPolygonSelect(selectedPolygon);\n }\n }\n\n const onPolygonSelect = useCallback(function (idx: number | null) {\n if (lassoMode === 'selection') {\n return;\n }\n if (idx !== null) {\n const d = drag<SVGCircleElement, CircleData, SVGGElement | null>()\n .on('drag', function (e) {\n const el = select<SVGCircleElement, CircleData>(this);\n const d = el.data()[0] as number[] & CircleData;\n d[0] = e.x;\n d[1] = e.y;\n d.p = [scales.x.invert(d[0]), scales.y.invert(d[1])];\n el.attr('cx', d[0]).attr('cy', d[1]);\n const editedPolygons = closedPolygonsRef.current.map((polygon, polygonIdx) => {\n return idx !== polygonIdx ? polygon : {\n ...polygon,\n points: polygon.points.map((el, pointIdx) =>\n pointIdx === d.idx ? ([scales.x.invert(d[0]), scales.y.invert(d[1])] as Point) : el\n ),\n };\n });\n updatePolygons(editedPolygons, false);\n })\n .on('end', function () {\n saveCurrentStateToHistory();\n onPolygonsApply(closedPolygonsRef.current);\n });\n const draggablePointsData = closedPolygonsRef.current[idx].points.map((p, idx) => ({idx, p}));\n const selectedCircles = select(selectedCirclesContainerRef.current)\n .selectAll<SVGCircleElement, CircleData>('circle')\n .data(draggablePointsData, (d) => d.idx)\n .join('circle');\n selectedCirclesSelectionRef.current = selectedCircles;\n\n selectedCircles\n .attr('cx', d => scales.x(d.p[0]))\n .attr('cy', d => scales.y(d.p[1]))\n .attr('r', R)\n .attr('fill', 'white')\n .attr('stroke', SELECTION_COLOR);\n selectedCircles.call(d);\n }\n }, []);\n\n useEffect(() => {\n onLassoControlsStateUpdate({\n mode: lassoMode,\n backEnabled: historyIndex > 0,\n forwardEnabled: historyIndex < history.length - 1,\n deleteEnabled: selectedPolygon !== null || closedPolygons.length > 0 || newPolygonPoints.length > 0,\n });\n }, [lassoMode, selectedPolygon, closedPolygons, newPolygonPoints, historyIndex, history]);\n\n return (\n <>\n <g>\n <defs>\n <pattern\n id=\"diagonalStripes\"\n width=\"5\"\n height=\"5\"\n patternTransform=\"rotate(45 0 0)\"\n patternUnits=\"userSpaceOnUse\"\n >\n <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"10\" stroke={SELECTION_COLOR} strokeWidth=\"1\" />\n </pattern>\n </defs>\n <rect\n fill=\"transparent\"\n width={chartSizes.chartWidth}\n height={chartSizes.chartHeight}\n onMouseMove={onMouseMove}\n onClick={onNewPointAddByClick}\n />\n {closedPolygons.map((p, idx) => {\n const isHovered = idx === hoveredPolygon;\n const isSelected = idx === selectedPolygon;\n const points = p.points.map(p => [scales.x(p[0]), scales.y(p[1])]);\n const pathD =\n points\n .map((p, idx) => {\n return (idx === 0 ? 'M' : 'L') + p[0] + ',' + p[1];\n })\n .join('') + 'z';\n return (\n <g key={idx}>\n <path\n d={pathD}\n fill={isHovered && !isSelected ? 'url(#diagonalStripes)' : 'transparent'}\n stroke={isSelected || isHovered ? SELECTION_COLOR : BLACK}\n onMouseOver={() => setHoveredPolygon(idx)}\n onMouseLeave={() => setHoveredPolygon(null)}\n onClick={() => updateSelectedPolygon(idx)}\n style={{pointerEvents: lassoMode === 'selection' || isSelected ? 'none' : 'auto'}}\n />\n {isSelected && <g ref={el => updateSelectedCircles(el)} />}\n </g>\n );\n })}\n <polyline\n points={newPolygonPoints.map((p) => `${scales.x(p[0])},${scales.y(p[1])}`).join(' ')}\n stroke={BLACK}\n fill=\"none\"\n style={{pointerEvents: 'none'}}\n />\n {newPolygonPoints.length > 1 && movingPoint && (\n <g style={{pointerEvents: 'none'}}>\n <circle\n cx={scales.x(newPolygonPoints[0][0])}\n cy={scales.y(newPolygonPoints[0][1])}\n r={R_START}\n fill=\"none\"\n stroke={START_GREY}\n strokeDasharray=\"3 3\"\n />\n <line\n x1={movingPoint[0]}\n y1={movingPoint[1]}\n x2={scales.x(newPolygonPoints[0][0])}\n y2={scales.y(newPolygonPoints[0][1])}\n stroke={START_GREY}\n strokeDasharray=\"3 3\"\n />\n </g>\n )}\n {newPolygonPoints.length > 0 && movingPoint && (\n <g style={{pointerEvents: 'none'}}>\n <line\n x1={scales.x(newPolygonPoints[newPolygonPoints.length - 1][0])}\n y1={scales.y(newPolygonPoints[newPolygonPoints.length - 1][1])}\n x2={movingPoint[0]}\n y2={movingPoint[1]}\n stroke={SELECTION_COLOR}\n />\n {newPolygonPoints.map((p, idx) => (\n <circle\n key={idx}\n cx={scales.x(p[0])}\n cy={scales.y(p[1])}\n r={R}\n fill=\"white\"\n stroke={idx > 0 ? SELECTION_COLOR : BLACK}\n />\n ))}\n <circle\n cx={movingPoint[0]}\n cy={movingPoint[1]}\n r={R}\n fill=\"white\"\n stroke={SELECTION_COLOR}\n />\n </g>\n )}\n {closeToStartPoint && movingPoint && (\n <circle\n cx={movingPoint[0] + 5}\n cy={movingPoint[1] - 5}\n r={2}\n fill=\"none\"\n stroke={SELECTION_COLOR}\n strokeWidth={0.5}\n />\n )}\n </g>\n </>\n );\n}\n"],"names":["SELECTION_COLOR","START_GREY","CLOSING_DISTANCE","R","R_START","MAX_HISTORY_LENGTH","Lasso","scales","chartSizes","zoomStateKey","defaultPolygons","onPolygonsApply","onLassoControlsStateUpdate","useEffect","onPolygonDelete","newPolygonPointsRef","clearNotFinishedPolygon","selectedPolygonRef","updatePolygons","closedPolygonsRef","_p","idx","updateSelectedPolygon","onModeSelect","e","updateMode","onClickBack","loadHistoryItem","historyIndexRef","onClickForward","SCATTERPLOT_LASSO_EVENTS","lassoMode","setLassoMode","useState","closedPolygons","setClosedPolygons","useRef","hoveredPolygon","setHoveredPolygon","selectedPolygon","setSelectedPolygon","newPolygonPoints","setNewPolygonPoints","history","setHistory","historyIndex","setHistoryIndex","historyRef","movingPoint","setMovingPoint","movingPointRef","closeToStartPoint","setCloseToStartPoint","selectedCirclesContainerRef","selectedCirclesSelectionRef","saveCurrentStateToHistory","useCallback","newHistoryItem","newHistory","index","historyState","updateNewPolygon","p","saveToHistory","points","v","polygon","onKeyDown","_a","d","onNewPointAddByClick","currentCoords","x","y","onMouseMove","startPoint","startX","startY","distance","clearSelectedCircles","select","updateSelectedCircles","el","onPolygonSelect","drag","editedPolygons","polygonIdx","pointIdx","draggablePointsData","selectedCircles","jsx","Fragment","c","isHovered","isSelected","pathD","BLACK","jsxs"],"mappings":";;;;;;AAWA,MAAMA,IAAkB,WAClBC,IAAa,WACbC,KAAmB,IACnBC,IAAI,GACJC,KAAU,GACVC,KAAqB;AAepB,SAASC,GAAM;AAAA,EAClB,QAAAC;AAAAA,EACA,YAAAC;AAAAA,EACA,cAAAC;AAAAA,EACA,iBAAAC;AAAAA,EACA,iBAAAC;AAAAA,EACA,4BAAAC;AACJ,GAOG;AACCC,EAAAA,EAAAA,UAAU,MAAM;AAEZ,aAASC,IAAkB;AACnBC,MAAAA,EAAoB,QAAQ,SAAS,IACrCC,EAAAA,IACOC,EAAmB,YAAY,QACtCC,EAAe,CAAA,CAAE,GACjBP,EAAgB,CAAA,CAAE,MAElBO,EAAe,CAAC,GAAGC,EAAkB,QAAQ,OAAO,CAACC,GAAIC,MAAQA,MAAQJ,EAAmB,OAAO,CAAC,CAAC,GACrGK,EAAsB,IAAI,GAC1BX,EAAgBQ,EAAkB,OAAO;AAAA,IAEjD;AAEA,aAASI,E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/miplots4/dist/scatterplot-umap/components/LowerSVG.js
CHANGED
|
@@ -80,9 +80,9 @@ function tt({
|
|
|
80
80
|
title: m,
|
|
81
81
|
show: w.show,
|
|
82
82
|
position: w.position,
|
|
83
|
-
leftPadding: i.left,
|
|
83
|
+
leftPadding: -i.left,
|
|
84
84
|
rightPadding: i.right,
|
|
85
|
-
chartsWidth: t.
|
|
85
|
+
chartsWidth: t.totalWidth
|
|
86
86
|
}
|
|
87
87
|
),
|
|
88
88
|
/* @__PURE__ */ e.jsxs("g", { dominantBaseline: "central", textAnchor: "middle", fontWeight: "500", fontSize: "14px", fill: U, children: [
|
package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/components/LowerSVG.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LowerSVG.js","sources":["../../../../../../../node_modules/@milaboratories/miplots4/src/scatterplot-umap/components/LowerSVG.tsx"],"sourcesContent":["import {format} from 'd3-format';\nimport { curveBasis, line } from 'd3-shape';\nimport React, { useEffect, useState } from 'react';\nimport { ChartsTitle } from '../../common/ChartsTitle';\nimport { ContinuousGrid } from '../../common/ContinuousGrid';\nimport fonts from '../../common/fonts';\nimport { Legend } from '../../common/Legend';\nimport type { TooltipsData } from '../../common/Tooltip';\nimport { Tooltip } from '../../common/Tooltip';\nimport type { LegendData } from '../../common/types';\nimport { useDataFrame } from '../../common/useDataFrame';\nimport { BLACK } from '../../constants';\nimport type { DataFrame } from '../../DataFrame';\nimport { ContinuousAxis } from '../../common/ContinuousAxis';\nimport {formatColumnValue} from '../../scatterplot/utils/formatColumnValue';\nimport type { ColumnName } from '../../types';\nimport type { CurveUmapLayer } from '../../types/scatterplot-umap';\nimport { DEFAULT_TICKS_SIZE, LEGEND_OFFSET, TITLE_LINE } from '../constants';\nimport type { ScatterplotUmapSettingsImpl } from '../SettingsImpl';\nimport type { CaptionsSizes, ChartScales, ChartSizes, Dot, DotInfo, Margins, SVGLayerProps } from '../types';\n\nfunction getTooltipContent(dataFrame: DataFrame, dot: DotInfo, columnsList: ColumnName[] = [], ) {\n const lines: string[] = [];\n for (const column of columnsList) {\n const columnFormatter = column?.format ? format(column.format) : undefined;\n lines.push(`${column.label}: ${formatColumnValue(dataFrame, dot.idx, column, columnFormatter)}`);\n }\n return lines;\n}\n\nfunction getTitle(title: string | ColumnName): string {\n if (typeof title === 'string') {\n return title;\n }\n return title.label ?? title.value;\n}\n\nconst lineGenerator = line<Dot>().curve(curveBasis);\n\nfunction LowerSvg({\n scales,\n chartSettings,\n mainTitle,\n keyColumn,\n margins,\n chartSizes,\n container,\n zoomStateKey,\n legendData,\n dotsByGrouping,\n layers,\n aesGetters,\n tooltipData\n}: {\n aesGetters: SVGLayerProps['aesGetters'];\n scales: ChartScales;\n chartSettings: ScatterplotUmapSettingsImpl['chartSettings'];\n mainTitle: string[];\n keyColumn: ColumnName | null;\n margins: Margins;\n chartSizes: ChartSizes;\n captionsSizes: CaptionsSizes;\n selectedDot?: DotInfo | null;\n container: SVGElement | null;\n zoomStateKey: string;\n legendData: LegendData;\n dotsByGrouping: Record<string, Dot[]>;\n layers: ScatterplotUmapSettingsImpl['layers'];\n tooltipData: TooltipsData<DotInfo>;\n}) {\n const dataFrame = useDataFrame();\n const {title, xAxis, yAxis, frame, legend} = chartSettings;\n const tickSizeX = xAxis.showTicks ? DEFAULT_TICKS_SIZE : 0;\n const tickSizeY = yAxis.showTicks ? DEFAULT_TICKS_SIZE : 0;\n const xTitle = xAxis.title;\n const yTitle = yAxis.title;\n const needLeftAxis = true;\n const needBottomAxis = true;\n\n const sideDistances = {\n left: 0,\n right: chartSizes.chartWidth,\n top: 0,\n bottom: chartSizes.chartHeight,\n };\n\n if (!container) {\n return null;\n }\n\n const curveLayer = layers.find(layer => layer.type === 'curve') as CurveUmapLayer | undefined;\n const [lines, setLines] = useState<{key: string, d:string, dot: Dot}[]>([]);\n\n function updateLines() {\n const data = Object.entries(dotsByGrouping);\n const nextLines = data.map(([key, dots]) => ({\n key,\n d: curveLayer?.smoothing ? lineGenerator(dots) ?? '' : dots.map(d => `${scales.x(d.x)},${scales.y(d.y)}`).join(' '),\n dot: dots[0]\n }));\n setLines(nextLines);\n }\n useEffect(() => {\n if (!curveLayer) {\n return;\n }\n lineGenerator\n .x((d: Dot) => scales.x(d.x))\n .y((d: Dot) => scales.y(d.y));\n updateLines();\n }, [zoomStateKey, chartSizes.chartWidth, chartSizes.chartHeight]);\n\n useEffect(() => {\n if (!curveLayer) {\n return;\n }\n updateLines();\n }, [curveLayer?.smoothing]);\n\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox={`0 0 ${chartSizes.totalWidth} ${chartSizes.totalHeight}`}\n width={chartSizes.totalWidth}\n height={chartSizes.totalHeight}\n style={{pointerEvents: 'none'}}\n >\n <defs>{fonts}</defs>\n <g transform={`translate(${margins.left},${margins.top})`} fontFamily=\"Manrope\">\n <clipPath id=\"viewportClipPath\">\n <rect x=\"0\" y=\"0\" width={chartSizes.chartWidth} height={chartSizes.chartHeight}/>\n </clipPath>\n <ChartsTitle\n title={mainTitle}\n show={title.show}\n position={title.position}\n leftPadding={margins.left}\n rightPadding={margins.right}\n chartsWidth={chartSizes.chartWidth}\n />\n <g dominantBaseline=\"central\" textAnchor=\"middle\" fontWeight=\"500\" fontSize=\"14px\" fill={BLACK}>\n {xTitle && (\n <text\n x={chartSizes.chartWidth / 2}\n y={chartSizes.chartHeight + margins.bottom - TITLE_LINE / 2}\n >\n {getTitle(xTitle)}\n </text>\n )}\n {yTitle && (\n <text\n x={-margins.left + TITLE_LINE / 2}\n y={chartSizes.chartHeight / 2}\n transform={`rotate(-90,${-margins.left + TITLE_LINE / 2},${\n chartSizes.chartHeight / 2\n })`}\n >\n {getTitle(yTitle)}\n </text>\n )}\n </g>\n <ContinuousGrid\n width={chartSizes.chartWidth}\n height={chartSizes.chartHeight}\n scaleX={scales.x}\n scaleY={scales.y}\n axisX={xAxis}\n axisY={yAxis}\n updatingKey={zoomStateKey}\n frameType={frame.type}\n />\n {needBottomAxis && (\n <g transform={`translate(0,${chartSizes.chartHeight})`}>\n <ContinuousAxis scale={scales.x} orient=\"bottom\" tickSize={tickSizeX} />\n </g>\n )}\n {needLeftAxis && (\n <g>\n <ContinuousAxis scale={scales.y} orient=\"left\" tickSize={tickSizeY} />\n </g>\n )}\n {curveLayer && curveLayer.smoothing && (\n <g clipPath=\"url(#viewportClipPath)\">\n {lines.map(({key, d, dot}) => (\n <path\n key={key}\n d={d}\n fill=\"none\"\n stroke={aesGetters.dotFill(dot.idx)}\n strokeWidth={curveLayer.aes?.lineWidth}\n strokeDasharray={aesGetters.lineType(dot.idx)}\n />\n ))}\n </g>\n )}\n {curveLayer && !curveLayer.smoothing && (\n <g clipPath=\"url(#viewportClipPath)\">\n {lines.map(({key, d, dot}) => (\n <polyline\n key={key}\n points={d}\n fill=\"none\"\n stroke={aesGetters.dotFill(dot.idx)}\n strokeWidth={curveLayer.aes?.lineWidth}\n strokeDasharray={aesGetters.lineType(dot.idx)}\n />\n ))}\n </g>\n )}\n {chartSettings.tooltips.show && tooltipData.selectedData && (\n <Tooltip\n content={getTooltipContent(dataFrame, tooltipData.selectedData, chartSettings.tooltips?.content)}\n x={scales.x(tooltipData.selectedData.x)}\n y={scales.y(tooltipData.selectedData.y)}\n active={true}\n fixed={tooltipData.fixed}\n sideDistances={sideDistances}\n container={container}\n onClose={tooltipData.onClose}\n />\n )}\n {legend.show && (\n <g transform={`translate(${chartSizes.chartWidth + LEGEND_OFFSET},0)`}>\n <Legend legendData={legendData} />\n </g>\n )}\n </g>\n </svg>\n );\n}\n\nexport default React.memo(LowerSvg);\n"],"names":["getTooltipContent","dataFrame","dot","columnsList","lines","column","columnFormatter","format","formatColumnValue","getTitle","title","lineGenerator","line","curveBasis","LowerSvg","scales","chartSettings","mainTitle","keyColumn","margins","chartSizes","container","zoomStateKey","legendData","dotsByGrouping","layers","aesGetters","tooltipData","useDataFrame","xAxis","yAxis","frame","legend","tickSizeX","DEFAULT_TICKS_SIZE","tickSizeY","xTitle","yTitle","sideDistances","curveLayer","layer","setLines","useState","updateLines","nextLines","key","dots","d","useEffect","jsxs","jsx","fonts","ChartsTitle","BLACK","TITLE_LINE","ContinuousGrid","ContinuousAxis","_a","o","Tooltip","LEGEND_OFFSET","Legend","LowerSvg$1","React"],"mappings":";;;;;;;;;;;;;;;AAqBA,SAASA,EAAkBC,GAAsBC,GAAcC,IAA4B,CAAA,GAAM;AAC7F,QAAMC,IAAkB,CAAA;AACxB,aAAWC,KAAUF,GAAa;AAC9B,UAAMG,IAAkBD,KAAA,QAAAA,EAAQ,SAASE,EAAOF,EAAO,MAAM,IAAI;AACjED,IAAAA,EAAM,KAAK,GAAGC,EAAO,KAAK,KAAKG,EAAkBP,GAAWC,EAAI,KAAKG,GAAQC,CAAe,CAAC,EAAE;AAAA,EACnG;AACA,SAAOF;AACX;AAEA,SAASK,EAASC,GAAoC;AAClD,SAAI,OAAOA,KAAU,WACVA,IAEJA,EAAM,SAASA,EAAM;AAChC;AAEA,MAAMC,IAAgBC,EAAAA,EAAY,MAAMC,CAAU;AAElD,SAASC,GAAS;AAAA,EACd,QAAAC;AAAAA,EACA,eAAAC;AAAAA,EACA,WAAAC;AAAAA,EACA,WAAAC;AAAAA,EACA,SAAAC;AAAAA,EACA,YAAAC;AAAAA,EACA,WAAAC;AAAAA,EACA,cAAAC;AAAAA,EACA,YAAAC;AAAAA,EACA,gBAAAC;AAAAA,EACA,QAAAC;AAAAA,EACA,YAAAC;AAAAA,EACA,aAAAC;AACJ,GAgBG;;AACC,QAAM1B,IAAY2B,EAAAA,GACZ,EAAC,OAAAlB,GAAO,OAAAmB,GAAO,OAAAC,GAAO,OAAAC,GAAO,QAAAC,EAAAA,IAAUhB,GACvCiB,IAAYJ,EAAM,YAAYK,IAAqB,GACnDC,IAAYL,EAAM,YAAYI,IAAqB,GACnDE,IAASP,EAAM,OACfQ,IAASP,EAAM,OAIfQ,IAAgB;AAAA,IAClB,MAAM;AAAA,IAC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AAA;AAAA,gBAEG,QAAQH;AAAAA,gBACR,MAAK;AAAA,gBACL,QAAQrB,EAAW,QAAQxB,EAAI,GAAG;AAAA,gBAClC,cAAauD,IAAAlB,EAAW,QAAX,gBAAAkB,EAAgB;AAAA,gBAC7B,iBAAiB/B,EAAW,SAASxB,EAAI,GAAG;AAAA,cAAA;AAAA,cALvC2C;AAAAA,YAAA;AAAA,UAAA,CAOZ,EAAA,CACL;AAAA,UAEH7B,EAAc,SAAS,QAAQW,EAAY,gBACxCuB,gBAAAA,EAAAA;AAAAA,YAACS;AAAAA,YAAA;AAAA,cACG,SAAS3D,EAAkBC,GAAW0B,EAAY,eAAc8B,IAAAzC,EAAc,aAAd,OAAA,SAAAyC,EAAwB,OAAO;AAAA,cAC/F,GAAG1C,EAAO,EAAEY,EAAY,aAAa,CAAC;AAAA,cACtC,GAAGZ,EAAO,EAAEY,EAAY,aAAa,CAAC;AAAA,cACtC,QAAQ;AAAA,cACR,OAAOA,EAAY;AAAA,cACnB,eAAAW;AAAAA,cACA,WAAAjB;AAAAA,cACA,SAASM,EAAY;AAAA,YAAA;AAAA,UAAA;AAAA,UAG5BK,EAAO,QACJkB,gBAAAA,EAAAA,IAAC,KAAA,EAAE,WAAW,aAAa9B,EAAW,aAAawC,CAAa,OAC5D,UAAAV,gBAAAA,EAAAA,IAACW,GAAA,EAAO,YAAAtC,EAAAA,CAAwB,EAAA,CACpC;AAAA,QAAA,GAER;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGZ;AAEA,MAAAuC,KAAeC,EAAM,KAAKjD,EAAQ;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"LowerSVG.js","sources":["../../../../../../../node_modules/@milaboratories/miplots4/src/scatterplot-umap/components/LowerSVG.tsx"],"sourcesContent":["import {format} from 'd3-format';\nimport { curveBasis, line } from 'd3-shape';\nimport React, { useEffect, useState } from 'react';\nimport { ChartsTitle } from '../../common/ChartsTitle';\nimport { ContinuousGrid } from '../../common/ContinuousGrid';\nimport fonts from '../../common/fonts';\nimport { Legend } from '../../common/Legend';\nimport type { TooltipsData } from '../../common/Tooltip';\nimport { Tooltip } from '../../common/Tooltip';\nimport type { LegendData } from '../../common/types';\nimport { useDataFrame } from '../../common/useDataFrame';\nimport { BLACK } from '../../constants';\nimport type { DataFrame } from '../../DataFrame';\nimport { ContinuousAxis } from '../../common/ContinuousAxis';\nimport {formatColumnValue} from '../../scatterplot/utils/formatColumnValue';\nimport type { ColumnName } from '../../types';\nimport type { CurveUmapLayer } from '../../types/scatterplot-umap';\nimport { DEFAULT_TICKS_SIZE, LEGEND_OFFSET, TITLE_LINE } from '../constants';\nimport type { ScatterplotUmapSettingsImpl } from '../SettingsImpl';\nimport type { CaptionsSizes, ChartScales, ChartSizes, Dot, DotInfo, Margins, SVGLayerProps } from '../types';\n\nfunction getTooltipContent(dataFrame: DataFrame, dot: DotInfo, columnsList: ColumnName[] = [], ) {\n const lines: string[] = [];\n for (const column of columnsList) {\n const columnFormatter = column?.format ? format(column.format) : undefined;\n lines.push(`${column.label}: ${formatColumnValue(dataFrame, dot.idx, column, columnFormatter)}`);\n }\n return lines;\n}\n\nfunction getTitle(title: string | ColumnName): string {\n if (typeof title === 'string') {\n return title;\n }\n return title.label ?? title.value;\n}\n\nconst lineGenerator = line<Dot>().curve(curveBasis);\n\nfunction LowerSvg({\n scales,\n chartSettings,\n mainTitle,\n keyColumn,\n margins,\n chartSizes,\n container,\n zoomStateKey,\n legendData,\n dotsByGrouping,\n layers,\n aesGetters,\n tooltipData\n}: {\n aesGetters: SVGLayerProps['aesGetters'];\n scales: ChartScales;\n chartSettings: ScatterplotUmapSettingsImpl['chartSettings'];\n mainTitle: string[];\n keyColumn: ColumnName | null;\n margins: Margins;\n chartSizes: ChartSizes;\n captionsSizes: CaptionsSizes;\n selectedDot?: DotInfo | null;\n container: SVGElement | null;\n zoomStateKey: string;\n legendData: LegendData;\n dotsByGrouping: Record<string, Dot[]>;\n layers: ScatterplotUmapSettingsImpl['layers'];\n tooltipData: TooltipsData<DotInfo>;\n}) {\n const dataFrame = useDataFrame();\n const {title, xAxis, yAxis, frame, legend} = chartSettings;\n const tickSizeX = xAxis.showTicks ? DEFAULT_TICKS_SIZE : 0;\n const tickSizeY = yAxis.showTicks ? DEFAULT_TICKS_SIZE : 0;\n const xTitle = xAxis.title;\n const yTitle = yAxis.title;\n const needLeftAxis = true;\n const needBottomAxis = true;\n\n const sideDistances = {\n left: 0,\n right: chartSizes.chartWidth,\n top: 0,\n bottom: chartSizes.chartHeight,\n };\n\n if (!container) {\n return null;\n }\n\n const curveLayer = layers.find(layer => layer.type === 'curve') as CurveUmapLayer | undefined;\n const [lines, setLines] = useState<{key: string, d:string, dot: Dot}[]>([]);\n\n function updateLines() {\n const data = Object.entries(dotsByGrouping);\n const nextLines = data.map(([key, dots]) => ({\n key,\n d: curveLayer?.smoothing ? lineGenerator(dots) ?? '' : dots.map(d => `${scales.x(d.x)},${scales.y(d.y)}`).join(' '),\n dot: dots[0]\n }));\n setLines(nextLines);\n }\n useEffect(() => {\n if (!curveLayer) {\n return;\n }\n lineGenerator\n .x((d: Dot) => scales.x(d.x))\n .y((d: Dot) => scales.y(d.y));\n updateLines();\n }, [zoomStateKey, chartSizes.chartWidth, chartSizes.chartHeight]);\n\n useEffect(() => {\n if (!curveLayer) {\n return;\n }\n updateLines();\n }, [curveLayer?.smoothing]);\n\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox={`0 0 ${chartSizes.totalWidth} ${chartSizes.totalHeight}`}\n width={chartSizes.totalWidth}\n height={chartSizes.totalHeight}\n style={{pointerEvents: 'none'}}\n >\n <defs>{fonts}</defs>\n <g transform={`translate(${margins.left},${margins.top})`} fontFamily=\"Manrope\">\n <clipPath id=\"viewportClipPath\">\n <rect x=\"0\" y=\"0\" width={chartSizes.chartWidth} height={chartSizes.chartHeight}/>\n </clipPath>\n <ChartsTitle\n title={mainTitle}\n show={title.show}\n position={title.position}\n leftPadding={-margins.left}\n rightPadding={margins.right}\n chartsWidth={chartSizes.totalWidth}\n />\n <g dominantBaseline=\"central\" textAnchor=\"middle\" fontWeight=\"500\" fontSize=\"14px\" fill={BLACK}>\n {xTitle && (\n <text\n x={chartSizes.chartWidth / 2}\n y={chartSizes.chartHeight + margins.bottom - TITLE_LINE / 2}\n >\n {getTitle(xTitle)}\n </text>\n )}\n {yTitle && (\n <text\n x={-margins.left + TITLE_LINE / 2}\n y={chartSizes.chartHeight / 2}\n transform={`rotate(-90,${-margins.left + TITLE_LINE / 2},${\n chartSizes.chartHeight / 2\n })`}\n >\n {getTitle(yTitle)}\n </text>\n )}\n </g>\n <ContinuousGrid\n width={chartSizes.chartWidth}\n height={chartSizes.chartHeight}\n scaleX={scales.x}\n scaleY={scales.y}\n axisX={xAxis}\n axisY={yAxis}\n updatingKey={zoomStateKey}\n frameType={frame.type}\n />\n {needBottomAxis && (\n <g transform={`translate(0,${chartSizes.chartHeight})`}>\n <ContinuousAxis scale={scales.x} orient=\"bottom\" tickSize={tickSizeX} />\n </g>\n )}\n {needLeftAxis && (\n <g>\n <ContinuousAxis scale={scales.y} orient=\"left\" tickSize={tickSizeY} />\n </g>\n )}\n {curveLayer && curveLayer.smoothing && (\n <g clipPath=\"url(#viewportClipPath)\">\n {lines.map(({key, d, dot}) => (\n <path\n key={key}\n d={d}\n fill=\"none\"\n stroke={aesGetters.dotFill(dot.idx)}\n strokeWidth={curveLayer.aes?.lineWidth}\n strokeDasharray={aesGetters.lineType(dot.idx)}\n />\n ))}\n </g>\n )}\n {curveLayer && !curveLayer.smoothing && (\n <g clipPath=\"url(#viewportClipPath)\">\n {lines.map(({key, d, dot}) => (\n <polyline\n key={key}\n points={d}\n fill=\"none\"\n stroke={aesGetters.dotFill(dot.idx)}\n strokeWidth={curveLayer.aes?.lineWidth}\n strokeDasharray={aesGetters.lineType(dot.idx)}\n />\n ))}\n </g>\n )}\n {chartSettings.tooltips.show && tooltipData.selectedData && (\n <Tooltip\n content={getTooltipContent(dataFrame, tooltipData.selectedData, chartSettings.tooltips?.content)}\n x={scales.x(tooltipData.selectedData.x)}\n y={scales.y(tooltipData.selectedData.y)}\n active={true}\n fixed={tooltipData.fixed}\n sideDistances={sideDistances}\n container={container}\n onClose={tooltipData.onClose}\n />\n )}\n {legend.show && (\n <g transform={`translate(${chartSizes.chartWidth + LEGEND_OFFSET},0)`}>\n <Legend legendData={legendData} />\n </g>\n )}\n </g>\n </svg>\n );\n}\n\nexport default React.memo(LowerSvg);\n"],"names":["getTooltipContent","dataFrame","dot","columnsList","lines","column","columnFormatter","format","formatColumnValue","getTitle","title","lineGenerator","line","curveBasis","LowerSvg","scales","chartSettings","mainTitle","keyColumn","margins","chartSizes","container","zoomStateKey","legendData","dotsByGrouping","layers","aesGetters","tooltipData","useDataFrame","xAxis","yAxis","frame","legend","tickSizeX","DEFAULT_TICKS_SIZE","tickSizeY","xTitle","yTitle","sideDistances","curveLayer","layer","setLines","useState","updateLines","nextLines","key","dots","d","useEffect","jsxs","jsx","fonts","ChartsTitle","BLACK","TITLE_LINE","ContinuousGrid","ContinuousAxis","_a","o","Tooltip","LEGEND_OFFSET","Legend","LowerSvg$1","React"],"mappings":";;;;;;;;;;;;;;;AAqBA,SAASA,EAAkBC,GAAsBC,GAAcC,IAA4B,CAAA,GAAM;AAC7F,QAAMC,IAAkB,CAAA;AACxB,aAAWC,KAAUF,GAAa;AAC9B,UAAMG,IAAkBD,KAAA,QAAAA,EAAQ,SAASE,EAAOF,EAAO,MAAM,IAAI;AACjED,IAAAA,EAAM,KAAK,GAAGC,EAAO,KAAK,KAAKG,EAAkBP,GAAWC,EAAI,KAAKG,GAAQC,CAAe,CAAC,EAAE;AAAA,EACnG;AACA,SAAOF;AACX;AAEA,SAASK,EAASC,GAAoC;AAClD,SAAI,OAAOA,KAAU,WACVA,IAEJA,EAAM,SAASA,EAAM;AAChC;AAEA,MAAMC,IAAgBC,EAAAA,EAAY,MAAMC,CAAU;AAElD,SAASC,GAAS;AAAA,EACd,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UAG5BK,EAAO,QACJkB,gBAAAA,EAAAA,IAAC,KAAA,EAAE,WAAW,aAAa9B,EAAW,aAAawC,CAAa,OAC5D,UAAAV,gBAAAA,EAAAA,IAACW,GAAA,EAAO,YAAAtC,EAAAA,CAAwB,EAAA,CACpC;AAAA,QAAA,GAER;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGZ;AAEA,MAAAuC,KAAeC,EAAM,KAAKjD,EAAQ;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code.js","sources":["../../../../../../node_modules/@milaboratories/pl-model-common/src/bmodel/code.ts"],"sourcesContent":["import type { BlockCodeFeatureFlags } from '../flags';\nimport { z } from 'zod';\n\nexport const Code = z.object({\n type: z.literal('plain'),\n content: z.string(),\n});\n\nexport type Code = z.infer<typeof Code>;\n\nexport type BlockCodeWithInfo = {\n readonly code: Code;\n readonly sdkVersion: string;\n readonly featureFlags: BlockCodeFeatureFlags | undefined;\n};\n"],"names":["z"],"mappings":";AAGoBA,EAAE,OAAO;AAAA,EAC3B,MAAMA,EAAE,QAAQ,OAAO;AAAA,EACvB,SAASA,EAAE,OAAM;AAClB,CAAA;","x_google_ignoreList":[0]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "../../../../../@milaboratories/pl-model-common/dist/bmodel/code.js";
|
|
1
2
|
import "../../../../../@milaboratories/pl-model-common/dist/drivers/blob.js";
|
|
2
3
|
import "../../../../../@milaboratories/pl-model-common/dist/drivers/pframe/spec/spec.js";
|
|
3
4
|
import "../../../../../@milaboratories/pl-model-common/dist/plid.js";
|