@milaboratories/miplots4 1.0.134 → 1.0.135
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/{discrete/components → common}/BandAxis.d.ts +2 -2
- package/dist/common/BandAxis.d.ts.map +1 -0
- package/dist/{discrete/components → common}/BandAxis.js +3 -3
- package/dist/common/BandAxis.js.map +1 -0
- package/dist/common/ContinuousGrid.d.ts +3 -3
- package/dist/common/ContinuousGrid.d.ts.map +1 -1
- package/dist/common/ContinuousGrid.js.map +1 -1
- package/dist/discrete/ChartRenderer.d.ts.map +1 -1
- package/dist/discrete/ChartRenderer.js +192 -265
- package/dist/discrete/ChartRenderer.js.map +1 -1
- package/dist/discrete/components/Chart.js +1 -1
- package/dist/discrete/components/Chart.js.map +1 -1
- package/dist/discrete/components/Grid.d.ts +3 -3
- package/dist/discrete/components/Grid.d.ts.map +1 -1
- package/dist/discrete/components/Grid.js.map +1 -1
- package/dist/discrete/components/types.d.ts +5 -3
- package/dist/discrete/components/types.d.ts.map +1 -1
- package/dist/discrete/utils/index.d.ts +1 -1
- package/dist/discrete/utils/index.d.ts.map +1 -1
- package/dist/histogram/ChartRenderer.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/node_modules/d3-scale/src/band.js +45 -35
- package/dist/node_modules/d3-scale/src/band.js.map +1 -1
- package/dist/scatterplot/ChartRenderer.d.ts +10 -5
- package/dist/scatterplot/ChartRenderer.d.ts.map +1 -1
- package/dist/scatterplot/ChartRenderer.js +276 -197
- package/dist/scatterplot/ChartRenderer.js.map +1 -1
- package/dist/scatterplot/ScatterplotSettingsImpl.d.ts +5 -3
- package/dist/scatterplot/ScatterplotSettingsImpl.d.ts.map +1 -1
- package/dist/scatterplot/ScatterplotSettingsImpl.js +53 -53
- package/dist/scatterplot/ScatterplotSettingsImpl.js.map +1 -1
- package/dist/scatterplot/components/Chart.d.ts +3 -1
- package/dist/scatterplot/components/Chart.d.ts.map +1 -1
- package/dist/scatterplot/components/Chart.js +23 -19
- package/dist/scatterplot/components/Chart.js.map +1 -1
- package/dist/scatterplot/components/ChartAxis.d.ts +3 -1
- package/dist/scatterplot/components/ChartAxis.d.ts.map +1 -1
- package/dist/scatterplot/components/ChartAxis.js +31 -27
- package/dist/scatterplot/components/ChartAxis.js.map +1 -1
- package/dist/scatterplot/components/ChartLayersData.d.ts.map +1 -1
- package/dist/scatterplot/components/ChartLayersData.js.map +1 -1
- package/dist/scatterplot/components/ChartTooltip.js.map +1 -1
- package/dist/scatterplot/components/ChartTrendsData.d.ts.map +1 -1
- package/dist/scatterplot/components/ChartTrendsData.js +20 -17
- package/dist/scatterplot/components/ChartTrendsData.js.map +1 -1
- package/dist/scatterplot/components/ChartsGroup.d.ts +5 -1
- package/dist/scatterplot/components/ChartsGroup.d.ts.map +1 -1
- package/dist/scatterplot/components/ChartsGroup.js +49 -46
- package/dist/scatterplot/components/ChartsGroup.js.map +1 -1
- package/dist/scatterplot/components/Grid.d.ts +3 -3
- package/dist/scatterplot/components/Grid.d.ts.map +1 -1
- package/dist/scatterplot/components/Grid.js +31 -27
- package/dist/scatterplot/components/Grid.js.map +1 -1
- package/dist/scatterplot/components/types.d.ts +15 -5
- package/dist/scatterplot/components/types.d.ts.map +1 -1
- package/dist/scatterplot/dots.d.ts +2 -2
- package/dist/scatterplot/dots.d.ts.map +1 -1
- package/dist/scatterplot/dots.js.map +1 -1
- package/dist/scatterplot/getLayersData.d.ts +3 -2
- package/dist/scatterplot/getLayersData.d.ts.map +1 -1
- package/dist/scatterplot/getLayersData.js +29 -18
- package/dist/scatterplot/getLayersData.js.map +1 -1
- package/dist/scatterplot/index.d.ts +3 -0
- package/dist/scatterplot/index.d.ts.map +1 -1
- package/dist/scatterplot/index.js +73 -59
- package/dist/scatterplot/index.js.map +1 -1
- package/dist/scatterplot/linearRegression.d.ts +4 -6
- package/dist/scatterplot/linearRegression.d.ts.map +1 -1
- package/dist/scatterplot/linearRegression.js.map +1 -1
- package/dist/scatterplot/utils/isNumericScale.d.ts +6 -0
- package/dist/scatterplot/utils/isNumericScale.d.ts.map +1 -0
- package/dist/scatterplot/utils/isNumericScale.js +11 -0
- package/dist/scatterplot/utils/isNumericScale.js.map +1 -0
- package/dist/scatterplot-umap/ChartRenderer.js +1 -1
- package/dist/scatterplot-umap/ChartRenderer.js.map +1 -1
- package/dist/scatterplot-umap/SettingsImpl.d.ts +7 -4
- package/dist/scatterplot-umap/SettingsImpl.d.ts.map +1 -1
- package/dist/scatterplot-umap/SettingsImpl.js.map +1 -1
- package/dist/scatterplot-umap/components/LowerSVG.js +7 -7
- package/dist/scatterplot-umap/components/LowerSVG.js.map +1 -1
- package/dist/types/bubble.d.ts +12 -12
- package/dist/types/common.d.ts +186 -21
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/common.js +36 -26
- package/dist/types/common.js.map +1 -1
- package/dist/types/dendro.d.ts +22 -22
- package/dist/types/discrete.d.ts +23 -53
- package/dist/types/discrete.d.ts.map +1 -1
- package/dist/types/discrete.js +35 -35
- package/dist/types/discrete.js.map +1 -1
- package/dist/types/heatmap.d.ts +12 -12
- package/dist/types/histogram.d.ts +4 -4
- package/dist/types/scatterplot-umap.d.ts +4 -34
- package/dist/types/scatterplot-umap.d.ts.map +1 -1
- package/dist/types/scatterplot-umap.js +1 -1
- package/dist/types/scatterplot-umap.js.map +1 -1
- package/dist/types/scatterplot.d.ts +186 -32
- package/dist/types/scatterplot.d.ts.map +1 -1
- package/dist/utils/createMultilineDiscreteLabels.d.ts +4 -0
- package/dist/utils/createMultilineDiscreteLabels.d.ts.map +1 -0
- package/dist/utils/createMultilineDiscreteLabels.js +32 -0
- package/dist/utils/createMultilineDiscreteLabels.js.map +1 -0
- package/dist/utils/getFacetRowsColumns.d.ts +3 -0
- package/dist/utils/getFacetRowsColumns.d.ts.map +1 -0
- package/dist/utils/getFacetRowsColumns.js +18 -0
- package/dist/utils/getFacetRowsColumns.js.map +1 -0
- package/dist/utils/measureMultilineDiscreteLabels.d.ts +9 -0
- package/dist/utils/measureMultilineDiscreteLabels.d.ts.map +1 -0
- package/dist/utils/measureMultilineDiscreteLabels.js +63 -0
- package/dist/utils/measureMultilineDiscreteLabels.js.map +1 -0
- package/dist/utils/splitTextByWidth.d.ts.map +1 -0
- package/dist/{discrete/utils → utils}/splitTextByWidth.js +1 -1
- package/dist/utils/splitTextByWidth.js.map +1 -0
- package/package.json +1 -1
- package/dist/discrete/components/BandAxis.d.ts.map +0 -1
- package/dist/discrete/components/BandAxis.js.map +0 -1
- package/dist/discrete/utils/splitTextByWidth.d.ts.map +0 -1
- package/dist/discrete/utils/splitTextByWidth.js.map +0 -1
- package/dist/scatterplot/components/Axis.d.ts +0 -13
- package/dist/scatterplot/components/Axis.d.ts.map +0 -1
- package/dist/scatterplot/components/Axis.js +0 -59
- package/dist/scatterplot/components/Axis.js.map +0 -1
- /package/dist/{discrete/utils → utils}/splitTextByWidth.d.ts +0 -0
|
@@ -1,109 +1,133 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { j as
|
|
5
|
-
import { createRoot as
|
|
6
|
-
import { Error as
|
|
7
|
-
import { DataFrameProvider as
|
|
8
|
-
import { DEFAULT_HEIGHT as X, DEFAULT_WIDTH as
|
|
9
|
-
import { FACET_TITLE_LINE as
|
|
10
|
-
import { splitTextByWidth as
|
|
11
|
-
import { isContinuousAes as
|
|
1
|
+
var st = Object.defineProperty;
|
|
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 b = (a, t, i) => ot(a, typeof t != "symbol" ? t + "" : t, i);
|
|
4
|
+
import { j as v } from "../node_modules/react/jsx-runtime.js";
|
|
5
|
+
import { createRoot as nt } from "../node_modules/react-dom/client.js";
|
|
6
|
+
import { Error as at } from "../common/Error.js";
|
|
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";
|
|
10
|
+
import { splitTextByWidth as V } from "../utils/splitTextByWidth.js";
|
|
11
|
+
import { isContinuousAes as q } from "../types/common.js";
|
|
12
12
|
import "../types/discrete.js";
|
|
13
13
|
import "../types/scatterplot.js";
|
|
14
14
|
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
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import {
|
|
31
|
-
|
|
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";
|
|
26
|
+
import { isContinuousAxis as $ } from "./utils/isNumericScale.js";
|
|
27
|
+
import { createMultilineDiscreteLabels as J } from "../utils/createMultilineDiscreteLabels.js";
|
|
28
|
+
import { measureMultilineDiscreteLabels as k } from "../utils/measureMultilineDiscreteLabels.js";
|
|
29
|
+
import B from "../node_modules/d3-scale/src/linear.js";
|
|
30
|
+
import { point as y } from "../node_modules/d3-scale/src/band.js";
|
|
31
|
+
import K from "../node_modules/d3-scale/src/log.js";
|
|
32
|
+
import xt from "../node_modules/d3-scale/src/ordinal.js";
|
|
33
|
+
import Mt from "../node_modules/d3-scale/src/symlog.js";
|
|
34
|
+
import { sqrt as zt } from "../node_modules/d3-scale/src/pow.js";
|
|
35
|
+
function tt(a, t) {
|
|
36
|
+
if (a === void 0)
|
|
37
|
+
return !0;
|
|
38
|
+
{
|
|
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])
|
|
41
|
+
return !0;
|
|
42
|
+
}
|
|
43
|
+
return !1;
|
|
44
|
+
}
|
|
45
|
+
function bt(a, t, i, s) {
|
|
32
46
|
const e = [];
|
|
33
|
-
return
|
|
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;
|
|
34
48
|
}
|
|
35
|
-
function
|
|
36
|
-
const
|
|
49
|
+
function Et(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));
|
|
37
51
|
return {
|
|
38
|
-
left:
|
|
39
|
-
top:
|
|
40
|
-
bottom:
|
|
41
|
-
right:
|
|
52
|
+
left: n ? C : F,
|
|
53
|
+
top: I === 0 ? 0 : Tt * 2 + I * mt,
|
|
54
|
+
bottom: c ? l + 8 : F,
|
|
55
|
+
right: M ? 0 : F
|
|
42
56
|
};
|
|
43
57
|
}
|
|
44
|
-
function
|
|
58
|
+
function wt(a, t, i) {
|
|
45
59
|
const s = [];
|
|
46
60
|
for (let e = 0; e < t; e++)
|
|
47
|
-
s.push(
|
|
61
|
+
s.push(a.slice(e * i, e * i + i));
|
|
48
62
|
return s;
|
|
49
63
|
}
|
|
50
|
-
function
|
|
51
|
-
const i = Math.floor(
|
|
64
|
+
function Nt(a, t) {
|
|
65
|
+
const i = Math.floor(a / t), s = a - i * t;
|
|
52
66
|
return [i, s];
|
|
53
67
|
}
|
|
54
|
-
function
|
|
55
|
-
const e = i.find((
|
|
68
|
+
function Wt(a, t, i, s) {
|
|
69
|
+
const e = i.find((g) => g.type === "dots"), o = i.find((g) => g.type === "curve");
|
|
56
70
|
return {
|
|
57
|
-
dotShape:
|
|
58
|
-
dotColor:
|
|
59
|
-
dotSize:
|
|
60
|
-
lineShape:
|
|
61
|
-
lineColor:
|
|
62
|
-
trendColor:
|
|
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")
|
|
63
77
|
};
|
|
64
78
|
}
|
|
65
|
-
|
|
79
|
+
const It = Math.cos(Math.PI / 4), At = 5;
|
|
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;
|
|
82
|
+
}
|
|
83
|
+
class ri {
|
|
66
84
|
constructor() {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
top:
|
|
73
|
-
bottom:
|
|
74
|
-
left:
|
|
75
|
-
right:
|
|
85
|
+
b(this, "reactRoot", null);
|
|
86
|
+
b(this, "parentNode", null);
|
|
87
|
+
b(this, "rootNode", null);
|
|
88
|
+
b(this, "component", /* @__PURE__ */ v.jsx(v.Fragment, {}));
|
|
89
|
+
b(this, "margins", {
|
|
90
|
+
top: H,
|
|
91
|
+
bottom: H,
|
|
92
|
+
left: H,
|
|
93
|
+
right: H
|
|
76
94
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
chartWidth:
|
|
95
|
+
b(this, "chartsDimensions", {});
|
|
96
|
+
b(this, "chartSizes", {
|
|
97
|
+
chartWidth: P,
|
|
80
98
|
// width of single chart
|
|
81
99
|
chartHeight: X,
|
|
82
100
|
// height of single chart
|
|
83
|
-
chartsWidth:
|
|
101
|
+
chartsWidth: P,
|
|
84
102
|
// width of all charts in charts row
|
|
85
103
|
chartsHeight: X,
|
|
86
104
|
// width of all charts in charts column, without axes
|
|
87
|
-
totalWidth:
|
|
105
|
+
totalWidth: P,
|
|
88
106
|
// width of all charts in charts row, plus left axis, plus legend
|
|
89
107
|
totalHeight: X
|
|
90
108
|
// width of all charts in charts height, plus bottom axis, plus top title
|
|
91
109
|
});
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
x: { null:
|
|
96
|
-
y: { null:
|
|
110
|
+
b(this, "columnsCount", 1);
|
|
111
|
+
b(this, "rowsCount", 1);
|
|
112
|
+
b(this, "scales", {
|
|
113
|
+
x: { null: B().domain([0, 1]).range([0, P]) },
|
|
114
|
+
y: { null: B().domain([0, 1]).range([X, 0]) }
|
|
97
115
|
});
|
|
98
|
-
|
|
116
|
+
b(this, "captionsSizes", {
|
|
99
117
|
xAxisCaptionsWidth: 30,
|
|
100
|
-
yAxisCaptionsWidth: 100
|
|
118
|
+
yAxisCaptionsWidth: 100,
|
|
119
|
+
bottomAxisCaptionsWidthByRows: [],
|
|
120
|
+
leftAxisCaptionsWidthByColumns: [],
|
|
121
|
+
bottomCaptionsTail: 0,
|
|
122
|
+
leftCaptionsTail: 0
|
|
101
123
|
});
|
|
102
|
-
|
|
124
|
+
b(this, "facetTitles", {});
|
|
103
125
|
// can be multiline
|
|
104
|
-
|
|
126
|
+
b(this, "mainTitle", []);
|
|
105
127
|
// can be multiline
|
|
106
|
-
|
|
128
|
+
b(this, "discreteAxesLabels", { x: {}, y: {} });
|
|
129
|
+
// only for discrete axes, by facets, can be multiline
|
|
130
|
+
b(this, "legend", { width: 0, height: 0, items: [] });
|
|
107
131
|
}
|
|
108
132
|
clear() {
|
|
109
133
|
var t;
|
|
@@ -113,134 +137,188 @@ class Zt {
|
|
|
113
137
|
});
|
|
114
138
|
}
|
|
115
139
|
init(t) {
|
|
116
|
-
this.parentNode === null && (this.parentNode = t, this.rootNode = document.createElement("div"), this.parentNode.appendChild(this.rootNode), this.reactRoot =
|
|
140
|
+
this.parentNode === null && (this.parentNode = t, this.rootNode = document.createElement("div"), this.parentNode.appendChild(this.rootNode), this.reactRoot = nt(this.rootNode));
|
|
117
141
|
}
|
|
118
142
|
updateChartSizes(t) {
|
|
119
143
|
this.chartSizes.chartWidth = t.width, this.chartSizes.chartHeight = t.height;
|
|
120
144
|
}
|
|
121
145
|
updateChartDimensions(t, i, s, e) {
|
|
122
|
-
const { chartWidth: o, chartHeight:
|
|
123
|
-
let
|
|
124
|
-
|
|
125
|
-
|
|
146
|
+
const { chartWidth: o, chartHeight: g } = this.chartSizes;
|
|
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 = bt(c, t.length, this.columnsCount, this.rowsCount), S = Et(
|
|
126
151
|
s,
|
|
127
152
|
e,
|
|
128
153
|
this.captionsSizes,
|
|
129
|
-
|
|
154
|
+
u[f],
|
|
130
155
|
this.facetTitles,
|
|
131
|
-
|
|
156
|
+
d,
|
|
157
|
+
f,
|
|
158
|
+
r,
|
|
159
|
+
r === this.columnsCount - 1,
|
|
132
160
|
i
|
|
133
|
-
),
|
|
134
|
-
return
|
|
135
|
-
left:
|
|
136
|
-
top:
|
|
137
|
-
chartEdgeSides:
|
|
138
|
-
padding:
|
|
139
|
-
inner: { width: o, height:
|
|
140
|
-
outer: { width:
|
|
141
|
-
},
|
|
161
|
+
), x = o + S.left + S.right, z = g + S.top + S.bottom;
|
|
162
|
+
return n[h] = {
|
|
163
|
+
left: T,
|
|
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;
|
|
142
170
|
}, {});
|
|
143
171
|
const W = Math.max(
|
|
144
|
-
...t.map((
|
|
145
|
-
),
|
|
146
|
-
...t.map((
|
|
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)
|
|
147
175
|
);
|
|
148
|
-
this.chartSizes.chartsWidth = W, this.chartSizes.chartsHeight =
|
|
176
|
+
this.chartSizes.chartsWidth = W, this.chartSizes.chartsHeight = m;
|
|
149
177
|
}
|
|
150
|
-
updateViewport(t, i, s, e, o,
|
|
151
|
-
const
|
|
152
|
-
this.columnsCount = i.nRows ? Math.ceil(
|
|
153
|
-
let [
|
|
154
|
-
const
|
|
155
|
-
const
|
|
156
|
-
return
|
|
157
|
-
}, {}),
|
|
158
|
-
let
|
|
159
|
-
t.forEach((
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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: E, maxX: w, maxY: N } = I;
|
|
184
|
+
return n = Math.min(n, p), c = Math.min(c, E), h = Math.max(h, w), f = Math.max(f, N), C[l] = { minX: p, maxX: w, minY: E, maxY: N }, C;
|
|
185
|
+
}, {}), d = {}, S = {};
|
|
186
|
+
let x = !1, z = !1;
|
|
187
|
+
t.forEach((C) => {
|
|
188
|
+
let l;
|
|
189
|
+
if (!$(s))
|
|
190
|
+
l = y().range([0, this.chartSizes.chartWidth]).domain(o.keys ?? []).padding(0.5);
|
|
191
|
+
else {
|
|
192
|
+
l = s.scale === "log" ? K() : B();
|
|
193
|
+
const p = r[C];
|
|
194
|
+
let E = s.lowerValue ? Number(s.lowerValue) : i.sharedX ? n : p.minX, w = s.upperValue ? Number(s.upperValue) : i.sharedX ? h : p.maxX;
|
|
195
|
+
if (typeof s.symmetricRange < "u") {
|
|
196
|
+
const R = s.symmetricRange;
|
|
197
|
+
if (R >= E && R <= w) {
|
|
198
|
+
const Y = Math.max(R - E, w - R);
|
|
199
|
+
E = R - Y, w = R + Y;
|
|
200
|
+
}
|
|
167
201
|
}
|
|
202
|
+
const N = [0, this.chartSizes.chartWidth], A = l.copy().domain([E, w]).range([G.LEFT, this.chartSizes.chartWidth - G.RIGHT]);
|
|
203
|
+
l.domain([A.invert(0), A.invert(this.chartSizes.chartWidth)]).range(N).nice();
|
|
168
204
|
}
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
const H = this.scales.x[p];
|
|
172
|
-
if (H === void 0)
|
|
173
|
-
l = !0;
|
|
174
|
-
else if (!l) {
|
|
175
|
-
const M = H.domain(), x = H.range();
|
|
176
|
-
(M[0] !== h.domain()[0] || M[1] !== h.domain()[1] || x[0] !== h.range()[0] || x[1] !== h.range()[1]) && (l = !0);
|
|
177
|
-
}
|
|
178
|
-
E[p] = h;
|
|
205
|
+
const I = this.scales.x[C];
|
|
206
|
+
d[C] = l, x = x || tt(I, l);
|
|
179
207
|
});
|
|
180
|
-
const
|
|
181
|
-
const
|
|
182
|
-
return
|
|
183
|
-
(
|
|
184
|
-
const
|
|
185
|
-
return
|
|
208
|
+
const L = t.reduce((C, l) => {
|
|
209
|
+
const I = M ? M[l] : [];
|
|
210
|
+
return C[l] = I.reduce(
|
|
211
|
+
(p, E) => {
|
|
212
|
+
const w = E.bounded ? E.xBounds : this.scales.x[l].domain(), N = E.getInterval(w[0]), A = E.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;
|
|
186
214
|
},
|
|
187
215
|
{ minY: 1 / 0, maxY: -1 / 0 }
|
|
188
|
-
),
|
|
216
|
+
), c = Math.min(c, C[l].minY), f = Math.max(f, C[l].maxY), C;
|
|
189
217
|
}, {});
|
|
190
|
-
t.forEach((
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
218
|
+
t.forEach((C) => {
|
|
219
|
+
let l;
|
|
220
|
+
if (!$(e))
|
|
221
|
+
l = y().range([this.chartSizes.chartHeight, 0]).domain(g.keys ?? []).padding(0.5);
|
|
222
|
+
else {
|
|
223
|
+
l = e.scale === "log" ? K() : B();
|
|
224
|
+
const p = r[C], E = L[C];
|
|
225
|
+
let w = e.lowerValue ? Number(e.lowerValue) : i.sharedY ? c : Math.min(p.minY, E.minY), N = e.upperValue ? Number(e.upperValue) : i.sharedY ? f : Math.max(p.maxY, E.maxY);
|
|
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;
|
|
231
|
+
}
|
|
198
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();
|
|
199
235
|
}
|
|
200
|
-
const I =
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if (M === void 0)
|
|
204
|
-
f = !0;
|
|
205
|
-
else if (!f) {
|
|
206
|
-
const x = M.domain(), R = M.range();
|
|
207
|
-
(x[0] !== h.domain()[0] || x[1] !== h.domain()[1] || R[0] !== h.range()[0] || R[1] !== h.range()[1]) && (f = !0);
|
|
208
|
-
}
|
|
209
|
-
m[p] = h;
|
|
210
|
-
}), l && (this.scales.x = E), f && (this.scales.y = m);
|
|
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);
|
|
211
239
|
}
|
|
212
|
-
updateCaptionsSize(t) {
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
return Math.max(...o.map((c) => i.getTextWidth(c)));
|
|
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)));
|
|
217
244
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
245
|
+
let T = 0, M = 0, u = [], W = [], m = 0, n = 0;
|
|
246
|
+
if (i.scale === "discrete") {
|
|
247
|
+
const h = k(
|
|
248
|
+
t,
|
|
249
|
+
this.rowsCount,
|
|
250
|
+
this.columnsCount,
|
|
251
|
+
i.labelsPosition ?? "center",
|
|
252
|
+
this.discreteAxesLabels.x,
|
|
253
|
+
"vertical",
|
|
254
|
+
this.scales.x
|
|
255
|
+
);
|
|
256
|
+
T = h.xTail, u = h.axisCaptionsWidthByRows;
|
|
257
|
+
} else
|
|
258
|
+
m = 20;
|
|
259
|
+
if (s.scale === "discrete") {
|
|
260
|
+
const h = k(
|
|
261
|
+
t,
|
|
262
|
+
this.rowsCount,
|
|
263
|
+
this.columnsCount,
|
|
264
|
+
s.labelsPosition ?? "center",
|
|
265
|
+
this.discreteAxesLabels.y,
|
|
266
|
+
"horizontal",
|
|
267
|
+
this.scales.y
|
|
268
|
+
);
|
|
269
|
+
M = h.yTail, W = h.axisCaptionsWidthByColumns;
|
|
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)));
|
|
274
|
+
});
|
|
275
|
+
this.captionsSizes = {
|
|
276
|
+
xAxisCaptionsWidth: it(m, i),
|
|
277
|
+
yAxisCaptionsWidth: it(n, s),
|
|
278
|
+
bottomAxisCaptionsWidthByRows: u,
|
|
279
|
+
leftAxisCaptionsWidthByColumns: W,
|
|
280
|
+
bottomCaptionsTail: T,
|
|
281
|
+
leftCaptionsTail: M
|
|
224
282
|
};
|
|
225
283
|
}
|
|
226
284
|
createMainTitle(t, i) {
|
|
227
285
|
const s = this.chartsDimensions[t[0]], e = this.chartsDimensions[t[t.length - 1]];
|
|
228
|
-
this.mainTitle =
|
|
286
|
+
this.mainTitle = V(
|
|
229
287
|
i.name,
|
|
230
288
|
this.chartSizes.chartsWidth - s.padding.left - e.padding.right,
|
|
231
289
|
20
|
|
232
290
|
);
|
|
233
291
|
}
|
|
234
292
|
createFacetTitles(t, i) {
|
|
235
|
-
this.facetTitles = t.reduce((s, e, o) => (i[o].length === 1 && i[o][0] === "null" ? s[e] = [] : s[e] =
|
|
293
|
+
this.facetTitles = t.reduce((s, e, o) => (i[o].length === 1 && i[o][0] === "null" ? s[e] = [] : s[e] = V(i[o].join(", "), this.chartSizes.chartWidth, 14), s), {});
|
|
294
|
+
}
|
|
295
|
+
createAxisLabels(t, i, s, e, o) {
|
|
296
|
+
this.discreteAxesLabels = {
|
|
297
|
+
x: i.scale !== "discrete" ? {} : J(
|
|
298
|
+
t,
|
|
299
|
+
(i == null ? void 0 : i.labelsPosition) ?? "center",
|
|
300
|
+
e.labels,
|
|
301
|
+
!1,
|
|
302
|
+
"vertical",
|
|
303
|
+
this.scales.x
|
|
304
|
+
),
|
|
305
|
+
y: s.scale !== "discrete" ? {} : J(
|
|
306
|
+
t,
|
|
307
|
+
s.labelsPosition ?? "center",
|
|
308
|
+
o.labels,
|
|
309
|
+
!1,
|
|
310
|
+
"horizontal",
|
|
311
|
+
this.scales.y
|
|
312
|
+
)
|
|
313
|
+
};
|
|
236
314
|
}
|
|
237
|
-
updateMargins() {
|
|
238
|
-
const
|
|
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]];
|
|
239
317
|
this.margins = {
|
|
240
|
-
top: Math.max(
|
|
241
|
-
bottom:
|
|
242
|
-
left:
|
|
243
|
-
right: this.legend.width +
|
|
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
|
|
244
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;
|
|
245
323
|
}
|
|
246
324
|
updateLegendSize(t, i, s, e) {
|
|
@@ -248,49 +326,49 @@ class Zt {
|
|
|
248
326
|
this.legend = { width: 0, height: 0, items: [] };
|
|
249
327
|
return;
|
|
250
328
|
}
|
|
251
|
-
const o = [],
|
|
252
|
-
if (s.forEach((
|
|
253
|
-
const n = i[
|
|
329
|
+
const o = [], g = { width: 0, height: 0, left: 0, top: 0 };
|
|
330
|
+
if (s.forEach((m) => {
|
|
331
|
+
const n = i[m.value];
|
|
254
332
|
if (n.usedAes.length === 0 || !n.aesMap)
|
|
255
333
|
return;
|
|
256
|
-
if (n.values.length >
|
|
334
|
+
if (n.values.length > lt) {
|
|
257
335
|
console.warn(`Too many values for discrete legend (${n.values.length})`);
|
|
258
336
|
return;
|
|
259
337
|
}
|
|
260
|
-
const
|
|
261
|
-
n.values.forEach((
|
|
262
|
-
|
|
263
|
-
(
|
|
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);
|
|
264
342
|
});
|
|
265
343
|
});
|
|
266
|
-
const
|
|
267
|
-
o.push({ ...
|
|
268
|
-
}), e.forEach((
|
|
269
|
-
if (
|
|
270
|
-
const { domain: n, range:
|
|
271
|
-
o.push({ ...
|
|
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 });
|
|
272
350
|
}
|
|
273
|
-
if (
|
|
274
|
-
const { columnName: n, domain:
|
|
275
|
-
o.push({ ...
|
|
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 });
|
|
276
354
|
}
|
|
277
355
|
}), !o.length) {
|
|
278
356
|
this.legend = { width: 0, height: 0, items: [] };
|
|
279
357
|
return;
|
|
280
358
|
}
|
|
281
|
-
const
|
|
359
|
+
const T = dt(o, this.chartSizes.chartHeight), M = T[T.length - 1], u = M.left + M.width + Ct, W = this.chartSizes.chartHeight;
|
|
282
360
|
this.legend = {
|
|
283
|
-
width:
|
|
284
|
-
height:
|
|
285
|
-
items:
|
|
361
|
+
width: u,
|
|
362
|
+
height: W,
|
|
363
|
+
items: T
|
|
286
364
|
};
|
|
287
365
|
}
|
|
288
|
-
render(t, i, s, e, o,
|
|
289
|
-
var
|
|
290
|
-
const { xAxis:
|
|
291
|
-
this.updateChartSizes(
|
|
292
|
-
const
|
|
293
|
-
|
|
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);
|
|
370
|
+
const I = /* @__PURE__ */ v.jsx(ht, { dataFrame: t, children: /* @__PURE__ */ v.jsx(
|
|
371
|
+
ft,
|
|
294
372
|
{
|
|
295
373
|
settingsId: i,
|
|
296
374
|
chartSettings: s,
|
|
@@ -299,29 +377,30 @@ class Zt {
|
|
|
299
377
|
chartSizes: this.chartSizes,
|
|
300
378
|
chartsDimensions: this.chartsDimensions,
|
|
301
379
|
scales: this.scales,
|
|
302
|
-
groupedDots:
|
|
303
|
-
trendsData:
|
|
380
|
+
groupedDots: T,
|
|
381
|
+
trendsData: M,
|
|
304
382
|
legendData: this.legend,
|
|
305
383
|
columnsCount: this.columnsCount,
|
|
306
384
|
margins: this.margins,
|
|
307
|
-
keyColumn:
|
|
385
|
+
keyColumn: u,
|
|
308
386
|
mainTitle: this.mainTitle,
|
|
309
387
|
facetTitles: this.facetTitles,
|
|
310
388
|
captionsSizes: this.captionsSizes,
|
|
311
|
-
onlyPositive:
|
|
389
|
+
onlyPositive: W,
|
|
312
390
|
layersData: n,
|
|
313
|
-
aesGetters:
|
|
314
|
-
onTooltipHintSwitch:
|
|
391
|
+
aesGetters: Wt(t, m, c, f),
|
|
392
|
+
onTooltipHintSwitch: S,
|
|
393
|
+
discreteAxesLabels: this.discreteAxesLabels
|
|
315
394
|
}
|
|
316
395
|
) });
|
|
317
|
-
this.component =
|
|
396
|
+
this.component = I, (p = this.reactRoot) == null || p.render(I);
|
|
318
397
|
}
|
|
319
398
|
renderError(t) {
|
|
320
399
|
var i;
|
|
321
|
-
(i = this.reactRoot) == null || i.render(/* @__PURE__ */
|
|
400
|
+
(i = this.reactRoot) == null || i.render(/* @__PURE__ */ v.jsx(at, { message: t }));
|
|
322
401
|
}
|
|
323
402
|
}
|
|
324
403
|
export {
|
|
325
|
-
|
|
404
|
+
ri as default
|
|
326
405
|
};
|
|
327
406
|
//# sourceMappingURL=ChartRenderer.js.map
|