@genspectrum/dashboard-components 1.13.0 → 1.14.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 +393 -2
- package/dist/components.d.ts +126 -9
- package/dist/components.js +701 -163
- package/dist/components.js.map +1 -1
- package/dist/util.d.ts +146 -11
- package/package.json +1 -1
- package/src/lapisApi/lapisTypes.ts +1 -1
- package/src/preact/queriesOverTime/__mockData__/defaultMockData/queriesOverTime.json +32 -0
- package/src/preact/queriesOverTime/__mockData__/manyQueries.json +128 -0
- package/src/preact/queriesOverTime/__mockData__/request1800s.json +16 -0
- package/src/preact/queriesOverTime/__mockData__/withGaps.json +52 -0
- package/src/preact/queriesOverTime/getFilteredQueriesOverTimeData.ts +85 -0
- package/src/preact/queriesOverTime/queries-over-time-filter.tsx +25 -0
- package/src/preact/queriesOverTime/queries-over-time-grid-tooltip.stories.tsx +134 -0
- package/src/preact/queriesOverTime/queries-over-time-grid-tooltip.tsx +123 -0
- package/src/preact/queriesOverTime/queries-over-time.stories.tsx +481 -0
- package/src/preact/queriesOverTime/queries-over-time.tsx +304 -0
- package/src/utilEntrypoint.ts +1 -0
- package/src/web-components/visualization/gs-mutations-over-time.spec-d.ts +3 -0
- package/src/web-components/visualization/gs-mutations-over-time.tsx +1 -1
- package/src/web-components/visualization/gs-queries-over-time.spec-d.ts +38 -0
- package/src/web-components/visualization/gs-queries-over-time.stories.ts +288 -0
- package/src/web-components/visualization/gs-queries-over-time.tsx +154 -0
- package/src/web-components/visualization/index.ts +1 -0
- package/standalone-bundle/dashboard-components.js +8509 -8068
- package/standalone-bundle/dashboard-components.js.map +1 -1
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
2
|
+
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
import { QueriesOverTime } from '../../preact/queriesOverTime/queries-over-time';
|
|
5
|
+
import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsStyles';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ## Context
|
|
9
|
+
*
|
|
10
|
+
* This component displays arbitrary LAPIS queries over time for a dataset.
|
|
11
|
+
* Each query consists of a displayLabel (optional), countQuery (string for counting matches),
|
|
12
|
+
* and coverageQuery (string for determining the coverage/denominator).
|
|
13
|
+
* The shown date range is determined by the available dates in the dataset.
|
|
14
|
+
*
|
|
15
|
+
* ## Views
|
|
16
|
+
*
|
|
17
|
+
* ### Grid View
|
|
18
|
+
*
|
|
19
|
+
* The grid view shows the proportion for each query over date ranges.
|
|
20
|
+
* Proportions are calculated as count/coverage for each time period.
|
|
21
|
+
*
|
|
22
|
+
* Users can filter the displayed rows by mean proportion via a slider in the toolbar.
|
|
23
|
+
* The mean proportion of each row is calculated over the whole data range that the component displays.
|
|
24
|
+
*
|
|
25
|
+
* @fires {CustomEvent<undefined>} gs-component-finished-loading
|
|
26
|
+
* Fired when the component has finished loading the required data from LAPIS.
|
|
27
|
+
*/
|
|
28
|
+
@customElement('gs-queries-over-time')
|
|
29
|
+
export class QueriesOverTimeComponent extends PreactLitAdapterWithGridJsStyles {
|
|
30
|
+
/**
|
|
31
|
+
* LAPIS filter to apply to all queries. This is used to determine the date range and total counts.
|
|
32
|
+
*/
|
|
33
|
+
@property({ type: Object })
|
|
34
|
+
lapisFilter: Record<string, string | string[] | number | null | boolean | undefined> & {
|
|
35
|
+
nucleotideMutations?: string[];
|
|
36
|
+
aminoAcidMutations?: string[];
|
|
37
|
+
nucleotideInsertions?: string[];
|
|
38
|
+
aminoAcidInsertions?: string[];
|
|
39
|
+
} = {};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Required.
|
|
43
|
+
*
|
|
44
|
+
* Array of queries to display. Each query has:
|
|
45
|
+
* - displayLabel: string - The name to show in the grid row label
|
|
46
|
+
* - countQuery: string - Query string to count matches
|
|
47
|
+
* - coverageQuery: string - Query string to determine coverage/denominator
|
|
48
|
+
*
|
|
49
|
+
* Both queries (count and coverage) are 'advanced queries' as they are defined in LAPIS.
|
|
50
|
+
*/
|
|
51
|
+
@property({ type: Array })
|
|
52
|
+
queries: {
|
|
53
|
+
displayLabel: string;
|
|
54
|
+
countQuery: string;
|
|
55
|
+
coverageQuery: string;
|
|
56
|
+
}[] = [];
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* A list of tabs with views that this component should provide.
|
|
60
|
+
*/
|
|
61
|
+
@property({ type: Array })
|
|
62
|
+
views: 'grid'[] = ['grid'];
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The width of the component.
|
|
66
|
+
*
|
|
67
|
+
* Visit https://genspectrum.github.io/dashboard-components/?path=/docs/concepts-size-of-components--docs for more information.
|
|
68
|
+
*/
|
|
69
|
+
@property({ type: String })
|
|
70
|
+
width: string = '100%';
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The height of the component.
|
|
74
|
+
*
|
|
75
|
+
* Visit https://genspectrum.github.io/dashboard-components/?path=/docs/concepts-size-of-components--docs for more information.
|
|
76
|
+
*/
|
|
77
|
+
@property({ type: String })
|
|
78
|
+
height: string | undefined = undefined;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The granularity of the time axis.
|
|
82
|
+
*/
|
|
83
|
+
@property({ type: String })
|
|
84
|
+
granularity: 'day' | 'week' | 'month' | 'year' = 'week';
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Required.
|
|
88
|
+
*
|
|
89
|
+
* The LAPIS field that the data should be aggregated by.
|
|
90
|
+
* Must be a field of type `date` in LAPIS.
|
|
91
|
+
*/
|
|
92
|
+
@property({ type: String })
|
|
93
|
+
lapisDateField: string = 'date';
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The initial proportion interval for the grid view.
|
|
97
|
+
* The values must be between 0 and 1, inclusive.
|
|
98
|
+
*/
|
|
99
|
+
@property({ type: Object })
|
|
100
|
+
initialMeanProportionInterval: { min: number; max: number } = { min: 0, max: 1 };
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* If true, date ranges with no data will be hidden initially; if false, not.
|
|
104
|
+
* Can be switched with a button in the toolbar.
|
|
105
|
+
*/
|
|
106
|
+
@property({ type: Boolean })
|
|
107
|
+
hideGaps: boolean | undefined = false;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The number of rows per page, which can be selected by the user.
|
|
111
|
+
*/
|
|
112
|
+
@property({ type: Array })
|
|
113
|
+
pageSizes: number[] | number = [10, 20, 30, 40, 50];
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Custom columns to add to the grid.
|
|
117
|
+
* Each column has a header and a map of query displayLabels to values.
|
|
118
|
+
*/
|
|
119
|
+
@property({ type: Array })
|
|
120
|
+
customColumns?: { header: string; values: Record<string, string | number> }[] = undefined;
|
|
121
|
+
|
|
122
|
+
override render() {
|
|
123
|
+
return (
|
|
124
|
+
<QueriesOverTime
|
|
125
|
+
lapisFilter={this.lapisFilter}
|
|
126
|
+
queries={this.queries}
|
|
127
|
+
views={this.views}
|
|
128
|
+
width={this.width}
|
|
129
|
+
height={this.height}
|
|
130
|
+
granularity={this.granularity}
|
|
131
|
+
lapisDateField={this.lapisDateField}
|
|
132
|
+
initialMeanProportionInterval={this.initialMeanProportionInterval}
|
|
133
|
+
hideGaps={this.hideGaps}
|
|
134
|
+
pageSizes={this.pageSizes}
|
|
135
|
+
customColumns={this.customColumns}
|
|
136
|
+
/>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
declare global {
|
|
142
|
+
interface HTMLElementTagNameMap {
|
|
143
|
+
'gs-queries-over-time': QueriesOverTimeComponent;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
declare global {
|
|
148
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
149
|
+
namespace JSX {
|
|
150
|
+
interface IntrinsicElements {
|
|
151
|
+
'gs-queries-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -6,5 +6,6 @@ export { RelativeGrowthAdvantageComponent } from './gs-relative-growth-advantage
|
|
|
6
6
|
export { AggregateComponent } from './gs-aggregate';
|
|
7
7
|
export { NumberSequencesOverTimeComponent } from './gs-number-sequences-over-time';
|
|
8
8
|
export { MutationsOverTimeComponent } from './gs-mutations-over-time';
|
|
9
|
+
export { QueriesOverTimeComponent } from './gs-queries-over-time';
|
|
9
10
|
export { SequencesByLocationComponent } from './gs-sequences-by-location';
|
|
10
11
|
export { StatisticsComponent } from './gs-statistics';
|