@genspectrum/dashboard-components 0.16.0 → 0.16.2

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.
@@ -57,7 +57,7 @@ export const WastewaterMutationsOverTimeInner: FunctionComponent<WastewaterMutat
57
57
  componentProps.lapisFilter,
58
58
  componentProps.sequenceType,
59
59
  ),
60
- [],
60
+ [componentProps.lapisFilter, componentProps.sequenceType],
61
61
  );
62
62
 
63
63
  if (isLoading) {
@@ -8,7 +8,7 @@ import { lapisContext } from './lapis-context';
8
8
  import { referenceGenomeContext } from './reference-genome-context';
9
9
  import { type ReferenceGenome } from '../lapisApi/ReferenceGenome';
10
10
  import { LapisUrlContextProvider } from '../preact/LapisUrlContext';
11
- import { ReferenceGenomeContext } from '../preact/ReferenceGenomeContext';
11
+ import { INITIAL_REFERENCE_GENOMES, ReferenceGenomeContext } from '../preact/ReferenceGenomeContext';
12
12
  import minMaxPercentSliderCss from '../preact/components/min-max-percent-slider.css?inline';
13
13
  import tailwindStyle from '../styles/tailwind.css?inline';
14
14
 
@@ -40,10 +40,7 @@ export abstract class PreactLitAdapter extends ReactiveElement {
40
40
  * This value will automatically be injected by the parent `gs-app` component.
41
41
  */
42
42
  @consume({ context: referenceGenomeContext, subscribe: true })
43
- referenceGenome: ReferenceGenome = {
44
- nucleotideSequences: [],
45
- genes: [],
46
- };
43
+ referenceGenome: ReferenceGenome = INITIAL_REFERENCE_GENOMES;
47
44
 
48
45
  override update(changedProperties: PropertyValues) {
49
46
  const vdom = (
@@ -9,6 +9,7 @@ import { lapisContext } from './lapis-context';
9
9
  import { referenceGenomeContext } from './reference-genome-context';
10
10
  import { type ReferenceGenome } from '../lapisApi/ReferenceGenome';
11
11
  import { fetchReferenceGenome } from '../lapisApi/lapisApi';
12
+ import { INITIAL_REFERENCE_GENOMES } from '../preact/ReferenceGenomeContext';
12
13
 
13
14
  const lapisUrlSchema = z.string().url();
14
15
 
@@ -43,10 +44,7 @@ export class AppComponent extends LitElement {
43
44
  * @internal
44
45
  */
45
46
  @provide({ context: referenceGenomeContext })
46
- referenceGenome: ReferenceGenome = {
47
- nucleotideSequences: [],
48
- genes: [],
49
- };
47
+ referenceGenome: ReferenceGenome = INITIAL_REFERENCE_GENOMES;
50
48
 
51
49
  /**
52
50
  * @internal
@@ -16,6 +16,7 @@ const codeExample = String.raw`
16
16
  height='700px'
17
17
  granularity="month"
18
18
  lapisDateField="date"
19
+ displayMutations='["A23403G","C241T"]'
19
20
  ></gs-mutations-over-time>`;
20
21
 
21
22
  const meta: Meta<Required<MutationsOverTimeProps>> = {
@@ -38,6 +39,8 @@ const meta: Meta<Required<MutationsOverTimeProps>> = {
38
39
  control: { type: 'radio' },
39
40
  },
40
41
  lapisDateField: { control: 'text' },
42
+ displayMutations: { control: 'object' },
43
+ initialMeanProportionInterval: { control: 'object' },
41
44
  },
42
45
  args: {
43
46
  lapisFilter: { pangoLineage: 'JN.1*', dateFrom: '2024-01-15', dateTo: '2024-07-10' },
@@ -46,6 +49,7 @@ const meta: Meta<Required<MutationsOverTimeProps>> = {
46
49
  width: '100%',
47
50
  granularity: 'month',
48
51
  lapisDateField: 'date',
52
+ initialMeanProportionInterval: { min: 0.05, max: 0.9 },
49
53
  },
50
54
  parameters: withComponentDocs({
51
55
  componentDocs: {
@@ -71,6 +75,8 @@ const Template: StoryObj<Required<MutationsOverTimeProps>> = {
71
75
  .height=${args.height}
72
76
  .granularity=${args.granularity}
73
77
  .lapisDateField=${args.lapisDateField}
78
+ .displayMutations=${args.displayMutations}
79
+ .initialMeanProportionInterval=${args.initialMeanProportionInterval}
74
80
  ></gs-mutations-over-time>
75
81
  </gs-app>
76
82
  `,
@@ -81,6 +87,15 @@ export const ByMonth: StoryObj<Required<MutationsOverTimeProps>> = {
81
87
  ...Template,
82
88
  };
83
89
 
90
+ // This test uses mock data: defaultMockData.ts (through mutationOverTimeWorker.mock.ts)
91
+ export const ByMonthWithFilterOnDisplayedMutations: StoryObj<Required<MutationsOverTimeProps>> = {
92
+ ...Template,
93
+ args: {
94
+ ...Template.args,
95
+ displayMutations: ['A19722G', 'G21641T', 'T21653-'],
96
+ },
97
+ };
98
+
84
99
  // This test uses mock data: byWeek.ts (through mutationOverTimeWorker.mock.ts)
85
100
  export const ByWeek: StoryObj<Required<MutationsOverTimeProps>> = {
86
101
  ...Template,
@@ -29,6 +29,10 @@ import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsS
29
29
  *
30
30
  * The number of rows is limited to 100.
31
31
  * If there are more, the component will only show 100 mutations and notify the user.
32
+ *
33
+ * Users can filter the displayed rows by mean proportion via a slider in the toolbar.
34
+ * The mean proportion of each row is calculated by LAPIS over the whole data range that the component displays.
35
+ * The initial mean proportion can be set via `initialMeanProportionInterval`.
32
36
  */
33
37
  @customElement('gs-mutations-over-time')
34
38
  export class MutationsOverTimeComponent extends PreactLitAdapterWithGridJsStyles {
@@ -87,6 +91,20 @@ export class MutationsOverTimeComponent extends PreactLitAdapterWithGridJsStyles
87
91
  @property({ type: String })
88
92
  lapisDateField: string = 'date';
89
93
 
94
+ /**
95
+ * If provided, only the given mutations will be displayed.
96
+ * The mutations must be provided in the exact format as they would be displayed by the component.
97
+ */
98
+ @property({ type: Array })
99
+ displayMutations: string[] | undefined = undefined;
100
+
101
+ /**
102
+ * The initial proportion interval for the grid view.
103
+ * The values must be between 0 and 1, inclusive.
104
+ */
105
+ @property({ type: Object })
106
+ initialMeanProportionInterval: { min: number; max: number } = { min: 0.05, max: 0.9 };
107
+
90
108
  override render() {
91
109
  return (
92
110
  <MutationsOverTime
@@ -97,6 +115,8 @@ export class MutationsOverTimeComponent extends PreactLitAdapterWithGridJsStyles
97
115
  height={this.height}
98
116
  granularity={this.granularity}
99
117
  lapisDateField={this.lapisDateField}
118
+ displayMutations={this.displayMutations}
119
+ initialMeanProportionInterval={this.initialMeanProportionInterval}
100
120
  />
101
121
  );
102
122
  }
@@ -135,4 +155,13 @@ type GranularityMatches = Expect<
135
155
  type LapisDateFieldMatches = Expect<
136
156
  Equals<typeof MutationsOverTimeComponent.prototype.lapisDateField, MutationsOverTimeProps['lapisDateField']>
137
157
  >;
158
+ type DisplayMutationsMatches = Expect<
159
+ Equals<typeof MutationsOverTimeComponent.prototype.displayMutations, MutationsOverTimeProps['displayMutations']>
160
+ >;
161
+ type InitialMeanProportionIntervalMatches = Expect<
162
+ Equals<
163
+ typeof MutationsOverTimeComponent.prototype.initialMeanProportionInterval,
164
+ MutationsOverTimeProps['initialMeanProportionInterval']
165
+ >
166
+ >;
138
167
  /* eslint-enable @typescript-eslint/no-unused-vars, no-unused-vars */