@milaboratories/miplots4 1.0.124 → 1.0.125

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