@milaboratories/miplots4 1.0.124 → 1.0.126

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