@milaboratories/graph-maker 1.2.7 → 1.2.9
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 +30 -17
- 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/ui.d.ts +0 -1
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +1 -2
- package/dist/ui.vue2.js +1 -1
- package/dist/ui.vue2.js.map +1 -1
- package/dist/ui2.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/composeChartSettings.d.ts +5 -1
- package/dist/utils/createChartSettingsForRender/composeChartSettings.d.ts.map +1 -1
- package/dist/utils/createChartSettingsForRender/composeChartSettings.js +5 -1
- package/dist/utils/createChartSettingsForRender/composeChartSettings.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
- package/dist/GraphMakerPlugin.js +0 -5
- package/dist/GraphMakerPlugin.js.map +0 -1
- package/dist/GraphMakerPlugin.vue.d.ts +0 -37
- package/dist/GraphMakerPlugin.vue.d.ts.map +0 -1
- package/dist/GraphMakerPlugin.vue2.js +0 -61
- package/dist/GraphMakerPlugin.vue2.js.map +0 -1
package/dist/ui2.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui2.js","names":[],"sources":["../src/ui.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport './assets/ui.scss';\nimport type {\n ChartInterface,\n DataByColumns,\n ErrorInfo,\n LassoControlsState,\n Settings,\n} from '@milaboratories/miplots4';\nimport { MiPlots } from '@milaboratories/miplots4';\nimport type { ChartType, PlotDataAndSettings } from '@milaboratories/pf-plots';\nimport { DemoDataStore } from '@milaboratories/pf-plots';\nimport type { AxisSpec, PFrameDriver, PlSelectionModel, PTableKey } from '@platforma-sdk/model';\nimport { watchDebounced } from '@vueuse/core';\nimport { computed, onMounted, onUnmounted, ref, shallowRef, toRaw, useSlots, watch } from 'vue';\nimport Chart from './components/Chart.vue';\nimport PanelModal from './components/PanelModal.vue';\nimport VTabs from './components/SettingsTabs/index.vue';\nimport TransitionSlidePanel from './components/TransitionSlidePanel.vue';\nimport ChartErrorNotificationAlert from './components/ChartErrorNotificationAlert.vue';\nimport ChartTruncationWarningAlert from './components/ChartTruncationWarningAlert.vue';\nimport { isOwnGraphMakerTab, useSettingsForm } from './forms';\nimport { createReactiveState, provideStore } from './store';\nimport type { DendroNodeInfo, GraphMakerProps, GraphMakerState, GraphStatus } from './types';\nimport { composeChartSettings, saveToFile } from './utils';\nimport type { ChartTruncationWarning } from './utils/createChartSettingsForRender/composeChartSettings';\nimport { copyJSON } from './utils/copyJSON';\nimport GraphStatusScreen from './components/GraphStatusScreen.vue';\n\nconst _emit = defineEmits(['delete-this-graph', 'tooltip-btn-click']);\n\nconst graphMakerState = defineModel<GraphMakerState>({ required: true });\nconst selectionState = defineModel<PlSelectionModel>('selection');\n\nconst props = defineProps<GraphMakerProps>();\n\ndefineExpose({\n /**\n reset() will update data-mapping, axis-settings, layers-settings with the state that is in v-model at the moment.\n In other cases editing of v-model fields doesn't make any impact to graphs and interface.\n */\n reset,\n});\n\nconst dataStore = ref<DemoDataStore | null>(null);\n\nwatch(() => props.pFrame, (pframe) => {\n if (!pframe.ok || !pframe.value) {\n dataStore.value = null;\n return;\n }\n const driver = ('platforma' in window) ? window.platforma?.pFrameDriver as PFrameDriver : props.driver;\n if (!driver) {\n throw new Error('PFrame driver is missing');\n }\n dataStore.value = new DemoDataStore(\n pframe.value,\n driver,\n props.labelsModifier,\n );\n}, { immediate: true, deep: true });\n\n// fixed options can be updated outside, other settings only inside from chart settings interface, so we don't watching other settings\nconst fixedOptions = ref<typeof props.fixedOptions>(props.fixedOptions ?? []);\nwatch(() => props.fixedOptions, (value, oldValue) => {\n if (\n (value && oldValue && JSON.stringify(value) !== JSON.stringify(oldValue))\n || (value && !oldValue)\n || (oldValue && !value)\n ) {\n fixedOptions.value = value;\n }\n}, { deep: true });\nconst defaultOptions = ref<typeof props.defaultOptions>(props.defaultOptions);\nwatch(() => props.defaultOptions, (v) => {\n defaultOptions.value = v;\n}, { deep: true });\nconst state = provideStore(\n toRaw(graphMakerState.value),\n dataStore,\n props.chartType,\n defaultOptions,\n fixedOptions,\n props.dataColumnPredicate,\n props.metaColumnPredicate,\n props.readonlyInputs,\n props.defaultPalette,\n);\n\nfunction reset() {\n const nextReactiveState = createReactiveState(\n toRaw(graphMakerState.value),\n props.chartType,\n );\n Object.assign(state.value.reactive, nextReactiveState);\n Object.assign(state.value.loading, {\n initialInputGuide: true,\n initialCharts: true,\n initialDefaults: true,\n inputGuide: false,\n chartData: false,\n });\n defaultOptions.value = props.defaultOptions;\n}\n\nconst currentForm = computed(() => useSettingsForm(state.value.reactive.currentTab));\n\nconst chartRef = shallowRef<ChartInterface | null>(null);\nconst chartCalculatedDataRef = ref<Record<string, unknown> | null>(null);\nconst chartError = ref(false);\nconst chartErrorInfo = ref<ErrorInfo | null>(null);\n\nconst isRunning = computed(\n () => props.pFrame.ok && !props.pFrame.value && !props.pFrame.stable,\n);\nconst isInitialLoading = computed(\n () => state.value.loading.initialInputGuide && graphStatus.value === 'loading',\n);\n\nwatch(() => isRunning.value, (val, prevVal) => {\n if (val && !prevVal) {\n state.value.reactive.currentTab = null;\n }\n});\n\nconst graphStatus = computed<GraphStatus>((previousStatus) => {\n if (isRunning.value) {\n return 'running';\n }\n if (props.pFrame.ok && props.pFrame.stable && !props.pFrame.value) {\n return 'noPframe';\n }\n if (!props.pFrame.ok) {\n return 'noPframeWithError';\n }\n const inputGuide = state.value.inputGuide.value;\n const chartData = state.value.chartData.value;\n if (!inputGuide.consistent) {\n return 'inconsistent';\n }\n if (!inputGuide.ready) {\n return defaultOptions.value === null\n || state.value.loading.defaults\n || state.value.loading.initialInputGuide\n ? 'loading'\n : 'notReady';\n }\n if (chartData && Object.values(chartData.data.byColumns.values)[0]?.length === 0) {\n return 'empty';\n }\n if (chartError.value) {\n return chartErrorInfo.value?.type === 'unknownError' ? 'unknownError' : 'knownError';\n }\n if (\n (state.value.loading.initialCharts || (previousStatus !== 'ready' && state.value.loading.chartData) || state.value.loading.chartRendering)\n || (chartRef.value === null && (state.value.loading.inputGuide || state.value.loading.chartData))\n ) {\n return 'loading';\n }\n return 'ready';\n});\n\nfunction onTreeNodeClick(d: DendroNodeInfo) {\n state.value.reactive.dendroSelectedNodeId = d?.info[0]?.id as number;\n state.value.reactive.dendroInfoByClick = d;\n}\n\nconst tooltipHintHideTimerRef = ref<ReturnType<typeof setTimeout> | null>(null);\n\nfunction onTooltipHintSwitch(v: boolean) {\n const reactive = state.value.reactive;\n if (v) {\n if (reactive.tooltipHintWasShown) return;\n if (tooltipHintHideTimerRef.value) {\n clearTimeout(tooltipHintHideTimerRef.value);\n tooltipHintHideTimerRef.value = null;\n }\n reactive.showTooltipHint = true;\n tooltipHintHideTimerRef.value = setTimeout(() => {\n reactive.showTooltipHint = false;\n reactive.tooltipHintWasShown = true;\n tooltipHintHideTimerRef.value = null;\n }, 3000);\n } else {\n reactive.showTooltipHint = false;\n }\n}\n\nfunction onLassoPolygonUpdate(dotIndexes: number[], polygons: { points: [number, number][]; closed: boolean }[]) {\n graphMakerState.value = {\n ...graphMakerState.value,\n selectedPolygons: polygons,\n };\n\n const axesData = state.value.chartData.value?.data?.axesData;\n if (dotIndexes.length === 0 || !axesData) {\n selectionState.value = { axesSpec: [], selectedKeys: [] };\n return;\n }\n\n const axisKeys = Object.keys(axesData);\n const inputGuide = state.value.inputGuide.value;\n selectionState.value = {\n axesSpec: axisKeys.map((axisKey) => inputGuide.getSourceInfo(axisKey).spec as AxisSpec),\n selectedKeys: dotIndexes.map((idx) => axisKeys.map((axisKey) => axesData[axisKey][idx]) as PTableKey),\n };\n}\n\nfunction onLassoStateChange(v: LassoControlsState) {\n state.value.reactive.lassoControlsState = v;\n}\nlet chartRenderingInProgress: ReturnType<typeof setTimeout> | null = null;\nfunction onLoadingStateChange(v: boolean) {\n if (v) {\n chartRenderingInProgress = setTimeout(() => {\n state.value.loading.chartRendering = true;\n }, 1000);\n } else {\n if (chartRenderingInProgress) {\n clearTimeout(chartRenderingInProgress);\n }\n state.value.loading.chartRendering = false;\n }\n}\nconst isScatterplotZoomChanged = ref(false);\nfunction onZoomChange(isZoomChanged: boolean) {\n isScatterplotZoomChanged.value = isZoomChanged;\n}\nconst graphEventHandlers: Record<ChartType, unknown> = {\n 'dendro': [onTreeNodeClick],\n 'scatterplot-umap': {\n onPolygonUpdate: onLassoPolygonUpdate,\n onTooltipHintSwitch,\n onLassoControlsStateUpdate: onLassoStateChange,\n onZoomChange,\n },\n 'discrete': [onTooltipHintSwitch],\n 'scatterplot': {\n onPolygonUpdate: onLassoPolygonUpdate,\n onTooltipHintSwitch,\n onLassoControlsStateUpdate: onLassoStateChange,\n },\n 'histogram': [onTooltipHintSwitch],\n 'heatmap': { onTooltipHintSwitch, onLoadingChange: onLoadingStateChange },\n 'bubble': [onTooltipHintSwitch],\n};\nfunction updateChart(value: { data: PlotDataAndSettings['data']['byColumns']; settings: PlotDataAndSettings['settings'] } | null) {\n // if dataByColumns exists but columns has no data - show empty chart\n if (value && Object.values(value.data.values)[0]?.length > 0) {\n // console.log('value.dataByColumns', toRaw(value.data));\n // console.log('value.settings', toRaw(value.settings));\n if (chartRef.value) {\n chartRef.value.updateSettingsAndData({ ...toRaw(value.data), id: value.data.id + (props.pFrame.ok ? props.pFrame.value : '') }, toRaw(value.settings) as Settings);\n } else {\n const htmlNode = document.getElementById('chartSvgContainer');\n if (htmlNode) {\n chartRef.value = MiPlots.newPlot(toRaw(value.data), toRaw(value.settings) as Settings, graphEventHandlers[value.settings.type as ChartType]);\n if (value.settings.type === 'scatterplot-umap') {\n // set default polygons (from props)\n chartRef.value.updateChartState('polygon', graphMakerState.value.selectedPolygons ?? []);\n }\n chartRef.value.mount(htmlNode);\n }\n }\n // calculated by chart renderer data, tree hierarchy for example\n chartCalculatedDataRef.value = chartRef.value?.calculatedData ? { ...chartRef.value.calculatedData } : null;\n chartError.value = chartRef.value?.hasError ?? false;\n chartErrorInfo.value = chartRef.value?.errorInfo ?? null;\n } else {\n chartRef.value?.unmount();\n chartRef.value = null;\n chartErrorInfo.value = null;\n }\n}\n\nwatch(() => graphStatus.value, (v) => {\n if (v === 'notReady' || v === 'noPframe' || dataStore.value === null) {\n chartRef.value?.unmount();\n chartRef.value = null;\n }\n});\n\nconst chartDataForRender = shallowRef<{ settings: Settings; data: DataByColumns } | null>(null);\nconst chartTruncationWarning = ref<ChartTruncationWarning | null>(null);\n\nfunction applyComposeResult(result: ReturnType<typeof composeChartSettings>) {\n if (!result) {\n chartDataForRender.value = null;\n chartTruncationWarning.value = null;\n return;\n }\n chartDataForRender.value = { settings: result.settings, data: result.data };\n chartTruncationWarning.value = result.truncationWarning;\n}\n\nwatch([\n () => state.value.chartData.value,\n], ([chartData]) => {\n applyComposeResult(composeChartSettings(\n toRaw(chartData),\n toRaw(state.value.inputGuide.value),\n toRaw(state.value.uniqueValuesData.value),\n toRaw(state.value.filterLabelsInfo.value),\n toRaw(state.value.reactive),\n toRaw(state.value.defaultPalette),\n toRaw(state.value.facetValuesData.value),\n ));\n});\nwatch([\n () => state.value.reactive.template,\n () => state.value.reactive.layersSettings,\n () => state.value.reactive.axesSettings,\n () => state.value.reactive.statisticsSettings,\n () => state.value.reactive.dataBindAes,\n () => state.value.reactive.chartScale,\n], () => {\n applyComposeResult(composeChartSettings(\n toRaw(state.value.chartData.value),\n toRaw(state.value.inputGuide.value),\n toRaw(state.value.uniqueValuesData.value),\n toRaw(state.value.filterLabelsInfo.value),\n toRaw(state.value.reactive),\n toRaw(state.value.defaultPalette),\n toRaw(state.value.facetValuesData.value),\n ));\n}, { deep: true });\n\nwatch(() => chartDataForRender.value, (chartData) => {\n updateChart(chartData);\n});\nonMounted(() => {\n updateChart(null);\n});\nonUnmounted(() => {\n if (tooltipHintHideTimerRef.value) {\n clearTimeout(tooltipHintHideTimerRef.value);\n tooltipHintHideTimerRef.value = null;\n }\n chartRef.value?.unmount();\n});\n\nwatchDebounced(() => state.value.reactive.optionsState, (v) => {\n graphMakerState.value = {\n ...graphMakerState.value,\n optionsState: copyJSON(v),\n };\n}, { deep: true, debounce: 1000 });\nwatchDebounced(() => state.value.reactive.usedDefaultOptions, (v) => {\n graphMakerState.value = {\n ...graphMakerState.value,\n usedDefaultOptions: copyJSON(v),\n };\n}, { deep: true, debounce: 1000 });\nwatchDebounced(() => state.value.reactive.statisticsSettings, (v) => {\n graphMakerState.value = {\n ...graphMakerState.value,\n statisticsSettings: copyJSON(v),\n };\n}, { deep: true, debounce: 1000 });\nwatchDebounced(() => state.value.reactive.axesSettings, (v) => {\n graphMakerState.value = {\n ...graphMakerState.value,\n axesSettings: copyJSON(v),\n };\n}, { deep: true, debounce: 1000 });\nwatchDebounced(() => state.value.reactive.layersSettings, (v) => {\n graphMakerState.value = {\n ...graphMakerState.value,\n layersSettings: copyJSON(v),\n };\n}, { deep: true, debounce: 1000 });\nwatchDebounced(() => state.value.reactive.dataBindAes, (v) => {\n graphMakerState.value = {\n ...graphMakerState.value,\n dataBindAes: copyJSON(v),\n };\n}, { deep: true, debounce: 1000 });\n\nwatchDebounced([\n () => state.value.reactive.chartScale,\n () => state.value.reactive.template,\n () => state.value.reactive.currentTab,\n], ([zoomState, template, currentTab]) => {\n graphMakerState.value = {\n ...graphMakerState.value,\n zoomState,\n template,\n currentTab,\n };\n}, { debounce: 1000 });\n\nwatch(() => state.value.reactive.tooltipHintWasShown, (v) => {\n if (v) {\n graphMakerState.value = { ...graphMakerState.value, tooltipHintWasShown: true };\n }\n});\n\nwatch(() => graphMakerState.value.currentTab, (v) => {\n state.value.reactive.currentTab = v === undefined ? 'dataMapping' : v;\n});\n\nwatch(() => graphMakerState.value?.layersSettings?.dendro?.showTable, (v) => {\n state.value.reactive.layersSettings.dendro.showTable = v ?? false;\n});\n\nfunction onExport() {\n saveToFile(\n new Blob([\n chartRef.value?.export() ?? '',\n ]),\n 'chart.svg',\n );\n}\n\nfunction updateGraphTitle(nextTitle: string) {\n graphMakerState.value = {\n ...graphMakerState.value,\n title: nextTitle,\n };\n}\n\nfunction selectTreeNode(id: number | null) {\n state.value.reactive.dendroSelectedNodeId = id;\n chartRef.value?.updateChartState('selectedNode', id);\n}\n\nconst slots = useSlots();\n\nconst hasAnnotationsSlot = computed(() => Boolean(slots.annotationsSlot));\nconst hasSettingsSlot = computed(() => Boolean(slots.settingsSlot));\nconst hasLogSlot = computed(() => Boolean(slots.logSlot));\n\n</script>\n\n<template>\n <div class=\"graph-maker\">\n <div class=\"graph-maker__main-pane\">\n <Chart\n :graph-status=\"graphStatus\" :graphTitle=\"graphMakerState.title\" :chartData=\"chartCalculatedDataRef\"\n :chart-ref=\"chartRef\" :error-info=\"chartErrorInfo\" :dendroTooltipButton=\"tooltipButton\"\n :custom-status-text=\"statusText\"\n :allow-title-editing=\"allowTitleEditing\"\n :isScatterplotZoomChanged=\"isScatterplotZoomChanged\"\n @graph-title-update=\"updateGraphTitle\" @dendro-node-select=\"selectTreeNode\"\n @dendro-tooltip-btn-click=\"(id: string) => $emit('tooltip-btn-click', id)\"\n >\n <slot name=\"titleLineSlot\" />\n </Chart>\n <GraphStatusScreen v-if=\"isInitialLoading || isRunning\" :graphStatus=\"isRunning ? 'running' : 'loading'\" :top=\"67\" :left=\"12\" :right=\"12\" :bottom=\"12\" :customStatusText=\"statusText\" />\n <TransitionSlidePanel id=\"graph-settings-modal\">\n <PanelModal\n v-if=\"state.reactive.currentTab && !((isInitialLoading || isRunning) && isOwnGraphMakerTab(state.reactive.currentTab))\"\n @close=\"state.reactive.currentTab = null\"\n >\n <component :is=\"currentForm.value\">\n <slot v-if=\"state.reactive.currentTab === 'annotations'\" name=\"annotationsSlot\" />\n <slot v-if=\"state.reactive.currentTab === 'settings'\" name=\"settingsSlot\" />\n <slot v-if=\"state.reactive.currentTab === 'log'\" name=\"logSlot\" />\n </component>\n </PanelModal>\n </TransitionSlidePanel>\n </div>\n <VTabs\n v-model=\"state.reactive.currentTab\" :chart-type=\"state.reactive.chartType\" :graph-status=\"graphStatus\"\n :allowDeleting=\"allowChartDeleting\" :hasAnnotationsSlot=\"hasAnnotationsSlot\" :hasSettingsSlot=\"hasSettingsSlot\"\n :hasLogSlot=\"hasLogSlot\" :initialLoading=\"isInitialLoading || isRunning\" @export=\"onExport\"\n @delete=\"$emit('delete-this-graph')\"\n />\n <ChartErrorNotificationAlert v-if=\"chartErrorInfo?.type === 'unknownError'\" :errorInfo=\"chartErrorInfo\" />\n <ChartTruncationWarningAlert\n v-if=\"chartTruncationWarning && (chartTruncationWarning.groups || chartTruncationWarning.facets)\"\n :truncation-warning=\"chartTruncationWarning\"\n />\n </div>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ui2.js","names":[],"sources":["../src/ui.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport './assets/ui.scss';\nimport type {\n ChartInterface,\n DataByColumns,\n ErrorInfo,\n LassoControlsState,\n Settings,\n} from '@milaboratories/miplots4';\nimport { MiPlots } from '@milaboratories/miplots4';\nimport type { ChartType, PlotDataAndSettings } from '@milaboratories/pf-plots';\nimport { DemoDataStore } from '@milaboratories/pf-plots';\nimport type { AxisSpec, PFrameDriver, PlSelectionModel, PTableKey } from '@platforma-sdk/model';\nimport { watchDebounced } from '@vueuse/core';\nimport { computed, onMounted, onUnmounted, ref, shallowRef, toRaw, useSlots, watch } from 'vue';\nimport Chart from './components/Chart.vue';\nimport PanelModal from './components/PanelModal.vue';\nimport VTabs from './components/SettingsTabs/index.vue';\nimport TransitionSlidePanel from './components/TransitionSlidePanel.vue';\nimport ChartErrorNotificationAlert from './components/ChartErrorNotificationAlert.vue';\nimport ChartTruncationWarningAlert from './components/ChartTruncationWarningAlert.vue';\nimport { isOwnGraphMakerTab, useSettingsForm } from './forms';\nimport { createReactiveState, provideStore } from './store';\nimport type { DendroNodeInfo, GraphMakerProps, GraphMakerState, GraphStatus } from './types';\nimport { composeChartSettings, saveToFile } from './utils';\nimport type { ChartTruncationWarning } from './utils/createChartSettingsForRender/composeChartSettings';\nimport { copyJSON } from './utils/copyJSON';\nimport GraphStatusScreen from './components/GraphStatusScreen.vue';\n\nconst _emit = defineEmits(['delete-this-graph', 'tooltip-btn-click']);\n\nconst graphMakerState = defineModel<GraphMakerState>({ required: true });\nconst selectionState = defineModel<PlSelectionModel>('selection');\n\nconst props = defineProps<GraphMakerProps>();\n\ndefineExpose({\n /**\n reset() will update data-mapping, axis-settings, layers-settings with the state that is in v-model at the moment.\n In other cases editing of v-model fields doesn't make any impact to graphs and interface.\n */\n reset,\n});\n\nconst dataStore = ref<DemoDataStore | null>(null);\n\nwatch(() => props.pFrame, (pframe) => {\n if (!pframe.ok || !pframe.value) {\n dataStore.value = null;\n return;\n }\n const driver = ('platforma' in window) ? window.platforma?.pFrameDriver as PFrameDriver : props.driver;\n if (!driver) {\n throw new Error('PFrame driver is missing');\n }\n dataStore.value = new DemoDataStore(\n pframe.value,\n driver,\n props.labelsModifier,\n );\n}, { immediate: true, deep: true });\n\n// fixed options can be updated outside, other settings only inside from chart settings interface, so we don't watching other settings\nconst fixedOptions = ref<typeof props.fixedOptions>(props.fixedOptions ?? []);\nwatch(() => props.fixedOptions, (value, oldValue) => {\n if (\n (value && oldValue && JSON.stringify(value) !== JSON.stringify(oldValue))\n || (value && !oldValue)\n || (oldValue && !value)\n ) {\n fixedOptions.value = value;\n }\n}, { deep: true });\nconst defaultOptions = ref<typeof props.defaultOptions>(props.defaultOptions);\nwatch(() => props.defaultOptions, (v) => {\n defaultOptions.value = v;\n}, { deep: true });\nconst state = provideStore(\n toRaw(graphMakerState.value),\n dataStore,\n props.chartType,\n defaultOptions,\n fixedOptions,\n props.dataColumnPredicate,\n props.metaColumnPredicate,\n props.readonlyInputs,\n props.defaultPalette,\n);\n\nfunction reset() {\n const nextReactiveState = createReactiveState(\n toRaw(graphMakerState.value),\n props.chartType,\n );\n Object.assign(state.value.reactive, nextReactiveState);\n Object.assign(state.value.loading, {\n initialInputGuide: true,\n initialCharts: true,\n initialDefaults: true,\n inputGuide: false,\n chartData: false,\n });\n defaultOptions.value = props.defaultOptions;\n}\n\nconst currentForm = computed(() => useSettingsForm(state.value.reactive.currentTab));\n\nconst chartRef = shallowRef<ChartInterface | null>(null);\nconst chartCalculatedDataRef = ref<Record<string, unknown> | null>(null);\nconst chartError = ref(false);\nconst chartErrorInfo = ref<ErrorInfo | null>(null);\n\nconst isRunning = computed(\n () => props.pFrame.ok && !props.pFrame.value && !props.pFrame.stable,\n);\nconst isInitialLoading = computed(\n () => state.value.loading.initialInputGuide && graphStatus.value === 'loading',\n);\n\nwatch(() => isRunning.value, (val, prevVal) => {\n if (val && !prevVal) {\n state.value.reactive.currentTab = null;\n }\n});\n\nconst graphStatus = computed<GraphStatus>((previousStatus) => {\n if (isRunning.value) {\n return 'running';\n }\n if (props.pFrame.ok && props.pFrame.stable && !props.pFrame.value) {\n return 'noPframe';\n }\n if (!props.pFrame.ok) {\n return 'noPframeWithError';\n }\n const inputGuide = state.value.inputGuide.value;\n const chartData = state.value.chartData.value;\n if (!inputGuide.consistent) {\n return 'inconsistent';\n }\n if (!inputGuide.ready) {\n return defaultOptions.value === null\n || state.value.loading.defaults\n || state.value.loading.initialInputGuide\n ? 'loading'\n : 'notReady';\n }\n if (chartData && Object.values(chartData.data.byColumns.values)[0]?.length === 0) {\n return 'empty';\n }\n if (chartError.value) {\n return chartErrorInfo.value?.type === 'unknownError' ? 'unknownError' : 'knownError';\n }\n if (\n (state.value.loading.initialCharts || (previousStatus !== 'ready' && state.value.loading.chartData) || state.value.loading.chartRendering)\n || (chartRef.value === null && (state.value.loading.inputGuide || state.value.loading.chartData))\n ) {\n return 'loading';\n }\n return 'ready';\n});\n\nfunction onTreeNodeClick(d: DendroNodeInfo) {\n state.value.reactive.dendroSelectedNodeId = d?.info[0]?.id as number;\n state.value.reactive.dendroInfoByClick = d;\n}\n\nconst tooltipHintHideTimerRef = ref<ReturnType<typeof setTimeout> | null>(null);\n\nfunction onTooltipHintSwitch(v: boolean) {\n const reactive = state.value.reactive;\n if (v) {\n if (reactive.tooltipHintWasShown) return;\n if (tooltipHintHideTimerRef.value) {\n clearTimeout(tooltipHintHideTimerRef.value);\n tooltipHintHideTimerRef.value = null;\n }\n reactive.showTooltipHint = true;\n tooltipHintHideTimerRef.value = setTimeout(() => {\n reactive.showTooltipHint = false;\n reactive.tooltipHintWasShown = true;\n tooltipHintHideTimerRef.value = null;\n }, 3000);\n } else {\n reactive.showTooltipHint = false;\n }\n}\n\nfunction onLassoPolygonUpdate(dotIndexes: number[], polygons: { points: [number, number][]; closed: boolean }[]) {\n graphMakerState.value = {\n ...graphMakerState.value,\n selectedPolygons: polygons,\n };\n\n const axesData = state.value.chartData.value?.data?.axesData;\n if (dotIndexes.length === 0 || !axesData) {\n selectionState.value = { axesSpec: [], selectedKeys: [] };\n return;\n }\n\n const axisKeys = Object.keys(axesData);\n const inputGuide = state.value.inputGuide.value;\n selectionState.value = {\n axesSpec: axisKeys.map((axisKey) => inputGuide.getSourceInfo(axisKey).spec as AxisSpec),\n selectedKeys: dotIndexes.map((idx) => axisKeys.map((axisKey) => axesData[axisKey][idx]) as PTableKey),\n };\n}\n\nfunction onLassoStateChange(v: LassoControlsState) {\n state.value.reactive.lassoControlsState = v;\n}\nlet chartRenderingInProgress: ReturnType<typeof setTimeout> | null = null;\nfunction onLoadingStateChange(v: boolean) {\n if (v) {\n chartRenderingInProgress = setTimeout(() => {\n state.value.loading.chartRendering = true;\n }, 1000);\n } else {\n if (chartRenderingInProgress) {\n clearTimeout(chartRenderingInProgress);\n }\n state.value.loading.chartRendering = false;\n }\n}\nconst isScatterplotZoomChanged = ref(false);\nfunction onZoomChange(isZoomChanged: boolean) {\n isScatterplotZoomChanged.value = isZoomChanged;\n}\nconst graphEventHandlers: Record<ChartType, unknown> = {\n 'dendro': [onTreeNodeClick],\n 'scatterplot-umap': {\n onPolygonUpdate: onLassoPolygonUpdate,\n onTooltipHintSwitch,\n onLassoControlsStateUpdate: onLassoStateChange,\n onZoomChange,\n },\n 'discrete': [onTooltipHintSwitch],\n 'scatterplot': {\n onPolygonUpdate: onLassoPolygonUpdate,\n onTooltipHintSwitch,\n onLassoControlsStateUpdate: onLassoStateChange,\n },\n 'histogram': [onTooltipHintSwitch],\n 'heatmap': { onTooltipHintSwitch, onLoadingChange: onLoadingStateChange },\n 'bubble': [onTooltipHintSwitch],\n};\nfunction updateChart(value: { data: PlotDataAndSettings['data']['byColumns']; settings: PlotDataAndSettings['settings'] } | null) {\n // if dataByColumns exists but columns has no data - show empty chart\n if (value && Object.values(value.data.values)[0]?.length > 0) {\n // console.log('value.dataByColumns', toRaw(value.data));\n // console.log('value.settings', toRaw(value.settings));\n if (chartRef.value) {\n chartRef.value.updateSettingsAndData({ ...toRaw(value.data), id: value.data.id + (props.pFrame.ok ? props.pFrame.value : '') }, toRaw(value.settings) as Settings);\n } else {\n const htmlNode = document.getElementById('chartSvgContainer');\n if (htmlNode) {\n chartRef.value = MiPlots.newPlot(toRaw(value.data), toRaw(value.settings) as Settings, graphEventHandlers[value.settings.type as ChartType]);\n if (value.settings.type === 'scatterplot-umap') {\n // set default polygons (from props)\n chartRef.value.updateChartState('polygon', graphMakerState.value.selectedPolygons ?? []);\n }\n chartRef.value.mount(htmlNode);\n }\n }\n // calculated by chart renderer data, tree hierarchy for example\n chartCalculatedDataRef.value = chartRef.value?.calculatedData ? { ...chartRef.value.calculatedData } : null;\n chartError.value = chartRef.value?.hasError ?? false;\n chartErrorInfo.value = chartRef.value?.errorInfo ?? null;\n } else {\n chartRef.value?.unmount();\n chartRef.value = null;\n chartErrorInfo.value = null;\n }\n}\n\nwatch(() => graphStatus.value, (v) => {\n if (v === 'notReady' || v === 'noPframe' || dataStore.value === null) {\n chartRef.value?.unmount();\n chartRef.value = null;\n }\n});\n\nconst chartDataForRender = shallowRef<{ settings: Settings; data: DataByColumns } | null>(null);\nconst chartTruncationWarning = ref<ChartTruncationWarning | null>(null);\n\nfunction applyComposeResult(result: ReturnType<typeof composeChartSettings>) {\n if (!result) {\n chartDataForRender.value = null;\n chartTruncationWarning.value = null;\n return;\n }\n chartDataForRender.value = { settings: result.settings, data: result.data };\n chartTruncationWarning.value = result.truncationWarning;\n}\n\nwatch([\n () => state.value.chartData.value,\n], ([chartData]) => {\n applyComposeResult(composeChartSettings(\n toRaw(chartData),\n toRaw(state.value.inputGuide.value),\n toRaw(state.value.uniqueValuesData.value),\n toRaw(state.value.filterLabelsInfo.value),\n toRaw(state.value.reactive),\n toRaw(state.value.defaultPalette),\n toRaw(state.value.facetValuesData.value),\n ));\n});\nwatch([\n () => state.value.reactive.template,\n () => state.value.reactive.layersSettings,\n () => state.value.reactive.axesSettings,\n () => state.value.reactive.statisticsSettings,\n () => state.value.reactive.dataBindAes,\n () => state.value.reactive.chartScale,\n], () => {\n applyComposeResult(composeChartSettings(\n toRaw(state.value.chartData.value),\n toRaw(state.value.inputGuide.value),\n toRaw(state.value.uniqueValuesData.value),\n toRaw(state.value.filterLabelsInfo.value),\n toRaw(state.value.reactive),\n toRaw(state.value.defaultPalette),\n toRaw(state.value.facetValuesData.value),\n ));\n}, { deep: true });\n\nwatch(() => chartDataForRender.value, (chartData) => {\n updateChart(chartData);\n});\nonMounted(() => {\n updateChart(null);\n});\nonUnmounted(() => {\n if (tooltipHintHideTimerRef.value) {\n clearTimeout(tooltipHintHideTimerRef.value);\n tooltipHintHideTimerRef.value = null;\n }\n chartRef.value?.unmount();\n});\n\nwatchDebounced(() => state.value.reactive.optionsState, (v) => {\n graphMakerState.value = {\n ...graphMakerState.value,\n optionsState: copyJSON(v),\n };\n}, { deep: true, debounce: 1000 });\nwatchDebounced(() => state.value.reactive.usedDefaultOptions, (v) => {\n graphMakerState.value = {\n ...graphMakerState.value,\n usedDefaultOptions: copyJSON(v),\n };\n}, { deep: true, debounce: 1000 });\nwatchDebounced(() => state.value.reactive.statisticsSettings, (v) => {\n graphMakerState.value = {\n ...graphMakerState.value,\n statisticsSettings: copyJSON(v),\n };\n}, { deep: true, debounce: 1000 });\nwatchDebounced(() => state.value.reactive.axesSettings, (v) => {\n graphMakerState.value = {\n ...graphMakerState.value,\n axesSettings: copyJSON(v),\n };\n}, { deep: true, debounce: 1000 });\nwatchDebounced(() => state.value.reactive.layersSettings, (v) => {\n graphMakerState.value = {\n ...graphMakerState.value,\n layersSettings: copyJSON(v),\n };\n}, { deep: true, debounce: 1000 });\nwatchDebounced(() => state.value.reactive.dataBindAes, (v) => {\n graphMakerState.value = {\n ...graphMakerState.value,\n dataBindAes: copyJSON(v),\n };\n}, { deep: true, debounce: 1000 });\n\nwatchDebounced([\n () => state.value.reactive.chartScale,\n () => state.value.reactive.template,\n () => state.value.reactive.currentTab,\n], ([zoomState, template, currentTab]) => {\n graphMakerState.value = {\n ...graphMakerState.value,\n zoomState,\n template,\n currentTab,\n };\n}, { debounce: 1000 });\n\nwatch(() => state.value.reactive.tooltipHintWasShown, (v) => {\n if (v) {\n graphMakerState.value = { ...graphMakerState.value, tooltipHintWasShown: true };\n }\n});\n\nwatch(() => graphMakerState.value.currentTab, (v) => {\n state.value.reactive.currentTab = v === undefined ? 'dataMapping' : v;\n});\n\nwatch(() => graphMakerState.value?.layersSettings?.dendro?.showTable, (v) => {\n state.value.reactive.layersSettings.dendro.showTable = v ?? false;\n});\n\nfunction onExport() {\n saveToFile(\n new Blob([\n chartRef.value?.export() ?? '',\n ]),\n 'chart.svg',\n );\n}\n\nfunction updateGraphTitle(nextTitle: string) {\n graphMakerState.value = {\n ...graphMakerState.value,\n title: nextTitle,\n };\n}\n\nfunction selectTreeNode(id: number | null) {\n state.value.reactive.dendroSelectedNodeId = id;\n chartRef.value?.updateChartState('selectedNode', id);\n}\n\nconst slots = useSlots();\n\nconst hasAnnotationsSlot = computed(() => Boolean(slots.annotationsSlot));\nconst hasSettingsSlot = computed(() => Boolean(slots.settingsSlot));\nconst hasLogSlot = computed(() => Boolean(slots.logSlot));\n\n</script>\n\n<template>\n <div class=\"graph-maker\">\n <div class=\"graph-maker__main-pane\">\n <Chart\n :graph-status=\"graphStatus\" :graphTitle=\"graphMakerState.title\" :chartData=\"chartCalculatedDataRef\"\n :chart-ref=\"chartRef\" :error-info=\"chartErrorInfo\" :dendroTooltipButton=\"tooltipButton\"\n :custom-status-text=\"statusText\"\n :allow-title-editing=\"allowTitleEditing\"\n :isScatterplotZoomChanged=\"isScatterplotZoomChanged\"\n @graph-title-update=\"updateGraphTitle\" @dendro-node-select=\"selectTreeNode\"\n @dendro-tooltip-btn-click=\"(id: string) => $emit('tooltip-btn-click', id)\"\n >\n <slot name=\"titleLineSlot\" />\n </Chart>\n <GraphStatusScreen v-if=\"isInitialLoading || isRunning\" :graphStatus=\"isRunning ? 'running' : 'loading'\" :top=\"67\" :left=\"12\" :right=\"12\" :bottom=\"12\" :customStatusText=\"statusText\" />\n <TransitionSlidePanel id=\"graph-settings-modal\">\n <PanelModal\n v-if=\"state.reactive.currentTab && !((isInitialLoading || isRunning) && isOwnGraphMakerTab(state.reactive.currentTab))\"\n @close=\"state.reactive.currentTab = null\"\n >\n <component :is=\"currentForm.value\">\n <slot v-if=\"state.reactive.currentTab === 'annotations'\" name=\"annotationsSlot\" />\n <slot v-if=\"state.reactive.currentTab === 'settings'\" name=\"settingsSlot\" />\n <slot v-if=\"state.reactive.currentTab === 'log'\" name=\"logSlot\" />\n </component>\n </PanelModal>\n </TransitionSlidePanel>\n </div>\n <VTabs\n v-model=\"state.reactive.currentTab\" :chart-type=\"state.reactive.chartType\" :graph-status=\"graphStatus\"\n :allowDeleting=\"allowChartDeleting\" :hasAnnotationsSlot=\"hasAnnotationsSlot\" :hasSettingsSlot=\"hasSettingsSlot\"\n :hasLogSlot=\"hasLogSlot\" :initialLoading=\"isInitialLoading || isRunning\" @export=\"onExport\"\n @delete=\"$emit('delete-this-graph')\"\n />\n <ChartErrorNotificationAlert v-if=\"chartErrorInfo?.type === 'unknownError'\" :errorInfo=\"chartErrorInfo\" />\n <ChartTruncationWarningAlert\n v-if=\"chartTruncationWarning\"\n :truncation-warning=\"chartTruncationWarning\"\n />\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -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,EAA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,CAAC;;;;;cAAyH,CAAC;aAAmC,CAAC;mBAAyC,CAAC;sBAA4C,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"}
|
|
@@ -2,6 +2,10 @@ import { DemoDataStore, InputGuide, InputState, PlotDataAndSettings } from '@mil
|
|
|
2
2
|
import { DefaultPalettes, GraphMakerProps, ReactiveState, UniqueValuesBySourceMap } from '../../types';
|
|
3
3
|
import { DataByColumns, Settings } from '@milaboratories/miplots4';
|
|
4
4
|
export type ChartTruncationWarning = {
|
|
5
|
+
type: 'dataOverflow';
|
|
6
|
+
dataVisible: number;
|
|
7
|
+
} | {
|
|
8
|
+
type: 'tooManyGroups';
|
|
5
9
|
groups: boolean;
|
|
6
10
|
facets: boolean;
|
|
7
11
|
/** Visible (shown) count for groups */
|
|
@@ -25,6 +29,6 @@ export declare function composeChartSettings(chartData: PlotDataAndSettings | nu
|
|
|
25
29
|
}>>, reactiveState: ReactiveState, defaultPalette: DefaultPalettes, facetValuesData?: UniqueValuesBySourceMap): null | {
|
|
26
30
|
settings: Settings;
|
|
27
31
|
data: DataByColumns;
|
|
28
|
-
truncationWarning: ChartTruncationWarning;
|
|
32
|
+
truncationWarning: ChartTruncationWarning | null;
|
|
29
33
|
};
|
|
30
34
|
//# sourceMappingURL=composeChartSettings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composeChartSettings.d.ts","sourceRoot":"","sources":["../../../src/utils/createChartSettingsForRender/composeChartSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK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M,CAAA;CAAE,CAAC,CAAC,EACnF,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,eAAe,EAC/B,eAAe,GAAE,uBAA4B,GAC5C,IAAI,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,aAAa,CAAC;IAAC,iBAAiB,EAAE,sBAAsB,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"composeChartSettings.d.ts","sourceRoot":"","sources":["../../../src/utils/createChartSettingsForRender/composeChartSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EACb,UAAU,EACV,UAAU,EACV,mBAAmB,EAEpB,MAAM,0BAA0B,CAAC;AAIlC,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,aAAa,EAEb,uBAAuB,EACxB,MAAM,aAAa,CAAC;AAIrB,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,cAAc,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG;IACF,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,uCAAuC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uCAAuC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,+FAA+F;AAC/F,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,EAC5B,eAAe,EAAE,uBAAuB,EACxC,cAAc,EAAE,MAAM,GACrB,MAAM,EAAE,GAAG,SAAS,CAUtB;AAMD,OAAO,KAAK,EAEV,aAAa,EAOb,QAAQ,EACT,MAAM,0BAA0B,CAAC;AAgElC,wBAAsB,eAAe,CACnC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,EAClC,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,aAAa,GAAG,IAAI,EAC/B,YAAY,CAAC,EAAE,eAAe,CAAC,cAAc,CAAC,uCAqB/C;AACD,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,mBAAmB,GAAG,IAAI,EACrC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,EAClC,UAAU,EAAE,uBAAuB,EACnC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,EACnF,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,eAAe,EAC/B,eAAe,GAAE,uBAA4B,GAC5C,IAAI,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,aAAa,CAAC;IAAC,iBAAiB,EAAE,sBAAsB,GAAG,IAAI,CAAA;CAAE,CA0EtG"}
|
|
@@ -63,6 +63,7 @@ function g(e, l, u, d, h, g, _ = {}) {
|
|
|
63
63
|
let v = { ...e.settings }, y = e.data.byColumns;
|
|
64
64
|
v.title = m(h.chartType, h.optionsState, d, h.axesSettings), v.size = p(h.chartScale, h.optionsState.components?.facetBy.selectorStates.length || 0), v.legend = { show: h.axesSettings.other.showLegend };
|
|
65
65
|
let b = {
|
|
66
|
+
type: "tooManyGroups",
|
|
66
67
|
groups: !1,
|
|
67
68
|
facets: !1
|
|
68
69
|
};
|
|
@@ -77,7 +78,10 @@ function g(e, l, u, d, h, g, _ = {}) {
|
|
|
77
78
|
order: r
|
|
78
79
|
};
|
|
79
80
|
}
|
|
80
|
-
return {
|
|
81
|
+
return b.facets === !1 && b.groups === !1 && (b = null), e.data.byColumns.overflow && (b = {
|
|
82
|
+
type: "dataOverflow",
|
|
83
|
+
dataVisible: e.data.byColumns.values[Object.keys(e.data.byColumns.values)[0]].length
|
|
84
|
+
}), {
|
|
81
85
|
settings: v,
|
|
82
86
|
data: e.data.byColumns,
|
|
83
87
|
truncationWarning: b
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composeChartSettings.js","names":[],"sources":["../../../src/utils/createChartSettingsForRender/composeChartSettings.ts"],"sourcesContent":["import type {\n ChartType,\n DemoDataStore,\n InputGuide,\n InputState,\n PlotDataAndSettings,\n SelectorStateFilter,\n} from '@milaboratories/pf-plots';\nimport {\n getControllerByType,\n} from '@milaboratories/pf-plots';\nimport type {\n DefaultPalettes,\n GraphMakerProps,\n ReactiveState,\n TitlePosition,\n UniqueValuesBySourceMap,\n} from '../../types';\n\nconst DISPLAY_MAX = 1000;\n\nexport type ChartTruncationWarning = {\n groups: boolean;\n facets: boolean;\n /** Visible (shown) count for groups */\n groupsVisible?: number;\n /** Total count for groups (use 1000+ in UI when >= 1000) */\n groupsTotal?: number;\n /** Visible (shown) count for facets */\n facetsVisible?: number;\n /** Total count for facets (use 1000+ in UI when >= 1000) */\n facetsTotal?: number;\n};\n\nexport function formatTruncationTotal(n: number): string {\n return n >= DISPLAY_MAX ? '1000+' : String(n);\n}\n\n/** Build facet order for chart settings from saved facet values, limited by maxFacetsCount. */\nexport function getFacetOrderForChartSettings(\n facetBy: { value: string }[],\n facetValuesData: UniqueValuesBySourceMap,\n maxFacetsCount: number,\n): string[] | undefined {\n if (!facetBy?.length || maxFacetsCount <= 0) {\n return undefined;\n }\n const valueLists = facetBy.map((col) => facetValuesData[col.value]?.list ?? []);\n if (valueLists.some((list) => !list.length)) {\n return undefined;\n }\n const keys = getFacetKeysFromValueLists(valueLists);\n return keys.slice(0, maxFacetsCount);\n}\nimport { addFixedOptionsToState } from '../addFixedOptionsToState';\nimport type {\n AxesState } from '../../constantsCommon';\nimport { DEFAULT_HEIGHT, DEFAULT_HEIGHT_SMALL, DEFAULT_WIDTH, DEFAULT_WIDTH_SMALL,\n} from '../../constantsCommon';\nimport type {\n BubbleSettings,\n DataByColumns,\n DendroSettings,\n DiscreteSettings,\n HeatmapSettings,\n HistogramSettings,\n ScatterplotSettings,\n ScatterplotUmapSettings,\n Settings,\n} from '@milaboratories/miplots4';\nimport { getFacetKeysFromValueLists } from '@milaboratories/miplots4';\nimport { composeDiscreteSettings } from './composeDiscreteSettings';\nimport { composeScatterplotSettings } from './composeScatterplotSettings';\nimport { composeScatterplotUmapSettings } from './composeScatterplotUmapSettings';\nimport { composeHeatmapSettings } from './composeHeatmapSettings';\nimport { composeDendroSettings } from './composeDendroSettings';\nimport { composeHistogramSettings } from './composeHistogramSettings';\nimport { composeBubbleSettings } from './composeBubbleSettings';\n\nfunction getChartSizes(chartScale: number, facetByLength = 0) {\n return {\n width: (facetByLength > 0 ? DEFAULT_WIDTH_SMALL : DEFAULT_WIDTH) * (chartScale / 100),\n height: (facetByLength > 0 ? DEFAULT_HEIGHT_SMALL : DEFAULT_HEIGHT) * (chartScale / 100),\n };\n}\n\nfunction getChartTitle(\n chartType: ChartType,\n optionsState: InputState,\n filterLabelsInfo: Record<string, Record<string, { value: unknown; label: string }>>,\n axesSettings: AxesState,\n): {\n name: string;\n show: boolean;\n position?: TitlePosition;\n } {\n if (\n chartType !== 'scatterplot'\n && chartType !== 'scatterplot-umap'\n && chartType !== 'discrete'\n && chartType !== 'heatmap'\n && chartType !== 'histogram'\n && chartType !== 'bubble'\n ) {\n return { name: '', show: false };\n }\n if (axesSettings.title.mode === 'hidden') {\n return { name: '', show: false };\n }\n if (axesSettings.title.mode === 'custom') {\n return { name: axesSettings.title.value, show: true, position: axesSettings.title.position };\n }\n if (axesSettings.title.mode === 'auto') {\n const selectedFilters: string[] = [];\n const tabByStates = (optionsState.components?.tabBy.selectorStates ?? []);\n const filterStates = (optionsState.components?.filters.selectorStates ?? []).filter((state) => !tabByStates.some((tabByState) => tabByState.selectedSource === state.selectedSource));\n\n const usedInTitleStates = [\n ...tabByStates,\n ...filterStates,\n ] as SelectorStateFilter[];\n usedInTitleStates.forEach(({ type, selectedSource, selectedFilterValues }) => {\n if ((!type || type === 'equals') && selectedFilterValues && filterLabelsInfo[selectedSource]) {\n selectedFilters.push(...selectedFilterValues\n .map((selectedFilterValue) => filterLabelsInfo[selectedSource]?.[selectedFilterValue]?.label ?? String(selectedFilterValue)));\n }\n });\n const title = selectedFilters.join(', ');\n return { name: title, show: true, position: axesSettings.title.position };\n }\n return { name: '', show: false };\n}\n\nexport async function loadDataForPlot(\n inputGuide: InputGuide<InputState>,\n reactiveState: ReactiveState,\n dataStore: DemoDataStore | null,\n fixedOptions?: GraphMakerProps['fixedOptions'],\n) {\n if (!inputGuide.ready || dataStore === null) {\n return null;\n }\n try {\n const controller = getControllerByType(reactiveState.chartType);\n const optionsStateWithFixed = await addFixedOptionsToState(\n reactiveState.optionsState,\n dataStore,\n fixedOptions,\n );\n return controller.createDataForPlot(\n dataStore,\n optionsStateWithFixed,\n );\n } catch (err) {\n console.warn('Cant build chart data');\n console.warn((err as Error).message);\n return null;\n }\n}\nexport function composeChartSettings(\n chartData: PlotDataAndSettings | null,\n inputGuide: InputGuide<InputState>,\n labelsInfo: UniqueValuesBySourceMap,\n filterLabelsInfo: Record<string, Record<string, { value: unknown; label: string }>>,\n reactiveState: ReactiveState,\n defaultPalette: DefaultPalettes,\n facetValuesData: UniqueValuesBySourceMap = {},\n): null | { settings: Settings; data: DataByColumns; truncationWarning: ChartTruncationWarning } {\n if (!inputGuide.ready || chartData === null) {\n return null;\n }\n\n let settings: Settings = { ...chartData.settings } as Settings;\n const dataByColumns = chartData.data.byColumns;\n settings.title = getChartTitle(reactiveState.chartType, reactiveState.optionsState, filterLabelsInfo, reactiveState.axesSettings);\n settings.size = getChartSizes(reactiveState.chartScale, reactiveState.optionsState.components?.facetBy.selectorStates.length || 0);\n settings.legend = { show: reactiveState.axesSettings.other.showLegend };\n\n const truncationWarning: ChartTruncationWarning = { groups: false, facets: false };\n\n if (reactiveState.chartType === 'discrete') {\n const result = composeDiscreteSettings(settings as DiscreteSettings, reactiveState, labelsInfo, inputGuide, defaultPalette);\n settings = result.settings;\n truncationWarning.groups = result.groupsAreTruncated;\n if (result.groupsAreTruncated && result.groupsVisible != null && result.groupsTotal != null) {\n truncationWarning.groupsVisible = result.groupsVisible;\n truncationWarning.groupsTotal = result.groupsTotal;\n }\n }\n if (reactiveState.chartType === 'scatterplot') {\n settings = composeScatterplotSettings(settings as ScatterplotSettings, dataByColumns, reactiveState, inputGuide, labelsInfo, defaultPalette);\n }\n if (reactiveState.chartType === 'scatterplot-umap') {\n settings = composeScatterplotUmapSettings(settings as ScatterplotUmapSettings, dataByColumns, reactiveState, inputGuide, labelsInfo, defaultPalette);\n }\n if (reactiveState.chartType === 'heatmap') {\n settings = composeHeatmapSettings(settings as HeatmapSettings, reactiveState, defaultPalette);\n }\n if (reactiveState.chartType === 'dendro') {\n settings = composeDendroSettings(settings as DendroSettings, dataByColumns, reactiveState, inputGuide, labelsInfo);\n }\n if (reactiveState.chartType === 'histogram') {\n settings = composeHistogramSettings(settings as HistogramSettings, reactiveState, labelsInfo, defaultPalette);\n }\n if (reactiveState.chartType === 'bubble') {\n settings = composeBubbleSettings(settings as BubbleSettings, reactiveState, defaultPalette);\n }\n\n if ('facetBy' in settings && 'facetSettings' in settings && settings.facetBy?.length && settings.facetSettings) {\n const valueLists = settings.facetBy.map((col: { value: string }) => facetValuesData[col.value]?.list ?? []);\n const allFacetKeys = valueLists.every((list: string[]) => list.length > 0)\n ? getFacetKeysFromValueLists(valueLists)\n : [];\n const maxFacetsCount = reactiveState.axesSettings.other.maxFacetsCount;\n const order = getFacetOrderForChartSettings(\n settings.facetBy,\n facetValuesData,\n maxFacetsCount,\n );\n if (allFacetKeys.length > maxFacetsCount) {\n truncationWarning.facets = true;\n truncationWarning.facetsVisible = order?.length ?? 0;\n truncationWarning.facetsTotal = allFacetKeys.length;\n }\n settings.facetSettings = { ...settings.facetSettings, order };\n }\n return {\n settings: settings as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AAc,kBAC9B,IAAW,EAA2B,GAAiC,GAAe,GAAe,GAAY,GAAY,EAAe,GAE1I,EAAc,cAAc,uBAC9B,IAAW,EAA+B,GAAqC,GAAe,GAAe,GAAY,GAAY,EAAe,GAElJ,EAAc,cAAc,cAC9B,IAAW,EAAuB,GAA6B,GAAe,EAAe,GAE3F,EAAc,cAAc,aAC9B,IAAW,EAAsB,GAA4B,GAAe,GAAe,GAAY,EAAW,GAEhH,EAAc,cAAc,gBAC9B,IAAW,EAAyB,GAA+B,GAAe,GAAY,EAAe,GAE3G,EAAc,cAAc,aAC9B,IAAW,EAAsB,GAA4B,GAAe,EAAe,GAGzF,aAAa,KAAY,mBAAmB,KAAY,EAAS,SAAS,UAAU,EAAS,eAAe;EAC9G,IAAM,IAAa,EAAS,QAAQ,KAAK,MAA2B,EAAgB,EAAI,QAAQ,QAAQ,EAAE,CAAC,EACrG,IAAe,EAAW,OAAO,MAAmB,EAAK,SAAS,EAAE,GACtE,EAA2B,EAAW,GACtC,EAAE,EACA,IAAiB,EAAc,aAAa,MAAM,gBAClD,IAAQ,EACZ,EAAS,SACT,GACA,EACD;AAMD,EALI,EAAa,SAAS,MACxB,EAAkB,SAAS,IAC3B,EAAkB,gBAAgB,GAAO,UAAU,GACnD,EAAkB,cAAc,EAAa,SAE/C,EAAS,gBAAgB;GAAE,GAAG,EAAS;GAAe;GAAO;;AAE/D,QAAO;EACK;EACV,MAAM,EAAU,KAAK;EACrB;EACD"}
|
|
1
|
+
{"version":3,"file":"composeChartSettings.js","names":[],"sources":["../../../src/utils/createChartSettingsForRender/composeChartSettings.ts"],"sourcesContent":["import type {\n ChartType,\n DemoDataStore,\n InputGuide,\n InputState,\n PlotDataAndSettings,\n SelectorStateFilter,\n} from '@milaboratories/pf-plots';\nimport {\n getControllerByType,\n} from '@milaboratories/pf-plots';\nimport type {\n DefaultPalettes,\n GraphMakerProps,\n ReactiveState,\n TitlePosition,\n UniqueValuesBySourceMap,\n} from '../../types';\n\nconst DISPLAY_MAX = 1000;\n\nexport type ChartTruncationWarning = {\n type: 'dataOverflow';\n dataVisible: number;\n} | {\n type: 'tooManyGroups';\n groups: boolean;\n facets: boolean;\n /** Visible (shown) count for groups */\n groupsVisible?: number;\n /** Total count for groups (use 1000+ in UI when >= 1000) */\n groupsTotal?: number;\n /** Visible (shown) count for facets */\n facetsVisible?: number;\n /** Total count for facets (use 1000+ in UI when >= 1000) */\n facetsTotal?: number;\n};\n\nexport function formatTruncationTotal(n: number): string {\n return n >= DISPLAY_MAX ? '1000+' : String(n);\n}\n\n/** Build facet order for chart settings from saved facet values, limited by maxFacetsCount. */\nexport function getFacetOrderForChartSettings(\n facetBy: { value: string }[],\n facetValuesData: UniqueValuesBySourceMap,\n maxFacetsCount: number,\n): string[] | undefined {\n if (!facetBy?.length || maxFacetsCount <= 0) {\n return undefined;\n }\n const valueLists = facetBy.map((col) => facetValuesData[col.value]?.list ?? []);\n if (valueLists.some((list) => !list.length)) {\n return undefined;\n }\n const keys = getFacetKeysFromValueLists(valueLists);\n return keys.slice(0, maxFacetsCount);\n}\nimport { addFixedOptionsToState } from '../addFixedOptionsToState';\nimport type {\n AxesState } from '../../constantsCommon';\nimport { DEFAULT_HEIGHT, DEFAULT_HEIGHT_SMALL, DEFAULT_WIDTH, DEFAULT_WIDTH_SMALL,\n} from '../../constantsCommon';\nimport type {\n BubbleSettings,\n DataByColumns,\n DendroSettings,\n DiscreteSettings,\n HeatmapSettings,\n HistogramSettings,\n ScatterplotSettings,\n ScatterplotUmapSettings,\n Settings,\n} from '@milaboratories/miplots4';\nimport { getFacetKeysFromValueLists } from '@milaboratories/miplots4';\nimport { composeDiscreteSettings } from './composeDiscreteSettings';\nimport { composeScatterplotSettings } from './composeScatterplotSettings';\nimport { composeScatterplotUmapSettings } from './composeScatterplotUmapSettings';\nimport { composeHeatmapSettings } from './composeHeatmapSettings';\nimport { composeDendroSettings } from './composeDendroSettings';\nimport { composeHistogramSettings } from './composeHistogramSettings';\nimport { composeBubbleSettings } from './composeBubbleSettings';\n\nfunction getChartSizes(chartScale: number, facetByLength = 0) {\n return {\n width: (facetByLength > 0 ? DEFAULT_WIDTH_SMALL : DEFAULT_WIDTH) * (chartScale / 100),\n height: (facetByLength > 0 ? DEFAULT_HEIGHT_SMALL : DEFAULT_HEIGHT) * (chartScale / 100),\n };\n}\n\nfunction getChartTitle(\n chartType: ChartType,\n optionsState: InputState,\n filterLabelsInfo: Record<string, Record<string, { value: unknown; label: string }>>,\n axesSettings: AxesState,\n): {\n name: string;\n show: boolean;\n position?: TitlePosition;\n } {\n if (\n chartType !== 'scatterplot'\n && chartType !== 'scatterplot-umap'\n && chartType !== 'discrete'\n && chartType !== 'heatmap'\n && chartType !== 'histogram'\n && chartType !== 'bubble'\n ) {\n return { name: '', show: false };\n }\n if (axesSettings.title.mode === 'hidden') {\n return { name: '', show: false };\n }\n if (axesSettings.title.mode === 'custom') {\n return { name: axesSettings.title.value, show: true, position: axesSettings.title.position };\n }\n if (axesSettings.title.mode === 'auto') {\n const selectedFilters: string[] = [];\n const tabByStates = (optionsState.components?.tabBy.selectorStates ?? []);\n const filterStates = (optionsState.components?.filters.selectorStates ?? []).filter((state) => !tabByStates.some((tabByState) => tabByState.selectedSource === state.selectedSource));\n\n const usedInTitleStates = [\n ...tabByStates,\n ...filterStates,\n ] as SelectorStateFilter[];\n usedInTitleStates.forEach(({ type, selectedSource, selectedFilterValues }) => {\n if ((!type || type === 'equals') && selectedFilterValues && filterLabelsInfo[selectedSource]) {\n selectedFilters.push(...selectedFilterValues\n .map((selectedFilterValue) => filterLabelsInfo[selectedSource]?.[selectedFilterValue]?.label ?? String(selectedFilterValue)));\n }\n });\n const title = selectedFilters.join(', ');\n return { name: title, show: true, position: axesSettings.title.position };\n }\n return { name: '', show: false };\n}\n\nexport async function loadDataForPlot(\n inputGuide: InputGuide<InputState>,\n reactiveState: ReactiveState,\n dataStore: DemoDataStore | null,\n fixedOptions?: GraphMakerProps['fixedOptions'],\n) {\n if (!inputGuide.ready || dataStore === null) {\n return null;\n }\n try {\n const controller = getControllerByType(reactiveState.chartType);\n const optionsStateWithFixed = await addFixedOptionsToState(\n reactiveState.optionsState,\n dataStore,\n fixedOptions,\n );\n return controller.createDataForPlot(\n dataStore,\n optionsStateWithFixed,\n );\n } catch (err) {\n console.warn('Cant build chart data');\n console.warn((err as Error).message);\n return null;\n }\n}\nexport function composeChartSettings(\n chartData: PlotDataAndSettings | null,\n inputGuide: InputGuide<InputState>,\n labelsInfo: UniqueValuesBySourceMap,\n filterLabelsInfo: Record<string, Record<string, { value: unknown; label: string }>>,\n reactiveState: ReactiveState,\n defaultPalette: DefaultPalettes,\n facetValuesData: UniqueValuesBySourceMap = {},\n): null | { settings: Settings; data: DataByColumns; truncationWarning: ChartTruncationWarning | null } {\n if (!inputGuide.ready || chartData === null) {\n return null;\n }\n\n let settings: Settings = { ...chartData.settings } as Settings;\n const dataByColumns = chartData.data.byColumns;\n settings.title = getChartTitle(reactiveState.chartType, reactiveState.optionsState, filterLabelsInfo, reactiveState.axesSettings);\n settings.size = getChartSizes(reactiveState.chartScale, reactiveState.optionsState.components?.facetBy.selectorStates.length || 0);\n settings.legend = { show: reactiveState.axesSettings.other.showLegend };\n\n let truncationWarning: ChartTruncationWarning | null = { type: 'tooManyGroups', groups: false, facets: false };\n\n if (reactiveState.chartType === 'discrete') {\n const result = composeDiscreteSettings(settings as DiscreteSettings, reactiveState, labelsInfo, inputGuide, defaultPalette);\n settings = result.settings;\n truncationWarning.groups = result.groupsAreTruncated;\n if (result.groupsAreTruncated && result.groupsVisible != null && result.groupsTotal != null) {\n truncationWarning.groupsVisible = result.groupsVisible;\n truncationWarning.groupsTotal = result.groupsTotal;\n }\n }\n if (reactiveState.chartType === 'scatterplot') {\n settings = composeScatterplotSettings(settings as ScatterplotSettings, dataByColumns, reactiveState, inputGuide, labelsInfo, defaultPalette);\n }\n if (reactiveState.chartType === 'scatterplot-umap') {\n settings = composeScatterplotUmapSettings(settings as ScatterplotUmapSettings, dataByColumns, reactiveState, inputGuide, labelsInfo, defaultPalette);\n }\n if (reactiveState.chartType === 'heatmap') {\n settings = composeHeatmapSettings(settings as HeatmapSettings, reactiveState, defaultPalette);\n }\n if (reactiveState.chartType === 'dendro') {\n settings = composeDendroSettings(settings as DendroSettings, dataByColumns, reactiveState, inputGuide, labelsInfo);\n }\n if (reactiveState.chartType === 'histogram') {\n settings = composeHistogramSettings(settings as HistogramSettings, reactiveState, labelsInfo, defaultPalette);\n }\n if (reactiveState.chartType === 'bubble') {\n settings = composeBubbleSettings(settings as BubbleSettings, reactiveState, defaultPalette);\n }\n\n if ('facetBy' in settings && 'facetSettings' in settings && settings.facetBy?.length && settings.facetSettings) {\n const valueLists = settings.facetBy.map((col: { value: string }) => facetValuesData[col.value]?.list ?? []);\n const allFacetKeys = valueLists.every((list: string[]) => list.length > 0)\n ? getFacetKeysFromValueLists(valueLists)\n : [];\n const maxFacetsCount = reactiveState.axesSettings.other.maxFacetsCount;\n const order = getFacetOrderForChartSettings(\n settings.facetBy,\n facetValuesData,\n maxFacetsCount,\n );\n if (allFacetKeys.length > maxFacetsCount) {\n truncationWarning.facets = true;\n truncationWarning.facetsVisible = order?.length ?? 0;\n truncationWarning.facetsTotal = allFacetKeys.length;\n }\n settings.facetSettings = { ...settings.facetSettings, order };\n }\n\n if (truncationWarning.facets === false && truncationWarning.groups === false) {\n truncationWarning = null;\n }\n if (chartData.data.byColumns.overflow) {\n truncationWarning = {\n type: 'dataOverflow',\n dataVisible: chartData.data.byColumns.values[Object.keys(chartData.data.byColumns.values)[0]].length,\n };\n }\n return {\n settings: settings as Settings,\n data: chartData.data.byColumns,\n truncationWarning,\n };\n}\n"],"mappings":";;;;;;;;;;AAmBA,IAAM,IAAc;AAmBpB,SAAgB,EAAsB,GAAmB;AACvD,QAAO,KAAK,IAAc,UAAU,OAAO,EAAE;;;AAI/C,SAAgB,EACd,GACA,GACA,GACsB;AACtB,KAAI,CAAC,GAAS,UAAU,KAAkB,EACxC;CAEF,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,IAAW,EAAsB,GAA4B,GAAe,GAAe,GAAY,EAAW,GAEhH,EAAc,cAAc,gBAC9B,IAAW,EAAyB,GAA+B,GAAe,GAAY,EAAe,GAE3G,EAAc,cAAc,aAC9B,IAAW,EAAsB,GAA4B,GAAe,EAAe,GAGzF,aAAa,KAAY,mBAAmB,KAAY,EAAS,SAAS,UAAU,EAAS,eAAe;EAC9G,IAAM,IAAa,EAAS,QAAQ,KAAK,MAA2B,EAAgB,EAAI,QAAQ,QAAQ,EAAE,CAAC,EACrG,IAAe,EAAW,OAAO,MAAmB,EAAK,SAAS,EAAE,GACtE,EAA2B,EAAW,GACtC,EAAE,EACA,IAAiB,EAAc,aAAa,MAAM,gBAClD,IAAQ,EACZ,EAAS,SACT,GACA,EACD;AAMD,EALI,EAAa,SAAS,MACxB,EAAkB,SAAS,IAC3B,EAAkB,gBAAgB,GAAO,UAAU,GACnD,EAAkB,cAAc,EAAa,SAE/C,EAAS,gBAAgB;GAAE,GAAG,EAAS;GAAe;GAAO;;AAY/D,QATI,EAAkB,WAAW,MAAS,EAAkB,WAAW,OACrE,IAAoB,OAElB,EAAU,KAAK,UAAU,aAC3B,IAAoB;EAClB,MAAM;EACN,aAAa,EAAU,KAAK,UAAU,OAAO,OAAO,KAAK,EAAU,KAAK,UAAU,OAAO,CAAC,IAAI;EAC/F,GAEI;EACK;EACV,MAAM,EAAU,KAAK;EACrB;EACD"}
|
|
@@ -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,aAAa,CAAC;AAGxF,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,eAAe;;;;YAoHs7+C,CAAC;gBAAuC,CAAC;;;;;cAA8H,CAAC;aAAmC,CAAC;mBAAyC,CAAC;sBAA4C,CAAC;;;;;cAAyG,CAAC;aAAmC,CAAC;mBAAyC,CAAC;sBAA4C,CAAC;;;;;cAA6G,CAAC;aAAmC,CAAC;mBAAyC,CAAC;sBAA4C,CAAC;;;aAAuD,CAAC;cAAoC,CAAC;mBAAyC,CAAC;mBAAyC,CAAC;iBAAuC,CAAC;kBAAwC,CAAC;;;kBAAuE,CAAC;uBAA+C,CAAC;sBAA4C,CAAC;iBAAuC,CAAC;mBAAyD,CAAC;sBAA8C,CAAC;gBAAwC,CAAC;eAAqC,CAAC;;;YAAoE,CAAC;gBAAuC,CAAC;;;YAAqG,CAAC;eAAsC,CAAC;;;kBAA6E,CAAC;iBAAuC,CAAC;uBAA6C,CAAC;0BAAgD,CAAC;;;;YAA4F,CAAC;;;eAAkG,CAAC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AoD,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;;;YAA0E,CAAC;WAAiC,CAAC;mBAAuB,CAAC;;;sBAAkG,CAAC;qBAA2C,CAAC;2BAAiD,CAAC;8BAAoD,CAAC;;oBAAqE,CAAC;;;sBAA8P,CAAC;qBAA2C,CAAC;2BAAiD,CAAC;8BAAoD,CAAC;;mBAAoE,CAAC;;;sBAAkG,CAAC;qBAA2C,CAAC;2BAAiD,CAAC;8BAAoD,CAAC;;qBAAsE,CAAC;;;sBAAkG,CAAC;qBAA2C,CAAC;2BAAiD,CAAC;8BAAoD,CAAC;;qBAAsE,CAAC;;;sBAAyF,CAAC;qBAA2C,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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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,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|
+
{"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,EA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graph-maker",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/ui.js",
|
|
6
6
|
"types": "dist/ui.d.ts",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"d3-hierarchy": "^3.1.2",
|
|
39
39
|
"d3-scale": "^4.0.2",
|
|
40
40
|
"vue": "^3.5.24",
|
|
41
|
-
"@milaboratories/miplots4": "1.0.
|
|
42
|
-
"@milaboratories/pf-plots": "1.1.
|
|
41
|
+
"@milaboratories/miplots4": "1.0.179",
|
|
42
|
+
"@milaboratories/pf-plots": "1.1.70"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@milaboratories/build-configs": "^1.5.0",
|
package/dist/GraphMakerPlugin.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GraphMakerPlugin.js","names":[],"sources":["../src/GraphMakerPlugin.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed } from 'vue';\nimport { usePlugin, type InferPluginHandle } from '@platforma-sdk/ui-vue';\nimport { type PlSelectionModel, type PColumnSpec, getRawPlatformaInstance } from '@platforma-sdk/model';\nimport type { ChartType } from '@milaboratories/pf-plots';\nimport type { GraphMakerPlugin } from './plugin';\nimport type { GraphMakerProps, GraphMakerState, PredefinedGraphOption, StatusTextData } from './types';\nimport GraphMaker from './ui.vue';\n\nconst props = defineProps<{\n handle: InferPluginHandle<GraphMakerPlugin>;\n defaultOptions?: PredefinedGraphOption<ChartType>[] | null;\n fixedOptions?: PredefinedGraphOption<ChartType>[];\n tooltipButton?: string;\n labelsModifier?: (id: string, label: string) => string;\n dataColumnPredicate?: (spec: PColumnSpec) => boolean;\n metaColumnPredicate?: (spec: PColumnSpec) => boolean;\n statusText?: Partial<StatusTextData>;\n}>();\n\nconst emit = defineEmits<{\n 'delete-this-graph': [];\n 'tooltip-btn-click': [id: string];\n}>();\n\nconst plugin = usePlugin(props.handle);\nconst data = plugin.model.data;\n\nconst state = computed<GraphMakerState>({\n get: () => data.state,\n set: (v) => { data.state = v; },\n});\n\nconst selection = computed<PlSelectionModel | undefined>({\n get: () => data.selection,\n set: (v) => { data.selection = v; },\n});\n\nconst graphMakerProps = computed(() => ({\n chartType: plugin.model.outputs.chartType as ChartType,\n pFrame: plugin.model.outputs.pFrame,\n defaultPalette: plugin.model.outputs.defaultPalette ?? undefined,\n readonlyInputs: plugin.model.outputs.readonlyInputs ?? [],\n allowChartDeleting: plugin.model.outputs.allowChartDeleting ?? false,\n allowTitleEditing: plugin.model.outputs.allowTitleEditing ?? false,\n defaultOptions: props.defaultOptions,\n fixedOptions: props.fixedOptions,\n driver: getRawPlatformaInstance().pFrameDriver,\n tooltipButton: props.tooltipButton,\n labelsModifier: props.labelsModifier,\n dataColumnPredicate: props.dataColumnPredicate,\n metaColumnPredicate: props.metaColumnPredicate,\n statusText: props.statusText,\n}) as GraphMakerProps);\n</script>\n\n<template>\n <GraphMaker\n v-model=\"state\"\n v-model:selection=\"selection\"\n v-bind=\"graphMakerProps\"\n @delete-this-graph=\"emit('delete-this-graph')\"\n @tooltip-btn-click=\"(id: string) => emit('tooltip-btn-click', id)\"\n >\n <template v-for=\"(_, name) in $slots\" #[name]>\n <slot :name=\"name\" />\n </template>\n </GraphMaker>\n</template>\n"],"mappings":""}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { InferPluginHandle } from '@platforma-sdk/ui-vue';
|
|
2
|
-
import { PColumnSpec } from '@platforma-sdk/model';
|
|
3
|
-
import { ChartType } from '@milaboratories/pf-plots';
|
|
4
|
-
import { GraphMakerPlugin } from './plugin';
|
|
5
|
-
import { PredefinedGraphOption, StatusTextData } from './types';
|
|
6
|
-
type __VLS_Props = {
|
|
7
|
-
handle: InferPluginHandle<GraphMakerPlugin>;
|
|
8
|
-
defaultOptions?: PredefinedGraphOption<ChartType>[] | null;
|
|
9
|
-
fixedOptions?: PredefinedGraphOption<ChartType>[];
|
|
10
|
-
tooltipButton?: string;
|
|
11
|
-
labelsModifier?: (id: string, label: string) => string;
|
|
12
|
-
dataColumnPredicate?: (spec: PColumnSpec) => boolean;
|
|
13
|
-
metaColumnPredicate?: (spec: PColumnSpec) => boolean;
|
|
14
|
-
statusText?: Partial<StatusTextData>;
|
|
15
|
-
};
|
|
16
|
-
declare function __VLS_template(): {
|
|
17
|
-
attrs: Partial<{}>;
|
|
18
|
-
slots: any;
|
|
19
|
-
refs: {};
|
|
20
|
-
rootEl: HTMLDivElement;
|
|
21
|
-
};
|
|
22
|
-
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
23
|
-
declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
24
|
-
"tooltip-btn-click": (id: string) => any;
|
|
25
|
-
"delete-this-graph": () => any;
|
|
26
|
-
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
27
|
-
"onTooltip-btn-click"?: ((id: string) => any) | undefined;
|
|
28
|
-
"onDelete-this-graph"?: (() => any) | undefined;
|
|
29
|
-
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
30
|
-
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
31
|
-
export default _default;
|
|
32
|
-
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
33
|
-
new (): {
|
|
34
|
-
$slots: S;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=GraphMakerPlugin.vue.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GraphMakerPlugin.vue.d.ts","sourceRoot":"","sources":["../src/GraphMakerPlugin.vue"],"names":[],"mappings":"AAwEA,OAAO,EAAa,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAyB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createSlots as r, defineComponent as i, mergeProps as a, openBlock as o, renderList as s, renderSlot as c, withCtx as l } from "vue";
|
|
3
|
-
import { usePlugin as u } from "@platforma-sdk/ui-vue";
|
|
4
|
-
import { getRawPlatformaInstance as d } from "@platforma-sdk/model";
|
|
5
|
-
var f = /* @__PURE__ */ i({
|
|
6
|
-
__name: "GraphMakerPlugin",
|
|
7
|
-
props: {
|
|
8
|
-
handle: {},
|
|
9
|
-
defaultOptions: {},
|
|
10
|
-
fixedOptions: {},
|
|
11
|
-
tooltipButton: {},
|
|
12
|
-
labelsModifier: { type: Function },
|
|
13
|
-
dataColumnPredicate: { type: Function },
|
|
14
|
-
metaColumnPredicate: { type: Function },
|
|
15
|
-
statusText: {}
|
|
16
|
-
},
|
|
17
|
-
emits: ["delete-this-graph", "tooltip-btn-click"],
|
|
18
|
-
setup(i, { emit: f }) {
|
|
19
|
-
let p = i, m = f, h = u(p.handle), g = h.model.data, _ = t({
|
|
20
|
-
get: () => g.state,
|
|
21
|
-
set: (e) => {
|
|
22
|
-
g.state = e;
|
|
23
|
-
}
|
|
24
|
-
}), v = t({
|
|
25
|
-
get: () => g.selection,
|
|
26
|
-
set: (e) => {
|
|
27
|
-
g.selection = e;
|
|
28
|
-
}
|
|
29
|
-
}), y = t(() => ({
|
|
30
|
-
chartType: h.model.outputs.chartType,
|
|
31
|
-
pFrame: h.model.outputs.pFrame,
|
|
32
|
-
defaultPalette: h.model.outputs.defaultPalette ?? void 0,
|
|
33
|
-
readonlyInputs: h.model.outputs.readonlyInputs ?? [],
|
|
34
|
-
allowChartDeleting: h.model.outputs.allowChartDeleting ?? !1,
|
|
35
|
-
allowTitleEditing: h.model.outputs.allowTitleEditing ?? !1,
|
|
36
|
-
defaultOptions: p.defaultOptions,
|
|
37
|
-
fixedOptions: p.fixedOptions,
|
|
38
|
-
driver: d().pFrameDriver,
|
|
39
|
-
tooltipButton: p.tooltipButton,
|
|
40
|
-
labelsModifier: p.labelsModifier,
|
|
41
|
-
dataColumnPredicate: p.dataColumnPredicate,
|
|
42
|
-
metaColumnPredicate: p.metaColumnPredicate,
|
|
43
|
-
statusText: p.statusText
|
|
44
|
-
}));
|
|
45
|
-
return (t, i) => (o(), n(e, a({
|
|
46
|
-
modelValue: _.value,
|
|
47
|
-
"onUpdate:modelValue": i[0] ||= (e) => _.value = e,
|
|
48
|
-
selection: v.value,
|
|
49
|
-
"onUpdate:selection": i[1] ||= (e) => v.value = e
|
|
50
|
-
}, y.value, {
|
|
51
|
-
onDeleteThisGraph: i[2] ||= (e) => m("delete-this-graph"),
|
|
52
|
-
onTooltipBtnClick: i[3] ||= (e) => m("tooltip-btn-click", e)
|
|
53
|
-
}), r({ _: 2 }, [s(t.$slots, (e, n) => ({
|
|
54
|
-
name: n,
|
|
55
|
-
fn: l(() => [c(t.$slots, n)])
|
|
56
|
-
}))]), 1040, ["modelValue", "selection"]));
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
export { f as default };
|
|
60
|
-
|
|
61
|
-
//# sourceMappingURL=GraphMakerPlugin.vue2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GraphMakerPlugin.vue_vue_type_script_setup_true_lang.js","names":["$slots"],"sources":["../src/GraphMakerPlugin.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed } from 'vue';\nimport { usePlugin, type InferPluginHandle } from '@platforma-sdk/ui-vue';\nimport { type PlSelectionModel, type PColumnSpec, getRawPlatformaInstance } from '@platforma-sdk/model';\nimport type { ChartType } from '@milaboratories/pf-plots';\nimport type { GraphMakerPlugin } from './plugin';\nimport type { GraphMakerProps, GraphMakerState, PredefinedGraphOption, StatusTextData } from './types';\nimport GraphMaker from './ui.vue';\n\nconst props = defineProps<{\n handle: InferPluginHandle<GraphMakerPlugin>;\n defaultOptions?: PredefinedGraphOption<ChartType>[] | null;\n fixedOptions?: PredefinedGraphOption<ChartType>[];\n tooltipButton?: string;\n labelsModifier?: (id: string, label: string) => string;\n dataColumnPredicate?: (spec: PColumnSpec) => boolean;\n metaColumnPredicate?: (spec: PColumnSpec) => boolean;\n statusText?: Partial<StatusTextData>;\n}>();\n\nconst emit = defineEmits<{\n 'delete-this-graph': [];\n 'tooltip-btn-click': [id: string];\n}>();\n\nconst plugin = usePlugin(props.handle);\nconst data = plugin.model.data;\n\nconst state = computed<GraphMakerState>({\n get: () => data.state,\n set: (v) => { data.state = v; },\n});\n\nconst selection = computed<PlSelectionModel | undefined>({\n get: () => data.selection,\n set: (v) => { data.selection = v; },\n});\n\nconst graphMakerProps = computed(() => ({\n chartType: plugin.model.outputs.chartType as ChartType,\n pFrame: plugin.model.outputs.pFrame,\n defaultPalette: plugin.model.outputs.defaultPalette ?? undefined,\n readonlyInputs: plugin.model.outputs.readonlyInputs ?? [],\n allowChartDeleting: plugin.model.outputs.allowChartDeleting ?? false,\n allowTitleEditing: plugin.model.outputs.allowTitleEditing ?? false,\n defaultOptions: props.defaultOptions,\n fixedOptions: props.fixedOptions,\n driver: getRawPlatformaInstance().pFrameDriver,\n tooltipButton: props.tooltipButton,\n labelsModifier: props.labelsModifier,\n dataColumnPredicate: props.dataColumnPredicate,\n metaColumnPredicate: props.metaColumnPredicate,\n statusText: props.statusText,\n}) as GraphMakerProps);\n</script>\n\n<template>\n <GraphMaker\n v-model=\"state\"\n v-model:selection=\"selection\"\n v-bind=\"graphMakerProps\"\n @delete-this-graph=\"emit('delete-this-graph')\"\n @tooltip-btn-click=\"(id: string) => emit('tooltip-btn-click', id)\"\n >\n <template v-for=\"(_, name) in $slots\" #[name]>\n <slot :name=\"name\" />\n </template>\n </GraphMaker>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;EASA,IAAM,IAAQ,GAWR,IAAO,GAKP,IAAS,EAAU,EAAM,OAAO,EAChC,IAAO,EAAO,MAAM,MAEpB,IAAQ,EAA0B;GACtC,WAAW,EAAK;GAChB,MAAM,MAAM;AAAE,MAAK,QAAQ;;GAC5B,CAAC,EAEI,IAAY,EAAuC;GACvD,WAAW,EAAK;GAChB,MAAM,MAAM;AAAE,MAAK,YAAY;;GAChC,CAAC,EAEI,IAAkB,SAAgB;GACtC,WAAW,EAAO,MAAM,QAAQ;GAChC,QAAQ,EAAO,MAAM,QAAQ;GAC7B,gBAAgB,EAAO,MAAM,QAAQ,kBAAkB,KAAA;GACvD,gBAAgB,EAAO,MAAM,QAAQ,kBAAkB,EAAE;GACzD,oBAAoB,EAAO,MAAM,QAAQ,sBAAsB;GAC/D,mBAAmB,EAAO,MAAM,QAAQ,qBAAqB;GAC7D,gBAAgB,EAAM;GACtB,cAAc,EAAM;GACpB,QAAQ,GAAyB,CAAC;GAClC,eAAe,EAAM;GACrB,gBAAgB,EAAM;GACtB,qBAAqB,EAAM;GAC3B,qBAAqB,EAAM;GAC3B,YAAY,EAAM;GACnB,EAAqB;yBAIpB,EAUa,GAVb,EAUa;eATF,EAAA;4CAAK,QAAA;GACN,WAAW,EAAA;2CAAS,QAAA;KACpB,EAAA,OAAe;GACtB,mBAAiB,AAAA,EAAA,QAAA,MAAE,EAAI,oBAAA;GACvB,mBAAiB,AAAA,EAAA,QAAG,MAAe,EAAI,qBAAsB,EAAE;qBAElCA,EAAAA,SAAZ,GAAG;GAAkB;eAChB,CAArB,EAAqB,EAAA,QAAR,EAAI,CAAA,CAAA"}
|