@genspectrum/dashboard-components 0.4.5 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/custom-elements.json +178 -102
- package/dist/dashboard-components.js +318 -147
- package/dist/dashboard-components.js.map +1 -1
- package/dist/genspectrum-components.d.ts +91 -55
- package/dist/style.css +34 -7
- package/package.json +5 -5
- package/src/preact/mutationComparison/mutation-comparison-venn.tsx +1 -1
- package/src/preact/mutationComparison/mutation-comparison.stories.tsx +18 -18
- package/src/preact/mutationComparison/mutation-comparison.tsx +6 -6
- package/src/preact/mutationComparison/queryMutationData.ts +4 -4
- package/src/preact/mutations/mutations.stories.tsx +3 -3
- package/src/preact/mutations/mutations.tsx +16 -6
- package/src/preact/mutations/queryMutations.ts +3 -3
- package/src/preact/prevalenceOverTime/__mockData__/{denominatorOneVariant.json → denominatorFilterOneDataset.json} +1 -1
- package/src/preact/prevalenceOverTime/__mockData__/{numeratorOneVariant.json → numeratorFilterOneDataset.json} +1 -1
- package/src/preact/prevalenceOverTime/prevalence-over-time-bar-chart.tsx +42 -5
- package/src/preact/prevalenceOverTime/prevalence-over-time-bubble-chart.tsx +26 -7
- package/src/preact/prevalenceOverTime/prevalence-over-time-line-chart.tsx +62 -28
- package/src/preact/prevalenceOverTime/prevalence-over-time.stories.tsx +26 -16
- package/src/preact/prevalenceOverTime/prevalence-over-time.tsx +38 -11
- package/src/preact/relativeGrowthAdvantage/relative-growth-advantage-chart.tsx +39 -7
- package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.stories.tsx +10 -4
- package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.tsx +19 -10
- package/src/preact/shared/charts/confideceInterval.ts +7 -2
- package/src/preact/shared/charts/getYAxisMax.ts +24 -0
- package/src/preact/shared/charts/getYAxisScale.ts +1 -3
- package/src/query/queryAggregateData.ts +2 -2
- package/src/query/queryInsertions.ts +7 -2
- package/src/query/querySubstitutionsOrDeletions.ts +2 -2
- package/src/web-components/input/gs-date-range-selector.tsx +1 -1
- package/src/web-components/input/gs-location-filter.tsx +1 -1
- package/src/web-components/input/gs-mutation-filter.tsx +1 -1
- package/src/web-components/input/gs-text-input.tsx +1 -1
- package/src/web-components/visualization/gs-aggregate.tsx +2 -2
- package/src/web-components/visualization/gs-mutation-comparison.stories.ts +12 -12
- package/src/web-components/visualization/gs-mutation-comparison.tsx +18 -19
- package/src/web-components/visualization/gs-mutations.stories.ts +4 -4
- package/src/web-components/visualization/gs-mutations.tsx +10 -11
- package/src/web-components/visualization/gs-prevalence-over-time.stories.ts +46 -35
- package/src/web-components/visualization/gs-prevalence-over-time.tsx +54 -20
- package/src/web-components/visualization/gs-relative-growth-advantage.stories.ts +32 -18
- package/src/web-components/visualization/gs-relative-growth-advantage.tsx +51 -13
- /package/src/preact/mutationComparison/__mockData__/{nucleotideMutationsOtherVariant.json → nucleotideMutationsOtherDataset.json} +0 -0
- /package/src/preact/mutationComparison/__mockData__/{nucleotideMutationsSomeVariant.json → nucleotideMutationsSomeDataset.json} +0 -0
- /package/src/preact/prevalenceOverTime/__mockData__/{denominator.json → denominatorFilter.json} +0 -0
- /package/src/preact/prevalenceOverTime/__mockData__/{numeratorEG.json → numeratorFilterEG.json} +0 -0
- /package/src/preact/prevalenceOverTime/__mockData__/{numeratorJN1.json → numeratorFilterJN1.json} +0 -0
- /package/src/preact/relativeGrowthAdvantage/__mockData__/{denominator.json → denominatorFilter.json} +0 -0
- /package/src/preact/relativeGrowthAdvantage/__mockData__/{numerator.json → numeratorFilter.json} +0 -0
|
@@ -7,8 +7,8 @@ import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsS
|
|
|
7
7
|
/**
|
|
8
8
|
* ## Context
|
|
9
9
|
*
|
|
10
|
-
* This component allows to compare mutations between different
|
|
11
|
-
*
|
|
10
|
+
* This component allows to compare mutations between two different datasets.
|
|
11
|
+
* The datasets are selected by LAPIS filters.
|
|
12
12
|
*
|
|
13
13
|
* It only shows substitutions and deletions, it does not show insertions.
|
|
14
14
|
*
|
|
@@ -16,34 +16,33 @@ import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsS
|
|
|
16
16
|
*
|
|
17
17
|
* ### Table View
|
|
18
18
|
*
|
|
19
|
-
* The table view shows mutations
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* and where the proportion is within the selected proportion interval for at least one variant.
|
|
19
|
+
* The table view shows mutations and the proportions with which the mutation occurs in the respective data subsets.
|
|
20
|
+
* It only shows mutations that are present in at least one of the data subsets
|
|
21
|
+
* and where the proportion is within the selected proportion interval for at least one data subset.
|
|
23
22
|
*
|
|
24
23
|
* ### Venn View
|
|
25
24
|
*
|
|
26
|
-
* The Venn view shows the overlap of mutations between the
|
|
27
|
-
* A
|
|
28
|
-
*
|
|
29
|
-
* Thus, changing the proportion interval may change a mutations from being "common" between
|
|
30
|
-
* to being "for one
|
|
25
|
+
* The Venn view shows the overlap of mutations between the datasets in a Venn diagram.
|
|
26
|
+
* A dataset is considered to have a certain mutation, if the proportion of the mutation in the dataset is within the
|
|
27
|
+
* selected proportion interval.
|
|
28
|
+
* Thus, changing the proportion interval may change a mutations from being "common" between the datasets
|
|
29
|
+
* to being "for one dataset only".
|
|
31
30
|
*/
|
|
32
31
|
@customElement('gs-mutation-comparison')
|
|
33
32
|
export class MutationComparisonComponent extends PreactLitAdapterWithGridJsStyles {
|
|
34
33
|
/**
|
|
35
34
|
* Required.
|
|
36
35
|
*
|
|
37
|
-
* An array of
|
|
36
|
+
* An array of LAPIS filters to select the data to compare.
|
|
38
37
|
*
|
|
39
38
|
* The `lapisFilter` will be sent as is to LAPIS to filter the mutation data.
|
|
40
39
|
* It must be a valid LAPIS filter object.
|
|
41
40
|
*
|
|
42
|
-
* The `displayName` will be used as the label for the
|
|
41
|
+
* The `displayName` will be used as the label for the filtered dataset in the views.
|
|
43
42
|
* It should be human-readable.
|
|
44
43
|
*/
|
|
45
44
|
@property({ type: Array })
|
|
46
|
-
|
|
45
|
+
lapisFilters: {
|
|
47
46
|
lapisFilter: Record<string, string | number | null | boolean>;
|
|
48
47
|
displayName: string;
|
|
49
48
|
}[] = [];
|
|
@@ -63,7 +62,7 @@ export class MutationComparisonComponent extends PreactLitAdapterWithGridJsStyle
|
|
|
63
62
|
/**
|
|
64
63
|
* The width of the component.
|
|
65
64
|
*
|
|
66
|
-
* Visit https://genspectrum.github.io/
|
|
65
|
+
* Visit https://genspectrum.github.io/dashboard-components/?path=/docs/components-size-of-components--docs for more information.
|
|
67
66
|
*/
|
|
68
67
|
@property({ type: String })
|
|
69
68
|
width: string = '100%';
|
|
@@ -71,7 +70,7 @@ export class MutationComparisonComponent extends PreactLitAdapterWithGridJsStyle
|
|
|
71
70
|
/**
|
|
72
71
|
* The height of the component.
|
|
73
72
|
*
|
|
74
|
-
* Visit https://genspectrum.github.io/
|
|
73
|
+
* Visit https://genspectrum.github.io/dashboard-components/?path=/docs/components-size-of-components--docs for more information.
|
|
75
74
|
*/
|
|
76
75
|
@property({ type: String })
|
|
77
76
|
height: string = '700px';
|
|
@@ -92,7 +91,7 @@ export class MutationComparisonComponent extends PreactLitAdapterWithGridJsStyle
|
|
|
92
91
|
override render() {
|
|
93
92
|
return (
|
|
94
93
|
<MutationComparison
|
|
95
|
-
|
|
94
|
+
lapisFilters={this.lapisFilters}
|
|
96
95
|
sequenceType={this.sequenceType}
|
|
97
96
|
views={this.views}
|
|
98
97
|
width={this.width}
|
|
@@ -111,8 +110,8 @@ declare global {
|
|
|
111
110
|
}
|
|
112
111
|
|
|
113
112
|
/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
|
|
114
|
-
type
|
|
115
|
-
Equals<typeof MutationComparisonComponent.prototype.
|
|
113
|
+
type LapisFiltersMatches = Expect<
|
|
114
|
+
Equals<typeof MutationComparisonComponent.prototype.lapisFilters, MutationComparisonProps['lapisFilters']>
|
|
116
115
|
>;
|
|
117
116
|
type SequenceTypeMatches = Expect<
|
|
118
117
|
Equals<typeof MutationComparisonComponent.prototype.sequenceType, MutationComparisonProps['sequenceType']>
|
|
@@ -13,7 +13,7 @@ import { withinShadowRoot } from '../withinShadowRoot.story';
|
|
|
13
13
|
|
|
14
14
|
const codeExample = String.raw`
|
|
15
15
|
<gs-mutations
|
|
16
|
-
|
|
16
|
+
lapisFilter='{ "country": "Switzerland", "pangoLineage": "B.1.1.7", "dateTo": "2022-01-01" }'
|
|
17
17
|
sequenceType="nucleotide"
|
|
18
18
|
views='["grid", "table", "insertions"]'
|
|
19
19
|
headline="Mutations"
|
|
@@ -26,7 +26,7 @@ const meta: Meta<Required<MutationsProps>> = {
|
|
|
26
26
|
title: 'Visualization/Mutations',
|
|
27
27
|
component: 'gs-mutations',
|
|
28
28
|
argTypes: {
|
|
29
|
-
|
|
29
|
+
lapisFilter: { control: 'object' },
|
|
30
30
|
sequenceType: {
|
|
31
31
|
options: ['nucleotide', 'amino acid'],
|
|
32
32
|
control: { type: 'radio' },
|
|
@@ -41,7 +41,7 @@ const meta: Meta<Required<MutationsProps>> = {
|
|
|
41
41
|
pageSize: { control: 'object' },
|
|
42
42
|
},
|
|
43
43
|
args: {
|
|
44
|
-
|
|
44
|
+
lapisFilter: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateTo: '2022-01-01' },
|
|
45
45
|
sequenceType: 'nucleotide',
|
|
46
46
|
views: ['grid', 'table', 'insertions'],
|
|
47
47
|
width: '100%',
|
|
@@ -65,7 +65,7 @@ const Template: StoryObj<Required<MutationsProps>> = {
|
|
|
65
65
|
render: (args) => html`
|
|
66
66
|
<gs-app lapis="${LAPIS_URL}">
|
|
67
67
|
<gs-mutations
|
|
68
|
-
.
|
|
68
|
+
.lapisFilter=${args.lapisFilter}
|
|
69
69
|
.sequenceType=${args.sequenceType}
|
|
70
70
|
.views=${args.views}
|
|
71
71
|
.width=${args.width}
|
|
@@ -8,15 +8,15 @@ import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsS
|
|
|
8
8
|
/**
|
|
9
9
|
* ## Context
|
|
10
10
|
*
|
|
11
|
-
* This component displays mutations (substitutions, deletions and insertions) for a
|
|
11
|
+
* This component displays mutations (substitutions, deletions and insertions) for a dataset selected by a LAPIS filter.
|
|
12
12
|
*
|
|
13
13
|
* ## Views
|
|
14
14
|
*
|
|
15
15
|
* ### Table View
|
|
16
16
|
*
|
|
17
|
-
* The table view shows all substitutions and deletions for the
|
|
17
|
+
* The table view shows all substitutions and deletions for the dataset.
|
|
18
18
|
* It shows the type (substitution or deletion), the total count of the mutation
|
|
19
|
-
* and the proportion of the mutation in the
|
|
19
|
+
* and the proportion of the mutation in the dataset.
|
|
20
20
|
* The proportion is relative to the total number of sequences matching
|
|
21
21
|
* the specified sequence filters with non-ambiguous reads at that position.
|
|
22
22
|
*
|
|
@@ -29,7 +29,7 @@ import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsS
|
|
|
29
29
|
*
|
|
30
30
|
* ### Insertions View
|
|
31
31
|
*
|
|
32
|
-
* The insertions view shows the count of all insertions for the
|
|
32
|
+
* The insertions view shows the count of all insertions for the dataset.
|
|
33
33
|
*
|
|
34
34
|
*/
|
|
35
35
|
@customElement('gs-mutations')
|
|
@@ -37,11 +37,10 @@ export class MutationsComponent extends PreactLitAdapterWithGridJsStyles {
|
|
|
37
37
|
/**
|
|
38
38
|
* Required.
|
|
39
39
|
*
|
|
40
|
-
*
|
|
41
|
-
* It must be a valid LAPIS filter object.
|
|
40
|
+
* LAPIS filter to select the displayed data.
|
|
42
41
|
*/
|
|
43
42
|
@property({ type: Object })
|
|
44
|
-
|
|
43
|
+
lapisFilter: Record<string, string | number | null | boolean> = {};
|
|
45
44
|
|
|
46
45
|
/**
|
|
47
46
|
* The type of the sequence for which the mutations should be shown.
|
|
@@ -58,7 +57,7 @@ export class MutationsComponent extends PreactLitAdapterWithGridJsStyles {
|
|
|
58
57
|
/**
|
|
59
58
|
* The width of the component.
|
|
60
59
|
*
|
|
61
|
-
* Visit https://genspectrum.github.io/
|
|
60
|
+
* Visit https://genspectrum.github.io/dashboard-components/?path=/docs/components-size-of-components--docs for more information.
|
|
62
61
|
*/
|
|
63
62
|
@property({ type: String })
|
|
64
63
|
width: string = '100%';
|
|
@@ -66,7 +65,7 @@ export class MutationsComponent extends PreactLitAdapterWithGridJsStyles {
|
|
|
66
65
|
/**
|
|
67
66
|
* The height of the component.
|
|
68
67
|
*
|
|
69
|
-
* Visit https://genspectrum.github.io/
|
|
68
|
+
* Visit https://genspectrum.github.io/dashboard-components/?path=/docs/components-size-of-components--docs for more information.
|
|
70
69
|
*/
|
|
71
70
|
@property({ type: String })
|
|
72
71
|
height: string = '700px';
|
|
@@ -87,7 +86,7 @@ export class MutationsComponent extends PreactLitAdapterWithGridJsStyles {
|
|
|
87
86
|
override render() {
|
|
88
87
|
return (
|
|
89
88
|
<Mutations
|
|
90
|
-
|
|
89
|
+
lapisFilter={this.lapisFilter}
|
|
91
90
|
sequenceType={this.sequenceType}
|
|
92
91
|
views={this.views}
|
|
93
92
|
width={this.width}
|
|
@@ -106,7 +105,7 @@ declare global {
|
|
|
106
105
|
}
|
|
107
106
|
|
|
108
107
|
/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
|
|
109
|
-
type
|
|
108
|
+
type LapisFilterMatches = Expect<Equals<typeof MutationsComponent.prototype.lapisFilter, LapisFilter>>;
|
|
110
109
|
type SequenceTypeMatches = Expect<Equals<typeof MutationsComponent.prototype.sequenceType, SequenceType>>;
|
|
111
110
|
type ViewsMatches = Expect<Equals<typeof MutationsComponent.prototype.views, View[]>>;
|
|
112
111
|
/* eslint-enable @typescript-eslint/no-unused-vars, no-unused-vars */
|
|
@@ -4,20 +4,21 @@ import { html } from 'lit';
|
|
|
4
4
|
|
|
5
5
|
import '../app';
|
|
6
6
|
import './gs-prevalence-over-time';
|
|
7
|
+
// eslint-disable-next-line no-duplicate-imports
|
|
8
|
+
import { type PrevalenceOverTimeComponentProps } from './gs-prevalence-over-time';
|
|
7
9
|
import { withComponentDocs } from '../../../.storybook/ComponentDocsBlock';
|
|
8
10
|
import { AGGREGATED_ENDPOINT, LAPIS_URL } from '../../constants';
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import { type PrevalenceOverTimeProps } from '../../preact/prevalenceOverTime/prevalence-over-time';
|
|
11
|
+
import denominatorFilter from '../../preact/prevalenceOverTime/__mockData__/denominatorFilter.json';
|
|
12
|
+
import denominatorFilterOneDataset from '../../preact/prevalenceOverTime/__mockData__/denominatorFilterOneDataset.json';
|
|
13
|
+
import numeratorFilterEG from '../../preact/prevalenceOverTime/__mockData__/numeratorFilterEG.json';
|
|
14
|
+
import numeratorFilterJN1 from '../../preact/prevalenceOverTime/__mockData__/numeratorFilterJN1.json';
|
|
15
|
+
import numeratorFilterOneDataset from '../../preact/prevalenceOverTime/__mockData__/numeratorFilterOneDataset.json';
|
|
15
16
|
import { withinShadowRoot } from '../withinShadowRoot.story';
|
|
16
17
|
|
|
17
18
|
const codeExample = String.raw`
|
|
18
19
|
<gs-prevalence-over-time
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
numeratorFilter='[{ "displayName": "EG", "lapisFilter": { "country": "USA", "pangoLineage": "EG*" }}, { "displayName": "JN.1", "lapisFilter": { "country": "USA", "pangoLineage": "JN.1*" }}]'
|
|
21
|
+
denominatorFilter='{ "country": "USA"}'
|
|
21
22
|
granularity="month"
|
|
22
23
|
smoothingWindow="0"
|
|
23
24
|
views='["bar", "line", "bubble", "table"]'
|
|
@@ -27,14 +28,16 @@ const codeExample = String.raw`
|
|
|
27
28
|
height="700px"
|
|
28
29
|
lapisDateField="date"
|
|
29
30
|
pageSize="10"
|
|
31
|
+
yAxisMaxLinear="1"
|
|
32
|
+
yAxisMaxLogarithmic="limitTo1"
|
|
30
33
|
></gs-prevalence-over-time>`;
|
|
31
34
|
|
|
32
|
-
const meta: Meta<Required<
|
|
35
|
+
const meta: Meta<Required<PrevalenceOverTimeComponentProps>> = {
|
|
33
36
|
title: 'Visualization/Prevalence over time',
|
|
34
37
|
component: 'gs-prevalence-over-time',
|
|
35
38
|
argTypes: {
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
numeratorFilter: { control: 'object' },
|
|
40
|
+
denominatorFilter: { control: 'object' },
|
|
38
41
|
granularity: {
|
|
39
42
|
options: ['day', 'week', 'month', 'year'],
|
|
40
43
|
control: { type: 'radio' },
|
|
@@ -52,6 +55,8 @@ const meta: Meta<Required<PrevalenceOverTimeProps>> = {
|
|
|
52
55
|
height: { control: 'text' },
|
|
53
56
|
headline: { control: 'text' },
|
|
54
57
|
pageSize: { control: 'object' },
|
|
58
|
+
yAxisMaxLinear: { control: 'object' },
|
|
59
|
+
yAxisMaxLogarithmic: { control: 'object' },
|
|
55
60
|
},
|
|
56
61
|
parameters: withComponentDocs({
|
|
57
62
|
componentDocs: {
|
|
@@ -65,12 +70,12 @@ const meta: Meta<Required<PrevalenceOverTimeProps>> = {
|
|
|
65
70
|
|
|
66
71
|
export default meta;
|
|
67
72
|
|
|
68
|
-
const Template: StoryObj<Required<
|
|
73
|
+
const Template: StoryObj<Required<PrevalenceOverTimeComponentProps>> = {
|
|
69
74
|
render: (args) => html`
|
|
70
75
|
<gs-app lapis="${LAPIS_URL}">
|
|
71
76
|
<gs-prevalence-over-time
|
|
72
|
-
.
|
|
73
|
-
.
|
|
77
|
+
.numeratorFilter=${args.numeratorFilter}
|
|
78
|
+
.denominatorFilter=${args.denominatorFilter}
|
|
74
79
|
.granularity=${args.granularity}
|
|
75
80
|
.smoothingWindow=${args.smoothingWindow}
|
|
76
81
|
.views=${args.views}
|
|
@@ -80,19 +85,21 @@ const Template: StoryObj<Required<PrevalenceOverTimeProps>> = {
|
|
|
80
85
|
.headline=${args.headline}
|
|
81
86
|
.lapisDateField=${args.lapisDateField}
|
|
82
87
|
.pageSize=${args.pageSize}
|
|
88
|
+
.yAxisMaxLinear=${args.yAxisMaxLinear}
|
|
89
|
+
.yAxisMaxLogarithmic=${args.yAxisMaxLogarithmic}
|
|
83
90
|
></gs-prevalence-over-time>
|
|
84
91
|
</gs-app>
|
|
85
92
|
`,
|
|
86
93
|
};
|
|
87
94
|
|
|
88
|
-
export const
|
|
95
|
+
export const TwoDatasets: StoryObj<Required<PrevalenceOverTimeComponentProps>> = {
|
|
89
96
|
...Template,
|
|
90
97
|
args: {
|
|
91
|
-
|
|
98
|
+
numeratorFilter: [
|
|
92
99
|
{ displayName: 'EG', lapisFilter: { country: 'USA', pangoLineage: 'EG*', dateFrom: '2023-01-01' } },
|
|
93
100
|
{ displayName: 'JN.1', lapisFilter: { country: 'USA', pangoLineage: 'JN.1*', dateFrom: '2023-01-01' } },
|
|
94
101
|
],
|
|
95
|
-
|
|
102
|
+
denominatorFilter: { country: 'USA', dateFrom: '2023-01-01' },
|
|
96
103
|
granularity: 'month',
|
|
97
104
|
smoothingWindow: 0,
|
|
98
105
|
views: ['bar', 'line', 'bubble', 'table'],
|
|
@@ -102,6 +109,8 @@ export const TwoVariants: StoryObj<Required<PrevalenceOverTimeProps>> = {
|
|
|
102
109
|
headline: 'Prevalence over time',
|
|
103
110
|
lapisDateField: 'date',
|
|
104
111
|
pageSize: 10,
|
|
112
|
+
yAxisMaxLinear: 1,
|
|
113
|
+
yAxisMaxLogarithmic: 'limitTo1',
|
|
105
114
|
},
|
|
106
115
|
parameters: {
|
|
107
116
|
fetchMock: {
|
|
@@ -119,7 +128,7 @@ export const TwoVariants: StoryObj<Required<PrevalenceOverTimeProps>> = {
|
|
|
119
128
|
},
|
|
120
129
|
response: {
|
|
121
130
|
status: 200,
|
|
122
|
-
body:
|
|
131
|
+
body: numeratorFilterEG,
|
|
123
132
|
},
|
|
124
133
|
},
|
|
125
134
|
{
|
|
@@ -135,7 +144,7 @@ export const TwoVariants: StoryObj<Required<PrevalenceOverTimeProps>> = {
|
|
|
135
144
|
},
|
|
136
145
|
response: {
|
|
137
146
|
status: 200,
|
|
138
|
-
body:
|
|
147
|
+
body: numeratorFilterJN1,
|
|
139
148
|
},
|
|
140
149
|
},
|
|
141
150
|
{
|
|
@@ -150,7 +159,7 @@ export const TwoVariants: StoryObj<Required<PrevalenceOverTimeProps>> = {
|
|
|
150
159
|
},
|
|
151
160
|
response: {
|
|
152
161
|
status: 200,
|
|
153
|
-
body:
|
|
162
|
+
body: denominatorFilter,
|
|
154
163
|
},
|
|
155
164
|
},
|
|
156
165
|
],
|
|
@@ -158,16 +167,16 @@ export const TwoVariants: StoryObj<Required<PrevalenceOverTimeProps>> = {
|
|
|
158
167
|
},
|
|
159
168
|
};
|
|
160
169
|
|
|
161
|
-
export const
|
|
170
|
+
export const OneDataset: StoryObj<Required<PrevalenceOverTimeComponentProps>> = {
|
|
162
171
|
...Template,
|
|
163
172
|
args: {
|
|
164
|
-
|
|
173
|
+
numeratorFilter: {
|
|
165
174
|
displayName: 'EG',
|
|
166
175
|
lapisFilter: { country: 'USA', pangoLineage: 'BA.2.86*', dateFrom: '2023-10-01' },
|
|
167
176
|
},
|
|
168
|
-
|
|
169
|
-
granularity: '
|
|
170
|
-
smoothingWindow:
|
|
177
|
+
denominatorFilter: { country: 'USA', dateFrom: '2023-10-01' },
|
|
178
|
+
granularity: 'week',
|
|
179
|
+
smoothingWindow: 2,
|
|
171
180
|
views: ['bar', 'line', 'bubble', 'table'],
|
|
172
181
|
confidenceIntervalMethods: ['wilson'],
|
|
173
182
|
width: '100%',
|
|
@@ -175,13 +184,15 @@ export const OneVariant: StoryObj<Required<PrevalenceOverTimeProps>> = {
|
|
|
175
184
|
headline: 'Prevalence over time',
|
|
176
185
|
lapisDateField: 'date',
|
|
177
186
|
pageSize: 10,
|
|
187
|
+
yAxisMaxLinear: 1,
|
|
188
|
+
yAxisMaxLogarithmic: 'limitTo1',
|
|
178
189
|
},
|
|
179
190
|
parameters: {
|
|
180
191
|
fetchMock: {
|
|
181
192
|
mocks: [
|
|
182
193
|
{
|
|
183
194
|
matcher: {
|
|
184
|
-
name: '
|
|
195
|
+
name: 'numeratorOneDataset',
|
|
185
196
|
url: AGGREGATED_ENDPOINT,
|
|
186
197
|
body: {
|
|
187
198
|
country: 'USA',
|
|
@@ -192,12 +203,12 @@ export const OneVariant: StoryObj<Required<PrevalenceOverTimeProps>> = {
|
|
|
192
203
|
},
|
|
193
204
|
response: {
|
|
194
205
|
status: 200,
|
|
195
|
-
body:
|
|
206
|
+
body: numeratorFilterOneDataset,
|
|
196
207
|
},
|
|
197
208
|
},
|
|
198
209
|
{
|
|
199
210
|
matcher: {
|
|
200
|
-
name: '
|
|
211
|
+
name: 'denominatorOneDataset',
|
|
201
212
|
url: AGGREGATED_ENDPOINT,
|
|
202
213
|
body: {
|
|
203
214
|
country: 'USA',
|
|
@@ -207,7 +218,7 @@ export const OneVariant: StoryObj<Required<PrevalenceOverTimeProps>> = {
|
|
|
207
218
|
},
|
|
208
219
|
response: {
|
|
209
220
|
status: 200,
|
|
210
|
-
body:
|
|
221
|
+
body: denominatorFilterOneDataset,
|
|
211
222
|
},
|
|
212
223
|
},
|
|
213
224
|
],
|
|
@@ -215,8 +226,8 @@ export const OneVariant: StoryObj<Required<PrevalenceOverTimeProps>> = {
|
|
|
215
226
|
},
|
|
216
227
|
};
|
|
217
228
|
|
|
218
|
-
export const
|
|
219
|
-
...
|
|
229
|
+
export const OneDatasetOnLineTab: StoryObj<Required<PrevalenceOverTimeComponentProps>> = {
|
|
230
|
+
...OneDataset,
|
|
220
231
|
play: async ({ canvasElement }) => {
|
|
221
232
|
const canvas = await withinShadowRoot(canvasElement, 'gs-prevalence-over-time');
|
|
222
233
|
|
|
@@ -226,8 +237,8 @@ export const OneVariantOnLineTab: StoryObj<Required<PrevalenceOverTimeProps>> =
|
|
|
226
237
|
},
|
|
227
238
|
};
|
|
228
239
|
|
|
229
|
-
export const
|
|
230
|
-
...
|
|
240
|
+
export const OneDatasetOnBubbleTab: StoryObj<Required<PrevalenceOverTimeComponentProps>> = {
|
|
241
|
+
...OneDataset,
|
|
231
242
|
play: async ({ canvasElement }) => {
|
|
232
243
|
const canvas = await withinShadowRoot(canvasElement, 'gs-prevalence-over-time');
|
|
233
244
|
|
|
@@ -237,8 +248,8 @@ export const OneVariantOnBubbleTab: StoryObj<Required<PrevalenceOverTimeProps>>
|
|
|
237
248
|
},
|
|
238
249
|
};
|
|
239
250
|
|
|
240
|
-
export const
|
|
241
|
-
...
|
|
251
|
+
export const OneDatasetOnTableTab: StoryObj<Required<PrevalenceOverTimeComponentProps>> = {
|
|
252
|
+
...OneDataset,
|
|
242
253
|
play: async ({ canvasElement }) => {
|
|
243
254
|
const canvas = await withinShadowRoot(canvasElement, 'gs-prevalence-over-time');
|
|
244
255
|
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { customElement, property } from 'lit/decorators.js';
|
|
2
2
|
|
|
3
3
|
import { PrevalenceOverTime, type PrevalenceOverTimeProps } from '../../preact/prevalenceOverTime/prevalence-over-time';
|
|
4
|
+
import { type AxisMax } from '../../preact/shared/charts/getYAxisMax';
|
|
4
5
|
import { type Equals, type Expect } from '../../utils/typeAssertions';
|
|
5
6
|
import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsStyles';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* ## Context
|
|
9
10
|
*
|
|
10
|
-
* This component displays the prevalence over time of one or more
|
|
11
|
-
* The prevalence is calculated as the ratio of the number of cases of each
|
|
12
|
-
*
|
|
11
|
+
* This component displays the prevalence over time of one or more datasets, selected by LAPIS filters.
|
|
12
|
+
* The prevalence is calculated as the ratio of the number of cases of each dataset to the number of cases of a reference dataset.
|
|
13
|
+
* The reference dataset is also selected by a LAPIS filter.
|
|
13
14
|
*
|
|
14
15
|
* In the chart views,
|
|
15
16
|
* - the user can select whether to display a confidence interval (not available in the bubble chart).
|
|
@@ -23,19 +24,19 @@ import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsS
|
|
|
23
24
|
* ### Bar View
|
|
24
25
|
*
|
|
25
26
|
* Displays the prevalence over time as a bar chart.
|
|
26
|
-
* Shows a bar for each
|
|
27
|
+
* Shows a bar for each dataset of the `numeratorFilter` on every time step.
|
|
27
28
|
*
|
|
28
29
|
* ### Line View
|
|
29
30
|
*
|
|
30
31
|
* Displays the prevalence over time as a line chart.
|
|
31
32
|
* Each data point is connected for better visibility.
|
|
32
|
-
* Shows a line for each
|
|
33
|
+
* Shows a line for each dataset of the `numeratorFilter`.
|
|
33
34
|
*
|
|
34
35
|
* ### Bubble View
|
|
35
36
|
*
|
|
36
37
|
* Displays the prevalence over time as a bubble chart.
|
|
37
|
-
* The size of the bubbles represents the number of cases of the `
|
|
38
|
-
* The height of the bubbles represents the prevalence of the `
|
|
38
|
+
* The size of the bubbles represents the number of cases of the reference, defined by the `denominatorFilter`.
|
|
39
|
+
* The height of the bubbles represents the prevalence of the datasets selected by the `numeratorFilters`.
|
|
39
40
|
*
|
|
40
41
|
* ### Table View
|
|
41
42
|
*
|
|
@@ -47,14 +48,17 @@ export class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyle
|
|
|
47
48
|
// The multiline union type must not start with `|` because it looks weird in the Storybook docs
|
|
48
49
|
/**
|
|
49
50
|
* Required.
|
|
51
|
+
* Either a LAPIS filter or an array of LAPIS filters to calculate the prevalence for.
|
|
52
|
+
*
|
|
53
|
+
* The `lapisFilter` will be sent as is to LAPIS to select the data.
|
|
54
|
+
* It must be a valid LAPIS filter object.
|
|
55
|
+
*
|
|
56
|
+
* The `displayName` will be used as the label the prevalence in the views.
|
|
57
|
+
* It should be human-readable.
|
|
50
58
|
*
|
|
51
|
-
* Either a single variant or an array of variants to compare.
|
|
52
|
-
* This must be a valid LAPIS filter object with an additional `displayName` property
|
|
53
|
-
* which will be used as the label for the variant in the views,
|
|
54
|
-
* or an array of such objects.
|
|
55
59
|
*/
|
|
56
60
|
@property({ type: Object })
|
|
57
|
-
|
|
61
|
+
numeratorFilter:
|
|
58
62
|
{
|
|
59
63
|
lapisFilter: Record<string, string | number | null | boolean>;
|
|
60
64
|
displayName: string;
|
|
@@ -67,10 +71,11 @@ export class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyle
|
|
|
67
71
|
/**
|
|
68
72
|
* Required.
|
|
69
73
|
*
|
|
70
|
-
* The
|
|
74
|
+
* The LAPIS filter, to select the data of the reference.
|
|
75
|
+
* It must be a valid LAPIS filter object.
|
|
71
76
|
*/
|
|
72
77
|
@property({ type: Object })
|
|
73
|
-
|
|
78
|
+
denominatorFilter: Record<string, string | number | null | boolean> = {};
|
|
74
79
|
|
|
75
80
|
/**
|
|
76
81
|
* The granularity of the time axis.
|
|
@@ -113,7 +118,7 @@ export class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyle
|
|
|
113
118
|
/**
|
|
114
119
|
* The width of the component.
|
|
115
120
|
*
|
|
116
|
-
* Visit https://genspectrum.github.io/
|
|
121
|
+
* Visit https://genspectrum.github.io/dashboard-components/?path=/docs/components-size-of-components--docs for more information.
|
|
117
122
|
*/
|
|
118
123
|
@property({ type: String })
|
|
119
124
|
width: string = '100%';
|
|
@@ -121,7 +126,7 @@ export class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyle
|
|
|
121
126
|
/**
|
|
122
127
|
* The height of the component.
|
|
123
128
|
*
|
|
124
|
-
* Visit https://genspectrum.github.io/
|
|
129
|
+
* Visit https://genspectrum.github.io/dashboard-components/?path=/docs/components-size-of-components--docs for more information.
|
|
125
130
|
*/
|
|
126
131
|
@property({ type: String })
|
|
127
132
|
height: string = '700px';
|
|
@@ -143,11 +148,31 @@ export class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyle
|
|
|
143
148
|
@property({ type: Object })
|
|
144
149
|
pageSize: boolean | number = false;
|
|
145
150
|
|
|
151
|
+
/**
|
|
152
|
+
* The maximum value for the y-axis on all graphs in linear view.
|
|
153
|
+
* If set to a number, the maximum value is set to this number.
|
|
154
|
+
* If set to `maxInData`, the maximum value is set to the maximum value in the data.
|
|
155
|
+
* If set to `limitTo1`, the maximum value is set to `min(1, the maximum value in the data)`.
|
|
156
|
+
* If not set, the maximum value is set to the default value (1).
|
|
157
|
+
*/
|
|
158
|
+
@property({ type: String })
|
|
159
|
+
yAxisMaxLinear: 'maxInData' | 'limitTo1' | number = 1;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* The maximum value for the y-axis on all graphs in logarithmic view.
|
|
163
|
+
* If set to a number, the maximum value is set to this number.
|
|
164
|
+
* If set to `maxInData`, the maximum value is set to the maximum value in the data.
|
|
165
|
+
* If set to `limitTo1`, the maximum value is set to `min(1, the maximum value in the data)`.
|
|
166
|
+
* If not set, the maximum value is set to the default value (1).
|
|
167
|
+
*/
|
|
168
|
+
@property({ type: String })
|
|
169
|
+
yAxisMaxLogarithmic: 'maxInData' | 'limitTo1' | number = 1;
|
|
170
|
+
|
|
146
171
|
override render() {
|
|
147
172
|
return (
|
|
148
173
|
<PrevalenceOverTime
|
|
149
|
-
|
|
150
|
-
|
|
174
|
+
numeratorFilter={this.numeratorFilter}
|
|
175
|
+
denominatorFilter={this.denominatorFilter}
|
|
151
176
|
granularity={this.granularity}
|
|
152
177
|
smoothingWindow={this.smoothingWindow}
|
|
153
178
|
views={this.views}
|
|
@@ -157,11 +182,20 @@ export class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyle
|
|
|
157
182
|
headline={this.headline}
|
|
158
183
|
lapisDateField={this.lapisDateField}
|
|
159
184
|
pageSize={this.pageSize}
|
|
185
|
+
yAxisMaxConfig={{
|
|
186
|
+
linear: this.yAxisMaxLinear,
|
|
187
|
+
logarithmic: this.yAxisMaxLogarithmic,
|
|
188
|
+
}}
|
|
160
189
|
/>
|
|
161
190
|
);
|
|
162
191
|
}
|
|
163
192
|
}
|
|
164
193
|
|
|
194
|
+
export interface PrevalenceOverTimeComponentProps extends Omit<PrevalenceOverTimeProps, 'yAxisMaxConfig'> {
|
|
195
|
+
yAxisMaxLinear?: AxisMax;
|
|
196
|
+
yAxisMaxLogarithmic?: AxisMax;
|
|
197
|
+
}
|
|
198
|
+
|
|
165
199
|
declare global {
|
|
166
200
|
interface HTMLElementTagNameMap {
|
|
167
201
|
'gs-prevalence-over-time': PrevalenceOverTimeComponent;
|
|
@@ -170,10 +204,10 @@ declare global {
|
|
|
170
204
|
|
|
171
205
|
/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
|
|
172
206
|
type NumeratorMatches = Expect<
|
|
173
|
-
Equals<typeof PrevalenceOverTimeComponent.prototype.
|
|
207
|
+
Equals<typeof PrevalenceOverTimeComponent.prototype.numeratorFilter, PrevalenceOverTimeProps['numeratorFilter']>
|
|
174
208
|
>;
|
|
175
209
|
type DenominatorMatches = Expect<
|
|
176
|
-
Equals<typeof PrevalenceOverTimeComponent.prototype.
|
|
210
|
+
Equals<typeof PrevalenceOverTimeComponent.prototype.denominatorFilter, PrevalenceOverTimeProps['denominatorFilter']>
|
|
177
211
|
>;
|
|
178
212
|
type GranularityMatches = Expect<
|
|
179
213
|
Equals<typeof PrevalenceOverTimeComponent.prototype.granularity, PrevalenceOverTimeProps['granularity']>
|