@milaboratories/miplots4 1.2.3 → 1.2.4

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 +1 @@
1
- {"version":3,"file":"ChartRenderer.d.ts","sourceRoot":"","sources":["../../src/heatmap/ChartRenderer.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAG1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAG7C,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,iBAAiB,CAAC;AAG9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAW,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAM/D,OAAO,KAAK,EACR,qBAAqB,EACrB,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,UAAU,EACV,YAAY,EAEZ,mBAAmB,EACnB,WAAW,EACX,OAAO,EACV,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AA8FjE,cAAM,aAAa;IACf,SAAS,EAAE,IAAI,GAAG,IAAI,CAAQ;IAC9B,UAAU,EAAE,WAAW,GAAG,IAAI,CAAQ;IACtC,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAQ;IACpC,SAAS,EAAE,YAAY,CAAW;IAClC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAM;IAC3D,UAAU,EAAE,UAAU,CAOpB;IACF,OAAO,EAAE,OAAO,CAKd;IACF,aAAa,EAAE,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AAC,aAAa,CAAC,EAC/C,WAAW,EAAE,mBAAmB,CAAC,aAAa,CAAC,EAC/C,eAAe,EAAE,eAAe,EAChC,sBAAsB,EAAE,mBAAmB,CAAC,wBAAwB,CAAC,EACrE,cAAc,EAAE,SAAS,EAAE,EAC3B,aAAa,EAAE,mBAAmB,CAAC,eAAe,CAAC,EACnD,mBAAmB,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,EACzC,kBAAkB,EAAE,QAAQ,GAAG,KAAK;IA6DxC,WAAW,CAAC,OAAO,EAAE,MAAM;CAG9B;AAED,eAAe,aAAa,CAAC"}
@@ -3,35 +3,36 @@ import { getContinuousLegendTicks as t } from "../utils/getContinuousLegendTicks
3
3
  import { TextMeasurer as n } from "../utils/TextMeasurer/TextMeasurer.js";
4
4
  import { DataFrameProvider as r } from "../common/useDataFrame.js";
5
5
  import { arrangeLegendParts as i } from "../utils/arrangeLegendParts.js";
6
- import { getChartEdgeSides as a } from "../utils/getChartEdgeSides.js";
7
- import { CHART_SIDE_ELEMENTS as o, DEFAULT_AES as s } from "./constants.js";
8
- import { ChartsGroup as c } from "./components/ChartsGroup.js";
9
- import { calculateChartSideElementSizes as l } from "./utils/calculateChartSideElementSizes.js";
10
- import { calculateSideElementsBBoxes as u } from "./utils/calculateSideElementsBBoxes.js";
11
- import { createContinuousColorScale as d, createDiscreteColorScale as f, createDiscreteRoundColorScale as p } from "./utils/createColorScales.js";
12
- import { calculateAnnotationTitleSizes as m } from "./utils/calculateAnnotationTitleSizes.js";
6
+ import { computeChartInnerSize as a } from "../utils/computeChartInnerSize.js";
7
+ import { getChartEdgeSides as o } from "../utils/getChartEdgeSides.js";
8
+ import { CHART_SIDE_ELEMENTS as s, DEFAULT_AES as c } from "./constants.js";
9
+ import { ChartsGroup as l } from "./components/ChartsGroup.js";
10
+ import { calculateChartSideElementSizes as u } from "./utils/calculateChartSideElementSizes.js";
11
+ import { calculateSideElementsBBoxes as d } from "./utils/calculateSideElementsBBoxes.js";
12
+ import { createContinuousColorScale as f, createDiscreteColorScale as p, createDiscreteRoundColorScale as m } from "./utils/createColorScales.js";
13
+ import { calculateAnnotationTitleSizes as h } from "./utils/calculateAnnotationTitleSizes.js";
13
14
  import "./utils/index.js";
14
- import { calculateCaptionTails as h } from "./utils/calculateCaptionTails.js";
15
- import g from "lodash";
16
- import { cluster as _ } from "d3-hierarchy";
17
- import { scaleLinear as v, scaleOrdinal as y } from "d3-scale";
18
- import { createRoot as b } from "react-dom/client";
19
- import { Fragment as x, jsx as S } from "react/jsx-runtime";
20
- import { extent as C } from "d3-array";
21
- var w = Math.cos(Math.PI / 4), T = 5;
22
- function E(e, t, n) {
15
+ import { calculateCaptionTails as g } from "./utils/calculateCaptionTails.js";
16
+ import _ from "lodash";
17
+ import { cluster as v } from "d3-hierarchy";
18
+ import { scaleLinear as y, scaleOrdinal as b } from "d3-scale";
19
+ import { createRoot as x } from "react-dom/client";
20
+ import { Fragment as S, jsx as C } from "react/jsx-runtime";
21
+ import { extent as w } from "d3-array";
22
+ var T = Math.cos(Math.PI / 4), E = 5;
23
+ function D(e, t, n) {
23
24
  function r(e) {
24
25
  e[n] = t(e.data.height), e.children && e.children.forEach(r);
25
26
  }
26
27
  r(e);
27
28
  }
28
- function D(e, t, n, r = n) {
29
+ function O(e, t, n, r = n) {
29
30
  function i(e) {
30
31
  e[r] = e[n] + t, e.children && e.children.forEach(i);
31
32
  }
32
33
  i(e);
33
34
  }
34
- var O = (e, t) => {
35
+ var k = (e, t) => {
35
36
  let n = Math.min(...t), r = Math.max(...t);
36
37
  if (n === r) {
37
38
  let t = e % 2 == 0 ? [] : [n];
@@ -43,11 +44,11 @@ var O = (e, t) => {
43
44
  for (let t = 0; t < e - 1; t++) a.push(n + i * t);
44
45
  return a.push(r), a;
45
46
  };
46
- function k(e, t, n) {
47
+ function A(e, t, n) {
47
48
  let r = n;
48
- return e && (e.colorRange && (r = e.colorRange), e.method === "standardScaling" && (r = [-2, 2]), e.method === "meanNormalization" && (r = [-.75, .75])), O(t, r);
49
+ return e && (e.colorRange && (r = e.colorRange), e.method === "standardScaling" && (r = [-2, 2]), e.method === "meanNormalization" && (r = [-.75, .75])), k(t, r);
49
50
  }
50
- function A(e, t, n) {
51
+ function j(e, t, n) {
51
52
  let r = 0;
52
53
  for (let i of e) {
53
54
  if (t[i] === void 0) continue;
@@ -56,14 +57,14 @@ function A(e, t, n) {
56
57
  }
57
58
  return r;
58
59
  }
59
- function j(e, t) {
60
- return t === 90 ? e : t === 45 ? e * w + (e > 0 ? 2 * T : 0) : 30;
60
+ function M(e, t) {
61
+ return t === 90 ? e : t === 45 ? e * T + (e > 0 ? 2 * E : 0) : 30;
61
62
  }
62
- var M = class {
63
+ var N = class {
63
64
  reactRoot = null;
64
65
  parentNode = null;
65
66
  rootNode = null;
66
- component = /* @__PURE__ */ S(x, {});
67
+ component = /* @__PURE__ */ C(S, {});
67
68
  chartsDimensions = {};
68
69
  chartSizes = {
69
70
  chartWidth: 600,
@@ -96,14 +97,14 @@ var M = class {
96
97
  columnsCount = 1;
97
98
  rowsCount = 1;
98
99
  scales = {
99
- x: { null: y().domain(["null"]).range([1]) },
100
- y: { null: y().domain(["null"]).range([1]) }
100
+ x: { null: b().domain(["null"]).range([1]) },
101
+ y: { null: b().domain(["null"]).range([1]) }
101
102
  };
102
103
  step = {
103
104
  x: {},
104
105
  y: {}
105
106
  };
106
- colorScale = v().domain([0, 1]).range(["white", "black"]);
107
+ colorScale = y().domain([0, 1]).range(["white", "black"]);
107
108
  annotationColorScales = {};
108
109
  dendrogramAesScales = {};
109
110
  legend = {
@@ -118,7 +119,7 @@ var M = class {
118
119
  });
119
120
  }
120
121
  init(e) {
121
- this.parentNode === null && (this.parentNode = e, this.rootNode = document.createElement("div"), this.parentNode.appendChild(this.rootNode), this.reactRoot = b(this.rootNode));
122
+ this.parentNode === null && (this.parentNode = e, this.rootNode = document.createElement("div"), this.parentNode.appendChild(this.rootNode), this.reactRoot = x(this.rootNode));
122
123
  }
123
124
  updateMargins(e, t) {
124
125
  this.margins = {
@@ -144,7 +145,7 @@ var M = class {
144
145
  top: 0
145
146
  }, d = (e) => e.reduce((e, t) => (e[t] = String(t), e), {});
146
147
  if (e === "continuous") {
147
- let e = this.colorScale, n = t(e, o), r = v([n[0], n[n.length - 1]], [s, 0]), i = a.label ?? a.value;
148
+ let e = this.colorScale, n = t(e, o), r = y([n[0], n[n.length - 1]], [s, 0]), i = a.label ?? a.value;
148
149
  l.push({
149
150
  ...u,
150
151
  type: "continuous",
@@ -169,7 +170,7 @@ var M = class {
169
170
  if (r.forEach((e) => {
170
171
  let n = e.valueColumn.label ?? e.valueColumn.value;
171
172
  if (e.type === "continuous") {
172
- let r = this.annotationColorScales[e.id].scale, i = t(r, o), a = v([i[0], i[i.length - 1]], [s, 0]);
173
+ let r = this.annotationColorScales[e.id].scale, i = t(r, o), a = y([i[0], i[i.length - 1]], [s, 0]);
173
174
  l.push({
174
175
  ...u,
175
176
  type: "continuous",
@@ -215,26 +216,26 @@ var M = class {
215
216
  xGroupLabels: t.groupLabelsAngle,
216
217
  yGroupLabels: r.groupLabelsAngle
217
218
  };
218
- let m = o.reduce((e, t) => Math.max(e, A(u[t], f, a)), 0), g = s.reduce((e, t) => Math.max(e, A(d[t], p, a)), 0), _ = A(o, c, a), v = A(s, l, a), { xCaptionTail: y, yCaptionTail: b } = h(this.labelAngles, i, this.scales, this.step, e, a);
219
+ let m = o.reduce((e, t) => Math.max(e, j(u[t], f, a)), 0), h = s.reduce((e, t) => Math.max(e, j(d[t], p, a)), 0), _ = j(o, c, a), v = j(s, l, a), { xCaptionTail: y, yCaptionTail: b } = g(this.labelAngles, i, this.scales, this.step, e, a);
219
220
  this.captionsSizes = {
220
221
  xCaptionTail: y,
221
222
  yCaptionTail: b,
222
- xGroupCaptions: j(_, this.labelAngles.xGroupLabels),
223
- yGroupCaptions: j(v, this.labelAngles.yGroupLabels),
224
- xAxisCaptions: j(m, this.labelAngles.xAxisLabels),
225
- yAxisCaptions: j(g, this.labelAngles.yAxisLabels)
223
+ xGroupCaptions: M(_, this.labelAngles.xGroupLabels),
224
+ yGroupCaptions: M(v, this.labelAngles.yGroupLabels),
225
+ xAxisCaptions: M(m, this.labelAngles.xAxisLabels),
226
+ yAxisCaptions: M(h, this.labelAngles.yAxisLabels)
226
227
  };
227
228
  }
228
- updateChartDimensions(e, t, n, r, i, s, c, d, f, p) {
229
- let h = t.length, g = Math.min(i.nRows ?? h, h), _ = Math.min(i.nCols ?? h, h);
230
- this.columnsCount = i.nRows ? Math.ceil(h / g) : _, this.rowsCount = Math.ceil(h / this.columnsCount);
229
+ updateChartDimensions(e, t, n, r, i, a, c, l, f, p) {
230
+ let m = t.length, g = Math.min(i.nRows ?? m, m), _ = Math.min(i.nCols ?? m, m);
231
+ this.columnsCount = i.nRows ? Math.ceil(m / g) : _, this.rowsCount = Math.ceil(m / this.columnsCount);
231
232
  let { sharedX: v, sharedY: y } = i;
232
233
  this.chartsDimensions = {};
233
234
  let b = 0, x = 0;
234
- t.forEach((i, h) => {
235
- let g = h % this.columnsCount + 1, _ = a(h, t.length, this.columnsCount, this.rowsCount), S = this.step.x[i], C = this.step.y[i], w = l(s, c, this.captionsSizes, d, f, p, _, v, y, t, n, r, S, C), T = m(d, _, v, y);
235
+ t.forEach((i, m) => {
236
+ let g = m % this.columnsCount + 1, _ = o(m, t.length, this.columnsCount, this.rowsCount), S = this.step.x[i], C = this.step.y[i], w = u(a, c, this.captionsSizes, l, f, p, _, v, y, t, n, r, S, C), T = h(l, _, v, y);
236
237
  function E(t) {
237
- return Math.max(o[t].reduce((e, n) => e + w[t][n], 0), T[t], e.innerOffset);
238
+ return Math.max(s[t].reduce((e, n) => e + w[t][n], 0), T[t], e.innerOffset);
238
239
  }
239
240
  let D = {
240
241
  left: E("left"),
@@ -243,7 +244,7 @@ var M = class {
243
244
  bottom: E("bottom")
244
245
  };
245
246
  D.left < this.captionsSizes.xCaptionTail && (D.left = this.captionsSizes.xCaptionTail), D.bottom < this.captionsSizes.yCaptionTail && (D.bottom = this.captionsSizes.yCaptionTail);
246
- let O = u(w, this.chartSizes.chartWidth, this.chartSizes.chartHeight), k = this.chartSizes.chartWidth + D.left + D.right, A = this.chartSizes.chartHeight + D.top + D.bottom;
247
+ let O = d(w, this.chartSizes.chartWidth, this.chartSizes.chartHeight), k = this.chartSizes.chartWidth + D.left + D.right, A = this.chartSizes.chartHeight + D.top + D.bottom;
247
248
  this.chartsDimensions[i] = {
248
249
  left: b,
249
250
  top: x,
@@ -264,23 +265,16 @@ var M = class {
264
265
  this.chartSizes.chartsWidth = S, this.chartSizes.chartsHeight = C;
265
266
  }
266
267
  updateChartsSizes(e, t, n) {
267
- let { width: r, height: i, cellWidth: a, cellHeight: o } = e, s = t.meta.facetKeys[0];
268
- if (a && s) {
269
- let e = t.facets[s].xKeys.length, r = t.meta.xGroupKeys.filter((e) => (t.facets[s]?.xKeysByGroups[e]?.length ?? 0) > 0).length;
270
- this.chartSizes.chartWidth = e * a + n * (r - 1);
271
- } else this.chartSizes.chartWidth = r;
272
- if (o && s) {
273
- let e = t.facets[s].yKeys.length, r = t.meta.yGroupKeys.filter((e) => (t.facets[s]?.yKeysByGroups[e]?.length ?? 0) > 0).length;
274
- this.chartSizes.chartHeight = e * o + n * (r - 1);
275
- } else this.chartSizes.chartHeight = i;
268
+ let { chartWidth: r, chartHeight: i } = a(e, t.meta, n);
269
+ this.chartSizes.chartWidth = r, this.chartSizes.chartHeight = i;
276
270
  }
277
271
  updateScales(e, t, n, r, i) {
278
272
  let { width: a, height: o, cellWidth: s, cellHeight: c } = i, { meta: l, facets: u } = t, { sharedX: d, sharedY: f } = r;
279
273
  e.forEach((e) => {
280
- let t = u[e], r = l.xGroupKeys, i = l.yGroupKeys, { xKeysByGroups: p } = d ? l : t, { yKeysByGroups: m } = f ? l : t, h = r.map((e) => p[e].length), g = i.map((e) => m[e].length), _ = h.reduce((e, t) => e + t, 0), v = g.reduce((e, t) => e + t, 0), b = s || (a - (h.filter((e) => e > 0).length - 1) * n) / _, x = c || (o - (g.filter((e) => e > 0).length - 1) * n) / v, S = [], C = [], w = 0, T = r.map((e) => p[e]);
274
+ let t = u[e], r = l.xGroupKeys, i = l.yGroupKeys, { xKeysByGroups: p } = d ? l : t, { yKeysByGroups: m } = f ? l : t, h = r.map((e) => p[e].length), g = i.map((e) => m[e].length), _ = h.reduce((e, t) => e + t, 0), v = g.reduce((e, t) => e + t, 0), y = s || (a - (h.filter((e) => e > 0).length - 1) * n) / _, x = c || (o - (g.filter((e) => e > 0).length - 1) * n) / v, S = [], C = [], w = 0, T = r.map((e) => p[e]);
281
275
  T.forEach((e, t) => {
282
276
  C = C.concat(e), e.forEach(() => {
283
- S.push(w), w += b;
277
+ S.push(w), w += y;
284
278
  });
285
279
  let r = T.slice(t + 1).some((e) => e.length > 0);
286
280
  e.length > 0 && r && (w += n);
@@ -292,31 +286,31 @@ var M = class {
292
286
  });
293
287
  let r = k.slice(t + 1).some((e) => e.length > 0);
294
288
  e.length > 0 && r && (O += n);
295
- }), this.scales.x[e] = y().domain(C).range(S), this.scales.y[e] = y().domain(D).range(E), this.step.x[e] = b, this.step.y[e] = x;
289
+ }), this.scales.x[e] = b().domain(C).range(S), this.scales.y[e] = b().domain(D).range(E), this.step.x[e] = y, this.step.y[e] = x;
296
290
  });
297
291
  }
298
292
  updateAesScale(e, t, n, r, i, a, o) {
299
- if (e === "continuous") n.valueColors ? this.colorScale = v().domain(n.valuesByColors ?? k(o, n.valueColors.length, t)).range(n.valueColors) : n.colorsList && (this.colorScale = v().domain(k(o, n.colorsList.length, t)).range(n.colorsList));
293
+ if (e === "continuous") n.valueColors ? this.colorScale = y().domain(n.valuesByColors ?? A(o, n.valueColors.length, t)).range(n.valueColors) : n.colorsList && (this.colorScale = y().domain(A(o, n.colorsList.length, t)).range(n.colorsList));
300
294
  else if (n.colorsMap) {
301
295
  let e = Object.entries(n.colorsMap);
302
- this.colorScale = y().domain(e.map((e) => e[0])).range(e.map((e) => e[1])).unknown("#ccc");
303
- } else n.colorsList && (this.colorScale = f(n.colorsList, a.map(String)));
296
+ this.colorScale = b().domain(e.map((e) => e[0])).range(e.map((e) => e[1])).unknown("#ccc");
297
+ } else n.colorsList && (this.colorScale = p(n.colorsList, a.map(String)));
304
298
  let { xDataByKeys: s, yDataByKeys: c } = i.meta;
305
299
  r.forEach((e) => {
306
300
  let { colors: t, type: n, axis: r, valueColumn: i } = e, a = (r === "x" ? s : c)[i.valueLabels ?? i.value];
307
301
  if (n === "discrete") {
308
- let n = g.uniq(Object.values(a).map(String)).sort();
302
+ let n = _.uniq(Object.values(a).map(String)).sort();
309
303
  this.annotationColorScales[e.id] = {
310
304
  type: "discrete",
311
- scale: p(t, n)
305
+ scale: m(t, n)
312
306
  };
313
307
  } else {
314
308
  let n = Object.values(a).map(Number);
315
309
  if (!n.length) return;
316
- let [r = n[0], i = n[0]] = C(n);
310
+ let [r = n[0], i = n[0]] = w(n);
317
311
  this.annotationColorScales[e.id] = {
318
312
  type: "continuous",
319
- scale: d(t, r, i, 0, .5, 1)
313
+ scale: f(t, r, i, 0, .5, 1)
320
314
  };
321
315
  }
322
316
  });
@@ -340,9 +334,9 @@ var M = class {
340
334
  let o = n[i];
341
335
  if (!o) return t;
342
336
  let c = s[i];
343
- _().separation(() => 1).size([o.leaves().length * this.step.x[e], a.size])(o);
337
+ v().separation(() => 1).size([o.leaves().length * this.step.x[e], a.size])(o);
344
338
  let l = o;
345
- return E(l, v().domain(a.position === "top" ? [0, r] : [r, 0]).range([a.size, 0]), "y"), D(l, this.scales.x[e](c[0]), "x"), t[i] = l, t;
339
+ return D(l, y().domain(a.position === "top" ? [0, r] : [r, 0]).range([a.size, 0]), "y"), O(l, this.scales.x[e](c[0]), "x"), t[i] = l, t;
346
340
  }, {}), this.dendrograms[e].x.data = a;
347
341
  }
348
342
  if (o) {
@@ -351,9 +345,9 @@ var M = class {
351
345
  let a = t[i];
352
346
  if (!a) return n;
353
347
  let s = c[i];
354
- _().separation(() => 1).size([a.leaves().length * this.step.y[e], o.size])(a);
355
- let l = a, u = v().domain(o.position === "left" ? [0, r] : [r, 0]).range([o.size, 0]);
356
- return D(l, this.scales.y[e](s[0]), "x", "y"), E(l, u, "x"), n[i] = l, n;
348
+ v().separation(() => 1).size([a.leaves().length * this.step.y[e], o.size])(a);
349
+ let l = a, u = y().domain(o.position === "left" ? [0, r] : [r, 0]).range([o.size, 0]);
350
+ return O(l, this.scales.y[e](s[0]), "x", "y"), D(l, u, "x"), n[i] = l, n;
357
351
  }, {}), this.dendrograms[e].y.data = o;
358
352
  }
359
353
  });
@@ -361,18 +355,18 @@ var M = class {
361
355
  updateDendrogramAesScales(e) {
362
356
  e && (this.dendrogramAesScales = Object.keys(e).reduce((t, n) => {
363
357
  let r = e[n], i = Object.keys(r);
364
- return t[n] = y().domain(i).range(i.map((e) => ({
365
- ...s,
358
+ return t[n] = b().domain(i).range(i.map((e) => ({
359
+ ...c,
366
360
  ...r[e]
367
- }))).unknown(s), t;
361
+ }))).unknown(c), t;
368
362
  }, {}));
369
363
  }
370
- render(e, t, n, i, a, o, s, l, u, d, f, p, m, h, g, _) {
371
- let { meta: v, facets: y } = o, { facetKeys: b, xGroupKeys: x, yGroupKeys: C, valueExtent: w } = v, { xAxis: T, yAxis: E, title: D, size: O, valueType: k } = n;
372
- this.updateChartsSizes(O, o, a.groupGap), this.updateAesScale(k, w.dataSource, a, s, o, m, h), this.updateScales(b, o, a.groupGap, i, O), this.updateCaptionsSize(o, T, E, i), this.updateChartDimensions(O, b, x, C, i, T, E, s, u, d), this.updateLegendSize(k, n.legend, s, l, w.dataSource), this.updateMargins(D, O), this.updateDendrogram(b, x, C, y, f, u, d), this.updateDendrogramAesScales(p);
373
- let A = /* @__PURE__ */ S(r, {
364
+ render(e, t, n, i, a, o, s, c, u, d, f, p, m, h, g, _) {
365
+ let { meta: v, facets: y } = o, { facetKeys: b, xGroupKeys: x, yGroupKeys: S, valueExtent: w } = v, { xAxis: T, yAxis: E, title: D, size: O, valueType: k } = n;
366
+ this.updateChartsSizes(O, o, a.groupGap), this.updateAesScale(k, w.dataSource, a, s, o, m, h), this.updateScales(b, o, a.groupGap, i, O), this.updateCaptionsSize(o, T, E, i), this.updateChartDimensions(O, b, x, S, i, T, E, s, u, d), this.updateLegendSize(k, n.legend, s, c, w.dataSource), this.updateMargins(D, O), this.updateDendrogram(b, x, S, y, f, u, d), this.updateDendrogramAesScales(p);
367
+ let A = /* @__PURE__ */ C(r, {
374
368
  dataFrame: e,
375
- children: /* @__PURE__ */ S(c, {
369
+ children: /* @__PURE__ */ C(l, {
376
370
  aes: a,
377
371
  annotations: s,
378
372
  annotationColorScales: this.annotationColorScales,
@@ -395,7 +389,7 @@ var M = class {
395
389
  settingsId: t,
396
390
  step: this.step,
397
391
  xGroupKeys: x,
398
- yGroupKeys: C,
392
+ yGroupKeys: S,
399
393
  onTooltipHintSwitch: g,
400
394
  cellsRenderingMode: _
401
395
  })
@@ -403,9 +397,9 @@ var M = class {
403
397
  this.component = A, this.reactRoot?.render(A);
404
398
  }
405
399
  renderError(t) {
406
- this.reactRoot?.render(/* @__PURE__ */ S(e, { message: t }));
400
+ this.reactRoot?.render(/* @__PURE__ */ C(e, { message: t }));
407
401
  }
408
402
  };
409
- export { M as default };
403
+ export { N as default };
410
404
 
411
405
  //# sourceMappingURL=ChartRenderer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChartRenderer.js","names":[],"sources":["../../src/heatmap/ChartRenderer.tsx"],"sourcesContent":["import { extent } from 'd3-array';\nimport type { HierarchyNode, HierarchyPointNode } from 'd3-hierarchy';\nimport { cluster } from 'd3-hierarchy';\nimport type { ScaleLinear, ScaleOrdinal } from 'd3-scale';\nimport { scaleLinear, scaleOrdinal } from 'd3-scale';\nimport lodash from 'lodash';\nimport type { ReactElement } from 'react';\nimport type { Root } from 'react-dom/client';\nimport { createRoot } from 'react-dom/client';\nimport { Error } from '../common/Error';\nimport type { LegendData, LegendItem } from '../common/types';\nimport { DataFrameProvider } from '../common/useDataFrame';\nimport { DEFAULT_HEIGHT, DEFAULT_WIDTH, MAX_LEGEND_GRADIENT_HEIGHT, MIN_LEGEND_GRADIENT_HEIGHT, TITLE_LINE_HEIGHT, TITLE_MARGIN } from '../constants';\nimport type { DataFrame } from '../DataFrame';\nimport type { AesItem, ColumnName, DataValue } from '../types';\nimport { arrangeLegendParts } from '../utils/arrangeLegendParts';\nimport { getChartEdgeSides } from '../utils/getChartEdgeSides';\nimport { getContinuousLegendTicks } from '../utils/getContinuousLegendTicks';\nimport { TextMeasurer } from '../utils/TextMeasurer/TextMeasurer';\nimport { ChartsGroup } from './components/ChartsGroup';\nimport type {\n AnnotationColorScales,\n CaptionsSizes,\n ChartDendrograms,\n ChartDimensionsData,\n ChartSizes,\n ChartsScales,\n Cluster,\n DendrogramAesScales,\n LabelAngles,\n Margins,\n} from './components/types';\nimport { CHART_SIDE_ELEMENTS, DEFAULT_AES, LEGEND_OFFSET, MIN_MARGIN, TITLE_LINE } from './constants';\nimport type { GroupedCellsHeatmap } from './getCells';\nimport type { DendrogramsData } from './getDendrograms';\nimport type { HeatmapSettingsImpl } from './HeatmapSettingsImpl';\nimport {\n calculateAnnotationTitleSizes,\n calculateChartSideElementSizes,\n calculateSideElementsBBoxes,\n createContinuousColorScale,\n createDiscreteColorScale,\n createDiscreteRoundColorScale,\n} from './utils';\nimport { calculateCaptionTails } from './utils/calculateCaptionTails';\n\nconst COS_PI_4 = Math.cos(Math.PI / 4);\nconst INCLINE_OFFSET = 5; // height of little triangle of text for captions inclined 45deg\nfunction updateLinksHeight(root: HierarchyPointNode<Cluster>, scale: (v: number) => number, coord: 'x' | 'y') {\n function setHeight(d: HierarchyPointNode<Cluster>) {\n d[coord] = scale(d.data.height);\n if (d.children) d.children.forEach(setHeight);\n }\n setHeight(root);\n}\n\n// add shift to move nodes positions with group gaps\nfunction addShiftToLinkCoord(\n root: HierarchyPointNode<Cluster>,\n shift: number,\n coordFrom: 'x' | 'y',\n coordTo = coordFrom\n) {\n function setX(d: HierarchyPointNode<Cluster>) {\n d[coordTo] = d[coordFrom] + shift;\n if (d.children) d.children.forEach(setX);\n }\n setX(root);\n}\n\nconst getSteps = (count: number, valueExtent: number[]) => {\n const min = Math.min(...valueExtent);\n const max = Math.max(...valueExtent);\n if (min === max) {\n const steps = count % 2 === 0 ? [] : [min];\n for (let i = 1; i < count / 2 + 1; i++) {\n steps.push(min + i);\n steps.unshift(min - i);\n }\n return steps;\n }\n if (count < 2) {\n return [min, max];\n }\n const step = (max - min) / (count - 1);\n const steps = [];\n for (let i = 0; i < count - 1; i++) {\n steps.push(min + step * i);\n }\n steps.push(max);\n return steps;\n};\n\nfunction getContinuousColorRange(normalization: HeatmapSettingsImpl['normalization'], colorsCount: number, valueExtent: number[]) {\n let extent = valueExtent;\n if (normalization) {\n if (normalization.colorRange) {\n extent = normalization.colorRange;\n }\n if (normalization.method === 'standardScaling') {\n extent = [-2, 2];\n }\n if (normalization.method === 'meanNormalization') {\n extent = [-0.75, 0.75];\n }\n }\n return getSteps(colorsCount, extent);\n}\n\nfunction getMaxTextLength(keys: string[], labels: Record<string, string>, textMeasurer: TextMeasurer) {\n let maxLabelSize = 0;\n for (const key of keys) {\n if (labels[key] === undefined) continue;\n const l = textMeasurer.getTextWidth(labels[key]);\n if (l > maxLabelSize) maxLabelSize = l;\n }\n return maxLabelSize;\n}\n\nfunction getCaptionHeight(size: number, angle: number) {\n if (angle === 90) {\n return size;\n }\n if (angle === 45) {\n return size * COS_PI_4 + (size > 0 ? 2 * INCLINE_OFFSET : 0);\n }\n return TITLE_LINE;\n}\n\nclass ChartRenderer {\n reactRoot: Root | null = null;\n parentNode: HTMLElement | null = null;\n rootNode: HTMLElement | null = null;\n component: ReactElement = (<></>);\n chartsDimensions: Record<string, ChartDimensionsData> = {};\n chartSizes: ChartSizes = {\n chartWidth: DEFAULT_WIDTH, // width of single chart\n chartHeight: DEFAULT_HEIGHT, // height of single chart\n chartsWidth: DEFAULT_WIDTH, // width of all charts in charts row\n chartsHeight: DEFAULT_HEIGHT, // width of all charts in charts column, without axes\n totalWidth: DEFAULT_WIDTH, // width of all charts in charts row, plus left axis, plus legend\n totalHeight: DEFAULT_HEIGHT, // width of all charts in charts height, plus bottom axis, plus top title\n };\n margins: Margins = {\n top: MIN_MARGIN,\n bottom: MIN_MARGIN,\n left: MIN_MARGIN,\n right: MIN_MARGIN,\n };\n captionsSizes: CaptionsSizes = {\n xAxisCaptions: 100,\n yAxisCaptions: 100,\n xGroupCaptions: TITLE_LINE,\n yGroupCaptions: TITLE_LINE,\n xCaptionTail: 0,\n yCaptionTail: 0,\n };\n labelAngles: LabelAngles = {\n xAxisLabels: 0,\n yAxisLabels: 0,\n xGroupLabels: 0,\n yGroupLabels: 0,\n };\n columnsCount = 1;\n rowsCount = 1;\n scales: ChartsScales = {\n // scales grouped by facet\n x: { null: scaleOrdinal<string, number>().domain(['null']).range([1]) },\n y: { null: scaleOrdinal<string, number>().domain(['null']).range([1]) },\n };\n step: {\n x: Record<string, number>;\n y: Record<string, number>;\n } = { x: {}, y: {} };\n colorScale: ScaleLinear<string, string> | ScaleOrdinal<string, string, string> = scaleLinear<string, string>()\n .domain([0, 1])\n .range(['white', 'black']);\n annotationColorScales: AnnotationColorScales = {};\n dendrogramAesScales: DendrogramAesScales = {};\n legend: LegendData = {\n width: 0,\n height: 0,\n items: [],\n };\n dendrograms: Record<string, ChartDendrograms> = {};\n\n clear() {\n if (this.parentNode && this.rootNode) {\n this.parentNode?.removeChild(this.rootNode);\n this.parentNode = null;\n this.rootNode = null;\n }\n // timeout to avoid trying to unmount during rendering\n setTimeout(() => {\n this.reactRoot?.unmount();\n this.reactRoot = null;\n });\n }\n\n init(node: HTMLElement) {\n if (this.parentNode === null) {\n this.parentNode = node;\n this.rootNode = document.createElement('div');\n this.parentNode.appendChild(this.rootNode);\n this.reactRoot = createRoot(this.rootNode);\n }\n }\n\n updateMargins(title: HeatmapSettingsImpl['chartSettings']['title'], size: HeatmapSettingsImpl['chartSettings']['size']) {\n this.margins = {\n top: title.show ? TITLE_LINE_HEIGHT + TITLE_MARGIN * 2 : size.outerOffset,\n bottom: size.outerOffset,\n left: size.outerOffset,\n right: this.legend.width + size.outerOffset,\n };\n this.chartSizes.totalWidth = this.margins.left + this.chartSizes.chartsWidth + this.margins.right;\n this.chartSizes.totalHeight =\n this.margins.top + Math.max(this.chartSizes.chartsHeight + this.margins.bottom, this.legend.height);\n }\n\n updateLegendSize(\n valueType: HeatmapSettingsImpl['chartSettings']['valueType'],\n legend: HeatmapSettingsImpl['chartSettings']['legend'],\n annotations: HeatmapSettingsImpl['annotations'],\n columnValue: ColumnName,\n valueExtent: [number, number]\n ) {\n if (!legend.show) {\n this.legend = { width: 0, height: 0, items: [] };\n return;\n }\n const continuousHeight = Math.min(\n Math.max(this.chartSizes.chartHeight, MIN_LEGEND_GRADIENT_HEIGHT),\n MAX_LEGEND_GRADIENT_HEIGHT\n );\n const legendHeight = Math.max(this.chartSizes.chartHeight, continuousHeight);\n const legendItems: LegendItem[] = [];\n const emptySizes = { width: 0, height: 0, left: 0, top: 0 };\n\n const getDefaultLabels = (values: (string | number)[]) => values.reduce((res: Record<string, string>, v: string | number) => { res[v] = String(v); return res; }, {});\n if (valueType === 'continuous') {\n const scale = this.colorScale as ScaleLinear<string, string>;\n const values = getContinuousLegendTicks(scale, valueExtent);\n const tickPositionScale = scaleLinear([values[0], values[values.length - 1]], [continuousHeight, 0]); //TODO: update during adding log scale for heatmap\n const title = columnValue.label ?? columnValue.value;\n legendItems.push({\n ...emptySizes,\n type: 'continuous',\n id: 'heatmapValue',\n scale,\n values,\n title,\n tickPositionScale\n });\n } else if (valueType === 'discrete') {\n const scale = this.colorScale as ScaleOrdinal<string, string>;\n const title = columnValue.label ?? columnValue.value;\n const values = scale.domain();\n const labels = getDefaultLabels(values);\n\n legendItems.push({ ...emptySizes, type: 'discreteColor', id: 'heatmapValue', title, scale, values, labels });\n }\n annotations.forEach(item => {\n const title = item.valueColumn.label ?? item.valueColumn.value;\n if (item.type === 'continuous') {\n const scale = this.annotationColorScales[item.id].scale as ScaleLinear<string, string>;\n const values = getContinuousLegendTicks(scale, valueExtent);\n const tickPositionScale = scaleLinear([values[0], values[values.length - 1]], [continuousHeight, 0]); //TODO: update during adding log scale for heatmap\n\n legendItems.push({ ...emptySizes, type: 'continuous', id: item.id, tickPositionScale, title, scale, values });\n }\n if (item.type === 'discrete') {\n const scale = this.annotationColorScales[item.id].scale as ScaleOrdinal<string, string>;\n const values = scale.domain();\n const labels = getDefaultLabels(values);\n\n legendItems.push({ ...emptySizes, type: 'discreteColor', id: item.id, title, scale, values, labels });\n }\n });\n\n if (!legendItems.length) {\n this.legend = { width: 0, height: 0, items: [] };\n return;\n }\n\n const items = arrangeLegendParts(legendItems, this.chartSizes.chartHeight,continuousHeight);\n const maxRightEdge = items.reduce((max, item) => Math.max(max, item.left + item.width), 0);\n\n const legendWidth = maxRightEdge + LEGEND_OFFSET;\n\n this.legend = {\n width: legendWidth,\n height: legendHeight,\n items\n };\n }\n\n updateCaptionsSize(\n groupedCells: GroupedCellsHeatmap,\n xAxis: HeatmapSettingsImpl['chartSettings']['xAxis'],\n yAxis: HeatmapSettingsImpl['chartSettings']['yAxis'],\n facetSettings: HeatmapSettingsImpl['facetSettings']\n ) {\n const textMeasurer = new TextMeasurer('bold 16px Manrope');\n const { xGroupKeys, yGroupKeys, xGroupLabels, yGroupLabels, xKeysByGroups, yKeysByGroups, xLabels, yLabels } = groupedCells.meta;\n this.labelAngles = {\n xAxisLabels: xAxis.axisLabelsAngle,\n yAxisLabels: yAxis.axisLabelsAngle,\n xGroupLabels: xAxis.groupLabelsAngle,\n yGroupLabels: yAxis.groupLabelsAngle,\n };\n\n const maxXLabelSize = xGroupKeys.reduce((res, key) => Math.max(res, getMaxTextLength(xKeysByGroups[key], xLabels, textMeasurer)), 0);\n const maxYLabelSize = yGroupKeys.reduce((res, key) => Math.max(res, getMaxTextLength(yKeysByGroups[key], yLabels, textMeasurer)), 0);\n const maxXGroupLabelSize = getMaxTextLength(xGroupKeys, xGroupLabels, textMeasurer);\n const maxYGroupLabelSize = getMaxTextLength(yGroupKeys, yGroupLabels, textMeasurer);\n const { xCaptionTail, yCaptionTail } = calculateCaptionTails(\n this.labelAngles,\n facetSettings,\n this.scales,\n this.step,\n groupedCells,\n textMeasurer\n );\n this.captionsSizes = {\n xCaptionTail,\n yCaptionTail,\n xGroupCaptions: getCaptionHeight(maxXGroupLabelSize, this.labelAngles.xGroupLabels),\n yGroupCaptions: getCaptionHeight(maxYGroupLabelSize, this.labelAngles.yGroupLabels),\n xAxisCaptions: getCaptionHeight(maxXLabelSize, this.labelAngles.xAxisLabels),\n yAxisCaptions: getCaptionHeight(maxYLabelSize, this.labelAngles.yAxisLabels),\n };\n }\n\n updateChartDimensions(\n size: HeatmapSettingsImpl['chartSettings']['size'],\n facetKeys: string[],\n xGroupKeys: string[],\n yGroupKeys: string[],\n facetSettings: HeatmapSettingsImpl['facetSettings'],\n xAxis: HeatmapSettingsImpl['chartSettings']['xAxis'],\n yAxis: HeatmapSettingsImpl['chartSettings']['yAxis'],\n annotations: HeatmapSettingsImpl['annotations'],\n dendrogramX: HeatmapSettingsImpl['dendrogramX'],\n dendrogramY: HeatmapSettingsImpl['dendrogramY']\n ) {\n const facetCount = facetKeys.length;\n const maxNRows = Math.min(facetSettings.nRows ?? facetCount, facetCount);\n const maxNCols = Math.min(facetSettings.nCols ?? facetCount, facetCount);\n // Use columns/rows count from settings if some of them defined, else make 1 column\n this.columnsCount = facetSettings.nRows ? Math.ceil(facetCount / maxNRows) : maxNCols;\n this.rowsCount = Math.ceil(facetCount / this.columnsCount);\n const { sharedX, sharedY } = facetSettings;\n\n this.chartsDimensions = {};\n\n let currentLeft = 0;\n let currentTop = 0;\n facetKeys.forEach((key, index) => {\n const currentColumn = (index % this.columnsCount) + 1;\n const chartSides = getChartEdgeSides(index, facetKeys.length, this.columnsCount, this.rowsCount);\n const stepX = this.step.x[key];\n const stepY = this.step.y[key];\n const sideElementSizes = calculateChartSideElementSizes(\n xAxis,\n yAxis,\n this.captionsSizes,\n annotations,\n dendrogramX,\n dendrogramY,\n chartSides,\n sharedX,\n sharedY,\n facetKeys,\n xGroupKeys,\n yGroupKeys,\n stepX,\n stepY\n );\n const annotationsTitleSizes = calculateAnnotationTitleSizes(annotations, chartSides, sharedX, sharedY);\n function getPadding(side: 'left' | 'right' | 'top' | 'bottom') {\n return Math.max(\n CHART_SIDE_ELEMENTS[side].reduce((res, el) => res + sideElementSizes[side][el], 0),\n annotationsTitleSizes[side],\n size.innerOffset\n );\n }\n const padding = {\n left: getPadding('left'),\n right: getPadding('right'),\n top: getPadding('top'),\n bottom: getPadding('bottom'),\n };\n if (padding.left < this.captionsSizes.xCaptionTail) {\n padding.left = this.captionsSizes.xCaptionTail;\n }\n if (padding.bottom < this.captionsSizes.yCaptionTail) {\n padding.bottom = this.captionsSizes.yCaptionTail;\n }\n const sideElementBBoxes = calculateSideElementsBBoxes(sideElementSizes, this.chartSizes.chartWidth, this.chartSizes.chartHeight);\n const outerWidth = this.chartSizes.chartWidth + padding.left + padding.right;\n const outerHeight = this.chartSizes.chartHeight + padding.top + padding.bottom;\n this.chartsDimensions[key] = {\n left: currentLeft,\n top: currentTop,\n inner: { width: this.chartSizes.chartWidth, height: this.chartSizes.chartHeight },\n outer: { width: outerWidth, height: outerHeight },\n padding,\n sideElementBBoxes,\n chartEdgeSides: chartSides,\n };\n currentLeft += outerWidth;\n if (currentColumn === this.columnsCount) {\n currentLeft = 0;\n currentTop += outerHeight;\n }\n });\n\n // sum of widths of first row\n const chartsWidth = facetKeys\n .slice(0, this.columnsCount)\n .reduce((sum, key) => sum + this.chartsDimensions[key].outer.width, 0);\n // sum of heights of first column\n const chartsHeight = facetKeys\n .filter((_key, index) => index % this.columnsCount === 0)\n .reduce((sum, key) => sum + this.chartsDimensions[key].outer.height, 0);\n this.chartSizes.chartsWidth = chartsWidth;\n this.chartSizes.chartsHeight = chartsHeight;\n }\n\n updateChartsSizes(\n size: HeatmapSettingsImpl['chartSettings']['size'],\n groupedCells: GroupedCellsHeatmap,\n groupGap: number,\n ) {\n const { width, height, cellWidth, cellHeight } = size;\n const firstFacet = groupedCells.meta.facetKeys[0];\n if (cellWidth && firstFacet) {\n const keysCount = groupedCells.facets[firstFacet].xKeys.length;\n const nonEmptyXGroupsCount = groupedCells.meta.xGroupKeys.filter(\n k => (groupedCells.facets[firstFacet]?.xKeysByGroups[k]?.length ?? 0) > 0\n ).length;\n this.chartSizes.chartWidth = keysCount * cellWidth + groupGap * (nonEmptyXGroupsCount - 1);\n } else {\n this.chartSizes.chartWidth = width;\n }\n\n if (cellHeight && firstFacet) {\n const keysCount = groupedCells.facets[firstFacet].yKeys.length;\n const nonEmptyYGroupsCount = groupedCells.meta.yGroupKeys.filter(\n k => (groupedCells.facets[firstFacet]?.yKeysByGroups[k]?.length ?? 0) > 0\n ).length;\n this.chartSizes.chartHeight = keysCount * cellHeight + groupGap * (nonEmptyYGroupsCount - 1);\n } else {\n this.chartSizes.chartHeight = height;\n }\n }\n\n // update scales for cell positions, x and y for each facet.\n // Keys arrive pre-sorted from fillCellsData (and re-ordered by getDendrograms for clustered axes).\n updateScales(\n facetKeys: string[],\n groupedCells: GroupedCellsHeatmap,\n groupGap: number,\n facetSettings: HeatmapSettingsImpl['facetSettings'],\n size: HeatmapSettingsImpl['chartSettings']['size'],\n ) {\n const { width, height, cellWidth, cellHeight } = size;\n const { meta, facets } = groupedCells;\n const { sharedX, sharedY } = facetSettings;\n // All sorting is done upstream in fillCellsData; keys arrive already ordered.\n facetKeys.forEach(facetKey => {\n const facetGroup = facets[facetKey];\n const xGroupKeys = meta.xGroupKeys;\n const yGroupKeys = meta.yGroupKeys;\n const { xKeysByGroups } = sharedX ? meta : facetGroup;\n const { yKeysByGroups } = sharedY ? meta : facetGroup;\n // for shared facets max cells counts in group should be used\n const xCounts = xGroupKeys.map(xGroupKey => xKeysByGroups[xGroupKey].length);\n const yCounts = yGroupKeys.map(yGroupKey => yKeysByGroups[yGroupKey].length);\n const xCellsCount = xCounts.reduce((sum, count) => sum + count, 0);\n const yCellsCount = yCounts.reduce((sum, count) => sum + count, 0);\n const xStep = cellWidth ? cellWidth : (width - (xCounts.filter(count => count > 0).length - 1) * groupGap) / xCellsCount;\n const yStep = cellHeight ? cellHeight : (height - (yCounts.filter(count => count > 0).length - 1) * groupGap) / yCellsCount;\n\n const xPositions: number[] = [];\n let xKeys: string[] = [];\n let currentX = 0;\n const resolvedXGroups = xGroupKeys.map(xKey => xKeysByGroups[xKey]);\n resolvedXGroups.forEach((axisKeys, idx) => {\n xKeys = xKeys.concat(axisKeys);\n axisKeys.forEach(() => {\n xPositions.push(currentX);\n currentX += xStep;\n });\n // add gap only if a non-empty group follows (skip trailing gap after last visible group)\n const hasMoreNonEmpty = resolvedXGroups.slice(idx + 1).some(keys => keys.length > 0);\n if (axisKeys.length > 0 && hasMoreNonEmpty) {\n currentX += groupGap;\n }\n });\n\n const yPositions: number[] = [];\n let yKeys: string[] = [];\n let currentY = 0;\n const resolvedYGroups = yGroupKeys.map(yKey => yKeysByGroups[yKey]);\n resolvedYGroups.forEach((axisKeys, idx) => {\n yKeys = yKeys.concat(axisKeys);\n axisKeys.forEach(() => {\n yPositions.push(currentY);\n currentY += yStep;\n });\n // add gap only if a non-empty group follows (skip trailing gap after last visible group)\n const hasMoreNonEmpty = resolvedYGroups.slice(idx + 1).some(keys => keys.length > 0);\n if (axisKeys.length > 0 && hasMoreNonEmpty) {\n currentY += groupGap;\n }\n });\n\n this.scales.x[facetKey] = scaleOrdinal<string, number>().domain(xKeys).range(xPositions);\n this.scales.y[facetKey] = scaleOrdinal<string, number>().domain(yKeys).range(yPositions);\n this.step.x[facetKey] = xStep;\n this.step.y[facetKey] = yStep;\n });\n }\n\n updateAesScale(\n valueType: 'discrete' | 'continuous',\n valueExtent: [number, number],\n aes: HeatmapSettingsImpl['aes'],\n annotations: HeatmapSettingsImpl['annotations'],\n groupedCellsData: GroupedCellsHeatmap,\n cellUniqValues: DataValue[],\n normalization: HeatmapSettingsImpl['normalization']\n ) {\n if (valueType === 'continuous') {\n if (aes.valueColors) {\n this.colorScale = scaleLinear<string, string>()\n .domain(aes.valuesByColors ?? getContinuousColorRange(normalization, aes.valueColors.length, valueExtent))\n .range(aes.valueColors);\n } else if (aes.colorsList) {\n this.colorScale = scaleLinear<string, string>()\n .domain(getContinuousColorRange(normalization, aes.colorsList.length, valueExtent))\n .range(aes.colorsList);\n }\n } else {\n if (aes.colorsMap) {\n const valueKeys = Object.entries(aes.colorsMap);\n this.colorScale = scaleOrdinal<string, string>()\n .domain(valueKeys.map(v => v[0]))\n .range(valueKeys.map(v => v[1]))\n .unknown('#ccc');\n } else if (aes.colorsList) {\n this.colorScale = createDiscreteColorScale(aes.colorsList, cellUniqValues.map(String));\n }\n }\n\n const { xDataByKeys, yDataByKeys } = groupedCellsData.meta;\n annotations.forEach(item => {\n const { colors, type, axis, valueColumn } = item;\n const data = (axis === 'x' ? xDataByKeys : yDataByKeys)[valueColumn.valueLabels ?? valueColumn.value];\n if (type === 'discrete') {\n const discreteValues = lodash.uniq(Object.values(data).map(String)).sort();\n this.annotationColorScales[item.id] = {\n type: 'discrete',\n scale: createDiscreteRoundColorScale(colors, discreteValues),\n };\n } else {\n const values = Object.values(data).map(Number);\n if (!values.length) {\n return;\n }\n const [min = values[0], max = values[0]] = extent(values);\n this.annotationColorScales[item.id] = {\n type: 'continuous',\n scale: createContinuousColorScale(colors, min, max, 0, 0.5, 1),\n };\n }\n });\n }\n\n updateDendrogram(\n facetKeys: string[],\n xGroupKeys: string[],\n yGroupKeys: string[],\n groups: GroupedCellsHeatmap['facets'],\n dendrogramsData: DendrogramsData,\n dendrogramX: HeatmapSettingsImpl['dendrogramX'],\n dendrogramY: HeatmapSettingsImpl['dendrogramY']\n ) {\n facetKeys.forEach(facetKey => {\n this.dendrograms[facetKey] = { x: { treesByGroupKey: {}, data: dendrogramX }, y: { treesByGroupKey: {}, data: dendrogramY } };\n const { xKeysByGroups, yKeysByGroups } = groups[facetKey];\n if (dendrogramX) {\n const { hierarchyByGroupX } = dendrogramsData[facetKey];\n const maxHeightX = xGroupKeys.reduce((res, xKey) => Math.max(res, hierarchyByGroupX[xKey]?.data.height ?? 0), 0);\n this.dendrograms[facetKey].x.treesByGroupKey = xGroupKeys.reduce((res, groupKey) => {\n const hierarchy = hierarchyByGroupX[groupKey];\n if (!hierarchy) return res;\n const xKeys = xKeysByGroups[groupKey];\n cluster()\n .separation(() => 1)\n .size([hierarchy.leaves().length * this.step.x[facetKey], dendrogramX.size])(\n hierarchy as HierarchyNode<unknown>\n );\n const root = hierarchy as HierarchyPointNode<Cluster>;\n const heightScale = scaleLinear()\n .domain(dendrogramX.position === 'top' ? [0, maxHeightX] : [maxHeightX, 0])\n .range([dendrogramX.size, 0]);\n updateLinksHeight(root, heightScale, 'y');\n addShiftToLinkCoord(root, this.scales.x[facetKey](xKeys[0]), 'x');\n res[groupKey] = root;\n return res;\n }, {} as Record<string, HierarchyPointNode<Cluster>>);\n this.dendrograms[facetKey].x.data = dendrogramX;\n }\n if (dendrogramY) {\n const { hierarchyByGroupY } = dendrogramsData[facetKey];\n const maxHeightY = yGroupKeys.reduce((res, yKey) => Math.max(res, hierarchyByGroupY[yKey]?.data.height ?? 0), 0);\n this.dendrograms[facetKey].y.treesByGroupKey = yGroupKeys.reduce((res, groupKey) => {\n const hierarchy = hierarchyByGroupY[groupKey];\n if (!hierarchy) return res;\n const yKeys = yKeysByGroups[groupKey];\n cluster()\n .separation(() => 1)\n .size([hierarchy.leaves().length * this.step.y[facetKey], dendrogramY.size])(\n hierarchy as HierarchyNode<unknown>\n );\n const root = hierarchy as HierarchyPointNode<Cluster>;\n const heightScale = scaleLinear()\n .domain(dendrogramY.position === 'left' ? [0, maxHeightY] : [maxHeightY, 0])\n .range([dendrogramY.size, 0]);\n addShiftToLinkCoord(root, this.scales.y[facetKey](yKeys[0]), 'x', 'y');\n updateLinksHeight(root, heightScale, 'x');\n res[groupKey] = root;\n return res;\n }, {} as Record<string, HierarchyPointNode<Cluster>>);\n this.dendrograms[facetKey].y.data = dendrogramY;\n }\n });\n }\n\n updateDendrogramAesScales(inheritedAes: HeatmapSettingsImpl['inheritedDendrogramAes']) {\n if (!inheritedAes) {\n return;\n }\n const usedColumns = Object.keys(inheritedAes);\n this.dendrogramAesScales = usedColumns.reduce((res: DendrogramAesScales, columnName) => {\n const aesMap = inheritedAes[columnName];\n const columnValues: string[] = Object.keys(aesMap);\n res[columnName] = scaleOrdinal<string, AesItem, AesItem>()\n .domain(columnValues)\n .range(\n columnValues.map(value => ({\n ...DEFAULT_AES,\n ...aesMap[value],\n }))\n )\n .unknown(DEFAULT_AES);\n return res;\n }, {});\n }\n\n render(\n dataFrame: DataFrame,\n settingsId: string,\n chartSettings: HeatmapSettingsImpl['chartSettings'],\n facetSettings: HeatmapSettingsImpl['facetSettings'],\n aes: HeatmapSettingsImpl['aes'],\n groupedCellsData: GroupedCellsHeatmap,\n annotations: HeatmapSettingsImpl['annotations'],\n valueColumn: ColumnName,\n dendrogramX: HeatmapSettingsImpl['dendrogramX'],\n dendrogramY: HeatmapSettingsImpl['dendrogramY'],\n dendrogramsData: DendrogramsData,\n inheritedDendrogramAes: HeatmapSettingsImpl['inheritedDendrogramAes'],\n cellUniqValues: DataValue[],\n normalization: HeatmapSettingsImpl['normalization'],\n onTooltipHintSwitch: (v: boolean) => void,\n cellsRenderingMode: 'canvas' | 'svg'\n ) {\n const { meta, facets } = groupedCellsData;\n const { facetKeys, xGroupKeys, yGroupKeys, valueExtent } = meta;\n const { xAxis, yAxis, title, size, valueType } = chartSettings;\n this.updateChartsSizes(size, groupedCellsData, aes.groupGap);\n this.updateAesScale(valueType, valueExtent.dataSource, aes, annotations, groupedCellsData, cellUniqValues, normalization);\n this.updateScales(facetKeys, groupedCellsData, aes.groupGap, facetSettings, size);\n // caption sizes are needed for chart paddings in chart dimensions\n this.updateCaptionsSize(groupedCellsData, xAxis, yAxis, facetSettings);\n this.updateChartDimensions(\n size,\n facetKeys,\n xGroupKeys,\n yGroupKeys,\n facetSettings,\n xAxis,\n yAxis,\n annotations,\n dendrogramX,\n dendrogramY\n );\n this.updateLegendSize(valueType, chartSettings.legend, annotations, valueColumn, valueExtent.dataSource);\n this.updateMargins(title, size);\n this.updateDendrogram(facetKeys, xGroupKeys, yGroupKeys, facets, dendrogramsData, dendrogramX, dendrogramY);\n this.updateDendrogramAesScales(inheritedDendrogramAes);\n const component = (\n <DataFrameProvider dataFrame={dataFrame}>\n <ChartsGroup\n aes={aes}\n annotations={annotations}\n annotationColorScales={this.annotationColorScales}\n captionsSizes={this.captionsSizes}\n cellsMeta={meta}\n columnsCount={this.columnsCount}\n chartsDimensions={this.chartsDimensions}\n chartSettings={chartSettings}\n chartSizes={this.chartSizes}\n colorScale={this.colorScale as (v: unknown) => string}\n dendrogramAesScales={this.dendrogramAesScales}\n dendrograms={this.dendrograms}\n facetKeys={facetKeys}\n facetSettings={facetSettings}\n groupedCells={facets}\n labelAngles={this.labelAngles}\n legend={this.legend}\n margins={this.margins}\n scales={this.scales}\n settingsId={settingsId}\n step={this.step}\n xGroupKeys={xGroupKeys}\n yGroupKeys={yGroupKeys}\n onTooltipHintSwitch={onTooltipHintSwitch}\n cellsRenderingMode={cellsRenderingMode}\n />\n </DataFrameProvider>\n );\n this.component = component;\n this.reactRoot?.render(component);\n }\n\n renderError(message: string) {\n this.reactRoot?.render(<Error message={message} />);\n }\n}\n\nexport default ChartRenderer;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8CA,IAAM,IAAW,KAAK,IAAI,KAAK,KAAK,EAAE,EAChC,IAAiB;AACvB,SAAS,EAAkB,GAAmC,GAA8B,GAAkB;CAC1G,SAAS,EAAU,GAAgC;AAE/C,EADA,EAAE,KAAS,EAAM,EAAE,KAAK,OAAO,EAC3B,EAAE,YAAU,EAAE,SAAS,QAAQ,EAAU;;AAEjD,GAAU,EAAK;;AAInB,SAAS,EAC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AAW,EAAc,QAAQ,GAAa,GAAa,EAAY,WAAW,EACxG,KAAK,cAAc,GAAO,EAAK,EAC/B,KAAK,iBAAiB,GAAW,GAAY,GAAY,GAAQ,GAAiB,GAAa,EAAY,EAC3G,KAAK,0BAA0B,EAAuB;EACtD,IAAM,IACF,kBAAC,GAAD;GAA8B;aAC1B,kBAAC,GAAD;IACS;IACQ;IACb,uBAAuB,KAAK;IAC5B,eAAe,KAAK;IACpB,WAAW;IACX,cAAc,KAAK;IACnB,kBAAkB,KAAK;IACR;IACf,YAAY,KAAK;IACjB,YAAY,KAAK;IACjB,qBAAqB,KAAK;IAC1B,aAAa,KAAK;IACP;IACI;IACf,cAAc;IACd,aAAa,KAAK;IAClB,QAAQ,KAAK;IACb,SAAS,KAAK;IACd,QAAQ,KAAK;IACD;IACZ,MAAM,KAAK;IACC;IACA;IACS;IACD;IACtB,CAAA;GACc,CAAA;AAGxB,EADA,KAAK,YAAY,GACjB,KAAK,WAAW,OAAO,EAAU;;CAGrC,YAAY,GAAiB;AACzB,OAAK,WAAW,OAAO,kBAAC,GAAD,EAAgB,YAAW,CAAA,CAAC"}
1
+ {"version":3,"file":"ChartRenderer.js","names":[],"sources":["../../src/heatmap/ChartRenderer.tsx"],"sourcesContent":["import { extent } from 'd3-array';\nimport type { HierarchyNode, HierarchyPointNode } from 'd3-hierarchy';\nimport { cluster } from 'd3-hierarchy';\nimport type { ScaleLinear, ScaleOrdinal } from 'd3-scale';\nimport { scaleLinear, scaleOrdinal } from 'd3-scale';\nimport lodash from 'lodash';\nimport type { ReactElement } from 'react';\nimport type { Root } from 'react-dom/client';\nimport { createRoot } from 'react-dom/client';\nimport { Error } from '../common/Error';\nimport type { LegendData, LegendItem } from '../common/types';\nimport { DataFrameProvider } from '../common/useDataFrame';\nimport { DEFAULT_HEIGHT, DEFAULT_WIDTH, MAX_LEGEND_GRADIENT_HEIGHT, MIN_LEGEND_GRADIENT_HEIGHT, TITLE_LINE_HEIGHT, TITLE_MARGIN } from '../constants';\nimport type { DataFrame } from '../DataFrame';\nimport type { AesItem, ColumnName, DataValue } from '../types';\nimport { arrangeLegendParts } from '../utils/arrangeLegendParts';\nimport { computeChartInnerSize } from '../utils/computeChartInnerSize';\nimport { getChartEdgeSides } from '../utils/getChartEdgeSides';\nimport { getContinuousLegendTicks } from '../utils/getContinuousLegendTicks';\nimport { TextMeasurer } from '../utils/TextMeasurer/TextMeasurer';\nimport { ChartsGroup } from './components/ChartsGroup';\nimport type {\n AnnotationColorScales,\n CaptionsSizes,\n ChartDendrograms,\n ChartDimensionsData,\n ChartSizes,\n ChartsScales,\n Cluster,\n DendrogramAesScales,\n LabelAngles,\n Margins,\n} from './components/types';\nimport { CHART_SIDE_ELEMENTS, DEFAULT_AES, LEGEND_OFFSET, MIN_MARGIN, TITLE_LINE } from './constants';\nimport type { GroupedCellsHeatmap } from './getCells';\nimport type { DendrogramsData } from './getDendrograms';\nimport type { HeatmapSettingsImpl } from './HeatmapSettingsImpl';\nimport {\n calculateAnnotationTitleSizes,\n calculateChartSideElementSizes,\n calculateSideElementsBBoxes,\n createContinuousColorScale,\n createDiscreteColorScale,\n createDiscreteRoundColorScale,\n} from './utils';\nimport { calculateCaptionTails } from './utils/calculateCaptionTails';\n\nconst COS_PI_4 = Math.cos(Math.PI / 4);\nconst INCLINE_OFFSET = 5; // height of little triangle of text for captions inclined 45deg\nfunction updateLinksHeight(root: HierarchyPointNode<Cluster>, scale: (v: number) => number, coord: 'x' | 'y') {\n function setHeight(d: HierarchyPointNode<Cluster>) {\n d[coord] = scale(d.data.height);\n if (d.children) d.children.forEach(setHeight);\n }\n setHeight(root);\n}\n\n// add shift to move nodes positions with group gaps\nfunction addShiftToLinkCoord(\n root: HierarchyPointNode<Cluster>,\n shift: number,\n coordFrom: 'x' | 'y',\n coordTo = coordFrom\n) {\n function setX(d: HierarchyPointNode<Cluster>) {\n d[coordTo] = d[coordFrom] + shift;\n if (d.children) d.children.forEach(setX);\n }\n setX(root);\n}\n\nconst getSteps = (count: number, valueExtent: number[]) => {\n const min = Math.min(...valueExtent);\n const max = Math.max(...valueExtent);\n if (min === max) {\n const steps = count % 2 === 0 ? [] : [min];\n for (let i = 1; i < count / 2 + 1; i++) {\n steps.push(min + i);\n steps.unshift(min - i);\n }\n return steps;\n }\n if (count < 2) {\n return [min, max];\n }\n const step = (max - min) / (count - 1);\n const steps = [];\n for (let i = 0; i < count - 1; i++) {\n steps.push(min + step * i);\n }\n steps.push(max);\n return steps;\n};\n\nfunction getContinuousColorRange(normalization: HeatmapSettingsImpl['normalization'], colorsCount: number, valueExtent: number[]) {\n let extent = valueExtent;\n if (normalization) {\n if (normalization.colorRange) {\n extent = normalization.colorRange;\n }\n if (normalization.method === 'standardScaling') {\n extent = [-2, 2];\n }\n if (normalization.method === 'meanNormalization') {\n extent = [-0.75, 0.75];\n }\n }\n return getSteps(colorsCount, extent);\n}\n\nfunction getMaxTextLength(keys: string[], labels: Record<string, string>, textMeasurer: TextMeasurer) {\n let maxLabelSize = 0;\n for (const key of keys) {\n if (labels[key] === undefined) continue;\n const l = textMeasurer.getTextWidth(labels[key]);\n if (l > maxLabelSize) maxLabelSize = l;\n }\n return maxLabelSize;\n}\n\nfunction getCaptionHeight(size: number, angle: number) {\n if (angle === 90) {\n return size;\n }\n if (angle === 45) {\n return size * COS_PI_4 + (size > 0 ? 2 * INCLINE_OFFSET : 0);\n }\n return TITLE_LINE;\n}\n\nclass ChartRenderer {\n reactRoot: Root | null = null;\n parentNode: HTMLElement | null = null;\n rootNode: HTMLElement | null = null;\n component: ReactElement = (<></>);\n chartsDimensions: Record<string, ChartDimensionsData> = {};\n chartSizes: ChartSizes = {\n chartWidth: DEFAULT_WIDTH, // width of single chart\n chartHeight: DEFAULT_HEIGHT, // height of single chart\n chartsWidth: DEFAULT_WIDTH, // width of all charts in charts row\n chartsHeight: DEFAULT_HEIGHT, // width of all charts in charts column, without axes\n totalWidth: DEFAULT_WIDTH, // width of all charts in charts row, plus left axis, plus legend\n totalHeight: DEFAULT_HEIGHT, // width of all charts in charts height, plus bottom axis, plus top title\n };\n margins: Margins = {\n top: MIN_MARGIN,\n bottom: MIN_MARGIN,\n left: MIN_MARGIN,\n right: MIN_MARGIN,\n };\n captionsSizes: CaptionsSizes = {\n xAxisCaptions: 100,\n yAxisCaptions: 100,\n xGroupCaptions: TITLE_LINE,\n yGroupCaptions: TITLE_LINE,\n xCaptionTail: 0,\n yCaptionTail: 0,\n };\n labelAngles: LabelAngles = {\n xAxisLabels: 0,\n yAxisLabels: 0,\n xGroupLabels: 0,\n yGroupLabels: 0,\n };\n columnsCount = 1;\n rowsCount = 1;\n scales: ChartsScales = {\n // scales grouped by facet\n x: { null: scaleOrdinal<string, number>().domain(['null']).range([1]) },\n y: { null: scaleOrdinal<string, number>().domain(['null']).range([1]) },\n };\n step: {\n x: Record<string, number>;\n y: Record<string, number>;\n } = { x: {}, y: {} };\n colorScale: ScaleLinear<string, string> | ScaleOrdinal<string, string, string> = scaleLinear<string, string>()\n .domain([0, 1])\n .range(['white', 'black']);\n annotationColorScales: AnnotationColorScales = {};\n dendrogramAesScales: DendrogramAesScales = {};\n legend: LegendData = {\n width: 0,\n height: 0,\n items: [],\n };\n dendrograms: Record<string, ChartDendrograms> = {};\n\n clear() {\n if (this.parentNode && this.rootNode) {\n this.parentNode?.removeChild(this.rootNode);\n this.parentNode = null;\n this.rootNode = null;\n }\n // timeout to avoid trying to unmount during rendering\n setTimeout(() => {\n this.reactRoot?.unmount();\n this.reactRoot = null;\n });\n }\n\n init(node: HTMLElement) {\n if (this.parentNode === null) {\n this.parentNode = node;\n this.rootNode = document.createElement('div');\n this.parentNode.appendChild(this.rootNode);\n this.reactRoot = createRoot(this.rootNode);\n }\n }\n\n updateMargins(title: HeatmapSettingsImpl['chartSettings']['title'], size: HeatmapSettingsImpl['chartSettings']['size']) {\n this.margins = {\n top: title.show ? TITLE_LINE_HEIGHT + TITLE_MARGIN * 2 : size.outerOffset,\n bottom: size.outerOffset,\n left: size.outerOffset,\n right: this.legend.width + size.outerOffset,\n };\n this.chartSizes.totalWidth = this.margins.left + this.chartSizes.chartsWidth + this.margins.right;\n this.chartSizes.totalHeight =\n this.margins.top + Math.max(this.chartSizes.chartsHeight + this.margins.bottom, this.legend.height);\n }\n\n updateLegendSize(\n valueType: HeatmapSettingsImpl['chartSettings']['valueType'],\n legend: HeatmapSettingsImpl['chartSettings']['legend'],\n annotations: HeatmapSettingsImpl['annotations'],\n columnValue: ColumnName,\n valueExtent: [number, number]\n ) {\n if (!legend.show) {\n this.legend = { width: 0, height: 0, items: [] };\n return;\n }\n const continuousHeight = Math.min(\n Math.max(this.chartSizes.chartHeight, MIN_LEGEND_GRADIENT_HEIGHT),\n MAX_LEGEND_GRADIENT_HEIGHT\n );\n const legendHeight = Math.max(this.chartSizes.chartHeight, continuousHeight);\n const legendItems: LegendItem[] = [];\n const emptySizes = { width: 0, height: 0, left: 0, top: 0 };\n\n const getDefaultLabels = (values: (string | number)[]) => values.reduce((res: Record<string, string>, v: string | number) => { res[v] = String(v); return res; }, {});\n if (valueType === 'continuous') {\n const scale = this.colorScale as ScaleLinear<string, string>;\n const values = getContinuousLegendTicks(scale, valueExtent);\n const tickPositionScale = scaleLinear([values[0], values[values.length - 1]], [continuousHeight, 0]); //TODO: update during adding log scale for heatmap\n const title = columnValue.label ?? columnValue.value;\n legendItems.push({\n ...emptySizes,\n type: 'continuous',\n id: 'heatmapValue',\n scale,\n values,\n title,\n tickPositionScale\n });\n } else if (valueType === 'discrete') {\n const scale = this.colorScale as ScaleOrdinal<string, string>;\n const title = columnValue.label ?? columnValue.value;\n const values = scale.domain();\n const labels = getDefaultLabels(values);\n\n legendItems.push({ ...emptySizes, type: 'discreteColor', id: 'heatmapValue', title, scale, values, labels });\n }\n annotations.forEach(item => {\n const title = item.valueColumn.label ?? item.valueColumn.value;\n if (item.type === 'continuous') {\n const scale = this.annotationColorScales[item.id].scale as ScaleLinear<string, string>;\n const values = getContinuousLegendTicks(scale, valueExtent);\n const tickPositionScale = scaleLinear([values[0], values[values.length - 1]], [continuousHeight, 0]); //TODO: update during adding log scale for heatmap\n\n legendItems.push({ ...emptySizes, type: 'continuous', id: item.id, tickPositionScale, title, scale, values });\n }\n if (item.type === 'discrete') {\n const scale = this.annotationColorScales[item.id].scale as ScaleOrdinal<string, string>;\n const values = scale.domain();\n const labels = getDefaultLabels(values);\n\n legendItems.push({ ...emptySizes, type: 'discreteColor', id: item.id, title, scale, values, labels });\n }\n });\n\n if (!legendItems.length) {\n this.legend = { width: 0, height: 0, items: [] };\n return;\n }\n\n const items = arrangeLegendParts(legendItems, this.chartSizes.chartHeight,continuousHeight);\n const maxRightEdge = items.reduce((max, item) => Math.max(max, item.left + item.width), 0);\n\n const legendWidth = maxRightEdge + LEGEND_OFFSET;\n\n this.legend = {\n width: legendWidth,\n height: legendHeight,\n items\n };\n }\n\n updateCaptionsSize(\n groupedCells: GroupedCellsHeatmap,\n xAxis: HeatmapSettingsImpl['chartSettings']['xAxis'],\n yAxis: HeatmapSettingsImpl['chartSettings']['yAxis'],\n facetSettings: HeatmapSettingsImpl['facetSettings']\n ) {\n const textMeasurer = new TextMeasurer('bold 16px Manrope');\n const { xGroupKeys, yGroupKeys, xGroupLabels, yGroupLabels, xKeysByGroups, yKeysByGroups, xLabels, yLabels } = groupedCells.meta;\n this.labelAngles = {\n xAxisLabels: xAxis.axisLabelsAngle,\n yAxisLabels: yAxis.axisLabelsAngle,\n xGroupLabels: xAxis.groupLabelsAngle,\n yGroupLabels: yAxis.groupLabelsAngle,\n };\n\n const maxXLabelSize = xGroupKeys.reduce((res, key) => Math.max(res, getMaxTextLength(xKeysByGroups[key], xLabels, textMeasurer)), 0);\n const maxYLabelSize = yGroupKeys.reduce((res, key) => Math.max(res, getMaxTextLength(yKeysByGroups[key], yLabels, textMeasurer)), 0);\n const maxXGroupLabelSize = getMaxTextLength(xGroupKeys, xGroupLabels, textMeasurer);\n const maxYGroupLabelSize = getMaxTextLength(yGroupKeys, yGroupLabels, textMeasurer);\n const { xCaptionTail, yCaptionTail } = calculateCaptionTails(\n this.labelAngles,\n facetSettings,\n this.scales,\n this.step,\n groupedCells,\n textMeasurer\n );\n this.captionsSizes = {\n xCaptionTail,\n yCaptionTail,\n xGroupCaptions: getCaptionHeight(maxXGroupLabelSize, this.labelAngles.xGroupLabels),\n yGroupCaptions: getCaptionHeight(maxYGroupLabelSize, this.labelAngles.yGroupLabels),\n xAxisCaptions: getCaptionHeight(maxXLabelSize, this.labelAngles.xAxisLabels),\n yAxisCaptions: getCaptionHeight(maxYLabelSize, this.labelAngles.yAxisLabels),\n };\n }\n\n updateChartDimensions(\n size: HeatmapSettingsImpl['chartSettings']['size'],\n facetKeys: string[],\n xGroupKeys: string[],\n yGroupKeys: string[],\n facetSettings: HeatmapSettingsImpl['facetSettings'],\n xAxis: HeatmapSettingsImpl['chartSettings']['xAxis'],\n yAxis: HeatmapSettingsImpl['chartSettings']['yAxis'],\n annotations: HeatmapSettingsImpl['annotations'],\n dendrogramX: HeatmapSettingsImpl['dendrogramX'],\n dendrogramY: HeatmapSettingsImpl['dendrogramY']\n ) {\n const facetCount = facetKeys.length;\n const maxNRows = Math.min(facetSettings.nRows ?? facetCount, facetCount);\n const maxNCols = Math.min(facetSettings.nCols ?? facetCount, facetCount);\n // Use columns/rows count from settings if some of them defined, else make 1 column\n this.columnsCount = facetSettings.nRows ? Math.ceil(facetCount / maxNRows) : maxNCols;\n this.rowsCount = Math.ceil(facetCount / this.columnsCount);\n const { sharedX, sharedY } = facetSettings;\n\n this.chartsDimensions = {};\n\n let currentLeft = 0;\n let currentTop = 0;\n facetKeys.forEach((key, index) => {\n const currentColumn = (index % this.columnsCount) + 1;\n const chartSides = getChartEdgeSides(index, facetKeys.length, this.columnsCount, this.rowsCount);\n const stepX = this.step.x[key];\n const stepY = this.step.y[key];\n const sideElementSizes = calculateChartSideElementSizes(\n xAxis,\n yAxis,\n this.captionsSizes,\n annotations,\n dendrogramX,\n dendrogramY,\n chartSides,\n sharedX,\n sharedY,\n facetKeys,\n xGroupKeys,\n yGroupKeys,\n stepX,\n stepY\n );\n const annotationsTitleSizes = calculateAnnotationTitleSizes(annotations, chartSides, sharedX, sharedY);\n function getPadding(side: 'left' | 'right' | 'top' | 'bottom') {\n return Math.max(\n CHART_SIDE_ELEMENTS[side].reduce((res, el) => res + sideElementSizes[side][el], 0),\n annotationsTitleSizes[side],\n size.innerOffset\n );\n }\n const padding = {\n left: getPadding('left'),\n right: getPadding('right'),\n top: getPadding('top'),\n bottom: getPadding('bottom'),\n };\n if (padding.left < this.captionsSizes.xCaptionTail) {\n padding.left = this.captionsSizes.xCaptionTail;\n }\n if (padding.bottom < this.captionsSizes.yCaptionTail) {\n padding.bottom = this.captionsSizes.yCaptionTail;\n }\n const sideElementBBoxes = calculateSideElementsBBoxes(sideElementSizes, this.chartSizes.chartWidth, this.chartSizes.chartHeight);\n const outerWidth = this.chartSizes.chartWidth + padding.left + padding.right;\n const outerHeight = this.chartSizes.chartHeight + padding.top + padding.bottom;\n this.chartsDimensions[key] = {\n left: currentLeft,\n top: currentTop,\n inner: { width: this.chartSizes.chartWidth, height: this.chartSizes.chartHeight },\n outer: { width: outerWidth, height: outerHeight },\n padding,\n sideElementBBoxes,\n chartEdgeSides: chartSides,\n };\n currentLeft += outerWidth;\n if (currentColumn === this.columnsCount) {\n currentLeft = 0;\n currentTop += outerHeight;\n }\n });\n\n // sum of widths of first row\n const chartsWidth = facetKeys\n .slice(0, this.columnsCount)\n .reduce((sum, key) => sum + this.chartsDimensions[key].outer.width, 0);\n // sum of heights of first column\n const chartsHeight = facetKeys\n .filter((_key, index) => index % this.columnsCount === 0)\n .reduce((sum, key) => sum + this.chartsDimensions[key].outer.height, 0);\n this.chartSizes.chartsWidth = chartsWidth;\n this.chartSizes.chartsHeight = chartsHeight;\n }\n\n updateChartsSizes(\n size: HeatmapSettingsImpl['chartSettings']['size'],\n groupedCells: GroupedCellsHeatmap,\n groupGap: number,\n ) {\n const { chartWidth, chartHeight } = computeChartInnerSize(size, groupedCells.meta, groupGap);\n this.chartSizes.chartWidth = chartWidth;\n this.chartSizes.chartHeight = chartHeight;\n }\n\n // update scales for cell positions, x and y for each facet.\n // Keys arrive pre-sorted from fillCellsData (and re-ordered by getDendrograms for clustered axes).\n updateScales(\n facetKeys: string[],\n groupedCells: GroupedCellsHeatmap,\n groupGap: number,\n facetSettings: HeatmapSettingsImpl['facetSettings'],\n size: HeatmapSettingsImpl['chartSettings']['size'],\n ) {\n const { width, height, cellWidth, cellHeight } = size;\n const { meta, facets } = groupedCells;\n const { sharedX, sharedY } = facetSettings;\n // All sorting is done upstream in fillCellsData; keys arrive already ordered.\n facetKeys.forEach(facetKey => {\n const facetGroup = facets[facetKey];\n const xGroupKeys = meta.xGroupKeys;\n const yGroupKeys = meta.yGroupKeys;\n const { xKeysByGroups } = sharedX ? meta : facetGroup;\n const { yKeysByGroups } = sharedY ? meta : facetGroup;\n // for shared facets max cells counts in group should be used\n const xCounts = xGroupKeys.map(xGroupKey => xKeysByGroups[xGroupKey].length);\n const yCounts = yGroupKeys.map(yGroupKey => yKeysByGroups[yGroupKey].length);\n const xCellsCount = xCounts.reduce((sum, count) => sum + count, 0);\n const yCellsCount = yCounts.reduce((sum, count) => sum + count, 0);\n const xStep = cellWidth ? cellWidth : (width - (xCounts.filter(count => count > 0).length - 1) * groupGap) / xCellsCount;\n const yStep = cellHeight ? cellHeight : (height - (yCounts.filter(count => count > 0).length - 1) * groupGap) / yCellsCount;\n\n const xPositions: number[] = [];\n let xKeys: string[] = [];\n let currentX = 0;\n const resolvedXGroups = xGroupKeys.map(xKey => xKeysByGroups[xKey]);\n resolvedXGroups.forEach((axisKeys, idx) => {\n xKeys = xKeys.concat(axisKeys);\n axisKeys.forEach(() => {\n xPositions.push(currentX);\n currentX += xStep;\n });\n // add gap only if a non-empty group follows (skip trailing gap after last visible group)\n const hasMoreNonEmpty = resolvedXGroups.slice(idx + 1).some(keys => keys.length > 0);\n if (axisKeys.length > 0 && hasMoreNonEmpty) {\n currentX += groupGap;\n }\n });\n\n const yPositions: number[] = [];\n let yKeys: string[] = [];\n let currentY = 0;\n const resolvedYGroups = yGroupKeys.map(yKey => yKeysByGroups[yKey]);\n resolvedYGroups.forEach((axisKeys, idx) => {\n yKeys = yKeys.concat(axisKeys);\n axisKeys.forEach(() => {\n yPositions.push(currentY);\n currentY += yStep;\n });\n // add gap only if a non-empty group follows (skip trailing gap after last visible group)\n const hasMoreNonEmpty = resolvedYGroups.slice(idx + 1).some(keys => keys.length > 0);\n if (axisKeys.length > 0 && hasMoreNonEmpty) {\n currentY += groupGap;\n }\n });\n\n this.scales.x[facetKey] = scaleOrdinal<string, number>().domain(xKeys).range(xPositions);\n this.scales.y[facetKey] = scaleOrdinal<string, number>().domain(yKeys).range(yPositions);\n this.step.x[facetKey] = xStep;\n this.step.y[facetKey] = yStep;\n });\n }\n\n updateAesScale(\n valueType: 'discrete' | 'continuous',\n valueExtent: [number, number],\n aes: HeatmapSettingsImpl['aes'],\n annotations: HeatmapSettingsImpl['annotations'],\n groupedCellsData: GroupedCellsHeatmap,\n cellUniqValues: DataValue[],\n normalization: HeatmapSettingsImpl['normalization']\n ) {\n if (valueType === 'continuous') {\n if (aes.valueColors) {\n this.colorScale = scaleLinear<string, string>()\n .domain(aes.valuesByColors ?? getContinuousColorRange(normalization, aes.valueColors.length, valueExtent))\n .range(aes.valueColors);\n } else if (aes.colorsList) {\n this.colorScale = scaleLinear<string, string>()\n .domain(getContinuousColorRange(normalization, aes.colorsList.length, valueExtent))\n .range(aes.colorsList);\n }\n } else {\n if (aes.colorsMap) {\n const valueKeys = Object.entries(aes.colorsMap);\n this.colorScale = scaleOrdinal<string, string>()\n .domain(valueKeys.map(v => v[0]))\n .range(valueKeys.map(v => v[1]))\n .unknown('#ccc');\n } else if (aes.colorsList) {\n this.colorScale = createDiscreteColorScale(aes.colorsList, cellUniqValues.map(String));\n }\n }\n\n const { xDataByKeys, yDataByKeys } = groupedCellsData.meta;\n annotations.forEach(item => {\n const { colors, type, axis, valueColumn } = item;\n const data = (axis === 'x' ? xDataByKeys : yDataByKeys)[valueColumn.valueLabels ?? valueColumn.value];\n if (type === 'discrete') {\n const discreteValues = lodash.uniq(Object.values(data).map(String)).sort();\n this.annotationColorScales[item.id] = {\n type: 'discrete',\n scale: createDiscreteRoundColorScale(colors, discreteValues),\n };\n } else {\n const values = Object.values(data).map(Number);\n if (!values.length) {\n return;\n }\n const [min = values[0], max = values[0]] = extent(values);\n this.annotationColorScales[item.id] = {\n type: 'continuous',\n scale: createContinuousColorScale(colors, min, max, 0, 0.5, 1),\n };\n }\n });\n }\n\n updateDendrogram(\n facetKeys: string[],\n xGroupKeys: string[],\n yGroupKeys: string[],\n groups: GroupedCellsHeatmap['facets'],\n dendrogramsData: DendrogramsData,\n dendrogramX: HeatmapSettingsImpl['dendrogramX'],\n dendrogramY: HeatmapSettingsImpl['dendrogramY']\n ) {\n facetKeys.forEach(facetKey => {\n this.dendrograms[facetKey] = { x: { treesByGroupKey: {}, data: dendrogramX }, y: { treesByGroupKey: {}, data: dendrogramY } };\n const { xKeysByGroups, yKeysByGroups } = groups[facetKey];\n if (dendrogramX) {\n const { hierarchyByGroupX } = dendrogramsData[facetKey];\n const maxHeightX = xGroupKeys.reduce((res, xKey) => Math.max(res, hierarchyByGroupX[xKey]?.data.height ?? 0), 0);\n this.dendrograms[facetKey].x.treesByGroupKey = xGroupKeys.reduce((res, groupKey) => {\n const hierarchy = hierarchyByGroupX[groupKey];\n if (!hierarchy) return res;\n const xKeys = xKeysByGroups[groupKey];\n cluster()\n .separation(() => 1)\n .size([hierarchy.leaves().length * this.step.x[facetKey], dendrogramX.size])(\n hierarchy as HierarchyNode<unknown>\n );\n const root = hierarchy as HierarchyPointNode<Cluster>;\n const heightScale = scaleLinear()\n .domain(dendrogramX.position === 'top' ? [0, maxHeightX] : [maxHeightX, 0])\n .range([dendrogramX.size, 0]);\n updateLinksHeight(root, heightScale, 'y');\n addShiftToLinkCoord(root, this.scales.x[facetKey](xKeys[0]), 'x');\n res[groupKey] = root;\n return res;\n }, {} as Record<string, HierarchyPointNode<Cluster>>);\n this.dendrograms[facetKey].x.data = dendrogramX;\n }\n if (dendrogramY) {\n const { hierarchyByGroupY } = dendrogramsData[facetKey];\n const maxHeightY = yGroupKeys.reduce((res, yKey) => Math.max(res, hierarchyByGroupY[yKey]?.data.height ?? 0), 0);\n this.dendrograms[facetKey].y.treesByGroupKey = yGroupKeys.reduce((res, groupKey) => {\n const hierarchy = hierarchyByGroupY[groupKey];\n if (!hierarchy) return res;\n const yKeys = yKeysByGroups[groupKey];\n cluster()\n .separation(() => 1)\n .size([hierarchy.leaves().length * this.step.y[facetKey], dendrogramY.size])(\n hierarchy as HierarchyNode<unknown>\n );\n const root = hierarchy as HierarchyPointNode<Cluster>;\n const heightScale = scaleLinear()\n .domain(dendrogramY.position === 'left' ? [0, maxHeightY] : [maxHeightY, 0])\n .range([dendrogramY.size, 0]);\n addShiftToLinkCoord(root, this.scales.y[facetKey](yKeys[0]), 'x', 'y');\n updateLinksHeight(root, heightScale, 'x');\n res[groupKey] = root;\n return res;\n }, {} as Record<string, HierarchyPointNode<Cluster>>);\n this.dendrograms[facetKey].y.data = dendrogramY;\n }\n });\n }\n\n updateDendrogramAesScales(inheritedAes: HeatmapSettingsImpl['inheritedDendrogramAes']) {\n if (!inheritedAes) {\n return;\n }\n const usedColumns = Object.keys(inheritedAes);\n this.dendrogramAesScales = usedColumns.reduce((res: DendrogramAesScales, columnName) => {\n const aesMap = inheritedAes[columnName];\n const columnValues: string[] = Object.keys(aesMap);\n res[columnName] = scaleOrdinal<string, AesItem, AesItem>()\n .domain(columnValues)\n .range(\n columnValues.map(value => ({\n ...DEFAULT_AES,\n ...aesMap[value],\n }))\n )\n .unknown(DEFAULT_AES);\n return res;\n }, {});\n }\n\n render(\n dataFrame: DataFrame,\n settingsId: string,\n chartSettings: HeatmapSettingsImpl['chartSettings'],\n facetSettings: HeatmapSettingsImpl['facetSettings'],\n aes: HeatmapSettingsImpl['aes'],\n groupedCellsData: GroupedCellsHeatmap,\n annotations: HeatmapSettingsImpl['annotations'],\n valueColumn: ColumnName,\n dendrogramX: HeatmapSettingsImpl['dendrogramX'],\n dendrogramY: HeatmapSettingsImpl['dendrogramY'],\n dendrogramsData: DendrogramsData,\n inheritedDendrogramAes: HeatmapSettingsImpl['inheritedDendrogramAes'],\n cellUniqValues: DataValue[],\n normalization: HeatmapSettingsImpl['normalization'],\n onTooltipHintSwitch: (v: boolean) => void,\n cellsRenderingMode: 'canvas' | 'svg'\n ) {\n const { meta, facets } = groupedCellsData;\n const { facetKeys, xGroupKeys, yGroupKeys, valueExtent } = meta;\n const { xAxis, yAxis, title, size, valueType } = chartSettings;\n this.updateChartsSizes(size, groupedCellsData, aes.groupGap);\n this.updateAesScale(valueType, valueExtent.dataSource, aes, annotations, groupedCellsData, cellUniqValues, normalization);\n this.updateScales(facetKeys, groupedCellsData, aes.groupGap, facetSettings, size);\n // caption sizes are needed for chart paddings in chart dimensions\n this.updateCaptionsSize(groupedCellsData, xAxis, yAxis, facetSettings);\n this.updateChartDimensions(\n size,\n facetKeys,\n xGroupKeys,\n yGroupKeys,\n facetSettings,\n xAxis,\n yAxis,\n annotations,\n dendrogramX,\n dendrogramY\n );\n this.updateLegendSize(valueType, chartSettings.legend, annotations, valueColumn, valueExtent.dataSource);\n this.updateMargins(title, size);\n this.updateDendrogram(facetKeys, xGroupKeys, yGroupKeys, facets, dendrogramsData, dendrogramX, dendrogramY);\n this.updateDendrogramAesScales(inheritedDendrogramAes);\n const component = (\n <DataFrameProvider dataFrame={dataFrame}>\n <ChartsGroup\n aes={aes}\n annotations={annotations}\n annotationColorScales={this.annotationColorScales}\n captionsSizes={this.captionsSizes}\n cellsMeta={meta}\n columnsCount={this.columnsCount}\n chartsDimensions={this.chartsDimensions}\n chartSettings={chartSettings}\n chartSizes={this.chartSizes}\n colorScale={this.colorScale as (v: unknown) => string}\n dendrogramAesScales={this.dendrogramAesScales}\n dendrograms={this.dendrograms}\n facetKeys={facetKeys}\n facetSettings={facetSettings}\n groupedCells={facets}\n labelAngles={this.labelAngles}\n legend={this.legend}\n margins={this.margins}\n scales={this.scales}\n settingsId={settingsId}\n step={this.step}\n xGroupKeys={xGroupKeys}\n yGroupKeys={yGroupKeys}\n onTooltipHintSwitch={onTooltipHintSwitch}\n cellsRenderingMode={cellsRenderingMode}\n />\n </DataFrameProvider>\n );\n this.component = component;\n this.reactRoot?.render(component);\n }\n\n renderError(message: string) {\n this.reactRoot?.render(<Error message={message} />);\n }\n}\n\nexport default ChartRenderer;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+CA,IAAM,IAAW,KAAK,IAAI,KAAK,KAAK,EAAE,EAChC,IAAiB;AACvB,SAAS,EAAkB,GAAmC,GAA8B,GAAkB;CAC1G,SAAS,EAAU,GAAgC;AAE/C,EADA,EAAE,KAAS,EAAM,EAAE,KAAK,OAAO,EAC3B,EAAE,YAAU,EAAE,SAAS,QAAQ,EAAU;;AAEjD,GAAU,EAAK;;AAInB,SAAS,EACL,GACA,GACA,GACA,IAAU,GACZ;CACE,SAAS,EAAK,GAAgC;AAE1C,EADA,EAAE,KAAW,EAAE,KAAa,GACxB,EAAE,YAAU,EAAE,SAAS,QAAQ,EAAK;;AAE5C,GAAK,EAAK;;AAGd,IAAM,KAAY,GAAe,MAA0B;CACvD,IAAM,IAAM,KAAK,IAAI,GAAG,EAAY,EAC9B,IAAM,KAAK,IAAI,GAAG,EAAY;AACpC,KAAI,MAAQ,GAAK;EACb,IAAM,IAAQ,IAAQ,KAAM,IAAI,EAAE,GAAG,CAAC,EAAI;AAC1C,OAAK,IAAI,IAAI,GAAG,IAAI,IAAQ,IAAI,GAAG,IAE/B,CADA,EAAM,KAAK,IAAM,EAAE,EACnB,EAAM,QAAQ,IAAM,EAAE;AAE1B,SAAO;;AAEX,KAAI,IAAQ,EACR,QAAO,CAAC,GAAK,EAAI;CAErB,IAAM,KAAQ,IAAM,MAAQ,IA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Y,GAAK,GAAa,GAAkB,GAAgB,EAAc,EACzH,KAAK,aAAa,GAAW,GAAkB,EAAI,UAAU,GAAe,EAAK,EAEjF,KAAK,mBAAmB,GAAkB,GAAO,GAAO,EAAc,EACtE,KAAK,sBACD,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,EACH,EACD,KAAK,iBAAiB,GAAW,EAAc,QAAQ,GAAa,GAAa,EAAY,WAAW,EACxG,KAAK,cAAc,GAAO,EAAK,EAC/B,KAAK,iBAAiB,GAAW,GAAY,GAAY,GAAQ,GAAiB,GAAa,EAAY,EAC3G,KAAK,0BAA0B,EAAuB;EACtD,IAAM,IACF,kBAAC,GAAD;GAA8B;aAC1B,kBAAC,GAAD;IACS;IACQ;IACb,uBAAuB,KAAK;IAC5B,eAAe,KAAK;IACpB,WAAW;IACX,cAAc,KAAK;IACnB,kBAAkB,KAAK;IACR;IACf,YAAY,KAAK;IACjB,YAAY,KAAK;IACjB,qBAAqB,KAAK;IAC1B,aAAa,KAAK;IACP;IACI;IACf,cAAc;IACd,aAAa,KAAK;IAClB,QAAQ,KAAK;IACb,SAAS,KAAK;IACd,QAAQ,KAAK;IACD;IACZ,MAAM,KAAK;IACC;IACA;IACS;IACD;IACtB,CAAA;GACc,CAAA;AAGxB,EADA,KAAK,YAAY,GACjB,KAAK,WAAW,OAAO,EAAU;;CAGrC,YAAY,GAAiB;AACzB,OAAK,WAAW,OAAO,kBAAC,GAAD,EAAgB,YAAW,CAAA,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { GroupedCellsHeatmap } from '../heatmap/getCells';
2
+ import { HeatmapSettingsImpl } from '../heatmap/HeatmapSettingsImpl';
3
+ type Size = HeatmapSettingsImpl['chartSettings']['size'];
4
+ /**
5
+ * Inner (cell-area) size of a single facet.
6
+ *
7
+ * A custom cell size forces shared axes (see HeatmapSettingsImpl), so every facet is laid out
8
+ * against the GLOBAL key set (meta) in updateScales. The single shared inner size must therefore
9
+ * be derived from meta — not from one facet's (possibly partial) subset — otherwise a partially
10
+ * empty facet under-counts the keys, the inner size disagrees with the drawn cells, and facets end
11
+ * up mis-sized and overlapping. With auto cell size (null), fall back to the fixed width/height.
12
+ */
13
+ export declare function computeChartInnerSize(size: Size, meta: GroupedCellsHeatmap['meta'], groupGap: number): {
14
+ chartWidth: number;
15
+ chartHeight: number;
16
+ };
17
+ export {};
18
+ //# sourceMappingURL=computeChartInnerSize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computeChartInnerSize.d.ts","sourceRoot":"","sources":["../../src/utils/computeChartInnerSize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAE1E,KAAK,IAAI,GAAG,mBAAmB,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAMzD;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACjC,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC,EACjC,QAAQ,EAAE,MAAM,GACjB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAY7C"}
@@ -0,0 +1,22 @@
1
+ function e(e, t) {
2
+ return e.filter((e) => (t[e]?.length ?? 0) > 0).length;
3
+ }
4
+ /**
5
+ * Inner (cell-area) size of a single facet.
6
+ *
7
+ * A custom cell size forces shared axes (see HeatmapSettingsImpl), so every facet is laid out
8
+ * against the GLOBAL key set (meta) in updateScales. The single shared inner size must therefore
9
+ * be derived from meta — not from one facet's (possibly partial) subset — otherwise a partially
10
+ * empty facet under-counts the keys, the inner size disagrees with the drawn cells, and facets end
11
+ * up mis-sized and overlapping. With auto cell size (null), fall back to the fixed width/height.
12
+ */
13
+ function t(t, n, r) {
14
+ let { width: i, height: a, cellWidth: o, cellHeight: s } = t;
15
+ return {
16
+ chartWidth: o && n.xKeys.length ? n.xKeys.length * o + r * (e(n.xGroupKeys, n.xKeysByGroups) - 1) : i,
17
+ chartHeight: s && n.yKeys.length ? n.yKeys.length * s + r * (e(n.yGroupKeys, n.yKeysByGroups) - 1) : a
18
+ };
19
+ }
20
+ export { t as computeChartInnerSize };
21
+
22
+ //# sourceMappingURL=computeChartInnerSize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computeChartInnerSize.js","names":[],"sources":["../../src/utils/computeChartInnerSize.ts"],"sourcesContent":["import type { GroupedCellsHeatmap } from '../heatmap/getCells';\nimport type { HeatmapSettingsImpl } from '../heatmap/HeatmapSettingsImpl';\n\ntype Size = HeatmapSettingsImpl['chartSettings']['size'];\n\nfunction countNonEmptyGroups(groupKeys: string[], keysByGroups: Record<string, string[]>): number {\n return groupKeys.filter(k => (keysByGroups[k]?.length ?? 0) > 0).length;\n}\n\n/**\n * Inner (cell-area) size of a single facet.\n *\n * A custom cell size forces shared axes (see HeatmapSettingsImpl), so every facet is laid out\n * against the GLOBAL key set (meta) in updateScales. The single shared inner size must therefore\n * be derived from meta — not from one facet's (possibly partial) subset — otherwise a partially\n * empty facet under-counts the keys, the inner size disagrees with the drawn cells, and facets end\n * up mis-sized and overlapping. With auto cell size (null), fall back to the fixed width/height.\n */\nexport function computeChartInnerSize(\n size: Size,\n meta: GroupedCellsHeatmap['meta'],\n groupGap: number,\n): { chartWidth: number; chartHeight: number } {\n // A defined cellWidth/cellHeight means the user picked a CUSTOM cell size, so the chart size is\n // derived from it (cellSize × key count). When null, the cell size is AUTO — the chart uses a\n // fixed width/height and the cells are stretched to fill it instead.\n const { width, height, cellWidth, cellHeight } = size;\n const chartWidth = cellWidth && meta.xKeys.length\n ? meta.xKeys.length * cellWidth + groupGap * (countNonEmptyGroups(meta.xGroupKeys, meta.xKeysByGroups) - 1)\n : width;\n const chartHeight = cellHeight && meta.yKeys.length\n ? meta.yKeys.length * cellHeight + groupGap * (countNonEmptyGroups(meta.yGroupKeys, meta.yKeysByGroups) - 1)\n : height;\n return { chartWidth, chartHeight };\n}\n"],"mappings":"AAKA,SAAS,EAAoB,GAAqB,GAAgD;AAC9F,QAAO,EAAU,QAAO,OAAM,EAAa,IAAI,UAAU,KAAK,EAAE,CAAC;;;;;;;;;;;AAYrE,SAAgB,EACZ,GACA,GACA,GAC2C;CAI3C,IAAM,EAAE,UAAO,WAAQ,cAAW,kBAAe;AAOjD,QAAO;EAAE,YANU,KAAa,EAAK,MAAM,SACrC,EAAK,MAAM,SAAS,IAAY,KAAY,EAAoB,EAAK,YAAY,EAAK,cAAc,GAAG,KACvG;EAIe,aAHD,KAAc,EAAK,MAAM,SACvC,EAAK,MAAM,SAAS,IAAa,KAAY,EAAoB,EAAK,YAAY,EAAK,cAAc,GAAG,KACxG;EAC4B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milaboratories/miplots4",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "Data visualization library",
5
5
  "author": "erohinaelena",
6
6
  "license": "ISC",