@milaboratories/miplots4 1.0.155 → 1.0.157

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,21 +1,21 @@
1
1
  var ot = Object.defineProperty;
2
2
  var it = (m, e, s) => e in m ? ot(m, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : m[e] = s;
3
- var L = (m, e, s) => it(m, typeof e != "symbol" ? e + "" : e, s);
4
- import { j } from "../node_modules/react/jsx-runtime.js";
3
+ var C = (m, e, s) => it(m, typeof e != "symbol" ? e + "" : e, s);
4
+ import { j as O } from "../node_modules/react/jsx-runtime.js";
5
5
  import nt from "../node_modules/lodash/lodash.js";
6
6
  import { createRoot as rt } from "../node_modules/react-dom/client.js";
7
7
  import { Error as at } from "../common/Error.js";
8
8
  import { DataFrameProvider as ht } from "../common/useDataFrame.js";
9
- import { DEFAULT_HEIGHT as U, DEFAULT_WIDTH as Y, TITLE_LINE_HEIGHT as ct, TITLE_MARGIN as lt } from "../constants.js";
9
+ import { DEFAULT_HEIGHT as Y, DEFAULT_WIDTH as q, TITLE_LINE_HEIGHT as ct, TITLE_MARGIN as lt } from "../constants.js";
10
10
  import { arrangeLegendParts as ut } from "../utils/arrangeLegendParts.js";
11
11
  import { getChartEdgeSides as pt } from "../utils/getChartEdgeSides.js";
12
12
  import { getContinuousLegendTicks as Q } from "../utils/getContinuousLegendTicks.js";
13
13
  import { TextMeasurer as dt } from "../utils/TextMeasurer/TextMeasurer.js";
14
14
  import { ChartsGroup as mt } from "./components/ChartsGroup.js";
15
- import { MIN_MARGIN as F, TITLE_LINE as q, LEGEND_OFFSET as gt, DEFAULT_AES as Z, CHART_SIDE_ELEMENTS as xt } from "./constants.js";
15
+ import { MIN_MARGIN as F, TITLE_LINE as V, LEGEND_OFFSET as gt, DEFAULT_AES as Z, CHART_SIDE_ELEMENTS as xt } from "./constants.js";
16
16
  import { calculateChartSideElementSizes as ft } from "./utils/calculateChartSideElementSizes.js";
17
- import { calculateSideElementsBBoxes as yt } from "./utils/calculateSideElementsBBoxes.js";
18
- import { createDiscreteColorScale as St, createDiscreteRoundColorScale as Ct, createContinuousColorScale as Lt } from "./utils/createColorScales.js";
17
+ import { calculateSideElementsBBoxes as St } from "./utils/calculateSideElementsBBoxes.js";
18
+ import { createDiscreteColorScale as yt, createDiscreteRoundColorScale as Ct, createContinuousColorScale as Lt } from "./utils/createColorScales.js";
19
19
  import { calculateAnnotationTitleSizes as bt } from "./utils/calculateAnnotationTitleSizes.js";
20
20
  import { calculateCaptionTails as zt } from "./utils/calculateCaptionTails.js";
21
21
  import I from "../node_modules/d3-scale/src/ordinal.js";
@@ -24,30 +24,30 @@ import Gt from "../node_modules/d3-array/src/extent.js";
24
24
  import $ from "../node_modules/d3-hierarchy/src/cluster.js";
25
25
  const At = Math.cos(Math.PI / 4), Et = 5;
26
26
  function tt(m, e, s) {
27
- function t(r) {
28
- r[s] = e(r.data.height), r.children && r.children.forEach(t);
27
+ function t(n) {
28
+ n[s] = e(n.data.height), n.children && n.children.forEach(t);
29
29
  }
30
30
  t(m);
31
31
  }
32
32
  function st(m, e, s, t = s) {
33
- function r(i) {
34
- i[t] = i[s] + e, i.children && i.children.forEach(r);
33
+ function n(i) {
34
+ i[t] = i[s] + e, i.children && i.children.forEach(n);
35
35
  }
36
- r(m);
36
+ n(m);
37
37
  }
38
38
  const Tt = (m, e) => {
39
39
  const s = Math.min(...e), t = Math.max(...e);
40
40
  if (s === t) {
41
- const a = m % 2 === 0 ? [] : [s];
42
- for (let h = 1; h < m / 2 + 1; h++)
43
- a.push(s + h), a.unshift(s - h);
44
- return a;
41
+ const r = m % 2 === 0 ? [] : [s];
42
+ for (let a = 1; a < m / 2 + 1; a++)
43
+ r.push(s + a), r.unshift(s - a);
44
+ return r;
45
45
  }
46
46
  if (m < 2)
47
47
  return [s, t];
48
- const r = (t - s) / (m - 1), i = [];
49
- for (let a = 0; a < m - 1; a++)
50
- i.push(s + r * a);
48
+ const n = (t - s) / (m - 1), i = [];
49
+ for (let r = 0; r < m - 1; r++)
50
+ i.push(s + n * r);
51
51
  return i.push(t), i;
52
52
  };
53
53
  function et(m, e, s) {
@@ -56,74 +56,74 @@ function et(m, e, s) {
56
56
  }
57
57
  function P(m, e, s) {
58
58
  let t = 0;
59
- for (const r of m) {
60
- if (e[r] === void 0) continue;
61
- const i = s.getTextWidth(e[r]);
59
+ for (const n of m) {
60
+ if (e[n] === void 0) continue;
61
+ const i = s.getTextWidth(e[n]);
62
62
  i > t && (t = i);
63
63
  }
64
64
  return t;
65
65
  }
66
66
  function K(m, e) {
67
- return e === 90 ? m : e === 45 ? m * At + (m > 0 ? 2 * Et : 0) : q;
67
+ return e === 90 ? m : e === 45 ? m * At + (m > 0 ? 2 * Et : 0) : V;
68
68
  }
69
69
  class Jt {
70
70
  constructor() {
71
- L(this, "reactRoot", null);
72
- L(this, "parentNode", null);
73
- L(this, "rootNode", null);
74
- L(this, "component", /* @__PURE__ */ j.jsx(j.Fragment, {}));
75
- L(this, "chartsDimensions", {});
76
- L(this, "chartSizes", {
77
- chartWidth: Y,
71
+ C(this, "reactRoot", null);
72
+ C(this, "parentNode", null);
73
+ C(this, "rootNode", null);
74
+ C(this, "component", /* @__PURE__ */ O.jsx(O.Fragment, {}));
75
+ C(this, "chartsDimensions", {});
76
+ C(this, "chartSizes", {
77
+ chartWidth: q,
78
78
  // width of single chart
79
- chartHeight: U,
79
+ chartHeight: Y,
80
80
  // height of single chart
81
- chartsWidth: Y,
81
+ chartsWidth: q,
82
82
  // width of all charts in charts row
83
- chartsHeight: U,
83
+ chartsHeight: Y,
84
84
  // width of all charts in charts column, without axes
85
- totalWidth: Y,
85
+ totalWidth: q,
86
86
  // width of all charts in charts row, plus left axis, plus legend
87
- totalHeight: U
87
+ totalHeight: Y
88
88
  // width of all charts in charts height, plus bottom axis, plus top title
89
89
  });
90
- L(this, "margins", {
90
+ C(this, "margins", {
91
91
  top: F,
92
92
  bottom: F,
93
93
  left: F,
94
94
  right: F
95
95
  });
96
- L(this, "captionsSizes", {
96
+ C(this, "captionsSizes", {
97
97
  xAxisCaptions: 100,
98
98
  yAxisCaptions: 100,
99
- xGroupCaptions: q,
100
- yGroupCaptions: q,
99
+ xGroupCaptions: V,
100
+ yGroupCaptions: V,
101
101
  xCaptionTail: 0,
102
102
  yCaptionTail: 0
103
103
  });
104
- L(this, "labelAngles", {
104
+ C(this, "labelAngles", {
105
105
  xAxisLabels: 0,
106
106
  yAxisLabels: 0,
107
107
  xGroupLabels: 0,
108
108
  yGroupLabels: 0
109
109
  });
110
- L(this, "columnsCount", 1);
111
- L(this, "rowsCount", 1);
112
- L(this, "scales", {
110
+ C(this, "columnsCount", 1);
111
+ C(this, "rowsCount", 1);
112
+ C(this, "scales", {
113
113
  // scales grouped by facet
114
114
  x: { null: I().domain(["null"]).range([1]) },
115
115
  y: { null: I().domain(["null"]).range([1]) }
116
116
  });
117
- L(this, "step", { x: {}, y: {} });
118
- L(this, "colorScale", D().domain([0, 1]).range(["white", "black"]));
119
- L(this, "annotationColorScales", {});
120
- L(this, "dendrogramAesScales", {});
121
- L(this, "legend", {
117
+ C(this, "step", { x: {}, y: {} });
118
+ C(this, "colorScale", D().domain([0, 1]).range(["white", "black"]));
119
+ C(this, "annotationColorScales", {});
120
+ C(this, "dendrogramAesScales", {});
121
+ C(this, "legend", {
122
122
  width: 0,
123
123
  height: 0,
124
124
  items: []
125
125
  });
126
- L(this, "dendrograms", {});
126
+ C(this, "dendrograms", {});
127
127
  }
128
128
  clear() {
129
129
  var e;
@@ -143,222 +143,222 @@ class Jt {
143
143
  right: this.legend.width + s.outerOffset
144
144
  }, this.chartSizes.totalWidth = this.margins.left + this.chartSizes.chartsWidth + this.margins.right, this.chartSizes.totalHeight = this.margins.top + Math.max(this.chartSizes.chartsHeight + this.margins.bottom, this.legend.height);
145
145
  }
146
- updateLegendSize(e, s, t, r, i) {
146
+ updateLegendSize(e, s, t, n, i) {
147
147
  if (!s.show) {
148
148
  this.legend = { width: 0, height: 0, items: [] };
149
149
  return;
150
150
  }
151
- const a = this.chartSizes.chartHeight, h = [], u = { width: 0, height: 0, left: 0, top: 0 }, x = (l) => l.reduce((c, o) => (c[o] = String(o), c), {});
151
+ const r = this.chartSizes.chartHeight, a = [], p = { width: 0, height: 0, left: 0, top: 0 }, f = (h) => h.reduce((c, o) => (c[o] = String(o), c), {});
152
152
  if (e === "continuous") {
153
- const l = this.colorScale, c = Q(l, i), o = D([c[0], c[c.length - 1]], [a, 0]), n = r.label ?? r.value;
154
- h.push({
155
- ...u,
153
+ const h = this.colorScale, c = Q(h, i), o = D([c[0], c[c.length - 1]], [r, 0]), l = n.label ?? n.value;
154
+ a.push({
155
+ ...p,
156
156
  type: "continuous",
157
157
  id: "heatmapValue",
158
- scale: l,
158
+ scale: h,
159
159
  values: c,
160
- title: n,
160
+ title: l,
161
161
  tickPositionScale: o
162
162
  });
163
163
  } else if (e === "discrete") {
164
- const l = this.colorScale, c = r.label ?? r.value, o = l.domain(), n = x(o);
165
- h.push({ ...u, type: "discreteColor", id: "heatmapValue", title: c, scale: l, values: o, labels: n });
164
+ const h = this.colorScale, c = n.label ?? n.value, o = h.domain(), l = f(o);
165
+ a.push({ ...p, type: "discreteColor", id: "heatmapValue", title: c, scale: h, values: o, labels: l });
166
166
  }
167
- if (t.forEach((l) => {
168
- const c = l.valueColumn.label ?? l.valueColumn.value;
169
- if (l.type === "continuous") {
170
- const o = this.annotationColorScales[l.id].scale, n = Q(o, i), f = D([n[0], n[n.length - 1]], [a, 0]);
171
- h.push({ ...u, type: "continuous", id: l.id, tickPositionScale: f, title: c, scale: o, values: n });
167
+ if (t.forEach((h) => {
168
+ const c = h.valueColumn.label ?? h.valueColumn.value;
169
+ if (h.type === "continuous") {
170
+ const o = this.annotationColorScales[h.id].scale, l = Q(o, i), x = D([l[0], l[l.length - 1]], [r, 0]);
171
+ a.push({ ...p, type: "continuous", id: h.id, tickPositionScale: x, title: c, scale: o, values: l });
172
172
  }
173
- if (l.type === "discrete") {
174
- const o = this.annotationColorScales[l.id].scale, n = o.domain(), f = x(n);
175
- h.push({ ...u, type: "discreteColor", id: l.id, title: c, scale: o, values: n, labels: f });
173
+ if (h.type === "discrete") {
174
+ const o = this.annotationColorScales[h.id].scale, l = o.domain(), x = f(l);
175
+ a.push({ ...p, type: "discreteColor", id: h.id, title: c, scale: o, values: l, labels: x });
176
176
  }
177
- }), !h.length) {
177
+ }), !a.length) {
178
178
  this.legend = { width: 0, height: 0, items: [] };
179
179
  return;
180
180
  }
181
- const p = ut(h, this.chartSizes.chartHeight), d = p[p.length - 1], A = d.left + d.width + gt;
181
+ const d = ut(a, this.chartSizes.chartHeight), u = d[d.length - 1], b = u.left + u.width + gt;
182
182
  this.legend = {
183
- width: A,
184
- height: a,
185
- items: p
183
+ width: b,
184
+ height: r,
185
+ items: d
186
186
  };
187
187
  }
188
- updateCaptionsSize(e, s, t, r) {
189
- const i = new dt("bold 16px Manrope"), { xGroupKeys: a, yGroupKeys: h, xGroupLabels: u, yGroupLabels: x, xKeysByGroups: p, yKeysByGroups: d, xLabels: A, yLabels: l } = e.meta;
188
+ updateCaptionsSize(e, s, t, n) {
189
+ const i = new dt("bold 16px Manrope"), { xGroupKeys: r, yGroupKeys: a, xGroupLabels: p, yGroupLabels: f, xKeysByGroups: d, yKeysByGroups: u, xLabels: b, yLabels: h } = e.meta;
190
190
  this.labelAngles = {
191
191
  xAxisLabels: s.axisLabelsAngle,
192
192
  yAxisLabels: t.axisLabelsAngle,
193
193
  xGroupLabels: s.groupLabelsAngle,
194
194
  yGroupLabels: t.groupLabelsAngle
195
195
  };
196
- const c = a.reduce((y, g) => Math.max(y, P(p[g], A, i)), 0), o = h.reduce((y, g) => Math.max(y, P(d[g], l, i)), 0), n = P(a, u, i), f = P(h, x, i), { xCaptionTail: S, yCaptionTail: T } = zt(
196
+ const c = r.reduce((S, g) => Math.max(S, P(d[g], b, i)), 0), o = a.reduce((S, g) => Math.max(S, P(u[g], h, i)), 0), l = P(r, p, i), x = P(a, f, i), { xCaptionTail: A, yCaptionTail: M } = zt(
197
197
  this.labelAngles,
198
- r,
198
+ n,
199
199
  this.scales,
200
200
  this.step,
201
201
  e,
202
202
  i
203
203
  );
204
204
  this.captionsSizes = {
205
- xCaptionTail: S,
206
- yCaptionTail: T,
207
- xGroupCaptions: K(n, this.labelAngles.xGroupLabels),
208
- yGroupCaptions: K(f, this.labelAngles.yGroupLabels),
205
+ xCaptionTail: A,
206
+ yCaptionTail: M,
207
+ xGroupCaptions: K(l, this.labelAngles.xGroupLabels),
208
+ yGroupCaptions: K(x, this.labelAngles.yGroupLabels),
209
209
  xAxisCaptions: K(c, this.labelAngles.xAxisLabels),
210
210
  yAxisCaptions: K(o, this.labelAngles.yAxisLabels)
211
211
  };
212
212
  }
213
- updateChartDimensions(e, s, t, r, i, a, h, u, x, p) {
214
- const d = s.length, A = Math.min(i.nRows ?? d, d), l = Math.min(i.nCols ?? d, d);
215
- this.columnsCount = i.nRows ? Math.ceil(d / A) : l, this.rowsCount = Math.ceil(d / this.columnsCount);
213
+ updateChartDimensions(e, s, t, n, i, r, a, p, f, d) {
214
+ const u = s.length, b = Math.min(i.nRows ?? u, u), h = Math.min(i.nCols ?? u, u);
215
+ this.columnsCount = i.nRows ? Math.ceil(u / b) : h, this.rowsCount = Math.ceil(u / this.columnsCount);
216
216
  const { sharedX: c, sharedY: o } = i;
217
217
  this.chartsDimensions = {};
218
- let n = 0, f = 0;
219
- s.forEach((y, g) => {
220
- const b = g % this.columnsCount + 1, C = pt(g, s.length, this.columnsCount, this.rowsCount), z = this.step.x[y], w = this.step.y[y], v = ft(
218
+ let l = 0, x = 0;
219
+ s.forEach((S, g) => {
220
+ const L = g % this.columnsCount + 1, y = pt(g, s.length, this.columnsCount, this.rowsCount), z = this.step.x[S], w = this.step.y[S], v = ft(
221
+ r,
221
222
  a,
222
- h,
223
223
  this.captionsSizes,
224
- u,
225
- x,
226
224
  p,
227
- C,
225
+ f,
226
+ d,
227
+ y,
228
228
  c,
229
229
  o,
230
230
  s,
231
231
  t,
232
- r,
232
+ n,
233
233
  z,
234
234
  w
235
- ), N = bt(u, C, c, o);
236
- function M(R) {
235
+ ), N = bt(p, y, c, o);
236
+ function H(R) {
237
237
  return Math.max(
238
- xt[R].reduce((O, k) => O + v[R][k], 0),
238
+ xt[R].reduce((k, j) => k + v[R][j], 0),
239
239
  N[R],
240
240
  e.innerOffset
241
241
  );
242
242
  }
243
243
  const E = {
244
- left: M("left"),
245
- right: M("right"),
246
- top: M("top"),
247
- bottom: M("bottom")
244
+ left: H("left"),
245
+ right: H("right"),
246
+ top: H("top"),
247
+ bottom: H("bottom")
248
248
  };
249
249
  E.left < this.captionsSizes.xCaptionTail && (E.left = this.captionsSizes.xCaptionTail), E.bottom < this.captionsSizes.yCaptionTail && (E.bottom = this.captionsSizes.yCaptionTail);
250
- const B = yt(v, this.chartSizes.chartWidth, this.chartSizes.chartHeight), W = this.chartSizes.chartWidth + E.left + E.right, _ = this.chartSizes.chartHeight + E.top + E.bottom;
251
- this.chartsDimensions[y] = {
252
- left: n,
253
- top: f,
250
+ const B = St(v, this.chartSizes.chartWidth, this.chartSizes.chartHeight), W = this.chartSizes.chartWidth + E.left + E.right, _ = this.chartSizes.chartHeight + E.top + E.bottom;
251
+ this.chartsDimensions[S] = {
252
+ left: l,
253
+ top: x,
254
254
  inner: { width: this.chartSizes.chartWidth, height: this.chartSizes.chartHeight },
255
255
  outer: { width: W, height: _ },
256
256
  padding: E,
257
257
  sideElementBBoxes: B,
258
- chartEdgeSides: C
259
- }, n += W, b === this.columnsCount && (n = 0, f += _);
258
+ chartEdgeSides: y
259
+ }, l += W, L === this.columnsCount && (l = 0, x += _);
260
260
  });
261
- const S = s.slice(0, this.columnsCount).reduce((y, g) => y + this.chartsDimensions[g].outer.width, 0), T = s.filter((y, g) => g % this.columnsCount === 0).reduce((y, g) => y + this.chartsDimensions[g].outer.height, 0);
262
- this.chartSizes.chartsWidth = S, this.chartSizes.chartsHeight = T;
261
+ const A = s.slice(0, this.columnsCount).reduce((S, g) => S + this.chartsDimensions[g].outer.width, 0), M = s.filter((S, g) => g % this.columnsCount === 0).reduce((S, g) => S + this.chartsDimensions[g].outer.height, 0);
262
+ this.chartSizes.chartsWidth = A, this.chartSizes.chartsHeight = M;
263
263
  }
264
- updateChartsSizes(e, s, t, r) {
265
- const { width: i, height: a, cellWidth: h, cellHeight: u } = e, x = t.meta.facetKeys[0];
266
- if (h && s.sharedX && x) {
267
- const p = t.facets[x].xKeys.length, d = t.meta.xGroupKeys.length;
268
- this.chartSizes.chartWidth = p * h + r * (d - 1);
264
+ updateChartsSizes(e, s, t, n) {
265
+ const { width: i, height: r, cellWidth: a, cellHeight: p } = e, f = t.meta.facetKeys[0];
266
+ if (a && s.sharedX && f) {
267
+ const d = t.facets[f].xKeys.length, u = t.meta.xGroupKeys.length;
268
+ this.chartSizes.chartWidth = d * a + n * (u - 1);
269
269
  } else
270
270
  this.chartSizes.chartWidth = i;
271
- if (u && s.sharedY && x) {
272
- const p = t.facets[x].yKeys.length, d = t.meta.yGroupKeys.length;
273
- this.chartSizes.chartHeight = p * u + r * (d - 1);
271
+ if (p && s.sharedY && f) {
272
+ const d = t.facets[f].yKeys.length, u = t.meta.yGroupKeys.length;
273
+ this.chartSizes.chartHeight = d * p + n * (u - 1);
274
274
  } else
275
- this.chartSizes.chartHeight = a;
275
+ this.chartSizes.chartHeight = r;
276
276
  }
277
277
  // update scales for cell positions, x and y for each facet
278
- updateScales(e, s, t, r, i, a, h, u, x, p) {
279
- const { width: d, height: A, cellWidth: l, cellHeight: c } = i, { meta: o, facets: n } = s, { sharedX: f, sharedY: S } = r, T = (g, b = {}) => g.sort(
280
- (C, z) => a.sorting === "asc" ? (b[C] ?? C).localeCompare(b[z] ?? z, "en", { numeric: !0 }) : (b[z] ?? z).localeCompare(b[C] ?? C, "en", { numeric: !0 })
281
- ), y = (g, b = {}) => g.sort(
282
- (C, z) => h.sorting === "asc" ? (b[C] ?? C).localeCompare(b[z] ?? z, "en", { numeric: !0 }) : (b[z] ?? z).localeCompare(b[C] ?? C, "en", { numeric: !0 })
278
+ updateScales(e, s, t, n, i, r, a, p, f, d) {
279
+ const { width: u, height: b, cellWidth: h, cellHeight: c } = i, { meta: o, facets: l } = s, { sharedX: x, sharedY: A } = n, M = (g, L = {}) => g.sort(
280
+ (y, z) => r.sorting === "asc" ? (L[y] ?? y).localeCompare(L[z] ?? z, "en", { numeric: !0 }) : (L[z] ?? z).localeCompare(L[y] ?? y, "en", { numeric: !0 })
281
+ ), S = (g, L = {}) => g.sort(
282
+ (y, z) => a.sorting === "asc" ? (L[y] ?? y).localeCompare(L[z] ?? z, "en", { numeric: !0 }) : (L[z] ?? z).localeCompare(L[y] ?? y, "en", { numeric: !0 })
283
283
  );
284
284
  e.forEach((g) => {
285
- const b = n[g], C = p.xGroup ? o.xGroupKeys : T(o.xGroupKeys), z = p.yGroup ? o.yGroupKeys : y(o.yGroupKeys), { xKeysByGroups: w } = f ? o : b, { yKeysByGroups: v } = S ? o : b, N = C.map((G) => w[G].length), M = z.map((G) => v[G].length), E = N.reduce((G, H) => G + H, 0), B = M.reduce((G, H) => G + H, 0), W = f && l ? l : (d - (N.filter((G) => G > 0).length - 1) * t) / E, _ = S && c ? c : (A - (M.filter((G) => G > 0).length - 1) * t) / B, R = [], O = [];
286
- let k = 0;
287
- C.forEach((G) => {
288
- const H = u || p.x ? w[G] : T(w[G], o.xLabels);
289
- O.push(...H), H.forEach(() => {
290
- R.push(k), k += W;
291
- }), H.length > 0 && (k += t);
285
+ const L = l[g], y = d.xGroup ? o.xGroupKeys : M(o.xGroupKeys), z = d.yGroup ? o.yGroupKeys : S(o.yGroupKeys), { xKeysByGroups: w } = x ? o : L, { yKeysByGroups: v } = A ? o : L, N = y.map((G) => w[G].length), H = z.map((G) => v[G].length), E = N.reduce((G, T) => G + T, 0), B = H.reduce((G, T) => G + T, 0), W = x && h ? h : (u - (N.filter((G) => G > 0).length - 1) * t) / E, _ = A && c ? c : (b - (H.filter((G) => G > 0).length - 1) * t) / B, R = [];
286
+ let k = [], j = 0;
287
+ y.forEach((G) => {
288
+ const T = p || d.x ? w[G] : M(w[G], o.xLabels);
289
+ k = k.concat(T), T.forEach(() => {
290
+ R.push(j), j += W;
291
+ }), T.length > 0 && (j += t);
292
292
  });
293
- const V = [], J = [];
294
- let X = 0;
293
+ const J = [];
294
+ let X = [], U = 0;
295
295
  z.forEach((G) => {
296
- const H = x || p.y ? v[G] : y(v[G], o.yLabels);
297
- J.push(...H), H.forEach(() => {
298
- V.push(X), X += _;
299
- }), H.length > 0 && (X += t);
300
- }), this.scales.x[g] = I().domain(O).range(R), this.scales.y[g] = I().domain(J).range(V), this.step.x[g] = W, this.step.y[g] = _;
296
+ const T = f || d.y ? v[G] : S(v[G], o.yLabels);
297
+ X = X.concat(T), T.forEach(() => {
298
+ J.push(U), U += _;
299
+ }), T.length > 0 && (U += t);
300
+ }), this.scales.x[g] = I().domain(k).range(R), this.scales.y[g] = I().domain(X).range(J), this.step.x[g] = W, this.step.y[g] = _;
301
301
  });
302
302
  }
303
- updateAesScale(e, s, t, r, i, a, h) {
303
+ updateAesScale(e, s, t, n, i, r, a) {
304
304
  if (e === "continuous")
305
- t.valueColors ? this.colorScale = D().domain(t.valuesByColors ?? et(h, t.valueColors.length, s)).range(t.valueColors) : t.colorsList && (this.colorScale = D().domain(et(h, t.colorsList.length, s)).range(t.colorsList));
305
+ t.valueColors ? this.colorScale = D().domain(t.valuesByColors ?? et(a, t.valueColors.length, s)).range(t.valueColors) : t.colorsList && (this.colorScale = D().domain(et(a, t.colorsList.length, s)).range(t.colorsList));
306
306
  else if (t.colorsMap) {
307
- const p = Object.entries(t.colorsMap);
308
- this.colorScale = I().domain(p.map((d) => d[0])).range(p.map((d) => d[1])).unknown("#ccc");
309
- } else t.colorsList && (this.colorScale = St(t.colorsList, a.map(String)));
310
- const { xDataByKeys: u, yDataByKeys: x } = i.meta;
311
- r.forEach((p) => {
312
- const { colors: d, type: A, axis: l, valueColumn: c } = p, o = (l === "x" ? u : x)[c.valueLabels ?? c.value];
313
- if (A === "discrete") {
314
- const n = nt.uniq(Object.values(o).map(String)).sort();
315
- this.annotationColorScales[p.id] = {
307
+ const d = Object.entries(t.colorsMap);
308
+ this.colorScale = I().domain(d.map((u) => u[0])).range(d.map((u) => u[1])).unknown("#ccc");
309
+ } else t.colorsList && (this.colorScale = yt(t.colorsList, r.map(String)));
310
+ const { xDataByKeys: p, yDataByKeys: f } = i.meta;
311
+ n.forEach((d) => {
312
+ const { colors: u, type: b, axis: h, valueColumn: c } = d, o = (h === "x" ? p : f)[c.valueLabels ?? c.value];
313
+ if (b === "discrete") {
314
+ const l = nt.uniq(Object.values(o).map(String)).sort();
315
+ this.annotationColorScales[d.id] = {
316
316
  type: "discrete",
317
- scale: Ct(d, n)
317
+ scale: Ct(u, l)
318
318
  };
319
319
  } else {
320
- const n = Object.values(o).map(Number);
321
- if (!n.length)
320
+ const l = Object.values(o).map(Number);
321
+ if (!l.length)
322
322
  return;
323
- const [f = n[0], S = n[0]] = Gt(n);
324
- this.annotationColorScales[p.id] = {
323
+ const [x = l[0], A = l[0]] = Gt(l);
324
+ this.annotationColorScales[d.id] = {
325
325
  type: "continuous",
326
- scale: Lt(d, f, S, 0, 0.5, 1)
326
+ scale: Lt(u, x, A, 0, 0.5, 1)
327
327
  };
328
328
  }
329
329
  });
330
330
  }
331
- updateDendrogram(e, s, t, r, i, a, h) {
332
- e.forEach((u) => {
333
- this.dendrograms[u] = { x: { treesByGroupKey: {}, data: a }, y: { treesByGroupKey: {}, data: h } };
334
- const { xKeysByGroups: x, yKeysByGroups: p } = r[u], { hierarchyByGroupX: d, hierarchyByGroupY: A } = i[u];
335
- if (a) {
336
- const l = s.reduce((c, o) => {
337
- var n;
338
- return Math.max(c, (n = d[o]) == null ? void 0 : n.data.height);
331
+ updateDendrogram(e, s, t, n, i, r, a) {
332
+ e.forEach((p) => {
333
+ this.dendrograms[p] = { x: { treesByGroupKey: {}, data: r }, y: { treesByGroupKey: {}, data: a } };
334
+ const { xKeysByGroups: f, yKeysByGroups: d } = n[p];
335
+ if (r) {
336
+ const { hierarchyByGroupX: u } = i[p], b = s.reduce((h, c) => {
337
+ var o;
338
+ return Math.max(h, (o = u[c]) == null ? void 0 : o.data.height);
339
339
  }, 0);
340
- this.dendrograms[u].x.treesByGroupKey = s.reduce((c, o) => {
341
- const n = d[o], f = x[o];
342
- $().separation(() => 1).size([f.length * this.step.x[u], a.size])(
343
- n
340
+ this.dendrograms[p].x.treesByGroupKey = s.reduce((h, c) => {
341
+ const o = u[c], l = f[c];
342
+ $().separation(() => 1).size([l.length * this.step.x[p], r.size])(
343
+ o
344
344
  );
345
- const S = n, T = D().domain(a.position === "top" ? [0, l] : [l, 0]).range([a.size, 0]);
346
- return tt(S, T, "y"), st(S, this.scales.x[u](f[0]), "x"), c[o] = S, c;
347
- }, {}), this.dendrograms[u].x.data = a;
345
+ const x = o, A = D().domain(r.position === "top" ? [0, b] : [b, 0]).range([r.size, 0]);
346
+ return tt(x, A, "y"), st(x, this.scales.x[p](l[0]), "x"), h[c] = x, h;
347
+ }, {}), this.dendrograms[p].x.data = r;
348
348
  }
349
- if (h) {
350
- const l = t.reduce((c, o) => {
351
- var n;
352
- return Math.max(c, (n = A[o]) == null ? void 0 : n.data.height);
349
+ if (a) {
350
+ const { hierarchyByGroupY: u } = i[p], b = t.reduce((h, c) => {
351
+ var o;
352
+ return Math.max(h, (o = u[c]) == null ? void 0 : o.data.height);
353
353
  }, 0);
354
- this.dendrograms[u].y.treesByGroupKey = t.reduce((c, o) => {
355
- const n = A[o], f = p[o];
356
- $().separation(() => 1).size([f.length * this.step.y[u], h.size])(
357
- n
354
+ this.dendrograms[p].y.treesByGroupKey = t.reduce((h, c) => {
355
+ const o = u[c], l = d[c];
356
+ $().separation(() => 1).size([l.length * this.step.y[p], a.size])(
357
+ o
358
358
  );
359
- const S = n, T = D().domain(h.position === "left" ? [0, l] : [l, 0]).range([h.size, 0]);
360
- return st(S, this.scales.y[u](f[0]), "x", "y"), tt(S, T, "x"), c[o] = S, c;
361
- }, {}), this.dendrograms[u].y.data = h;
359
+ const x = o, A = D().domain(a.position === "left" ? [0, b] : [b, 0]).range([a.size, 0]);
360
+ return st(x, this.scales.y[p](l[0]), "x", "y"), tt(x, A, "x"), h[c] = x, h;
361
+ }, {}), this.dendrograms[p].y.data = a;
362
362
  }
363
363
  });
364
364
  }
@@ -366,39 +366,39 @@ class Jt {
366
366
  if (!e)
367
367
  return;
368
368
  const s = Object.keys(e);
369
- this.dendrogramAesScales = s.reduce((t, r) => {
370
- const i = e[r], a = Object.keys(i);
371
- return t[r] = I().domain(a).range(
372
- a.map((h) => ({
369
+ this.dendrogramAesScales = s.reduce((t, n) => {
370
+ const i = e[n], r = Object.keys(i);
371
+ return t[n] = I().domain(r).range(
372
+ r.map((a) => ({
373
373
  ...Z,
374
- ...i[h]
374
+ ...i[a]
375
375
  }))
376
376
  ).unknown(Z), t;
377
377
  }, {});
378
378
  }
379
- render(e, s, t, r, i, a, h, u, x, p, d, A, l, c, o, n, f) {
379
+ render(e, s, t, n, i, r, a, p, f, d, u, b, h, c, o, l, x) {
380
380
  var B;
381
- const { meta: S, facets: T } = a, { facetKeys: y, xGroupKeys: g, yGroupKeys: b, valueExtent: C } = S, { xAxis: z, yAxis: w, title: v, size: N, valueType: M } = t;
382
- this.updateChartsSizes(N, r, a, i.groupGap), this.updateAesScale(M, C.dataSource, i, h, a, l, c), this.updateScales(y, a, i.groupGap, r, N, t.xAxis, t.yAxis, x, p, n), this.updateCaptionsSize(a, z, w, r), this.updateChartDimensions(
381
+ const { meta: A, facets: M } = r, { facetKeys: S, xGroupKeys: g, yGroupKeys: L, valueExtent: y } = A, { xAxis: z, yAxis: w, title: v, size: N, valueType: H } = t;
382
+ this.updateChartsSizes(N, n, r, i.groupGap), this.updateAesScale(H, y.dataSource, i, a, r, h, c), this.updateScales(S, r, i.groupGap, n, N, t.xAxis, t.yAxis, f, d, l), this.updateCaptionsSize(r, z, w, n), this.updateChartDimensions(
383
383
  N,
384
- y,
384
+ S,
385
385
  g,
386
- b,
387
- r,
386
+ L,
387
+ n,
388
388
  z,
389
389
  w,
390
- h,
391
- x,
392
- p
393
- ), this.updateLegendSize(M, t.legend, h, u, C.dataSource), this.updateMargins(v, N), this.updateDendrogram(y, g, b, T, d, x, p), this.updateDendrogramAesScales(A);
394
- const E = /* @__PURE__ */ j.jsx(ht, { dataFrame: e, children: /* @__PURE__ */ j.jsx(
390
+ a,
391
+ f,
392
+ d
393
+ ), this.updateLegendSize(H, t.legend, a, p, y.dataSource), this.updateMargins(v, N), this.updateDendrogram(S, g, L, M, u, f, d), this.updateDendrogramAesScales(b);
394
+ const E = /* @__PURE__ */ O.jsx(ht, { dataFrame: e, children: /* @__PURE__ */ O.jsx(
395
395
  mt,
396
396
  {
397
397
  aes: i,
398
- annotations: h,
398
+ annotations: a,
399
399
  annotationColorScales: this.annotationColorScales,
400
400
  captionsSizes: this.captionsSizes,
401
- cellsMeta: S,
401
+ cellsMeta: A,
402
402
  columnsCount: this.columnsCount,
403
403
  chartsDimensions: this.chartsDimensions,
404
404
  chartSettings: t,
@@ -406,9 +406,9 @@ class Jt {
406
406
  colorScale: this.colorScale,
407
407
  dendrogramAesScales: this.dendrogramAesScales,
408
408
  dendrograms: this.dendrograms,
409
- facetKeys: y,
410
- facetSettings: r,
411
- groupedCells: T,
409
+ facetKeys: S,
410
+ facetSettings: n,
411
+ groupedCells: M,
412
412
  labelAngles: this.labelAngles,
413
413
  legend: this.legend,
414
414
  margins: this.margins,
@@ -416,16 +416,16 @@ class Jt {
416
416
  settingsId: s,
417
417
  step: this.step,
418
418
  xGroupKeys: g,
419
- yGroupKeys: b,
419
+ yGroupKeys: L,
420
420
  onTooltipHintSwitch: o,
421
- cellsRenderingMode: f
421
+ cellsRenderingMode: x
422
422
  }
423
423
  ) });
424
424
  this.component = E, (B = this.reactRoot) == null || B.render(E);
425
425
  }
426
426
  renderError(e) {
427
427
  var s;
428
- (s = this.reactRoot) == null || s.render(/* @__PURE__ */ j.jsx(at, { message: e }));
428
+ (s = this.reactRoot) == null || s.render(/* @__PURE__ */ O.jsx(at, { message: e }));
429
429
  }
430
430
  }
431
431
  export {