@milaboratories/miplots4 1.0.159 → 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.
- package/dist/DataFrame.d.ts +3 -3
- package/dist/DataFrame.js +3 -3
- package/dist/DataFrame.js.map +1 -1
- package/dist/bubble/ChartRenderer.js +55 -55
- package/dist/bubble/ChartRenderer.js.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +9 -7
- package/dist/constants.js.map +1 -1
- package/dist/discrete/layers/stackedBar.js.map +1 -1
- package/dist/heatmap/ChartRenderer.js +184 -181
- package/dist/heatmap/ChartRenderer.js.map +1 -1
- package/dist/scatterplot/ChartRenderer.js +179 -176
- package/dist/scatterplot/ChartRenderer.js.map +1 -1
- package/dist/scatterplot/dots.js +20 -20
- package/dist/scatterplot/dots.js.map +1 -1
- package/dist/scatterplot-umap/ChartRenderer.js +168 -165
- package/dist/scatterplot-umap/ChartRenderer.js.map +1 -1
- package/dist/scatterplot-umap/index.js +15 -15
- package/dist/scatterplot-umap/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -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
|
|
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
|
|
9
|
-
import { FACET_TITLE_LINE as
|
|
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
|
|
19
|
-
import { getContinuousColorScale as
|
|
20
|
-
import { getContinuousLegendTicks as
|
|
21
|
-
import { TextMeasurer as
|
|
22
|
-
import { ChartsGroup as
|
|
23
|
-
import { MIN_MARGIN as
|
|
24
|
-
import { createAesGetter as
|
|
25
|
-
import { getTicksAndFormat as
|
|
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
|
|
33
|
-
import
|
|
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((
|
|
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
|
|
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
|
|
50
|
-
const
|
|
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:
|
|
53
|
-
top: I === 0 ? 0 :
|
|
54
|
-
bottom:
|
|
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
|
|
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
|
|
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
|
|
69
|
-
const e = i.find((
|
|
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:
|
|
72
|
-
dotColor:
|
|
73
|
-
dotSize:
|
|
74
|
-
lineShape:
|
|
75
|
-
lineColor:
|
|
76
|
-
trendColor:
|
|
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
|
|
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 *
|
|
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
|
|
83
|
+
class ci {
|
|
84
84
|
constructor() {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
top:
|
|
91
|
-
bottom:
|
|
92
|
-
left:
|
|
93
|
-
right:
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
chartWidth:
|
|
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:
|
|
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:
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
x: { null: B().domain([0, 1]).range([0,
|
|
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
|
-
|
|
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
|
-
|
|
124
|
+
S(this, "facetTitles", {});
|
|
125
125
|
// can be multiline
|
|
126
|
-
|
|
126
|
+
S(this, "mainTitle", []);
|
|
127
127
|
// can be multiline
|
|
128
|
-
|
|
128
|
+
S(this, "discreteAxesLabels", { x: {}, y: {} });
|
|
129
129
|
// only for discrete axes, by facets, can be multiline
|
|
130
|
-
|
|
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:
|
|
146
|
+
const { chartWidth: o, chartHeight: f } = this.chartSizes;
|
|
147
147
|
let T = 0, M = 0;
|
|
148
|
-
const
|
|
149
|
-
this.chartsDimensions = t.reduce((
|
|
150
|
-
const [
|
|
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
|
-
|
|
154
|
+
d[g],
|
|
155
155
|
this.facetTitles,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
156
|
+
l,
|
|
157
|
+
g,
|
|
158
|
+
x,
|
|
159
|
+
x === this.columnsCount - 1,
|
|
160
160
|
i
|
|
161
|
-
),
|
|
162
|
-
return n
|
|
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:
|
|
166
|
-
padding:
|
|
167
|
-
inner: { width: o, height:
|
|
168
|
-
outer: { width:
|
|
169
|
-
}, T +=
|
|
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
|
|
172
|
-
...t.map((
|
|
173
|
-
),
|
|
174
|
-
...t.map((
|
|
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 =
|
|
176
|
+
this.chartSizes.chartsWidth = b, this.chartSizes.chartsHeight = W;
|
|
177
177
|
}
|
|
178
|
-
updateViewport(t, i, s, e, o,
|
|
179
|
-
const
|
|
180
|
-
this.columnsCount = i.nRows ? Math.ceil(
|
|
181
|
-
let [
|
|
182
|
-
const
|
|
183
|
-
const I = T[
|
|
184
|
-
return
|
|
185
|
-
}, {}),
|
|
186
|
-
let
|
|
187
|
-
t.forEach((
|
|
188
|
-
let
|
|
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
|
-
|
|
190
|
+
c = y().range([0, this.chartSizes.chartWidth]).domain(o.keys ?? []).padding(0.5);
|
|
191
191
|
else {
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
let
|
|
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
|
|
197
|
-
if (
|
|
198
|
-
const
|
|
199
|
-
|
|
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
|
|
203
|
-
|
|
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[
|
|
206
|
-
|
|
205
|
+
const I = this.scales.x[p];
|
|
206
|
+
l[p] = c, C = C || tt(I, c);
|
|
207
207
|
});
|
|
208
|
-
const
|
|
209
|
-
const I = M ? M[
|
|
210
|
-
return
|
|
211
|
-
(
|
|
212
|
-
const
|
|
213
|
-
return
|
|
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
|
-
),
|
|
216
|
+
), r = Math.min(r, p[c].minY), g = Math.max(g, p[c].maxY), p;
|
|
217
217
|
}, {});
|
|
218
|
-
t.forEach((
|
|
219
|
-
let
|
|
218
|
+
t.forEach((p) => {
|
|
219
|
+
let c;
|
|
220
220
|
if (!$(e))
|
|
221
|
-
|
|
221
|
+
c = y().range([this.chartSizes.chartHeight, 0]).domain(f.keys ?? []).padding(0.5);
|
|
222
222
|
else {
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
let
|
|
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
|
|
228
|
-
if (
|
|
229
|
-
const j = Math.max(
|
|
230
|
-
|
|
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],
|
|
234
|
-
|
|
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[
|
|
237
|
-
|
|
238
|
-
}),
|
|
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
|
|
242
|
-
function
|
|
243
|
-
return Math.max(...
|
|
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,
|
|
245
|
+
let T = 0, M = 0, d = [], b = [], W = 0, h = 0;
|
|
246
246
|
if (i.scale === "discrete") {
|
|
247
|
-
const
|
|
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 =
|
|
256
|
+
T = n.xTail, d = n.axisCaptionsWidthByRows;
|
|
257
257
|
} else
|
|
258
|
-
|
|
258
|
+
W = 20;
|
|
259
259
|
if (s.scale === "discrete") {
|
|
260
|
-
const
|
|
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 =
|
|
269
|
+
M = n.yTail, b = n.axisCaptionsWidthByColumns;
|
|
270
270
|
} else
|
|
271
|
-
Object.values(this.scales.y).forEach((
|
|
272
|
-
const { ticks:
|
|
273
|
-
|
|
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(
|
|
277
|
-
yAxisCaptionsWidth: it(
|
|
278
|
-
bottomAxisCaptionsWidthByRows:
|
|
279
|
-
leftAxisCaptionsWidthByColumns:
|
|
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 +
|
|
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,
|
|
319
|
-
bottom: Math.max(
|
|
320
|
-
left: Math.max(
|
|
321
|
-
right: this.legend.width +
|
|
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 = [],
|
|
330
|
-
|
|
331
|
-
|
|
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 >
|
|
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
|
|
339
|
-
n.values.forEach((
|
|
340
|
-
|
|
341
|
-
(
|
|
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
|
|
345
|
-
o.push({ ...
|
|
346
|
-
}), e.forEach((
|
|
347
|
-
if (
|
|
348
|
-
const { domain: n, range:
|
|
349
|
-
o.push({ ...
|
|
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 (
|
|
352
|
-
const { columnName: n, domain:
|
|
353
|
-
o.push({ ...
|
|
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
|
|
362
|
+
const d = ut(o, M, T), b = d[d.length - 1], W = b.left + b.width + xt;
|
|
360
363
|
this.legend = {
|
|
361
|
-
width:
|
|
362
|
-
height:
|
|
363
|
-
items:
|
|
364
|
+
width: W,
|
|
365
|
+
height: M,
|
|
366
|
+
items: d
|
|
364
367
|
};
|
|
365
368
|
}
|
|
366
|
-
render(t, i, s, e, o,
|
|
367
|
-
var
|
|
368
|
-
const { xAxis:
|
|
369
|
-
this.updateChartSizes(
|
|
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
|
-
|
|
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:
|
|
388
|
+
keyColumn: d,
|
|
386
389
|
mainTitle: this.mainTitle,
|
|
387
390
|
facetTitles: this.facetTitles,
|
|
388
391
|
captionsSizes: this.captionsSizes,
|
|
389
|
-
onlyPositive:
|
|
390
|
-
layersData:
|
|
391
|
-
aesGetters:
|
|
392
|
-
onTooltipHintSwitch:
|
|
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, (
|
|
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
|
-
|
|
407
|
+
ci as default
|
|
405
408
|
};
|
|
406
409
|
//# sourceMappingURL=ChartRenderer.js.map
|