From 12c39b5cfdab9fecf8fa8ba61f99dd28fdbe7fa7 Mon Sep 17 00:00:00 2001 From: bistline Date: Mon, 8 Jul 2024 10:33:14 -0400 Subject: [PATCH] Only use refColorMap in multi-plot context --- app/javascript/components/explore/ScatterTab.jsx | 2 ++ .../components/visualization/ScatterPlot.jsx | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/javascript/components/explore/ScatterTab.jsx b/app/javascript/components/explore/ScatterTab.jsx index 1cf7c504a..65a6c365f 100644 --- a/app/javascript/components/explore/ScatterTab.jsx +++ b/app/javascript/components/explore/ScatterTab.jsx @@ -25,6 +25,7 @@ export default function ScatterTab({ function updateScatterColor(color) { updateExploreParamsWithDefaults({ scatterColor: color }, false) } + const hasMultipleRefs = exploreParamsWithDefaults?.spatialGroups?.length > 0 // identify any repeat graphs const newContextMap = getNewContextMap(scatterParams, plotlyContextMap.current) @@ -68,6 +69,7 @@ export default function ScatterTab({ isRefCluster={isRefCluster} refClusterRendered={refClusterRendered} setRefClusterRendered={setRefClusterRendered} + hasMultipleRefs={hasMultipleRefs} /> , rowDivider diff --git a/app/javascript/components/visualization/ScatterPlot.jsx b/app/javascript/components/visualization/ScatterPlot.jsx index 094e09b5b..9352acc3b 100644 --- a/app/javascript/components/visualization/ScatterPlot.jsx +++ b/app/javascript/components/visualization/ScatterPlot.jsx @@ -47,7 +47,7 @@ function RawScatterPlot({ isAnnotatedScatter=false, isCorrelatedScatter=false, isCellSelecting=false, plotPointsSelected, dataCache, canEdit, bucketId, expressionFilter=[0, 1], setCountsByLabelForDe, hiddenTraces=[], isSplitLabelArrays, updateExploreParams, filteredCells, refColorMap, setRefColorMap, isRefCluster, refClusterRendered, - setRefClusterRendered + setRefClusterRendered, hasMultipleRefs }) { const [countsByLabel, setCountsByLabel] = useState(null) const [isLoading, setIsLoading] = useState(false) @@ -198,7 +198,7 @@ function RawScatterPlot({ refColorMap, setRefColorMap, isRefCluster, - refClusterRendered + hasMultipleRefs }) if (isRG) { setCountsByLabel(labelCounts) @@ -719,7 +719,7 @@ function getPlotlyTraces({ refColorMap, setRefColorMap, isRefCluster, - refClusterRendered + hasMultipleRefs }) { const unfilteredTrace = { type: is3D ? 'scatter3d' : 'scattergl', @@ -755,7 +755,12 @@ function getPlotlyTraces({ groupTrace.type = unfilteredTrace.type groupTrace.mode = unfilteredTrace.mode groupTrace.opacity = unfilteredTrace.opacity - const color = getColorForLabel(groupTrace.name, customColors, editedCustomColors, refColorMap, labelIndex) + let color + if (hasMultipleRefs) { + color = getColorForLabel(groupTrace.name, customColors, editedCustomColors, refColorMap, labelIndex) + } else { + color = getColorForLabel(groupTrace.name, customColors, editedCustomColors, {}, labelIndex) + } if (isRefCluster) { updateRefColorMap(setRefColorMap, color, groupTrace.name) }