@milaboratories/miplots4 1.0.163 → 1.0.165

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