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

Commit

Permalink
feature/COR-1260-variants-colour-updates (#4537)
Browse files Browse the repository at this point in the history
* feat(variants): updated colour order for variant colours; updated getVariantOrderColors function to filter out variants with an 'other'-prefix; updated VariantStackedAreaTile component to set the default timeframe selection to three months, to simplify the component and to remove unused logic;

Co-authored-by: VWSCoronaDashboard26 <[email protected]>
  • Loading branch information
VWSCoronaDashboard26 and VWSCoronaDashboard26 authored Dec 16, 2022
1 parent 4cc1dd7 commit 35a3aaa
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 300 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NlVariants, colors } from '@corona-dashboard/common';
import { isDefined } from 'ts-is-present';
import { VariantCode } from './'
import { VariantCode } from './';

export type ColorMatch = {
variant: VariantCode;
Expand All @@ -12,29 +12,23 @@ const getColorForVariant = (variantCode: VariantCode, index: number): string =>
if (variantCode === 'other_graph') return colors.gray5;

return colors.variants.colorList[index];
}
};

export function getVariantOrderColors(
variants: NlVariants | undefined
): ColorMatch[] {
export const getVariantOrderColors = (variants: NlVariants | undefined): ColorMatch[] => {
if (!isDefined(variants) || !isDefined(variants.values)) {
return [];
}

const colorOrder = variants.values
.filter(
(variant) =>
variant.last_value.is_variant_of_concern ||
variant.last_value.has_historical_significance
)
.sort((a, b) => a.last_value.order - b.last_value.order)
.filter((variant) => variant.last_value.is_variant_of_concern || variant.last_value.has_historical_significance)
.sort((a, b) => (a.variant_code.includes('other') || b.variant_code.includes('other') ? -1 : a.last_value.order - b.last_value.order))
.map((variant, index) => {
const variantColor = getColorForVariant(variant.variant_code, index)
const variantColor = getColorForVariant(variant.variant_code, index);
return {
variant: variant.variant_code,
color: variantColor
color: variantColor,
};
});
});

return colorOrder;
}
};
Loading

0 comments on commit 35a3aaa

Please sign in to comment.