This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature/COR-1811 adjust variant page (#4907)
* feat(COR-1811): Add kpi section to variants page and update metadataprops * feat(COR-1811): Variants table arrows color * refactor(COR-1811): Refactor functions * feat(COR-1811): Show variants table conditionally * feat(COR-1811): Update schema for archived variants * feat(COR-1811): Regenerate datatypes based on schema update * feat(COR-1811): Archive variants graph * refactor(COR-1811): Refactored variants components * fix: Add parameters to nextJS dev server * refactor: Split useSeriesConfig into seperate file * task: create semi-working prototype for bar chart * feat(COR-1811): Build variant bar chart * feat(COR-1811): Add comment * feat(COR-1811): Update barchart to timeframe * fix(COR-1811): Add differentation between states of interactiveLegends * feat(COR-1811): Calculate total variants in frontend * feat(COR-1811): Refactor keys and add comments * feat(COR-1811): Add key mutations --------- Co-authored-by: VWSCoronaDashboard29 <B>
- Loading branch information
1 parent
bc78169
commit 51f74db
Showing
37 changed files
with
659 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"title": "archived_nl_variants", | ||
"required": ["values"], | ||
"additionalProperties": false, | ||
"properties": { | ||
"values": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/variant" | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"variant": { | ||
"type": "object", | ||
"title": "archived_nl_variants_variant", | ||
"additionalProperties": false, | ||
"required": ["variant_code", "values", "last_value"], | ||
"properties": { | ||
"variant_code": { | ||
"type": "string" | ||
}, | ||
"values": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/value" | ||
} | ||
}, | ||
"last_value": { | ||
"$ref": "#/definitions/value" | ||
} | ||
} | ||
}, | ||
"value": { | ||
"type": "object", | ||
"title": "archived_nl_variants_variant_value", | ||
"additionalProperties": false, | ||
"required": [ | ||
"order", | ||
"occurrence", | ||
"percentage", | ||
"sample_size", | ||
"date_start_unix", | ||
"date_end_unix", | ||
"date_of_report_unix", | ||
"date_of_insertion_unix", | ||
"label_nl", | ||
"label_en" | ||
], | ||
"properties": { | ||
"order": { | ||
"type": "integer" | ||
}, | ||
"occurrence": { | ||
"type": "integer" | ||
}, | ||
"percentage": { | ||
"type": "number" | ||
}, | ||
"sample_size": { | ||
"type": "integer" | ||
}, | ||
"date_start_unix": { | ||
"type": "integer" | ||
}, | ||
"date_end_unix": { | ||
"type": "integer" | ||
}, | ||
"date_of_insertion_unix": { | ||
"type": "integer" | ||
}, | ||
"date_of_report_unix": { | ||
"type": "integer" | ||
}, | ||
"label_nl": { | ||
"type": "string" | ||
}, | ||
"label_en": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
packages/app/src/domain/variants/data-selection/get-variant-bar-chart-data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { NlVariants } from '@corona-dashboard/common'; | ||
import { isDefined } from 'ts-is-present'; | ||
import { VariantChartValue } from '~/domain/variants/data-selection/types'; | ||
|
||
const EMPTY_VALUES = { | ||
variantChart: null, | ||
dates: { | ||
date_of_report_unix: 0, | ||
date_start_unix: 0, | ||
date_end_unix: 0, | ||
}, | ||
} as const; | ||
|
||
/** | ||
* Returns values for variant timeseries chart | ||
* @param variants | ||
*/ | ||
export function getVariantBarChartData(variants: NlVariants) { | ||
if (!isDefined(variants) || !isDefined(variants.values)) { | ||
return EMPTY_VALUES; | ||
} | ||
|
||
const sortedVariants = variants.values.sort((a, b) => b.last_value.order - a.last_value.order); | ||
|
||
const firstVariantInList = sortedVariants.shift(); | ||
|
||
if (!isDefined(firstVariantInList)) { | ||
return EMPTY_VALUES; | ||
} | ||
|
||
const values = firstVariantInList.values.map<VariantChartValue>((value, index) => { | ||
const item = { | ||
is_reliable: true, | ||
date_start_unix: value.date_start_unix, | ||
date_end_unix: value.date_end_unix, | ||
[`${firstVariantInList.variant_code}_occurrence`]: value.occurrence, | ||
} as VariantChartValue; | ||
|
||
sortedVariants.forEach((variant) => { | ||
(item as unknown as Record<string, number>)[`${variant.variant_code}_occurrence`] = variant.values[index].occurrence; | ||
}); | ||
|
||
return item; | ||
}); | ||
|
||
return { | ||
variantChart: values, | ||
dates: { | ||
date_of_report_unix: firstVariantInList.last_value.date_of_report_unix, | ||
date_start_unix: firstVariantInList.last_value.date_start_unix, | ||
date_end_unix: firstVariantInList.last_value.date_end_unix, | ||
}, | ||
} as const; | ||
} |
7 changes: 1 addition & 6 deletions
7
.../static-props/get-variant-order-colors.ts → ...ata-selection/get-variant-order-colors.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 2 additions & 13 deletions
15
...ts/static-props/get-variant-table-data.ts → .../data-selection/get-variant-table-data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './get-variant-bar-chart-data'; | ||
export * from './get-archived-variant-chart-data'; | ||
export * from './get-variant-order-colors'; | ||
export * from './get-variant-table-data'; |
Oops, something went wrong.