@milaboratories/graph-maker 1.2.8 → 1.2.10
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/components/Chart.js.map +1 -1
- package/dist/components/Chart.vue.d.ts.map +1 -1
- package/dist/components/Chart.vue2.js +23 -3
- package/dist/components/Chart.vue2.js.map +1 -1
- package/dist/components/ChartTruncationWarningAlert.js.map +1 -1
- package/dist/components/ChartTruncationWarningAlert.style.js.map +1 -1
- package/dist/components/ChartTruncationWarningAlert.vue.d.ts.map +1 -1
- package/dist/components/ChartTruncationWarningAlert.vue2.js +12 -12
- package/dist/components/ChartTruncationWarningAlert.vue2.js.map +1 -1
- package/dist/constantsCommon.d.ts +6 -0
- package/dist/constantsCommon.d.ts.map +1 -1
- package/dist/constantsCommon.js +9 -3
- package/dist/constantsCommon.js.map +1 -1
- package/dist/forms/DataMappingForm/DendroForm.js.map +1 -1
- package/dist/forms/DataMappingForm/DendroForm.vue.d.ts.map +1 -1
- package/dist/forms/DataMappingForm/DendroForm.vue2.js +22 -3
- package/dist/forms/DataMappingForm/DendroForm.vue2.js.map +1 -1
- package/dist/forms/DataMappingForm/useBaskets.d.ts.map +1 -1
- package/dist/forms/DataMappingForm/useBaskets.js +22 -3
- package/dist/forms/DataMappingForm/useBaskets.js.map +1 -1
- package/dist/forms/LayersForm/Layer/Bubble.js.map +1 -1
- package/dist/forms/LayersForm/Layer/Bubble.vue.d.ts.map +1 -1
- package/dist/forms/LayersForm/Layer/Bubble.vue2.js +53 -45
- package/dist/forms/LayersForm/Layer/Bubble.vue2.js.map +1 -1
- package/dist/forms/LayersForm/Layer/heatmap/Heatmap.js.map +1 -1
- package/dist/forms/LayersForm/Layer/heatmap/Heatmap.vue.d.ts.map +1 -1
- package/dist/forms/LayersForm/Layer/heatmap/Heatmap.vue2.js +49 -41
- package/dist/forms/LayersForm/Layer/heatmap/Heatmap.vue2.js.map +1 -1
- package/dist/forms/LayersForm/Layer/heatmap/HeatmapClustered.js.map +1 -1
- package/dist/forms/LayersForm/Layer/heatmap/HeatmapClustered.vue.d.ts.map +1 -1
- package/dist/forms/LayersForm/Layer/heatmap/HeatmapClustered.vue2.js +63 -55
- package/dist/forms/LayersForm/Layer/heatmap/HeatmapClustered.vue2.js.map +1 -1
- package/dist/store.js +7 -1
- package/dist/store.js.map +1 -1
- package/dist/utils/createChartSettingsForRender/composeBubbleSettings.d.ts +2 -0
- package/dist/utils/createChartSettingsForRender/composeBubbleSettings.d.ts.map +1 -1
- package/dist/utils/createChartSettingsForRender/composeBubbleSettings.js +1 -1
- package/dist/utils/createChartSettingsForRender/composeBubbleSettings.js.map +1 -1
- package/dist/utils/createChartSettingsForRender/composeHeatmapSettings.d.ts +2 -0
- package/dist/utils/createChartSettingsForRender/composeHeatmapSettings.d.ts.map +1 -1
- package/dist/utils/createChartSettingsForRender/composeHeatmapSettings.js +1 -1
- package/dist/utils/createChartSettingsForRender/composeHeatmapSettings.js.map +1 -1
- package/dist/utils/loadUniqueValuesToSave.d.ts.map +1 -1
- package/dist/utils/loadUniqueValuesToSave.js +16 -3
- package/dist/utils/loadUniqueValuesToSave.js.map +1 -1
- package/package.json +3 -3
|
@@ -19,14 +19,14 @@ var S = { class: "checkbox-item" }, C = {
|
|
|
19
19
|
display: "flex",
|
|
20
20
|
alignItems: "end"
|
|
21
21
|
}
|
|
22
|
-
}, M = "
|
|
22
|
+
}, M = { class: "checkbox-item" }, N = { class: "checkbox-item" }, P = "heatmapClustered", F = /* @__PURE__ */ m({
|
|
23
23
|
__name: "HeatmapClustered",
|
|
24
24
|
setup(m) {
|
|
25
|
-
let
|
|
26
|
-
function
|
|
27
|
-
|
|
25
|
+
let F = o(), I = c(() => F.value.reactive.layersSettings[P]), L = c(() => F.value.reactive.optionsState), R = c(() => F.value.inputGuide.value), z = c(() => L.value.components.value.selectorStates[0]?.selectedSource), B = c(() => z.value ? F.value.reactive.dataBindAes[z.value]?.palette : void 0), V = g(!1), H = g(B.value ?? F.value.defaultPalette.continuous);
|
|
26
|
+
function U(e) {
|
|
27
|
+
H.value = e, V.value = !1, z.value && (F.value.reactive.dataBindAes[z.value] = t(e));
|
|
28
28
|
}
|
|
29
|
-
let
|
|
29
|
+
let W = [
|
|
30
30
|
{
|
|
31
31
|
label: "None",
|
|
32
32
|
value: null
|
|
@@ -39,111 +39,119 @@ var S = { class: "checkbox-item" }, C = {
|
|
|
39
39
|
label: "Rows",
|
|
40
40
|
value: "row"
|
|
41
41
|
}
|
|
42
|
-
],
|
|
42
|
+
], G = [{
|
|
43
43
|
label: "z-score",
|
|
44
44
|
value: "standardScaling"
|
|
45
45
|
}, {
|
|
46
46
|
label: "Min-max",
|
|
47
47
|
value: "meanNormalization"
|
|
48
|
-
}],
|
|
48
|
+
}], K = [{
|
|
49
49
|
label: "empty",
|
|
50
50
|
value: null
|
|
51
51
|
}, {
|
|
52
52
|
label: "Special value",
|
|
53
53
|
value: "custom"
|
|
54
|
-
}],
|
|
54
|
+
}], q = n, J = g(I.value.NAValueAs === null ? I.value.NAValueAs : "custom"), Y = g(I.value.NAValueAs ?? 0);
|
|
55
55
|
return (t, n) => (h(), d(s, null, [
|
|
56
56
|
p(a, {
|
|
57
57
|
label: "Color Palette ",
|
|
58
|
-
title: _(e)[
|
|
59
|
-
palette:
|
|
58
|
+
title: _(e)[H.value].title,
|
|
59
|
+
palette: H.value,
|
|
60
60
|
onButtonClick: n[0] ||= (e) => {
|
|
61
|
-
|
|
61
|
+
V.value = !0;
|
|
62
62
|
}
|
|
63
63
|
}, null, 8, ["title", "palette"]),
|
|
64
|
-
|
|
64
|
+
V.value ? (h(), l(r, {
|
|
65
65
|
key: 0,
|
|
66
66
|
title: "Color Palette",
|
|
67
67
|
"back-title": "Color mapping",
|
|
68
|
-
"onForm:close": n[1] ||= (e) =>
|
|
68
|
+
"onForm:close": n[1] ||= (e) => V.value = !1
|
|
69
69
|
}, {
|
|
70
70
|
default: v(() => [p(i, {
|
|
71
|
-
selected:
|
|
72
|
-
categorical:
|
|
73
|
-
onSelect:
|
|
71
|
+
selected: H.value,
|
|
72
|
+
categorical: z.value ? R.value.getSourceInfo(z.value).type === "String" : !1,
|
|
73
|
+
onSelect: U
|
|
74
74
|
}, null, 8, ["selected", "categorical"])]),
|
|
75
75
|
_: 1
|
|
76
76
|
})) : u("", !0),
|
|
77
77
|
f("div", S, [p(_(b), {
|
|
78
|
-
modelValue:
|
|
79
|
-
"onUpdate:modelValue": n[2] ||= (e) =>
|
|
80
|
-
}, null, 8, ["modelValue"]), n[
|
|
81
|
-
|
|
82
|
-
modelValue:
|
|
83
|
-
"onUpdate:modelValue": n[3] ||= (e) =>
|
|
84
|
-
}, null, 8, ["modelValue"]), n[
|
|
78
|
+
modelValue: I.value.disableClusteringX,
|
|
79
|
+
"onUpdate:modelValue": n[2] ||= (e) => I.value.disableClusteringX = e
|
|
80
|
+
}, null, 8, ["modelValue"]), n[17] ||= f("span", null, "Disable clustering for X axis", -1)]),
|
|
81
|
+
I.value.disableClusteringX ? u("", !0) : (h(), d("div", C, [p(_(b), {
|
|
82
|
+
modelValue: I.value.dendrogramX,
|
|
83
|
+
"onUpdate:modelValue": n[3] ||= (e) => I.value.dendrogramX = e
|
|
84
|
+
}, null, 8, ["modelValue"]), n[18] ||= f("span", null, "Show dendrogram for X axis", -1)])),
|
|
85
85
|
f("div", w, [p(_(b), {
|
|
86
|
-
modelValue:
|
|
87
|
-
"onUpdate:modelValue": n[4] ||= (e) =>
|
|
88
|
-
}, null, 8, ["modelValue"]), n[
|
|
89
|
-
|
|
90
|
-
modelValue:
|
|
91
|
-
"onUpdate:modelValue": n[5] ||= (e) =>
|
|
92
|
-
}, null, 8, ["modelValue"]), n[
|
|
86
|
+
modelValue: I.value.disableClusteringY,
|
|
87
|
+
"onUpdate:modelValue": n[4] ||= (e) => I.value.disableClusteringY = e
|
|
88
|
+
}, null, 8, ["modelValue"]), n[19] ||= f("span", null, "Disable clustering for Y axis", -1)]),
|
|
89
|
+
I.value.disableClusteringY ? u("", !0) : (h(), d("div", T, [p(_(b), {
|
|
90
|
+
modelValue: I.value.dendrogramY,
|
|
91
|
+
"onUpdate:modelValue": n[5] ||= (e) => I.value.dendrogramY = e
|
|
92
|
+
}, null, 8, ["modelValue"]), n[20] ||= f("span", null, "Show dendrogram for Y axis", -1)])),
|
|
93
93
|
f("div", E, [p(_(y), {
|
|
94
|
-
modelValue:
|
|
95
|
-
"onUpdate:modelValue": n[6] ||= (e) =>
|
|
94
|
+
modelValue: I.value.normalizationDirection,
|
|
95
|
+
"onUpdate:modelValue": n[6] ||= (e) => I.value.normalizationDirection = e,
|
|
96
96
|
label: "Normalize by",
|
|
97
|
-
options:
|
|
97
|
+
options: W,
|
|
98
98
|
compact: !0
|
|
99
99
|
}, null, 8, ["modelValue"])]),
|
|
100
100
|
f("div", D, [p(_(y), {
|
|
101
|
-
modelValue:
|
|
102
|
-
"onUpdate:modelValue": n[7] ||= (e) =>
|
|
101
|
+
modelValue: I.value.normalizationMethod,
|
|
102
|
+
"onUpdate:modelValue": n[7] ||= (e) => I.value.normalizationMethod = e,
|
|
103
103
|
label: "Normalization method",
|
|
104
|
-
options:
|
|
104
|
+
options: G,
|
|
105
105
|
compact: !0
|
|
106
106
|
}, null, 8, ["modelValue"])]),
|
|
107
107
|
f("div", O, [p(_(b), {
|
|
108
|
-
modelValue:
|
|
109
|
-
"onUpdate:modelValue": n[8] ||= (e) =>
|
|
110
|
-
}, null, 8, ["modelValue"]), n[
|
|
108
|
+
modelValue: I.value.aggregateByX,
|
|
109
|
+
"onUpdate:modelValue": n[8] ||= (e) => I.value.aggregateByX = e
|
|
110
|
+
}, null, 8, ["modelValue"]), n[21] ||= f("span", null, "Aggregate X groups", -1)]),
|
|
111
111
|
f("div", k, [p(_(b), {
|
|
112
|
-
modelValue:
|
|
113
|
-
"onUpdate:modelValue": n[9] ||= (e) =>
|
|
114
|
-
}, null, 8, ["modelValue"]), n[
|
|
112
|
+
modelValue: I.value.aggregateByY,
|
|
113
|
+
"onUpdate:modelValue": n[9] ||= (e) => I.value.aggregateByY = e
|
|
114
|
+
}, null, 8, ["modelValue"]), n[22] ||= f("span", null, "Aggregate Y groups", -1)]),
|
|
115
115
|
f("div", A, [p(_(y), {
|
|
116
|
-
modelValue:
|
|
117
|
-
"onUpdate:modelValue": n[10] ||= (e) =>
|
|
116
|
+
modelValue: I.value.aggregationMethod,
|
|
117
|
+
"onUpdate:modelValue": n[10] ||= (e) => I.value.aggregationMethod = e,
|
|
118
118
|
label: "Aggregation method",
|
|
119
|
-
options: _(
|
|
119
|
+
options: _(q),
|
|
120
120
|
compact: !0
|
|
121
121
|
}, null, 8, ["modelValue", "options"])]),
|
|
122
122
|
f("div", j, [p(_(y), {
|
|
123
|
-
modelValue:
|
|
124
|
-
"onUpdate:modelValue": [n[11] ||= (e) =>
|
|
125
|
-
e === "custom" ?
|
|
123
|
+
modelValue: J.value,
|
|
124
|
+
"onUpdate:modelValue": [n[11] ||= (e) => J.value = e, n[12] ||= (e) => {
|
|
125
|
+
e === "custom" ? I.value.NAValueAs = Y.value : I.value.NAValueAs = e;
|
|
126
126
|
}],
|
|
127
127
|
label: "Treat NA value as:",
|
|
128
|
-
options:
|
|
128
|
+
options: K,
|
|
129
129
|
compact: !0
|
|
130
130
|
}, null, 8, ["modelValue"]), p(_(x), {
|
|
131
|
-
modelValue:
|
|
132
|
-
"onUpdate:modelValue": [n[13] ||= (e) =>
|
|
133
|
-
e !== void 0 && (
|
|
131
|
+
modelValue: Y.value,
|
|
132
|
+
"onUpdate:modelValue": [n[13] ||= (e) => Y.value = e, n[14] ||= (e) => {
|
|
133
|
+
e !== void 0 && (I.value.NAValueAs = e);
|
|
134
134
|
}],
|
|
135
135
|
style: {
|
|
136
136
|
height: "33px",
|
|
137
137
|
marginLeft: "16px",
|
|
138
138
|
width: "75px"
|
|
139
139
|
},
|
|
140
|
-
disabled:
|
|
140
|
+
disabled: J.value !== "custom",
|
|
141
141
|
label: "NA value",
|
|
142
142
|
useIncrementButtons: !1
|
|
143
|
-
}, null, 8, ["modelValue", "disabled"])])
|
|
143
|
+
}, null, 8, ["modelValue", "disabled"])]),
|
|
144
|
+
f("div", M, [p(_(b), {
|
|
145
|
+
modelValue: I.value.showEmptyRows,
|
|
146
|
+
"onUpdate:modelValue": n[15] ||= (e) => I.value.showEmptyRows = e
|
|
147
|
+
}, null, 8, ["modelValue"]), n[23] ||= f("span", null, "Show empty rows", -1)]),
|
|
148
|
+
f("div", N, [p(_(b), {
|
|
149
|
+
modelValue: I.value.showEmptyColumns,
|
|
150
|
+
"onUpdate:modelValue": n[16] ||= (e) => I.value.showEmptyColumns = e
|
|
151
|
+
}, null, 8, ["modelValue"]), n[24] ||= f("span", null, "Show empty columns", -1)])
|
|
144
152
|
], 64));
|
|
145
153
|
}
|
|
146
154
|
});
|
|
147
|
-
export {
|
|
155
|
+
export { F as default };
|
|
148
156
|
|
|
149
157
|
//# sourceMappingURL=HeatmapClustered.vue2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeatmapClustered.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../../../../src/forms/LayersForm/Layer/heatmap/HeatmapClustered.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { useStore } from '../../../../store';\nimport type { HeatmapLayer } from '../../../../types';\nimport type { SimpleOption } from '@platforma-sdk/ui-vue';\nimport { PlBtnGroup, PlCheckbox, PlNumberField } from '@platforma-sdk/ui-vue';\nimport { computed, ref } from 'vue';\nimport { PALETTE_MAP } from '../../../../constantsAesthetic';\nimport type { HeatmapUIState, InputGuide } from '@milaboratories/pf-plots';\nimport type { ContinuousPalette } from '../../../../components/AesSettings/types';\nimport { createContinuousMappingFromPalette } from '../../../../dataBindAes';\nimport MultiselectButton from '../../../../components/MultiselectButton.vue';\nimport PalettesForm from '../../../../components/AesSettings/PalettesForm.vue';\nimport FormWrapper from '../../../../components/AesSettings/FormWrapper.vue';\nimport { AGGREGATION_METHOD_OPTIONS } from '../../../../constantsCommon';\n\nconst store = useStore();\nconst layer: HeatmapLayer = 'heatmapClustered';\nconst settings = computed(() => store.value.reactive.layersSettings[layer]);\n\nconst optionsState = computed(() => store.value.reactive.optionsState as HeatmapUIState);\nconst inputGuide = computed(() => store.value.inputGuide.value as InputGuide<HeatmapUIState>);\n\nconst dataSource = computed(() => optionsState.value.components.value.selectorStates[0]?.selectedSource);\nconst savedDataValuePalette = computed(() => dataSource.value ? store.value.reactive.dataBindAes[dataSource.value]?.palette : undefined);\n\nconst palettesOpen = ref(false);\nconst palette = ref<ContinuousPalette>(savedDataValuePalette.value as ContinuousPalette ?? store.value.defaultPalette.continuous);\n\nfunction onPaletteSelect(value: ContinuousPalette) {\n palette.value = value;\n palettesOpen.value = false;\n if (dataSource.value) {\n store.value.reactive.dataBindAes[dataSource.value] = createContinuousMappingFromPalette(value);\n }\n}\nconst NORMALIZATION_DIRECTION: SimpleOption[] = [\n { label: 'None', value: null },\n { label: 'Columns', value: 'column' },\n { label: 'Rows', value: 'row' },\n];\nconst NORMALIZATION_METHOD: SimpleOption[] = [\n { label: 'z-score', value: 'standardScaling' },\n { label: 'Min-max', value: 'meanNormalization' },\n];\nconst NA_VALUE_OPTIONS: SimpleOption[] = [\n { label: 'empty', value: null },\n { label: 'Special value', value: 'custom' },\n];\nconst AGGREGATION_METHOD = AGGREGATION_METHOD_OPTIONS;\n\nconst NAValueOption = ref(settings.value.NAValueAs !== null ? 'custom' : settings.value.NAValueAs);\nconst customNA = ref(settings.value.NAValueAs ?? 0);\n</script>\n\n<template>\n <MultiselectButton\n label=\"Color Palette \"\n :title=\"PALETTE_MAP[palette].title\"\n :palette=\"palette\"\n @button-click=\"palettesOpen = true;\"\n />\n <FormWrapper\n v-if=\"palettesOpen\"\n title=\"Color Palette\"\n back-title=\"Color mapping\"\n @form:close=\"palettesOpen = false\"\n >\n <PalettesForm :selected=\"palette\" :categorical=\"dataSource ? inputGuide.getSourceInfo(dataSource).type === 'String' : false\" @select=\"onPaletteSelect\" />\n </FormWrapper>\n <div class=\"checkbox-item\">\n <PlCheckbox v-model=\"settings.disableClusteringX\"/>\n <span>Disable clustering for X axis</span>\n </div>\n <div v-if=\"!settings.disableClusteringX\" class=\"checkbox-item\">\n <PlCheckbox v-model=\"settings.dendrogramX\" />\n <span>Show dendrogram for X axis</span>\n </div>\n <div class=\"checkbox-item\">\n <PlCheckbox v-model=\"settings.disableClusteringY\"/>\n <span>Disable clustering for Y axis</span>\n </div>\n <div v-if=\"!settings.disableClusteringY\" class=\"checkbox-item\">\n <PlCheckbox v-model=\"settings.dendrogramY\"/>\n <span>Show dendrogram for Y axis</span>\n </div>\n <div class=\"button-group-item\">\n <PlBtnGroup\n v-model=\"settings.normalizationDirection\"\n label=\"Normalize by\"\n :options=\"NORMALIZATION_DIRECTION\"\n :compact=\"true\"\n />\n </div>\n <div class=\"button-group-item\">\n <PlBtnGroup\n v-model=\"settings.normalizationMethod\"\n label=\"Normalization method\"\n :options=\"NORMALIZATION_METHOD\"\n :compact=\"true\"\n />\n </div>\n <div class=\"checkbox-item\">\n <PlCheckbox v-model=\"settings.aggregateByX\"/>\n <span>Aggregate X groups</span>\n </div>\n <div class=\"checkbox-item\">\n <PlCheckbox v-model=\"settings.aggregateByY\"/>\n <span>Aggregate Y groups</span>\n </div>\n <div class=\"button-group-item\">\n <PlBtnGroup\n v-model=\"settings.aggregationMethod\"\n label=\"Aggregation method\"\n :options=\"AGGREGATION_METHOD\"\n :compact=\"true\"\n />\n </div>\n <div class=\"button-group-item\" :style=\"{display: 'flex', alignItems: 'end'}\">\n <PlBtnGroup\n v-model=\"NAValueOption\"\n label=\"Treat NA value as:\"\n :options=\"NA_VALUE_OPTIONS\"\n :compact=\"true\"\n @update:modelValue=\"(value:unknown) => {\n if (value === 'custom') {\n settings.NAValueAs = customNA;\n } else {\n settings.NAValueAs = value as number|null;\n }\n }\"\n />\n <PlNumberField\n v-model=\"customNA\"\n :style=\"{height: '33px', marginLeft: '16px', width: '75px'}\"\n :disabled=\"NAValueOption !== 'custom'\"\n label=\"NA value\"\n :useIncrementButtons=\"false\"\n @update:modelValue=\"(value:unknown) => {\n if (value !== undefined) {\n settings.NAValueAs = value as number;\n }\n }\"\n />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"HeatmapClustered.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../../../../src/forms/LayersForm/Layer/heatmap/HeatmapClustered.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { useStore } from '../../../../store';\nimport type { HeatmapLayer } from '../../../../types';\nimport type { SimpleOption } from '@platforma-sdk/ui-vue';\nimport { PlBtnGroup, PlCheckbox, PlNumberField } from '@platforma-sdk/ui-vue';\nimport { computed, ref } from 'vue';\nimport { PALETTE_MAP } from '../../../../constantsAesthetic';\nimport type { HeatmapUIState, InputGuide } from '@milaboratories/pf-plots';\nimport type { ContinuousPalette } from '../../../../components/AesSettings/types';\nimport { createContinuousMappingFromPalette } from '../../../../dataBindAes';\nimport MultiselectButton from '../../../../components/MultiselectButton.vue';\nimport PalettesForm from '../../../../components/AesSettings/PalettesForm.vue';\nimport FormWrapper from '../../../../components/AesSettings/FormWrapper.vue';\nimport { AGGREGATION_METHOD_OPTIONS } from '../../../../constantsCommon';\n\nconst store = useStore();\nconst layer: HeatmapLayer = 'heatmapClustered';\nconst settings = computed(() => store.value.reactive.layersSettings[layer]);\n\nconst optionsState = computed(() => store.value.reactive.optionsState as HeatmapUIState);\nconst inputGuide = computed(() => store.value.inputGuide.value as InputGuide<HeatmapUIState>);\n\nconst dataSource = computed(() => optionsState.value.components.value.selectorStates[0]?.selectedSource);\nconst savedDataValuePalette = computed(() => dataSource.value ? store.value.reactive.dataBindAes[dataSource.value]?.palette : undefined);\n\nconst palettesOpen = ref(false);\nconst palette = ref<ContinuousPalette>(savedDataValuePalette.value as ContinuousPalette ?? store.value.defaultPalette.continuous);\n\nfunction onPaletteSelect(value: ContinuousPalette) {\n palette.value = value;\n palettesOpen.value = false;\n if (dataSource.value) {\n store.value.reactive.dataBindAes[dataSource.value] = createContinuousMappingFromPalette(value);\n }\n}\nconst NORMALIZATION_DIRECTION: SimpleOption[] = [\n { label: 'None', value: null },\n { label: 'Columns', value: 'column' },\n { label: 'Rows', value: 'row' },\n];\nconst NORMALIZATION_METHOD: SimpleOption[] = [\n { label: 'z-score', value: 'standardScaling' },\n { label: 'Min-max', value: 'meanNormalization' },\n];\nconst NA_VALUE_OPTIONS: SimpleOption[] = [\n { label: 'empty', value: null },\n { label: 'Special value', value: 'custom' },\n];\nconst AGGREGATION_METHOD = AGGREGATION_METHOD_OPTIONS;\n\nconst NAValueOption = ref(settings.value.NAValueAs !== null ? 'custom' : settings.value.NAValueAs);\nconst customNA = ref(settings.value.NAValueAs ?? 0);\n</script>\n\n<template>\n <MultiselectButton\n label=\"Color Palette \"\n :title=\"PALETTE_MAP[palette].title\"\n :palette=\"palette\"\n @button-click=\"palettesOpen = true;\"\n />\n <FormWrapper\n v-if=\"palettesOpen\"\n title=\"Color Palette\"\n back-title=\"Color mapping\"\n @form:close=\"palettesOpen = false\"\n >\n <PalettesForm :selected=\"palette\" :categorical=\"dataSource ? inputGuide.getSourceInfo(dataSource).type === 'String' : false\" @select=\"onPaletteSelect\" />\n </FormWrapper>\n <div class=\"checkbox-item\">\n <PlCheckbox v-model=\"settings.disableClusteringX\"/>\n <span>Disable clustering for X axis</span>\n </div>\n <div v-if=\"!settings.disableClusteringX\" class=\"checkbox-item\">\n <PlCheckbox v-model=\"settings.dendrogramX\" />\n <span>Show dendrogram for X axis</span>\n </div>\n <div class=\"checkbox-item\">\n <PlCheckbox v-model=\"settings.disableClusteringY\"/>\n <span>Disable clustering for Y axis</span>\n </div>\n <div v-if=\"!settings.disableClusteringY\" class=\"checkbox-item\">\n <PlCheckbox v-model=\"settings.dendrogramY\"/>\n <span>Show dendrogram for Y axis</span>\n </div>\n <div class=\"button-group-item\">\n <PlBtnGroup\n v-model=\"settings.normalizationDirection\"\n label=\"Normalize by\"\n :options=\"NORMALIZATION_DIRECTION\"\n :compact=\"true\"\n />\n </div>\n <div class=\"button-group-item\">\n <PlBtnGroup\n v-model=\"settings.normalizationMethod\"\n label=\"Normalization method\"\n :options=\"NORMALIZATION_METHOD\"\n :compact=\"true\"\n />\n </div>\n <div class=\"checkbox-item\">\n <PlCheckbox v-model=\"settings.aggregateByX\"/>\n <span>Aggregate X groups</span>\n </div>\n <div class=\"checkbox-item\">\n <PlCheckbox v-model=\"settings.aggregateByY\"/>\n <span>Aggregate Y groups</span>\n </div>\n <div class=\"button-group-item\">\n <PlBtnGroup\n v-model=\"settings.aggregationMethod\"\n label=\"Aggregation method\"\n :options=\"AGGREGATION_METHOD\"\n :compact=\"true\"\n />\n </div>\n <div class=\"button-group-item\" :style=\"{display: 'flex', alignItems: 'end'}\">\n <PlBtnGroup\n v-model=\"NAValueOption\"\n label=\"Treat NA value as:\"\n :options=\"NA_VALUE_OPTIONS\"\n :compact=\"true\"\n @update:modelValue=\"(value:unknown) => {\n if (value === 'custom') {\n settings.NAValueAs = customNA;\n } else {\n settings.NAValueAs = value as number|null;\n }\n }\"\n />\n <PlNumberField\n v-model=\"customNA\"\n :style=\"{height: '33px', marginLeft: '16px', width: '75px'}\"\n :disabled=\"NAValueOption !== 'custom'\"\n label=\"NA value\"\n :useIncrementButtons=\"false\"\n @update:modelValue=\"(value:unknown) => {\n if (value !== undefined) {\n settings.NAValueAs = value as number;\n }\n }\"\n />\n </div>\n <div class=\"checkbox-item\">\n <PlCheckbox v-model=\"settings.showEmptyRows\"/>\n <span>Show empty rows</span>\n </div>\n <div class=\"checkbox-item\">\n <PlCheckbox v-model=\"settings.showEmptyColumns\"/>\n <span>Show empty columns</span>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;mEAgBM,IAAsB;;;EAD5B,IAAM,IAAQ,GAAU,EAElB,IAAW,QAAe,EAAM,MAAM,SAAS,eAAe,GAAO,EAErE,IAAe,QAAe,E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6C,EAAA,EAAA,EAAA;gBAAxB,EAAA,MAAS;6CAAT,MAAS,eAAY;0CAC1C,EAA+B,QAAA,MAAzB,sBAAkB,GAAA,CAAA,CAAA;GAE1B,EAOM,OAPN,GAOM,CANJ,EAKE,EAAA,EAAA,EAAA;gBAJS,EAAA,MAAS;8CAAT,MAAS,oBAAiB;IACnC,OAAM;IACL,SAAS,EAAA,EAAkB;IAC3B,SAAS;;GAGd,EA0BM,OA1BN,GA0BM,CAzBJ,EAYE,EAAA,EAAA,EAAA;gBAXS,EAAA;+CAAa,QAAA,GAAA,AAAA,EAAA,SAID,MAAa;KAAmB,MAAK,WAA2B,EAAA,MAAS,YAAY,EAAA,QAAqC,EAAA,MAAS,YAAY;;IAHpK,OAAM;IACL,SAAS;IACT,SAAS;gCASZ,EAWE,EAAA,EAAA,EAAA;gBAVS,EAAA;+CAAQ,QAAA,GAAA,AAAA,EAAA,SAKI,MAAa;KAAmB,MAAU,KAAA,MAAuB,EAAA,MAAS,YAAY;;IAJ1G,OAAO;KAAA,QAAA;KAAA,YAAA;KAAA,OAAA;KAAmD;IAC1D,UAAU,EAAA,UAAa;IACxB,OAAM;IACL,qBAAqB;;GAQ1B,EAGM,OAHN,GAGM,CAFJ,EAA8C,EAAA,EAAA,EAAA;gBAAzB,EAAA,MAAS;8CAAT,MAAS,gBAAa;0CAC3C,EAA4B,QAAA,MAAtB,mBAAe,GAAA,CAAA,CAAA;GAEvB,EAGM,OAHN,GAGM,CAFJ,EAAiD,EAAA,EAAA,EAAA;gBAA5B,EAAA,MAAS;8CAAT,MAAS,mBAAgB;0CAC9C,EAA+B,QAAA,MAAzB,sBAAkB,GAAA,CAAA,CAAA"}
|
package/dist/store.js
CHANGED
|
@@ -110,7 +110,13 @@ function N(e, t, r, i, a, o, s, l, m) {
|
|
|
110
110
|
R.value++;
|
|
111
111
|
let a = R.value;
|
|
112
112
|
I.value.loading.inputGuide = !0;
|
|
113
|
-
let c = n && r ? Object.values(await f(n, r, null, !1)).flatMap((e) => e.map((e) => e.selectedSource)) : [], l = n ? await b.calculateOptions(
|
|
113
|
+
let c = n && r ? Object.values(await f(n, r, null, !1)).flatMap((e) => e.map((e) => e.selectedSource)) : [], l = n ? await b.calculateOptions({
|
|
114
|
+
store: E(n),
|
|
115
|
+
state: e,
|
|
116
|
+
fixedIds: c,
|
|
117
|
+
dataColumnPredicate: o,
|
|
118
|
+
metaColumnPredicate: s
|
|
119
|
+
}) : b.getEmptyInputGuide(e);
|
|
114
120
|
a === R.value && (S.value = l, I.value.loading.defaults = !1, I.value.loading.inputGuide = !1, I.value.loading.initialInputGuide && (I.value.loading.initialInputGuide = !1));
|
|
115
121
|
}, {
|
|
116
122
|
immediate: !0,
|
package/dist/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","names":[],"sources":["../src/store.ts"],"sourcesContent":["import type {\n ChartType,\n DemoDataStore,\n DendroStateController,\n DendroUIState,\n InputGuide,\n InputNamesByChartType,\n InputState,\n PlotDataAndSettings,\n} from '@milaboratories/pf-plots';\nimport {\n getControllerByType,\n getInitialStateByType,\n} from '@milaboratories/pf-plots';\nimport type { PColumnSpec } from '@platforma-sdk/model';\nimport type { CategoricalPalette, ContinuousPalette, Palette } from './components/AesSettings/types';\nimport type { ComputedRef, Reactive, Ref } from 'vue';\nimport { computed, inject, provide, reactive, ref, toRaw, watch } from 'vue';\nimport type { AesType } from './constantsCommon';\nimport {\n getInitialAxesSettings,\n getInitialLayersSettings,\n getInitialStatisticsState,\n getInitialTemplate,\n} from './constantsCommon';\nimport { updateDataBindAes } from './dataBindAes';\nimport { notEmpty } from './helpers';\nimport { storeKey } from './keys';\nimport type {\n DefaultPalettes,\n DendroNodeInfo,\n FilterLabelsInfoBySourceMap,\n FilterSuggestionsBySourceMap,\n GraphMakerProps,\n GraphMakerState,\n ReactiveState, UniqueValuesBySourceMap,\n} from './types';\nimport type { LoadedDefaultOptionsMap } from './utils';\nimport { createUpdatedWithNewDefaultsOptionsState, isOptionsStateNeedsToBeUpdated, loadDefaultSources } from './utils';\nimport { addFixedOptionsToState } from './utils/addFixedOptionsToState';\nimport { calculateDiscreteGroups } from './utils/calculateDiscreteGroups';\nimport { copyJSON } from './utils/copyJSON';\nimport { loadDataForPlot } from './utils/createChartSettingsForRender/composeChartSettings';\nimport { getUsedAesInMapping } from './utils/getUsedAesInMapping';\nimport {\n getFacetValuesFromReadyChartData,\n getUniqueValuesFromReadyChartData,\n loadFilterLabelsForTitle,\n} from './utils/loadUniqueValuesToSave';\nimport type { FormKey } from './forms';\nimport { tabKeys } from './forms';\nimport { DEFAULT_CATEGORICAL_PALETTE, DEFAULT_CONTINUOUS_PALETTE } from './constantsAesthetic';\n\nfunction getInitialOptionsState(chartType: ChartType, optionsState: InputState | undefined) {\n const defaultState = copyJSON(getInitialStateByType(chartType));\n if (optionsState?.type !== chartType) {\n return defaultState;\n }\n const optionsStateCopy = copyJSON(optionsState);\n\n return {\n ...defaultState,\n ...optionsStateCopy,\n components: {\n ...defaultState.components,\n ...optionsStateCopy.components,\n },\n };\n}\n\nexport function createReactiveState(\n initialData: GraphMakerState,\n chartType: ChartType,\n): Reactive<ReactiveState> {\n return reactive({\n chartType: chartType,\n // from pf-plots\n optionsState: getInitialOptionsState(chartType, initialData.optionsState), // contains user selected inputs\n // previously used default options\n usedDefaultOptions: initialData.usedDefaultOptions ? copyJSON(initialData.usedDefaultOptions ?? {}) as LoadedDefaultOptionsMap<ChartType> : null,\n\n // local form states, updates directly in forms\n template: getInitialTemplate(initialData.template, chartType),\n statisticsSettings: getInitialStatisticsState(chartType, initialData.statisticsSettings),\n layersSettings: getInitialLayersSettings(initialData.layersSettings),\n axesSettings: getInitialAxesSettings(chartType, initialData.axesSettings),\n // common aesthetics data mapped on columns/axes values\n dataBindAes: copyJSON(initialData.dataBindAes ?? {}),\n chartScale: initialData.zoomState ?? 100,\n lassoControlsState: null,\n currentTab: initialData.currentTab === undefined ? 'dataMapping' : initialData.currentTab,\n tabDefaultState: tabKeys().reduce((res, formKey: FormKey) => {\n res[formKey] = {};\n return res;\n }, {} as Record<FormKey, Record<string, boolean>>),\n dendroInfoByClick: null as null | DendroNodeInfo,\n dendroSelectedNodeId: null,\n showTooltipHint: false,\n tooltipHintWasShown: initialData.tooltipHintWasShown ?? false,\n });\n}\n\nexport interface Store {\n reactive: Reactive<ReactiveState>;\n loading: {\n initialInputGuide: boolean;\n initialCharts: boolean;\n initialDefaults: boolean;\n inputGuide: boolean;\n chartData: boolean;\n defaults: boolean;\n chartRendering: boolean;\n dendroTableData: boolean;\n };\n commonHelpersData: {\n primaryGroups: ComputedRef<ReturnType<typeof calculateDiscreteGroups>>;\n secondaryGroups: ComputedRef<ReturnType<typeof calculateDiscreteGroups>>;\n usedAesInMapping: ComputedRef<Record<string, Record<AesType, boolean>>>;\n dendroTableData: Ref<Awaited<ReturnType<DendroStateController['createTableData']>> | null>;\n };\n controller: ReturnType<typeof getControllerByType>;\n columnsDataStore: Ref<DemoDataStore | null>;\n inputGuide: Ref<InputGuide<InputState>>;\n chartData: Ref<PlotDataAndSettings | null>;\n uniqueValuesData: Ref<UniqueValuesBySourceMap>;\n facetValuesData: Ref<UniqueValuesBySourceMap>;\n filterSuggestionsData: Ref<FilterSuggestionsBySourceMap>;\n filterLabelsInfo: Ref<FilterLabelsInfoBySourceMap>;\n readonlyInputs?: InputNamesByChartType[ChartType][];\n defaultPalette: DefaultPalettes;\n}\n\nexport function factoryStore(\n reactiveState: Reactive<ReactiveState>,\n dataStore: Ref<DemoDataStore | null>,\n inputGuide: Ref<InputGuide<InputState>>,\n chartData: Ref<PlotDataAndSettings | null>,\n dendroTableData: Ref<Awaited<ReturnType<DendroStateController['createTableData']>> | null>,\n uniqueValuesData: Ref<UniqueValuesBySourceMap>,\n facetValuesData: Ref<UniqueValuesBySourceMap>,\n filterSuggestionsData: Ref<FilterSuggestionsBySourceMap>,\n filterLabelsInfo: Ref<FilterLabelsInfoBySourceMap>,\n readonlyInputs?: InputNamesByChartType[ChartType][],\n defaultPalette?: Palette | { categorical?: Palette; continuous?: Palette },\n): Store {\n return {\n reactive: reactiveState,\n loading: reactive({\n initialInputGuide: true,\n initialCharts: true,\n initialDefaults: true,\n inputGuide: false,\n chartData: false,\n defaults: false,\n chartRendering: false,\n dendroTableData: false,\n }),\n commonHelpersData: {\n primaryGroups: computed(() => calculateDiscreteGroups(\n reactiveState.optionsState,\n uniqueValuesData.value,\n 'primaryGrouping',\n ),\n ),\n secondaryGroups: computed(() => calculateDiscreteGroups(\n reactiveState.optionsState,\n uniqueValuesData.value,\n 'secondaryGrouping',\n ),\n ),\n usedAesInMapping: computed<Record<string, Record<AesType, boolean>>>(() =>\n getUsedAesInMapping(\n reactiveState.chartType,\n reactiveState.template,\n reactiveState.layersSettings,\n reactiveState.statisticsSettings,\n reactiveState.optionsState,\n inputGuide.value,\n ),\n ),\n dendroTableData,\n },\n controller: getControllerByType(reactiveState.chartType),\n columnsDataStore: dataStore,\n inputGuide,\n chartData,\n uniqueValuesData,\n facetValuesData,\n filterSuggestionsData,\n filterLabelsInfo,\n readonlyInputs,\n defaultPalette: {\n categorical: typeof defaultPalette === 'object' && defaultPalette.categorical\n ? defaultPalette.categorical as CategoricalPalette\n : typeof defaultPalette === 'string' ? defaultPalette as CategoricalPalette : DEFAULT_CATEGORICAL_PALETTE,\n continuous: typeof defaultPalette === 'object' && defaultPalette.continuous\n ? defaultPalette.continuous as ContinuousPalette\n : typeof defaultPalette === 'string' ? defaultPalette as ContinuousPalette : DEFAULT_CONTINUOUS_PALETTE,\n },\n };\n}\n\nexport type ComputedStore = ComputedRef<Store>;\n\nexport function provideStore(\n initialState: GraphMakerState,\n dataStoreRef: Ref<DemoDataStore | null>,\n chartType: ChartType,\n defaultOptionsRef: Ref<GraphMakerProps['defaultOptions']>,\n fixedOptionsRef: Ref<GraphMakerProps['fixedOptions']>,\n dataColumnPredicate?: (spec: PColumnSpec) => boolean,\n metaColumnPredicate?: (spec: PColumnSpec) => boolean,\n readonlyInputs?: InputNamesByChartType[ChartType][],\n defaultPalette?: GraphMakerProps['defaultPalette'],\n) {\n const reactiveState = createReactiveState(initialState, chartType);\n const controller = getControllerByType(reactiveState.chartType);\n\n const inputGuide = ref<InputGuide<InputState>>(getControllerByType(reactiveState.chartType).getEmptyInputGuide(reactiveState.optionsState));\n const chartData = ref<PlotDataAndSettings | null>(null);\n\n const uniqueValuesData = ref<UniqueValuesBySourceMap>({});\n const facetValuesData = ref<UniqueValuesBySourceMap>({});\n const filterSuggestionsData = ref<FilterSuggestionsBySourceMap>({});\n const filterLabelsInfo = ref<FilterLabelsInfoBySourceMap>({}); // for auto titles of chart if something selected in filter/tabby\n\n const dendroTableData = ref<Awaited<ReturnType<DendroStateController['createTableData']>> | null>(null);\n\n // toRaw removes Vue proxy from dataStore.pframe (PFrame api)\n const store = computed(() => factoryStore(\n reactiveState,\n dataStoreRef,\n inputGuide,\n chartData,\n dendroTableData,\n uniqueValuesData,\n facetValuesData,\n filterSuggestionsData,\n filterLabelsInfo,\n readonlyInputs,\n defaultPalette,\n ));\n\n watch(() => dataStoreRef.value, () => {\n filterLabelsInfo.value = {};\n uniqueValuesData.value = {};\n facetValuesData.value = {};\n filterSuggestionsData.value = {}; // reset saved data; avoid caching of empty results from old empty pframe\n });\n\n const defaultOptionsCounter = ref(0);\n watch([\n () => dataStoreRef.value,\n () => defaultOptionsRef.value,\n ], async ([ds, defaultOptions]) => {\n if (!defaultOptions || defaultOptions?.length === 0 || !ds) {\n return;\n }\n defaultOptionsCounter.value++;\n const counter = defaultOptionsCounter.value;\n store.value.loading.defaults = true;\n if (reactiveState.usedDefaultOptions === null) {\n store.value.loading.initialInputGuide = true;\n }\n const loadedDefaultOptions = await loadDefaultSources(ds, defaultOptions, reactiveState.usedDefaultOptions);\n if (defaultOptionsCounter.value !== counter) {\n return;\n }\n const { usedDefaultOptions, optionsState } = reactiveState;\n const needsToBeUpdated = isOptionsStateNeedsToBeUpdated(optionsState, usedDefaultOptions, loadedDefaultOptions);\n if (!needsToBeUpdated) {\n store.value.loading.defaults = false;\n return;\n }\n store.value.loading.initialCharts = true; // we want to show loader when default are really changed and new chart data is requested\n reactiveState.optionsState.components = createUpdatedWithNewDefaultsOptionsState(optionsState, usedDefaultOptions, loadedDefaultOptions);\n reactiveState.usedDefaultOptions = loadedDefaultOptions;\n }, { immediate: true });\n\n // recalculate input guide - options for every data input, consistency info etc\n const inputGuideCounter = ref(0); // to avoid race condition on async calculations\n watch([\n () => reactiveState.optionsState,\n () => dataStoreRef.value,\n () => fixedOptionsRef.value,\n ], async ([optionsState, ds, fixedOptions]) => {\n if (defaultOptionsRef.value === null || dataStoreRef.value === null) { // they are not ready, waiting for them\n return;\n }\n inputGuideCounter.value++;\n const counter = inputGuideCounter.value;\n store.value.loading.inputGuide = true;\n const ignoredIds = ds && fixedOptions ? Object.values(await loadDefaultSources(ds, fixedOptions, null, false)).flatMap((item) => item.map((s) => s.selectedSource)) : [];\n\n // const start = Date.now();\n const nextInputGuide = ds ? await controller.calculateOptions(toRaw(ds), optionsState, ignoredIds, dataColumnPredicate, metaColumnPredicate) : controller.getEmptyInputGuide(optionsState);\n // console.log('input guide', Date.now() - start);\n\n if (counter === inputGuideCounter.value) { // race condition check\n inputGuide.value = nextInputGuide;\n\n store.value.loading.defaults = false;\n store.value.loading.inputGuide = false;\n if (store.value.loading.initialInputGuide) {\n store.value.loading.initialInputGuide = false;\n }\n }\n }, { immediate: true, deep: true });\n\n // recalculate data for chart rendering (miplots4)\n const chartDataCounter = ref(0); // to avoid race condition on async calculations\n watch(() => inputGuide.value, async (ig) => {\n chartDataCounter.value++;\n const counter = chartDataCounter.value;\n\n store.value.loading.chartData = true;\n\n const ds = toRaw(dataStoreRef.value);\n // const start = Date.now();\n const nextChartData = await loadDataForPlot(ig, reactiveState, ds, fixedOptionsRef.value);\n\n if (nextChartData && ds) {\n const { uniqueValues, filterSuggestions } = await getUniqueValuesFromReadyChartData(\n nextChartData, ig, reactiveState.optionsState.components, controller, ds, toRaw(filterSuggestionsData.value),\n );\n uniqueValuesData.value = uniqueValues;\n facetValuesData.value = getFacetValuesFromReadyChartData(\n nextChartData,\n reactiveState.optionsState.components,\n );\n filterSuggestionsData.value = filterSuggestions;\n updateDataBindAes(reactiveState.optionsState, reactiveState.dataBindAes, uniqueValuesData.value);\n } else {\n facetValuesData.value = {};\n }\n filterLabelsInfo.value = ds\n ? await loadFilterLabelsForTitle(reactiveState.optionsState.components, ig, controller, ds)\n : {};\n // console.log('chart data', Date.now() - start);\n\n if (counter === chartDataCounter.value) { // race condition check\n chartData.value = nextChartData;\n if (ig.ready) {\n store.value.loading.initialCharts = false;\n }\n store.value.loading.chartData = false;\n }\n }, { immediate: true, deep: true });\n\n // watch data for table, only dendro chart; data is also using for popup by tree node click\n if (reactiveState.chartType === 'dendro') {\n const dendroDataCounter = ref(0); // to avoid race condition on async calculations\n watch([\n () => reactiveState.optionsState as DendroUIState,\n () => dataStoreRef.value,\n () => inputGuide.value.readyData,\n () => fixedOptionsRef.value,\n ], async ([optionsState, dataStore, ready, fixed]) => {\n if (ready && dataStore) {\n dendroDataCounter.value++;\n const counter = dendroDataCounter.value;\n store.value.loading.dendroTableData = true;\n const state = (await addFixedOptionsToState(optionsState, dataStore, fixed)) as DendroUIState;\n const nextDendroTableData = await (controller as unknown as DendroStateController).createTableData(dataStore, state);\n\n if (dendroDataCounter.value === counter) {\n dendroTableData.value = nextDendroTableData;\n }\n store.value.loading.dendroTableData = false;\n }\n }, { immediate: true });\n }\n\n provide(storeKey, store);\n return store;\n}\n\nexport function useStore() {\n return notEmpty(inject<ComputedStore>(storeKey), 'Empty store');\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqDA,SAAS,EAAuB,GAAsB,GAAsC;CAC1F,IAAM,IAAe,EAAS,EAAsB,EAAU,CAAC;AAC/D,KAAI,GAAc,SAAS,EACzB,QAAO;CAET,IAAM,IAAmB,EAAS,EAAa;AAE/C,QAAO;EACL,GAAG;EACH,GAAG;EACH,YAAY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Ac,yBAAsB,MAAM,EAChD,GAAe,GAAI,EAAc,aAAa,YAAY,GAAY,GAAI,EAAM,EAAsB,MAAM,CAC7G;AAOD,GANA,EAAiB,QAAQ,GACzB,EAAgB,QAAQ,EACtB,GACA,EAAc,aAAa,WAC5B,EACD,EAAsB,QAAQ,GAC9B,EAAkB,EAAc,cAAc,EAAc,aAAa,EAAiB,MAAM;QAEhG,GAAgB,QAAQ,EAAE;AAO5B,EALA,EAAiB,QAAQ,IACrB,MAAM,EAAyB,EAAc,aAAa,YAAY,GAAI,GAAY,EAAG,GACzF,EAAE,EAGF,MAAY,EAAiB,UAC/B,EAAU,QAAQ,GACd,EAAG,UACL,EAAM,MAAM,QAAQ,gBAAgB,KAEtC,EAAM,MAAM,QAAQ,YAAY;IAEjC;EAAE,WAAW;EAAM,MAAM;EAAM,CAAC,EAG/B,EAAc,cAAc,UAAU;EACxC,IAAM,IAAoB,EAAI,EAAE;AAChC,IAAM;SACE,EAAc;SACd,EAAa;SACb,EAAW,MAAM;SACjB,EAAgB;GACvB,EAAE,OAAO,CAAC,GAAc,GAAW,GAAO,OAAW;AACpD,OAAI,KAAS,GAAW;AACtB,MAAkB;IAClB,IAAM,IAAU,EAAkB;AAClC,MAAM,MAAM,QAAQ,kBAAkB;IACtC,IAAM,IAAS,MAAM,EAAuB,GAAc,GAAW,EAAM,EACrE,IAAsB,MAAO,EAAgD,gBAAgB,GAAW,EAAM;AAKpH,IAHI,EAAkB,UAAU,MAC9B,EAAgB,QAAQ,IAE1B,EAAM,MAAM,QAAQ,kBAAkB;;KAEvC,EAAE,WAAW,IAAM,CAAC;;AAIzB,QADA,EAAQ,GAAU,EAAM,EACjB;;AAGT,SAAgB,IAAW;AACzB,QAAO,EAAS,EAAsB,EAAS,EAAE,cAAc"}
|
|
1
|
+
{"version":3,"file":"store.js","names":[],"sources":["../src/store.ts"],"sourcesContent":["import type {\n ChartType,\n DemoDataStore,\n DendroStateController,\n DendroUIState,\n InputGuide,\n InputNamesByChartType,\n InputState,\n PlotDataAndSettings,\n} from '@milaboratories/pf-plots';\nimport {\n getControllerByType,\n getInitialStateByType,\n} from '@milaboratories/pf-plots';\nimport type { PColumnSpec } from '@platforma-sdk/model';\nimport type { CategoricalPalette, ContinuousPalette, Palette } from './components/AesSettings/types';\nimport type { ComputedRef, Reactive, Ref } from 'vue';\nimport { computed, inject, provide, reactive, ref, toRaw, watch } from 'vue';\nimport type { AesType } from './constantsCommon';\nimport {\n getInitialAxesSettings,\n getInitialLayersSettings,\n getInitialStatisticsState,\n getInitialTemplate,\n} from './constantsCommon';\nimport { updateDataBindAes } from './dataBindAes';\nimport { notEmpty } from './helpers';\nimport { storeKey } from './keys';\nimport type {\n DefaultPalettes,\n DendroNodeInfo,\n FilterLabelsInfoBySourceMap,\n FilterSuggestionsBySourceMap,\n GraphMakerProps,\n GraphMakerState,\n ReactiveState, UniqueValuesBySourceMap,\n} from './types';\nimport type { LoadedDefaultOptionsMap } from './utils';\nimport { createUpdatedWithNewDefaultsOptionsState, isOptionsStateNeedsToBeUpdated, loadDefaultSources } from './utils';\nimport { addFixedOptionsToState } from './utils/addFixedOptionsToState';\nimport { calculateDiscreteGroups } from './utils/calculateDiscreteGroups';\nimport { copyJSON } from './utils/copyJSON';\nimport { loadDataForPlot } from './utils/createChartSettingsForRender/composeChartSettings';\nimport { getUsedAesInMapping } from './utils/getUsedAesInMapping';\nimport {\n getFacetValuesFromReadyChartData,\n getUniqueValuesFromReadyChartData,\n loadFilterLabelsForTitle,\n} from './utils/loadUniqueValuesToSave';\nimport type { FormKey } from './forms';\nimport { tabKeys } from './forms';\nimport { DEFAULT_CATEGORICAL_PALETTE, DEFAULT_CONTINUOUS_PALETTE } from './constantsAesthetic';\n\nfunction getInitialOptionsState(chartType: ChartType, optionsState: InputState | undefined) {\n const defaultState = copyJSON(getInitialStateByType(chartType));\n if (optionsState?.type !== chartType) {\n return defaultState;\n }\n const optionsStateCopy = copyJSON(optionsState);\n\n return {\n ...defaultState,\n ...optionsStateCopy,\n components: {\n ...defaultState.components,\n ...optionsStateCopy.components,\n },\n };\n}\n\nexport function createReactiveState(\n initialData: GraphMakerState,\n chartType: ChartType,\n): Reactive<ReactiveState> {\n return reactive({\n chartType: chartType,\n // from pf-plots\n optionsState: getInitialOptionsState(chartType, initialData.optionsState), // contains user selected inputs\n // previously used default options\n usedDefaultOptions: initialData.usedDefaultOptions ? copyJSON(initialData.usedDefaultOptions ?? {}) as LoadedDefaultOptionsMap<ChartType> : null,\n\n // local form states, updates directly in forms\n template: getInitialTemplate(initialData.template, chartType),\n statisticsSettings: getInitialStatisticsState(chartType, initialData.statisticsSettings),\n layersSettings: getInitialLayersSettings(initialData.layersSettings),\n axesSettings: getInitialAxesSettings(chartType, initialData.axesSettings),\n // common aesthetics data mapped on columns/axes values\n dataBindAes: copyJSON(initialData.dataBindAes ?? {}),\n chartScale: initialData.zoomState ?? 100,\n lassoControlsState: null,\n currentTab: initialData.currentTab === undefined ? 'dataMapping' : initialData.currentTab,\n tabDefaultState: tabKeys().reduce((res, formKey: FormKey) => {\n res[formKey] = {};\n return res;\n }, {} as Record<FormKey, Record<string, boolean>>),\n dendroInfoByClick: null as null | DendroNodeInfo,\n dendroSelectedNodeId: null,\n showTooltipHint: false,\n tooltipHintWasShown: initialData.tooltipHintWasShown ?? false,\n });\n}\n\nexport interface Store {\n reactive: Reactive<ReactiveState>;\n loading: {\n initialInputGuide: boolean;\n initialCharts: boolean;\n initialDefaults: boolean;\n inputGuide: boolean;\n chartData: boolean;\n defaults: boolean;\n chartRendering: boolean;\n dendroTableData: boolean;\n };\n commonHelpersData: {\n primaryGroups: ComputedRef<ReturnType<typeof calculateDiscreteGroups>>;\n secondaryGroups: ComputedRef<ReturnType<typeof calculateDiscreteGroups>>;\n usedAesInMapping: ComputedRef<Record<string, Record<AesType, boolean>>>;\n dendroTableData: Ref<Awaited<ReturnType<DendroStateController['createTableData']>> | null>;\n };\n controller: ReturnType<typeof getControllerByType>;\n columnsDataStore: Ref<DemoDataStore | null>;\n inputGuide: Ref<InputGuide<InputState>>;\n chartData: Ref<PlotDataAndSettings | null>;\n uniqueValuesData: Ref<UniqueValuesBySourceMap>;\n facetValuesData: Ref<UniqueValuesBySourceMap>;\n filterSuggestionsData: Ref<FilterSuggestionsBySourceMap>;\n filterLabelsInfo: Ref<FilterLabelsInfoBySourceMap>;\n readonlyInputs?: InputNamesByChartType[ChartType][];\n defaultPalette: DefaultPalettes;\n}\n\nexport function factoryStore(\n reactiveState: Reactive<ReactiveState>,\n dataStore: Ref<DemoDataStore | null>,\n inputGuide: Ref<InputGuide<InputState>>,\n chartData: Ref<PlotDataAndSettings | null>,\n dendroTableData: Ref<Awaited<ReturnType<DendroStateController['createTableData']>> | null>,\n uniqueValuesData: Ref<UniqueValuesBySourceMap>,\n facetValuesData: Ref<UniqueValuesBySourceMap>,\n filterSuggestionsData: Ref<FilterSuggestionsBySourceMap>,\n filterLabelsInfo: Ref<FilterLabelsInfoBySourceMap>,\n readonlyInputs?: InputNamesByChartType[ChartType][],\n defaultPalette?: Palette | { categorical?: Palette; continuous?: Palette },\n): Store {\n return {\n reactive: reactiveState,\n loading: reactive({\n initialInputGuide: true,\n initialCharts: true,\n initialDefaults: true,\n inputGuide: false,\n chartData: false,\n defaults: false,\n chartRendering: false,\n dendroTableData: false,\n }),\n commonHelpersData: {\n primaryGroups: computed(() => calculateDiscreteGroups(\n reactiveState.optionsState,\n uniqueValuesData.value,\n 'primaryGrouping',\n ),\n ),\n secondaryGroups: computed(() => calculateDiscreteGroups(\n reactiveState.optionsState,\n uniqueValuesData.value,\n 'secondaryGrouping',\n ),\n ),\n usedAesInMapping: computed<Record<string, Record<AesType, boolean>>>(() =>\n getUsedAesInMapping(\n reactiveState.chartType,\n reactiveState.template,\n reactiveState.layersSettings,\n reactiveState.statisticsSettings,\n reactiveState.optionsState,\n inputGuide.value,\n ),\n ),\n dendroTableData,\n },\n controller: getControllerByType(reactiveState.chartType),\n columnsDataStore: dataStore,\n inputGuide,\n chartData,\n uniqueValuesData,\n facetValuesData,\n filterSuggestionsData,\n filterLabelsInfo,\n readonlyInputs,\n defaultPalette: {\n categorical: typeof defaultPalette === 'object' && defaultPalette.categorical\n ? defaultPalette.categorical as CategoricalPalette\n : typeof defaultPalette === 'string' ? defaultPalette as CategoricalPalette : DEFAULT_CATEGORICAL_PALETTE,\n continuous: typeof defaultPalette === 'object' && defaultPalette.continuous\n ? defaultPalette.continuous as ContinuousPalette\n : typeof defaultPalette === 'string' ? defaultPalette as ContinuousPalette : DEFAULT_CONTINUOUS_PALETTE,\n },\n };\n}\n\nexport type ComputedStore = ComputedRef<Store>;\n\nexport function provideStore(\n initialState: GraphMakerState,\n dataStoreRef: Ref<DemoDataStore | null>,\n chartType: ChartType,\n defaultOptionsRef: Ref<GraphMakerProps['defaultOptions']>,\n fixedOptionsRef: Ref<GraphMakerProps['fixedOptions']>,\n dataColumnPredicate?: (spec: PColumnSpec) => boolean,\n metaColumnPredicate?: (spec: PColumnSpec) => boolean,\n readonlyInputs?: InputNamesByChartType[ChartType][],\n defaultPalette?: GraphMakerProps['defaultPalette'],\n) {\n const reactiveState = createReactiveState(initialState, chartType);\n const controller = getControllerByType(reactiveState.chartType);\n\n const inputGuide = ref<InputGuide<InputState>>(getControllerByType(reactiveState.chartType).getEmptyInputGuide(reactiveState.optionsState));\n const chartData = ref<PlotDataAndSettings | null>(null);\n\n const uniqueValuesData = ref<UniqueValuesBySourceMap>({});\n const facetValuesData = ref<UniqueValuesBySourceMap>({});\n const filterSuggestionsData = ref<FilterSuggestionsBySourceMap>({});\n const filterLabelsInfo = ref<FilterLabelsInfoBySourceMap>({}); // for auto titles of chart if something selected in filter/tabby\n\n const dendroTableData = ref<Awaited<ReturnType<DendroStateController['createTableData']>> | null>(null);\n\n // toRaw removes Vue proxy from dataStore.pframe (PFrame api)\n const store = computed(() => factoryStore(\n reactiveState,\n dataStoreRef,\n inputGuide,\n chartData,\n dendroTableData,\n uniqueValuesData,\n facetValuesData,\n filterSuggestionsData,\n filterLabelsInfo,\n readonlyInputs,\n defaultPalette,\n ));\n\n watch(() => dataStoreRef.value, () => {\n filterLabelsInfo.value = {};\n uniqueValuesData.value = {};\n facetValuesData.value = {};\n filterSuggestionsData.value = {}; // reset saved data; avoid caching of empty results from old empty pframe\n });\n\n const defaultOptionsCounter = ref(0);\n watch([\n () => dataStoreRef.value,\n () => defaultOptionsRef.value,\n ], async ([ds, defaultOptions]) => {\n if (!defaultOptions || defaultOptions?.length === 0 || !ds) {\n return;\n }\n defaultOptionsCounter.value++;\n const counter = defaultOptionsCounter.value;\n store.value.loading.defaults = true;\n if (reactiveState.usedDefaultOptions === null) {\n store.value.loading.initialInputGuide = true;\n }\n const loadedDefaultOptions = await loadDefaultSources(ds, defaultOptions, reactiveState.usedDefaultOptions);\n if (defaultOptionsCounter.value !== counter) {\n return;\n }\n const { usedDefaultOptions, optionsState } = reactiveState;\n const needsToBeUpdated = isOptionsStateNeedsToBeUpdated(optionsState, usedDefaultOptions, loadedDefaultOptions);\n if (!needsToBeUpdated) {\n store.value.loading.defaults = false;\n return;\n }\n store.value.loading.initialCharts = true; // we want to show loader when default are really changed and new chart data is requested\n reactiveState.optionsState.components = createUpdatedWithNewDefaultsOptionsState(optionsState, usedDefaultOptions, loadedDefaultOptions);\n reactiveState.usedDefaultOptions = loadedDefaultOptions;\n }, { immediate: true });\n\n // recalculate input guide - options for every data input, consistency info etc\n const inputGuideCounter = ref(0); // to avoid race condition on async calculations\n watch([\n () => reactiveState.optionsState,\n () => dataStoreRef.value,\n () => fixedOptionsRef.value,\n ], async ([optionsState, ds, fixedOptions]) => {\n if (defaultOptionsRef.value === null || dataStoreRef.value === null) { // they are not ready, waiting for them\n return;\n }\n inputGuideCounter.value++;\n const counter = inputGuideCounter.value;\n store.value.loading.inputGuide = true;\n const ignoredIds = ds && fixedOptions ? Object.values(await loadDefaultSources(ds, fixedOptions, null, false)).flatMap((item) => item.map((s) => s.selectedSource)) : [];\n\n // const start = Date.now();\n const nextInputGuide = ds ? await controller.calculateOptions({ store: toRaw(ds), state: optionsState, fixedIds: ignoredIds, dataColumnPredicate, metaColumnPredicate }) : controller.getEmptyInputGuide(optionsState);\n // console.log('input guide', Date.now() - start);\n\n if (counter === inputGuideCounter.value) { // race condition check\n inputGuide.value = nextInputGuide;\n\n store.value.loading.defaults = false;\n store.value.loading.inputGuide = false;\n if (store.value.loading.initialInputGuide) {\n store.value.loading.initialInputGuide = false;\n }\n }\n }, { immediate: true, deep: true });\n\n // recalculate data for chart rendering (miplots4)\n const chartDataCounter = ref(0); // to avoid race condition on async calculations\n watch(() => inputGuide.value, async (ig) => {\n chartDataCounter.value++;\n const counter = chartDataCounter.value;\n\n store.value.loading.chartData = true;\n\n const ds = toRaw(dataStoreRef.value);\n // const start = Date.now();\n const nextChartData = await loadDataForPlot(ig, reactiveState, ds, fixedOptionsRef.value);\n\n if (nextChartData && ds) {\n const { uniqueValues, filterSuggestions } = await getUniqueValuesFromReadyChartData(\n nextChartData, ig, reactiveState.optionsState.components, controller, ds, toRaw(filterSuggestionsData.value),\n );\n uniqueValuesData.value = uniqueValues;\n facetValuesData.value = getFacetValuesFromReadyChartData(\n nextChartData,\n reactiveState.optionsState.components,\n );\n filterSuggestionsData.value = filterSuggestions;\n updateDataBindAes(reactiveState.optionsState, reactiveState.dataBindAes, uniqueValuesData.value);\n } else {\n facetValuesData.value = {};\n }\n filterLabelsInfo.value = ds\n ? await loadFilterLabelsForTitle(reactiveState.optionsState.components, ig, controller, ds)\n : {};\n // console.log('chart data', Date.now() - start);\n\n if (counter === chartDataCounter.value) { // race condition check\n chartData.value = nextChartData;\n if (ig.ready) {\n store.value.loading.initialCharts = false;\n }\n store.value.loading.chartData = false;\n }\n }, { immediate: true, deep: true });\n\n // watch data for table, only dendro chart; data is also using for popup by tree node click\n if (reactiveState.chartType === 'dendro') {\n const dendroDataCounter = ref(0); // to avoid race condition on async calculations\n watch([\n () => reactiveState.optionsState as DendroUIState,\n () => dataStoreRef.value,\n () => inputGuide.value.readyData,\n () => fixedOptionsRef.value,\n ], async ([optionsState, dataStore, ready, fixed]) => {\n if (ready && dataStore) {\n dendroDataCounter.value++;\n const counter = dendroDataCounter.value;\n store.value.loading.dendroTableData = true;\n const state = (await addFixedOptionsToState(optionsState, dataStore, fixed)) as DendroUIState;\n const nextDendroTableData = await (controller as unknown as DendroStateController).createTableData(dataStore, state);\n\n if (dendroDataCounter.value === counter) {\n dendroTableData.value = nextDendroTableData;\n }\n store.value.loading.dendroTableData = false;\n }\n }, { immediate: true });\n }\n\n provide(storeKey, store);\n return store;\n}\n\nexport function useStore() {\n return notEmpty(inject<ComputedStore>(storeKey), 'Empty store');\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqDA,SAAS,EAAuB,GAAsB,GAAsC;CAC1F,IAAM,IAAe,EAAS,EAAsB,EAAU,CAAC;AAC/D,KAAI,GAAc,SAAS,EACzB,QAAO;CAET,IAAM,IAAmB,EAAS,EAAa;AAE/C,QAAO;EACL,GAAG;EACH,GAAG;EACH,YAAY;GACV,GAAG,EAAa;GAChB,GAAG,EAAiB;GACrB;EACF;;AAGH,SAAgB,EACd,GACA,GACyB;AACzB,QAAO,EAAS;EACH;EAEX,cAAc,EAAuB,GAAW,EAAY,aAAa;EAEzE,oBAAoB,EAAY,qBAAqB,EAAS,EAAY,sBAAsB,EAAE,CAAC,GAAyC;EAG5I,UAAU,EAAmB,EAAY,UAAU,EAAU;EAC7D,oBAAoB,EAA0B,GAAW,EAAY,mBAAmB;EACxF,gBAAgB,EAAyB,EAAY,eAAe;EACpE,cAAc,EAAuB,GAAW,EAAY,aAAa;EAEzE,aAAa,EAAS,EAAY,eAAe,EAAE,CAAC;EACpD,YAAY,EAAY,aAAa;EACrC,oBAAoB;EACpB,YAAY,EAAY,eAAe,KAAA,IAAY,gBAAgB,EAAY;EAC/E,iBAAiB,GAAS,CAAC,QAAQ,GAAK,OACtC,EAAI,KAAW,EAAE,EACV,IACN,EAAE,CAA6C;EAClD,mBAAmB;EAC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I,EAAE;AAChC,IAAM;SACE,EAAc;SACd,EAAa;SACb,EAAW,MAAM;SACjB,EAAgB;GACvB,EAAE,OAAO,CAAC,GAAc,GAAW,GAAO,OAAW;AACpD,OAAI,KAAS,GAAW;AACtB,MAAkB;IAClB,IAAM,IAAU,EAAkB;AAClC,MAAM,MAAM,QAAQ,kBAAkB;IACtC,IAAM,IAAS,MAAM,EAAuB,GAAc,GAAW,EAAM,EACrE,IAAsB,MAAO,EAAgD,gBAAgB,GAAW,EAAM;AAKpH,IAHI,EAAkB,UAAU,MAC9B,EAAgB,QAAQ,IAE1B,EAAM,MAAM,QAAQ,kBAAkB;;KAEvC,EAAE,WAAW,IAAM,CAAC;;AAIzB,QADA,EAAQ,GAAU,EAAM,EACjB;;AAGT,SAAgB,IAAW;AACzB,QAAO,EAAS,EAAsB,EAAS,EAAE,cAAc"}
|
|
@@ -129,5 +129,7 @@ export declare function composeBubbleSettings(settings: BubbleSettings, reactive
|
|
|
129
129
|
method?: "sum" | "mean" | "median" | "min" | "max" | undefined;
|
|
130
130
|
} | undefined;
|
|
131
131
|
NAValueAs?: number | null | undefined;
|
|
132
|
+
showEmptyRows?: boolean | undefined;
|
|
133
|
+
showEmptyColumns?: boolean | undefined;
|
|
132
134
|
};
|
|
133
135
|
//# sourceMappingURL=composeBubbleSettings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composeBubbleSettings.d.ts","sourceRoot":"","sources":["../../../src/utils/createChartSettingsForRender/composeBubbleSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAK/D,OAAO,KAAK,EAAe,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAM/E,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,cAAc,EACxB,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,eAAe;;;;
|
|
1
|
+
{"version":3,"file":"composeBubbleSettings.d.ts","sourceRo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CAAC;;;;;;kBAAuO,CAAC;iBAAyC,CAAC;;;SAAwE,CAAC;SAAgC,CAAC;cAAqC,CAAC;;;;;EAD/wd"}
|
|
@@ -8,7 +8,7 @@ function a(a, o, s) {
|
|
|
8
8
|
colorsList: e[u ?? s.continuous].colors,
|
|
9
9
|
maxRadius: r * (o.chartScale / 100),
|
|
10
10
|
minRadius: i
|
|
11
|
-
}, a.size = { cellSize: n * (o.chartScale / 100) }, Object.assign(a, t(o.axesSettings, o.chartType)), a.NAValueAs = l.NAValueAs, l.normalizationDirection && (a.normalization = {
|
|
11
|
+
}, a.size = { cellSize: n * (o.chartScale / 100) }, Object.assign(a, t(o.axesSettings, o.chartType)), a.NAValueAs = l.NAValueAs, a.showEmptyRows = l.showEmptyRows, a.showEmptyColumns = l.showEmptyColumns, l.normalizationDirection && (a.normalization = {
|
|
12
12
|
method: l.normalizationMethod,
|
|
13
13
|
direction: l.normalizationDirection
|
|
14
14
|
}), (l.aggregateByX || l.aggregateByY) && (a.aggregation = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composeBubbleSettings.js","names":[],"sources":["../../../src/utils/createChartSettingsForRender/composeBubbleSettings.ts"],"sourcesContent":["import type { BubbleSettings } from '@milaboratories/miplots4';\nimport {\n DEFAULT_BLACK,\n PALETTE_MAP,\n} from '../../constantsAesthetic';\nimport type { BubbleLayer, DefaultPalettes, ReactiveState } from '../../types';\nimport { getAxesDataFromForms } from '../index';\n\nconst DEFAULT_CELL_SIZE = 40;\nconst DEFAULT_MAX_R = DEFAULT_CELL_SIZE / 2 - 2;\nconst DEFAULT_MIN_R = 3;\nexport function composeBubbleSettings(\n settings: BubbleSettings,\n reactiveState: ReactiveState,\n defaultPalettes: DefaultPalettes,\n) {\n const template = reactiveState.template as BubbleLayer;\n const layerSettings = reactiveState.layersSettings[template];\n const palette = reactiveState.dataBindAes[settings.valueColor.value]?.palette;\n\n settings.aes = {\n cellStrokeColor: layerSettings.strokeColor ?? DEFAULT_BLACK,\n colorsList: PALETTE_MAP[palette ?? defaultPalettes.continuous].colors,\n maxRadius: DEFAULT_MAX_R * (reactiveState.chartScale / 100),\n minRadius: DEFAULT_MIN_R,\n };\n\n settings.size = { cellSize: DEFAULT_CELL_SIZE * (reactiveState.chartScale / 100) };\n\n Object.assign(\n settings,\n getAxesDataFromForms(reactiveState.axesSettings, reactiveState.chartType),\n );\n\n settings.NAValueAs = layerSettings.NAValueAs;\n if (layerSettings.normalizationDirection) {\n settings.normalization = {\n method: layerSettings.normalizationMethod,\n direction: layerSettings.normalizationDirection,\n };\n }\n\n if (layerSettings.aggregateByX || layerSettings.aggregateByY) {\n settings.aggregation = {\n x: layerSettings.aggregateByX && settings.xGroupBy && settings.xGroupBy.length > 0,\n y: layerSettings.aggregateByY && settings.yGroupBy && settings.yGroupBy.length > 0,\n method: layerSettings.aggregationMethod,\n };\n }\n\n const nullValueLabel = reactiveState.axesSettings.other.nullValueLabel;\n if (settings.xColumn) {\n settings.xColumn = { ...settings.xColumn, nullValueLabel: nullValueLabel };\n }\n if (settings.yColumn) {\n settings.yColumn = { ...settings.yColumn, nullValueLabel: nullValueLabel };\n }\n if (settings.xGroupBy) {\n settings.xGroupBy = settings.xGroupBy.map((column) => {\n return { ...column, nullValueLabel: nullValueLabel };\n });\n }\n if (settings.yGroupBy) {\n settings.yGroupBy = settings.yGroupBy.map((column) => {\n return { ...column, nullValueLabel: nullValueLabel };\n });\n }\n if (settings.facetBy) {\n settings.facetBy = settings.facetBy.map((column) => {\n return { ...column, nullValueLabel: nullValueLabel };\n });\n }\n\n return settings;\n}\n"],"mappings":";;AAQA,IAAM,IAAoB,IACpB,IAAgB,IAAoB,IAAI,GACxC,IAAgB;AACtB,SAAgB,EACd,GACA,GACA,GACA;CACA,IAAM,IAAW,EAAc,UACzB,IAAgB,EAAc,eAAe,IAC7C,IAAU,EAAc,YAAY,EAAS,WAAW,QAAQ;
|
|
1
|
+
{"version":3,"file":"composeBubbleSettings.js","names":[],"sources":["../../../src/utils/createChartSettingsForRender/composeBubbleSettings.ts"],"sourcesContent":["import type { BubbleSettings } from '@milaboratories/miplots4';\nimport {\n DEFAULT_BLACK,\n PALETTE_MAP,\n} from '../../constantsAesthetic';\nimport type { BubbleLayer, DefaultPalettes, ReactiveState } from '../../types';\nimport { getAxesDataFromForms } from '../index';\n\nconst DEFAULT_CELL_SIZE = 40;\nconst DEFAULT_MAX_R = DEFAULT_CELL_SIZE / 2 - 2;\nconst DEFAULT_MIN_R = 3;\nexport function composeBubbleSettings(\n settings: BubbleSettings,\n reactiveState: ReactiveState,\n defaultPalettes: DefaultPalettes,\n) {\n const template = reactiveState.template as BubbleLayer;\n const layerSettings = reactiveState.layersSettings[template];\n const palette = reactiveState.dataBindAes[settings.valueColor.value]?.palette;\n\n settings.aes = {\n cellStrokeColor: layerSettings.strokeColor ?? DEFAULT_BLACK,\n colorsList: PALETTE_MAP[palette ?? defaultPalettes.continuous].colors,\n maxRadius: DEFAULT_MAX_R * (reactiveState.chartScale / 100),\n minRadius: DEFAULT_MIN_R,\n };\n\n settings.size = { cellSize: DEFAULT_CELL_SIZE * (reactiveState.chartScale / 100) };\n\n Object.assign(\n settings,\n getAxesDataFromForms(reactiveState.axesSettings, reactiveState.chartType),\n );\n\n settings.NAValueAs = layerSettings.NAValueAs;\n settings.showEmptyRows = layerSettings.showEmptyRows;\n settings.showEmptyColumns = layerSettings.showEmptyColumns;\n if (layerSettings.normalizationDirection) {\n settings.normalization = {\n method: layerSettings.normalizationMethod,\n direction: layerSettings.normalizationDirection,\n };\n }\n\n if (layerSettings.aggregateByX || layerSettings.aggregateByY) {\n settings.aggregation = {\n x: layerSettings.aggregateByX && settings.xGroupBy && settings.xGroupBy.length > 0,\n y: layerSettings.aggregateByY && settings.yGroupBy && settings.yGroupBy.length > 0,\n method: layerSettings.aggregationMethod,\n };\n }\n\n const nullValueLabel = reactiveState.axesSettings.other.nullValueLabel;\n if (settings.xColumn) {\n settings.xColumn = { ...settings.xColumn, nullValueLabel: nullValueLabel };\n }\n if (settings.yColumn) {\n settings.yColumn = { ...settings.yColumn, nullValueLabel: nullValueLabel };\n }\n if (settings.xGroupBy) {\n settings.xGroupBy = settings.xGroupBy.map((column) => {\n return { ...column, nullValueLabel: nullValueLabel };\n });\n }\n if (settings.yGroupBy) {\n settings.yGroupBy = settings.yGroupBy.map((column) => {\n return { ...column, nullValueLabel: nullValueLabel };\n });\n }\n if (settings.facetBy) {\n settings.facetBy = settings.facetBy.map((column) => {\n return { ...column, nullValueLabel: nullValueLabel };\n });\n }\n\n return settings;\n}\n"],"mappings":";;AAQA,IAAM,IAAoB,IACpB,IAAgB,IAAoB,IAAI,GACxC,IAAgB;AACtB,SAAgB,EACd,GACA,GACA,GACA;CACA,IAAM,IAAW,EAAc,UACzB,IAAgB,EAAc,eAAe,IAC7C,IAAU,EAAc,YAAY,EAAS,WAAW,QAAQ;AA0BtE,CAxBA,EAAS,MAAM;EACb,iBAAiB,EAAc,eAAA;EAC/B,YAAY,EAAY,KAAW,EAAgB,YAAY;EAC/D,WAAW,KAAiB,EAAc,aAAa;EACvD,WAAW;EACZ,EAED,EAAS,OAAO,EAAE,UAAU,KAAqB,EAAc,aAAa,MAAM,EAElF,OAAO,OACL,GACA,EAAqB,EAAc,cAAc,EAAc,UAAU,CAC1E,EAED,EAAS,YAAY,EAAc,WACnC,EAAS,gBAAgB,EAAc,eACvC,EAAS,mBAAmB,EAAc,kBACtC,EAAc,2BAChB,EAAS,gBAAgB;EACvB,QAAQ,EAAc;EACtB,WAAW,EAAc;EAC1B,IAGC,EAAc,gBAAgB,EAAc,kBAC9C,EAAS,cAAc;EACrB,GAAG,EAAc,gBAAgB,EAAS,YAAY,EAAS,SAAS,SAAS;EACjF,GAAG,EAAc,gBAAgB,EAAS,YAAY,EAAS,SAAS,SAAS;EACjF,QAAQ,EAAc;EACvB;CAGH,IAAM,IAAiB,EAAc,aAAa,MAAM;AAuBxD,QAtBA,AACE,EAAS,YAAU;EAAE,GAAG,EAAS;EAAyB;EAAgB,EAE5E,AACE,EAAS,YAAU;EAAE,GAAG,EAAS;EAAyB;EAAgB,EAE5E,AACE,EAAS,aAAW,EAAS,SAAS,KAAK,OAClC;EAAE,GAAG;EAAwB;EAAgB,EACpD,EAEJ,AACE,EAAS,aAAW,EAAS,SAAS,KAAK,OAClC;EAAE,GAAG;EAAwB;EAAgB,EACpD,EAEJ,AACE,EAAS,YAAU,EAAS,QAAQ,KAAK,OAChC;EAAE,GAAG;EAAwB;EAAgB,EACpD,EAGG"}
|
|
@@ -134,6 +134,8 @@ export declare function composeHeatmapSettings(settings: HeatmapSettings, reacti
|
|
|
134
134
|
method?: "sum" | "mean" | "median" | "min" | "max" | undefined;
|
|
135
135
|
} | undefined;
|
|
136
136
|
NAValueAs?: number | null | undefined;
|
|
137
|
+
showEmptyRows?: boolean | undefined;
|
|
138
|
+
showEmptyColumns?: boolean | undefined;
|
|
137
139
|
valueType?: "continuous" | "discrete" | undefined;
|
|
138
140
|
annotations?: ({
|
|
139
141
|
type: "continuous" | "discrete";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composeHeatmapSettings.d.ts","sourceRoot":"","sources":["../../../src/utils/createChartSettingsForRender/composeHeatmapSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,KAAK,EAAE,eAAe,EAAwB,aAAa,EAAE,MAAM,aAAa,CAAC;AAGxF,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,eAAe;;;;
|
|
1
|
+
{"version":3,"file":"composeHeatmapSettings.d.ts","sourceRoot":"","sources":["../../../src/utils/createChartSettingsForRender/composeHeatmapSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,KAAK,EAAE,eAAe,EAAwB,aAAa,EAAE,MAAM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BAA2C,CAAC;2BAAiD,CAAC;8BAAoD,CAAC;;qBAA2I,CAAC;;;sBAAkG,CAAC;qBAA2C,CAAC;2BAAiD,CAAC;8BAAoD,CAAC;;;gBAAwF,CAAC;gBAAgD,CAAC;eAA+D,CAAC;iBAAkE,CAAC;uBAA8C,CAAC;cAA2C,CAAC;cAAoC,CAAC;;;eAAsH,CAAC;gBAAsC,CAAC;eAAiM,CAAC;iBAAuC,CAAC;iBAAuC,CAAC;iBAAmG,CAAC;iBAAuC,CAAC;;;EAD3g1D"}
|
|
@@ -23,7 +23,7 @@ function n(n, r, i) {
|
|
|
23
23
|
t.colors = e[r.dataBindAes[n]?.palette ?? (t.type === "discrete" ? i.categorical : i.continuous)].colors;
|
|
24
24
|
}), Object.assign(n, t(r.axesSettings, r.chartType)), r.axesSettings.axisX.cellSize !== null && n.size && (n.size.cellWidth = r.axesSettings.axisX.cellSize * (r.chartScale / 100)), r.axesSettings.axisY.cellSize !== null && n.size && (n.size.cellHeight = r.axesSettings.axisY.cellSize * (r.chartScale / 100)), r.template === "heatmapClustered" && n?.valueType !== "discrete" && (n.facetSettings.sharedX = !1, n.facetSettings.sharedY = !1);
|
|
25
25
|
let s = r.template, c = r.layersSettings[s];
|
|
26
|
-
n.NAValueAs = c.NAValueAs, n.valueType === "continuous" && c.normalizationDirection && (n.normalization = {
|
|
26
|
+
n.NAValueAs = c.NAValueAs, n.showEmptyRows = c.showEmptyRows, n.showEmptyColumns = c.showEmptyColumns, n.valueType === "continuous" && c.normalizationDirection && (n.normalization = {
|
|
27
27
|
method: c.normalizationMethod,
|
|
28
28
|
direction: c.normalizationDirection
|
|
29
29
|
}), n.valueType === "continuous" && (c.aggregateByX || c.aggregateByY) && (n.aggregation = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composeHeatmapSettings.js","names":[],"sources":["../../../src/utils/createChartSettingsForRender/composeHeatmapSettings.ts"],"sourcesContent":["import type { HeatmapSettings } from '@milaboratories/miplots4';\nimport { PALETTE_MAP } from '../../constantsAesthetic';\nimport type { DefaultPalettes, HeatmapLayerTemplate, ReactiveState } from '../../types';\nimport { getAxesDataFromForms } from '../index';\n\nexport function composeHeatmapSettings(\n settings: HeatmapSettings,\n reactiveState: ReactiveState,\n defaultPalette: DefaultPalettes,\n) {\n const aes = {} as Record<string, unknown>;\n const palette = reactiveState.dataBindAes[settings.valueColumn.value]?.palette;\n if (settings?.valueType !== 'discrete') {\n if (reactiveState.template === 'heatmapClustered') {\n const layer = reactiveState.layersSettings.heatmapClustered;\n if (!layer.disableClusteringX) {\n settings.dendrogramX = {\n fillNA: 0,\n showNodes: false,\n hidden: !layer.dendrogramX,\n };\n }\n if (!layer.disableClusteringY) {\n settings.dendrogramY = {\n fillNA: 0,\n position: 'right',\n showNodes: false,\n hidden: !layer.dendrogramY,\n };\n }\n }\n aes.colorsList = PALETTE_MAP[palette ?? defaultPalette.continuous].colors;\n } else {\n aes.colorsList = PALETTE_MAP[palette ?? 'bright'].colors;\n }\n\n settings.aes = aes;\n\n settings.annotations?.forEach((annotationSchema) => {\n const source = annotationSchema.valueColumn.value;\n const palette = reactiveState.dataBindAes[source]?.palette;\n\n annotationSchema.colors = PALETTE_MAP[palette ?? (annotationSchema.type === 'discrete' ? defaultPalette.categorical : defaultPalette.continuous)].colors;\n });\n Object.assign(\n settings,\n getAxesDataFromForms(reactiveState.axesSettings, reactiveState.chartType),\n );\n\n if (reactiveState.axesSettings.axisX.cellSize !== null && settings.size) {\n settings.size.cellWidth = reactiveState.axesSettings.axisX.cellSize * (reactiveState.chartScale / 100);\n }\n if (reactiveState.axesSettings.axisY.cellSize !== null && settings.size) {\n settings.size.cellHeight = reactiveState.axesSettings.axisY.cellSize * (reactiveState.chartScale / 100);\n }\n if (reactiveState.template === 'heatmapClustered' && settings?.valueType !== 'discrete') {\n (settings.facetSettings as HeatmapSettings['facetSettings'])!.sharedX = false;\n (settings.facetSettings as HeatmapSettings['facetSettings'])!.sharedY = false;\n }\n\n const template = reactiveState.template as HeatmapLayerTemplate;\n const layerSettings = reactiveState.layersSettings[template];\n\n settings.NAValueAs = layerSettings.NAValueAs;\n if (settings.valueType === 'continuous' && layerSettings.normalizationDirection) {\n settings.normalization = {\n method: layerSettings.normalizationMethod,\n direction: layerSettings.normalizationDirection,\n };\n }\n\n if (settings.valueType === 'continuous' && (layerSettings.aggregateByX || layerSettings.aggregateByY)) {\n settings.aggregation = {\n x: layerSettings.aggregateByX && settings.xGroupBy && settings.xGroupBy.length > 0,\n y: layerSettings.aggregateByY && settings.yGroupBy && settings.yGroupBy.length > 0,\n method: layerSettings.aggregationMethod,\n };\n }\n\n settings.annotations?.forEach((annotation) => {\n if (annotation.axis === 'x') {\n annotation.titlePosition = reactiveState.axesSettings.axisX.annotationTitlePosition === 'hidden' ? undefined : reactiveState.axesSettings.axisX.annotationTitlePosition;\n annotation.showTitle = reactiveState.axesSettings.axisX.annotationTitlePosition !== 'hidden';\n } else {\n annotation.titlePosition = reactiveState.axesSettings.axisY.annotationTitlePosition === 'hidden' ? undefined : reactiveState.axesSettings.axisY.annotationTitlePosition;\n annotation.showTitle = reactiveState.axesSettings.axisY.annotationTitlePosition !== 'hidden';\n }\n });\n\n if (reactiveState.axesSettings.other.canvasRenderMode) {\n settings.cellsRenderingMode = 'canvas';\n }\n\n const nullValueLabel = reactiveState.axesSettings.other.nullValueLabel;\n if (settings.xColumn) {\n settings.xColumn = { ...settings.xColumn, nullValueLabel: nullValueLabel };\n }\n if (settings.yColumn) {\n settings.yColumn = { ...settings.yColumn, nullValueLabel: nullValueLabel };\n }\n if (settings.xGroupBy) {\n settings.xGroupBy = settings.xGroupBy.map((column) => {\n return { ...column, nullValueLabel: nullValueLabel };\n });\n }\n if (settings.yGroupBy) {\n settings.yGroupBy = settings.yGroupBy.map((column) => {\n return { ...column, nullValueLabel: nullValueLabel };\n });\n }\n if (settings.facetBy) {\n settings.facetBy = settings.facetBy.map((column) => {\n return { ...column, nullValueLabel: nullValueLabel };\n });\n }\n if (settings.annotations) {\n settings.annotations = settings.annotations.map((annotation) => {\n return { ...annotation, valueColumn: { ...annotation.valueColumn, nullValueLabel: nullValueLabel } };\n });\n }\n return settings;\n}\n"],"mappings":";;AAKA,SAAgB,EACd,GACA,GACA,GACA;CACA,IAAM,IAAM,EAAE,EACR,IAAU,EAAc,YAAY,EAAS,YAAY,QAAQ;AACvE,KAAI,GAAU,cAAc,YAAY;AACtC,MAAI,EAAc,aAAa,oBAAoB;GACjD,IAAM,IAAQ,EAAc,eAAe;AAQ3C,GAPK,EAAM,uBACT,EAAS,cAAc;IACrB,QAAQ;IACR,WAAW;IACX,QAAQ,CAAC,EAAM;IAChB,GAEE,EAAM,uBACT,EAAS,cAAc;IACrB,QAAQ;IACR,UAAU;IACV,WAAW;IACX,QAAQ,CAAC,EAAM;IAChB;;AAGL,IAAI,aAAa,EAAY,KAAW,EAAe,YAAY;OAEnE,GAAI,aAAa,EAAY,KAAW,UAAU;AAsBpD,CAnBA,EAAS,MAAM,GAEf,EAAS,aAAa,SAAS,MAAqB;EAClD,IAAM,IAAS,EAAiB,YAAY;AAG5C,IAAiB,SAAS,EAFV,EAAc,YAAY,IAAS,YAED,EAAiB,SAAS,aAAa,EAAe,cAAc,EAAe,aAAa;GAClJ,EACF,OAAO,OACL,GACA,EAAqB,EAAc,cAAc,EAAc,UAAU,CAC1E,EAEG,EAAc,aAAa,MAAM,aAAa,QAAQ,EAAS,SACjE,EAAS,KAAK,YAAY,EAAc,aAAa,MAAM,YAAY,EAAc,aAAa,OAEhG,EAAc,aAAa,MAAM,aAAa,QAAQ,EAAS,SACjE,EAAS,KAAK,aAAa,EAAc,aAAa,MAAM,YAAY,EAAc,aAAa,OAEjG,EAAc,aAAa,sBAAsB,GAAU,cAAc,eAC1E,EAAS,cAAoD,UAAU,IACvE,EAAS,cAAoD,UAAU;CAG1E,IAAM,IAAW,EAAc,UACzB,IAAgB,EAAc,eAAe;
|
|
1
|
+
{"version":3,"file":"composeHeatmapSettings.js","names":[],"sources":["../../../src/utils/createChartSettingsForRender/composeHeatmapSettings.ts"],"sourcesContent":["import type { HeatmapSettings } from '@milaboratories/miplots4';\nimport { PALETTE_MAP } from '../../constantsAesthetic';\nimport type { DefaultPalettes, HeatmapLayerTemplate, ReactiveState } from '../../types';\nimport { getAxesDataFromForms } from '../index';\n\nexport function composeHeatmapSettings(\n settings: HeatmapSettings,\n reactiveState: ReactiveState,\n defaultPalette: DefaultPalettes,\n) {\n const aes = {} as Record<string, unknown>;\n const palette = reactiveState.dataBindAes[settings.valueColumn.value]?.palette;\n if (settings?.valueType !== 'discrete') {\n if (reactiveState.template === 'heatmapClustered') {\n const layer = reactiveState.layersSettings.heatmapClustered;\n if (!layer.disableClusteringX) {\n settings.dendrogramX = {\n fillNA: 0,\n showNodes: false,\n hidden: !layer.dendrogramX,\n };\n }\n if (!layer.disableClusteringY) {\n settings.dendrogramY = {\n fillNA: 0,\n position: 'right',\n showNodes: false,\n hidden: !layer.dendrogramY,\n };\n }\n }\n aes.colorsList = PALETTE_MAP[palette ?? defaultPalette.continuous].colors;\n } else {\n aes.colorsList = PALETTE_MAP[palette ?? 'bright'].colors;\n }\n\n settings.aes = aes;\n\n settings.annotations?.forEach((annotationSchema) => {\n const source = annotationSchema.valueColumn.value;\n const palette = reactiveState.dataBindAes[source]?.palette;\n\n annotationSchema.colors = PALETTE_MAP[palette ?? (annotationSchema.type === 'discrete' ? defaultPalette.categorical : defaultPalette.continuous)].colors;\n });\n Object.assign(\n settings,\n getAxesDataFromForms(reactiveState.axesSettings, reactiveState.chartType),\n );\n\n if (reactiveState.axesSettings.axisX.cellSize !== null && settings.size) {\n settings.size.cellWidth = reactiveState.axesSettings.axisX.cellSize * (reactiveState.chartScale / 100);\n }\n if (reactiveState.axesSettings.axisY.cellSize !== null && settings.size) {\n settings.size.cellHeight = reactiveState.axesSettings.axisY.cellSize * (reactiveState.chartScale / 100);\n }\n if (reactiveState.template === 'heatmapClustered' && settings?.valueType !== 'discrete') {\n (settings.facetSettings as HeatmapSettings['facetSettings'])!.sharedX = false;\n (settings.facetSettings as HeatmapSettings['facetSettings'])!.sharedY = false;\n }\n\n const template = reactiveState.template as HeatmapLayerTemplate;\n const layerSettings = reactiveState.layersSettings[template];\n\n settings.NAValueAs = layerSettings.NAValueAs;\n settings.showEmptyRows = layerSettings.showEmptyRows;\n settings.showEmptyColumns = layerSettings.showEmptyColumns;\n if (settings.valueType === 'continuous' && layerSettings.normalizationDirection) {\n settings.normalization = {\n method: layerSettings.normalizationMethod,\n direction: layerSettings.normalizationDirection,\n };\n }\n\n if (settings.valueType === 'continuous' && (layerSettings.aggregateByX || layerSettings.aggregateByY)) {\n settings.aggregation = {\n x: layerSettings.aggregateByX && settings.xGroupBy && settings.xGroupBy.length > 0,\n y: layerSettings.aggregateByY && settings.yGroupBy && settings.yGroupBy.length > 0,\n method: layerSettings.aggregationMethod,\n };\n }\n\n settings.annotations?.forEach((annotation) => {\n if (annotation.axis === 'x') {\n annotation.titlePosition = reactiveState.axesSettings.axisX.annotationTitlePosition === 'hidden' ? undefined : reactiveState.axesSettings.axisX.annotationTitlePosition;\n annotation.showTitle = reactiveState.axesSettings.axisX.annotationTitlePosition !== 'hidden';\n } else {\n annotation.titlePosition = reactiveState.axesSettings.axisY.annotationTitlePosition === 'hidden' ? undefined : reactiveState.axesSettings.axisY.annotationTitlePosition;\n annotation.showTitle = reactiveState.axesSettings.axisY.annotationTitlePosition !== 'hidden';\n }\n });\n\n if (reactiveState.axesSettings.other.canvasRenderMode) {\n settings.cellsRenderingMode = 'canvas';\n }\n\n const nullValueLabel = reactiveState.axesSettings.other.nullValueLabel;\n if (settings.xColumn) {\n settings.xColumn = { ...settings.xColumn, nullValueLabel: nullValueLabel };\n }\n if (settings.yColumn) {\n settings.yColumn = { ...settings.yColumn, nullValueLabel: nullValueLabel };\n }\n if (settings.xGroupBy) {\n settings.xGroupBy = settings.xGroupBy.map((column) => {\n return { ...column, nullValueLabel: nullValueLabel };\n });\n }\n if (settings.yGroupBy) {\n settings.yGroupBy = settings.yGroupBy.map((column) => {\n return { ...column, nullValueLabel: nullValueLabel };\n });\n }\n if (settings.facetBy) {\n settings.facetBy = settings.facetBy.map((column) => {\n return { ...column, nullValueLabel: nullValueLabel };\n });\n }\n if (settings.annotations) {\n settings.annotations = settings.annotations.map((annotation) => {\n return { ...annotation, valueColumn: { ...annotation.valueColumn, nullValueLabel: nullValueLabel } };\n });\n }\n return settings;\n}\n"],"mappings":";;AAKA,SAAgB,EACd,GACA,GACA,GACA;CACA,IAAM,IAAM,EAAE,EACR,IAAU,EAAc,YAAY,EAAS,YAAY,QAAQ;AACvE,KAAI,GAAU,cAAc,YAAY;AACtC,MAAI,EAAc,aAAa,oBAAoB;GACjD,IAAM,IAAQ,EAAc,eAAe;AAQ3C,GAPK,EAAM,uBACT,EAAS,cAAc;IACrB,QAAQ;IACR,WAAW;IACX,QAAQ,CAAC,EAAM;IAChB,GAEE,EAAM,uBACT,EAAS,cAAc;IACrB,QAAQ;IACR,UAAU;IACV,WAAW;IACX,QAAQ,CAAC,EAAM;IAChB;;AAGL,IAAI,aAAa,EAAY,KAAW,EAAe,YAAY;OAEnE,GAAI,aAAa,EAAY,KAAW,UAAU;AAsBpD,CAnBA,EAAS,MAAM,GAEf,EAAS,aAAa,SAAS,MAAqB;EAClD,IAAM,IAAS,EAAiB,YAAY;AAG5C,IAAiB,SAAS,EAFV,EAAc,YAAY,IAAS,YAED,EAAiB,SAAS,aAAa,EAAe,cAAc,EAAe,aAAa;GAClJ,EACF,OAAO,OACL,GACA,EAAqB,EAAc,cAAc,EAAc,UAAU,CAC1E,EAEG,EAAc,aAAa,MAAM,aAAa,QAAQ,EAAS,SACjE,EAAS,KAAK,YAAY,EAAc,aAAa,MAAM,YAAY,EAAc,aAAa,OAEhG,EAAc,aAAa,MAAM,aAAa,QAAQ,EAAS,SACjE,EAAS,KAAK,aAAa,EAAc,aAAa,MAAM,YAAY,EAAc,aAAa,OAEjG,EAAc,aAAa,sBAAsB,GAA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AK,OAChC;EAAE,GAAG;EAAwB;EAAgB,EACpD,EAEJ,AACE,EAAS,gBAAc,EAAS,YAAY,KAAK,OACxC;EAAE,GAAG;EAAY,aAAa;GAAE,GAAG,EAAW;GAA6B;GAAgB;EAAE,EACpG,EAEG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadUniqueValuesToSave.d.ts","sourceRoot":"","sources":["../../src/utils/loadUniqueValuesToSave.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AACnH,OAAO,KAAK,EAEV,UAAU,EACV,aAAa,EACb,UAAU,EACV,UAAU,EACV,mBAAmB,EAEpB,MAAM,0BAA0B,CAAC;AAyDlC,wBAAsB,iCAAiC,CACrD,SAAS,EAAE,mBAAmB,EAC9B,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,EAClC,YAAY,EAAE,UAAU,CAAC,YAAY,CAAC,EACtC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,EAClC,SAAS,EAAE,aAAa,EACxB,yBAAyB,EAAE,4BAA4B,EACvD,aAAa,SAAmB,GAC/B,OAAO,CAAC;IAAE,YAAY,EAAE,uBAAuB,CAAC;IAAC,iBAAiB,EAAE,4BAA4B,CAAA;CAAE,CAAC,CAgFrG;AAED,0HAA0H;AAC1H,wBAAgB,gCAAgC,CAC9C,SAAS,EAAE,mBAAmB,EAC9B,YAAY,EAAE,UAAU,CAAC,YAAY,CAAC,EACtC,mBAAmB,SAAO,GACzB,uBAAuB,CAazB;AAED,wBAAsB,wBAAwB,CAC5C,YAAY,EAAE,UAAU,CAAC,YAAY,CAAC,EACtC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,EAClC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,EAClC,SAAS,EAAE,aAAa,GACvB,OAAO,CAAC,2BAA2B,CAAC,
|
|
1
|
+
{"version":3,"file":"loadUniqueValuesToSave.d.ts","sourceRoot":"","sources":["../../src/utils/loadUniqueValuesToSave.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AACnH,OAAO,KAAK,EAEV,UAAU,EACV,aAAa,EACb,UAAU,EACV,UAAU,EACV,mBAAmB,EAEpB,MAAM,0BAA0B,CAAC;AAyDlC,wBAAsB,iCAAiC,CACrD,SAAS,EAAE,mBAAmB,EAC9B,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,EAClC,YAAY,EAAE,UAAU,CAAC,YAAY,CAAC,EACtC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,EAClC,SAAS,EAAE,aAAa,EACxB,yBAAyB,EAAE,4BAA4B,EACvD,aAAa,SAAmB,GAC/B,OAAO,CAAC;IAAE,YAAY,EAAE,uBAAuB,CAAC;IAAC,iBAAiB,EAAE,4BAA4B,CAAA;CAAE,CAAC,CAgFrG;AAED,0HAA0H;AAC1H,wBAAgB,gCAAgC,CAC9C,SAAS,EAAE,mBAAmB,EAC9B,YAAY,EAAE,UAAU,CAAC,YAAY,CAAC,EACtC,mBAAmB,SAAO,GACzB,uBAAuB,CAazB;AAED,wBAAsB,wBAAwB,CAC5C,YAAY,EAAE,UAAU,CAAC,YAAY,CAAC,EACtC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,EAClC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,EAClC,SAAS,EAAE,aAAa,GACvB,OAAO,CAAC,2BAA2B,CAAC,CA0BtC"}
|
|
@@ -69,7 +69,12 @@ async function u(s, c, u, d, f, p, m = e) {
|
|
|
69
69
|
if (t) for (let { selectedSource: n, type: r } of t.selectorStates) ((e === "filters" || e === "highlight") && r === "equals" || e === "tabBy") && _.push(n);
|
|
70
70
|
});
|
|
71
71
|
for (let e of _) if (g[e]) continue;
|
|
72
|
-
else f && (g[e] = await d.getUniqueSourceValuesWithLabels(
|
|
72
|
+
else f && (g[e] = await d.getUniqueSourceValuesWithLabels({
|
|
73
|
+
store: f,
|
|
74
|
+
inputGuide: c,
|
|
75
|
+
selectedSource: e,
|
|
76
|
+
limit: m
|
|
77
|
+
}));
|
|
73
78
|
return {
|
|
74
79
|
uniqueValues: h,
|
|
75
80
|
filterSuggestions: g
|
|
@@ -91,8 +96,16 @@ async function f(e, t, n, r) {
|
|
|
91
96
|
if (n) for (let { selectedSource: e, selectedFilterValues: r, type: a } of n.selectorStates) (t === "filters" && a === "equals" && r || r) && i.push([e, r]);
|
|
92
97
|
});
|
|
93
98
|
let a = {};
|
|
94
|
-
for (let [e, o] of i) (await Promise.all(o.map((i) => n.
|
|
95
|
-
|
|
99
|
+
for (let [e, o] of i) (await Promise.all(o.map((i) => n.getLabelForValue({
|
|
100
|
+
store: r,
|
|
101
|
+
inputGuide: t,
|
|
102
|
+
selectedSource: e,
|
|
103
|
+
value: i
|
|
104
|
+
})))).forEach((t, n) => {
|
|
105
|
+
a[e] || (a[e] = {}), a[e][o[n]] = {
|
|
106
|
+
value: o[n],
|
|
107
|
+
label: t
|
|
108
|
+
};
|
|
96
109
|
});
|
|
97
110
|
return a;
|
|
98
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadUniqueValuesToSave.js","names":[],"sources":["../../src/utils/loadUniqueValuesToSave.ts"],"sourcesContent":["import type { FilterLabelsInfoBySourceMap, FilterSuggestionsBySourceMap, UniqueValuesBySourceMap } from '../types';\nimport type {\n ComponentStateFilter,\n Controller,\n DemoDataStore,\n InputGuide,\n InputState,\n PlotDataAndSettings,\n SelectorStateFilter,\n} from '@milaboratories/pf-plots';\nimport type { DendroSettings, DiscreteSettings, HistogramSettings, ScatterplotSettings } from '@milaboratories/miplots4';\nimport { MAX_GROUPS_COUNT } from '../constantsCommon';\n\nconst SAVED_IN_CHART_DATA_DISCRETE_GROUPINGS = ['primaryGrouping', 'secondaryGrouping'];\nconst SAVED_IN_CHART_DATA_SCATTERPLOT_GROUPINGS = ['grouping', 'dotShape'];\nconst SAVED_IN_CHART_DATA_SCATTERPLOT_XY = ['x', 'y'];\nconst SAVED_IN_CHART_DATA_HISTOGRAM_GROUPING = ['grouping'];\nconst SAVED_IN_CHART_DATA_DENDRO_GROUPING = [\n 'nodeColor', 'nodeShape', 'lineColor', 'heatmapAnnotation', // dendro\n];\n\nconst FILTER_INPUTS = ['filters', 'highlight', 'tabBy'] as ((keyof InputState['components'])[]);\n\nconst sortValues = (values: { value: string; label: string }[]) => values.sort((a, b) => a.label.localeCompare(b.label, 'en', { numeric: true }));\n\nconst OVERFLOW_LIMIT = 100;\nfunction addUniqueData(chartData: PlotDataAndSettings, resultMap: UniqueValuesBySourceMap, sourceId: string, maxGroupCount: number, labelId?: string) {\n const data = chartData!.data.byColumns.values[sourceId];\n const dataLabels = labelId ? chartData!.data.byColumns.values[labelId] : null;\n\n const resultSet = new Set();\n const result: { value: string; label: string }[] = [];\n for (let i = 0; i < data.length; i++) {\n const v = String(data[i]);\n if (resultSet.has(v)) {\n continue;\n }\n if (resultSet.size === maxGroupCount) {\n sortValues(result);\n resultMap[sourceId] = {\n list: result.map((el) => el.value),\n labels: result.reduce((res, el) => {\n res[el.value] = el.label;\n return res;\n }, {} as Record<string, string>),\n options: result,\n overflow: result.length > OVERFLOW_LIMIT,\n };\n return;\n }\n resultSet.add(v);\n const label = dataLabels ? String(dataLabels[i]) : v;\n result.push({ value: v, label });\n }\n sortValues(result);\n resultMap[sourceId] = {\n list: result.map((el) => el.value),\n labels: result.reduce((res, el) => {\n res[el.value] = el.label;\n return res;\n }, {} as Record<string, string>),\n options: result,\n overflow: result.length > OVERFLOW_LIMIT,\n };\n}\n\nexport async function getUniqueValuesFromReadyChartData(\n chartData: PlotDataAndSettings,\n inputGuide: InputGuide<InputState>,\n optionsState: InputState['components'],\n controller: Controller<InputState>,\n dataStore: DemoDataStore,\n previousFilterSuggestions: FilterSuggestionsBySourceMap,\n maxGroupCount = MAX_GROUPS_COUNT,\n): Promise<{ uniqueValues: UniqueValuesBySourceMap; filterSuggestions: FilterSuggestionsBySourceMap }> {\n const resultMap: UniqueValuesBySourceMap = {};\n\n if (chartData.settings.type === 'discrete') {\n SAVED_IN_CHART_DATA_DISCRETE_GROUPINGS.forEach((inputName: string) => {\n const savedData = chartData.settings[inputName] as unknown as DiscreteSettings['primaryGrouping'];\n if (savedData) {\n const { columnName } = savedData;\n addUniqueData(chartData, resultMap, columnName.value, maxGroupCount, columnName.valueLabels);\n }\n });\n }\n if (chartData.settings.type === 'scatterplot' || chartData.settings.type === 'scatterplot-umap') {\n SAVED_IN_CHART_DATA_SCATTERPLOT_XY.forEach((inputName: string) => {\n const columnName = chartData.settings[inputName] as unknown as ScatterplotSettings['x'];\n if (columnName) {\n const valueType = inputGuide.getSourceInfo(columnName.value).type;\n if (valueType === 'String') {\n addUniqueData(chartData, resultMap, columnName.value, maxGroupCount, columnName.valueLabels);\n }\n }\n });\n SAVED_IN_CHART_DATA_SCATTERPLOT_GROUPINGS.forEach((inputName: string) => {\n const savedInGrouping = chartData.settings[inputName] as unknown as ScatterplotSettings['grouping'];\n savedInGrouping?.forEach(({ columnName }) => {\n const valueType = inputGuide.getSourceInfo(columnName.value).type;\n if (valueType === 'String' || valueType === 'Int' || valueType === 'Long') {\n addUniqueData(chartData, resultMap, columnName.value, maxGroupCount, columnName.valueLabels);\n }\n });\n });\n }\n\n if (chartData.settings.type === 'histogram') {\n SAVED_IN_CHART_DATA_HISTOGRAM_GROUPING.forEach((inputName: string) => {\n const savedByInputName = chartData.settings[inputName] as unknown as HistogramSettings['grouping'];\n if (savedByInputName) {\n addUniqueData(chartData, resultMap, savedByInputName.value, maxGroupCount, savedByInputName.valueLabels);\n }\n });\n }\n\n if (chartData.settings.type === 'dendro') {\n SAVED_IN_CHART_DATA_DENDRO_GROUPING.forEach((inputName: string) => {\n const savedByInputName = chartData.settings[inputName] as unknown as DendroSettings['heatmapAnnotation'];\n if (savedByInputName) {\n addUniqueData(chartData, resultMap, savedByInputName.value, maxGroupCount, savedByInputName.valueLabels);\n }\n });\n }\n\n const filterSuggestionsMap: FilterSuggestionsBySourceMap = { ...previousFilterSuggestions };\n\n // sources for loading\n const selectedSources: string[] = [];\n ([...inputGuide.fullOptionsSet]).forEach((id) => {\n const info = inputGuide.getSourceInfo(id);\n if (info.kind === 'axis' && info.isNonHomogenous) {\n selectedSources.push(id);\n }\n });\n FILTER_INPUTS.forEach((inputName) => {\n const componentState = optionsState[inputName] as ComponentStateFilter;\n if (!componentState) {\n return;\n }\n for (const { selectedSource, type } of componentState.selectorStates as SelectorStateFilter[]) {\n if (((inputName === 'filters' || inputName === 'highlight') && type === 'equals') || inputName === 'tabBy') {\n selectedSources.push(selectedSource);\n }\n }\n });\n for (const source of selectedSources) {\n if (filterSuggestionsMap[source]) {\n continue;\n } else if (dataStore) {\n filterSuggestionsMap[source] = await controller.getUniqueSourceValuesWithLabels(dataStore, inputGuide, source, maxGroupCount);\n }\n }\n return { uniqueValues: resultMap, filterSuggestions: filterSuggestionsMap };\n}\n\n/** Build facet values map from facetBy columns in chart data, limited by maxFacetsCount (same shape as unique values). */\nexport function getFacetValuesFromReadyChartData(\n chartData: PlotDataAndSettings,\n optionsState: InputState['components'],\n maxSavedFacetsCount = 1000,\n): UniqueValuesBySourceMap {\n const resultMap: UniqueValuesBySourceMap = {};\n const facetBy = optionsState?.facetBy as { selectorStates: { selectedSource: string }[] } | undefined;\n if (!facetBy?.selectorStates?.length) {\n return resultMap;\n }\n const columns = chartData.data.byColumns.values;\n facetBy.selectorStates.forEach(({ selectedSource }) => {\n if (columns[selectedSource]) {\n addUniqueData(chartData, resultMap, selectedSource, maxSavedFacetsCount);\n }\n });\n return resultMap;\n}\n\nexport async function loadFilterLabelsForTitle(\n optionsState: InputState['components'],\n inputGuide: InputGuide<InputState>,\n controller: Controller<InputState>,\n dataStore: DemoDataStore,\n): Promise<FilterLabelsInfoBySourceMap> {\n const selected: [string, string[]][] = [];\n const INPUTS_REQUESTING_LABELS = ['filters', 'tabBy'] as ((keyof InputState['components'])[]);\n INPUTS_REQUESTING_LABELS.forEach((inputName) => {\n const componentState = optionsState[inputName];\n if (componentState) {\n for (const { selectedSource, selectedFilterValues, type } of componentState.selectorStates as SelectorStateFilter[]) {\n if (inputName === 'filters' && type === 'equals' && selectedFilterValues) {\n selected.push([selectedSource, selectedFilterValues]);\n } else if (selectedFilterValues) {\n selected.push([selectedSource, selectedFilterValues]);\n }\n }\n }\n });\n const result: FilterLabelsInfoBySourceMap = {};\n for (const [source, selectedValues] of selected) {\n const uniqueValuesResponses = await Promise.all(selectedValues.map((v) => controller.getUniqueSourceValuesWithLabels(dataStore, inputGuide, source, 1, undefined, v)));\n uniqueValuesResponses.forEach((response, idx) => {\n if (response.values.length > 0) {\n if (!result[source]) {\n result[source] = {};\n }\n result[source][selectedValues[idx] as string] = response.values[0];\n }\n });\n }\n return result;\n}\n"],"mappings":";AAaA,IAAM,IAAyC,CAAC,mBAAmB,oBAAoB,EACjF,IAA4C,CAAC,YAAY,WAAW,EACpE,IAAqC,CAAC,KAAK,IAAI,EAC/C,IAAyC,CAAC,WAAW,EACrD,IAAsC;CAC1C;CAAa;CAAa;CAAa;CACxC,EAEK,IAAgB;CAAC;CAAW;CAAa;CAAQ,EAEjD,KAAc,MAA+C,EAAO,MAAM,GAAG,MAAM,EAAE,MAAM,cAAc,EAAE,OAAO,MAAM,EAAE,SAAS,IAAM,CAAC,CAAC,EAE3I,IAAiB;AACvB,SAAS,EAAc,GAAgC,GAAoC,GAAkB,GAAuB,GAAkB;CACpJ,IAAM,IAAO,EAAW,KAAK,UAAU,OAAO,IACxC,IAAa,IAAU,EAAW,KAAK,UAAU,OAAO,KAAW,MAEnE,oBAAY,IAAI,KAAK,EACrB,IAA6C,EAAE;AACrD,MAAK,IAAI,IAAI,GAAG,IAAI,EAAK,QAAQ,KAAK;EACpC,IAAM,IAAI,OAAO,EAAK,GAAG;AACzB,MAAI,EAAU,IAAI,EAAE,CACl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Ac,GAAW,GAAW,GAAgB,EAAoB;GAE1E,EACK;;AAGT,eAAsB,EACpB,GACA,GACA,GACA,GACsC;CACtC,IAAM,IAAiC,EAAE;AACR,EAAC,WAAW,QAAQ,CAC5B,SAAS,MAAc;EAC9C,IAAM,IAAiB,EAAa;AACpC,MAAI,QACG,IAAM,EAAE,mBAAgB,yBAAsB,aAAU,EAAe,eAC1E,EAAI,MAAc,aAAa,MAAS,YAAY,KAEzC,MADT,EAAS,KAAK,CAAC,GAAgB,EAAqB,CAAC;GAM3D;CACF,IAAM,IAAsC,EAAE;AAC9C,MAAK,IAAM,CAAC,GAAQ,MAAmB,EAErC,EAD8B,MAAM,QAAQ,IAAI,EAAe,KAAK,MAAM,EAAW,gCAAgC,GAAW,GAAY,GAAQ,GAAG,KAAA,GAAW,EAAE,CAAC,CAAC,EAChJ,SAAS,GAAU,MAAQ;AAC/C,EAAI,EAAS,OAAO,SAAS,MACtB,EAAO,OACV,EAAO,KAAU,EAAE,GAErB,EAAO,GAAQ,EAAe,MAAkB,EAAS,OAAO;GAElE;AAEJ,QAAO"}
|
|
1
|
+
{"version":3,"file":"loadUniqueValuesToSave.js","names":[],"sources":["../../src/utils/loadUniqueValuesToSave.ts"],"sourcesContent":["import type { FilterLabelsInfoBySourceMap, FilterSuggestionsBySourceMap, UniqueValuesBySourceMap } from '../types';\nimport type {\n ComponentStateFilter,\n Controller,\n DemoDataStore,\n InputGuide,\n InputState,\n PlotDataAndSettings,\n SelectorStateFilter,\n} from '@milaboratories/pf-plots';\nimport type { DendroSettings, DiscreteSettings, HistogramSettings, ScatterplotSettings } from '@milaboratories/miplots4';\nimport { MAX_GROUPS_COUNT } from '../constantsCommon';\n\nconst SAVED_IN_CHART_DATA_DISCRETE_GROUPINGS = ['primaryGrouping', 'secondaryGrouping'];\nconst SAVED_IN_CHART_DATA_SCATTERPLOT_GROUPINGS = ['grouping', 'dotShape'];\nconst SAVED_IN_CHART_DATA_SCATTERPLOT_XY = ['x', 'y'];\nconst SAVED_IN_CHART_DATA_HISTOGRAM_GROUPING = ['grouping'];\nconst SAVED_IN_CHART_DATA_DENDRO_GROUPING = [\n 'nodeColor', 'nodeShape', 'lineColor', 'heatmapAnnotation', // dendro\n];\n\nconst FILTER_INPUTS = ['filters', 'highlight', 'tabBy'] as ((keyof InputState['components'])[]);\n\nconst sortValues = (values: { value: string; label: string }[]) => values.sort((a, b) => a.label.localeCompare(b.label, 'en', { numeric: true }));\n\nconst OVERFLOW_LIMIT = 100;\nfunction addUniqueData(chartData: PlotDataAndSettings, resultMap: UniqueValuesBySourceMap, sourceId: string, maxGroupCount: number, labelId?: string) {\n const data = chartData!.data.byColumns.values[sourceId];\n const dataLabels = labelId ? chartData!.data.byColumns.values[labelId] : null;\n\n const resultSet = new Set();\n const result: { value: string; label: string }[] = [];\n for (let i = 0; i < data.length; i++) {\n const v = String(data[i]);\n if (resultSet.has(v)) {\n continue;\n }\n if (resultSet.size === maxGroupCount) {\n sortValues(result);\n resultMap[sourceId] = {\n list: result.map((el) => el.value),\n labels: result.reduce((res, el) => {\n res[el.value] = el.label;\n return res;\n }, {} as Record<string, string>),\n options: result,\n overflow: result.length > OVERFLOW_LIMIT,\n };\n return;\n }\n resultSet.add(v);\n const label = dataLabels ? String(dataLabels[i]) : v;\n result.push({ value: v, label });\n }\n sortValues(result);\n resultMap[sourceId] = {\n list: result.map((el) => el.value),\n labels: result.reduce((res, el) => {\n res[el.value] = el.label;\n return res;\n }, {} as Record<string, string>),\n options: result,\n overflow: result.length > OVERFLOW_LIMIT,\n };\n}\n\nexport async function getUniqueValuesFromReadyChartData(\n chartData: PlotDataAndSettings,\n inputGuide: InputGuide<InputState>,\n optionsState: InputState['components'],\n controller: Controller<InputState>,\n dataStore: DemoDataStore,\n previousFilterSuggestions: FilterSuggestionsBySourceMap,\n maxGroupCount = MAX_GROUPS_COUNT,\n): Promise<{ uniqueValues: UniqueValuesBySourceMap; filterSuggestions: FilterSuggestionsBySourceMap }> {\n const resultMap: UniqueValuesBySourceMap = {};\n\n if (chartData.settings.type === 'discrete') {\n SAVED_IN_CHART_DATA_DISCRETE_GROUPINGS.forEach((inputName: string) => {\n const savedData = chartData.settings[inputName] as unknown as DiscreteSettings['primaryGrouping'];\n if (savedData) {\n const { columnName } = savedData;\n addUniqueData(chartData, resultMap, columnName.value, maxGroupCount, columnName.valueLabels);\n }\n });\n }\n if (chartData.settings.type === 'scatterplot' || chartData.settings.type === 'scatterplot-umap') {\n SAVED_IN_CHART_DATA_SCATTERPLOT_XY.forEach((inputName: string) => {\n const columnName = chartData.settings[inputName] as unknown as ScatterplotSettings['x'];\n if (columnName) {\n const valueType = inputGuide.getSourceInfo(columnName.value).type;\n if (valueType === 'String') {\n addUniqueData(chartData, resultMap, columnName.value, maxGroupCount, columnName.valueLabels);\n }\n }\n });\n SAVED_IN_CHART_DATA_SCATTERPLOT_GROUPINGS.forEach((inputName: string) => {\n const savedInGrouping = chartData.settings[inputName] as unknown as ScatterplotSettings['grouping'];\n savedInGrouping?.forEach(({ columnName }) => {\n const valueType = inputGuide.getSourceInfo(columnName.value).type;\n if (valueType === 'String' || valueType === 'Int' || valueType === 'Long') {\n addUniqueData(chartData, resultMap, columnName.value, maxGroupCount, columnName.valueLabels);\n }\n });\n });\n }\n\n if (chartData.settings.type === 'histogram') {\n SAVED_IN_CHART_DATA_HISTOGRAM_GROUPING.forEach((inputName: string) => {\n const savedByInputName = chartData.settings[inputName] as unknown as HistogramSettings['grouping'];\n if (savedByInputName) {\n addUniqueData(chartData, resultMap, savedByInputName.value, maxGroupCount, savedByInputName.valueLabels);\n }\n });\n }\n\n if (chartData.settings.type === 'dendro') {\n SAVED_IN_CHART_DATA_DENDRO_GROUPING.forEach((inputName: string) => {\n const savedByInputName = chartData.settings[inputName] as unknown as DendroSettings['heatmapAnnotation'];\n if (savedByInputName) {\n addUniqueData(chartData, resultMap, savedByInputName.value, maxGroupCount, savedByInputName.valueLabels);\n }\n });\n }\n\n const filterSuggestionsMap: FilterSuggestionsBySourceMap = { ...previousFilterSuggestions };\n\n // sources for loading\n const selectedSources: string[] = [];\n ([...inputGuide.fullOptionsSet]).forEach((id) => {\n const info = inputGuide.getSourceInfo(id);\n if (info.kind === 'axis' && info.isNonHomogenous) {\n selectedSources.push(id);\n }\n });\n FILTER_INPUTS.forEach((inputName) => {\n const componentState = optionsState[inputName] as ComponentStateFilter;\n if (!componentState) {\n return;\n }\n for (const { selectedSource, type } of componentState.selectorStates as SelectorStateFilter[]) {\n if (((inputName === 'filters' || inputName === 'highlight') && type === 'equals') || inputName === 'tabBy') {\n selectedSources.push(selectedSource);\n }\n }\n });\n for (const source of selectedSources) {\n if (filterSuggestionsMap[source]) {\n continue;\n } else if (dataStore) {\n filterSuggestionsMap[source] = await controller.getUniqueSourceValuesWithLabels({ store: dataStore, inputGuide, selectedSource: source, limit: maxGroupCount });\n }\n }\n return { uniqueValues: resultMap, filterSuggestions: filterSuggestionsMap };\n}\n\n/** Build facet values map from facetBy columns in chart data, limited by maxFacetsCount (same shape as unique values). */\nexport function getFacetValuesFromReadyChartData(\n chartData: PlotDataAndSettings,\n optionsState: InputState['components'],\n maxSavedFacetsCount = 1000,\n): UniqueValuesBySourceMap {\n const resultMap: UniqueValuesBySourceMap = {};\n const facetBy = optionsState?.facetBy as { selectorStates: { selectedSource: string }[] } | undefined;\n if (!facetBy?.selectorStates?.length) {\n return resultMap;\n }\n const columns = chartData.data.byColumns.values;\n facetBy.selectorStates.forEach(({ selectedSource }) => {\n if (columns[selectedSource]) {\n addUniqueData(chartData, resultMap, selectedSource, maxSavedFacetsCount);\n }\n });\n return resultMap;\n}\n\nexport async function loadFilterLabelsForTitle(\n optionsState: InputState['components'],\n inputGuide: InputGuide<InputState>,\n controller: Controller<InputState>,\n dataStore: DemoDataStore,\n): Promise<FilterLabelsInfoBySourceMap> {\n const selected: [string, string[]][] = [];\n const INPUTS_REQUESTING_LABELS = ['filters', 'tabBy'] as ((keyof InputState['components'])[]);\n INPUTS_REQUESTING_LABELS.forEach((inputName) => {\n const componentState = optionsState[inputName];\n if (componentState) {\n for (const { selectedSource, selectedFilterValues, type } of componentState.selectorStates as SelectorStateFilter[]) {\n if (inputName === 'filters' && type === 'equals' && selectedFilterValues) {\n selected.push([selectedSource, selectedFilterValues]);\n } else if (selectedFilterValues) {\n selected.push([selectedSource, selectedFilterValues]);\n }\n }\n }\n });\n const result: FilterLabelsInfoBySourceMap = {};\n for (const [source, selectedValues] of selected) {\n const labels = await Promise.all(selectedValues.map((v) => controller.getLabelForValue({ store: dataStore, inputGuide, selectedSource: source, value: v })));\n labels.forEach((label, idx) => {\n if (!result[source]) {\n result[source] = {};\n }\n result[source][selectedValues[idx] as string] = { value: selectedValues[idx], label };\n });\n }\n return result;\n}\n"],"mappings":";AAaA,IAAM,IAAyC,CAAC,mBAAmB,oBAAoB,EACjF,IAA4C,CAAC,YAAY,WAAW,EACpE,IAAqC,CAAC,KAAK,IAAI,EAC/C,IAAyC,CAAC,WAAW,EACrD,IAAsC;CAC1C;CAAa;CAAa;CAAa;CACxC,EAEK,IAAgB;CAAC;CAAW;CAAa;CAAQ,EAEjD,KAAc,MAA+C,EAAO,MAAM,GAAG,MAAM,EAAE,MAAM,cAAc,EAAE,OAAO,MAAM,EAAE,SAAS,IAAM,CAAC,CAAC,EAE3I,IAAiB;AACvB,SAAS,EAAc,GAAgC,GAAoC,GAAkB,GAAuB,GAAkB;CACpJ,IAAM,IAAO,EAAW,KAAK,UAAU,OAAO,IACxC,IAAa,IAAU,EAAW,KAAK,UAAU,OAAO,KAAW,MAEnE,oBAAY,IAAI,KAAK,EACrB,IAA6C,EAAE;AACrD,MAAK,IAAI,IAAI,GAAG,IAAI,EAAK,QAAQ,KAAK;EACpC,IAAM,IAAI,OAAO,EAAK,GAAG;AACzB,MAAI,EAAU,IAAI,EAAE,CAClB;AAEF,MAAI,EAAU,SAAS,GAAe;AAEpC,GADA,EAAW,EAAO,EAClB,EAAU,KAAY;IACpB,MAAM,EAAO,KAAK,MAAO,EAAG,M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