From 6f8351313fe360ed1e9553862e2915b7d07c620f Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 13 May 2023 15:26:45 +0100 Subject: [PATCH] final fixes and note about scatter TO DO --- .../implementations/BarplotVisualization.tsx | 11 +++++++++-- .../implementations/BoxplotVisualization.tsx | 2 +- .../implementations/HistogramVisualization.tsx | 11 +++++++++-- .../implementations/LineplotVisualization.tsx | 11 +++++++++-- .../implementations/ScatterplotVisualization.tsx | 14 +++++++++++--- 5 files changed, 39 insertions(+), 10 deletions(-) diff --git a/packages/libs/eda/src/lib/core/components/visualizations/implementations/BarplotVisualization.tsx b/packages/libs/eda/src/lib/core/components/visualizations/implementations/BarplotVisualization.tsx index 9ffa8bfce6..c500566bd9 100755 --- a/packages/libs/eda/src/lib/core/components/visualizations/implementations/BarplotVisualization.tsx +++ b/packages/libs/eda/src/lib/core/components/visualizations/implementations/BarplotVisualization.tsx @@ -74,7 +74,10 @@ import PlotLegend from '@veupathdb/components/lib/components/plotControls/PlotLe import { LegendItemsProps } from '@veupathdb/components/lib/components/plotControls/PlotListLegend'; // import { gray } from '../colors'; -import { ColorPaletteDefault } from '@veupathdb/components/lib/types/plots/addOns'; +import { + ColorPaletteDefault, + SequentialGradientColorscale, +} from '@veupathdb/components/lib/types/plots/addOns'; // a custom hook to preserve the status of checked legend items import { useCheckedLegendItems } from '../../../hooks/checkedLegendItemsStatus'; @@ -454,7 +457,7 @@ function BarplotViz(props: VisualizationProps) { variable ); const overlayVocabulary = - options?.getOverlayVocabulary?.() ?? + (overlayVariable && options?.getOverlayVocabulary?.()) ?? fixLabelsForNumberVariables( overlayVariable?.vocabulary, overlayVariable @@ -680,6 +683,10 @@ function BarplotViz(props: VisualizationProps) { max: truncationConfigDependentAxisMax, }, }, + colorPalette: + options?.getOverlayType?.() === 'continuous' + ? SequentialGradientColorscale + : ColorPaletteDefault, ...neutralPaletteProps, }; diff --git a/packages/libs/eda/src/lib/core/components/visualizations/implementations/BoxplotVisualization.tsx b/packages/libs/eda/src/lib/core/components/visualizations/implementations/BoxplotVisualization.tsx index fffb57eefe..97afc036de 100755 --- a/packages/libs/eda/src/lib/core/components/visualizations/implementations/BoxplotVisualization.tsx +++ b/packages/libs/eda/src/lib/core/components/visualizations/implementations/BoxplotVisualization.tsx @@ -527,7 +527,7 @@ function BoxplotViz(props: VisualizationProps) { xAxisVariable ); const overlayVocabulary = - options?.getOverlayVocabulary?.() ?? + (overlayVariable && options?.getOverlayVocabulary?.()) ?? fixLabelsForNumberVariables( overlayVariable?.vocabulary, overlayVariable diff --git a/packages/libs/eda/src/lib/core/components/visualizations/implementations/HistogramVisualization.tsx b/packages/libs/eda/src/lib/core/components/visualizations/implementations/HistogramVisualization.tsx index 13785476f4..f92b34cb3f 100755 --- a/packages/libs/eda/src/lib/core/components/visualizations/implementations/HistogramVisualization.tsx +++ b/packages/libs/eda/src/lib/core/components/visualizations/implementations/HistogramVisualization.tsx @@ -73,7 +73,10 @@ import PluginError from '../PluginError'; // for custom legend import PlotLegend from '@veupathdb/components/lib/components/plotControls/PlotLegend'; import { LegendItemsProps } from '@veupathdb/components/lib/components/plotControls/PlotListLegend'; -import { ColorPaletteDefault } from '@veupathdb/components/lib/types/plots/addOns'; +import { + ColorPaletteDefault, + SequentialGradientColorscale, +} from '@veupathdb/components/lib/types/plots/addOns'; // a custom hook to preserve the status of checked legend items import { useCheckedLegendItems } from '../../../hooks/checkedLegendItemsStatus'; @@ -523,7 +526,7 @@ function HistogramViz(props: VisualizationProps) { ); const overlayVocabulary = - options?.getOverlayVocabulary?.() ?? + (overlayVariable && options?.getOverlayVocabulary?.()) ?? fixLabelsForNumberVariables( overlayVariable?.vocabulary, overlayVariable @@ -883,6 +886,10 @@ function HistogramViz(props: VisualizationProps) { max: truncationConfigDependentAxisMax, }, }, + colorPalette: + options?.getOverlayType?.() === 'continuous' + ? SequentialGradientColorscale + : ColorPaletteDefault, ...neutralPaletteProps, }; diff --git a/packages/libs/eda/src/lib/core/components/visualizations/implementations/LineplotVisualization.tsx b/packages/libs/eda/src/lib/core/components/visualizations/implementations/LineplotVisualization.tsx index 562deff1ae..b38df9d7dc 100755 --- a/packages/libs/eda/src/lib/core/components/visualizations/implementations/LineplotVisualization.tsx +++ b/packages/libs/eda/src/lib/core/components/visualizations/implementations/LineplotVisualization.tsx @@ -91,6 +91,7 @@ import { gray } from '../colors'; import { AvailableUnitsAddon, ColorPaletteDefault, + SequentialGradientColorscale, } from '@veupathdb/components/lib/types/plots/addOns'; // import variable's metadata-based independent axis range utils import { VariablesByInputName } from '../../../utils/data-element-constraints'; @@ -321,6 +322,12 @@ function LineplotViz(props: VisualizationProps) { providedOverlayVariableDescriptor ); + const colorPaletteOverride = + neutralPaletteProps.colorPalette ?? + options?.getOverlayType?.() === 'continuous' + ? SequentialGradientColorscale + : undefined; + const findEntityAndVariable = useFindEntityAndVariable(filters); const { @@ -741,7 +748,7 @@ function LineplotViz(props: VisualizationProps) { xAxisVariable ); const overlayVocabulary = - options?.getOverlayVocabulary?.() ?? + (overlayVariable && options?.getOverlayVocabulary?.()) ?? fixLabelsForNumberVariables( overlayVariable?.vocabulary, overlayVariable @@ -765,7 +772,7 @@ function LineplotViz(props: VisualizationProps) { showMissingFacet, facetVocabulary, facetVariable, - neutralPaletteProps.colorPalette + colorPaletteOverride ); }, [ outputEntity, diff --git a/packages/libs/eda/src/lib/core/components/visualizations/implementations/ScatterplotVisualization.tsx b/packages/libs/eda/src/lib/core/components/visualizations/implementations/ScatterplotVisualization.tsx index e9ea666b19..32ae45d183 100755 --- a/packages/libs/eda/src/lib/core/components/visualizations/implementations/ScatterplotVisualization.tsx +++ b/packages/libs/eda/src/lib/core/components/visualizations/implementations/ScatterplotVisualization.tsx @@ -86,6 +86,7 @@ import { ColorPaletteDark, gradientSequentialColorscaleMap, gradientDivergingColorscaleMap, + SequentialGradientColorscale, } from '@veupathdb/components/lib/types/plots/addOns'; import { VariablesByInputName } from '../../../utils/data-element-constraints'; import { useRouteMatch } from 'react-router'; @@ -354,7 +355,11 @@ function ScatterplotViz(props: VisualizationProps) { vizConfig.overlayVariable, providedOverlayVariableDescriptor ); - + const colorPaletteOverride = + neutralPaletteProps.colorPalette ?? + options?.getOverlayType?.() === 'continuous' + ? SequentialGradientColorscale + : ColorPaletteDefault; const findEntityAndVariable = useFindEntityAndVariable(filters); const { @@ -780,7 +785,10 @@ function ScatterplotViz(props: VisualizationProps) { ? response.scatterplot.config.variables.find( (v) => v.plotReference === 'overlay' && v.vocabulary != null )?.vocabulary - : options?.getOverlayVocabulary?.() ?? + : // TO DO: remove the categorical condition when https://github.com/VEuPathDB/EdaNewIssues/issues/642 is sorted + (overlayVariable && options?.getOverlayType?.() === 'categorical' + ? options?.getOverlayVocabulary?.() + : undefined) ?? fixLabelsForNumberVariables( overlayVariable?.vocabulary, overlayVariable @@ -802,7 +810,7 @@ function ScatterplotViz(props: VisualizationProps) { // pass computation computation.descriptor.type, entities, - neutralPaletteProps.colorPalette + colorPaletteOverride ); return { ...returnData,