@milaboratories/miplots4 1.0.160 → 1.0.161

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,12 +1,12 @@
1
1
  var st = Object.defineProperty;
2
2
  var ot = (a, t, i) => t in a ? st(a, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : a[t] = i;
3
- var E = (a, t, i) => ot(a, typeof t != "symbol" ? t + "" : t, i);
3
+ var S = (a, t, i) => ot(a, typeof t != "symbol" ? t + "" : t, i);
4
4
  import { j as v } from "../_virtual/jsx-runtime.js";
5
5
  import { c as nt } from "../_virtual/client.js";
6
6
  import { Error as at } from "../common/Error.js";
7
7
  import { DataFrameProvider as ht } from "../common/useDataFrame.js";
8
- import { DEFAULT_HEIGHT as X, DEFAULT_WIDTH as P, TITLE_LINE_HEIGHT as rt, MAX_SHOWN_UNIQUE_VALUES_IN_LABELS as lt, BLACK as et, TITLE_MARGIN as ct } from "../constants.js";
9
- import { FACET_TITLE_LINE as mt } from "../discrete/constants.js";
8
+ import { DEFAULT_HEIGHT as X, DEFAULT_WIDTH as G, TITLE_LINE_HEIGHT as rt, MIN_LEGEND_GRADIENT_HEIGHT as lt, MAX_LEGEND_GRADIENT_HEIGHT as ct, MAX_SHOWN_UNIQUE_VALUES_IN_LABELS as mt, BLACK as et, TITLE_MARGIN as dt } from "../constants.js";
9
+ import { FACET_TITLE_LINE as pt } from "../discrete/constants.js";
10
10
  import { splitTextByWidth as V } from "../utils/splitTextByWidth.js";
11
11
  import { isContinuousAes as q } from "../types/common.js";
12
12
  import "../types/discrete.js";
@@ -15,105 +15,105 @@ import "../types/heatmap.js";
15
15
  import "../types/dendro.js";
16
16
  import "../types/histogram.js";
17
17
  import "../types/bubble.js";
18
- import { arrangeLegendParts as dt } from "../utils/arrangeLegendParts.js";
19
- import { getContinuousColorScale as pt } from "../utils/getContinuousColorScale.js";
20
- import { getContinuousLegendTicks as ut } from "../utils/getContinuousLegendTicks.js";
21
- import { TextMeasurer as gt } from "../utils/TextMeasurer/TextMeasurer.js";
22
- import { ChartsGroup as ft } from "./components/ChartsGroup.js";
23
- import { MIN_MARGIN as H, PADDINGS as G, DEFAULT_DOT_AES as _, LEGEND_OFFSET as Ct, TICK_OFFSET as O, DEFAULT_TICKS_SIZE as Q, MIN_PADDING as F, FACET_TITLE_OFFSET as Tt, TITLE_LINE as U, FACET_AXIS_OFFSET as Z } from "./constants.js";
24
- import { createAesGetter as D } from "./utils/createAesGetter.js";
25
- import { getTicksAndFormat as St } from "./utils/getTicksAndFormat.js";
18
+ import { arrangeLegendParts as ut } from "../utils/arrangeLegendParts.js";
19
+ import { getContinuousColorScale as gt } from "../utils/getContinuousColorScale.js";
20
+ import { getContinuousLegendTicks as ft } from "../utils/getContinuousLegendTicks.js";
21
+ import { TextMeasurer as Tt } from "../utils/TextMeasurer/TextMeasurer.js";
22
+ import { ChartsGroup as Ct } from "./components/ChartsGroup.js";
23
+ import { MIN_MARGIN as D, PADDINGS as P, DEFAULT_DOT_AES as Y, LEGEND_OFFSET as xt, TICK_OFFSET as O, DEFAULT_TICKS_SIZE as Q, MIN_PADDING as F, FACET_TITLE_OFFSET as Et, TITLE_LINE as U, FACET_AXIS_OFFSET as Z } from "./constants.js";
24
+ import { createAesGetter as L } from "./utils/createAesGetter.js";
25
+ import { getTicksAndFormat as Mt } from "./utils/getTicksAndFormat.js";
26
26
  import { isContinuousAxis as $ } from "./utils/isNumericScale.js";
27
27
  import { createMultilineDiscreteLabels as J } from "../utils/createMultilineDiscreteLabels.js";
28
28
  import { measureMultilineDiscreteLabels as k } from "../utils/measureMultilineDiscreteLabels.js";
29
29
  import B from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/linear.js";
30
30
  import { point as y } from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/band.js";
31
31
  import K from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/log.js";
32
- import xt from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/ordinal.js";
33
- import Mt from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/symlog.js";
32
+ import St from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/ordinal.js";
33
+ import Nt from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/symlog.js";
34
34
  import { sqrt as zt } from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/pow.js";
35
35
  function tt(a, t) {
36
36
  if (a === void 0)
37
37
  return !0;
38
38
  {
39
39
  const i = a.domain(), s = a.range(), e = t.domain(), o = t.range();
40
- if (i.length !== e.length || i.some((g, T) => g !== e[T]) || s[0] !== o[0] || s[1] !== o[1])
40
+ if (i.length !== e.length || i.some((f, T) => f !== e[T]) || s[0] !== o[0] || s[1] !== o[1])
41
41
  return !0;
42
42
  }
43
43
  return !1;
44
44
  }
45
- function Et(a, t, i, s) {
45
+ function bt(a, t, i, s) {
46
46
  const e = [];
47
47
  return a % i === i - 1 && e.push("right"), a % i === 0 && e.push("left"), a < i && e.push("top"), (Math.ceil((a + 1) / i) === s || Math.ceil((a + 1) / i) === s - 1 && a % i > (t - 1) % i) && e.push("bottom"), e;
48
48
  }
49
- function bt(a, t, i, s, e, o, g, T, M, u) {
50
- const W = a.scale === "discrete", m = t.scale === "discrete", n = o.includes("left") || !(u != null && u.sharedY), h = o.includes("left") && t.title !== "", c = o.includes("bottom") || !(u != null && u.sharedX), f = o.includes("bottom") && a.title !== "", r = m ? i.leftAxisCaptionsWidthByColumns[T] : i.yAxisCaptionsWidth + 2 * O, d = (t.showTicks ? Q : 0) + O, S = h ? U + F : 0, x = W ? i.bottomAxisCaptionsWidthByRows[g] : i.xAxisCaptionsWidth + 2 * O, z = a.showTicks ? Q : 0, L = f ? U + F : 0, C = r + d + S + Z, l = x + z + L + Z, I = Math.max(...s.map((p) => e[p].length));
49
+ function wt(a, t, i, s, e, o, f, T, M, d) {
50
+ const b = a.scale === "discrete", W = t.scale === "discrete", h = o.includes("left") || !(d != null && d.sharedY), n = o.includes("left") && t.title !== "", r = o.includes("bottom") || !(d != null && d.sharedX), g = o.includes("bottom") && a.title !== "", x = W ? i.leftAxisCaptionsWidthByColumns[T] : i.yAxisCaptionsWidth + 2 * O, l = (t.showTicks ? Q : 0) + O, m = n ? U + F : 0, C = b ? i.bottomAxisCaptionsWidthByRows[f] : i.xAxisCaptionsWidth + 2 * O, E = a.showTicks ? Q : 0, R = g ? U + F : 0, p = x + l + m + Z, c = C + E + R + Z, I = Math.max(...s.map((u) => e[u].length));
51
51
  return {
52
- left: n ? C : F,
53
- top: I === 0 ? 0 : Tt * 2 + I * mt,
54
- bottom: c ? l + 8 : F,
52
+ left: h ? p : F,
53
+ top: I === 0 ? 0 : Et * 2 + I * pt,
54
+ bottom: r ? c + 8 : F,
55
55
  right: M ? 0 : F
56
56
  };
57
57
  }
58
- function wt(a, t, i) {
58
+ function Wt(a, t, i) {
59
59
  const s = [];
60
60
  for (let e = 0; e < t; e++)
61
61
  s.push(a.slice(e * i, e * i + i));
62
62
  return s;
63
63
  }
64
- function Nt(a, t) {
64
+ function It(a, t) {
65
65
  const i = Math.floor(a / t), s = a - i * t;
66
66
  return [i, s];
67
67
  }
68
- function Wt(a, t, i, s) {
69
- const e = i.find((g) => g.type === "dots"), o = i.find((g) => g.type === "curve");
68
+ function At(a, t, i, s) {
69
+ const e = i.find((f) => f.type === "dots"), o = i.find((f) => f.type === "curve");
70
70
  return {
71
- dotShape: D(a, t, (e == null ? void 0 : e.aes.dotShape) ?? _.shape, "dotShape"),
72
- dotColor: D(a, t, (e == null ? void 0 : e.aes.dotFill) ?? _.color, "dotFill"),
73
- dotSize: D(a, t, (e == null ? void 0 : e.aes.dotSize) ?? _.size, "dotSize"),
74
- lineShape: D(a, t, (o == null ? void 0 : o.aes.lineShape) ?? "solid", "lineShape"),
75
- lineColor: D(a, t, (o == null ? void 0 : o.aes.lineColor) ?? et, "lineColor"),
76
- trendColor: D(a, t, (s == null ? void 0 : s.color) ?? _.color, "fillColor")
71
+ dotShape: L(a, t, (e == null ? void 0 : e.aes.dotShape) ?? Y.shape, "dotShape"),
72
+ dotColor: L(a, t, (e == null ? void 0 : e.aes.dotFill) ?? Y.color, "dotFill"),
73
+ dotSize: L(a, t, (e == null ? void 0 : e.aes.dotSize) ?? Y.size, "dotSize"),
74
+ lineShape: L(a, t, (o == null ? void 0 : o.aes.lineShape) ?? "solid", "lineShape"),
75
+ lineColor: L(a, t, (o == null ? void 0 : o.aes.lineColor) ?? et, "lineColor"),
76
+ trendColor: L(a, t, (s == null ? void 0 : s.color) ?? Y.color, "fillColor")
77
77
  };
78
78
  }
79
- const It = Math.cos(Math.PI / 4), At = 5;
79
+ const _t = Math.cos(Math.PI / 4), Ht = 5;
80
80
  function it(a, t) {
81
- return t.scale === "discrete" ? t.labelsPosition === "90deg" ? a : t.labelsPosition === "45deg" ? a * It + (a > 0 ? 2 * At : 0) : U : a;
81
+ return t.scale === "discrete" ? t.labelsPosition === "90deg" ? a : t.labelsPosition === "45deg" ? a * _t + (a > 0 ? 2 * Ht : 0) : U : a;
82
82
  }
83
- class ri {
83
+ class ci {
84
84
  constructor() {
85
- E(this, "reactRoot", null);
86
- E(this, "parentNode", null);
87
- E(this, "rootNode", null);
88
- E(this, "component", /* @__PURE__ */ v.jsx(v.Fragment, {}));
89
- E(this, "margins", {
90
- top: H,
91
- bottom: H,
92
- left: H,
93
- right: H
85
+ S(this, "reactRoot", null);
86
+ S(this, "parentNode", null);
87
+ S(this, "rootNode", null);
88
+ S(this, "component", /* @__PURE__ */ v.jsx(v.Fragment, {}));
89
+ S(this, "margins", {
90
+ top: D,
91
+ bottom: D,
92
+ left: D,
93
+ right: D
94
94
  });
95
- E(this, "chartsDimensions", {});
96
- E(this, "chartSizes", {
97
- chartWidth: P,
95
+ S(this, "chartsDimensions", {});
96
+ S(this, "chartSizes", {
97
+ chartWidth: G,
98
98
  // width of single chart
99
99
  chartHeight: X,
100
100
  // height of single chart
101
- chartsWidth: P,
101
+ chartsWidth: G,
102
102
  // width of all charts in charts row
103
103
  chartsHeight: X,
104
104
  // width of all charts in charts column, without axes
105
- totalWidth: P,
105
+ totalWidth: G,
106
106
  // width of all charts in charts row, plus left axis, plus legend
107
107
  totalHeight: X
108
108
  // width of all charts in charts height, plus bottom axis, plus top title
109
109
  });
110
- E(this, "columnsCount", 1);
111
- E(this, "rowsCount", 1);
112
- E(this, "scales", {
113
- x: { null: B().domain([0, 1]).range([0, P]) },
110
+ S(this, "columnsCount", 1);
111
+ S(this, "rowsCount", 1);
112
+ S(this, "scales", {
113
+ x: { null: B().domain([0, 1]).range([0, G]) },
114
114
  y: { null: B().domain([0, 1]).range([X, 0]) }
115
115
  });
116
- E(this, "captionsSizes", {
116
+ S(this, "captionsSizes", {
117
117
  xAxisCaptionsWidth: 30,
118
118
  yAxisCaptionsWidth: 100,
119
119
  bottomAxisCaptionsWidthByRows: [],
@@ -121,13 +121,13 @@ class ri {
121
121
  bottomCaptionsTail: 0,
122
122
  leftCaptionsTail: 0
123
123
  });
124
- E(this, "facetTitles", {});
124
+ S(this, "facetTitles", {});
125
125
  // can be multiline
126
- E(this, "mainTitle", []);
126
+ S(this, "mainTitle", []);
127
127
  // can be multiline
128
- E(this, "discreteAxesLabels", { x: {}, y: {} });
128
+ S(this, "discreteAxesLabels", { x: {}, y: {} });
129
129
  // only for discrete axes, by facets, can be multiline
130
- E(this, "legend", { width: 0, height: 0, items: [] });
130
+ S(this, "legend", { width: 0, height: 0, items: [] });
131
131
  }
132
132
  clear() {
133
133
  var t;
@@ -143,108 +143,108 @@ class ri {
143
143
  this.chartSizes.chartWidth = t.width, this.chartSizes.chartHeight = t.height;
144
144
  }
145
145
  updateChartDimensions(t, i, s, e) {
146
- const { chartWidth: o, chartHeight: g } = this.chartSizes;
146
+ const { chartWidth: o, chartHeight: f } = this.chartSizes;
147
147
  let T = 0, M = 0;
148
- const u = wt(t, this.rowsCount, this.columnsCount);
149
- this.chartsDimensions = t.reduce((n, h, c) => {
150
- const [f, r] = Nt(c, this.columnsCount), d = Et(c, t.length, this.columnsCount, this.rowsCount), S = bt(
148
+ const d = Wt(t, this.rowsCount, this.columnsCount);
149
+ this.chartsDimensions = t.reduce((h, n, r) => {
150
+ const [g, x] = It(r, this.columnsCount), l = bt(r, t.length, this.columnsCount, this.rowsCount), m = wt(
151
151
  s,
152
152
  e,
153
153
  this.captionsSizes,
154
- u[f],
154
+ d[g],
155
155
  this.facetTitles,
156
- d,
157
- f,
158
- r,
159
- r === this.columnsCount - 1,
156
+ l,
157
+ g,
158
+ x,
159
+ x === this.columnsCount - 1,
160
160
  i
161
- ), x = o + S.left + S.right, z = g + S.top + S.bottom;
162
- return n[h] = {
161
+ ), C = o + m.left + m.right, E = f + m.top + m.bottom;
162
+ return h[n] = {
163
163
  left: T,
164
164
  top: M,
165
- chartEdgeSides: d,
166
- padding: S,
167
- inner: { width: o, height: g },
168
- outer: { width: x, height: z }
169
- }, T += x, r === this.columnsCount - 1 && (T = 0, M += z), n;
165
+ chartEdgeSides: l,
166
+ padding: m,
167
+ inner: { width: o, height: f },
168
+ outer: { width: C, height: E }
169
+ }, T += C, x === this.columnsCount - 1 && (T = 0, M += E), h;
170
170
  }, {});
171
- const W = Math.max(
172
- ...t.map((n) => this.chartsDimensions[n].outer.width + this.chartsDimensions[n].left)
173
- ), m = Math.max(
174
- ...t.map((n) => this.chartsDimensions[n].outer.height + this.chartsDimensions[n].top)
171
+ const b = Math.max(
172
+ ...t.map((h) => this.chartsDimensions[h].outer.width + this.chartsDimensions[h].left)
173
+ ), W = Math.max(
174
+ ...t.map((h) => this.chartsDimensions[h].outer.height + this.chartsDimensions[h].top)
175
175
  );
176
- this.chartSizes.chartsWidth = W, this.chartSizes.chartsHeight = m;
176
+ this.chartSizes.chartsWidth = b, this.chartSizes.chartsHeight = W;
177
177
  }
178
- updateViewport(t, i, s, e, o, g, T, M) {
179
- const u = t.length, W = Math.min(i.nRows ?? u, u), m = Math.min(i.nCols ?? u, u);
180
- this.columnsCount = i.nRows ? Math.ceil(u / W) : m, this.rowsCount = Math.ceil(u / this.columnsCount);
181
- let [n, h] = [1 / 0, -1 / 0], [c, f] = [1 / 0, -1 / 0];
182
- const r = t.reduce((C, l) => {
183
- const I = T[l], { minX: p, minY: b, maxX: w, maxY: N } = I;
184
- return n = Math.min(n, p), c = Math.min(c, b), h = Math.max(h, w), f = Math.max(f, N), C[l] = { minX: p, maxX: w, minY: b, maxY: N }, C;
185
- }, {}), d = {}, S = {};
186
- let x = !1, z = !1;
187
- t.forEach((C) => {
188
- let l;
178
+ updateViewport(t, i, s, e, o, f, T, M) {
179
+ const d = t.length, b = Math.min(i.nRows ?? d, d), W = Math.min(i.nCols ?? d, d);
180
+ this.columnsCount = i.nRows ? Math.ceil(d / b) : W, this.rowsCount = Math.ceil(d / this.columnsCount);
181
+ let [h, n] = [1 / 0, -1 / 0], [r, g] = [1 / 0, -1 / 0];
182
+ const x = t.reduce((p, c) => {
183
+ const I = T[c], { minX: u, minY: N, maxX: z, maxY: w } = I;
184
+ return h = Math.min(h, u), r = Math.min(r, N), n = Math.max(n, z), g = Math.max(g, w), p[c] = { minX: u, maxX: z, minY: N, maxY: w }, p;
185
+ }, {}), l = {}, m = {};
186
+ let C = !1, E = !1;
187
+ t.forEach((p) => {
188
+ let c;
189
189
  if (!$(s))
190
- l = y().range([0, this.chartSizes.chartWidth]).domain(o.keys ?? []).padding(0.5);
190
+ c = y().range([0, this.chartSizes.chartWidth]).domain(o.keys ?? []).padding(0.5);
191
191
  else {
192
- l = s.scale === "log" ? K() : B();
193
- const p = r[C];
194
- let b = s.lowerValue ? Number(s.lowerValue) : i.sharedX ? n : p.minX, w = s.upperValue ? Number(s.upperValue) : i.sharedX ? h : p.maxX;
192
+ c = s.scale === "log" ? K() : B();
193
+ const u = x[p];
194
+ let N = s.lowerValue ? Number(s.lowerValue) : i.sharedX ? h : u.minX, z = s.upperValue ? Number(s.upperValue) : i.sharedX ? n : u.maxX;
195
195
  if (typeof s.symmetricRange < "u") {
196
- const R = s.symmetricRange;
197
- if (R >= b && R <= w) {
198
- const Y = Math.max(R - b, w - R);
199
- b = R - Y, w = R + Y;
196
+ const _ = s.symmetricRange;
197
+ if (_ >= N && _ <= z) {
198
+ const H = Math.max(_ - N, z - _);
199
+ N = _ - H, z = _ + H;
200
200
  }
201
201
  }
202
- const N = [0, this.chartSizes.chartWidth], A = l.copy().domain([b, w]).range([G.LEFT, this.chartSizes.chartWidth - G.RIGHT]);
203
- l.domain([A.invert(0), A.invert(this.chartSizes.chartWidth)]).range(N).nice();
202
+ const w = [0, this.chartSizes.chartWidth], A = c.copy().domain([N, z]).range([P.LEFT, this.chartSizes.chartWidth - P.RIGHT]);
203
+ c.domain([A.invert(0), A.invert(this.chartSizes.chartWidth)]).range(w).nice();
204
204
  }
205
- const I = this.scales.x[C];
206
- d[C] = l, x = x || tt(I, l);
205
+ const I = this.scales.x[p];
206
+ l[p] = c, C = C || tt(I, c);
207
207
  });
208
- const L = t.reduce((C, l) => {
209
- const I = M ? M[l] : [];
210
- return C[l] = I.reduce(
211
- (p, b) => {
212
- const w = b.bounded ? b.xBounds : this.scales.x[l].domain(), N = b.getInterval(w[0]), A = b.getInterval(w[1]);
213
- return p.minY = Math.min(p.minY, isNaN(N.left) ? p.minY : N.left, isNaN(A.left) ? p.minY : A.left), p.maxY = Math.max(p.maxY, isNaN(N.right) ? p.maxY : N.right, isNaN(A.right) ? p.maxY : A.right), p;
208
+ const R = t.reduce((p, c) => {
209
+ const I = M ? M[c] : [];
210
+ return p[c] = I.reduce(
211
+ (u, N) => {
212
+ const z = N.bounded ? N.xBounds : this.scales.x[c].domain(), w = N.getInterval(z[0]), A = N.getInterval(z[1]);
213
+ return u.minY = Math.min(u.minY, isNaN(w.left) ? u.minY : w.left, isNaN(A.left) ? u.minY : A.left), u.maxY = Math.max(u.maxY, isNaN(w.right) ? u.maxY : w.right, isNaN(A.right) ? u.maxY : A.right), u;
214
214
  },
215
215
  { minY: 1 / 0, maxY: -1 / 0 }
216
- ), c = Math.min(c, C[l].minY), f = Math.max(f, C[l].maxY), C;
216
+ ), r = Math.min(r, p[c].minY), g = Math.max(g, p[c].maxY), p;
217
217
  }, {});
218
- t.forEach((C) => {
219
- let l;
218
+ t.forEach((p) => {
219
+ let c;
220
220
  if (!$(e))
221
- l = y().range([this.chartSizes.chartHeight, 0]).domain(g.keys ?? []).padding(0.5);
221
+ c = y().range([this.chartSizes.chartHeight, 0]).domain(f.keys ?? []).padding(0.5);
222
222
  else {
223
- l = e.scale === "log" ? K() : B();
224
- const p = r[C], b = L[C];
225
- let w = e.lowerValue ? Number(e.lowerValue) : i.sharedY ? c : Math.min(p.minY, b.minY), N = e.upperValue ? Number(e.upperValue) : i.sharedY ? f : Math.max(p.maxY, b.maxY);
223
+ c = e.scale === "log" ? K() : B();
224
+ const u = x[p], N = R[p];
225
+ let z = e.lowerValue ? Number(e.lowerValue) : i.sharedY ? r : Math.min(u.minY, N.minY), w = e.upperValue ? Number(e.upperValue) : i.sharedY ? g : Math.max(u.maxY, N.maxY);
226
226
  if (typeof e.symmetricRange < "u") {
227
- const Y = e.symmetricRange;
228
- if (Y >= w && Y <= N) {
229
- const j = Math.max(Y - w, N - Y);
230
- w = Y - j, N = Y + j;
227
+ const H = e.symmetricRange;
228
+ if (H >= z && H <= w) {
229
+ const j = Math.max(H - z, w - H);
230
+ z = H - j, w = H + j;
231
231
  }
232
232
  }
233
- const A = [this.chartSizes.chartHeight, 0], R = l.copy().domain([w, N]).range([this.chartSizes.chartHeight - G.BOTTOM, G.TOP]);
234
- l.domain([R.invert(this.chartSizes.chartHeight), R.invert(0)]).range(A).nice();
233
+ const A = [this.chartSizes.chartHeight, 0], _ = c.copy().domain([z, w]).range([this.chartSizes.chartHeight - P.BOTTOM, P.TOP]);
234
+ c.domain([_.invert(this.chartSizes.chartHeight), _.invert(0)]).range(A).nice();
235
235
  }
236
- const I = this.scales.y[C];
237
- S[C] = l, z = z || tt(I, l);
238
- }), x && (this.scales.x = d), z && (this.scales.y = S);
236
+ const I = this.scales.y[p];
237
+ m[p] = c, E = E || tt(I, c);
238
+ }), C && (this.scales.x = l), E && (this.scales.y = m);
239
239
  }
240
240
  updateCaptionsSize(t, i, s, e) {
241
- const o = new gt("600 14px Manrope");
242
- function g(h) {
243
- return Math.max(...h.map((c) => o.getTextWidth(c)));
241
+ const o = new Tt("600 14px Manrope");
242
+ function f(n) {
243
+ return Math.max(...n.map((r) => o.getTextWidth(r)));
244
244
  }
245
- let T = 0, M = 0, u = [], W = [], m = 0, n = 0;
245
+ let T = 0, M = 0, d = [], b = [], W = 0, h = 0;
246
246
  if (i.scale === "discrete") {
247
- const h = k(
247
+ const n = k(
248
248
  t,
249
249
  this.rowsCount,
250
250
  this.columnsCount,
@@ -253,11 +253,11 @@ class ri {
253
253
  "vertical",
254
254
  this.scales.x
255
255
  );
256
- T = h.xTail, u = h.axisCaptionsWidthByRows;
256
+ T = n.xTail, d = n.axisCaptionsWidthByRows;
257
257
  } else
258
- m = 20;
258
+ W = 20;
259
259
  if (s.scale === "discrete") {
260
- const h = k(
260
+ const n = k(
261
261
  t,
262
262
  this.rowsCount,
263
263
  this.columnsCount,
@@ -266,17 +266,17 @@ class ri {
266
266
  "horizontal",
267
267
  this.scales.y
268
268
  );
269
- M = h.yTail, W = h.axisCaptionsWidthByColumns;
269
+ M = n.yTail, b = n.axisCaptionsWidthByColumns;
270
270
  } else
271
- Object.values(this.scales.y).forEach((h) => {
272
- const { ticks: c, format: f } = St(h, e);
273
- n = Math.max(n, g(c.map(f)));
271
+ Object.values(this.scales.y).forEach((n) => {
272
+ const { ticks: r, format: g } = Mt(n, e);
273
+ h = Math.max(h, f(r.map(g)));
274
274
  });
275
275
  this.captionsSizes = {
276
- xAxisCaptionsWidth: it(m, i),
277
- yAxisCaptionsWidth: it(n, s),
278
- bottomAxisCaptionsWidthByRows: u,
279
- leftAxisCaptionsWidthByColumns: W,
276
+ xAxisCaptionsWidth: it(W, i),
277
+ yAxisCaptionsWidth: it(h, s),
278
+ bottomAxisCaptionsWidthByRows: d,
279
+ leftAxisCaptionsWidthByColumns: b,
280
280
  bottomCaptionsTail: T,
281
281
  leftCaptionsTail: M
282
282
  };
@@ -313,12 +313,12 @@ class ri {
313
313
  };
314
314
  }
315
315
  updateMargins(t) {
316
- const i = rt * this.mainTitle.length, s = i > 0 ? i + ct * 2 : 0, e = this.chartsDimensions[t[0]], o = this.chartsDimensions[t[t.length - 1]];
316
+ const i = rt * this.mainTitle.length, s = i > 0 ? i + dt * 2 : 0, e = this.chartsDimensions[t[0]], o = this.chartsDimensions[t[t.length - 1]];
317
317
  this.margins = {
318
- top: Math.max(s, H),
319
- bottom: Math.max(H, this.captionsSizes.leftCaptionsTail - o.padding.bottom),
320
- left: Math.max(H, this.captionsSizes.bottomCaptionsTail - e.padding.left),
321
- right: this.legend.width + H
318
+ top: Math.max(s, D),
319
+ bottom: Math.max(D, this.captionsSizes.leftCaptionsTail - o.padding.bottom),
320
+ left: Math.max(D, this.captionsSizes.bottomCaptionsTail - e.padding.left),
321
+ right: this.legend.width + D
322
322
  }, this.chartSizes.totalWidth = this.margins.left + this.chartSizes.chartsWidth + this.margins.right, this.chartSizes.totalHeight = this.margins.top + Math.max(this.chartSizes.chartsHeight, this.legend.height) + this.margins.bottom;
323
323
  }
324
324
  updateLegendSize(t, i, s, e) {
@@ -326,49 +326,52 @@ class ri {
326
326
  this.legend = { width: 0, height: 0, items: [] };
327
327
  return;
328
328
  }
329
- const o = [], g = { width: 0, height: 0, left: 0, top: 0 };
330
- if (s.forEach((m) => {
331
- const n = i[m.value];
329
+ const o = [], f = { width: 0, height: 0, left: 0, top: 0 }, T = Math.min(
330
+ Math.max(this.chartSizes.chartHeight, lt),
331
+ ct
332
+ ), M = Math.max(this.chartSizes.chartHeight, T);
333
+ if (s.forEach((h) => {
334
+ const n = i[h.value];
332
335
  if (n.usedAes.length === 0 || !n.aesMap)
333
336
  return;
334
- if (n.values.length > lt) {
337
+ if (n.values.length > mt) {
335
338
  console.warn(`Too many values for discrete legend (${n.values.length})`);
336
339
  return;
337
340
  }
338
- const h = {};
339
- n.values.forEach((r) => {
340
- h[r] || (h[r] = { ..._ }), n.usedAes.forEach((d) => {
341
- (d === "dotFill" || d === "lineColor") && (h[r].color = n.aesMap(r, d) ?? et), d === "dotShape" && (h[r].shape = n.aesMap(r, d) ?? "21"), d === "dotSize" && (h[r].size = n.aesMap(r, d) ?? 3);
341
+ const r = {};
342
+ n.values.forEach((l) => {
343
+ r[l] || (r[l] = { ...Y }), n.usedAes.forEach((m) => {
344
+ (m === "dotFill" || m === "lineColor") && (r[l].color = n.aesMap(l, m) ?? et), m === "dotShape" && (r[l].shape = n.aesMap(l, m) ?? "21"), m === "dotSize" && (r[l].size = n.aesMap(l, m) ?? 3);
342
345
  });
343
346
  });
344
- const c = m.label ?? m.value, f = xt().domain(n.values).range(n.values.map((r) => h[r])).unknown(_);
345
- o.push({ ...g, id: m.value, type: "dots", title: c, scale: f, values: n.values, labels: n.labels });
346
- }), e.forEach((m) => {
347
- if (m.type === "dots" && q(m.aes.dotFill)) {
348
- const { domain: n, range: h, columnName: c, type: f = "linear" } = m.aes.dotFill, r = c.label ?? c.value, d = pt(h, n, "linear"), S = (f === "log" ? Mt() : B()).domain(n).range([this.chartSizes.chartHeight, 0]), x = ut(S, n);
349
- o.push({ ...g, id: "dotFill", type: "continuous", title: r, scale: d, tickPositionScale: S, values: x });
347
+ const g = h.label ?? h.value, x = St().domain(n.values).range(n.values.map((l) => r[l])).unknown(Y);
348
+ o.push({ ...f, id: h.value, type: "dots", title: g, scale: x, values: n.values, labels: n.labels });
349
+ }), e.forEach((h) => {
350
+ if (h.type === "dots" && q(h.aes.dotFill)) {
351
+ const { domain: n, range: r, columnName: g, type: x = "linear" } = h.aes.dotFill, l = g.label ?? g.value, m = gt(r, n, "linear"), C = (x === "log" ? Nt() : B()).domain(n).range([T, 0]), E = ft(C, n);
352
+ o.push({ ...f, id: "dotFill", type: "continuous", title: l, scale: m, tickPositionScale: C, values: E });
350
353
  }
351
- if (m.type === "dots" && q(m.aes.dotSize)) {
352
- const { columnName: n, domain: h, range: c } = m.aes.dotSize, f = n.label ?? n.value, r = zt(h, c), d = r.ticks(3), S = r.tickFormat(3), x = d.reduce((z, L) => (z[String(L)] = S(L), z), {});
353
- o.push({ ...g, id: n.value, type: "size", title: f, scale: r, values: d, labels: x });
354
+ if (h.type === "dots" && q(h.aes.dotSize)) {
355
+ const { columnName: n, domain: r, range: g } = h.aes.dotSize, x = n.label ?? n.value, l = zt(r, g), m = l.ticks(3), C = l.tickFormat(3), E = m.reduce((R, p) => (R[String(p)] = C(p), R), {});
356
+ o.push({ ...f, id: n.value, type: "size", title: x, scale: l, values: m, labels: E });
354
357
  }
355
358
  }), !o.length) {
356
359
  this.legend = { width: 0, height: 0, items: [] };
357
360
  return;
358
361
  }
359
- const T = dt(o, this.chartSizes.chartHeight), M = T[T.length - 1], u = M.left + M.width + Ct, W = this.chartSizes.chartHeight;
362
+ const d = ut(o, M, T), b = d[d.length - 1], W = b.left + b.width + xt;
360
363
  this.legend = {
361
- width: u,
362
- height: W,
363
- items: T
364
+ width: W,
365
+ height: M,
366
+ items: d
364
367
  };
365
368
  }
366
- render(t, i, s, e, o, g, T, M, u, W, m, n, h, c, f, r, d, S) {
367
- var p;
368
- const { xAxis: x, yAxis: z, size: L, title: C, legend: l } = s;
369
- this.updateChartSizes(L), this.updateViewport(o, e, x, z, r, d, T, M), this.createAxisLabels(o, x, z, r, d), this.updateCaptionsSize(o, x, z, W.y), this.createFacetTitles(o, g), this.updateChartDimensions(o, e, x, z), this.updateLegendSize(l, m, h, c), this.createMainTitle(o, C), this.updateMargins(o);
369
+ render(t, i, s, e, o, f, T, M, d, b, W, h, n, r, g, x, l, m) {
370
+ var u;
371
+ const { xAxis: C, yAxis: E, size: R, title: p, legend: c } = s;
372
+ this.updateChartSizes(R), this.updateViewport(o, e, C, E, x, l, T, M), this.createAxisLabels(o, C, E, x, l), this.updateCaptionsSize(o, C, E, b.y), this.createFacetTitles(o, f), this.updateChartDimensions(o, e, C, E), this.updateLegendSize(c, W, n, r), this.createMainTitle(o, p), this.updateMargins(o);
370
373
  const I = /* @__PURE__ */ v.jsx(ht, { dataFrame: t, children: /* @__PURE__ */ v.jsx(
371
- ft,
374
+ Ct,
372
375
  {
373
376
  settingsId: i,
374
377
  chartSettings: s,
@@ -382,18 +385,18 @@ class ri {
382
385
  legendData: this.legend,
383
386
  columnsCount: this.columnsCount,
384
387
  margins: this.margins,
385
- keyColumn: u,
388
+ keyColumn: d,
386
389
  mainTitle: this.mainTitle,
387
390
  facetTitles: this.facetTitles,
388
391
  captionsSizes: this.captionsSizes,
389
- onlyPositive: W,
390
- layersData: n,
391
- aesGetters: Wt(t, m, c, f),
392
- onTooltipHintSwitch: S,
392
+ onlyPositive: b,
393
+ layersData: h,
394
+ aesGetters: At(t, W, r, g),
395
+ onTooltipHintSwitch: m,
393
396
  discreteAxesLabels: this.discreteAxesLabels
394
397
  }
395
398
  ) });
396
- this.component = I, (p = this.reactRoot) == null || p.render(I);
399
+ this.component = I, (u = this.reactRoot) == null || u.render(I);
397
400
  }
398
401
  renderError(t) {
399
402
  var i;
@@ -401,6 +404,6 @@ class ri {
401
404
  }
402
405
  }
403
406
  export {
404
- ri as default
407
+ ci as default
405
408
  };
406
409
  //# sourceMappingURL=ChartRenderer.js.map