@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.
Files changed (50) hide show
  1. package/README.md +2 -2
  2. package/custom-elements.json +178 -102
  3. package/dist/dashboard-components.js +318 -147
  4. package/dist/dashboard-components.js.map +1 -1
  5. package/dist/genspectrum-components.d.ts +91 -55
  6. package/dist/style.css +34 -7
  7. package/package.json +5 -5
  8. package/src/preact/mutationComparison/mutation-comparison-venn.tsx +1 -1
  9. package/src/preact/mutationComparison/mutation-comparison.stories.tsx +18 -18
  10. package/src/preact/mutationComparison/mutation-comparison.tsx +6 -6
  11. package/src/preact/mutationComparison/queryMutationData.ts +4 -4
  12. package/src/preact/mutations/mutations.stories.tsx +3 -3
  13. package/src/preact/mutations/mutations.tsx +16 -6
  14. package/src/preact/mutations/queryMutations.ts +3 -3
  15. package/src/preact/prevalenceOverTime/__mockData__/{denominatorOneVariant.json → denominatorFilterOneDataset.json} +1 -1
  16. package/src/preact/prevalenceOverTime/__mockData__/{numeratorOneVariant.json → numeratorFilterOneDataset.json} +1 -1
  17. package/src/preact/prevalenceOverTime/prevalence-over-time-bar-chart.tsx +42 -5
  18. package/src/preact/prevalenceOverTime/prevalence-over-time-bubble-chart.tsx +26 -7
  19. package/src/preact/prevalenceOverTime/prevalence-over-time-line-chart.tsx +62 -28
  20. package/src/preact/prevalenceOverTime/prevalence-over-time.stories.tsx +26 -16
  21. package/src/preact/prevalenceOverTime/prevalence-over-time.tsx +38 -11
  22. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage-chart.tsx +39 -7
  23. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.stories.tsx +10 -4
  24. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.tsx +19 -10
  25. package/src/preact/shared/charts/confideceInterval.ts +7 -2
  26. package/src/preact/shared/charts/getYAxisMax.ts +24 -0
  27. package/src/preact/shared/charts/getYAxisScale.ts +1 -3
  28. package/src/query/queryAggregateData.ts +2 -2
  29. package/src/query/queryInsertions.ts +7 -2
  30. package/src/query/querySubstitutionsOrDeletions.ts +2 -2
  31. package/src/web-components/input/gs-date-range-selector.tsx +1 -1
  32. package/src/web-components/input/gs-location-filter.tsx +1 -1
  33. package/src/web-components/input/gs-mutation-filter.tsx +1 -1
  34. package/src/web-components/input/gs-text-input.tsx +1 -1
  35. package/src/web-components/visualization/gs-aggregate.tsx +2 -2
  36. package/src/web-components/visualization/gs-mutation-comparison.stories.ts +12 -12
  37. package/src/web-components/visualization/gs-mutation-comparison.tsx +18 -19
  38. package/src/web-components/visualization/gs-mutations.stories.ts +4 -4
  39. package/src/web-components/visualization/gs-mutations.tsx +10 -11
  40. package/src/web-components/visualization/gs-prevalence-over-time.stories.ts +46 -35
  41. package/src/web-components/visualization/gs-prevalence-over-time.tsx +54 -20
  42. package/src/web-components/visualization/gs-relative-growth-advantage.stories.ts +32 -18
  43. package/src/web-components/visualization/gs-relative-growth-advantage.tsx +51 -13
  44. /package/src/preact/mutationComparison/__mockData__/{nucleotideMutationsOtherVariant.json → nucleotideMutationsOtherDataset.json} +0 -0
  45. /package/src/preact/mutationComparison/__mockData__/{nucleotideMutationsSomeVariant.json → nucleotideMutationsSomeDataset.json} +0 -0
  46. /package/src/preact/prevalenceOverTime/__mockData__/{denominator.json → denominatorFilter.json} +0 -0
  47. /package/src/preact/prevalenceOverTime/__mockData__/{numeratorEG.json → numeratorFilterEG.json} +0 -0
  48. /package/src/preact/prevalenceOverTime/__mockData__/{numeratorJN1.json → numeratorFilterJN1.json} +0 -0
  49. /package/src/preact/relativeGrowthAdvantage/__mockData__/{denominator.json → denominatorFilter.json} +0 -0
  50. /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 variants.
11
- * A variant is defined by its LAPIS filter.
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
- * and the proportions with which the mutation occurs in the respective variant.
21
- * It only shows mutations that are present in at least one of the variants
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 variants in a Venn diagram.
27
- * A variant is considered to have a certain mutation,
28
- * if the proportion of the mutation in the variant is within the selected proportion interval.
29
- * Thus, changing the proportion interval may change a mutations from being "common" between variant
30
- * to being "for one variant only".
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 variants to compare.
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 variant in the views.
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
- variants: {
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/dashboards/?path=/docs/components-size-of-components--docs for more information.
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/dashboards/?path=/docs/components-size-of-components--docs for more information.
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
- variants={this.variants}
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 VariantsMatches = Expect<
115
- Equals<typeof MutationComparisonComponent.prototype.variants, MutationComparisonProps['variants']>
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
- variant='{ "country": "Switzerland", "pangoLineage": "B.1.1.7", "dateTo": "2022-01-01" }'
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
- variant: { control: 'object' },
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
- variant: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateTo: '2022-01-01' },
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
- .variant=${args.variant}
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 given variant.
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 given variant.
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 variant.
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 given variant.
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
- * The `variant` will be sent as is to LAPIS to filter the mutation data.
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
- variant: Record<string, string | number | null | boolean> = {};
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/dashboards/?path=/docs/components-size-of-components--docs for more information.
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/dashboards/?path=/docs/components-size-of-components--docs for more information.
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
- variant={this.variant}
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 VariantsMatches = Expect<Equals<typeof MutationsComponent.prototype.variant, LapisFilter>>;
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 denominator from '../../preact/prevalenceOverTime/__mockData__/denominator.json';
10
- import denominatorOneVariant from '../../preact/prevalenceOverTime/__mockData__/denominatorOneVariant.json';
11
- import numeratorEG from '../../preact/prevalenceOverTime/__mockData__/numeratorEG.json';
12
- import numeratorJN1 from '../../preact/prevalenceOverTime/__mockData__/numeratorJN1.json';
13
- import numeratorOneVariant from '../../preact/prevalenceOverTime/__mockData__/numeratorOneVariant.json';
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
- numerator='[{ "displayName": "EG", "lapisFilter": { "country": "USA", "pangoLineage": "EG*" }}, { "displayName": "JN.1", "lapisFilter": { "country": "USA", "pangoLineage": "JN.1*" }}]'
20
- denominator='{ "country": "USA"}'
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<PrevalenceOverTimeProps>> = {
35
+ const meta: Meta<Required<PrevalenceOverTimeComponentProps>> = {
33
36
  title: 'Visualization/Prevalence over time',
34
37
  component: 'gs-prevalence-over-time',
35
38
  argTypes: {
36
- numerator: { control: 'object' },
37
- denominator: { control: 'object' },
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<PrevalenceOverTimeProps>> = {
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
- .numerator=${args.numerator}
73
- .denominator=${args.denominator}
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 TwoVariants: StoryObj<Required<PrevalenceOverTimeProps>> = {
95
+ export const TwoDatasets: StoryObj<Required<PrevalenceOverTimeComponentProps>> = {
89
96
  ...Template,
90
97
  args: {
91
- numerator: [
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
- denominator: { country: 'USA', dateFrom: '2023-01-01' },
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: numeratorEG,
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: numeratorJN1,
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: denominator,
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 OneVariant: StoryObj<Required<PrevalenceOverTimeProps>> = {
170
+ export const OneDataset: StoryObj<Required<PrevalenceOverTimeComponentProps>> = {
162
171
  ...Template,
163
172
  args: {
164
- numerator: {
173
+ numeratorFilter: {
165
174
  displayName: 'EG',
166
175
  lapisFilter: { country: 'USA', pangoLineage: 'BA.2.86*', dateFrom: '2023-10-01' },
167
176
  },
168
- denominator: { country: 'USA', dateFrom: '2023-10-01' },
169
- granularity: 'day',
170
- smoothingWindow: 7,
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: 'numeratorOneVariant',
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: numeratorOneVariant,
206
+ body: numeratorFilterOneDataset,
196
207
  },
197
208
  },
198
209
  {
199
210
  matcher: {
200
- name: 'denominatorOneVariant',
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: denominatorOneVariant,
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 OneVariantOnLineTab: StoryObj<Required<PrevalenceOverTimeProps>> = {
219
- ...OneVariant,
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 OneVariantOnBubbleTab: StoryObj<Required<PrevalenceOverTimeProps>> = {
230
- ...OneVariant,
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 OneVariantOnTableTab: StoryObj<Required<PrevalenceOverTimeProps>> = {
241
- ...OneVariant,
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 variants.
11
- * The prevalence is calculated as the ratio of the number of cases of each variant given as `numerator`
12
- * to the number of cases of the variant given as `denominator`.
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 variant in the `numerator` on every time step.
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 variant in the `numerator`.
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 `denominator` variant.
38
- * The height of the bubbles represents the prevalence of the `numerator` variants.
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
- numerator:
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 variant that the variants in `numerator` are compared to.
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
- denominator: Record<string, string | number | null | boolean> = {};
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/dashboards/?path=/docs/components-size-of-components--docs for more information.
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/dashboards/?path=/docs/components-size-of-components--docs for more information.
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
- numerator={this.numerator}
150
- denominator={this.denominator}
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.numerator, PrevalenceOverTimeProps['numerator']>
207
+ Equals<typeof PrevalenceOverTimeComponent.prototype.numeratorFilter, PrevalenceOverTimeProps['numeratorFilter']>
174
208
  >;
175
209
  type DenominatorMatches = Expect<
176
- Equals<typeof PrevalenceOverTimeComponent.prototype.denominator, PrevalenceOverTimeProps['denominator']>
210
+ Equals<typeof PrevalenceOverTimeComponent.prototype.denominatorFilter, PrevalenceOverTimeProps['denominatorFilter']>
177
211
  >;
178
212
  type GranularityMatches = Expect<
179
213
  Equals<typeof PrevalenceOverTimeComponent.prototype.granularity, PrevalenceOverTimeProps['granularity']>