@milaboratories/graph-maker 1.1.139 → 1.1.141
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/GraphMaker/components/Chart.vue.d.ts.map +1 -1
- package/dist/GraphMaker/components/Chart.vue.js +1 -0
- package/dist/GraphMaker/components/Chart.vue.js.map +1 -1
- package/dist/GraphMaker/dataBindAes.d.ts +5 -5
- package/dist/GraphMaker/dataBindAes.d.ts.map +1 -1
- package/dist/GraphMaker/dataBindAes.js +52 -49
- package/dist/GraphMaker/dataBindAes.js.map +1 -1
- package/dist/GraphMaker/forms/LayersForm/AesSelector.vue.js +14 -14
- package/dist/GraphMaker/forms/LayersForm/AesSelector.vue.js.map +1 -1
- package/dist/GraphMaker/index.vue.d.ts.map +1 -1
- package/dist/GraphMaker/index.vue.js +115 -113
- package/dist/GraphMaker/index.vue.js.map +1 -1
- package/dist/GraphMaker/store.js +9 -9
- package/dist/GraphMaker/types.d.ts +1 -1
- package/dist/GraphMaker/types.d.ts.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeBubbleSettings.d.ts +3 -3
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeChartSettings.d.ts +4 -8
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeChartSettings.d.ts.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeChartSettings.js.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeDendroSettings.d.ts +2 -2
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeDiscreteSettings.d.ts +5 -5
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeDiscreteSettings.d.ts.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeHeatmapSettings.d.ts +7 -7
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeHistogramSettings.d.ts +9 -9
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeHistogramSettings.d.ts.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotSettings.d.ts +20 -16
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotSettings.d.ts.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotSettings.js +65 -69
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotSettings.js.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotUmapSettings.d.ts +20 -16
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotUmapSettings.d.ts.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotUmapSettings.js +20 -19
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotUmapSettings.js.map +1 -1
- package/dist/GraphMaker/utils/loadDefaultSources.js +4 -3
- package/dist/GraphMaker/utils/loadDefaultSources.js.map +1 -1
- package/dist/GraphMaker/utils/loadUniqueValuesToSave.d.ts.map +1 -1
- package/dist/GraphMaker/utils/loadUniqueValuesToSave.js +57 -54
- package/dist/GraphMaker/utils/loadUniqueValuesToSave.js.map +1 -1
- package/dist/_virtual/_commonjsHelpers.js +3 -5
- package/dist/_virtual/_commonjsHelpers.js.map +1 -1
- package/dist/lib.js +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/AbstractChart.js +5 -5
- package/dist/node_modules/@milaboratories/miplots4/dist/AbstractChart.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/MiPlots.js +8 -5
- package/dist/node_modules/@milaboratories/miplots4/dist/MiPlots.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/bubble/index.js +22 -22
- package/dist/node_modules/@milaboratories/miplots4/dist/bubble/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/common/Error.js +4 -22
- package/dist/node_modules/@milaboratories/miplots4/dist/common/Error.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/index.js +53 -53
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/ChartRenderer.js +6 -6
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/index.js +45 -45
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Annotations/Annotation.js +71 -70
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Annotations/Annotation.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Chart.js +117 -112
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Chart.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/ChartsGroup.js +14 -14
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/index.js +6 -6
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/histogram/index.js +36 -36
- package/dist/node_modules/@milaboratories/miplots4/dist/histogram/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/ScatterplotSettingsImpl.js +24 -24
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/ScatterplotSettingsImpl.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/dots.js +23 -26
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/dots.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/getLayersData.js +13 -10
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/getLayersData.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/index.js +67 -73
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/utils/createLegendInfo.js +44 -39
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/utils/createLegendInfo.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/utils/sortDotsByGrouping.js +18 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/utils/sortDotsByGrouping.js.map +1 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/SettingsImpl.js +14 -14
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/SettingsImpl.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/index.js +68 -64
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/types/scatterplot-umap.js +23 -17
- package/dist/node_modules/@milaboratories/miplots4/dist/types/scatterplot-umap.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/types/scatterplot.js +23 -17
- package/dist/node_modules/@milaboratories/miplots4/dist/types/scatterplot.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/utils/arraysAreDifferent.js +7 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/utils/arraysAreDifferent.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/_virtual/_commonjsHelpers.js +9 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/_virtual/canonicalize.js +8 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/_virtual/canonicalize.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/_virtual/lodash.js +8 -0
- package/dist/{_virtual → node_modules/@milaboratories/pf-plots/dist/_virtual}/lodash.js.map +1 -1
- package/dist/{_virtual/lodash.js → node_modules/@milaboratories/pf-plots/dist/_virtual/lodash2.js} +1 -1
- package/dist/node_modules/@milaboratories/pf-plots/dist/_virtual/lodash2.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/_virtual/stringify.js +3 -0
- package/dist/{_virtual → node_modules/@milaboratories/pf-plots/dist/_virtual}/stringify.js.map +1 -1
- package/dist/{_virtual/stringify.js → node_modules/@milaboratories/pf-plots/dist/_virtual/stringify2.js} +1 -1
- package/dist/node_modules/@milaboratories/pf-plots/dist/_virtual/stringify2.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/constants.js +15 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/constants.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/ComponentController.js +198 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/ComponentController.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/ControllerBase.js +342 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/ControllerBase.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/bubble.js +278 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/bubble.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/dendro.js +453 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/dendro.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/discrete.js +203 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/discrete.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/heatmap.js +432 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/heatmap.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/histogram.js +170 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/histogram.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/scatterplot-umap.js +315 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/scatterplot-umap.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/scatterplot.js +323 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/scatterplot.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/demoStore.js +11 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/demoStore.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/index.js +36 -3420
- package/dist/node_modules/@milaboratories/pf-plots/dist/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/{pl-error-like → pf-plots/dist/node_modules/@milaboratories/pl-error-like}/dist/index.js +1 -1
- package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-error-like/dist/index.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/index.js +979 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/index.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@platforma-sdk/model/dist/index.js +1599 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@platforma-sdk/model/dist/index.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/canonicalize/lib/canonicalize.js +19 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/canonicalize/lib/canonicalize.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/json-stringify-safe/stringify.js +26 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/json-stringify-safe/stringify.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/lodash/lodash.js +3678 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/lodash/lodash.js.map +1 -0
- package/dist/node_modules/{zod → @milaboratories/pf-plots/dist/node_modules/zod}/lib/index.js +1141 -1141
- package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/zod/lib/index.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/pframe/ColumnsProvider.js +247 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/pframe/ColumnsProvider.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/spec.js +62 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/spec.js.map +1 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/utils.js +286 -0
- package/dist/node_modules/@milaboratories/pf-plots/dist/utils.js.map +1 -0
- package/package.json +3 -3
- package/dist/node_modules/@milaboratories/pl-error-like/dist/index.js.map +0 -1
- package/dist/node_modules/@milaboratories/pl-model-common/dist/index.js +0 -584
- package/dist/node_modules/@milaboratories/pl-model-common/dist/index.js.map +0 -1
- package/dist/node_modules/@platforma-sdk/model/dist/index.js +0 -1559
- package/dist/node_modules/@platforma-sdk/model/dist/index.js.map +0 -1
- package/dist/node_modules/json-stringify-safe/stringify.js +0 -20
- package/dist/node_modules/json-stringify-safe/stringify.js.map +0 -1
- package/dist/node_modules/lodash/lodash.js +0 -3678
- package/dist/node_modules/lodash/lodash.js.map +0 -1
- package/dist/node_modules/zod/lib/index.js.map +0 -1
|
@@ -1,36 +1,27 @@
|
|
|
1
|
-
import { renderToString as
|
|
2
|
-
import { AbstractChart as
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return d.forEach((e) => {
|
|
15
|
-
const a = [];
|
|
16
|
-
e.forEach((r) => {
|
|
17
|
-
a.push(...t.map((i) => [...i, r]));
|
|
18
|
-
}), t = a;
|
|
19
|
-
}), t;
|
|
1
|
+
import { renderToString as B } from "../node_modules/react-dom/server.browser.js";
|
|
2
|
+
import { AbstractChart as R } from "../AbstractChart.js";
|
|
3
|
+
import { arraysAreDifferent as D } from "../utils/arraysAreDifferent.js";
|
|
4
|
+
import { getKeysCombinations as b } from "../utils/getKeysCombination.js";
|
|
5
|
+
import A from "./ChartRenderer.js";
|
|
6
|
+
import { getDots as N } from "./dots.js";
|
|
7
|
+
import { getLayersData as j } from "./getLayersData.js";
|
|
8
|
+
import { getRegressionData as K } from "./linearRegression.js";
|
|
9
|
+
import { ScatterplotSettingsImpl as C } from "./ScatterplotSettingsImpl.js";
|
|
10
|
+
import { createLegendInfo as L, addPalettesToAesMapping as O } from "./utils/createLegendInfo.js";
|
|
11
|
+
var T = Object.defineProperty, k = (u, t, e) => t in u ? T(u, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[t] = e, y = (u, t, e) => k(u, typeof t != "symbol" ? t + "" : t, e);
|
|
12
|
+
function x(u) {
|
|
13
|
+
return typeof u == "object" && "type" in u && u.type === "grouping";
|
|
20
14
|
}
|
|
21
|
-
|
|
22
|
-
return typeof d == "object" && "type" in d && d.type === "grouping";
|
|
23
|
-
}
|
|
24
|
-
class $ extends A {
|
|
15
|
+
class q extends R {
|
|
25
16
|
constructor(t, e, a) {
|
|
26
|
-
super(t, e),
|
|
27
|
-
}),
|
|
17
|
+
super(t, e), y(this, "settings"), y(this, "chartRenderer"), y(this, "onTooltipHintSwitch", () => {
|
|
18
|
+
}), y(this, "calculatedData", null), this.chartRenderer = new A(), this.settings = new C(e), a && (this.onTooltipHintSwitch = a.onTooltipHintSwitch);
|
|
28
19
|
}
|
|
29
20
|
mount(t) {
|
|
30
21
|
try {
|
|
31
|
-
this.chartRenderer.init(t), this._updateData(), this._updateChart();
|
|
22
|
+
this.chartRenderer.init(t), this._updateData(), this._updateChart(), this.hasError = !1;
|
|
32
23
|
} catch (e) {
|
|
33
|
-
console.error(e), e instanceof Error && (this.chartRenderer.renderError(e.message), console.error(e));
|
|
24
|
+
this.hasError = !0, console.error(e), e instanceof Error && (this.chartRenderer.renderError(e.message), console.error(e));
|
|
34
25
|
}
|
|
35
26
|
}
|
|
36
27
|
unmount() {
|
|
@@ -38,73 +29,76 @@ class $ extends A {
|
|
|
38
29
|
}
|
|
39
30
|
updateSettingsAndData(t, e) {
|
|
40
31
|
try {
|
|
41
|
-
const a = this.settings,
|
|
42
|
-
this.settings = new
|
|
32
|
+
const a = this.settings, n = this.data;
|
|
33
|
+
this.settings = new C(e), this.data = t, this._needUpdateCalculatedDataBySettings(a, this.settings) || this._needUpdateCalculatedDataByData(n, this.data) ? this._updateData() : this._updateAesInData(), this._updateChart(), this.hasError = !1;
|
|
43
34
|
} catch (a) {
|
|
44
|
-
console.error(a), a instanceof Error && (this.chartRenderer.renderError(a.message), console.error(a));
|
|
35
|
+
this.hasError = !0, console.error(a), a instanceof Error && (this.chartRenderer.renderError(a.message), console.error(a));
|
|
45
36
|
}
|
|
46
37
|
}
|
|
47
38
|
updateChartState(t, e) {
|
|
48
39
|
console.warn("no chart state for scatterplot");
|
|
49
40
|
}
|
|
50
41
|
export() {
|
|
51
|
-
return this._updateChart(),
|
|
42
|
+
return this._updateChart(), B(this.chartRenderer.component);
|
|
52
43
|
}
|
|
53
44
|
_needUpdateCalculatedDataBySettings(t, e) {
|
|
54
|
-
var a,
|
|
55
|
-
return t.facetBy.some((
|
|
56
|
-
var
|
|
57
|
-
return
|
|
58
|
-
}) || t.grouping.length !== e.grouping.length ||
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
45
|
+
var a, n, i, o;
|
|
46
|
+
return t.facetBy.some((r, s) => {
|
|
47
|
+
var c;
|
|
48
|
+
return r.value !== ((c = e.facetBy[s]) == null ? void 0 : c.value);
|
|
49
|
+
}) || t.grouping.length !== e.grouping.length || D(
|
|
50
|
+
t.grouping.map((r) => r.columnName.value),
|
|
51
|
+
e.grouping.map((r) => r.columnName.value)
|
|
52
|
+
) || t.grouping.some((r, s) => {
|
|
53
|
+
var c;
|
|
54
|
+
return D(r.order, (c = e.grouping) == null ? void 0 : c[s].order);
|
|
55
|
+
}) || (((a = t.label) == null ? void 0 : a.value) || ((n = e.label) == null ? void 0 : n.value)) && ((i = t.label) == null ? void 0 : i.value) !== ((o = e.label) == null ? void 0 : o.value) || t.layers.length !== e.layers.length || t.layers.some((r, s) => r.type !== e.layers[s].type) || !!t.trend != !!e.trend;
|
|
62
56
|
}
|
|
63
57
|
_needUpdateCalculatedDataByData(t, e) {
|
|
64
|
-
const a = Object.keys(t.data),
|
|
65
|
-
return t.id !== e.id || a.length !==
|
|
66
|
-
var
|
|
67
|
-
return t.data[i].length !== ((
|
|
58
|
+
const a = Object.keys(t.data), n = Object.keys(e.data);
|
|
59
|
+
return t.id !== e.id || a.length !== n.length || a.some((i) => {
|
|
60
|
+
var o;
|
|
61
|
+
return t.data[i].length !== ((o = e.data[i]) == null ? void 0 : o.length);
|
|
68
62
|
});
|
|
69
63
|
}
|
|
70
64
|
_updateData() {
|
|
71
|
-
const { x: t, y: e, facetBy: a, grouping:
|
|
72
|
-
this.data.setGrouping([...
|
|
73
|
-
const
|
|
65
|
+
const { x: t, y: e, facetBy: a, grouping: n, trend: i, layers: o, label: r, highlight: s } = this.settings, c = a.map((l) => this.data.getColumnCategories(l.value)).filter((l) => l.length > 0), d = n.map(({ columnName: l }) => this.data.getColumnCategories(l.value)).filter((l) => l.length > 0), g = c.length ? b(c) : [["null"]], p = d.length ? b(d) : [["null"]], h = a.map((l) => l.value) ?? null;
|
|
66
|
+
this.data.setGrouping([...h]);
|
|
67
|
+
const S = {
|
|
74
68
|
x: this.data.getColumn(t.value).every((l) => l === null || !(Number(l) < 0)),
|
|
75
69
|
y: this.data.getColumn(e.value).every((l) => l === null || !(Number(l) < 0))
|
|
76
|
-
},
|
|
70
|
+
}, v = n.map((l) => l.columnName), m = N(this.data, g, t, e, r, s, n), f = Object.keys(m), E = K(this.data, m, f, p, v, i), _ = L(this.data, n, o), w = j(this.data, o, f, m, p, v);
|
|
77
71
|
this.calculatedData = {
|
|
78
|
-
onlyPositive:
|
|
79
|
-
dotsByFacets:
|
|
80
|
-
facetKeys:
|
|
81
|
-
facetKeysCombinations:
|
|
82
|
-
trendsData:
|
|
83
|
-
legendLabels:
|
|
84
|
-
layersData:
|
|
72
|
+
onlyPositive: S,
|
|
73
|
+
dotsByFacets: m,
|
|
74
|
+
facetKeys: f,
|
|
75
|
+
facetKeysCombinations: g,
|
|
76
|
+
trendsData: E,
|
|
77
|
+
legendLabels: _,
|
|
78
|
+
layersData: w
|
|
85
79
|
};
|
|
86
80
|
}
|
|
87
81
|
_updateAesInData() {
|
|
88
82
|
const t = this.calculatedData;
|
|
89
83
|
if (!t)
|
|
90
84
|
return;
|
|
91
|
-
const { grouping: e, trend: a, layers:
|
|
92
|
-
|
|
93
|
-
for (let s = 0; s <
|
|
94
|
-
t.layersData[
|
|
95
|
-
}), e.forEach((
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
85
|
+
const { grouping: e, trend: a, layers: n } = this.settings, { facetKeys: i, trendsData: o } = t;
|
|
86
|
+
i.forEach((r) => {
|
|
87
|
+
for (let s = 0; s < n.length; s++)
|
|
88
|
+
t.layersData[r][s].info = n[s];
|
|
89
|
+
}), e.forEach(({ columnName: r, inheritedAes: s }) => {
|
|
90
|
+
const c = /* @__PURE__ */ new Set(), d = {};
|
|
91
|
+
n.forEach((g) => {
|
|
92
|
+
g.aes && Object.entries(g.aes).forEach(([p, h]) => {
|
|
93
|
+
x(h) && h.value === r.value && (c.add(p), h.palette && (d[p] = h.palette));
|
|
100
94
|
});
|
|
101
|
-
}), t.legendLabels[
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
95
|
+
}), t.legendLabels[r.value].usedAes = [...c], t.legendLabels[r.value].aesMap = O(
|
|
96
|
+
r,
|
|
97
|
+
d,
|
|
98
|
+
s
|
|
105
99
|
);
|
|
106
|
-
}), o && a && Object.keys(o).forEach((
|
|
107
|
-
o[
|
|
100
|
+
}), o && a && Object.keys(o).forEach((r) => {
|
|
101
|
+
o[r].forEach((s) => {
|
|
108
102
|
s.color = a.color, s.bounded = a.bounded;
|
|
109
103
|
});
|
|
110
104
|
});
|
|
@@ -112,7 +106,7 @@ class $ extends A {
|
|
|
112
106
|
_updateChart() {
|
|
113
107
|
if (!this.calculatedData)
|
|
114
108
|
return;
|
|
115
|
-
const { id: t, chartSettings: e, facetSettings: a, grouping:
|
|
109
|
+
const { id: t, chartSettings: e, facetSettings: a, grouping: n, keyColumn: i, layers: o, trend: r } = this.settings;
|
|
116
110
|
this.chartRenderer.render(
|
|
117
111
|
this.data,
|
|
118
112
|
t,
|
|
@@ -127,14 +121,14 @@ class $ extends A {
|
|
|
127
121
|
this.calculatedData.onlyPositive,
|
|
128
122
|
this.calculatedData.legendLabels,
|
|
129
123
|
this.calculatedData.layersData,
|
|
130
|
-
|
|
131
|
-
h,
|
|
124
|
+
n.map((s) => s.columnName),
|
|
132
125
|
o,
|
|
126
|
+
r,
|
|
133
127
|
this.onTooltipHintSwitch
|
|
134
128
|
);
|
|
135
129
|
}
|
|
136
130
|
}
|
|
137
131
|
export {
|
|
138
|
-
|
|
132
|
+
q as ChartScatterplot
|
|
139
133
|
};
|
|
140
134
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../node_modules/@milaboratories/miplots4/src/scatterplot/index.ts"],"sourcesContent":["import { renderToString } from 'react-dom/server';\nimport { AbstractChart } from '../AbstractChart';\nimport type { DataFrame } from '../DataFrame';\nimport type {\n AesItem,\n ContinuousAesFromColumn,\n InheritAesScatterplot,\n ScatterplotEventHandlers,\n ScatterplotLegendInfo,\n ScatterplotSettings,\n} from '../types';\nimport ChartRenderer from './ChartRenderer';\nimport type { GroupedDots } from './dots';\nimport { getDots } from './dots';\nimport type { ScatterplotLayerData } from './getLayersData';\nimport { getLayersData } from './getLayersData';\nimport type { TrendsData } from './linearRegression';\nimport { getRegressionData } from './linearRegression';\nimport { ScatterplotSettingsImpl } from './ScatterplotSettingsImpl';\nimport { addPalettesToAesMapping, createLegendInfo } from './utils/createLegendInfo';\n\n// all combinations with 1 key from each list\nfunction getKeysCombinations(keysLists: string[][]) {\n if (!keysLists.length) {\n return [];\n }\n let result: string[][] = [[]];\n keysLists.forEach(keys => {\n const nextResult: string[][] = [];\n keys.forEach(key => {\n nextResult.push(...result.map(resultItem => [...resultItem, key]));\n });\n result = nextResult;\n });\n return result;\n}\n\nfunction isInheritMapping<T extends (string | number)>(value:T | InheritAesScatterplot | ContinuousAesFromColumn<T>):value is InheritAesScatterplot {\n return typeof value === 'object' && 'type' in value && value.type === 'grouping';\n}\n\nexport class ChartScatterplot extends AbstractChart {\n settings: ScatterplotSettingsImpl;\n chartRenderer: ChartRenderer;\n\n onTooltipHintSwitch: (v:boolean) => void = () => undefined;\n calculatedData: {\n onlyPositive: {x: boolean; y: boolean};\n dotsByFacets: GroupedDots;\n facetKeys: string[];\n facetKeysCombinations: string[][];\n trendsData: TrendsData | null;\n legendLabels: ScatterplotLegendInfo;\n layersData: Record<string, ScatterplotLayerData[]>;\n } | null = null;\n\n constructor(data: DataFrame, settings: ScatterplotSettings, eventHandlers?:ScatterplotEventHandlers) {\n super(data, settings);\n\n this.chartRenderer = new ChartRenderer();\n this.settings = new ScatterplotSettingsImpl(settings);\n if (eventHandlers) {\n this.onTooltipHintSwitch = eventHandlers.onTooltipHintSwitch;\n }\n }\n\n mount(node: HTMLElement) {\n try {\n this.chartRenderer.init(node);\n this._updateData();\n this._updateChart();\n } catch (err) {\n console.error(err);\n if (err instanceof Error) {\n this.chartRenderer.renderError(err.message as string);\n console.error(err);\n }\n }\n }\n\n unmount() {\n this.chartRenderer.clear();\n }\n\n updateSettingsAndData(data: DataFrame, settings: ScatterplotSettings) {\n try {\n const previousSettings = this.settings;\n const previousData = this.data;\n this.settings = new ScatterplotSettingsImpl(settings);\n this.data = data;\n if (\n this._needUpdateCalculatedDataBySettings(previousSettings, this.settings) ||\n this._needUpdateCalculatedDataByData(previousData, this.data)\n ) {\n this._updateData();\n } else {\n this._updateAesInData();\n }\n this._updateChart();\n } catch (err) {\n console.error(err);\n if (err instanceof Error) {\n this.chartRenderer.renderError(err.message as string);\n console.error(err);\n }\n }\n }\n\n updateChartState(_field: string, _value: unknown) {\n console.warn('no chart state for scatterplot');\n }\n\n export(): string {\n this._updateChart();\n return renderToString(this.chartRenderer.component);\n }\n\n _needUpdateCalculatedDataBySettings(prevSettings: ScatterplotSettingsImpl, settings: ScatterplotSettingsImpl) {\n return (\n prevSettings.facetBy.some((el, idx) => el.value !== settings.facetBy[idx]?.value) ||\n prevSettings.grouping.length !== settings.grouping.length ||\n prevSettings.grouping.some((el, idx) => el.value !== settings.grouping[idx]?.value) ||\n (prevSettings.label?.value || settings.label?.value) && prevSettings.label?.value !== settings.label?.value ||\n prevSettings.layers.length !== settings.layers.length ||\n prevSettings.layers.some((l, idx) => l.type !== settings.layers[idx].type) ||\n Boolean(prevSettings.trend) !== Boolean(settings.trend)\n );\n }\n\n _needUpdateCalculatedDataByData(prevData: DataFrame, data: DataFrame) {\n const prevKeys = Object.keys(prevData.data);\n const keys = Object.keys(data.data);\n return (\n prevData.id !== data.id ||\n prevKeys.length !== keys.length ||\n prevKeys.some(key => prevData.data[key].length !== data.data[key]?.length)\n );\n }\n\n _updateData() {\n const {x, y, facetBy, grouping, keyColumn, trend, layers, inheritedAes, label, highlight} = this.settings;\n const keys = this.data.getColumnCategories(keyColumn.value);\n\n const facetKeysLists = facetBy.map(column => this.data.getColumnCategories(column.value)).filter(v => v.length > 0);\n const categoryGroupingKeysLists = grouping.map(column => this.data.getColumnCategories(column.value)).filter(v => v.length > 0);\n\n const facetKeysCombinations = facetKeysLists.length\n ? getKeysCombinations(facetKeysLists)\n : [['null']];\n const categoryGroupingCombinations = categoryGroupingKeysLists.length\n ? getKeysCombinations(categoryGroupingKeysLists)\n : [['null']];\n\n const facetGroupingValues = facetBy.map(column => column.value) ?? null;\n\n this.data.setGrouping([...facetGroupingValues, keyColumn.value]);\n const onlyPositive = {\n x: this.data.getColumn(x.value).every(v => {\n return v === null || !(Number(v) < 0);\n }),\n y: this.data.getColumn(y.value).every(v => {\n return v === null || !(Number(v) < 0);\n }),\n };\n\n const dotsByFacets = getDots(this.data, facetKeysCombinations, x, y, label, highlight, keys);\n const facetKeys = Object.keys(dotsByFacets);\n const trendsData = getRegressionData(this.data, dotsByFacets, facetKeys, categoryGroupingCombinations, grouping, trend);\n\n const legendLabels = createLegendInfo(this.data, grouping, layers, inheritedAes);\n const layersData = getLayersData(this.data, layers, facetKeys, dotsByFacets, categoryGroupingCombinations, grouping);\n\n this.calculatedData = {\n onlyPositive,\n dotsByFacets,\n facetKeys,\n facetKeysCombinations,\n trendsData,\n legendLabels,\n layersData,\n };\n }\n\n _updateAesInData() {\n const calculated = this.calculatedData;\n if (!calculated) {\n return;\n }\n const {grouping, trend, layers, inheritedAes} = this.settings;\n const {facetKeys, trendsData} = calculated;\n\n facetKeys.forEach(facetKey => {\n for (let i = 0; i < layers.length; i++) {\n calculated.layersData[facetKey][i].info = layers[i];\n }\n });\n\n grouping.forEach(column => {\n const usedAes = new Set<keyof AesItem>();\n const usedAesFromPalettes:Partial<Record<keyof AesItem, string[]>> = {}; // if there is palette in mapping then\n layers.forEach(layer => {\n if (layer.aes) {\n Object.entries(layer.aes).forEach(([key, value]) => {\n if (isInheritMapping(value) && value.value === column.value) {\n usedAes.add(key as keyof AesItem);\n if (value.palette) {\n usedAesFromPalettes[key as keyof AesItem] = value.palette;\n }\n }\n });\n }\n });\n calculated.legendLabels[column.value].usedAes = [...usedAes];\n calculated.legendLabels[column.value].aesMap = addPalettesToAesMapping(\n column,\n usedAesFromPalettes,\n inheritedAes[column.value]\n );\n });\n if (trendsData && trend) {\n Object.keys(trendsData).forEach((key) => {\n trendsData[key].forEach(trendInfo => {\n trendInfo.color = trend.color;\n trendInfo.bounded = trend.bounded;\n });\n });\n }\n }\n\n _updateChart() {\n if (!this.calculatedData) {\n return;\n }\n const {id, chartSettings, facetSettings, grouping, keyColumn, layers, trend} = this.settings;\n this.chartRenderer.render(\n this.data,\n id,\n chartSettings,\n facetSettings,\n this.calculatedData.facetKeys,\n this.calculatedData.facetKeysCombinations, //for titles, if facet by more than 1 column\n this.calculatedData.dotsByFacets,\n this.calculatedData.trendsData,\n keyColumn,\n this.calculatedData.onlyPositive,\n this.calculatedData.legendLabels,\n this.calculatedData.layersData,\n grouping,\n layers,\n trend,\n this.onTooltipHintSwitch\n );\n }\n}\n"],"names":["getKeysCombinations","keysLists","result","keys","nextResult","key","resultItem","isInheritMapping","value","ChartScatterplot","AbstractChart","data","settings","eventHandlers","__publicField","ChartRenderer","ScatterplotSettingsImpl","node","err","previousSettings","previousData","_field","_value","renderToString","prevSettings","el","idx","_a","_b","_c","_d","l","prevData","prevKeys","h","x","y","facetBy","grouping","keyColumn","trend","layers","inheritedAes","label","highlight","facetKeysLists","column","v","categoryGroupingKeysLists","facetKeysCombinations","categoryGroupingCombinations","facetGroupingValues","onlyPositive","dotsByFacets","getDots","facetKeys","trendsData","getRegressionData","legendLabels","createLegendInfo","layersData","getLayersData","calculated","facetKey","i","usedAes","usedAesFromPalettes","layer","addPalettesToAesMapping","trendInfo","id","chartSettings","facetSettings"],"mappings":";;;;;;;;;AAsBA,SAASA,EAAoBC,GAAuB;AAChD,MAAI,CAACA,EAAU;AACX,WAAO,CAAA;AAEX,MAAIC,IAAqB,CAAC,EAAE;AAC5B,SAAAD,EAAU,QAAQ,CAAAE,MAAQ;AACtB,UAAMC,IAAyB,CAAA;AAC/BD,IAAAA,EAAK,QAAQ,CAAAE,MAAO;AAChBD,MAAAA,EAAW,KAAK,GAAGF,EAAO,IAAI,CAAAI,MAAc,CAAC,GAAGA,GAAYD,CAAG,CAAC,CAAC;AAAA,IACrE,CAAC,GACDH,IAASE;AAAAA,EACb,CAAC,GACMF;AACX;AAEA,SAASK,EAA8CC,GAA6F;AAChJ,SAAO,OAAOA,KAAU,YAAY,UAAUA,KAASA,EAAM,SAAS;AAC1E;AAEO,MAAMC,UAAyBC,EAAc;AAAA,EAehD,YAAYC,GAAiBC,GAA+BC,GAAyC;AACjG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Q,CAAAgE,MAAa;AACjCA,UAAU,QAAQ7B,EAAM,OACxB6B,EAAU,UAAU7B,EAAM;AAAA,MAC9B,CAAC;AAAA,IACL,CAAC;AAAA,EAET;AAAA,EAEA,eAAe;AACX,QAAI,CAAC,KAAK;AACN;AAEJ,UAAM,EAAC,IAAA8B,GAAI,eAAAC,GAAe,eAAAC,GAAe,UAAAlC,GAAU,WAAAC,GAAW,QAAAE,GAAQ,OAAAD,MAAS,KAAK;AACpF,SAAK,cAAc;AAAA,MACf,KAAK;AAAA,MACL8B;AAAAA,MACAC;AAAAA,MACAC;AAAAA,MACA,KAAK,eAAe;AAAA,MACpB,KAAK,eAAe;AAAA;AAAA,MACpB,KAAK,eAAe;AAAA,MACpB,KAAK,eAAe;AAAA,MACpBjC;AAAAA,MACA,KAAK,eAAe;AAAA,MACpB,KAAK,eAAe;AAAA,MACpB,KAAK,eAAe;AAAA,MACpBD;AAAAA,MACAG;AAAAA,MACAD;AAAAA,MACA,KAAK;AAAA,IAAA;AAAA,EAEb;AACJ;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../node_modules/@milaboratories/miplots4/src/scatterplot/index.ts"],"sourcesContent":["import { renderToString } from 'react-dom/server';\nimport { AbstractChart } from '../AbstractChart';\nimport type { DataFrame } from '../DataFrame';\nimport type {\n AesItem,\n ContinuousAesFromColumn,\n InheritAesScatterplot,\n ScatterplotEventHandlers,\n ScatterplotLegendInfo,\n ScatterplotSettings,\n} from '../types';\nimport { arraysAreDifferent } from '../utils/arraysAreDifferent';\nimport { getKeysCombinations } from '../utils/getKeysCombination';\nimport ChartRenderer from './ChartRenderer';\nimport type { GroupedDots } from './dots';\nimport { getDots } from './dots';\nimport type { ScatterplotLayerData } from './getLayersData';\nimport { getLayersData } from './getLayersData';\nimport type { TrendsData } from './linearRegression';\nimport { getRegressionData } from './linearRegression';\nimport { ScatterplotSettingsImpl } from './ScatterplotSettingsImpl';\nimport { addPalettesToAesMapping, createLegendInfo } from './utils/createLegendInfo';\n\nfunction isInheritMapping<T extends (string | number)>(value:T | InheritAesScatterplot | ContinuousAesFromColumn<T>):value is InheritAesScatterplot {\n return typeof value === 'object' && 'type' in value && value.type === 'grouping';\n}\n\nexport class ChartScatterplot extends AbstractChart {\n settings: ScatterplotSettingsImpl;\n chartRenderer: ChartRenderer;\n\n onTooltipHintSwitch: (v:boolean) => void = () => undefined;\n calculatedData: {\n onlyPositive: {x: boolean; y: boolean};\n dotsByFacets: GroupedDots;\n facetKeys: string[];\n facetKeysCombinations: string[][];\n trendsData: TrendsData | null;\n legendLabels: ScatterplotLegendInfo;\n layersData: Record<string, ScatterplotLayerData[]>;\n } | null = null;\n\n constructor(data: DataFrame, settings: ScatterplotSettings, eventHandlers?:ScatterplotEventHandlers) {\n super(data, settings);\n\n this.chartRenderer = new ChartRenderer();\n this.settings = new ScatterplotSettingsImpl(settings);\n if (eventHandlers) {\n this.onTooltipHintSwitch = eventHandlers.onTooltipHintSwitch;\n }\n }\n\n mount(node: HTMLElement) {\n try {\n this.chartRenderer.init(node);\n this._updateData();\n this._updateChart();\n this.hasError = false;\n } catch (err) {\n this.hasError = true;\n console.error(err);\n if (err instanceof Error) {\n this.chartRenderer.renderError(err.message as string);\n console.error(err);\n }\n }\n }\n\n unmount() {\n this.chartRenderer.clear();\n }\n\n updateSettingsAndData(data: DataFrame, settings: ScatterplotSettings) {\n try {\n const previousSettings = this.settings;\n const previousData = this.data;\n this.settings = new ScatterplotSettingsImpl(settings);\n this.data = data;\n if (\n this._needUpdateCalculatedDataBySettings(previousSettings, this.settings) ||\n this._needUpdateCalculatedDataByData(previousData, this.data)\n ) {\n this._updateData();\n } else {\n this._updateAesInData();\n }\n this._updateChart();\n this.hasError = false;\n } catch (err) {\n this.hasError = true;\n console.error(err);\n if (err instanceof Error) {\n this.chartRenderer.renderError(err.message as string);\n console.error(err);\n }\n }\n }\n\n updateChartState(_field: string, _value: unknown) {\n console.warn('no chart state for scatterplot');\n }\n\n export(): string {\n this._updateChart();\n return renderToString(this.chartRenderer.component);\n }\n\n _needUpdateCalculatedDataBySettings(prevSettings: ScatterplotSettingsImpl, settings: ScatterplotSettingsImpl) {\n return (\n prevSettings.facetBy.some((el, idx) => el.value !== settings.facetBy[idx]?.value) ||\n prevSettings.grouping.length !== settings.grouping.length ||\n arraysAreDifferent(\n prevSettings.grouping.map(v => v.columnName.value),\n settings.grouping.map(v => v.columnName.value),\n ) ||\n prevSettings.grouping.some((v, idx) => arraysAreDifferent(v.order, settings.grouping?.[idx].order)) ||\n (prevSettings.label?.value || settings.label?.value) && prevSettings.label?.value !== settings.label?.value ||\n prevSettings.layers.length !== settings.layers.length ||\n prevSettings.layers.some((l, idx) => l.type !== settings.layers[idx].type) ||\n Boolean(prevSettings.trend) !== Boolean(settings.trend)\n );\n }\n\n _needUpdateCalculatedDataByData(prevData: DataFrame, data: DataFrame) {\n const prevKeys = Object.keys(prevData.data);\n const keys = Object.keys(data.data);\n return (\n prevData.id !== data.id ||\n prevKeys.length !== keys.length ||\n prevKeys.some(key => prevData.data[key].length !== data.data[key]?.length)\n );\n }\n\n _updateData() {\n const {x, y, facetBy, grouping, trend, layers, label, highlight} = this.settings;\n const facetKeysLists = facetBy.map(column => this.data.getColumnCategories(column.value)).filter(v => v.length > 0);\n const categoryGroupingKeysLists = grouping.map(({columnName}) => this.data.getColumnCategories(columnName.value)).filter(v => v.length > 0);\n\n const facetKeysCombinations = facetKeysLists.length\n ? getKeysCombinations(facetKeysLists)\n : [['null']];\n const categoryGroupingCombinations = categoryGroupingKeysLists.length\n ? getKeysCombinations(categoryGroupingKeysLists)\n : [['null']];\n\n const facetGroupingValues = facetBy.map(column => column.value) ?? null;\n\n this.data.setGrouping([...facetGroupingValues]);\n const onlyPositive = {\n x: this.data.getColumn(x.value).every(v => {\n return v === null || !(Number(v) < 0);\n }),\n y: this.data.getColumn(y.value).every(v => {\n return v === null || !(Number(v) < 0);\n }),\n };\n\n const groupingColumns = grouping.map(v => v.columnName);\n\n const dotsByFacets = getDots(this.data, facetKeysCombinations, x, y, label, highlight, grouping);\n const facetKeys = Object.keys(dotsByFacets);\n const trendsData = getRegressionData(this.data, dotsByFacets, facetKeys, categoryGroupingCombinations, groupingColumns, trend);\n\n const legendLabels = createLegendInfo(this.data, grouping, layers);\n const layersData = getLayersData(this.data, layers, facetKeys, dotsByFacets, categoryGroupingCombinations, groupingColumns);\n\n this.calculatedData = {\n onlyPositive,\n dotsByFacets,\n facetKeys,\n facetKeysCombinations,\n trendsData,\n legendLabels,\n layersData,\n };\n }\n\n _updateAesInData() {\n const calculated = this.calculatedData;\n if (!calculated) {\n return;\n }\n const {grouping, trend, layers} = this.settings;\n const {facetKeys, trendsData} = calculated;\n\n facetKeys.forEach(facetKey => {\n for (let i = 0; i < layers.length; i++) {\n calculated.layersData[facetKey][i].info = layers[i];\n }\n });\n\n grouping.forEach(({columnName, inheritedAes}) => {\n const usedAes = new Set<keyof AesItem>();\n const usedAesFromPalettes: Partial<Record<keyof AesItem, string[]>> = {}; // if there is palette in mapping then\n layers.forEach(layer => {\n if (layer.aes) {\n Object.entries(layer.aes).forEach(([key, value]) => {\n if (isInheritMapping(value) && value.value === columnName.value) {\n usedAes.add(key as keyof AesItem);\n if (value.palette) {\n usedAesFromPalettes[key as keyof AesItem] = value.palette;\n }\n }\n });\n }\n });\n calculated.legendLabels[columnName.value].usedAes = [...usedAes];\n calculated.legendLabels[columnName.value].aesMap = addPalettesToAesMapping(\n columnName,\n usedAesFromPalettes,\n inheritedAes\n );\n });\n if (trendsData && trend) {\n Object.keys(trendsData).forEach((key) => {\n trendsData[key].forEach(trendInfo => {\n trendInfo.color = trend.color;\n trendInfo.bounded = trend.bounded;\n });\n });\n }\n }\n\n _updateChart() {\n if (!this.calculatedData) {\n return;\n }\n const {id, chartSettings, facetSettings, grouping, keyColumn, layers, trend} = this.settings;\n this.chartRenderer.render(\n this.data,\n id,\n chartSettings,\n facetSettings,\n this.calculatedData.facetKeys,\n this.calculatedData.facetKeysCombinations, //for titles, if facet by more than 1 column\n this.calculatedData.dotsByFacets,\n this.calculatedData.trendsData,\n keyColumn,\n this.calculatedData.onlyPositive,\n this.calculatedData.legendLabels,\n this.calculatedData.layersData,\n grouping.map(v => v.columnName),\n layers,\n trend,\n this.onTooltipHintSwitch\n );\n }\n}\n"],"names":["isInheritMapping","value","ChartScatterplot","AbstractChart","data","settings","eventHandlers","__publicField","ChartRenderer","ScatterplotSettingsImpl","node","err","previousSettings","previousData","_field","_value","renderToString","prevSettings","el","idx","_a","arraysAreDifferent","v","_b","_c","_d","l","prevData","prevKeys","keys","key","x","y","facetBy","grouping","trend","layers","label","highlight","facetKeysLists","column","categoryGroupingKeysLists","columnName","facetKeysCombinations","getKeysCombinations","categoryGroupingCombinations","facetGroupingValues","onlyPositive","groupingColumns","dotsByFacets","getDots","facetKeys","trendsData","getRegressionData","legendLabels","createLegendInfo","layersData","getLayersData","calculated","facetKey","i","inheritedAes","usedAes","usedAesFromPalettes","layer","addPalettesToAesMapping","trendInfo","id","chartSettings","facetSettings","keyColumn"],"mappings":";;;;;;;;;;;AAuBA,SAASA,EAA8CC,GAA6F;AAChJ,SAAO,OAAOA,KAAU,YAAY,UAAUA,KAASA,EAAM,SAAS;AAC1E;AAEO,MAAMC,UAAyBC,EAAc;AAAA,EAehD,YAAYC,GAAiBC,GAA+BC,GAAyC;AACjG,UAAMF,GAAMC,CAAQ,GAfxBE,EAAA,MAAA,UAAA,GACAA,EAAA,MAAA,eAAA,GAEAA,EAAA,6BAA2C,MAAA;AAAA,IAAA,CAAA,GAC3CA,EAAA,MAAA,kBAQW,IAAA,GAKP,KAAK,gBAAgB,IAAIC,EAAAA,GACzB,KAAK,WAAW,IAAIC,EAAwBJ,CAAQ,GAChDC,MACA,KAAK,sBAAsBA,EAAc;AAAA,EAEjD;AAAA,EAEA,MAAMI,GAAmB;AACrB,QAAI;AACA,WAAK,cAAc,KAAKA,CAAI,GAC5B,KAAK,eACL,KAAK,aAAA,GACL,KA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ACN;AAEJ,UAAM,EAAC,IAAAgC,GAAI,eAAAC,GAAe,eAAAC,GAAe,UAAAnC,GAAU,WAAAoC,GAAW,QAAAlC,GAAQ,OAAAD,MAAS,KAAK;AACpF,SAAK,cAAc;AAAA,MACf,KAAK;AAAA,MACLgC;AAAAA,MACAC;AAAAA,MACAC;AAAAA,MACA,KAAK,eAAe;AAAA,MACpB,KAAK,eAAe;AAAA;AAAA,MACpB,KAAK,eAAe;AAAA,MACpB,KAAK,eAAe;AAAA,MACpBC;AAAAA,MACA,KAAK,eAAe;AAAA,MACpB,KAAK,eAAe;AAAA,MACpB,KAAK,eAAe;AAAA,MACpBpC,EAAS,IAAI,CAAAZ,MAAKA,EAAE,UAAU;AAAA,MAC9Bc;AAAAA,MACAD;AAAAA,MACA,KAAK;AAAA,IAAA;AAAA,EAEb;AACJ;","x_google_ignoreList":[0]}
|
package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/utils/createLegendInfo.js
CHANGED
|
@@ -1,57 +1,62 @@
|
|
|
1
|
-
import { MAX_SHOWN_UNIQUE_VALUES_IN_LABELS as
|
|
2
|
-
const
|
|
1
|
+
import { MAX_SHOWN_UNIQUE_VALUES_IN_LABELS as m } from "../../constants.js";
|
|
2
|
+
const C = /* @__PURE__ */ (() => {
|
|
3
3
|
const e = /* @__PURE__ */ new Map();
|
|
4
4
|
return {
|
|
5
5
|
clear: () => e.clear(),
|
|
6
|
-
getIndex: (
|
|
7
|
-
let l = e.get(
|
|
8
|
-
l === void 0 && (l = /* @__PURE__ */ new Map(), e.set(
|
|
9
|
-
let
|
|
10
|
-
return
|
|
6
|
+
getIndex: (i, u) => {
|
|
7
|
+
let l = e.get(i.value);
|
|
8
|
+
l === void 0 && (l = /* @__PURE__ */ new Map(), e.set(i.value, l));
|
|
9
|
+
let t = l.get(u);
|
|
10
|
+
return t === void 0 && (t = l.size, l.set(u, t)), t;
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
})();
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
const l = u && Object.keys(u).length > 0,
|
|
17
|
-
return (
|
|
18
|
-
var
|
|
19
|
-
const
|
|
20
|
-
return
|
|
14
|
+
function I(e, i, u) {
|
|
15
|
+
C.clear();
|
|
16
|
+
const l = u && Object.keys(u).length > 0, t = i.dotFill, r = t && t.length > 0, d = i.lineColor, h = d && d.length > 0;
|
|
17
|
+
return (c, p) => {
|
|
18
|
+
var s;
|
|
19
|
+
const g = l ? (s = u[c]) == null ? void 0 : s[p] : void 0;
|
|
20
|
+
return p === "dotFill" && r ? t[C.getIndex(e, c) % t.length] ?? g : p === "lineColor" && h ? d[C.getIndex(e, c) % d.length] ?? g : g;
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function A(e) {
|
|
24
24
|
return typeof e == "object" && "type" in e && e.type === "grouping";
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
return
|
|
28
|
-
const
|
|
29
|
-
u.forEach((
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
function x(e, i, u) {
|
|
27
|
+
return i.reduce((l, t) => {
|
|
28
|
+
const r = t.columnName, d = t.order, h = (o) => r.valueLabels ? e.getColumnValueCategory(r.valueLabels, o) : void 0, c = /* @__PURE__ */ new Set(), p = {};
|
|
29
|
+
u.forEach((o) => {
|
|
30
|
+
o.aes && Object.entries(o.aes).forEach(([v, n]) => {
|
|
31
|
+
A(n) && n.value === r.value && (c.add(v), p[v] = n.palette);
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
|
-
let
|
|
35
|
-
if (
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
let s = {}, g = [];
|
|
35
|
+
if (c.has("dotFill") || c.has("dotShape")) {
|
|
36
|
+
const o = e.getColumnCategories(r.value);
|
|
37
|
+
if (o.length < m) {
|
|
38
|
+
s = o.reduce((n, a) => {
|
|
39
|
+
const f = e.getColumnCategoryRowIndex(r.value, a);
|
|
40
|
+
return n[a] = h(f) ?? a, n;
|
|
41
|
+
}, s);
|
|
42
|
+
const v = o.reduce((n, a) => (n[a] = (d == null ? void 0 : d.indexOf(a)) ?? -1, n), {});
|
|
43
|
+
g = o.sort((n, a) => {
|
|
44
|
+
var f;
|
|
45
|
+
return v[n] !== v[a] ? v[n] - v[a] : ((f = s[n]) == null ? void 0 : f.localeCompare(s[a] ?? "", "en", { numeric: !0 })) ?? 0;
|
|
46
|
+
});
|
|
47
|
+
} else
|
|
48
|
+
g = o;
|
|
44
49
|
}
|
|
45
|
-
return
|
|
46
|
-
values:
|
|
47
|
-
usedAes: [...
|
|
48
|
-
aesMap:
|
|
49
|
-
labels:
|
|
50
|
-
},
|
|
50
|
+
return l[r.value] = {
|
|
51
|
+
values: g,
|
|
52
|
+
usedAes: [...c],
|
|
53
|
+
aesMap: I(r, p, t.inheritedAes),
|
|
54
|
+
labels: s
|
|
55
|
+
}, l;
|
|
51
56
|
}, {});
|
|
52
57
|
}
|
|
53
58
|
export {
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
I as addPalettesToAesMapping,
|
|
60
|
+
x as createLegendInfo
|
|
56
61
|
};
|
|
57
62
|
//# sourceMappingURL=createLegendInfo.js.map
|
package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/utils/createLegendInfo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createLegendInfo.js","sources":["../../../../../../../node_modules/@milaboratories/miplots4/src/scatterplot/utils/createLegendInfo.ts"],"sourcesContent":["import { MAX_SHOWN_UNIQUE_VALUES_IN_LABELS } from '../../constants';\nimport type { DataFrame } from '../../DataFrame';\nimport type {\n AesItem,\n Category,\n ColumnName,\n ContinuousAesFromColumn,\n InheritAesScatterplot,\n ScatterplotLayer,\n ScatterplotLegendInfo\n} from '../../types';\nimport type { ScatterplotSettingsImpl } from '../ScatterplotSettingsImpl';\n\nconst categoryIndexer = (() => {\n const map = new Map<string, Map<Category, number>>();\n const clear = () => map.clear();\n const getIndex = (columnName: ColumnName, category: Category): number => {\n let categoryMap = map.get(columnName.value);\n if (categoryMap === undefined) {\n categoryMap = new Map();\n map.set(columnName.value, categoryMap);\n }\n let index = categoryMap.get(category);\n if (index === undefined) {\n index = categoryMap.size;\n categoryMap.set(category, index);\n }\n return index;\n };\n\n return {\n clear,\n getIndex,\n };\n})();\n\nexport function addPalettesToAesMapping(\n columnName: ColumnName,\n usedAesFromPalettes: Partial<Record<keyof AesItem, string[]>>,\n inheritedAes?:
|
|
1
|
+
{"version":3,"file":"createLegendInfo.js","sources":["../../../../../../../node_modules/@milaboratories/miplots4/src/scatterplot/utils/createLegendInfo.ts"],"sourcesContent":["import { MAX_SHOWN_UNIQUE_VALUES_IN_LABELS } from '../../constants';\nimport type { DataFrame } from '../../DataFrame';\nimport type {AesRecord} from '../../types';\nimport type {\n AesItem,\n Category,\n ColumnName,\n ContinuousAesFromColumn,\n InheritAesScatterplot,\n ScatterplotLayer,\n ScatterplotLegendInfo\n} from '../../types';\nimport type { ScatterplotSettingsImpl } from '../ScatterplotSettingsImpl';\n\nconst categoryIndexer = (() => {\n const map = new Map<string, Map<Category, number>>();\n const clear = () => map.clear();\n const getIndex = (columnName: ColumnName, category: Category): number => {\n let categoryMap = map.get(columnName.value);\n if (categoryMap === undefined) {\n categoryMap = new Map();\n map.set(columnName.value, categoryMap);\n }\n let index = categoryMap.get(category);\n if (index === undefined) {\n index = categoryMap.size;\n categoryMap.set(category, index);\n }\n return index;\n };\n\n return {\n clear,\n getIndex,\n };\n})();\n\nexport function addPalettesToAesMapping(\n columnName: ColumnName,\n usedAesFromPalettes: Partial<Record<keyof AesItem, string[]>>,\n inheritedAes?: AesRecord\n) {\n categoryIndexer.clear();\n const hasInheritedAes = inheritedAes && Object.keys(inheritedAes).length > 0;\n const dotFill = usedAesFromPalettes['dotFill'];\n const hasDotFill = dotFill && dotFill.length > 0;\n const lineColor = usedAesFromPalettes['lineColor'];\n const hasLineColor = lineColor && lineColor.length > 0;\n const getAesField = (category: Category, field: keyof AesItem) => {\n const inheritedResult = hasInheritedAes ? inheritedAes[category]?.[field] : undefined;\n \n if (field === 'dotFill' && hasDotFill) {\n return dotFill[categoryIndexer.getIndex(columnName, category) % dotFill.length] ?? inheritedResult;\n }\n if (field === 'lineColor' && hasLineColor) {\n return lineColor[categoryIndexer.getIndex(columnName, category) % lineColor.length] ?? inheritedResult;\n }\n \n return inheritedResult;\n };\n\n return getAesField;\n}\n\nfunction isInheritMapping<T extends (string | number)>(value:T | InheritAesScatterplot | ContinuousAesFromColumn<T>):value is InheritAesScatterplot {\n return typeof value === 'object' && 'type' in value && value.type === 'grouping';\n}\nexport function createLegendInfo(\n data: DataFrame,\n grouping: ScatterplotSettingsImpl['grouping'],\n layers: ScatterplotLayer[],\n): ScatterplotLegendInfo {\n return grouping.reduce((res: ScatterplotLegendInfo, groupingElement) => {\n // TODO: remove String conversion\n const column = groupingElement.columnName;\n const order = groupingElement.order;\n const getValueLabel = (index: number) => {\n return column.valueLabels\n ? data.getColumnValueCategory(column.valueLabels, index)\n : undefined;\n };\n\n const usedAes = new Set<keyof AesItem>();\n const usedAesFromPalettes:Partial<Record<keyof AesItem, string[]>> = {}; // if there is palette in mapping then\n layers.forEach(layer => {\n if (!layer.aes) return;\n \n Object.entries(layer.aes).forEach(([key, value]) => {\n if (!(isInheritMapping(value) && value.value === column.value)) return;\n \n usedAes.add(key as keyof AesItem);\n usedAesFromPalettes[key as keyof AesItem] = value.palette;\n });\n });\n let labels: Record<Category, string> = {};\n let values: Category[] = [];\n if (usedAes.has('dotFill') || usedAes.has('dotShape')) {\n const categories = data.getColumnCategories(column.value);\n if (categories.length < MAX_SHOWN_UNIQUE_VALUES_IN_LABELS) {\n labels = categories.reduce((res, category) => {\n const index = data.getColumnCategoryRowIndex(column.value, category);\n res[category] = getValueLabel(index) ?? category;\n return res;\n }, labels);\n const sortWeights = categories.reduce((res, v) => {\n res[v] = order?.indexOf(v) ?? -1;\n return res;\n }, {} as Record<string, number>);\n values = categories.sort((a, b) => {\n if (sortWeights[a] !== sortWeights[b]) {\n return sortWeights[a] - sortWeights[b];\n }\n return labels[a]?.localeCompare(labels[b] ?? '', 'en', {numeric: true}) ?? 0;\n });\n } else {\n values = categories;\n }\n }\n res[column.value] = {\n values,\n usedAes: [...usedAes],\n aesMap: addPalettesToAesMapping(column, usedAesFromPalettes, groupingElement.inheritedAes),\n labels,\n };\n return res;\n }, {});\n}"],"names":["categoryIndexer","map","columnName","category","categoryMap","index","addPalettesToAesMapping","usedAesFromPalettes","inheritedAes","hasInheritedAes","dotFill","hasDotFill","lineColor","hasLineColor","field","inheritedResult","_a","isInheritMapping","value","createLegendInfo","data","grouping","layers","res","groupingElement","column","order","getValueLabel","usedAes","layer","key","labels","values","categories","MAX_SHOWN_UNIQUE_VALUES_IN_LABELS","sortWeights","v","a","b"],"mappings":";AAcA,MAAMA,IAAmB,uBAAM;AAC3B,QAAMC,wBAAU,IAAA;AAgBhB,SAAO;AAAA,IACH,OAhBU,MAAMA,EAAI,MAAA;AAAA,IAiBpB,UAhBa,CAACC,GAAwBC,MAA+B;AACrE,UAAIC,IAAcH,EAAI,IAAIC,EAAW,KAAK;AACtCE,MAAAA,MAAgB,WAChBA,IAAAA,oBAAkB,IAAA,GAClBH,EAAI,IAAIC,EAAW,OAAOE,CAAW;AAEzC,UAAIC,IAAQD,EAAY,IAAID,CAAQ;AACpC,aAAIE,MAAU,WACVA,IAAQD,EAAY,MACpBA,EAAY,IAAID,GAAUE,CAAK,IAE5BA;AAAAA,IACX;AAAA,EAAA;AAMJ,GAAA;AAEO,SAASC,EACZJ,GACAK,GACAC,GACF;AACER,EAAAA,EAAgB,MAAA;AAChB,QAAMS,IAAkBD,KAAgB,OAAO,KAAKA,CAAY,EAAE,SAAS,GACrEE,IAAUH,EAAoB,SAC9BI,IAAaD,KAAWA,EAAQ,SAAS,GACzCE,IAAYL,EAAoB,WAChCM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AAKpB,MAAa;AAC1C,gBAAME,IAAQe,EAAK,0BAA0BK,EAAO,OAAOtB,CAAQ;AACnEoB,iBAAAA,EAAIpB,CAAQ,IAAIwB,EAActB,CAAK,KAAKF,GACjCoB;AAAAA,QACX,GAAGQ,CAAM;AACT,cAAMI,IAAcF,EAAW,OAAO,CAACV,GAAKa,OACxCb,EAAIa,CAAC,KAAIV,KAAA,gBAAAA,EAAO,QAAQU,OAAM,IACvBb,IACR,EAA4B;AAC/BS,QAAAA,IAASC,EAAW,KAAK,CAACI,GAAGC,MAAM;;AAC/B,iBAAIH,EAAYE,CAAC,MAAMF,EAAYG,CAAC,IACzBH,EAAYE,CAAC,IAAIF,EAAYG,CAAC,MAElCtB,IAAAe,EAAOM,CAAC,MAAR,OAAA,SAAArB,EAAW,cAAce,EAAOO,CAAC,KAAK,IAAI,MAAM,EAAC,SAAS,GAAA,CAAA,MAAU;AAAA,QAC/E,CAAC;AAAA,MACL;AACIN,QAAAA,IAASC;AAAAA,IAEjB;AACA,WAAAV,EAAIE,EAAO,KAAK,IAAI;AAAA,MAChB,QAAAO;AAAAA,MACA,SAAS,CAAC,GAAGJ,CAAO;AAAA,MACpB,QAAQtB,EAAwBmB,GAAQlB,GAAqBiB,EAAgB,YAAY;AAAA,MACzF,QAAAO;AAAAA,IAAA,GAEGR;AAAAA,EACX,GAAG,CAAA,CAAE;AACT;","x_google_ignoreList":[0]}
|
package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/utils/sortDotsByGrouping.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function f(n, c, m, v) {
|
|
2
|
+
const a = m.reduce((o, { columnName: l, order: e }) => (e && (o[l.value] = e.reduce((r, u, d) => (r[u] = e.length - d, r), {})), o), {});
|
|
3
|
+
c.sort((o, l) => {
|
|
4
|
+
var e, r;
|
|
5
|
+
if (v && l.dimmed !== o.dimmed)
|
|
6
|
+
return l.dimmed ? 1 : -1;
|
|
7
|
+
for (const { columnName: u } of m) {
|
|
8
|
+
const d = n.getColumnValue(u.value, o.idx), s = n.getColumnValue(u.value, l.idx), t = (e = a[u.value]) == null ? void 0 : e[d], i = (r = a[u.value]) == null ? void 0 : r[s];
|
|
9
|
+
if (t !== i)
|
|
10
|
+
return t - i;
|
|
11
|
+
}
|
|
12
|
+
return 0;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
f as sortDotsByGrouping
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=sortDotsByGrouping.js.map
|
package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/utils/sortDotsByGrouping.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortDotsByGrouping.js","sources":["../../../../../../../node_modules/@milaboratories/miplots4/src/scatterplot/utils/sortDotsByGrouping.ts"],"sourcesContent":["import type {DataFrame} from '../../DataFrame';\nimport type {ColumnName, DataValue} from '../../types';\nimport type {Dot} from '../dots';\n\nexport function sortDotsByGrouping(\n dataFrame: DataFrame,\n dots:Dot[],\n grouping: {columnName: ColumnName; order?: DataValue[];}[],\n highlight: ColumnName | null\n) {\n const weightsByColumnByOrder = grouping.reduce((res, {columnName, order}) => {\n if (order) {\n res[columnName.value] = order.reduce((weights, orderEl, idx) => {\n weights[orderEl as string] = order.length - idx;\n return weights;\n }, {} as Record<string, number>);\n }\n return res;\n }, {} as Record<string, Record<string, number>>);\n\n dots.sort((d1, d2) => {\n if (highlight && d2.dimmed !== d1.dimmed) {\n return d2.dimmed ? 1 : -1;\n }\n for (const {columnName} of grouping) {\n const aValue = dataFrame.getColumnValue(columnName.value, d1.idx);\n const bValue = dataFrame.getColumnValue(columnName.value, d2.idx);\n const aWeight = weightsByColumnByOrder[columnName.value]?.[aValue as string];\n const bWeight = weightsByColumnByOrder[columnName.value]?.[bValue as string];\n if (aWeight !== bWeight) {\n return aWeight - bWeight;\n }\n }\n return 0;\n });\n}"],"names":["sortDotsByGrouping","dataFrame","dots","grouping","highlight","weightsByColumnByOrder","res","columnName","order","weights","orderEl","idx","d1","d2","_a","_b","aValue","bValue","aWeight","bWeight"],"mappings":"AAIO,SAASA,EACZC,GACAC,GACAC,GACAC,GACF;AACE,QAAMC,IAAyBF,EAAS,OAAO,CAACG,GAAK,EAAC,YAAAC,GAAY,OAAAC,EAAAA,OAC1DA,MACAF,EAAIC,EAAW,KAAK,IAAIC,EAAM,OAAO,CAACC,GAASC,GAASC,OACpDF,EAAQC,CAAiB,IAAIF,EAAM,SAASG,GACrCF,IACR,CAAA,CAA4B,IAE5BH,IACR,EAA4C;AAE/CJ,EAAAA,EAAK,KAAK,CAACU,GAAIC,MAAO;AAhBnB,QAAAC,GAAAC;AAiBC,QAAIX,KAAaS,EAAG,WAAWD,EAAG;AAC9B,aAAOC,EAAG,SAAS,IAAI;AAE3B,eAAW,EAAC,YAAAN,EAAAA,KAAeJ,GAAU;AACjC,YAAMa,IAASf,EAAU,eAAeM,EAAW,OAAOK,EAAG,GAAG,GAC1DK,IAAShB,EAAU,eAAeM,EAAW,OAAOM,EAAG,GAAG,GAC1DK,KAAUJ,IAAAT,EAAuBE,EAAW,KAAK,MAAvC,gBAAAO,EAA2CE,CAAAA,GACrDG,KAAUJ,IAAAV,EAAuBE,EAAW,KAAK,MAAvC,gBAAAQ,EAA2CE,CAAAA;AAC3D,UAAIC,MAAYC;AACZ,eAAOD,IAAUC;AAAAA,IAEzB;AACA,WAAO;AAAA,EACX,CAAC;AACL;","x_google_ignoreList":[0]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import p from "../node_modules/lodash/lodash.js";
|
|
2
|
-
import { DEFAULT_HEIGHT as y, DEFAULT_WIDTH as
|
|
2
|
+
import { DEFAULT_HEIGHT as y, DEFAULT_WIDTH as c, BLACK as u } from "../constants.js";
|
|
3
3
|
import { ScatterplotUmapSettingsSchema as g } from "../types/scatterplot-umap.js";
|
|
4
|
-
var
|
|
4
|
+
var d = Object.defineProperty, m = (i, t, s) => t in i ? d(i, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : i[t] = s, e = (i, t, s) => m(i, typeof t != "symbol" ? t + "" : t, s);
|
|
5
5
|
class v {
|
|
6
6
|
constructor(t) {
|
|
7
|
-
|
|
7
|
+
e(this, "type", "dots"), e(this, "aes", {
|
|
8
8
|
dotFill: u,
|
|
9
9
|
dotShape: "21",
|
|
10
10
|
dotSize: 3,
|
|
@@ -17,7 +17,7 @@ class v {
|
|
|
17
17
|
}
|
|
18
18
|
class w {
|
|
19
19
|
constructor(t) {
|
|
20
|
-
|
|
20
|
+
e(this, "type", "curve"), e(this, "smoothing"), e(this, "aes", {
|
|
21
21
|
lineColor: u,
|
|
22
22
|
lineWidth: 1,
|
|
23
23
|
lineShape: "solid",
|
|
@@ -28,20 +28,20 @@ class w {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
class
|
|
31
|
+
class S {
|
|
32
32
|
constructor(t) {
|
|
33
|
-
|
|
34
|
-
var
|
|
33
|
+
e(this, "id"), e(this, "type", "scatterplot-umap"), e(this, "keyColumn"), e(this, "x"), e(this, "y"), e(this, "grouping"), e(this, "label"), e(this, "highlight"), e(this, "chartSettings"), e(this, "layers");
|
|
34
|
+
var s, r, a, h, n, o;
|
|
35
35
|
g.parse(t), this.id = p.uniqueId("settings"), this.keyColumn = t.keyColumn ?? null, this.x = t.x, this.y = t.y, this.grouping = t.grouping ?? [], this.label = t.label ?? null, this.highlight = t.highlight ?? null, this.chartSettings = {
|
|
36
36
|
size: {
|
|
37
|
-
width: ((
|
|
38
|
-
height: ((
|
|
37
|
+
width: ((s = t == null ? void 0 : t.size) == null ? void 0 : s.width) ?? c,
|
|
38
|
+
height: ((r = t == null ? void 0 : t.size) == null ? void 0 : r.height) ?? y
|
|
39
39
|
},
|
|
40
40
|
title: {
|
|
41
41
|
position: "center",
|
|
42
42
|
show: !0,
|
|
43
43
|
...t.title,
|
|
44
|
-
name: ((
|
|
44
|
+
name: ((a = t.title) == null ? void 0 : a.name) ?? "Chart"
|
|
45
45
|
},
|
|
46
46
|
yAxis: {
|
|
47
47
|
title: t.y.label ?? t.y.value,
|
|
@@ -57,7 +57,7 @@ class A {
|
|
|
57
57
|
showTicks: !0,
|
|
58
58
|
...t.xAxis
|
|
59
59
|
},
|
|
60
|
-
frame: { type: ((
|
|
60
|
+
frame: { type: ((h = t.frame) == null ? void 0 : h.type) ?? "full" },
|
|
61
61
|
legend: {
|
|
62
62
|
show: !0,
|
|
63
63
|
position: "right",
|
|
@@ -65,9 +65,9 @@ class A {
|
|
|
65
65
|
},
|
|
66
66
|
tooltips: {
|
|
67
67
|
...t.tooltips,
|
|
68
|
-
show: ((
|
|
68
|
+
show: ((n = t.tooltips) == null ? void 0 : n.show) !== !1 && (((o = t.tooltips) == null ? void 0 : o.content) ?? []).length > 0
|
|
69
69
|
}
|
|
70
|
-
}, this.
|
|
70
|
+
}, this.layers = t.layers.map((l) => {
|
|
71
71
|
if (l.type === "dots")
|
|
72
72
|
return new v(l);
|
|
73
73
|
if (l.type === "curve")
|
|
@@ -79,6 +79,6 @@ class A {
|
|
|
79
79
|
export {
|
|
80
80
|
w as CurveLayer,
|
|
81
81
|
v as DotsLayer,
|
|
82
|
-
|
|
82
|
+
S as ScatterplotUmapSettingsImpl
|
|
83
83
|
};
|
|
84
84
|
//# sourceMappingURL=SettingsImpl.js.map
|
package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/SettingsImpl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SettingsImpl.js","sources":["../../../../../../node_modules/@milaboratories/miplots4/src/scatterplot-umap/SettingsImpl.ts"],"sourcesContent":["import lodash from 'lodash';\nimport { BLACK, DEFAULT_HEIGHT, DEFAULT_WIDTH } from '../constants';\nimport type { ScatterplotAxisSettings } from '../scatterplot/ScatterplotSettingsImpl';\nimport type {\n ColumnName,\n ContinuousAesFromColumn,\n FrameType,\n LegendPosition,\n LineShape,\n SettingsInterface,\n TitlePosition
|
|
1
|
+
{"version":3,"file":"SettingsImpl.js","sources":["../../../../../../node_modules/@milaboratories/miplots4/src/scatterplot-umap/SettingsImpl.ts"],"sourcesContent":["import lodash from 'lodash';\nimport { BLACK, DEFAULT_HEIGHT, DEFAULT_WIDTH } from '../constants';\nimport type { ScatterplotAxisSettings } from '../scatterplot/ScatterplotSettingsImpl';\nimport type {\n ColumnName,\n ContinuousAesFromColumn,\n DataValue,\n FrameType,\n LegendPosition,\n LineShape,\n SettingsInterface,\n TitlePosition\n} from '../types';\nimport {type AesRecord, type InheritAesScatterplot, type PointShape} from '../types';\nimport type {\n CurveUmapLayer as OuterCurveLayer,\n DotsUmapLayer as OuterDotsLayer,\n ScatterplotUmapSettings\n} from '../types/scatterplot-umap';\nimport { ScatterplotUmapSettingsSchema } from '../types/scatterplot-umap';\n\nexport class DotsLayer {\n readonly type = 'dots';\n readonly aes: {\n dotFill: string | InheritAesScatterplot | ContinuousAesFromColumn<string>;\n dotShape: PointShape | InheritAesScatterplot;\n dotSize: number | ContinuousAesFromColumn<number>;\n opacity: number;\n } = {\n dotFill: BLACK,\n dotShape: '21',\n dotSize: 3,\n opacity: 1,\n };\n constructor(layer: OuterDotsLayer) {\n this.aes = {\n ...this.aes,\n ...layer.aes,\n };\n }\n}\nexport class CurveLayer {\n readonly type = 'curve';\n readonly smoothing: boolean;\n readonly aes: {\n lineColor: string | InheritAesScatterplot | ContinuousAesFromColumn<string>;\n lineWidth: number;\n lineShape: LineShape;\n opacity: number;\n } = {\n lineColor: BLACK,\n lineWidth: 1,\n lineShape: 'solid',\n opacity: 1,\n };\n\n constructor(layer: OuterCurveLayer) {\n this.smoothing = layer.smoothing ?? false;\n this.aes = {\n ...this.aes,\n ...layer.aes,\n };\n }\n}\n\nexport type ScatterplotUmapLayer = DotsLayer | CurveLayer;\n\nexport class ScatterplotUmapSettingsImpl implements SettingsInterface {\n readonly id: string;\n readonly type = 'scatterplot-umap';\n readonly keyColumn: ColumnName | null;\n readonly x: ColumnName;\n readonly y: ColumnName;\n readonly grouping: {\n columnName: ColumnName;\n order?: DataValue[];\n inheritedAes?: AesRecord;\n }[];\n readonly label: ColumnName | null;\n readonly highlight: ColumnName | null;\n readonly chartSettings: {\n readonly size: {width: number; height: number};\n readonly title: {name: string; show: boolean; position: TitlePosition};\n readonly yAxis: ScatterplotAxisSettings;\n readonly xAxis: ScatterplotAxisSettings;\n readonly frame: {type: FrameType};\n readonly legend: {show: boolean; position: LegendPosition};\n readonly tooltips: {show: boolean; content?: ColumnName[]};\n };\n readonly layers: ScatterplotUmapLayer[];\n\n constructor(settings: ScatterplotUmapSettings) {\n ScatterplotUmapSettingsSchema.parse(settings);\n this.id = lodash.uniqueId('settings');\n this.keyColumn = settings.keyColumn ?? null;\n this.x = settings.x;\n this.y = settings.y;\n this.grouping = settings.grouping ?? [];\n this.label = settings.label ?? null;\n this.highlight = settings.highlight ?? null;\n this.chartSettings = {\n size: {\n width: settings?.size?.width ?? DEFAULT_WIDTH,\n height: settings?.size?.height ?? DEFAULT_HEIGHT,\n },\n title: {\n position: 'center',\n show: true,\n ...settings.title,\n name: settings.title?.name ?? 'Chart',\n },\n yAxis: {\n title: settings.y.label ?? settings.y.value,\n scale: 'linear',\n showGrid: true,\n showTicks: true,\n ...settings.yAxis,\n },\n xAxis: {\n title: settings.x.label ?? settings.x.value,\n scale: 'linear',\n showGrid: true,\n showTicks: true,\n ...settings.xAxis,\n },\n frame: {type: settings.frame?.type ?? 'full'},\n legend: {\n show: true,\n position: 'right',\n ...settings.legend,\n },\n tooltips: {\n ...settings.tooltips,\n show: !(settings.tooltips?.show === false) && (settings.tooltips?.content ?? []).length > 0,\n },\n };\n\n this.layers = settings.layers\n .map(layer => {\n if (layer.type === 'dots') {\n return new DotsLayer(layer);\n } else if (layer.type === 'curve') {\n return new CurveLayer(layer);\n } else {\n throw new Error('Unknown layer type');\n }\n })\n .filter(Boolean) as ScatterplotUmapLayer[];\n }\n}\n"],"names":["DotsLayer","layer","__publicField","BLACK","CurveLayer","ScatterplotUmapSettingsImpl","settings","ScatterplotUmapSettingsSchema","lodash","_a","DEFAULT_WIDTH","_b","DEFAULT_HEIGHT","_c","_d","_e","_f"],"mappings":";;;;AAqBO,MAAMA,EAAU;AAAA,EAanB,YAAYC,GAAuB;AAZ1BC,MAAA,MAAA,QAAO,MAAA,GACPA,EAAA,MAAA,OAKL;AAAA,MACA,SAASC;AAAAA,MACT,UAAU;AAAA,MACV,SAAS;AAAA,MACT,SAAS;AAAA,IAAA,CAAA,GAGT,KAAK,MAAM;AAAA,MACP,GAAG,KAAK;AAAA,MACR,GAAGF,EAAM;AAAA,IAAA;AAAA,EAEjB;AACJ;AACO,MAAMG,EAAW;AAAA,EAepB,YAAYH,GAAwB;AAd3BC,MAAA,MAAA,QAAO,OAAA,GACPA,EAAA,MAAA,WAAA,GACAA,EAAA,MAAA,OAKL;AAAA,MACA,WAAWC;AAAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MACX,SAAS;AAAA,IAAA,CAAA,GAIT,KAAK,YAAYF,EAAM,aAAa,IACpC,KAAK,MAAM;AAAA,MACP,GAAG,KAAK;AAAA,MACR,GAAGA,EAAM;AAAA,IAAA;AAAA,EAEjB;AACJ;AAIO,MAAMI,EAAyD;AAAA,EAwBlE,YAAYC,GAAmC;AAvBtCJ,MAAA,MAAA,IAAA,GACAA,EAAA,MAAA,QAAO,kBAAA,GACPA,EAAA,MAAA,WAAA,GACAA,EAAA,MAAA,GAAA,GACAA,EAAA,MAAA,GAAA,GACAA,EAAA,MAAA,UAAA,GAKAA,EAAA,MAAA,OAAA,GACAA,EAAA,MAAA,WAAA,GACAA,EAAA,MAAA,eAAA,GASAA,EAAA,MAAA,QAAA;;AAGLK,IAAAA,EAA8B,MAAMD,CAAQ,GAC5C,KAAK,KAAKE,EAAO,SAAS,UAAU,GACpC,KAAK,YAAYF,EAAS,aAAa,MACvC,KAAK,IAAIA,EAAS,GAClB,KAAK,IAAIA,EAAS,GAClB,KAAK,W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