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

Commit

Permalink
feat(COR-1811): Different way of using interactive legend (#4908)
Browse files Browse the repository at this point in the history
Co-authored-by: VWSCoronaDashboard29 <B>
  • Loading branch information
ben-van-eekelen authored Oct 23, 2023
1 parent f38f823 commit 067ad0f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/app/src/components/interactive-legend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function InteractiveLegend<T = string>({ helpText, selectOptions, selecti
const isSelected = selection.includes(item.metricProperty);
return (
<Item key={item.label}>
<StyledLabel htmlFor={`checkboxgroup-${item.label}`} isActive={hasSelection && isSelected} borderColor={item.color} data-text={item.label}>
<StyledLabel htmlFor={`checkboxgroup-${item.metricProperty}`} isActive={hasSelection && isSelected} borderColor={item.color} data-text={item.label}>
{item.label}
{item.shape === 'line' && <Line color={item.color} />}
{item.shape === 'dashed' && (
Expand All @@ -51,7 +51,7 @@ export function InteractiveLegend<T = string>({ helpText, selectOptions, selecti
</StyledLabel>
<StyledInput
type="checkbox"
id={`checkboxgroup-${item.label}`}
id={`checkboxgroup-${item.metricProperty}`}
value={item.label}
onClick={() => onToggleItem(item.metricProperty)}
aria-label={item.legendAriaLabel}
Expand Down
10 changes: 10 additions & 0 deletions packages/app/src/domain/variants/logic/use-bar-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ const extractVariantNamesFromValues = (values: VariantChartValue[]) => {
.filter((keyName) => keyName.endsWith('_occurrence'));
};

/**
* Create configuration labels for interactive legend
* @param values
* @param selectedOptions
* @param variantLabels
* @param tooltipLabels
* @param colors
* @param timeframe
* @param today
*/
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] + ' '; // THIS IS NECESSARY TO DIFFERENTIATE STATE BETWEEN THE TWO INTERACTIVE LEGENDS ON THE PAGE;
const variantDynamicLabel = text.variantCodes[variantCode];

// Match appropriate variant color
const color = colors.find((variantColors) => variantColors.variant === variantCode)?.color;
Expand Down

0 comments on commit 067ad0f

Please sign in to comment.