@milaboratories/miplots4 1.0.127 → 1.0.129

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