@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,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
class
|
|
3
|
-
constructor(
|
|
4
|
-
|
|
1
|
+
var s = Object.defineProperty, l = (e, r, t) => r in e ? s(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, a = (e, r, t) => l(e, typeof r != "symbol" ? r + "" : r, t);
|
|
2
|
+
class c {
|
|
3
|
+
constructor(r, t) {
|
|
4
|
+
a(this, "hasError", !1), a(this, "calculatedData", null), this.data = r, this.settings = t;
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
7
|
export {
|
|
8
|
-
|
|
8
|
+
c as AbstractChart
|
|
9
9
|
};
|
|
10
10
|
//# sourceMappingURL=AbstractChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractChart.js","sources":["../../../../../node_modules/@milaboratories/miplots4/src/AbstractChart.ts"],"sourcesContent":["import type {DataFrame, DataSet} from './DataFrame';\nimport type {Settings, SettingsInterface} from './types';\n\nexport interface ChartInterface {\n calculatedData: Record<string, unknown> | null,\n mount: (node: HTMLElement) => void,\n unmount: () => void,\n updateSettingsAndData: (data: DataSet, settings: Settings) => void,\n updateChartState: (field: string, value: unknown) => void,\n export: () => string\n}\n\nexport abstract class AbstractChart implements ChartInterface {\n calculatedData = null as Record<string, unknown> | null;\n\n protected constructor(public data: DataFrame, public settings:SettingsInterface) {\n }\n\n abstract mount(node: HTMLElement): void;\n\n abstract unmount(): void;\n\n abstract updateSettingsAndData(data: DataSet, settings: Settings): void;\n\n abstract updateChartState(field: string, value: unknown): void;\n\n abstract export():string;\n}\n"],"names":["AbstractChart","data","settings","__publicField"],"mappings":";
|
|
1
|
+
{"version":3,"file":"AbstractChart.js","sources":["../../../../../node_modules/@milaboratories/miplots4/src/AbstractChart.ts"],"sourcesContent":["import type {DataFrame, DataSet} from './DataFrame';\nimport type {Settings, SettingsInterface} from './types';\n\nexport interface ChartInterface {\n hasError: boolean,\n calculatedData: Record<string, unknown> | null,\n mount: (node: HTMLElement) => void,\n unmount: () => void,\n updateSettingsAndData: (data: DataSet, settings: Settings) => void,\n updateChartState: (field: string, value: unknown) => void,\n export: () => string\n}\n\nexport abstract class AbstractChart implements ChartInterface {\n hasError = false;\n calculatedData = null as Record<string, unknown> | null;\n\n protected constructor(public data: DataFrame, public settings:SettingsInterface) {\n }\n\n abstract mount(node: HTMLElement): void;\n\n abstract unmount(): void;\n\n abstract updateSettingsAndData(data: DataSet, settings: Settings): void;\n\n abstract updateChartState(field: string, value: unknown): void;\n\n abstract export():string;\n}\n"],"names":["AbstractChart","data","settings","__publicField"],"mappings":";AAaO,MAAeA,EAAwC;AAAA,EAIhD,YAAmBC,GAAwBC,GAA4B;AAHjFC,IAAAA,EAAA,MAAA,YAAW,EAAA,GACXA,EAAA,MAAA,kBAAiB,IAAA,GAEY,KAAA,OAAAF,GAAwB,KAAA,WAAAC;AAAAA,EACrD;AAWJ;","x_google_ignoreList":[0]}
|
|
@@ -5,12 +5,12 @@ import { ChartHistogram as m } from "./histogram/index.js";
|
|
|
5
5
|
import { ChartScatterplot as p } from "./scatterplot/index.js";
|
|
6
6
|
import { ChartScatterplotUmap as f } from "./scatterplot-umap/index.js";
|
|
7
7
|
import { ChartBubble as d } from "./bubble/index.js";
|
|
8
|
-
import { DataFrame as
|
|
8
|
+
import { DataFrame as s } from "./DataFrame.js";
|
|
9
9
|
import { exhaustive as l } from "./utils/index.js";
|
|
10
|
-
var C = Object.defineProperty, b = (o, t, r) => t in o ? C(o, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[t] = r,
|
|
10
|
+
var C = Object.defineProperty, b = (o, t, r) => t in o ? C(o, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[t] = r, i = (o, t, r) => b(o, typeof t != "symbol" ? t + "" : t, r);
|
|
11
11
|
class h {
|
|
12
12
|
constructor(t) {
|
|
13
|
-
|
|
13
|
+
i(this, "node"), i(this, "chart"), this.chart = t;
|
|
14
14
|
}
|
|
15
15
|
static createChart(t, r, e) {
|
|
16
16
|
const { type: a } = r;
|
|
@@ -31,12 +31,15 @@ class h {
|
|
|
31
31
|
l(a, `Unknown chart type: ${a}`);
|
|
32
32
|
}
|
|
33
33
|
static newPlot(t, r, e) {
|
|
34
|
-
const a =
|
|
34
|
+
const a = s.from(t);
|
|
35
35
|
return new this(h.createChart(a, r, e));
|
|
36
36
|
}
|
|
37
37
|
get calculatedData() {
|
|
38
38
|
return this.chart.calculatedData;
|
|
39
39
|
}
|
|
40
|
+
get hasError() {
|
|
41
|
+
return this.chart.hasError;
|
|
42
|
+
}
|
|
40
43
|
mount(t) {
|
|
41
44
|
this.node = t, this.chart.mount(t);
|
|
42
45
|
}
|
|
@@ -48,7 +51,7 @@ class h {
|
|
|
48
51
|
const e = h.createChart(this.chart.data, r);
|
|
49
52
|
this.node ? (this.chart.unmount(), this.chart = e, this.chart.mount(this.node)) : this.chart = e;
|
|
50
53
|
} else
|
|
51
|
-
this.chart.updateSettingsAndData(
|
|
54
|
+
this.chart.updateSettingsAndData(s.from(t), r);
|
|
52
55
|
}
|
|
53
56
|
updateChartState(t, r) {
|
|
54
57
|
this.chart.updateChartState(t, r);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiPlots.js","sources":["../../../../../node_modules/@milaboratories/miplots4/src/MiPlots.ts"],"sourcesContent":["import type {AbstractChart, ChartInterface} from './AbstractChart';\nimport {ChartDendro} from './dendro';\nimport {ChartDiscrete} from './discrete';\nimport {ChartHeatmap} from './heatmap';\nimport {ChartHistogram} from './histogram';\nimport {ChartScatterplot} from './scatterplot';\nimport {ChartScatterplotUmap} from './scatterplot-umap';\nimport {ChartBubble} from './bubble';\nimport {DataFrame} from './DataFrame';\nimport type {\n BubbleEventHandlers,\n ChartEventHandlers,\n DendroEventHandlers,\n DiscreteEventHandlers,\n HeatmapEventHandlers,\n HistogramEventHandlers,\n ScatterplotEventHandlers,\n Settings,\n} from './types';\nimport {exhaustive} from './utils';\nimport type {DataSet} from './DataFrame';\n\nexport class MiPlots implements ChartInterface {\n node?: HTMLElement;\n chart: AbstractChart;\n\n private static createChart(\n data: DataFrame,\n settings: Settings,\n eventHandlers?: ChartEventHandlers<unknown>\n ): AbstractChart {\n const {type} = settings;\n\n if (type === 'discrete') {\n return new ChartDiscrete(data, settings, eventHandlers as DiscreteEventHandlers);\n }\n\n if (type === 'dendro') {\n return new ChartDendro(data, settings, eventHandlers as DendroEventHandlers);\n }\n\n if (type === 'scatterplot') {\n return new ChartScatterplot(data, settings, eventHandlers as ScatterplotEventHandlers);\n }\n\n if (type === 'scatterplot-umap') {\n return new ChartScatterplotUmap(data, settings, eventHandlers as ScatterplotEventHandlers);\n }\n\n if (type === 'heatmap') {\n return new ChartHeatmap(data, settings, eventHandlers as HeatmapEventHandlers);\n }\n\n if (type === 'histogram') {\n return new ChartHistogram(data, settings, eventHandlers as HistogramEventHandlers);\n }\n\n if (type === 'bubble') {\n return new ChartBubble(data, settings, eventHandlers as BubbleEventHandlers);\n }\n\n exhaustive(type, `Unknown chart type: ${type}`);\n }\n\n static newPlot(data: DataSet, settings: Settings, eventHandlers?: ChartEventHandlers<unknown>): MiPlots {\n const dataFrame = DataFrame.from(data);\n return new this(MiPlots.createChart(dataFrame, settings, eventHandlers));\n }\n\n constructor(chart: AbstractChart) {\n this.chart = chart;\n }\n\n get calculatedData() {\n return this.chart.calculatedData;\n }\n\n mount(node: HTMLElement) {\n this.node = node;\n this.chart.mount(node);\n }\n\n unmount() {\n delete this.node;\n this.chart.unmount();\n }\n\n updateSettingsAndData(data: DataSet, settings: Settings) {\n if (settings.type !== this.chart.settings.type) {\n const newChart = MiPlots.createChart(this.chart.data, settings);\n\n if (this.node) {\n this.chart.unmount();\n this.chart = newChart;\n this.chart.mount(this.node);\n } else {\n this.chart = newChart;\n }\n } else {\n this.chart.updateSettingsAndData(DataFrame.from(data), settings);\n }\n }\n\n updateChartState(field: string, value: unknown) {\n this.chart.updateChartState(field, value);\n }\n\n export() {\n return this.chart.export();\n }\n}\n"],"names":["MiPlots","chart","__publicField","data","settings","eventHandlers","type","ChartDiscrete","ChartDendro","ChartScatterplot","ChartScatterplotUmap","ChartHeatmap","ChartHistogram","ChartBubble","exhaustive","dataFrame","DataFrame","node","newChart","field","value"],"mappings":";;;;;;;;;;AAsBO,MAAMA,EAAkC;AAAA,EA+C3C,YAAYC,GAAsB;AA9ClCC,IAAAA,EAAA,MAAA,MAAA,GACAA,EAAA,MAAA,OAAA,GA8CI,KAAK,QAAQD;AAAAA,EACjB;AAAA,EA7CA,OAAe,YACXE,GACAC,GACAC,GACa;AACb,UAAM,EAAC,MAAAC,EAAAA,IAAQF;AAEf,QAAIE,MAAS;AACT,aAAO,IAAIC,EAAcJ,GAAMC,GAAUC,CAAsC;AAGnF,QAAIC,MAAS;AACT,aAAO,IAAIE,EAAYL,GAAMC,G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AC5C;AAAA,EAEA,SAAS;AACL,WAAO,KAAK,MAAM,OAAA;AAAA,EACtB;AACJ;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"MiPlots.js","sources":["../../../../../node_modules/@milaboratories/miplots4/src/MiPlots.ts"],"sourcesContent":["import type {AbstractChart, ChartInterface} from './AbstractChart';\nimport {ChartDendro} from './dendro';\nimport {ChartDiscrete} from './discrete';\nimport {ChartHeatmap} from './heatmap';\nimport {ChartHistogram} from './histogram';\nimport {ChartScatterplot} from './scatterplot';\nimport {ChartScatterplotUmap} from './scatterplot-umap';\nimport {ChartBubble} from './bubble';\nimport {DataFrame} from './DataFrame';\nimport type {\n BubbleEventHandlers,\n ChartEventHandlers,\n DendroEventHandlers,\n DiscreteEventHandlers,\n HeatmapEventHandlers,\n HistogramEventHandlers,\n ScatterplotEventHandlers,\n Settings,\n} from './types';\nimport {exhaustive} from './utils';\nimport type {DataSet} from './DataFrame';\n\nexport class MiPlots implements ChartInterface {\n node?: HTMLElement;\n chart: AbstractChart;\n\n private static createChart(\n data: DataFrame,\n settings: Settings,\n eventHandlers?: ChartEventHandlers<unknown>\n ): AbstractChart {\n const {type} = settings;\n\n if (type === 'discrete') {\n return new ChartDiscrete(data, settings, eventHandlers as DiscreteEventHandlers);\n }\n\n if (type === 'dendro') {\n return new ChartDendro(data, settings, eventHandlers as DendroEventHandlers);\n }\n\n if (type === 'scatterplot') {\n return new ChartScatterplot(data, settings, eventHandlers as ScatterplotEventHandlers);\n }\n\n if (type === 'scatterplot-umap') {\n return new ChartScatterplotUmap(data, settings, eventHandlers as ScatterplotEventHandlers);\n }\n\n if (type === 'heatmap') {\n return new ChartHeatmap(data, settings, eventHandlers as HeatmapEventHandlers);\n }\n\n if (type === 'histogram') {\n return new ChartHistogram(data, settings, eventHandlers as HistogramEventHandlers);\n }\n\n if (type === 'bubble') {\n return new ChartBubble(data, settings, eventHandlers as BubbleEventHandlers);\n }\n\n exhaustive(type, `Unknown chart type: ${type}`);\n }\n\n static newPlot(data: DataSet, settings: Settings, eventHandlers?: ChartEventHandlers<unknown>): MiPlots {\n const dataFrame = DataFrame.from(data);\n return new this(MiPlots.createChart(dataFrame, settings, eventHandlers));\n }\n\n constructor(chart: AbstractChart) {\n this.chart = chart;\n }\n\n get calculatedData() {\n return this.chart.calculatedData;\n }\n\n get hasError() {\n return this.chart.hasError;\n }\n\n mount(node: HTMLElement) {\n this.node = node;\n this.chart.mount(node);\n }\n\n unmount() {\n delete this.node;\n this.chart.unmount();\n }\n\n updateSettingsAndData(data: DataSet, settings: Settings) {\n if (settings.type !== this.chart.settings.type) {\n const newChart = MiPlots.createChart(this.chart.data, settings);\n\n if (this.node) {\n this.chart.unmount();\n this.chart = newChart;\n this.chart.mount(this.node);\n } else {\n this.chart = newChart;\n }\n } else {\n this.chart.updateSettingsAndData(DataFrame.from(data), settings);\n }\n }\n\n updateChartState(field: string, value: unknown) {\n this.chart.updateChartState(field, value);\n }\n\n export() {\n return this.chart.export();\n }\n}\n"],"names":["MiPlots","chart","__publicField","data","settings","eventHandlers","type","ChartDiscrete","ChartDendro","ChartScatterplot","ChartScatterplotUmap","ChartHeatmap","ChartHistogram","ChartBubble","exhaustive","dataFrame","DataFrame","node","newChart","field","value"],"mappings":";;;;;;;;;;AAsBO,MAAMA,EAAkC;AAAA,EA+C3C,YAAYC,GAAsB;AA9ClCC,IAAAA,EAAA,MAAA,MAAA,GACAA,EAAA,MAAA,OAAA,GA8CI,KAAK,QAAQD;AAAAA,EACjB;AAAA,EA7CA,OAAe,YACXE,GACAC,GACAC,GACa;AACb,UAAM,EAAC,MAAAC,EAAAA,IAAQF;AAEf,QAAIE,MAAS;AACT,aAAO,IAAIC,EAAcJ,GAAMC,GAAUC,CAAsC;AAGnF,QAAIC,MAAS;AACT,aAAO,IAAIE,EAAYL,GAAMC,GAAUC,CAAoC;AAG/E,QAAIC,MAAS;AACT,aAAO,IAAIG,EAAiBN,GAAMC,GAAUC,CAAyC;AAGzF,QAAIC,MA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,MAAM,OAAA;AAAA,EACtB;AACJ;","x_google_ignoreList":[0]}
|
|
@@ -6,19 +6,19 @@ import D from "./ChartRenderer.js";
|
|
|
6
6
|
import { getCellTooltip as f } from "./getCellTooltip.js";
|
|
7
7
|
import { getGroupedCellsData as y } from "./getGroupedCellsData.js";
|
|
8
8
|
var b = Object.defineProperty, S = (n, t, e) => t in n ? b(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, s = (n, t, e) => S(n, typeof t != "symbol" ? t + "" : t, e);
|
|
9
|
-
class
|
|
9
|
+
class T extends C {
|
|
10
10
|
constructor(t, e, a) {
|
|
11
11
|
super(t, e), s(this, "settings"), s(this, "chartRenderer"), s(this, "onTooltipHintSwitch", () => {
|
|
12
|
-
}), s(this, "calculatedData", null), s(this, "_getTooltip", (
|
|
13
|
-
var
|
|
14
|
-
return this.calculatedData ? f(this.data,
|
|
12
|
+
}), s(this, "calculatedData", null), s(this, "_getTooltip", (r) => {
|
|
13
|
+
var l, o, i;
|
|
14
|
+
return this.calculatedData ? f(this.data, r, this.calculatedData.groupedCellsData.meta, (i = (o = (l = this.settings) == null ? void 0 : l.chartSettings) == null ? void 0 : o.tooltips) == null ? void 0 : i.content) : ["No data available"];
|
|
15
15
|
}), this.settings = new c(e), this.chartRenderer = new D(), a && (this.onTooltipHintSwitch = a[0]);
|
|
16
16
|
}
|
|
17
17
|
mount(t) {
|
|
18
18
|
try {
|
|
19
|
-
this.chartRenderer.init(t), this._updateData(), this._updateChart();
|
|
19
|
+
this.chartRenderer.init(t), this._updateData(), this._updateChart(), this.hasError = !1;
|
|
20
20
|
} catch (e) {
|
|
21
|
-
e instanceof Error && (this.chartRenderer.renderError(e.message), console.error(e));
|
|
21
|
+
this.hasError = !0, e instanceof Error && (this.chartRenderer.renderError(e.message), console.error(e));
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
unmount() {
|
|
@@ -26,10 +26,10 @@ class x extends C {
|
|
|
26
26
|
}
|
|
27
27
|
updateSettingsAndData(t, e) {
|
|
28
28
|
try {
|
|
29
|
-
const a = this.settings,
|
|
30
|
-
this.settings = new c(e), this.data = t, this._needUpdateCalculatedDataBySettings(a, this.settings) || this._needUpdateCalculatedDataByData(
|
|
29
|
+
const a = this.settings, r = this.data;
|
|
30
|
+
this.settings = new c(e), this.data = t, this._needUpdateCalculatedDataBySettings(a, this.settings) || this._needUpdateCalculatedDataByData(r, this.data) ? this._updateData() : this._updateAesInData(), this._updateChart(), this.hasError = !1;
|
|
31
31
|
} catch (a) {
|
|
32
|
-
a instanceof Error && (this.chartRenderer.renderError(a.message), console.error(a));
|
|
32
|
+
this.hasError = !0, a instanceof Error && (this.chartRenderer.renderError(a.message), console.error(a));
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
updateChartState(t, e) {
|
|
@@ -39,30 +39,30 @@ class x extends C {
|
|
|
39
39
|
return this._updateChart(), v(this.chartRenderer.component);
|
|
40
40
|
}
|
|
41
41
|
_needUpdateCalculatedDataBySettings(t, e) {
|
|
42
|
-
var a,
|
|
42
|
+
var a, r, l, o;
|
|
43
43
|
return t.facetBy.some((i, u) => {
|
|
44
|
-
var
|
|
45
|
-
return i.value !== ((
|
|
46
|
-
}) || ((a = t.normalization) == null ? void 0 : a.method) !== ((
|
|
44
|
+
var h;
|
|
45
|
+
return i.value !== ((h = e.facetBy[u]) == null ? void 0 : h.value);
|
|
46
|
+
}) || ((a = t.normalization) == null ? void 0 : a.method) !== ((r = e.normalization) == null ? void 0 : r.method) || ((l = t.normalization) == null ? void 0 : l.direction) !== ((o = e.normalization) == null ? void 0 : o.direction) || t.xColumn.value !== e.xColumn.value || t.yColumn.value !== e.yColumn.value || t.valueColumnColor.value !== e.valueColumnColor.value || t.valueColumnSize.value !== e.valueColumnSize.value || t.NAValueAs !== e.NAValueAs;
|
|
47
47
|
}
|
|
48
48
|
_needUpdateCalculatedDataByData(t, e) {
|
|
49
|
-
const a = Object.keys(t.data),
|
|
50
|
-
return t.id !== e.id || a.length !==
|
|
49
|
+
const a = Object.keys(t.data), r = Object.keys(e.data);
|
|
50
|
+
return t.id !== e.id || a.length !== r.length || a.some((l) => {
|
|
51
51
|
var o;
|
|
52
|
-
return t.data[
|
|
52
|
+
return t.data[l].length !== ((o = e.data[l]) == null ? void 0 : o.length);
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
_updateData() {
|
|
56
|
-
const { facetBy: t, xColumn: e, yColumn: a, valueColumnSize:
|
|
56
|
+
const { facetBy: t, xColumn: e, yColumn: a, valueColumnSize: r, valueColumnColor: l, normalization: o, NAValueAs: i } = this.settings, u = t.map((d) => this.data.getColumnCategories(d.value)), h = u.length ? g([...u]) : [["null"]], m = t.map((d) => d.value) ?? null;
|
|
57
57
|
this.data.setGrouping([...m]);
|
|
58
58
|
const p = y(
|
|
59
59
|
this.data,
|
|
60
60
|
e,
|
|
61
61
|
a,
|
|
62
|
-
l,
|
|
63
62
|
r,
|
|
63
|
+
l,
|
|
64
64
|
t,
|
|
65
|
-
|
|
65
|
+
h,
|
|
66
66
|
o,
|
|
67
67
|
i
|
|
68
68
|
);
|
|
@@ -76,15 +76,15 @@ class x extends C {
|
|
|
76
76
|
_updateChart() {
|
|
77
77
|
if (!this.calculatedData)
|
|
78
78
|
return;
|
|
79
|
-
const { id: t, chartSettings: e, facetSettings: a, valueColumnColor:
|
|
79
|
+
const { id: t, chartSettings: e, facetSettings: a, valueColumnColor: r, valueColumnSize: l, normalization: o, aes: i } = this.settings;
|
|
80
80
|
this.chartRenderer.render(
|
|
81
81
|
this.data,
|
|
82
82
|
t,
|
|
83
83
|
e,
|
|
84
84
|
a,
|
|
85
85
|
this.calculatedData.groupedCellsData,
|
|
86
|
-
l,
|
|
87
86
|
r,
|
|
87
|
+
l,
|
|
88
88
|
o,
|
|
89
89
|
i,
|
|
90
90
|
this._getTooltip,
|
|
@@ -93,6 +93,6 @@ class x extends C {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
export {
|
|
96
|
-
|
|
96
|
+
T as ChartBubble
|
|
97
97
|
};
|
|
98
98
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../node_modules/@milaboratories/miplots4/src/bubble/index.ts"],"sourcesContent":["import { renderToString } from 'react-dom/server';\nimport { AbstractChart } from '../AbstractChart';\nimport type { DataFrame } from '../DataFrame';\nimport type { BubbleEventHandlers, BubbleSettings } from '../types';\nimport { getKeysCombinations } from '../utils/getKeysCombination';\nimport { BubbleSettingsImpl } from './BubbleSettingsImpl';\nimport ChartRenderer from './ChartRenderer';\nimport { getCellTooltip } from './getCellTooltip';\nimport type { Cell, GroupedCellsData } from './getGroupedCellsData';\nimport { getGroupedCellsData } from './getGroupedCellsData';\n\nexport class ChartBubble extends AbstractChart {\n settings: BubbleSettingsImpl;\n chartRenderer: ChartRenderer;\n\n onTooltipHintSwitch: (v:boolean) => void = () => undefined;\n calculatedData: {\n groupedCellsData: GroupedCellsData;\n } | null = null;\n\n constructor(data: DataFrame, settings: BubbleSettings, eventHandlers?: BubbleEventHandlers) {\n super(data, settings);\n\n this.settings = new BubbleSettingsImpl(settings);\n this.chartRenderer = new ChartRenderer();\n if (eventHandlers) {\n this.onTooltipHintSwitch = eventHandlers[0];\n }\n }\n\n mount(node: HTMLElement) {\n try {\n this.chartRenderer.init(node);\n this._updateData();\n this._updateChart();\n } catch (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: BubbleSettings) {\n try {\n const previousSettings = this.settings;\n const previousData = this.data;\n this.settings = new BubbleSettingsImpl(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 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 bubble chart');\n }\n\n export(): string {\n this._updateChart();\n return renderToString(this.chartRenderer.component);\n }\n\n _needUpdateCalculatedDataBySettings(prevSettings: BubbleSettingsImpl, settings: BubbleSettingsImpl) {\n return prevSettings.facetBy.some((el, idx) => el.value !== settings.facetBy[idx]?.value) ||\n prevSettings.normalization?.method !== settings.normalization?.method ||\n prevSettings.normalization?.direction !== settings.normalization?.direction ||\n prevSettings.xColumn.value !== settings.xColumn.value ||\n prevSettings.yColumn.value !== settings.yColumn.value ||\n prevSettings.valueColumnColor.value !== settings.valueColumnColor.value ||\n prevSettings.valueColumnSize.value !== settings.valueColumnSize.value ||\n prevSettings.NAValueAs !== settings.NAValueAs;\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 {facetBy, xColumn, yColumn, valueColumnSize, valueColumnColor, normalization, NAValueAs} = this.settings;\n\n const facetKeysLists = facetBy.map(column => this.data.getColumnCategories(column.value));\n const facetKeysCombinations = facetKeysLists.length ? getKeysCombinations([...facetKeysLists]) : [['null']];\n const facetGroupingValues = facetBy.map(column => column.value) ?? null;\n\n this.data.setGrouping([...facetGroupingValues]);\n\n const groupedCellsData = getGroupedCellsData(\n this.data,\n xColumn,\n yColumn,\n valueColumnSize,\n valueColumnColor,\n facetBy,\n facetKeysCombinations,\n normalization,\n NAValueAs\n );\n this.calculatedData = {\n groupedCellsData,\n };\n }\n\n _updateAesInData() {\n const calculated = this.calculatedData;\n if (!calculated) {\n return;\n }\n }\n\n _updateChart() {\n if (!this.calculatedData) {\n return;\n }\n const {id, chartSettings, facetSettings, valueColumnColor, valueColumnSize, normalization, aes} = this.settings;\n this.chartRenderer.render(\n this.data,\n id,\n chartSettings,\n facetSettings,\n this.calculatedData.groupedCellsData,\n valueColumnColor,\n valueColumnSize,\n normalization,\n aes,\n this._getTooltip,\n this.onTooltipHintSwitch\n );\n }\n\n private _getTooltip = (cell: Cell): string[] => {\n return this.calculatedData\n ? getCellTooltip(this.data, cell, this.calculatedData.groupedCellsData.meta, this.settings?.chartSettings?.tooltips?.content)\n : ['No data available'];\n };\n}\n"],"names":["ChartBubble","AbstractChart","data","settings","eventHandlers","__publicField","cell","getCellTooltip","_c","_b","_a","BubbleSettingsImpl","ChartRenderer","node","err","previousSettings","previousData","_field","_value","renderToString","prevSettings","el","idx","_d","prevData","prevKeys","keys","key","facetBy","xColumn","yColumn","valueColumnSize","valueColumnColor","normalization","NAValueAs","facetKeysLists","column","facetKeysCombinations","getKeysCombinations","facetGroupingValues","groupedCellsData","getGroupedCellsData","id","chartSettings","facetSettings","aes"],"mappings":";;;;;;;;AAWO,MAAMA,UAAoBC,EAAc;AAAA,EAS3C,YAAYC,GAAiBC,GAA0BC,GAAqC;AACxF,UAAMF,GAAMC,CAAQ,GATxBE,EAAA,MAAA,UAAA,GACAA,EAAA,MAAA,eAAA,GAEAA,EAAA,6BAA2C,MAAA;AAAA,IAAA,CAAA,GAC3CA,EAAA,MAAA,kBAEW,IAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../node_modules/@milaboratories/miplots4/src/bubble/index.ts"],"sourcesContent":["import { renderToString } from 'react-dom/server';\nimport { AbstractChart } from '../AbstractChart';\nimport type { DataFrame } from '../DataFrame';\nimport type { BubbleEventHandlers, BubbleSettings } from '../types';\nimport { getKeysCombinations } from '../utils/getKeysCombination';\nimport { BubbleSettingsImpl } from './BubbleSettingsImpl';\nimport ChartRenderer from './ChartRenderer';\nimport { getCellTooltip } from './getCellTooltip';\nimport type { Cell, GroupedCellsData } from './getGroupedCellsData';\nimport { getGroupedCellsData } from './getGroupedCellsData';\n\nexport class ChartBubble extends AbstractChart {\n settings: BubbleSettingsImpl;\n chartRenderer: ChartRenderer;\n\n onTooltipHintSwitch: (v:boolean) => void = () => undefined;\n calculatedData: {\n groupedCellsData: GroupedCellsData;\n } | null = null;\n\n constructor(data: DataFrame, settings: BubbleSettings, eventHandlers?: BubbleEventHandlers) {\n super(data, settings);\n\n this.settings = new BubbleSettingsImpl(settings);\n this.chartRenderer = new ChartRenderer();\n if (eventHandlers) {\n this.onTooltipHintSwitch = eventHandlers[0];\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 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: BubbleSettings) {\n try {\n const previousSettings = this.settings;\n const previousData = this.data;\n this.settings = new BubbleSettingsImpl(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 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 bubble chart');\n }\n\n export(): string {\n this._updateChart();\n return renderToString(this.chartRenderer.component);\n }\n\n _needUpdateCalculatedDataBySettings(prevSettings: BubbleSettingsImpl, settings: BubbleSettingsImpl) {\n return prevSettings.facetBy.some((el, idx) => el.value !== settings.facetBy[idx]?.value) ||\n prevSettings.normalization?.method !== settings.normalization?.method ||\n prevSettings.normalization?.direction !== settings.normalization?.direction ||\n prevSettings.xColumn.value !== settings.xColumn.value ||\n prevSettings.yColumn.value !== settings.yColumn.value ||\n prevSettings.valueColumnColor.value !== settings.valueColumnColor.value ||\n prevSettings.valueColumnSize.value !== settings.valueColumnSize.value ||\n prevSettings.NAValueAs !== settings.NAValueAs;\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 {facetBy, xColumn, yColumn, valueColumnSize, valueColumnColor, normalization, NAValueAs} = this.settings;\n\n const facetKeysLists = facetBy.map(column => this.data.getColumnCategories(column.value));\n const facetKeysCombinations = facetKeysLists.length ? getKeysCombinations([...facetKeysLists]) : [['null']];\n const facetGroupingValues = facetBy.map(column => column.value) ?? null;\n\n this.data.setGrouping([...facetGroupingValues]);\n\n const groupedCellsData = getGroupedCellsData(\n this.data,\n xColumn,\n yColumn,\n valueColumnSize,\n valueColumnColor,\n facetBy,\n facetKeysCombinations,\n normalization,\n NAValueAs\n );\n this.calculatedData = {\n groupedCellsData,\n };\n }\n\n _updateAesInData() {\n const calculated = this.calculatedData;\n if (!calculated) {\n return;\n }\n }\n\n _updateChart() {\n if (!this.calculatedData) {\n return;\n }\n const {id, chartSettings, facetSettings, valueColumnColor, valueColumnSize, normalization, aes} = this.settings;\n this.chartRenderer.render(\n this.data,\n id,\n chartSettings,\n facetSettings,\n this.calculatedData.groupedCellsData,\n valueColumnColor,\n valueColumnSize,\n normalization,\n aes,\n this._getTooltip,\n this.onTooltipHintSwitch\n );\n }\n\n private _getTooltip = (cell: Cell): string[] => {\n return this.calculatedData\n ? getCellTooltip(this.data, cell, this.calculatedData.groupedCellsData.meta, this.settings?.chartSettings?.tooltips?.content)\n : ['No data available'];\n };\n}\n"],"names":["ChartBubble","AbstractChart","data","settings","eventHandlers","__publicField","cell","getCellTooltip","_c","_b","_a","BubbleSettingsImpl","ChartRenderer","node","err","previousSettings","previousData","_field","_value","renderToString","prevSettings","el","idx","_d","prevData","prevKeys","keys","o","key","facetBy","xColumn","yColumn","valueColumnSize","valueColumnColor","normalization","NAValueAs","facetKeysLists","column","facetKeysCombinations","getKeysCombinations","facetGroupingValues","groupedCellsData","getGroupedCellsData","id","chartSettings","facetSettings","aes"],"mappings":";;;;;;;;AAWO,MAAMA,UAAoBC,EAAc;AAAA,EAS3C,YAAYC,GAAiBC,GAA0BC,GAAqC;AACxF,UAAMF,GAAMC,CAAQ,GATxBE,EAAA,MAAA,UAAA,GACAA,EAAA,MAAA,eAAA,GAEAA,EAAA,6BAA2C,MAAA;AAAA,IAAA,CAAA,GAC3CA,EAAA,MAAA,kBAEW,IAAA,GA0IHA,EAAA,MAAA,eAAc,CAACC,MAAyB;;AAC5C,aAAO,KAAK,iBACNC,EAAe,KAAK,MAAMD,GAAM,KAAK,eAAe,iBAAiB,OAAME,KAAAC,KAAAC,IAAA,KAAK,aAAL,OAAA,SAAAA,EAAe,kBAAf,OAAA,SAAAD,EAA8B,aAA9B,OAAA,SAAAD,EAAwC,OAAO,IAC1H,CAAC,mBAAmB;AAAA,IAC9B,CAAA,GAzII,KAAK,WAAW,IAAIG,EAAmBR,CAAQ,GAC/C,KAAK,gBAAgB,IAAIS,EAAAA,GACrBR,MACA,KAAK,sBAAsBA,EAAc,CAAC;AAAA,EAElD;AAAA,EAEA,MAAMS,GAAmB;AACrB,QAAI;AACA,WAAK,cAAc,KAAKA,CAAI,GAC5B,KAAK,eACL,KAAK,aAAA,GACL,KAAK,WAAW;AAAA,IACpB,SAASC,GAAK;AACV,WAAK,WAAW,IACZA,aAAe,UACf,KAAK,cAAc,YAAYA,EAAI,OAAiB,GACpD,QAAQ,MAAMA,CAAG;AAAA,IAEzB;AAAA,EACJ;AAAA,EAEA,UAAU;AACN,SAAK,cAAc,MAAA;AAAA,EACvB;AAAA,EAEA,sBAAsBZ,GAAiBC,GAA0B;AAC7D,QAAI;AACA,YAAMY,IAAmB,KAAK,UACxBC,IAAe,KAAK;AAC1B,WAAK,WAAW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AAA,MACAE;AAAAA,MACAY;AAAAA,MACA,KAAK;AAAA,MACL,KAAK;AAAA,IAAA;AAAA,EAEb;AAOJ;","x_google_ignoreList":[0]}
|
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
function
|
|
3
|
-
return /* @__PURE__ */
|
|
4
|
-
"div",
|
|
5
|
-
{
|
|
6
|
-
style: {
|
|
7
|
-
width: "500px",
|
|
8
|
-
height: "400px",
|
|
9
|
-
color: "#ee1616",
|
|
10
|
-
display: "flex",
|
|
11
|
-
alignItems: "center",
|
|
12
|
-
justifyContent: "center",
|
|
13
|
-
fontSize: "25px",
|
|
14
|
-
fontFamily: "Arial",
|
|
15
|
-
border: "1px solid",
|
|
16
|
-
padding: "20px",
|
|
17
|
-
lineHeight: "25px"
|
|
18
|
-
},
|
|
19
|
-
children: e
|
|
20
|
-
}
|
|
21
|
-
);
|
|
1
|
+
import { j as r } from "../node_modules/react/jsx-runtime.js";
|
|
2
|
+
function e({ message: t }) {
|
|
3
|
+
return /* @__PURE__ */ r.jsx("div", { style: { width: "500px", height: "400px" } });
|
|
22
4
|
}
|
|
23
5
|
export {
|
|
24
|
-
|
|
6
|
+
e as Error
|
|
25
7
|
};
|
|
26
8
|
//# sourceMappingURL=Error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Error.js","sources":["../../../../../../node_modules/@milaboratories/miplots4/src/common/Error.tsx"],"sourcesContent":["import React from 'react';\n\nexport function Error({message}: {message
|
|
1
|
+
{"version":3,"file":"Error.js","sources":["../../../../../../node_modules/@milaboratories/miplots4/src/common/Error.tsx"],"sourcesContent":["import React from 'react';\n\nexport function Error({message}: {message?:string}) {\n return (\n <div style={{width: '500px', height: '400px'}} />\n );\n}\n"],"names":["Error","message","jsx"],"mappings":";AAEO,SAASA,EAAM,EAAC,SAAAC,KAA6B;AAChD,SACIC,gBAAAA,EAAAA,IAAC,OAAA,EAAI,OAAO,EAAC,OAAO,SAAS,QAAQ,QAAA,GAAU;AAEvD;","x_google_ignoreList":[0]}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
import { l as y } from "../node_modules/lodash/lodash.js";
|
|
2
|
-
import { renderToString as
|
|
2
|
+
import { renderToString as E } from "../node_modules/react-dom/server.browser.js";
|
|
3
3
|
import { undefined as C } from "../node_modules/zod/lib/index.js";
|
|
4
|
-
import { AbstractChart as
|
|
5
|
-
import
|
|
6
|
-
import { USER_UPDATE_EVENT as
|
|
4
|
+
import { AbstractChart as S } from "../AbstractChart.js";
|
|
5
|
+
import A from "./ChartRenderer.js";
|
|
6
|
+
import { USER_UPDATE_EVENT as _ } from "./constants.js";
|
|
7
7
|
import { DendroSettingsImpl as D } from "./DendroSettingsImpl.js";
|
|
8
8
|
import { getHeatmapData as w } from "./getHeatmapData.js";
|
|
9
9
|
import { getHierarchy as L } from "./getHierarchyData.js";
|
|
10
|
-
var R = Object.defineProperty, N = (
|
|
11
|
-
function g(
|
|
12
|
-
return typeof
|
|
10
|
+
var R = Object.defineProperty, N = (i, e, t) => e in i ? R(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, v = (i, e, t) => N(i, typeof e != "symbol" ? e + "" : e, t);
|
|
11
|
+
function g(i) {
|
|
12
|
+
return typeof i != "object" ? !1 : "valuesMap" in i;
|
|
13
13
|
}
|
|
14
|
-
function f(
|
|
15
|
-
const { nodeColor: t, nodeShape: a, lineColor:
|
|
14
|
+
function f(i, e) {
|
|
15
|
+
const { nodeColor: t, nodeShape: a, lineColor: s } = e, h = [t, a, s].filter(
|
|
16
16
|
g
|
|
17
17
|
);
|
|
18
|
-
return y.uniqBy(h, (
|
|
19
|
-
const { columnName: n } = p,
|
|
20
|
-
(n.valueLabels ?
|
|
21
|
-
), u = /* @__PURE__ */ new Set(), d =
|
|
22
|
-
return g(t) && n.value === t.columnName.value && (u.add("dotFill"),
|
|
23
|
-
d[
|
|
24
|
-
})), g(a) && n.value === a.columnName.value && (u.add("dotShape"),
|
|
25
|
-
d[
|
|
26
|
-
})), g(
|
|
27
|
-
d[
|
|
28
|
-
})),
|
|
29
|
-
values:
|
|
18
|
+
return y.uniqBy(h, (l) => l.columnName.value).reduce((l, p) => {
|
|
19
|
+
const { columnName: n } = p, o = i.getColumnCategories(n.value, !1), c = (r) => String(
|
|
20
|
+
(n.valueLabels ? i.getColumnValue(n.valueLabels, i.getColumnCategoryRowIndex(n.value, r)) : C) ?? r
|
|
21
|
+
), u = /* @__PURE__ */ new Set(), d = o.reduce((r, m) => (r[m] || (r[m] = {}), r), {});
|
|
22
|
+
return g(t) && n.value === t.columnName.value && (u.add("dotFill"), o.forEach((r) => {
|
|
23
|
+
d[r].dotFill = t.valuesMap[r];
|
|
24
|
+
})), g(a) && n.value === a.columnName.value && (u.add("dotShape"), o.forEach((r) => {
|
|
25
|
+
d[r].dotShape = a.valuesMap[r];
|
|
26
|
+
})), g(s) && n.value === s.columnName.value && (u.add("lineColor"), o.forEach((r) => {
|
|
27
|
+
d[r].lineColor = s.valuesMap[r];
|
|
28
|
+
})), l[n.value] = {
|
|
29
|
+
values: o.sort(),
|
|
30
30
|
usedAes: [...u],
|
|
31
31
|
aesMap: d,
|
|
32
|
-
labels:
|
|
33
|
-
},
|
|
32
|
+
labels: o.reduce((r, m) => (r[m] = c(m), r), {})
|
|
33
|
+
}, l;
|
|
34
34
|
}, {});
|
|
35
35
|
}
|
|
36
|
-
class z extends
|
|
36
|
+
class z extends S {
|
|
37
37
|
constructor(e, t, a) {
|
|
38
|
-
super(e, t), v(this, "settings"), v(this, "onClick", () => C), v(this, "chartRenderer", new
|
|
38
|
+
super(e, t), v(this, "settings"), v(this, "onClick", () => C), v(this, "chartRenderer", new A()), v(this, "calculatedData", null), this.settings = new D(t), a && (this.onClick = a[0]);
|
|
39
39
|
}
|
|
40
40
|
mount(e) {
|
|
41
41
|
try {
|
|
42
|
-
this.chartRenderer.init(e), this._updateData(), this._updateChart();
|
|
42
|
+
this.chartRenderer.init(e), this._updateData(), this._updateChart(), this.hasError = !1;
|
|
43
43
|
} catch (t) {
|
|
44
|
-
t instanceof Error && (this.chartRenderer.renderError(t.message), console.error(t));
|
|
44
|
+
this.hasError = !0, t instanceof Error && (this.chartRenderer.renderError(t.message), console.error(t));
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
unmount() {
|
|
@@ -49,50 +49,50 @@ class z extends A {
|
|
|
49
49
|
}
|
|
50
50
|
updateSettingsAndData(e, t) {
|
|
51
51
|
try {
|
|
52
|
-
const a = this.settings,
|
|
53
|
-
this.settings = new D(t), this.data = e, this._needUpdateCalculatedDataBySettings(a, this.settings) || this._needUpdateCalculatedDataByData(
|
|
52
|
+
const a = this.settings, s = this.data;
|
|
53
|
+
this.settings = new D(t), this.data = e, this._needUpdateCalculatedDataBySettings(a, this.settings) || this._needUpdateCalculatedDataByData(s, this.data) ? this._updateData() : this._updateAesInData(), this._updateChart(), this.hasError = !1;
|
|
54
54
|
} catch (a) {
|
|
55
|
-
a instanceof Error && (this.chartRenderer.renderError(a.message), console.error(a));
|
|
55
|
+
this.hasError = !0, a instanceof Error && (this.chartRenderer.renderError(a.message), console.error(a));
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
updateChartState(e, t) {
|
|
59
59
|
if (document) {
|
|
60
|
-
const a = new CustomEvent(
|
|
60
|
+
const a = new CustomEvent(_, { detail: { [e]: t } });
|
|
61
61
|
document.dispatchEvent(a);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
export() {
|
|
65
|
-
return this._updateChart(),
|
|
65
|
+
return this._updateChart(), E(this.chartRenderer.component);
|
|
66
66
|
}
|
|
67
67
|
_needUpdateCalculatedDataBySettings(e, t) {
|
|
68
|
-
var a,
|
|
69
|
-
const { mode: h, id:
|
|
70
|
-
function u(d,
|
|
71
|
-
return d.length !==
|
|
68
|
+
var a, s;
|
|
69
|
+
const { mode: h, id: l, parentId: p, heatmapAnnotation: n, heatmapAxis: o, heatmapGroup: c } = t;
|
|
70
|
+
function u(d, r) {
|
|
71
|
+
return d.length !== r.length || d.some((m, b) => m.value !== r[b].value);
|
|
72
72
|
}
|
|
73
|
-
return e.mode !== h || e.id.value !==
|
|
73
|
+
return e.mode !== h || e.id.value !== l.value || e.parentId.value !== p.value || ((a = e.heatmapAnnotation) == null ? void 0 : a.value) !== (n == null ? void 0 : n.value) || ((s = e.heatmapAxis) == null ? void 0 : s.value) !== (o == null ? void 0 : o.value) || u(e.heatmapGroup, c);
|
|
74
74
|
}
|
|
75
75
|
_needUpdateCalculatedDataByData(e, t) {
|
|
76
|
-
const a = Object.keys(e.data),
|
|
77
|
-
return e.id !== t.id || a.length !==
|
|
78
|
-
var
|
|
79
|
-
return e.data[h].length !== ((
|
|
76
|
+
const a = Object.keys(e.data), s = Object.keys(t.data);
|
|
77
|
+
return e.id !== t.id || a.length !== s.length || a.some((h) => {
|
|
78
|
+
var l;
|
|
79
|
+
return e.data[h].length !== ((l = t.data[h]) == null ? void 0 : l.length);
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
_updateData() {
|
|
83
|
-
const { mode: e, id: t, parentId: a, aes:
|
|
83
|
+
const { mode: e, id: t, parentId: a, aes: s, heatmapAnnotation: h, heatmapAxis: l, heatmapGroup: p, heatmapSettings: n, height: o, labels: c } = this.settings, u = L(
|
|
84
84
|
this.data,
|
|
85
85
|
t.value,
|
|
86
86
|
a.value,
|
|
87
|
-
(
|
|
87
|
+
(o == null ? void 0 : o.value) ?? null,
|
|
88
88
|
c.valueLabels ?? c.value ?? null,
|
|
89
89
|
e === "useAllNodesAsLeaves"
|
|
90
|
-
), d = w(this.data, n.valueType, h,
|
|
90
|
+
), d = w(this.data, n.valueType, h, l, p, t, u), r = f(this.data, s);
|
|
91
91
|
this.calculatedData = {
|
|
92
92
|
chartSizes: this.chartRenderer.chartSizes,
|
|
93
93
|
hierarchy: u,
|
|
94
94
|
heatmapData: d,
|
|
95
|
-
legendLabels:
|
|
95
|
+
legendLabels: r
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
_updateAesInData() {
|
|
@@ -105,16 +105,16 @@ class z extends A {
|
|
|
105
105
|
heatmapAnnotation: e,
|
|
106
106
|
chartSettings: t,
|
|
107
107
|
connectionType: a,
|
|
108
|
-
edgeInheritance:
|
|
108
|
+
edgeInheritance: s,
|
|
109
109
|
rootPosition: h,
|
|
110
|
-
showNodes:
|
|
110
|
+
showNodes: l,
|
|
111
111
|
showEdges: p,
|
|
112
112
|
showLeavesLabels: n,
|
|
113
|
-
showNodesLabels:
|
|
113
|
+
showNodesLabels: o,
|
|
114
114
|
aes: c,
|
|
115
115
|
labels: u,
|
|
116
116
|
heatmapSettings: d,
|
|
117
|
-
leavesMode:
|
|
117
|
+
leavesMode: r
|
|
118
118
|
} = this.settings;
|
|
119
119
|
this.chartRenderer.render(
|
|
120
120
|
this.data,
|
|
@@ -122,18 +122,18 @@ class z extends A {
|
|
|
122
122
|
this.calculatedData.hierarchy,
|
|
123
123
|
a,
|
|
124
124
|
h,
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
s,
|
|
126
|
+
l,
|
|
127
127
|
p,
|
|
128
128
|
n,
|
|
129
|
-
|
|
129
|
+
o,
|
|
130
130
|
c,
|
|
131
131
|
u,
|
|
132
132
|
e,
|
|
133
133
|
this.calculatedData.heatmapData,
|
|
134
134
|
d,
|
|
135
135
|
this.calculatedData.legendLabels,
|
|
136
|
-
|
|
136
|
+
r,
|
|
137
137
|
this.onClick
|
|
138
138
|
);
|
|
139
139
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../node_modules/@milaboratories/miplots4/src/dendro/index.ts"],"sourcesContent":["import type { HierarchyNode } from 'd3-hierarchy';\nimport { uniqBy } from 'lodash';\nimport { renderToString } from 'react-dom/server';\nimport { undefined } from 'zod';\nimport { AbstractChart } from '../AbstractChart';\nimport type { DataFrame } from '../DataFrame';\nimport type {\n AesItem,\n AesRecord,\n CategoricalAesFromColumn,\n Category,\n ClickEventData,\n ColumnName,\n ContinuousAesFromColumn,\n DendroEventHandlers,\n DendroLegendInfo,\n DendroSettings,\n LineShape,\n PointShape\n} from '../types';\nimport ChartRenderer from './ChartRenderer';\nimport type { ChartSizes } from './components/types';\nimport { USER_UPDATE_EVENT } from './constants';\nimport { DendroSettingsImpl } from './DendroSettingsImpl';\nimport type { HeatmapData } from './getHeatmapData';\nimport { getHeatmapData } from './getHeatmapData';\nimport type { TreeNodeData } from './getHierarchyData';\nimport { getHierarchy } from './getHierarchyData';\n\nfunction isCategoricalAes<InputType extends string | number | PointShape | LineShape>(\n item: InputType | CategoricalAesFromColumn<InputType> | ContinuousAesFromColumn<InputType>\n): item is CategoricalAesFromColumn<InputType> {\n if (typeof item !== 'object') {\n return false;\n }\n return 'valuesMap' in item;\n}\nfunction getLegendLabelsMap(data: DataFrame, aes: DendroSettingsImpl['aes']): DendroLegendInfo {\n const {nodeColor, nodeShape, lineColor} = aes;\n const aesGrouping: CategoricalAesFromColumn<string | PointShape>[] = [nodeColor, nodeShape, lineColor].filter(\n isCategoricalAes\n );\n const uniqueColumns = uniqBy(aesGrouping, item => item.columnName.value);\n return uniqueColumns.reduce((res: DendroLegendInfo, item) => {\n const {columnName} = item;\n const categories = data.getColumnCategories(columnName.value, false);\n const getValueLabel = (category: Category) => String(\n (columnName.valueLabels\n ? data.getColumnValue(columnName.valueLabels, data.getColumnCategoryRowIndex(columnName.value, category))\n : undefined\n ) ?? category\n );\n\n const usedAes = new Set<keyof AesItem>();\n const aesMap: AesRecord = categories.reduce((res: AesRecord, category) => {\n if (!res[category]) {\n res[category] = {} as AesItem;\n }\n return res;\n }, {});\n if (isCategoricalAes(nodeColor) && columnName.value === nodeColor.columnName.value) {\n usedAes.add('dotFill');\n categories.forEach(category => {\n aesMap[category]['dotFill'] = nodeColor.valuesMap[category];\n });\n }\n if (isCategoricalAes(nodeShape) && columnName.value === nodeShape.columnName.value) {\n usedAes.add('dotShape');\n categories.forEach(category => {\n aesMap[category]['dotShape'] = nodeShape.valuesMap[category];\n });\n }\n if (isCategoricalAes(lineColor) && columnName.value === lineColor.columnName.value) {\n usedAes.add('lineColor');\n categories.forEach(category => {\n aesMap[category]['lineColor'] = lineColor.valuesMap[category];\n });\n }\n res[columnName.value] = {\n values: categories.sort(),\n usedAes: [...usedAes],\n aesMap,\n labels: categories.reduce((res: Record<string, string>, category) => {\n res[category] = getValueLabel(category);\n return res;\n }, {}),\n };\n return res;\n }, {});\n}\n\nexport class ChartDendro extends AbstractChart {\n settings: DendroSettingsImpl;\n onClick: (data: ClickEventData) => void = () => undefined;\n chartRenderer = new ChartRenderer();\n\n calculatedData: {\n chartSizes: ChartSizes;\n hierarchy: HierarchyNode<TreeNodeData>;\n heatmapData: HeatmapData | null;\n legendLabels: DendroLegendInfo;\n } | null = null;\n\n constructor(data: DataFrame, settings: DendroSettings, eventHandlers?: DendroEventHandlers) {\n super(data, settings);\n\n this.settings = new DendroSettingsImpl(settings);\n if (eventHandlers) {\n this.onClick = eventHandlers[0];\n }\n }\n\n mount(node: HTMLElement) {\n try {\n this.chartRenderer.init(node);\n this._updateData();\n this._updateChart();\n } catch (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: DendroSettings) {\n try {\n const previousSettings = this.settings;\n const previousData = this.data;\n this.settings = new DendroSettingsImpl(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 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 if (document) {\n const event = new CustomEvent(USER_UPDATE_EVENT, {detail: {[field]: value}});\n document.dispatchEvent(event);\n }\n }\n\n export(): string {\n this._updateChart();\n return renderToString(this.chartRenderer.component);\n }\n\n _needUpdateCalculatedDataBySettings(prevSettings: DendroSettingsImpl, settings: DendroSettingsImpl) {\n const {mode, id, parentId, heatmapAnnotation, heatmapAxis, heatmapGroup} = settings;\n\n function compareColumnGroups(columns1: ColumnName[], columns2: ColumnName[]) {\n return (\n columns1.length !== columns2.length ||\n columns1.some((column, idx) => column.value !== columns2[idx].value)\n );\n }\n\n return (\n prevSettings.mode !== mode ||\n prevSettings.id.value !== id.value ||\n prevSettings.parentId.value !== parentId.value ||\n prevSettings.heatmapAnnotation?.value !== heatmapAnnotation?.value ||\n prevSettings.heatmapAxis?.value !== heatmapAxis?.value ||\n compareColumnGroups(prevSettings.heatmapGroup, heatmapGroup)\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 {mode, id, parentId, aes, heatmapAnnotation, heatmapAxis, heatmapGroup, heatmapSettings, height, labels} = this.settings;\n const hierarchy = getHierarchy(\n this.data,\n id.value,\n parentId.value,\n height?.value ?? null,\n labels.valueLabels ?? labels.value ?? null,\n mode === 'useAllNodesAsLeaves'\n );\n const heatmapData = getHeatmapData(this.data, heatmapSettings.valueType, heatmapAnnotation, heatmapAxis, heatmapGroup, id, hierarchy);\n\n const legendLabels = getLegendLabelsMap(this.data, aes);\n\n this.calculatedData = {\n chartSizes: this.chartRenderer.chartSizes,\n hierarchy,\n heatmapData,\n legendLabels,\n };\n }\n\n _updateAesInData() {\n if (!this.calculatedData) {\n return;\n }\n this.calculatedData.legendLabels = getLegendLabelsMap(this.data, this.settings.aes);\n }\n\n _updateChart() {\n if (!this.calculatedData) {\n return;\n }\n const {\n heatmapAnnotation,\n chartSettings,\n connectionType,\n edgeInheritance,\n rootPosition,\n showNodes,\n showEdges,\n showLeavesLabels,\n showNodesLabels,\n aes,\n labels,\n heatmapSettings,\n leavesMode\n } = this.settings;\n\n this.chartRenderer.render(\n this.data,\n chartSettings,\n this.calculatedData.hierarchy,\n connectionType,\n rootPosition,\n edgeInheritance,\n showNodes,\n showEdges,\n showLeavesLabels,\n showNodesLabels,\n aes,\n labels,\n heatmapAnnotation,\n this.calculatedData.heatmapData,\n heatmapSettings,\n this.calculatedData.legendLabels,\n leavesMode,\n this.onClick\n );\n }\n}\n"],"names":["isCategoricalAes","item","getLegendLabelsMap","data","aes","nodeColor","nodeShape","lineColor","aesGrouping","uniqBy","res","columnName","categories","getValueLabel","category","undefined","usedAes","aesMap","ChartDendro","AbstractChart","settings","eventHandlers","__publicField","ChartRenderer","DendroSettingsImpl","node","err","previousSettings","previousData","field","value","event","USER_UPDATE_EVENT","renderToString","prevSettings","mode","id","parentId","heatmapAnnotation","heatmapAxis","heatmapGroup","compareColumnGroups","columns1","columns2","column","idx","_a","_b","prevData","prevKeys","keys","c","key","heatmapSettings","height","labels","hierarchy","getHierarchy","heatmapData","getHeatmapData","legendLabels","chartSettings","connectionType","edgeInheritance","rootPosition","showNodes","showEdges","showLeavesLabels","showNodesLabels","leavesMode"],"mappings":";;;;;;;;;;AA6BA,SAASA,EACLC,GAC2C;AAC3C,SAAI,OAAOA,KAAS,WACT,KAEJ,eAAeA;AAC1B;AACA,SAASC,EAAmBC,GAAiBC,GAAkD;AAC3F,QAAM,EAAC,WAAAC,GAAW,WAAAC,GAAW,WAAAC,EAAAA,IAAaH,GACpCI,IAA+D,CAACH,GAAWC,GAAWC,CAAS,EAAE;AAAA,IACnGP;AAAAA,EAAA;AAGJ,SADsBS,EAAAA,OAAOD,GAAa,CAAAP,MAAQA,EAAK,WAAW,KAAK,EAClD,OAAO,CAACS,GAAuBT,MAAS;AACzD,UAAM,EAAC,YAAAU,EAAAA,IAAcV,GACfW,IAAaT,EAAK,oBAAoBQ,EAAW,OAAO,EAAK,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_modules/@milaboratories/miplots4/src/dendro/index.ts"],"sourcesContent":["import type { HierarchyNode } from 'd3-hierarchy';\nimport { uniqBy } from 'lodash';\nimport { renderToString } from 'react-dom/server';\nimport { undefined } from 'zod';\nimport { AbstractChart } from '../AbstractChart';\nimport type { DataFrame } from '../DataFrame';\nimport type {\n AesItem,\n AesRecord,\n CategoricalAesFromColumn,\n Category,\n ClickEventData,\n ColumnName,\n ContinuousAesFromColumn,\n DendroEventHandlers,\n DendroLegendInfo,\n DendroSettings,\n LineShape,\n PointShape\n} from '../types';\nimport ChartRenderer from './ChartRenderer';\nimport type { ChartSizes } from './components/types';\nimport { USER_UPDATE_EVENT } from './constants';\nimport { DendroSettingsImpl } from './DendroSettingsImpl';\nimport type { HeatmapData } from './getHeatmapData';\nimport { getHeatmapData } from './getHeatmapData';\nimport type { TreeNodeData } from './getHierarchyData';\nimport { getHierarchy } from './getHierarchyData';\n\nfunction isCategoricalAes<InputType extends string | number | PointShape | LineShape>(\n item: InputType | CategoricalAesFromColumn<InputType> | ContinuousAesFromColumn<InputType>\n): item is CategoricalAesFromColumn<InputType> {\n if (typeof item !== 'object') {\n return false;\n }\n return 'valuesMap' in item;\n}\nfunction getLegendLabelsMap(data: DataFrame, aes: DendroSettingsImpl['aes']): DendroLegendInfo {\n const {nodeColor, nodeShape, lineColor} = aes;\n const aesGrouping: CategoricalAesFromColumn<string | PointShape>[] = [nodeColor, nodeShape, lineColor].filter(\n isCategoricalAes\n );\n const uniqueColumns = uniqBy(aesGrouping, item => item.columnName.value);\n return uniqueColumns.reduce((res: DendroLegendInfo, item) => {\n const {columnName} = item;\n const categories = data.getColumnCategories(columnName.value, false);\n const getValueLabel = (category: Category) => String(\n (columnName.valueLabels\n ? data.getColumnValue(columnName.valueLabels, data.getColumnCategoryRowIndex(columnName.value, category))\n : undefined\n ) ?? category\n );\n\n const usedAes = new Set<keyof AesItem>();\n const aesMap: AesRecord = categories.reduce((res: AesRecord, category) => {\n if (!res[category]) {\n res[category] = {} as AesItem;\n }\n return res;\n }, {});\n if (isCategoricalAes(nodeColor) && columnName.value === nodeColor.columnName.value) {\n usedAes.add('dotFill');\n categories.forEach(category => {\n aesMap[category]['dotFill'] = nodeColor.valuesMap[category];\n });\n }\n if (isCategoricalAes(nodeShape) && columnName.value === nodeShape.columnName.value) {\n usedAes.add('dotShape');\n categories.forEach(category => {\n aesMap[category]['dotShape'] = nodeShape.valuesMap[category];\n });\n }\n if (isCategoricalAes(lineColor) && columnName.value === lineColor.columnName.value) {\n usedAes.add('lineColor');\n categories.forEach(category => {\n aesMap[category]['lineColor'] = lineColor.valuesMap[category];\n });\n }\n res[columnName.value] = {\n values: categories.sort(),\n usedAes: [...usedAes],\n aesMap,\n labels: categories.reduce((res: Record<string, string>, category) => {\n res[category] = getValueLabel(category);\n return res;\n }, {}),\n };\n return res;\n }, {});\n}\n\nexport class ChartDendro extends AbstractChart {\n settings: DendroSettingsImpl;\n onClick: (data: ClickEventData) => void = () => undefined;\n chartRenderer = new ChartRenderer();\n\n calculatedData: {\n chartSizes: ChartSizes;\n hierarchy: HierarchyNode<TreeNodeData>;\n heatmapData: HeatmapData | null;\n legendLabels: DendroLegendInfo;\n } | null = null;\n\n constructor(data: DataFrame, settings: DendroSettings, eventHandlers?: DendroEventHandlers) {\n super(data, settings);\n\n this.settings = new DendroSettingsImpl(settings);\n if (eventHandlers) {\n this.onClick = eventHandlers[0];\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 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: DendroSettings) {\n try {\n const previousSettings = this.settings;\n const previousData = this.data;\n this.settings = new DendroSettingsImpl(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 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 if (document) {\n const event = new CustomEvent(USER_UPDATE_EVENT, {detail: {[field]: value}});\n document.dispatchEvent(event);\n }\n }\n\n export(): string {\n this._updateChart();\n return renderToString(this.chartRenderer.component);\n }\n\n _needUpdateCalculatedDataBySettings(prevSettings: DendroSettingsImpl, settings: DendroSettingsImpl) {\n const {mode, id, parentId, heatmapAnnotation, heatmapAxis, heatmapGroup} = settings;\n\n function compareColumnGroups(columns1: ColumnName[], columns2: ColumnName[]) {\n return (\n columns1.length !== columns2.length ||\n columns1.some((column, idx) => column.value !== columns2[idx].value)\n );\n }\n\n return (\n prevSettings.mode !== mode ||\n prevSettings.id.value !== id.value ||\n prevSettings.parentId.value !== parentId.value ||\n prevSettings.heatmapAnnotation?.value !== heatmapAnnotation?.value ||\n prevSettings.heatmapAxis?.value !== heatmapAxis?.value ||\n compareColumnGroups(prevSettings.heatmapGroup, heatmapGroup)\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 {mode, id, parentId, aes, heatmapAnnotation, heatmapAxis, heatmapGroup, heatmapSettings, height, labels} = this.settings;\n const hierarchy = getHierarchy(\n this.data,\n id.value,\n parentId.value,\n height?.value ?? null,\n labels.valueLabels ?? labels.value ?? null,\n mode === 'useAllNodesAsLeaves'\n );\n const heatmapData = getHeatmapData(this.data, heatmapSettings.valueType, heatmapAnnotation, heatmapAxis, heatmapGroup, id, hierarchy);\n\n const legendLabels = getLegendLabelsMap(this.data, aes);\n\n this.calculatedData = {\n chartSizes: this.chartRenderer.chartSizes,\n hierarchy,\n heatmapData,\n legendLabels,\n };\n }\n\n _updateAesInData() {\n if (!this.calculatedData) {\n return;\n }\n this.calculatedData.legendLabels = getLegendLabelsMap(this.data, this.settings.aes);\n }\n\n _updateChart() {\n if (!this.calculatedData) {\n return;\n }\n const {\n heatmapAnnotation,\n chartSettings,\n connectionType,\n edgeInheritance,\n rootPosition,\n showNodes,\n showEdges,\n showLeavesLabels,\n showNodesLabels,\n aes,\n labels,\n heatmapSettings,\n leavesMode\n } = this.settings;\n\n this.chartRenderer.render(\n this.data,\n chartSettings,\n this.calculatedData.hierarchy,\n connectionType,\n rootPosition,\n edgeInheritance,\n showNodes,\n showEdges,\n showLeavesLabels,\n showNodesLabels,\n aes,\n labels,\n heatmapAnnotation,\n this.calculatedData.heatmapData,\n heatmapSettings,\n this.calculatedData.legendLabels,\n leavesMode,\n this.onClick\n );\n }\n}\n"],"names":["isCategoricalAes","item","getLegendLabelsMap","data","aes","nodeColor","nodeShape","lineColor","aesGrouping","uniqBy","res","columnName","categories","getValueLabel","category","undefined","usedAes","aesMap","ChartDendro","AbstractChart","settings","eventHandlers","__publicField","ChartRenderer","DendroSettingsImpl","node","err","previousSettings","previousData","field","value","event","USER_UPDATE_EVENT","renderToString","prevSettings","mode","id","parentId","heatmapAnnotation","heatmapAxis","heatmapGroup","compareColumnGroups","columns1","columns2","column","idx","_a","_b","prevData","prevKeys","keys","c","key","heatmapSettings","height","labels","hierarchy","getHierarchy","heatmapData","getHeatmapData","legendLabels","chartSettings","connectionType","edgeInheritance","rootPosition","showNodes","showEdges","showLeavesLabels","showNodesLabels","leavesMode"],"mappings":";;;;;;;;;;AA6BA,SAASA,EACLC,GAC2C;AAC3C,SAAI,OAAOA,KAAS,WACT,KAEJ,eAAeA;AAC1B;AACA,SAASC,EAAmBC,GAAiBC,GAAkD;AAC3F,QAAM,EAAC,WAAAC,GAAW,WAAAC,GAAW,WAAA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,MACA,KAAK,eAAe;AAAA,MACpBC;AAAAA,MACAE;AAAAA,MACAD;AAAAA,MACAE;AAAAA,MACAC;AAAAA,MACAC;AAAAA,MACAC;AAAAA,MACAhE;AAAAA,MACAmD;AAAAA,MACAjB;AAAAA,MACA,KAAK,eAAe;AAAA,MACpBe;AAAAA,MACA,KAAK,eAAe;AAAA,MACpBgB;AAAAA,MACA,KAAK;AAAA,IAAA;AAAA,EAEb;AACJ;","x_google_ignoreList":[0]}
|
|
@@ -12,7 +12,7 @@ import { DEFAULT_AES as H, CAPTION_LINE_HEIGHT as N, LEGEND_OFFSET as J, TICK_OF
|
|
|
12
12
|
import { getChartStatsPadding as O } from "./utils/getChartStatsPadding.js";
|
|
13
13
|
import { splitTextByWidth as I } from "./utils/splitTextByWidth.js";
|
|
14
14
|
import R from "../node_modules/d3-scale/src/ordinal.js";
|
|
15
|
-
import
|
|
15
|
+
import X from "../node_modules/d3-scale/src/linear.js";
|
|
16
16
|
import z from "../node_modules/d3-scale/src/band.js";
|
|
17
17
|
import et from "../node_modules/d3-scale/src/log.js";
|
|
18
18
|
var st = Object.defineProperty, it = (u, e, t) => e in u ? st(u, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : u[e] = t, C = (u, e, t) => it(u, typeof e != "symbol" ? e + "" : e, t);
|
|
@@ -36,7 +36,7 @@ function ht(u, e, t) {
|
|
|
36
36
|
r * t + i < u.length && s[i].push(u[r * t + i]);
|
|
37
37
|
return s;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function $(u, e, t) {
|
|
40
40
|
const s = [];
|
|
41
41
|
for (let i = 0; i < e; i++)
|
|
42
42
|
s.push(u.slice(i * t, i * t + t));
|
|
@@ -70,7 +70,7 @@ class wt {
|
|
|
70
70
|
// Scale from secondary grouping categories to x shift inside corresponding primary group
|
|
71
71
|
xSecondary: { null: z().range([0, L]).domain(["1"]) },
|
|
72
72
|
// Scale from y value to y coordinate, by facet
|
|
73
|
-
y: { null:
|
|
73
|
+
y: { null: X().domain([0, 10]).range([v, 0]).nice() },
|
|
74
74
|
// Scale for link primary grouping category and aesthetics
|
|
75
75
|
xPrimaryAes: R().unknown(H),
|
|
76
76
|
// Scale for link secondary grouping category and aesthetics
|
|
@@ -106,7 +106,7 @@ class wt {
|
|
|
106
106
|
i,
|
|
107
107
|
r,
|
|
108
108
|
this.captionsSizes,
|
|
109
|
-
|
|
109
|
+
$(e, this.rowsCount, this.columnsCount)[a],
|
|
110
110
|
this.facetTitles,
|
|
111
111
|
o,
|
|
112
112
|
t,
|
|
@@ -133,7 +133,7 @@ class wt {
|
|
|
133
133
|
updateViewport(e, t, s, i, r, p, h, l, c, f) {
|
|
134
134
|
const g = c.innerOffset, d = e === "vertical", T = O(l, t, c.innerOffset), y = r === null || r.sharedX, a = r === null || r.sharedY, { chartHeight: n, chartWidth: o } = this.chartSizes;
|
|
135
135
|
i.forEach((m) => {
|
|
136
|
-
const x = p.scale === "log" ? et() :
|
|
136
|
+
const x = p.scale === "log" ? et() : X(), S = Math.min(...a ? h.map(({ meta: b }) => b.minY) : h.map(({ geoms: b }) => Math.min(...b[m].map(({ boundsY: M }) => M.min)))), w = Math.max(...a ? h.map(({ meta: b }) => b.maxY) : h.map(({ geoms: b }) => Math.max(...b[m].map(({ boundsY: M }) => M.max)))), E = x.copy().domain([S, w]).range(
|
|
137
137
|
d ? [n - g, T] : [g, o - T]
|
|
138
138
|
);
|
|
139
139
|
x.domain([E.invert(d ? n : 0), E.invert(d ? 0 : o)]).range(d ? [n, 0] : [0, o]), this.scales.y[m] = x;
|
|
@@ -198,7 +198,7 @@ class wt {
|
|
|
198
198
|
return a.length ? Math.max(...a.map(h)) : 0;
|
|
199
199
|
}
|
|
200
200
|
let c = [], f = 0;
|
|
201
|
-
const g =
|
|
201
|
+
const g = $(t, this.rowsCount, this.columnsCount), d = ht(t, this.rowsCount, this.columnsCount);
|
|
202
202
|
if (!p)
|
|
203
203
|
c = d.map(
|
|
204
204
|
(a) => Math.max(
|