@milaboratories/miplots4 1.0.144 → 1.0.146

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