@milaboratories/miplots4 1.0.135 → 1.0.137

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