Skip to content

Commit

Permalink
final fixes and note about scatter TO DO
Browse files Browse the repository at this point in the history
  • Loading branch information
bobular committed May 13, 2023
1 parent f87eb16 commit 6f83513
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -454,7 +457,7 @@ function BarplotViz(props: VisualizationProps<Options>) {
variable
);
const overlayVocabulary =
options?.getOverlayVocabulary?.() ??
(overlayVariable && options?.getOverlayVocabulary?.()) ??
fixLabelsForNumberVariables(
overlayVariable?.vocabulary,
overlayVariable
Expand Down Expand Up @@ -680,6 +683,10 @@ function BarplotViz(props: VisualizationProps<Options>) {
max: truncationConfigDependentAxisMax,
},
},
colorPalette:
options?.getOverlayType?.() === 'continuous'
? SequentialGradientColorscale
: ColorPaletteDefault,
...neutralPaletteProps,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ function BoxplotViz(props: VisualizationProps<Options>) {
xAxisVariable
);
const overlayVocabulary =
options?.getOverlayVocabulary?.() ??
(overlayVariable && options?.getOverlayVocabulary?.()) ??
fixLabelsForNumberVariables(
overlayVariable?.vocabulary,
overlayVariable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -523,7 +526,7 @@ function HistogramViz(props: VisualizationProps<Options>) {
);

const overlayVocabulary =
options?.getOverlayVocabulary?.() ??
(overlayVariable && options?.getOverlayVocabulary?.()) ??
fixLabelsForNumberVariables(
overlayVariable?.vocabulary,
overlayVariable
Expand Down Expand Up @@ -883,6 +886,10 @@ function HistogramViz(props: VisualizationProps<Options>) {
max: truncationConfigDependentAxisMax,
},
},
colorPalette:
options?.getOverlayType?.() === 'continuous'
? SequentialGradientColorscale
: ColorPaletteDefault,
...neutralPaletteProps,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -321,6 +322,12 @@ function LineplotViz(props: VisualizationProps<Options>) {
providedOverlayVariableDescriptor
);

const colorPaletteOverride =
neutralPaletteProps.colorPalette ??
options?.getOverlayType?.() === 'continuous'
? SequentialGradientColorscale
: undefined;

const findEntityAndVariable = useFindEntityAndVariable(filters);

const {
Expand Down Expand Up @@ -741,7 +748,7 @@ function LineplotViz(props: VisualizationProps<Options>) {
xAxisVariable
);
const overlayVocabulary =
options?.getOverlayVocabulary?.() ??
(overlayVariable && options?.getOverlayVocabulary?.()) ??
fixLabelsForNumberVariables(
overlayVariable?.vocabulary,
overlayVariable
Expand All @@ -765,7 +772,7 @@ function LineplotViz(props: VisualizationProps<Options>) {
showMissingFacet,
facetVocabulary,
facetVariable,
neutralPaletteProps.colorPalette
colorPaletteOverride
);
}, [
outputEntity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -354,7 +355,11 @@ function ScatterplotViz(props: VisualizationProps<Options>) {
vizConfig.overlayVariable,
providedOverlayVariableDescriptor
);

const colorPaletteOverride =
neutralPaletteProps.colorPalette ??
options?.getOverlayType?.() === 'continuous'
? SequentialGradientColorscale
: ColorPaletteDefault;
const findEntityAndVariable = useFindEntityAndVariable(filters);

const {
Expand Down Expand Up @@ -780,7 +785,10 @@ function ScatterplotViz(props: VisualizationProps<Options>) {
? 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
Expand All @@ -802,7 +810,7 @@ function ScatterplotViz(props: VisualizationProps<Options>) {
// pass computation
computation.descriptor.type,
entities,
neutralPaletteProps.colorPalette
colorPaletteOverride
);
return {
...returnData,
Expand Down

0 comments on commit 6f83513

Please sign in to comment.