@genspectrum/dashboard-components 0.2.0 → 0.3.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/custom-elements.json +328 -177
- package/dist/dashboard-components.js +376 -129
- package/dist/dashboard-components.js.map +1 -1
- package/dist/genspectrum-components.d.ts +156 -110
- package/dist/style.css +179 -33
- package/package.json +1 -2
- package/src/constants.ts +1 -1
- package/src/lapisApi/lapisApi.ts +46 -2
- package/src/lapisApi/lapisTypes.ts +14 -0
- package/src/preact/aggregatedData/aggregate.stories.tsx +4 -2
- package/src/preact/aggregatedData/aggregate.tsx +8 -6
- package/src/preact/components/error-boundary.stories.tsx +6 -14
- package/src/preact/components/error-boundary.tsx +2 -11
- package/src/preact/components/error-display.stories.tsx +12 -5
- package/src/preact/components/error-display.tsx +37 -3
- package/src/preact/components/loading-display.stories.tsx +1 -1
- package/src/preact/components/resize-container.tsx +5 -14
- package/src/preact/dateRangeSelector/date-range-selector.stories.tsx +2 -0
- package/src/preact/dateRangeSelector/date-range-selector.tsx +11 -8
- package/src/preact/locationFilter/fetchAutocompletionList.ts +15 -1
- package/src/preact/locationFilter/location-filter.tsx +4 -5
- package/src/preact/mutationComparison/mutation-comparison.stories.tsx +6 -3
- package/src/preact/mutationComparison/mutation-comparison.tsx +10 -13
- package/src/preact/mutationComparison/queryMutationData.ts +2 -3
- package/src/preact/mutationFilter/mutation-filter.stories.tsx +8 -8
- package/src/preact/mutationFilter/mutation-filter.tsx +7 -6
- package/src/preact/mutations/mutations.stories.tsx +6 -3
- package/src/preact/mutations/mutations.tsx +8 -6
- package/src/preact/prevalenceOverTime/prevalence-over-time.stories.tsx +14 -7
- package/src/preact/prevalenceOverTime/prevalence-over-time.tsx +10 -8
- package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.stories.tsx +6 -3
- package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.tsx +9 -7
- package/src/preact/textInput/text-input.stories.tsx +26 -0
- package/src/preact/textInput/text-input.tsx +4 -5
- package/src/query/queryPrevalenceOverTime.ts +4 -10
- package/src/types.ts +4 -1
- package/src/web-components/ResizeContainer.mdx +13 -0
- package/src/web-components/app.ts +3 -1
- package/src/web-components/input/gs-date-range-selector.stories.ts +10 -2
- package/src/web-components/input/gs-date-range-selector.tsx +26 -16
- package/src/web-components/input/gs-location-filter.stories.ts +5 -3
- package/src/web-components/input/gs-location-filter.tsx +5 -6
- package/src/web-components/input/gs-mutation-filter.stories.ts +11 -8
- package/src/web-components/input/gs-mutation-filter.tsx +38 -26
- package/src/web-components/input/gs-text-input.stories.ts +3 -3
- package/src/web-components/input/gs-text-input.tsx +10 -10
- package/src/web-components/input/introduction.mdx +11 -0
- package/src/web-components/introduction.mdx +15 -0
- package/src/web-components/visualization/gs-aggregate.stories.ts +19 -6
- package/src/web-components/visualization/gs-aggregate.tsx +31 -15
- package/src/web-components/visualization/gs-mutation-comparison.stories.ts +13 -7
- package/src/web-components/visualization/gs-mutation-comparison.tsx +26 -17
- package/src/web-components/visualization/gs-mutations.stories.ts +14 -8
- package/src/web-components/visualization/gs-mutations.tsx +18 -8
- package/src/web-components/visualization/gs-prevalence-over-time.stories.ts +28 -18
- package/src/web-components/visualization/gs-prevalence-over-time.tsx +45 -22
- package/src/web-components/visualization/gs-relative-growth-advantage.stories.ts +11 -5
- package/src/web-components/visualization/gs-relative-growth-advantage.tsx +21 -9
|
@@ -7,50 +7,65 @@ import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsS
|
|
|
7
7
|
/**
|
|
8
8
|
* ## Context
|
|
9
9
|
*
|
|
10
|
-
* This component displays aggregated data, which can provide an overview of the underlying data.
|
|
10
|
+
* This component displays aggregated data in a table, which can provide an overview of the underlying data.
|
|
11
11
|
*
|
|
12
|
-
* It expects a list of fields to aggregate by and a filter to apply to the data.
|
|
12
|
+
* It expects a list of `fields` to aggregate by and a `filter` to apply to the data.
|
|
13
|
+
*
|
|
14
|
+
* ## Views
|
|
15
|
+
*
|
|
16
|
+
* ### Table View
|
|
17
|
+
*
|
|
18
|
+
* In the table view, the data is presented in a table format where each field is a column,
|
|
19
|
+
* along with the aggregated value and its proportion.
|
|
20
|
+
* The proportion represents the ratio of the aggregated value to the total count of the data
|
|
21
|
+
* (considering the applied filter).
|
|
13
22
|
*/
|
|
14
23
|
@customElement('gs-aggregate')
|
|
15
24
|
export class AggregateComponent extends PreactLitAdapterWithGridJsStyles {
|
|
16
25
|
/**
|
|
17
26
|
* The fields to aggregate by.
|
|
27
|
+
* Every field will be a table column.
|
|
28
|
+
* Every field must exist in the backing LAPIS instance.
|
|
29
|
+
*
|
|
30
|
+
* If left empty, the component will only show the absolute count of the provided `filter` and proportion `100%`.
|
|
18
31
|
*/
|
|
19
32
|
@property({ type: Array })
|
|
20
33
|
fields: string[] = [];
|
|
21
34
|
|
|
22
35
|
/**
|
|
23
|
-
*
|
|
24
|
-
* In the table view, the data is presented in a table format where each field is a column,
|
|
25
|
-
* along with the aggregated value and its proportion.
|
|
26
|
-
* The proportion represents the ratio of the aggregated value to the total count of the data
|
|
27
|
-
* (considering the applied filter).
|
|
36
|
+
* A list of tabs with views that this component should provide.
|
|
28
37
|
*/
|
|
29
38
|
@property({ type: Array })
|
|
30
39
|
views: View[] = ['table'];
|
|
31
40
|
|
|
32
41
|
/**
|
|
33
42
|
* The filter to apply to the data.
|
|
43
|
+
* It must be a valid LAPIS filter object.
|
|
34
44
|
*/
|
|
35
45
|
@property({ type: Object })
|
|
36
46
|
filter: LapisFilter = {};
|
|
37
47
|
|
|
38
48
|
/**
|
|
39
|
-
* The
|
|
49
|
+
* The width of the component.
|
|
40
50
|
*
|
|
41
|
-
*
|
|
51
|
+
* Visit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.
|
|
52
|
+
*/
|
|
53
|
+
@property({ type: String })
|
|
54
|
+
width: string = '100%';
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The height of the component.
|
|
42
58
|
*
|
|
43
|
-
*
|
|
44
|
-
* If the unit is %, the size will be relative to the container of the component.
|
|
59
|
+
* Visit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.
|
|
45
60
|
*/
|
|
46
|
-
@property({ type:
|
|
47
|
-
|
|
61
|
+
@property({ type: String })
|
|
62
|
+
height: string = '700px';
|
|
48
63
|
|
|
49
64
|
/**
|
|
50
65
|
* The headline of the component. Set to an empty string to hide the headline.
|
|
51
66
|
*/
|
|
52
67
|
@property({ type: String })
|
|
53
|
-
headline: string
|
|
68
|
+
headline: string = 'Aggregate';
|
|
54
69
|
|
|
55
70
|
override render() {
|
|
56
71
|
return (
|
|
@@ -58,7 +73,8 @@ export class AggregateComponent extends PreactLitAdapterWithGridJsStyles {
|
|
|
58
73
|
fields={this.fields}
|
|
59
74
|
views={this.views}
|
|
60
75
|
filter={this.filter}
|
|
61
|
-
|
|
76
|
+
width={this.width}
|
|
77
|
+
height={this.height}
|
|
62
78
|
headline={this.headline}
|
|
63
79
|
/>
|
|
64
80
|
);
|
|
@@ -16,9 +16,12 @@ const codeExample = String.raw`
|
|
|
16
16
|
variants='[{ "displayName": "variant1", "lapisFilter": { "country": "Switzerland" }}, { "displayName": "variant2", "lapisFilter": { "country": "Germany" }}]'
|
|
17
17
|
sequenceType="nucleotide"
|
|
18
18
|
views='["table", "venn"]'
|
|
19
|
+
headline="Mutation comparison"
|
|
20
|
+
width='100%'
|
|
21
|
+
height='700px'
|
|
19
22
|
></gs-mutation-comparison>`;
|
|
20
23
|
|
|
21
|
-
const meta: Meta<MutationComparisonProps
|
|
24
|
+
const meta: Meta<Required<MutationComparisonProps>> = {
|
|
22
25
|
title: 'Visualization/Mutation comparison',
|
|
23
26
|
component: 'gs-mutation-comparison',
|
|
24
27
|
argTypes: {
|
|
@@ -31,7 +34,8 @@ const meta: Meta<MutationComparisonProps> = {
|
|
|
31
34
|
options: ['table', 'venn'],
|
|
32
35
|
control: { type: 'check' },
|
|
33
36
|
},
|
|
34
|
-
|
|
37
|
+
width: { control: 'text' },
|
|
38
|
+
height: { control: 'text' },
|
|
35
39
|
headline: { control: 'text' },
|
|
36
40
|
},
|
|
37
41
|
parameters: withComponentDocs({
|
|
@@ -46,14 +50,15 @@ const meta: Meta<MutationComparisonProps> = {
|
|
|
46
50
|
|
|
47
51
|
export default meta;
|
|
48
52
|
|
|
49
|
-
const Template: StoryObj<MutationComparisonProps
|
|
53
|
+
const Template: StoryObj<Required<MutationComparisonProps>> = {
|
|
50
54
|
render: (args) => html`
|
|
51
55
|
<gs-app lapis="${LAPIS_URL}">
|
|
52
56
|
<gs-mutation-comparison
|
|
53
57
|
.variants=${args.variants}
|
|
54
58
|
.sequenceType=${args.sequenceType}
|
|
55
59
|
.views=${args.views}
|
|
56
|
-
.
|
|
60
|
+
.width=${args.width}
|
|
61
|
+
.height=${args.height}
|
|
57
62
|
.headline=${args.headline}
|
|
58
63
|
></gs-mutation-comparison>
|
|
59
64
|
</gs-app>
|
|
@@ -63,7 +68,7 @@ const Template: StoryObj<MutationComparisonProps> = {
|
|
|
63
68
|
const dateTo = '2022-01-01';
|
|
64
69
|
const dateFrom = '2021-01-01';
|
|
65
70
|
|
|
66
|
-
export const Default: StoryObj<MutationComparisonProps
|
|
71
|
+
export const Default: StoryObj<Required<MutationComparisonProps>> = {
|
|
67
72
|
...Template,
|
|
68
73
|
args: {
|
|
69
74
|
variants: [
|
|
@@ -83,7 +88,8 @@ export const Default: StoryObj<MutationComparisonProps> = {
|
|
|
83
88
|
],
|
|
84
89
|
sequenceType: 'nucleotide',
|
|
85
90
|
views: ['table', 'venn'],
|
|
86
|
-
|
|
91
|
+
width: '100%',
|
|
92
|
+
height: '700px',
|
|
87
93
|
headline: 'Mutation comparison',
|
|
88
94
|
},
|
|
89
95
|
parameters: {
|
|
@@ -138,7 +144,7 @@ export const Default: StoryObj<MutationComparisonProps> = {
|
|
|
138
144
|
},
|
|
139
145
|
};
|
|
140
146
|
|
|
141
|
-
export const VennDiagram: StoryObj<MutationComparisonProps
|
|
147
|
+
export const VennDiagram: StoryObj<Required<MutationComparisonProps>> = {
|
|
142
148
|
...Default,
|
|
143
149
|
play: async ({ canvasElement, step }) => {
|
|
144
150
|
const canvas = await withinShadowRoot(canvasElement, 'gs-mutation-comparison');
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { customElement, property } from 'lit/decorators.js';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
MutationComparison,
|
|
5
|
-
type MutationComparisonVariant,
|
|
6
|
-
type View,
|
|
7
|
-
} from '../../preact/mutationComparison/mutation-comparison';
|
|
8
|
-
import { type SequenceType } from '../../types';
|
|
3
|
+
import { MutationComparison, type MutationComparisonProps } from '../../preact/mutationComparison/mutation-comparison';
|
|
9
4
|
import { type Equals, type Expect } from '../../utils/typeAssertions';
|
|
10
5
|
import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsStyles';
|
|
11
6
|
|
|
12
7
|
/**
|
|
8
|
+
* ## Context
|
|
9
|
+
*
|
|
13
10
|
* This component allows to compare mutations between different variants.
|
|
14
11
|
* A variant is defined by its LAPIS filter.
|
|
15
12
|
*
|
|
@@ -35,6 +32,8 @@ import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsS
|
|
|
35
32
|
@customElement('gs-mutation-comparison')
|
|
36
33
|
export class MutationComparisonComponent extends PreactLitAdapterWithGridJsStyles {
|
|
37
34
|
/**
|
|
35
|
+
* Required.
|
|
36
|
+
*
|
|
38
37
|
* An array of variants to compare.
|
|
39
38
|
*
|
|
40
39
|
* The `lapisFilter` will be sent as is to LAPIS to filter the mutation data.
|
|
@@ -62,21 +61,26 @@ export class MutationComparisonComponent extends PreactLitAdapterWithGridJsStyle
|
|
|
62
61
|
views: ('table' | 'venn')[] = ['table'];
|
|
63
62
|
|
|
64
63
|
/**
|
|
65
|
-
* The
|
|
64
|
+
* The width of the component.
|
|
66
65
|
*
|
|
67
|
-
*
|
|
66
|
+
* Visit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.
|
|
67
|
+
*/
|
|
68
|
+
@property({ type: String })
|
|
69
|
+
width: string = '100%';
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The height of the component.
|
|
68
73
|
*
|
|
69
|
-
*
|
|
70
|
-
* If the unit is %, the size will be relative to the container of the component.
|
|
74
|
+
* Visit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.
|
|
71
75
|
*/
|
|
72
|
-
@property({ type:
|
|
73
|
-
|
|
76
|
+
@property({ type: String })
|
|
77
|
+
height: string = '700px';
|
|
74
78
|
|
|
75
79
|
/**
|
|
76
80
|
* The headline of the component. Set to an empty string to hide the headline.
|
|
77
81
|
*/
|
|
78
82
|
@property({ type: String })
|
|
79
|
-
headline: string
|
|
83
|
+
headline: string = 'Mutation comparison';
|
|
80
84
|
|
|
81
85
|
override render() {
|
|
82
86
|
return (
|
|
@@ -84,7 +88,8 @@ export class MutationComparisonComponent extends PreactLitAdapterWithGridJsStyle
|
|
|
84
88
|
variants={this.variants}
|
|
85
89
|
sequenceType={this.sequenceType}
|
|
86
90
|
views={this.views}
|
|
87
|
-
|
|
91
|
+
width={this.width}
|
|
92
|
+
height={this.height}
|
|
88
93
|
headline={this.headline}
|
|
89
94
|
/>
|
|
90
95
|
);
|
|
@@ -99,8 +104,12 @@ declare global {
|
|
|
99
104
|
|
|
100
105
|
/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
|
|
101
106
|
type VariantsMatches = Expect<
|
|
102
|
-
Equals<typeof MutationComparisonComponent.prototype.variants,
|
|
107
|
+
Equals<typeof MutationComparisonComponent.prototype.variants, MutationComparisonProps['variants']>
|
|
108
|
+
>;
|
|
109
|
+
type SequenceTypeMatches = Expect<
|
|
110
|
+
Equals<typeof MutationComparisonComponent.prototype.sequenceType, MutationComparisonProps['sequenceType']>
|
|
111
|
+
>;
|
|
112
|
+
type ViewsMatches = Expect<
|
|
113
|
+
Equals<typeof MutationComparisonComponent.prototype.views, MutationComparisonProps['views']>
|
|
103
114
|
>;
|
|
104
|
-
type SequenceTypeMatches = Expect<Equals<typeof MutationComparisonComponent.prototype.sequenceType, SequenceType>>;
|
|
105
|
-
type ViewsMatches = Expect<Equals<typeof MutationComparisonComponent.prototype.views, View[]>>;
|
|
106
115
|
/* eslint-enable @typescript-eslint/no-unused-vars, no-unused-vars */
|
|
@@ -16,9 +16,12 @@ const codeExample = String.raw`
|
|
|
16
16
|
variant='{ "country": "Switzerland", "pangoLineage": "B.1.1.7", "dateTo": "2022-01-01" }'
|
|
17
17
|
sequenceType="nucleotide"
|
|
18
18
|
views='["grid", "table", "insertions"]'
|
|
19
|
+
headline="Mutations"
|
|
20
|
+
width='100%'
|
|
21
|
+
height='700px'
|
|
19
22
|
></gs-mutations>`;
|
|
20
23
|
|
|
21
|
-
const meta: Meta<MutationsProps
|
|
24
|
+
const meta: Meta<Required<MutationsProps>> = {
|
|
22
25
|
title: 'Visualization/Mutations',
|
|
23
26
|
component: 'gs-mutations',
|
|
24
27
|
argTypes: {
|
|
@@ -31,14 +34,16 @@ const meta: Meta<MutationsProps> = {
|
|
|
31
34
|
options: ['table', 'grid', 'insertions'],
|
|
32
35
|
control: { type: 'check' },
|
|
33
36
|
},
|
|
34
|
-
|
|
37
|
+
width: { control: 'text' },
|
|
38
|
+
height: { control: 'text' },
|
|
35
39
|
headline: { control: 'text' },
|
|
36
40
|
},
|
|
37
41
|
args: {
|
|
38
42
|
variant: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateTo: '2022-01-01' },
|
|
39
43
|
sequenceType: 'nucleotide',
|
|
40
44
|
views: ['grid', 'table', 'insertions'],
|
|
41
|
-
|
|
45
|
+
width: '100%',
|
|
46
|
+
height: '700px',
|
|
42
47
|
headline: 'Mutations',
|
|
43
48
|
},
|
|
44
49
|
parameters: withComponentDocs({
|
|
@@ -53,21 +58,22 @@ const meta: Meta<MutationsProps> = {
|
|
|
53
58
|
|
|
54
59
|
export default meta;
|
|
55
60
|
|
|
56
|
-
const Template: StoryObj<MutationsProps
|
|
61
|
+
const Template: StoryObj<Required<MutationsProps>> = {
|
|
57
62
|
render: (args) => html`
|
|
58
63
|
<gs-app lapis="${LAPIS_URL}">
|
|
59
64
|
<gs-mutations
|
|
60
65
|
.variant=${args.variant}
|
|
61
66
|
.sequenceType=${args.sequenceType}
|
|
62
67
|
.views=${args.views}
|
|
63
|
-
.
|
|
68
|
+
.width=${args.width}
|
|
69
|
+
.height=${args.height}
|
|
64
70
|
.headline=${args.headline}
|
|
65
71
|
></gs-mutations>
|
|
66
72
|
</gs-app>
|
|
67
73
|
`,
|
|
68
74
|
};
|
|
69
75
|
|
|
70
|
-
export const Default: StoryObj<MutationsProps
|
|
76
|
+
export const Default: StoryObj<Required<MutationsProps>> = {
|
|
71
77
|
...Template,
|
|
72
78
|
parameters: {
|
|
73
79
|
fetchMock: {
|
|
@@ -104,7 +110,7 @@ export const Default: StoryObj<MutationsProps> = {
|
|
|
104
110
|
},
|
|
105
111
|
};
|
|
106
112
|
|
|
107
|
-
export const OnTableTab: StoryObj<MutationsProps
|
|
113
|
+
export const OnTableTab: StoryObj<Required<MutationsProps>> = {
|
|
108
114
|
...Default,
|
|
109
115
|
play: async ({ canvasElement }) => {
|
|
110
116
|
const canvas = await withinShadowRoot(canvasElement, 'gs-mutations');
|
|
@@ -115,7 +121,7 @@ export const OnTableTab: StoryObj<MutationsProps> = {
|
|
|
115
121
|
},
|
|
116
122
|
};
|
|
117
123
|
|
|
118
|
-
export const OnInsertionsTab: StoryObj<MutationsProps
|
|
124
|
+
export const OnInsertionsTab: StoryObj<Required<MutationsProps>> = {
|
|
119
125
|
...Default,
|
|
120
126
|
play: async ({ canvasElement }) => {
|
|
121
127
|
const canvas = await withinShadowRoot(canvasElement, 'gs-mutations');
|
|
@@ -6,6 +6,8 @@ import type { Equals, Expect } from '../../utils/typeAssertions';
|
|
|
6
6
|
import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsStyles';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
+
* ## Context
|
|
10
|
+
*
|
|
9
11
|
* This component displays mutations (substitutions, deletions and insertions) for a given variant.
|
|
10
12
|
*
|
|
11
13
|
* ## Views
|
|
@@ -33,6 +35,8 @@ import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsS
|
|
|
33
35
|
@customElement('gs-mutations')
|
|
34
36
|
export class MutationsComponent extends PreactLitAdapterWithGridJsStyles {
|
|
35
37
|
/**
|
|
38
|
+
* Required.
|
|
39
|
+
*
|
|
36
40
|
* The `variant` will be sent as is to LAPIS to filter the mutation data.
|
|
37
41
|
* It must be a valid LAPIS filter object.
|
|
38
42
|
*/
|
|
@@ -52,21 +56,26 @@ export class MutationsComponent extends PreactLitAdapterWithGridJsStyles {
|
|
|
52
56
|
views: ('table' | 'grid' | 'insertions')[] = ['table', 'grid'];
|
|
53
57
|
|
|
54
58
|
/**
|
|
55
|
-
* The
|
|
59
|
+
* The width of the component.
|
|
56
60
|
*
|
|
57
|
-
*
|
|
61
|
+
* Visit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.
|
|
62
|
+
*/
|
|
63
|
+
@property({ type: String })
|
|
64
|
+
width: string = '100%';
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The height of the component.
|
|
58
68
|
*
|
|
59
|
-
*
|
|
60
|
-
* If the unit is %, the size will be relative to the container of the component.
|
|
69
|
+
* Visit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.
|
|
61
70
|
*/
|
|
62
|
-
@property({ type:
|
|
63
|
-
|
|
71
|
+
@property({ type: String })
|
|
72
|
+
height: string = '700px';
|
|
64
73
|
|
|
65
74
|
/**
|
|
66
75
|
* The headline of the component. Set to an empty string to hide the headline.
|
|
67
76
|
*/
|
|
68
77
|
@property({ type: String })
|
|
69
|
-
headline: string
|
|
78
|
+
headline: string = 'Mutations';
|
|
70
79
|
|
|
71
80
|
override render() {
|
|
72
81
|
return (
|
|
@@ -74,7 +83,8 @@ export class MutationsComponent extends PreactLitAdapterWithGridJsStyles {
|
|
|
74
83
|
variant={this.variant}
|
|
75
84
|
sequenceType={this.sequenceType}
|
|
76
85
|
views={this.views}
|
|
77
|
-
|
|
86
|
+
width={this.width}
|
|
87
|
+
height={this.height}
|
|
78
88
|
headline={this.headline}
|
|
79
89
|
/>
|
|
80
90
|
);
|
|
@@ -16,15 +16,18 @@ import { withinShadowRoot } from '../withinShadowRoot.story';
|
|
|
16
16
|
|
|
17
17
|
const codeExample = String.raw`
|
|
18
18
|
<gs-prevalence-over-time
|
|
19
|
-
numerator='[{ "displayName": "EG", "country": "USA", "pangoLineage": "EG*" }, { "displayName": "JN.1", "country": "USA", "pangoLineage": "JN.1*" }]'
|
|
20
|
-
denominator='{ "country": "USA"
|
|
19
|
+
numerator='[{ "displayName": "EG", "lapisFilter": { "country": "USA", "pangoLineage": "EG*" }}, { "displayName": "JN.1", "lapisFilter": { "country": "USA", "pangoLineage": "JN.1*" }}]'
|
|
20
|
+
denominator='{ "country": "USA"}'
|
|
21
21
|
granularity="month"
|
|
22
22
|
smoothingWindow="0"
|
|
23
23
|
views='["bar", "line", "bubble", "table"]'
|
|
24
24
|
confidenceIntervalMethods='["wilson"]'
|
|
25
|
+
headline="Prevalence over time"
|
|
26
|
+
width='100%'
|
|
27
|
+
height='700px'
|
|
25
28
|
></gs-prevalence-over-time>`;
|
|
26
29
|
|
|
27
|
-
const meta: Meta<PrevalenceOverTimeProps
|
|
30
|
+
const meta: Meta<Required<PrevalenceOverTimeProps>> = {
|
|
28
31
|
title: 'Visualization/Prevalence over time',
|
|
29
32
|
component: 'gs-prevalence-over-time',
|
|
30
33
|
argTypes: {
|
|
@@ -43,7 +46,8 @@ const meta: Meta<PrevalenceOverTimeProps> = {
|
|
|
43
46
|
options: ['wilson'],
|
|
44
47
|
control: { type: 'check' },
|
|
45
48
|
},
|
|
46
|
-
|
|
49
|
+
width: { control: 'text' },
|
|
50
|
+
height: { control: 'text' },
|
|
47
51
|
headline: { control: 'text' },
|
|
48
52
|
},
|
|
49
53
|
parameters: withComponentDocs({
|
|
@@ -58,7 +62,7 @@ const meta: Meta<PrevalenceOverTimeProps> = {
|
|
|
58
62
|
|
|
59
63
|
export default meta;
|
|
60
64
|
|
|
61
|
-
const Template: StoryObj<PrevalenceOverTimeProps
|
|
65
|
+
const Template: StoryObj<Required<PrevalenceOverTimeProps>> = {
|
|
62
66
|
render: (args) => html`
|
|
63
67
|
<gs-app lapis="${LAPIS_URL}">
|
|
64
68
|
<gs-prevalence-over-time
|
|
@@ -68,26 +72,28 @@ const Template: StoryObj<PrevalenceOverTimeProps> = {
|
|
|
68
72
|
.smoothingWindow=${args.smoothingWindow}
|
|
69
73
|
.views=${args.views}
|
|
70
74
|
.confidenceIntervalMethods=${args.confidenceIntervalMethods}
|
|
71
|
-
.
|
|
75
|
+
.width=${args.width}
|
|
76
|
+
.height=${args.height}
|
|
72
77
|
.headline=${args.headline}
|
|
73
78
|
></gs-prevalence-over-time>
|
|
74
79
|
</gs-app>
|
|
75
80
|
`,
|
|
76
81
|
};
|
|
77
82
|
|
|
78
|
-
export const TwoVariants: StoryObj<PrevalenceOverTimeProps
|
|
83
|
+
export const TwoVariants: StoryObj<Required<PrevalenceOverTimeProps>> = {
|
|
79
84
|
...Template,
|
|
80
85
|
args: {
|
|
81
86
|
numerator: [
|
|
82
|
-
{ displayName: 'EG', country: 'USA', pangoLineage: 'EG*', dateFrom: '2023-01-01' },
|
|
83
|
-
{ displayName: 'JN.1', country: 'USA', pangoLineage: 'JN.1*', dateFrom: '2023-01-01' },
|
|
87
|
+
{ displayName: 'EG', lapisFilter: { country: 'USA', pangoLineage: 'EG*', dateFrom: '2023-01-01' } },
|
|
88
|
+
{ displayName: 'JN.1', lapisFilter: { country: 'USA', pangoLineage: 'JN.1*', dateFrom: '2023-01-01' } },
|
|
84
89
|
],
|
|
85
|
-
denominator: { country: 'USA', dateFrom: '2023-01-01'
|
|
90
|
+
denominator: { country: 'USA', dateFrom: '2023-01-01' },
|
|
86
91
|
granularity: 'month',
|
|
87
92
|
smoothingWindow: 0,
|
|
88
93
|
views: ['bar', 'line', 'bubble', 'table'],
|
|
89
94
|
confidenceIntervalMethods: ['wilson'],
|
|
90
|
-
|
|
95
|
+
width: '100%',
|
|
96
|
+
height: '700px',
|
|
91
97
|
headline: 'Prevalence over time',
|
|
92
98
|
},
|
|
93
99
|
parameters: {
|
|
@@ -145,16 +151,20 @@ export const TwoVariants: StoryObj<PrevalenceOverTimeProps> = {
|
|
|
145
151
|
},
|
|
146
152
|
};
|
|
147
153
|
|
|
148
|
-
export const OneVariant: StoryObj<PrevalenceOverTimeProps
|
|
154
|
+
export const OneVariant: StoryObj<Required<PrevalenceOverTimeProps>> = {
|
|
149
155
|
...Template,
|
|
150
156
|
args: {
|
|
151
|
-
numerator: {
|
|
152
|
-
|
|
157
|
+
numerator: {
|
|
158
|
+
displayName: 'EG',
|
|
159
|
+
lapisFilter: { country: 'USA', pangoLineage: 'BA.2.86*', dateFrom: '2023-10-01' },
|
|
160
|
+
},
|
|
161
|
+
denominator: { country: 'USA', dateFrom: '2023-10-01' },
|
|
153
162
|
granularity: 'day',
|
|
154
163
|
smoothingWindow: 7,
|
|
155
164
|
views: ['bar', 'line', 'bubble', 'table'],
|
|
156
165
|
confidenceIntervalMethods: ['wilson'],
|
|
157
|
-
|
|
166
|
+
width: '100%',
|
|
167
|
+
height: '700px',
|
|
158
168
|
headline: 'Prevalence over time',
|
|
159
169
|
},
|
|
160
170
|
parameters: {
|
|
@@ -196,7 +206,7 @@ export const OneVariant: StoryObj<PrevalenceOverTimeProps> = {
|
|
|
196
206
|
},
|
|
197
207
|
};
|
|
198
208
|
|
|
199
|
-
export const OneVariantOnLineTab: StoryObj<PrevalenceOverTimeProps
|
|
209
|
+
export const OneVariantOnLineTab: StoryObj<Required<PrevalenceOverTimeProps>> = {
|
|
200
210
|
...OneVariant,
|
|
201
211
|
play: async ({ canvasElement }) => {
|
|
202
212
|
const canvas = await withinShadowRoot(canvasElement, 'gs-prevalence-over-time');
|
|
@@ -207,7 +217,7 @@ export const OneVariantOnLineTab: StoryObj<PrevalenceOverTimeProps> = {
|
|
|
207
217
|
},
|
|
208
218
|
};
|
|
209
219
|
|
|
210
|
-
export const OneVariantOnBubbleTab: StoryObj<PrevalenceOverTimeProps
|
|
220
|
+
export const OneVariantOnBubbleTab: StoryObj<Required<PrevalenceOverTimeProps>> = {
|
|
211
221
|
...OneVariant,
|
|
212
222
|
play: async ({ canvasElement }) => {
|
|
213
223
|
const canvas = await withinShadowRoot(canvasElement, 'gs-prevalence-over-time');
|
|
@@ -218,7 +228,7 @@ export const OneVariantOnBubbleTab: StoryObj<PrevalenceOverTimeProps> = {
|
|
|
218
228
|
},
|
|
219
229
|
};
|
|
220
230
|
|
|
221
|
-
export const OneVariantOnTableTab: StoryObj<PrevalenceOverTimeProps
|
|
231
|
+
export const OneVariantOnTableTab: StoryObj<Required<PrevalenceOverTimeProps>> = {
|
|
222
232
|
...OneVariant,
|
|
223
233
|
play: async ({ canvasElement }) => {
|
|
224
234
|
const canvas = await withinShadowRoot(canvasElement, 'gs-prevalence-over-time');
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { customElement, property } from 'lit/decorators.js';
|
|
2
2
|
|
|
3
|
-
import PrevalenceOverTime, { type
|
|
4
|
-
import { type ConfidenceIntervalMethod } from '../../preact/shared/charts/confideceInterval';
|
|
5
|
-
import { type NamedLapisFilter, type TemporalGranularity } from '../../types';
|
|
3
|
+
import PrevalenceOverTime, { type PrevalenceOverTimeProps } from '../../preact/prevalenceOverTime/prevalence-over-time';
|
|
6
4
|
import { type Equals, type Expect } from '../../utils/typeAssertions';
|
|
7
5
|
import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsStyles';
|
|
8
6
|
|
|
9
7
|
/**
|
|
8
|
+
* ## Context
|
|
9
|
+
*
|
|
10
10
|
* This component displays the prevalence over time of one or more variants.
|
|
11
11
|
* The prevalence is calculated as the ratio of the number of cases of each variant given as `numerator`
|
|
12
12
|
* to the number of cases of the variant given as `denominator`.
|
|
@@ -46,23 +46,31 @@ export class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyle
|
|
|
46
46
|
// prettier-ignore
|
|
47
47
|
// The multiline union type must not start with `|` because it looks weird in the Storybook docs
|
|
48
48
|
/**
|
|
49
|
+
* Required.
|
|
50
|
+
*
|
|
49
51
|
* Either a single variant or an array of variants to compare.
|
|
50
52
|
* This must be a valid LAPIS filter object with an additional `displayName` property
|
|
51
53
|
* which will be used as the label for the variant in the views,
|
|
52
54
|
* or an array of such objects.
|
|
53
55
|
*/
|
|
54
|
-
@property({
|
|
56
|
+
@property({type: Object})
|
|
55
57
|
numerator:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
{
|
|
59
|
+
lapisFilter: Record<string, string | number | null | boolean>;
|
|
60
|
+
displayName: string;
|
|
61
|
+
}
|
|
62
|
+
| {
|
|
63
|
+
lapisFilter: Record<string, string | number | null | boolean>;
|
|
64
|
+
displayName: string;
|
|
65
|
+
}[] = { displayName: '', lapisFilter: {} };
|
|
60
66
|
|
|
61
67
|
/**
|
|
68
|
+
* Required.
|
|
69
|
+
*
|
|
62
70
|
* The variant that the variants in `numerator` are compared to.
|
|
63
71
|
*/
|
|
64
72
|
@property({ type: Object })
|
|
65
|
-
denominator: Record<string, string | number | null | boolean>
|
|
73
|
+
denominator: Record<string, string | number | null | boolean> = {};
|
|
66
74
|
|
|
67
75
|
/**
|
|
68
76
|
* The granularity of the time axis.
|
|
@@ -100,18 +108,23 @@ export class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyle
|
|
|
100
108
|
* The headline of the component. Set to an empty string to hide the headline.
|
|
101
109
|
*/
|
|
102
110
|
@property({ type: String })
|
|
103
|
-
headline: string
|
|
111
|
+
headline: string = 'Prevalence over time';
|
|
104
112
|
|
|
105
113
|
/**
|
|
106
|
-
* The
|
|
114
|
+
* The width of the component.
|
|
107
115
|
*
|
|
108
|
-
*
|
|
116
|
+
* Visit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.
|
|
117
|
+
*/
|
|
118
|
+
@property({ type: String })
|
|
119
|
+
width: string = '100%';
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* The height of the component.
|
|
109
123
|
*
|
|
110
|
-
*
|
|
111
|
-
* If the unit is %, the size will be relative to the container of the component.
|
|
124
|
+
* Visit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.
|
|
112
125
|
*/
|
|
113
|
-
@property({ type:
|
|
114
|
-
|
|
126
|
+
@property({ type: String })
|
|
127
|
+
height: string = '700px';
|
|
115
128
|
|
|
116
129
|
override render() {
|
|
117
130
|
return (
|
|
@@ -122,7 +135,8 @@ export class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyle
|
|
|
122
135
|
smoothingWindow={this.smoothingWindow}
|
|
123
136
|
views={this.views}
|
|
124
137
|
confidenceIntervalMethods={this.confidenceIntervalMethods}
|
|
125
|
-
|
|
138
|
+
width={this.width}
|
|
139
|
+
height={this.height}
|
|
126
140
|
headline={this.headline}
|
|
127
141
|
/>
|
|
128
142
|
);
|
|
@@ -137,12 +151,21 @@ declare global {
|
|
|
137
151
|
|
|
138
152
|
/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
|
|
139
153
|
type NumeratorMatches = Expect<
|
|
140
|
-
Equals<typeof PrevalenceOverTimeComponent.prototype.numerator,
|
|
154
|
+
Equals<typeof PrevalenceOverTimeComponent.prototype.numerator, PrevalenceOverTimeProps['numerator']>
|
|
155
|
+
>;
|
|
156
|
+
type DenominatorMatches = Expect<
|
|
157
|
+
Equals<typeof PrevalenceOverTimeComponent.prototype.denominator, PrevalenceOverTimeProps['denominator']>
|
|
158
|
+
>;
|
|
159
|
+
type GranularityMatches = Expect<
|
|
160
|
+
Equals<typeof PrevalenceOverTimeComponent.prototype.granularity, PrevalenceOverTimeProps['granularity']>
|
|
161
|
+
>;
|
|
162
|
+
type ViewsMatches = Expect<
|
|
163
|
+
Equals<typeof PrevalenceOverTimeComponent.prototype.views, PrevalenceOverTimeProps['views']>
|
|
141
164
|
>;
|
|
142
|
-
type DenominatorMatches = Expect<Equals<typeof PrevalenceOverTimeComponent.prototype.denominator, NamedLapisFilter>>;
|
|
143
|
-
type GranularityMatches = Expect<Equals<typeof PrevalenceOverTimeComponent.prototype.granularity, TemporalGranularity>>;
|
|
144
|
-
type ViewsMatches = Expect<Equals<typeof PrevalenceOverTimeComponent.prototype.views, View[]>>;
|
|
145
165
|
type ConfidenceIntervalMethodsMatches = Expect<
|
|
146
|
-
Equals<
|
|
166
|
+
Equals<
|
|
167
|
+
typeof PrevalenceOverTimeComponent.prototype.confidenceIntervalMethods,
|
|
168
|
+
PrevalenceOverTimeProps['confidenceIntervalMethods']
|
|
169
|
+
>
|
|
147
170
|
>;
|
|
148
171
|
/* eslint-enable @typescript-eslint/no-unused-vars, no-unused-vars */
|