Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
fix(COR-1811): Add differentation between states of interactiveLegends
Browse files Browse the repository at this point in the history
  • Loading branch information
VWSCoronaDashboard29 authored and VWSCoronaDashboard29 committed Oct 19, 2023
1 parent 876f72d commit 9ad7576
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
1 change: 0 additions & 1 deletion packages/app/src/domain/variants/logic/use-bar-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const extractVariantNamesFromValues = (values: VariantChartValue[]) => {
.filter((keyName, index, array) => array.indexOf(keyName) === index)
.filter((keyName) => keyName.endsWith('_occurrence'));
};

export const useBarConfig = (
values: VariantChartValue[],
selectedOptions: (keyof VariantChartValue)[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const useSeriesConfig = (
const variantCode = variantCodeFragments.join('_');

// Match mnenonic variant name in lokalize to code-based variant name
const variantDynamicLabel = text.variantCodes[variantCode];
const variantDynamicLabel = text.variantCodes[variantCode] + ' '; // THIS IS NECESSARY TO DIFFERENTIATE STATE BETWEEN THE TWO INTERACTIVE LEGENDS ON THE PAGE;

// Match appropriate variant color
const color = colors.find((variantColors) => variantColors.variant === variantCode)?.color;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,11 @@ export const VariantsStackedBarChartTile = ({ title, description, helpText, valu

const { list, toggle, clear } = useList<keyof VariantChartValue>(alwaysEnabled);

const selectedOptions = list;

const [variantTimeFrame, setVariantTimeFrame] = useState<TimeframeOption>(TimeframeOption.THREE_MONTHS);

const [barChartConfig, selectionOptions] = useBarConfig(values, selectedOptions, variantLabels, variantColors, variantTimeFrame, today);
const [barChartConfig, selectionOptions] = useBarConfig(values, list, variantLabels, variantColors, variantTimeFrame, today);

const hasTwoColumns = selectedOptions.length === 0 || selectedOptions.length > 4;
const hasTwoColumns = list.length === 0 || list.length > 4;

return (
<ChartTile
Expand All @@ -90,7 +88,7 @@ export const VariantsStackedBarChartTile = ({ title, description, helpText, valu
timeframeInitialValue={TimeframeOption.THREE_MONTHS}
onSelectTimeframe={setVariantTimeFrame}
>
<InteractiveLegend helpText={helpText} selectOptions={selectionOptions} selection={selectedOptions} onToggleItem={toggle} onReset={clear} />
<InteractiveLegend helpText={helpText} selectOptions={selectionOptions} selection={list} onToggleItem={toggle} onReset={clear} />
<Spacer marginBottom={space[2]} />
<StackedChart
accessibility={{
Expand Down

0 comments on commit 9ad7576

Please sign in to comment.