@milaboratories/miplots4 1.0.164 → 1.0.165
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/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/scatterplot-umap/ChartRenderer.d.ts +3 -2
- package/dist/scatterplot-umap/ChartRenderer.js +166 -161
- package/dist/scatterplot-umap/ChartRenderer.js.map +1 -1
- package/dist/scatterplot-umap/components/Lasso.js +49 -49
- package/dist/scatterplot-umap/components/Lasso.js.map +1 -1
- package/dist/scatterplot-umap/constants.d.ts +6 -5
- package/dist/scatterplot-umap/constants.js +12 -11
- package/dist/scatterplot-umap/constants.js.map +1 -1
- package/dist/scatterplot-umap/index.d.ts +1 -0
- package/dist/scatterplot-umap/index.js +91 -81
- package/dist/scatterplot-umap/index.js.map +1 -1
- package/dist/types/common.d.ts +1 -0
- package/dist/types/common.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import { DataByColumns } from './DataFrame';
|
|
|
3
3
|
import { MiPlots } from './MiPlots';
|
|
4
4
|
import { BubbleSettings, DendroSettings, DiscreteSettings, ErrorInfo, ErrorInfoUnknown, HeatmapSettings, HistogramSettings, ScatterplotSettings, ScatterplotUmapSettings, Settings, AxisSettingsContinuous, AxisSettingsDiscrete } from './types';
|
|
5
5
|
import { LassoControlsState, Polygon } from './scatterplot-umap/types';
|
|
6
|
-
import {
|
|
7
|
-
export { BubbleSettings, ChartInterface, DataByColumns, DendroSettings, DiscreteSettings, HeatmapSettings, HistogramSettings, MiPlots, ScatterplotSettings, ScatterplotUmapSettings, Settings, AxisSettingsDiscrete, AxisSettingsContinuous,
|
|
6
|
+
import { SCATTERPLOT_CONTROLS_EVENTS } from './scatterplot-umap/constants';
|
|
7
|
+
export { BubbleSettings, ChartInterface, DataByColumns, DendroSettings, DiscreteSettings, HeatmapSettings, HistogramSettings, MiPlots, ScatterplotSettings, ScatterplotUmapSettings, Settings, AxisSettingsDiscrete, AxisSettingsContinuous, SCATTERPLOT_CONTROLS_EVENTS, LassoControlsState, Polygon, ErrorInfo, ErrorInfoUnknown };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { MiPlots as
|
|
2
|
-
import {
|
|
1
|
+
import { MiPlots as r } from "./MiPlots.js";
|
|
2
|
+
import { SCATTERPLOT_CONTROLS_EVENTS as E } from "./scatterplot-umap/constants.js";
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
r as MiPlots,
|
|
5
|
+
E as SCATTERPLOT_CONTROLS_EVENTS
|
|
6
6
|
};
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -53,14 +53,15 @@ declare class ChartRenderer {
|
|
|
53
53
|
createMainTitle(title: ScatterplotUmapSettingsImpl['chartSettings']['title']): void;
|
|
54
54
|
updateMargins(xAxis: ScatterplotUmapSettingsImpl['chartSettings']['xAxis'], yAxis: ScatterplotUmapSettingsImpl['chartSettings']['yAxis']): void;
|
|
55
55
|
updateLegendSize(legend: ScatterplotUmapSettingsImpl['chartSettings']['legend'], legendLabels: ScatterplotUmapLegendInfo, grouping: ColumnName[], layers: ScatterplotUmapLayer[]): void;
|
|
56
|
-
initSettings(dots: Dot[], chartSettings: ScatterplotUmapSettingsImpl['chartSettings'], dotExtents: DotsExtents, legendInfo: ScatterplotUmapLegendInfo, layers: ScatterplotUmapSettingsImpl['layers'], grouping: ColumnName[]): void;
|
|
56
|
+
initSettings(dots: Dot[], chartSettings: ScatterplotUmapSettingsImpl['chartSettings'], dotExtents: DotsExtents, legendInfo: ScatterplotUmapLegendInfo, layers: ScatterplotUmapSettingsImpl['layers'], grouping: ColumnName[], onZoomChange: (v: boolean) => void): void;
|
|
57
|
+
resetZoom(xAxis: ScatterplotUmapSettingsImpl['chartSettings']['xAxis'], yAxis: ScatterplotUmapSettingsImpl['chartSettings']['yAxis'], dotsExtents?: DotsExtents): void;
|
|
57
58
|
updateAes(legendInfo: ScatterplotUmapLegendInfo, layers: ScatterplotUmapSettingsImpl['layers']): void;
|
|
58
59
|
updatePointSize(): void;
|
|
59
60
|
updateByLasso(): void;
|
|
60
61
|
createQuadtree(dots: Dot[]): KDBush;
|
|
61
62
|
getClosestDot(_x: number, _y: number): Dot | null;
|
|
62
63
|
updateDots(dots: Dot[]): void;
|
|
63
|
-
render(dataFrame: DataFrame, settingsId: string, chartSettings: ScatterplotUmapSettingsImpl['chartSettings'], keyColumn: ColumnName | null, dots: Dot[], dotExtents: DotsExtents, dotsByGrouping: Record<string, Dot[]>, layers: ScatterplotUmapSettingsImpl['layers'], legendInfo: ScatterplotUmapLegendInfo, grouping: ColumnName[], onPolygonUpdateOutside: ScatterplotEventHandlers['onPolygonUpdate'], onTooltipHintSwitch: (v: boolean) => void, onLassoControlsStateUpdate: (v: LassoControlsState) => void): void;
|
|
64
|
+
render(dataFrame: DataFrame, settingsId: string, chartSettings: ScatterplotUmapSettingsImpl['chartSettings'], keyColumn: ColumnName | null, dots: Dot[], dotExtents: DotsExtents, dotsByGrouping: Record<string, Dot[]>, layers: ScatterplotUmapSettingsImpl['layers'], legendInfo: ScatterplotUmapLegendInfo, grouping: ColumnName[], onPolygonUpdateOutside: ScatterplotEventHandlers['onPolygonUpdate'], onTooltipHintSwitch: (v: boolean) => void, onLassoControlsStateUpdate: (v: LassoControlsState) => void, onZoomChange: (v: boolean) => void): void;
|
|
64
65
|
renderWebglLayer(): void;
|
|
65
66
|
onPolygonUpdate: (p: Polygon[]) => void;
|
|
66
67
|
renderSvgLayer(): void;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
var k = Object.defineProperty;
|
|
2
|
-
var X = (
|
|
3
|
-
var h = (
|
|
4
|
-
import { j as
|
|
2
|
+
var X = (y, t, e) => t in y ? k(y, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : y[t] = e;
|
|
3
|
+
var h = (y, t, e) => X(y, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { j as N } from "../_virtual/jsx-runtime.js";
|
|
5
5
|
import K from "../node_modules/.pnpm/@d3fc_d3fc-chart@5.1.9_d3-array@3.2.4_d3-path@3.1.0_d3-scale-chromatic@3.1.0_d3-scale@4.0.2_d_kyhwsugamw24x7v3obvyiw5jfe/node_modules/@d3fc/d3fc-chart/src/cartesian.js";
|
|
6
6
|
import { seriesWebglPoint as Y, seriesSvgMulti as j, seriesWebglMulti as q } from "@d3fc/d3fc-series";
|
|
7
7
|
import $ from "../node_modules/.pnpm/d3-zoom@3.0.0/node_modules/d3-zoom/src/zoom.js";
|
|
8
|
-
import "../node_modules/.pnpm/d3-zoom@3.0.0/node_modules/d3-zoom/src/transform.js";
|
|
9
|
-
import { c as
|
|
8
|
+
import { identity as Q } from "../node_modules/.pnpm/d3-zoom@3.0.0/node_modules/d3-zoom/src/transform.js";
|
|
9
|
+
import { c as Z } from "../_virtual/client.js";
|
|
10
10
|
import { Error as J } from "../common/Error.js";
|
|
11
|
-
import { BLACK as A, DEFAULT_HEIGHT as E, DEFAULT_WIDTH as w, TITLE_LINE_HEIGHT as
|
|
12
|
-
import { splitTextByWidth as
|
|
13
|
-
import { MIN_MARGIN as
|
|
11
|
+
import { BLACK as A, DEFAULT_HEIGHT as E, DEFAULT_WIDTH as w, TITLE_LINE_HEIGHT as tt, MIN_LEGEND_GRADIENT_HEIGHT as et, MAX_LEGEND_GRADIENT_HEIGHT as it, MAX_SHOWN_UNIQUE_VALUES_IN_LABELS as st, TITLE_MARGIN as ot } from "../constants.js";
|
|
12
|
+
import { splitTextByWidth as at } from "../utils/splitTextByWidth.js";
|
|
13
|
+
import { MIN_MARGIN as T, DEFAULT_DOT_AES as P } from "../scatterplot/constants.js";
|
|
14
14
|
import { createAesGetter as M } from "../scatterplot/utils/createAesGetter.js";
|
|
15
|
-
import { getTicksAndFormat as
|
|
16
|
-
import { createLabelPositioner as
|
|
15
|
+
import { getTicksAndFormat as nt } from "../scatterplot/utils/getTicksAndFormat.js";
|
|
16
|
+
import { createLabelPositioner as rt } from "../scatterplot/utils/getVisibleLabels.js";
|
|
17
17
|
import { isContinuousAes as R } from "../types/common.js";
|
|
18
18
|
import "../types/discrete.js";
|
|
19
19
|
import "../types/scatterplot.js";
|
|
@@ -21,48 +21,48 @@ import "../types/heatmap.js";
|
|
|
21
21
|
import "../types/dendro.js";
|
|
22
22
|
import "../types/histogram.js";
|
|
23
23
|
import "../types/bubble.js";
|
|
24
|
-
import { getContinuousColorScale as
|
|
25
|
-
import { getContinuousLegendTicks as
|
|
24
|
+
import { getContinuousColorScale as lt } from "../utils/getContinuousColorScale.js";
|
|
25
|
+
import { getContinuousLegendTicks as ht } from "../utils/getContinuousLegendTicks.js";
|
|
26
26
|
import { TextMeasurer as I } from "../utils/TextMeasurer/TextMeasurer.js";
|
|
27
|
-
import { SVGLayer as
|
|
28
|
-
import { PADDINGS as D, TITLE_LINE as _, LEGEND_OFFSET as
|
|
27
|
+
import { SVGLayer as ct } from "./components/SVGLayer.js";
|
|
28
|
+
import { PADDINGS as D, TITLE_LINE as _, LEGEND_OFFSET as dt } from "./constants.js";
|
|
29
29
|
import "../node_modules/.pnpm/@d3fc_d3fc-webgl@3.2.1_d3-scale@4.0.2_d3-shape@3.2.0/node_modules/@d3fc/d3fc-webgl/src/scale/scaleMapper.js";
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import { DataFrameProvider as
|
|
34
|
-
import { DataFrame as
|
|
35
|
-
import { arrangeLegendParts as
|
|
30
|
+
import mt from "../node_modules/.pnpm/@d3fc_d3fc-webgl@3.2.1_d3-scale@4.0.2_d3-shape@3.2.0/node_modules/@d3fc/d3fc-webgl/src/style/fillColor.js";
|
|
31
|
+
import pt from "../node_modules/.pnpm/@d3fc_d3fc-pointer@3.0.3_d3-dispatch@3.0.1_d3-selection@3.0.0/node_modules/@d3fc/d3fc-pointer/src/pointer.js";
|
|
32
|
+
import gt from "../node_modules/.pnpm/kdbush@4.0.2/node_modules/kdbush/index.js";
|
|
33
|
+
import { DataFrameProvider as ut } from "../common/useDataFrame.js";
|
|
34
|
+
import { DataFrame as ft } from "../DataFrame.js";
|
|
35
|
+
import { arrangeLegendParts as yt } from "../utils/arrangeLegendParts.js";
|
|
36
36
|
import { stringToNumberRgba as W, getColorWithFakeOpacity as G, GET_BLACK as O } from "./colors.js";
|
|
37
|
-
import
|
|
37
|
+
import b from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/linear.js";
|
|
38
38
|
import U from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/log.js";
|
|
39
|
-
import
|
|
40
|
-
import
|
|
41
|
-
import
|
|
42
|
-
import { sqrt as
|
|
39
|
+
import C from "../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/select.js";
|
|
40
|
+
import St from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/ordinal.js";
|
|
41
|
+
import xt from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/symlog.js";
|
|
42
|
+
import { sqrt as zt } from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/pow.js";
|
|
43
43
|
import vt from "../node_modules/.pnpm/d3-polygon@3.0.1/node_modules/d3-polygon/src/contains.js";
|
|
44
|
-
function V(
|
|
45
|
-
return
|
|
44
|
+
function V(y) {
|
|
45
|
+
return y / 2.35 * (y / 2.35) * 64;
|
|
46
46
|
}
|
|
47
|
-
function H(
|
|
48
|
-
return e.length === 0 ? !0 : e.some((i) => i.closed && i.points.length > 2 && vt(i.points, [
|
|
47
|
+
function H(y, t, e) {
|
|
48
|
+
return e.length === 0 ? !0 : e.some((i) => i.closed && i.points.length > 2 && vt(i.points, [y, t]));
|
|
49
49
|
}
|
|
50
|
-
function B(
|
|
51
|
-
const i = e.find((
|
|
50
|
+
function B(y, t, e) {
|
|
51
|
+
const i = e.find((o) => o.type === "dots"), n = e.find((o) => o.type === "curve");
|
|
52
52
|
return {
|
|
53
|
-
dotFill: M(
|
|
54
|
-
dotSize: M(
|
|
55
|
-
lineType: M(
|
|
53
|
+
dotFill: M(y, t, (i == null ? void 0 : i.aes.dotFill) ?? P.color, "dotFill"),
|
|
54
|
+
dotSize: M(y, t, (i == null ? void 0 : i.aes.dotSize) ?? P.size, "dotSize"),
|
|
55
|
+
lineType: M(y, t, (n == null ? void 0 : n.aes.lineShape) ?? "solid", "lineShape")
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
class
|
|
58
|
+
class he {
|
|
59
59
|
constructor() {
|
|
60
60
|
h(this, "reactRoot", null);
|
|
61
61
|
h(this, "parentNode", null);
|
|
62
62
|
h(this, "rootNode", null);
|
|
63
63
|
h(this, "canvasNode", null);
|
|
64
64
|
h(this, "svgLayerElement", null);
|
|
65
|
-
h(this, "svgLayerComponent", /* @__PURE__ */
|
|
65
|
+
h(this, "svgLayerComponent", /* @__PURE__ */ N.jsx(N.Fragment, {}));
|
|
66
66
|
h(this, "aesGetters", {
|
|
67
67
|
dotSize: () => 2,
|
|
68
68
|
dotFill: () => A,
|
|
@@ -70,10 +70,10 @@ class le {
|
|
|
70
70
|
});
|
|
71
71
|
h(this, "tools", null);
|
|
72
72
|
h(this, "margins", {
|
|
73
|
-
top:
|
|
74
|
-
bottom:
|
|
75
|
-
left:
|
|
76
|
-
right:
|
|
73
|
+
top: T,
|
|
74
|
+
bottom: T,
|
|
75
|
+
left: T,
|
|
76
|
+
right: T
|
|
77
77
|
});
|
|
78
78
|
h(this, "chartSizes", {
|
|
79
79
|
chartWidth: w,
|
|
@@ -86,10 +86,10 @@ class le {
|
|
|
86
86
|
// width of all charts in charts height, plus bottom axis, plus top title
|
|
87
87
|
});
|
|
88
88
|
h(this, "scales", {
|
|
89
|
-
x:
|
|
90
|
-
y:
|
|
91
|
-
xOriginal:
|
|
92
|
-
yOriginal:
|
|
89
|
+
x: b().domain([0, 10]).range([0, w]),
|
|
90
|
+
y: b().domain([0, 10]).range([E, 0]),
|
|
91
|
+
xOriginal: b().domain([0, 10]).range([0, w]),
|
|
92
|
+
yOriginal: b().domain([0, 10]).range([E, 0])
|
|
93
93
|
});
|
|
94
94
|
h(this, "polygons", []);
|
|
95
95
|
h(this, "onPolygonUpdateOutside", () => {
|
|
@@ -111,7 +111,7 @@ class le {
|
|
|
111
111
|
h(this, "notCalculatedProps", {});
|
|
112
112
|
h(this, "allDots", []);
|
|
113
113
|
h(this, "visibleLabels", []);
|
|
114
|
-
h(this, "dataFrame", new
|
|
114
|
+
h(this, "dataFrame", new ft("", {}));
|
|
115
115
|
h(this, "onPolygonUpdate", (t) => {
|
|
116
116
|
this.polygons = t, this.updateByLasso();
|
|
117
117
|
const e = this.allDots.filter((i) => H(i.x, i.y, this.polygons)).map((i) => i.idx);
|
|
@@ -126,206 +126,211 @@ class le {
|
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
128
|
init(t) {
|
|
129
|
-
this.parentNode === null && (this.parentNode = t, this.rootNode = document.createElement("div"), this.canvasNode = document.createElement("div"), this.parentNode.appendChild(this.rootNode), this.parentNode.appendChild(this.canvasNode), this.reactRoot =
|
|
129
|
+
this.parentNode === null && (this.parentNode = t, this.rootNode = document.createElement("div"), this.canvasNode = document.createElement("div"), this.parentNode.appendChild(this.rootNode), this.parentNode.appendChild(this.canvasNode), this.reactRoot = Z.createRoot(this.rootNode));
|
|
130
130
|
}
|
|
131
131
|
updateChartSizes(t) {
|
|
132
132
|
(t.width !== this.chartSizes.chartWidth || t.height !== this.chartSizes.chartHeight) && (this.chartSizes.chartWidth = t.width, this.chartSizes.chartHeight = t.height, this.scales.x.range([0, this.chartSizes.chartWidth]), this.scales.y.range([this.chartSizes.chartHeight, 0]));
|
|
133
133
|
}
|
|
134
134
|
updateViewport(t, e, i) {
|
|
135
|
-
const
|
|
136
|
-
let { minX:
|
|
137
|
-
if (t.lowerValue !== void 0 && (
|
|
138
|
-
const
|
|
139
|
-
if (
|
|
140
|
-
const
|
|
141
|
-
|
|
135
|
+
const n = t.scale === "log" ? U() : b();
|
|
136
|
+
let { minX: o, minY: c, maxX: d, maxY: m } = i;
|
|
137
|
+
if (t.lowerValue !== void 0 && (o = Math.max(o, t.lowerValue)), t.upperValue !== void 0 && (d = Math.min(d, t.upperValue)), e.lowerValue !== void 0 && (c = Math.max(c, e.lowerValue)), e.upperValue !== void 0 && (m = Math.min(m, e.upperValue)), t.symmetricRange !== void 0) {
|
|
138
|
+
const a = t.symmetricRange;
|
|
139
|
+
if (a >= o && a <= d) {
|
|
140
|
+
const u = Math.max(a - o, d - a);
|
|
141
|
+
o = a - u, d = a + u;
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
if (typeof e.symmetricRange < "u") {
|
|
145
|
-
const
|
|
146
|
-
if (
|
|
147
|
-
const
|
|
148
|
-
c =
|
|
145
|
+
const a = e.symmetricRange;
|
|
146
|
+
if (a >= c && a <= m) {
|
|
147
|
+
const u = Math.max(a - c, m - a);
|
|
148
|
+
c = a - u, m = a + u;
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
|
|
151
|
+
const f = [0, this.chartSizes.chartWidth], S = n.copy().domain([o, d]).range([D.LEFT, this.chartSizes.chartWidth - D.RIGHT]);
|
|
152
|
+
n.domain([S.invert(0), S.invert(this.chartSizes.chartWidth)]).range(f).nice(), this.scales.x.domain(n.domain()), this.scales.xOriginal.domain(n.domain());
|
|
153
|
+
const x = e.scale === "log" ? U() : b(), p = [this.chartSizes.chartHeight, 0], r = x.copy().domain([c, m]).range([this.chartSizes.chartHeight - D.BOTTOM, D.TOP]);
|
|
154
|
+
x.domain([r.invert(this.chartSizes.chartHeight), r.invert(0)]).range(p).nice(), this.scales.y.domain(x.domain()), this.scales.yOriginal.domain(x.domain());
|
|
155
155
|
}
|
|
156
156
|
updateCaptionsSize() {
|
|
157
157
|
const t = new I("600 14px Arial");
|
|
158
158
|
function e(c) {
|
|
159
159
|
return Math.max(...c.map((d) => t.getTextWidth(d)));
|
|
160
160
|
}
|
|
161
|
-
const { ticks: i, format:
|
|
161
|
+
const { ticks: i, format: n } = nt(this.scales.y, !1), o = e(i.map(n));
|
|
162
162
|
this.captionsSizes = {
|
|
163
163
|
xAxisCaptionsWidth: 20,
|
|
164
|
-
yAxisCaptionsWidth:
|
|
164
|
+
yAxisCaptionsWidth: o
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
167
|
createMainTitle(t) {
|
|
168
|
-
this.mainTitle =
|
|
168
|
+
this.mainTitle = at(
|
|
169
169
|
t.name,
|
|
170
170
|
this.chartSizes.totalWidth - this.margins.left - this.margins.right,
|
|
171
171
|
20
|
|
172
172
|
);
|
|
173
173
|
}
|
|
174
174
|
updateMargins(t, e) {
|
|
175
|
-
const i =
|
|
175
|
+
const i = tt * this.mainTitle.length, n = i > 0 ? i + ot * 2 : 0;
|
|
176
176
|
this.margins = {
|
|
177
|
-
top: Math.max(
|
|
178
|
-
bottom:
|
|
179
|
-
left:
|
|
180
|
-
right: this.legend.width +
|
|
181
|
-
}, this.chartSizes.totalWidth = this.margins.left + this.chartSizes.chartWidth + this.margins.right, this.chartSizes.totalHeight = this.margins.top + Math.max(this.chartSizes.chartHeight, this.legend.height) + this.margins.bottom,
|
|
177
|
+
top: Math.max(n, T),
|
|
178
|
+
bottom: T + (t.hiddenLabels ? 0 : this.captionsSizes.xAxisCaptionsWidth) + _,
|
|
179
|
+
left: T + (e.hiddenLabels ? 0 : this.captionsSizes.yAxisCaptionsWidth) + _,
|
|
180
|
+
right: this.legend.width + T
|
|
181
|
+
}, this.chartSizes.totalWidth = this.margins.left + this.chartSizes.chartWidth + this.margins.right, this.chartSizes.totalHeight = this.margins.top + Math.max(this.chartSizes.chartHeight, this.legend.height) + this.margins.bottom, C(this.canvasNode).style("width", this.chartSizes.chartWidth + "px").style("height", this.chartSizes.chartHeight + "px").style("top", this.margins.top + "px").style("left", this.margins.left + "px");
|
|
182
182
|
}
|
|
183
|
-
updateLegendSize(t, e, i,
|
|
183
|
+
updateLegendSize(t, e, i, n) {
|
|
184
184
|
if (!t.show) {
|
|
185
185
|
this.legend = { width: 0, height: 0, items: [] };
|
|
186
186
|
return;
|
|
187
187
|
}
|
|
188
|
-
const
|
|
189
|
-
Math.max(this.chartSizes.chartHeight,
|
|
190
|
-
|
|
191
|
-
),
|
|
192
|
-
if (i.forEach((
|
|
193
|
-
const r = e[
|
|
188
|
+
const o = [], c = { width: 0, height: 0, left: 0, top: 0 }, d = Math.min(
|
|
189
|
+
Math.max(this.chartSizes.chartHeight, et),
|
|
190
|
+
it
|
|
191
|
+
), m = Math.max(this.chartSizes.chartHeight, d);
|
|
192
|
+
if (i.forEach((p) => {
|
|
193
|
+
const r = e[p.value];
|
|
194
194
|
if (r.usedAes.length === 0 || !r.aesMap)
|
|
195
195
|
return;
|
|
196
|
-
if (r.values.length >
|
|
196
|
+
if (r.values.length > st) {
|
|
197
197
|
console.warn(`Too many values for discrete legend (${r.values.length})`);
|
|
198
198
|
return;
|
|
199
199
|
}
|
|
200
|
-
const
|
|
201
|
-
r.values.forEach((
|
|
202
|
-
|
|
203
|
-
|
|
200
|
+
const a = {};
|
|
201
|
+
r.values.forEach((g) => {
|
|
202
|
+
a[g] || (a[g] = { ...P }), r.usedAes.forEach((s) => {
|
|
203
|
+
s === "dotFill" && (a[g].color = r.aesMap(g, s) ?? A), s === "dotSize" && (a[g].size = Number(r.aesMap(g, s) ?? 3));
|
|
204
204
|
});
|
|
205
205
|
});
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
}),
|
|
209
|
-
if (
|
|
210
|
-
const { domain: r, range:
|
|
211
|
-
|
|
206
|
+
const u = p.label ?? p.value, z = St().domain(r.values).range(r.values.map((g) => a[g]));
|
|
207
|
+
o.push({ ...c, id: p.value, type: "dots", title: u, scale: z, values: r.values, labels: r.labels });
|
|
208
|
+
}), n.forEach((p) => {
|
|
209
|
+
if (p.type === "dots" && R(p.aes.dotFill)) {
|
|
210
|
+
const { domain: r, range: a, columnName: u, type: z = "linear" } = p.aes.dotFill, g = u.label ?? u.value, s = lt(a, r, "linear"), l = (z === "log" ? xt() : b()).domain(r).range([d, 0]), L = ht(l, r);
|
|
211
|
+
o.push({ ...c, id: "dotFill", type: "continuous", title: g, scale: s, tickPositionScale: l, values: L });
|
|
212
212
|
}
|
|
213
|
-
if (
|
|
214
|
-
const { columnName: r, domain:
|
|
215
|
-
|
|
213
|
+
if (p.type === "dots" && R(p.aes.dotSize)) {
|
|
214
|
+
const { columnName: r, domain: a, range: u } = p.aes.dotSize, z = r.label ?? r.value, g = zt(a, u), s = g.ticks(3), l = g.tickFormat(3), L = s.reduce((v, F) => (v[String(F)] = l(F), v), {});
|
|
215
|
+
o.push({ ...c, id: r.value, type: "size", title: z, scale: g, values: s, labels: L });
|
|
216
216
|
}
|
|
217
|
-
}), !
|
|
217
|
+
}), !o.length) {
|
|
218
218
|
this.legend = { width: 0, height: 0, items: [] };
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
221
|
-
const
|
|
221
|
+
const f = yt(o, m, d), S = f[f.length - 1], x = S.left + S.width + dt;
|
|
222
222
|
this.legend = {
|
|
223
|
-
width:
|
|
224
|
-
height:
|
|
225
|
-
items:
|
|
223
|
+
width: x,
|
|
224
|
+
height: m,
|
|
225
|
+
items: f
|
|
226
226
|
};
|
|
227
227
|
}
|
|
228
|
-
initSettings(t, e, i,
|
|
229
|
-
const { xAxis:
|
|
230
|
-
this.updateChartSizes(
|
|
231
|
-
const
|
|
232
|
-
const
|
|
233
|
-
return
|
|
234
|
-
}),
|
|
228
|
+
initSettings(t, e, i, n, o, c, d) {
|
|
229
|
+
const { xAxis: m, yAxis: f, size: S, title: x, legend: p } = e;
|
|
230
|
+
this.updateChartSizes(S), this.updateViewport(m, f, i), this.updateCaptionsSize(), this.updateLegendSize(p, n, c, o), this.createMainTitle(x), this.updateMargins(m, f), this.aesGetters = B(this.dataFrame, n, o);
|
|
231
|
+
const r = mt().data(t).value((s) => {
|
|
232
|
+
const l = W(this.aesGetters.dotFill(s.idx));
|
|
233
|
+
return l[3] = !s.dimmed && H(s.x, s.y, this.polygons) ? 1 : 0.4, G(l, l);
|
|
234
|
+
}), a = Y().equals((s, l) => s === l).size((s) => V(this.aesGetters.dotSize(s.idx))).crossValue((s) => s.x).mainValue((s) => s.y).decorate((s) => r(s)), u = $().scaleExtent([0.1, 1e3]).filter((s) => s.type === "wheel" || s.metaKey || s.ctrlKey).on("start", () => {
|
|
235
235
|
this.selectedDot = null;
|
|
236
236
|
}).on("zoom", (s) => {
|
|
237
|
-
const
|
|
238
|
-
this.scales.x.domain(
|
|
237
|
+
const l = s.transform, L = l.rescaleX(this.scales.xOriginal), v = l.rescaleY(this.scales.yOriginal);
|
|
238
|
+
this.scales.x.domain(L.domain()), this.scales.y.domain(v.domain()), this.zoomTransform = l, this.zoomStateKey = `${l.x}_${l.y}_${l.k}`, this.updateLabelsPosition(this.visibleLabels), this.renderSvgLayer(), this.renderWebglLayer();
|
|
239
239
|
}).on("end", () => {
|
|
240
|
-
this.visibleLabels = this.computeLabels(this.allDots), this.renderSvgLayer();
|
|
241
|
-
}),
|
|
242
|
-
var
|
|
243
|
-
let
|
|
244
|
-
s && (
|
|
245
|
-
const
|
|
246
|
-
this.selectedDot =
|
|
247
|
-
}),
|
|
240
|
+
this.visibleLabels = this.computeLabels(this.allDots), this.renderSvgLayer(), d(!0);
|
|
241
|
+
}), z = pt().on("point", ([s]) => {
|
|
242
|
+
var v;
|
|
243
|
+
let l;
|
|
244
|
+
s && (l = this.getClosestDot(s.x, s.y));
|
|
245
|
+
const L = this.selectedDot && !l || !this.selectedDot && l || ((v = this.selectedDot) == null ? void 0 : v.idx) !== (l == null ? void 0 : l.idx);
|
|
246
|
+
this.selectedDot = l ?? null, L && this.renderSvgLayer();
|
|
247
|
+
}), g = K({
|
|
248
248
|
xScale: this.scales.x,
|
|
249
249
|
yScale: this.scales.y
|
|
250
250
|
}).xAxisHeight(() => "0").yAxisWidth(() => "0").svgPlotArea(j()).webglPlotArea(
|
|
251
251
|
// only render the point series on the WebGL layer
|
|
252
|
-
q().series([
|
|
252
|
+
q().series([a]).mapping((s) => s)
|
|
253
253
|
).decorate((s) => {
|
|
254
|
-
const
|
|
255
|
-
|
|
254
|
+
const l = s.enter();
|
|
255
|
+
l && !this.svgLayerElement && (l.style("grid-template-columns", "0 auto 1fr auto 0"), l.style("grid-template-rows", "0 auto 1fr auto 0"), this.svgLayerElement = l.select(".svg-plot-area.plot-area svg").node()), l.select(".svg-plot-area.plot-area").attr("class", "svg-plot-area plot-area miplots-scatterplot-plot-area").call(u).call(z);
|
|
256
256
|
});
|
|
257
257
|
this.tools = {
|
|
258
|
-
webglChart:
|
|
259
|
-
zoom:
|
|
260
|
-
fillColor:
|
|
261
|
-
pointSeries:
|
|
262
|
-
},
|
|
258
|
+
webglChart: g,
|
|
259
|
+
zoom: u,
|
|
260
|
+
fillColor: r,
|
|
261
|
+
pointSeries: a
|
|
262
|
+
}, C(this.canvasNode).datum(t).style("position", "absolute").style("width", this.chartSizes.chartWidth + "px").style("height", this.chartSizes.chartHeight + "px").style("top", this.margins.top + "px").style("left", this.margins.left + "px");
|
|
263
|
+
}
|
|
264
|
+
resetZoom(t, e, i) {
|
|
265
|
+
var n;
|
|
266
|
+
!((n = this.tools) != null && n.zoom) || !i || (this.updateViewport(t, e, i), C(".miplots-scatterplot-plot-area").call(this.tools.zoom.transform, Q));
|
|
263
267
|
}
|
|
264
268
|
updateAes(t, e) {
|
|
265
269
|
this.tools !== null && (this.aesGetters = B(this.dataFrame, t, e), this.tools.fillColor.value((i) => {
|
|
266
|
-
const
|
|
267
|
-
return
|
|
270
|
+
const n = this.aesGetters.dotFill ?? O, o = W(n(i.idx));
|
|
271
|
+
return o[3] = !i.dimmed && H(i.x, i.y, this.polygons) ? 1 : 0.4, G(o, o);
|
|
268
272
|
}));
|
|
269
273
|
}
|
|
270
274
|
updatePointSize() {
|
|
271
|
-
this.tools !== null && (
|
|
275
|
+
this.tools !== null && (C(this.canvasNode).datum([...this.allDots]), this.tools.pointSeries.size((t) => V(this.aesGetters.dotSize(t.data))));
|
|
272
276
|
}
|
|
273
277
|
updateByLasso() {
|
|
274
278
|
var t;
|
|
275
279
|
this.tools !== null && ((t = this.tools) == null || t.fillColor.value((e) => {
|
|
276
|
-
const i = this.aesGetters.dotFill ?? O,
|
|
277
|
-
return
|
|
280
|
+
const i = this.aesGetters.dotFill ?? O, n = W(i(e.idx));
|
|
281
|
+
return n[3] = !e.dimmed && H(e.x, e.y, this.polygons) ? 1 : 0.4, G(n, n);
|
|
278
282
|
}), this.renderWebglLayer());
|
|
279
283
|
}
|
|
280
284
|
createQuadtree(t) {
|
|
281
|
-
const e = new
|
|
285
|
+
const e = new gt(t.length, 512);
|
|
282
286
|
for (let i = 0; i < t.length; i++)
|
|
283
287
|
e.add(t[i].x, t[i].y);
|
|
284
288
|
return e.finish();
|
|
285
289
|
}
|
|
286
290
|
getClosestDot(t, e) {
|
|
287
|
-
var
|
|
288
|
-
const i = (
|
|
291
|
+
var a, u;
|
|
292
|
+
const i = (a = this.tools) == null ? void 0 : a.qt;
|
|
289
293
|
if (!i) return null;
|
|
290
|
-
const
|
|
291
|
-
const
|
|
292
|
-
return (
|
|
294
|
+
const n = this.allDots, o = this.scales.x.invert(t), c = this.scales.y.invert(e), d = 1 / (((u = this.zoomTransform) == null ? void 0 : u.k) || 1), m = o - d, f = o + d, S = c - d, x = c + d, p = i.range(m, S, f, x), r = p.reduce((z, g) => {
|
|
295
|
+
const s = n[g], l = this.scales.x(s.x) - t, L = this.scales.y(s.y) - e, v = Math.hypot(l, L);
|
|
296
|
+
return (z === null || v < z.distance) && (z.index = g, z.distance = v), z;
|
|
293
297
|
}, {
|
|
294
298
|
index: -1,
|
|
295
299
|
distance: 1 / 0
|
|
296
300
|
});
|
|
297
|
-
return
|
|
301
|
+
return p.length === 0 || r.index === -1 ? null : n[r.index];
|
|
298
302
|
}
|
|
299
303
|
updateDots(t) {
|
|
300
|
-
this.tools !== null && (
|
|
304
|
+
this.tools !== null && (C(this.canvasNode).datum(t), this.tools.fillColor.data(t), this.tools.qt = this.createQuadtree(t), this.allDots = t);
|
|
301
305
|
}
|
|
302
|
-
render(t, e, i,
|
|
306
|
+
render(t, e, i, n, o, c, d, m, f, S, x, p, r, a) {
|
|
303
307
|
this.dataFrame = t;
|
|
304
|
-
const
|
|
308
|
+
const u = i.size.width !== this.chartSizes.chartWidth || i.size.height !== this.chartSizes.chartHeight;
|
|
305
309
|
if (this.tools === null)
|
|
306
310
|
this.initSettings(
|
|
307
|
-
|
|
311
|
+
o,
|
|
308
312
|
i,
|
|
309
313
|
c,
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
314
|
+
f,
|
|
315
|
+
m,
|
|
316
|
+
S,
|
|
317
|
+
a
|
|
313
318
|
);
|
|
314
319
|
else {
|
|
315
|
-
const { title:
|
|
316
|
-
this.updateChartSizes(s), this.updateLegendSize(
|
|
320
|
+
const { title: z, legend: g, size: s } = i;
|
|
321
|
+
this.updateChartSizes(s), this.updateLegendSize(g, f, S, m), this.createMainTitle(z), this.updateMargins(i.xAxis, i.yAxis), this.updateAes(f, m);
|
|
317
322
|
}
|
|
318
|
-
this.onPolygonUpdateOutside =
|
|
323
|
+
this.onPolygonUpdateOutside = x, this.onTooltipHintSwitch = p, this.onLassoControlsStateUpdate = r, this.allDots !== o ? (this.updateDots(o), this.visibleLabels = this.computeLabels(o)) : u && (this.visibleLabels = this.computeLabels(o)), this.notCalculatedProps = {
|
|
319
324
|
settingsId: e,
|
|
320
325
|
chartSettings: i,
|
|
321
|
-
keyColumn:
|
|
326
|
+
keyColumn: n,
|
|
322
327
|
dotsByGrouping: d,
|
|
323
|
-
layers:
|
|
328
|
+
layers: m
|
|
324
329
|
}, this.renderWebglLayer(), this.renderSvgLayer();
|
|
325
330
|
}
|
|
326
331
|
renderWebglLayer() {
|
|
327
332
|
var t, e;
|
|
328
|
-
(t = this.tools) != null && t.webglChart &&
|
|
333
|
+
(t = this.tools) != null && t.webglChart && C(this.canvasNode).call((e = this.tools) == null ? void 0 : e.webglChart);
|
|
329
334
|
}
|
|
330
335
|
renderSvgLayer() {
|
|
331
336
|
var e;
|
|
@@ -351,32 +356,32 @@ class le {
|
|
|
351
356
|
onTooltipHintSwitch: this.onTooltipHintSwitch,
|
|
352
357
|
onLassoControlsStateUpdate: this.onLassoControlsStateUpdate
|
|
353
358
|
};
|
|
354
|
-
this.svgLayerComponent = /* @__PURE__ */
|
|
359
|
+
this.svgLayerComponent = /* @__PURE__ */ N.jsx(ut, { dataFrame: this.dataFrame, children: /* @__PURE__ */ N.jsx(ct, { ...t }) }), (e = this.reactRoot) == null || e.render(this.svgLayerComponent);
|
|
355
360
|
}
|
|
356
361
|
renderError(t) {
|
|
357
362
|
var e;
|
|
358
|
-
(e = this.reactRoot) == null || e.render(/* @__PURE__ */
|
|
363
|
+
(e = this.reactRoot) == null || e.render(/* @__PURE__ */ N.jsx(J, { message: t }));
|
|
359
364
|
}
|
|
360
365
|
computeLabels(t) {
|
|
361
|
-
const e = new I("16px Manrope"), i =
|
|
362
|
-
for (let
|
|
363
|
-
const c = t[
|
|
366
|
+
const e = new I("16px Manrope"), i = rt(this.chartSizes.chartWidth, this.chartSizes.chartHeight), n = [];
|
|
367
|
+
for (let o = 0; o < t.length; o++) {
|
|
368
|
+
const c = t[o];
|
|
364
369
|
if (c.label == null)
|
|
365
370
|
continue;
|
|
366
|
-
const d = String(c.label),
|
|
367
|
-
|
|
368
|
-
x:
|
|
369
|
-
y,
|
|
371
|
+
const d = String(c.label), m = e.getTextMetrics(d), f = this.scales.x(c.x), S = this.scales.y(c.y), x = m.width, p = m.actualBoundingBoxAscent + m.actualBoundingBoxDescent, r = 10, a = i(f, S, x, p, r);
|
|
372
|
+
a && n.push({
|
|
373
|
+
x: f,
|
|
374
|
+
y: S,
|
|
370
375
|
dot: c,
|
|
371
376
|
name: d,
|
|
372
|
-
width:
|
|
373
|
-
height:
|
|
377
|
+
width: x,
|
|
378
|
+
height: p,
|
|
374
379
|
padding: r,
|
|
375
|
-
xPosition:
|
|
376
|
-
yPosition:
|
|
380
|
+
xPosition: a[0],
|
|
381
|
+
yPosition: a[1]
|
|
377
382
|
});
|
|
378
383
|
}
|
|
379
|
-
return
|
|
384
|
+
return n;
|
|
380
385
|
}
|
|
381
386
|
updateLabelsPosition(t) {
|
|
382
387
|
for (let e = 0; e < t.length; e++) {
|
|
@@ -386,6 +391,6 @@ class le {
|
|
|
386
391
|
}
|
|
387
392
|
}
|
|
388
393
|
export {
|
|
389
|
-
|
|
394
|
+
he as default
|
|
390
395
|
};
|
|
391
396
|
//# sourceMappingURL=ChartRenderer.js.map
|