@milaboratories/miplots4 1.0.143 → 1.0.144

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