@genspectrum/dashboard-components 0.5.6 → 0.6.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 +13 -127
- package/dist/dashboard-components.js +95 -109
- package/dist/dashboard-components.js.map +1 -1
- package/dist/genspectrum-components.d.ts +14 -28
- package/dist/style.css +0 -4
- package/package.json +1 -1
- package/src/preact/aggregatedData/aggregate.stories.tsx +0 -2
- package/src/preact/aggregatedData/aggregate.tsx +3 -12
- package/src/preact/components/error-boundary.stories.tsx +2 -6
- package/src/preact/components/error-boundary.tsx +2 -5
- package/src/preact/components/scaling-selector.tsx +9 -3
- package/src/preact/mutationComparison/mutation-comparison.stories.tsx +0 -3
- package/src/preact/mutationComparison/mutation-comparison.tsx +3 -12
- package/src/preact/mutations/mutations.stories.tsx +0 -3
- package/src/preact/mutations/mutations.tsx +4 -13
- package/src/preact/numberSequencesOverTime/number-sequences-over-time-bar-chart.tsx +9 -2
- package/src/preact/numberSequencesOverTime/number-sequences-over-time-line-chart.tsx +9 -2
- package/src/preact/numberSequencesOverTime/number-sequences-over-time.stories.tsx +0 -2
- package/src/preact/numberSequencesOverTime/number-sequences-over-time.tsx +70 -11
- package/src/preact/prevalenceOverTime/prevalence-over-time.stories.tsx +0 -4
- package/src/preact/prevalenceOverTime/prevalence-over-time.tsx +4 -13
- package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.stories.tsx +0 -3
- package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.tsx +2 -7
- package/src/web-components/visualization/gs-aggregate.stories.ts +0 -4
- package/src/web-components/visualization/gs-aggregate.tsx +0 -7
- package/src/web-components/visualization/gs-mutation-comparison.stories.ts +0 -4
- package/src/web-components/visualization/gs-mutation-comparison.tsx +0 -7
- package/src/web-components/visualization/gs-mutations.stories.ts +0 -4
- package/src/web-components/visualization/gs-mutations.tsx +0 -7
- package/src/web-components/visualization/gs-number-sequences-over-time.stories.ts +0 -3
- package/src/web-components/visualization/gs-number-sequences-over-time.tsx +14 -11
- package/src/web-components/visualization/gs-prevalence-over-time.stories.ts +0 -5
- package/src/web-components/visualization/gs-prevalence-over-time.tsx +0 -7
- package/src/web-components/visualization/gs-relative-growth-advantage.stories.ts +0 -4
- package/src/web-components/visualization/gs-relative-growth-advantage.tsx +0 -7
- package/src/preact/components/headline.stories.tsx +0 -47
- package/src/preact/components/headline.tsx +0 -36
- package/src/preact/shared/charts/scales.ts +0 -16
|
@@ -13,7 +13,6 @@ import { ConfidenceIntervalSelector } from '../components/confidence-interval-se
|
|
|
13
13
|
import { CsvDownloadButton } from '../components/csv-download-button';
|
|
14
14
|
import { ErrorBoundary } from '../components/error-boundary';
|
|
15
15
|
import { ErrorDisplay } from '../components/error-display';
|
|
16
|
-
import Headline from '../components/headline';
|
|
17
16
|
import Info, { InfoHeadline1, InfoParagraph } from '../components/info';
|
|
18
17
|
import { LoadingDisplay } from '../components/loading-display';
|
|
19
18
|
import { NoDataDisplay } from '../components/no-data-display';
|
|
@@ -30,7 +29,6 @@ export type View = 'bar' | 'line' | 'bubble' | 'table';
|
|
|
30
29
|
export interface PrevalenceOverTimeProps extends PrevalenceOverTimeInnerProps {
|
|
31
30
|
width: string;
|
|
32
31
|
height: string;
|
|
33
|
-
headline?: string;
|
|
34
32
|
}
|
|
35
33
|
|
|
36
34
|
export interface PrevalenceOverTimeInnerProps {
|
|
@@ -45,20 +43,13 @@ export interface PrevalenceOverTimeInnerProps {
|
|
|
45
43
|
yAxisMaxConfig: YAxisMaxConfig;
|
|
46
44
|
}
|
|
47
45
|
|
|
48
|
-
export const PrevalenceOverTime: FunctionComponent<PrevalenceOverTimeProps> = ({
|
|
49
|
-
width,
|
|
50
|
-
height,
|
|
51
|
-
headline = 'Prevalence over time',
|
|
52
|
-
...innerProps
|
|
53
|
-
}) => {
|
|
46
|
+
export const PrevalenceOverTime: FunctionComponent<PrevalenceOverTimeProps> = ({ width, height, ...innerProps }) => {
|
|
54
47
|
const size = { height, width };
|
|
55
48
|
|
|
56
49
|
return (
|
|
57
|
-
<ErrorBoundary size={size}
|
|
50
|
+
<ErrorBoundary size={size}>
|
|
58
51
|
<ResizeContainer size={size}>
|
|
59
|
-
<
|
|
60
|
-
<PrevalenceOverTimeInner {...innerProps} />
|
|
61
|
-
</Headline>
|
|
52
|
+
<PrevalenceOverTimeInner {...innerProps} />
|
|
62
53
|
</ResizeContainer>
|
|
63
54
|
</ErrorBoundary>
|
|
64
55
|
);
|
|
@@ -235,7 +226,7 @@ const Toolbar: FunctionComponent<ToolbarProps> = ({
|
|
|
235
226
|
<CsvDownloadButton
|
|
236
227
|
className='mx-1 btn btn-xs'
|
|
237
228
|
getData={() => getPrevalenceOverTimeTableData(data, granularity)}
|
|
238
|
-
filename='
|
|
229
|
+
filename='prevalence_over_time.csv'
|
|
239
230
|
/>
|
|
240
231
|
|
|
241
232
|
<PrevalenceOverTimeInfo />
|
|
@@ -20,7 +20,6 @@ export default {
|
|
|
20
20
|
},
|
|
21
21
|
width: { control: 'text' },
|
|
22
22
|
height: { control: 'text' },
|
|
23
|
-
headline: { control: 'text' },
|
|
24
23
|
yAxisMaxConfig: { control: 'object' },
|
|
25
24
|
},
|
|
26
25
|
};
|
|
@@ -35,7 +34,6 @@ export const Primary = {
|
|
|
35
34
|
views={args.views}
|
|
36
35
|
width={args.width}
|
|
37
36
|
height={args.height}
|
|
38
|
-
headline={args.headline}
|
|
39
37
|
lapisDateField={args.lapisDateField}
|
|
40
38
|
yAxisMaxConfig={args.yAxisMaxConfig}
|
|
41
39
|
/>
|
|
@@ -48,7 +46,6 @@ export const Primary = {
|
|
|
48
46
|
views: ['line'],
|
|
49
47
|
width: '100%',
|
|
50
48
|
height: '700px',
|
|
51
|
-
headline: 'Relative growth advantage',
|
|
52
49
|
lapisDateField: 'date',
|
|
53
50
|
yAxisMaxConfig: {
|
|
54
51
|
linear: 1,
|
|
@@ -10,7 +10,6 @@ import { type LapisFilter } from '../../types';
|
|
|
10
10
|
import { LapisUrlContext } from '../LapisUrlContext';
|
|
11
11
|
import { ErrorBoundary } from '../components/error-boundary';
|
|
12
12
|
import { ErrorDisplay } from '../components/error-display';
|
|
13
|
-
import Headline from '../components/headline';
|
|
14
13
|
import Info, { InfoHeadline1, InfoHeadline2, InfoLink, InfoParagraph } from '../components/info';
|
|
15
14
|
import { LoadingDisplay } from '../components/loading-display';
|
|
16
15
|
import { NoDataDisplay } from '../components/no-data-display';
|
|
@@ -26,7 +25,6 @@ export type View = 'line';
|
|
|
26
25
|
export interface RelativeGrowthAdvantageProps extends RelativeGrowthAdvantagePropsInner {
|
|
27
26
|
width: string;
|
|
28
27
|
height: string;
|
|
29
|
-
headline?: string;
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
export interface RelativeGrowthAdvantagePropsInner {
|
|
@@ -41,17 +39,14 @@ export interface RelativeGrowthAdvantagePropsInner {
|
|
|
41
39
|
export const RelativeGrowthAdvantage: FunctionComponent<RelativeGrowthAdvantageProps> = ({
|
|
42
40
|
width,
|
|
43
41
|
height,
|
|
44
|
-
headline = 'Relative growth advantage',
|
|
45
42
|
...innerProps
|
|
46
43
|
}) => {
|
|
47
44
|
const size = { height, width };
|
|
48
45
|
|
|
49
46
|
return (
|
|
50
|
-
<ErrorBoundary size={size}
|
|
47
|
+
<ErrorBoundary size={size}>
|
|
51
48
|
<ResizeContainer size={size}>
|
|
52
|
-
<
|
|
53
|
-
<RelativeGrowthAdvantageInner {...innerProps} />
|
|
54
|
-
</Headline>
|
|
49
|
+
<RelativeGrowthAdvantageInner {...innerProps} />
|
|
55
50
|
</ResizeContainer>
|
|
56
51
|
</ErrorBoundary>
|
|
57
52
|
);
|
|
@@ -14,7 +14,6 @@ const codeExample = `
|
|
|
14
14
|
fields='["division", "host"]'
|
|
15
15
|
filter='{"country": "USA"}'
|
|
16
16
|
views='["table"]'
|
|
17
|
-
headline="Aggregate"
|
|
18
17
|
width='100%'
|
|
19
18
|
height='700px'
|
|
20
19
|
initialSortField="count"
|
|
@@ -33,7 +32,6 @@ const meta: Meta<Required<AggregateProps>> = {
|
|
|
33
32
|
},
|
|
34
33
|
width: { control: 'text' },
|
|
35
34
|
height: { control: 'text' },
|
|
36
|
-
headline: { control: 'text' },
|
|
37
35
|
pageSize: { control: 'object' },
|
|
38
36
|
initialSortField: { control: 'text' },
|
|
39
37
|
initialSortDirection: {
|
|
@@ -80,7 +78,6 @@ export const Table: StoryObj<Required<AggregateProps>> = {
|
|
|
80
78
|
.views=${args.views}
|
|
81
79
|
.width=${args.width}
|
|
82
80
|
.height=${args.height}
|
|
83
|
-
.headline=${args.headline}
|
|
84
81
|
.initialSortField=${args.initialSortField}
|
|
85
82
|
.initialSortDirection=${args.initialSortDirection}
|
|
86
83
|
.pageSize=${args.pageSize}
|
|
@@ -95,7 +92,6 @@ export const Table: StoryObj<Required<AggregateProps>> = {
|
|
|
95
92
|
},
|
|
96
93
|
width: '100%',
|
|
97
94
|
height: '700px',
|
|
98
|
-
headline: 'Aggregate',
|
|
99
95
|
initialSortField: 'count',
|
|
100
96
|
initialSortDirection: 'descending',
|
|
101
97
|
pageSize: 10,
|
|
@@ -61,12 +61,6 @@ export class AggregateComponent extends PreactLitAdapterWithGridJsStyles {
|
|
|
61
61
|
@property({ type: String })
|
|
62
62
|
height: string = '700px';
|
|
63
63
|
|
|
64
|
-
/**
|
|
65
|
-
* The headline of the component. Set to an empty string to hide the headline.
|
|
66
|
-
*/
|
|
67
|
-
@property({ type: String })
|
|
68
|
-
headline: string = 'Aggregate';
|
|
69
|
-
|
|
70
64
|
/**
|
|
71
65
|
* The field by which the table is initially sorted.
|
|
72
66
|
* Must be one of the fields specified in the fields property, 'count', or 'proportion'.
|
|
@@ -95,7 +89,6 @@ export class AggregateComponent extends PreactLitAdapterWithGridJsStyles {
|
|
|
95
89
|
filter={this.filter}
|
|
96
90
|
width={this.width}
|
|
97
91
|
height={this.height}
|
|
98
|
-
headline={this.headline}
|
|
99
92
|
initialSortField={this.initialSortField}
|
|
100
93
|
initialSortDirection={this.initialSortDirection}
|
|
101
94
|
pageSize={this.pageSize}
|
|
@@ -16,7 +16,6 @@ const codeExample = String.raw`
|
|
|
16
16
|
lapisFilters='[{ "displayName": "Data in Switzerland", "lapisFilter": { "country": "Switzerland" }}, { "displayName": "Data in Germany", "lapisFilter": { "country": "Germany" }}]'
|
|
17
17
|
sequenceType="nucleotide"
|
|
18
18
|
views='["table", "venn"]'
|
|
19
|
-
headline="Mutation comparison"
|
|
20
19
|
width='100%'
|
|
21
20
|
height='700px'
|
|
22
21
|
pageSize="10"
|
|
@@ -37,7 +36,6 @@ const meta: Meta<Required<MutationComparisonProps>> = {
|
|
|
37
36
|
},
|
|
38
37
|
width: { control: 'text' },
|
|
39
38
|
height: { control: 'text' },
|
|
40
|
-
headline: { control: 'text' },
|
|
41
39
|
pageSize: { control: 'object' },
|
|
42
40
|
},
|
|
43
41
|
parameters: withComponentDocs({
|
|
@@ -61,7 +59,6 @@ const Template: StoryObj<Required<MutationComparisonProps>> = {
|
|
|
61
59
|
.views=${args.views}
|
|
62
60
|
.width=${args.width}
|
|
63
61
|
.height=${args.height}
|
|
64
|
-
.headline=${args.headline}
|
|
65
62
|
.pageSize=${args.pageSize}
|
|
66
63
|
></gs-mutation-comparison>
|
|
67
64
|
</gs-app>
|
|
@@ -93,7 +90,6 @@ export const Default: StoryObj<Required<MutationComparisonProps>> = {
|
|
|
93
90
|
views: ['table', 'venn'],
|
|
94
91
|
width: '100%',
|
|
95
92
|
height: '700px',
|
|
96
|
-
headline: 'Mutation comparison',
|
|
97
93
|
pageSize: 10,
|
|
98
94
|
},
|
|
99
95
|
parameters: {
|
|
@@ -75,12 +75,6 @@ export class MutationComparisonComponent extends PreactLitAdapterWithGridJsStyle
|
|
|
75
75
|
@property({ type: String })
|
|
76
76
|
height: string = '700px';
|
|
77
77
|
|
|
78
|
-
/**
|
|
79
|
-
* The headline of the component. Set to an empty string to hide the headline.
|
|
80
|
-
*/
|
|
81
|
-
@property({ type: String })
|
|
82
|
-
headline: string = 'Mutation comparison';
|
|
83
|
-
|
|
84
78
|
/**
|
|
85
79
|
* The maximum number of rows to display in the table view.
|
|
86
80
|
* Set to `false` to disable pagination. Set to `true` to enable pagination with a default limit (10).
|
|
@@ -96,7 +90,6 @@ export class MutationComparisonComponent extends PreactLitAdapterWithGridJsStyle
|
|
|
96
90
|
views={this.views}
|
|
97
91
|
width={this.width}
|
|
98
92
|
height={this.height}
|
|
99
|
-
headline={this.headline}
|
|
100
93
|
pageSize={this.pageSize}
|
|
101
94
|
/>
|
|
102
95
|
);
|
|
@@ -16,7 +16,6 @@ const codeExample = String.raw`
|
|
|
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
|
-
headline="Mutations"
|
|
20
19
|
width='100%'
|
|
21
20
|
height='700px'
|
|
22
21
|
pageSize="10"
|
|
@@ -37,7 +36,6 @@ const meta: Meta<Required<MutationsProps>> = {
|
|
|
37
36
|
},
|
|
38
37
|
width: { control: 'text' },
|
|
39
38
|
height: { control: 'text' },
|
|
40
|
-
headline: { control: 'text' },
|
|
41
39
|
pageSize: { control: 'object' },
|
|
42
40
|
},
|
|
43
41
|
args: {
|
|
@@ -46,7 +44,6 @@ const meta: Meta<Required<MutationsProps>> = {
|
|
|
46
44
|
views: ['grid', 'table', 'insertions'],
|
|
47
45
|
width: '100%',
|
|
48
46
|
height: '700px',
|
|
49
|
-
headline: 'Mutations',
|
|
50
47
|
pageSize: 10,
|
|
51
48
|
},
|
|
52
49
|
parameters: withComponentDocs({
|
|
@@ -70,7 +67,6 @@ const Template: StoryObj<Required<MutationsProps>> = {
|
|
|
70
67
|
.views=${args.views}
|
|
71
68
|
.width=${args.width}
|
|
72
69
|
.height=${args.height}
|
|
73
|
-
.headline=${args.headline}
|
|
74
70
|
.pageSize=${args.pageSize}
|
|
75
71
|
></gs-mutations>
|
|
76
72
|
</gs-app>
|
|
@@ -70,12 +70,6 @@ export class MutationsComponent extends PreactLitAdapterWithGridJsStyles {
|
|
|
70
70
|
@property({ type: String })
|
|
71
71
|
height: string = '700px';
|
|
72
72
|
|
|
73
|
-
/**
|
|
74
|
-
* The headline of the component. Set to an empty string to hide the headline.
|
|
75
|
-
*/
|
|
76
|
-
@property({ type: String })
|
|
77
|
-
headline: string = 'Mutations';
|
|
78
|
-
|
|
79
73
|
/**
|
|
80
74
|
* The maximum number of rows to display in the table view.
|
|
81
75
|
* Set to `false` to disable pagination. Set to `true` to enable pagination with a default limit (10).
|
|
@@ -91,7 +85,6 @@ export class MutationsComponent extends PreactLitAdapterWithGridJsStyles {
|
|
|
91
85
|
views={this.views}
|
|
92
86
|
width={this.width}
|
|
93
87
|
height={this.height}
|
|
94
|
-
headline={this.headline}
|
|
95
88
|
pageSize={this.pageSize}
|
|
96
89
|
/>
|
|
97
90
|
);
|
|
@@ -18,7 +18,6 @@ const codeExample = String.raw`
|
|
|
18
18
|
lapisFilter='[{ "displayName": "EG", "lapisFilter": { "country": "USA", "pangoLineage": "EG*" }}, { "displayName": "JN.1", "lapisFilter": { "country": "USA", "pangoLineage": "JN.1*" }}]'
|
|
19
19
|
lapisDateField="date"
|
|
20
20
|
views='["bar", "line", "table"]'
|
|
21
|
-
headline="Number of sequences over time"
|
|
22
21
|
width="100%"
|
|
23
22
|
height="700px"
|
|
24
23
|
granularity="month"
|
|
@@ -61,7 +60,6 @@ const Template: StoryObj<NumberSequencesOverTimeProps> = {
|
|
|
61
60
|
.views=${args.views}
|
|
62
61
|
.width=${args.width}
|
|
63
62
|
.height=${args.height}
|
|
64
|
-
.headline=${args.headline}
|
|
65
63
|
.granularity=${args.granularity}
|
|
66
64
|
.smoothingWindow=${args.smoothingWindow}
|
|
67
65
|
.pageSize=${args.pageSize}
|
|
@@ -76,7 +74,6 @@ const Template: StoryObj<NumberSequencesOverTimeProps> = {
|
|
|
76
74
|
lapisDateField: 'date',
|
|
77
75
|
width: '100%',
|
|
78
76
|
height: '700px',
|
|
79
|
-
headline: 'Number of sequences over time',
|
|
80
77
|
smoothingWindow: 0,
|
|
81
78
|
granularity: 'month',
|
|
82
79
|
pageSize: 10,
|
|
@@ -8,20 +8,30 @@ import type { Equals, Expect } from '../../utils/typeAssertions';
|
|
|
8
8
|
import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsStyles';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* ## Context
|
|
12
|
+
*
|
|
13
|
+
* This component displays the number of sequences over time of one or more datasets,
|
|
14
|
+
* selected by LAPIS filters.
|
|
15
|
+
*
|
|
16
|
+
* In the chart views, the user can select the y-axis scale (linear, logistic).
|
|
17
|
+
* The x-axis shows all available time intervals available in the datasets in the selected `granularity`.
|
|
18
|
+
* Thus, the `lapisFilter` implicitly also defines the range that is shown on the x-axis.
|
|
19
|
+
* If you want to restrict the x-axis to a smaller date range,
|
|
20
|
+
* then you need to set appropriate filter values in the `lapisFilter`.
|
|
12
21
|
*/
|
|
13
22
|
@customElement('gs-number-sequences-over-time')
|
|
14
23
|
export class NumberSequencesOverTimeComponent extends PreactLitAdapterWithGridJsStyles {
|
|
15
24
|
// prettier-ignore
|
|
16
25
|
// The multiline union type must not start with `|` because it looks weird in the Storybook docs
|
|
17
26
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
27
|
+
* Required.
|
|
28
|
+
*
|
|
29
|
+
* Either a LAPIS filter or an array of LAPIS filters to fetch the number of sequences for.
|
|
20
30
|
*
|
|
21
31
|
* The `lapisFilter` will be sent as is to LAPIS to select the data.
|
|
22
32
|
* It must be a valid LAPIS filter object.
|
|
23
33
|
*
|
|
24
|
-
* The `displayName` will be used
|
|
34
|
+
* The `displayName` will be used to label the component views.
|
|
25
35
|
* It should be human-readable.
|
|
26
36
|
*
|
|
27
37
|
*/ @property({type: Object})
|
|
@@ -51,12 +61,6 @@ export class NumberSequencesOverTimeComponent extends PreactLitAdapterWithGridJs
|
|
|
51
61
|
@property({ type: Array })
|
|
52
62
|
views: ('bar' | 'line' | 'table')[] = ['bar', 'line', 'table'];
|
|
53
63
|
|
|
54
|
-
/**
|
|
55
|
-
* The headline of the component. Set to an empty string to hide the headline.
|
|
56
|
-
*/
|
|
57
|
-
@property({ type: String })
|
|
58
|
-
headline: string = 'Number of sequences of time';
|
|
59
|
-
|
|
60
64
|
/**
|
|
61
65
|
* The width of the component.
|
|
62
66
|
*
|
|
@@ -104,7 +108,6 @@ export class NumberSequencesOverTimeComponent extends PreactLitAdapterWithGridJs
|
|
|
104
108
|
lapisFilter={this.lapisFilter}
|
|
105
109
|
lapisDateField={this.lapisDateField}
|
|
106
110
|
views={this.views}
|
|
107
|
-
headline={this.headline}
|
|
108
111
|
width={this.width}
|
|
109
112
|
height={this.height}
|
|
110
113
|
granularity={this.granularity}
|
|
@@ -23,7 +23,6 @@ const codeExample = String.raw`
|
|
|
23
23
|
smoothingWindow="0"
|
|
24
24
|
views='["bar", "line", "bubble", "table"]'
|
|
25
25
|
confidenceIntervalMethods='["wilson"]'
|
|
26
|
-
headline="Prevalence over time"
|
|
27
26
|
width="100%"
|
|
28
27
|
height="700px"
|
|
29
28
|
lapisDateField="date"
|
|
@@ -53,7 +52,6 @@ const meta: Meta<Required<PrevalenceOverTimeComponentProps>> = {
|
|
|
53
52
|
},
|
|
54
53
|
width: { control: 'text' },
|
|
55
54
|
height: { control: 'text' },
|
|
56
|
-
headline: { control: 'text' },
|
|
57
55
|
pageSize: { control: 'object' },
|
|
58
56
|
yAxisMaxLinear: { control: 'object' },
|
|
59
57
|
yAxisMaxLogarithmic: { control: 'object' },
|
|
@@ -82,7 +80,6 @@ const Template: StoryObj<Required<PrevalenceOverTimeComponentProps>> = {
|
|
|
82
80
|
.confidenceIntervalMethods=${args.confidenceIntervalMethods}
|
|
83
81
|
.width=${args.width}
|
|
84
82
|
.height=${args.height}
|
|
85
|
-
.headline=${args.headline}
|
|
86
83
|
.lapisDateField=${args.lapisDateField}
|
|
87
84
|
.pageSize=${args.pageSize}
|
|
88
85
|
.yAxisMaxLinear=${args.yAxisMaxLinear}
|
|
@@ -106,7 +103,6 @@ export const TwoDatasets: StoryObj<Required<PrevalenceOverTimeComponentProps>> =
|
|
|
106
103
|
confidenceIntervalMethods: ['wilson'],
|
|
107
104
|
width: '100%',
|
|
108
105
|
height: '700px',
|
|
109
|
-
headline: 'Prevalence over time',
|
|
110
106
|
lapisDateField: 'date',
|
|
111
107
|
pageSize: 10,
|
|
112
108
|
yAxisMaxLinear: 1,
|
|
@@ -181,7 +177,6 @@ export const OneDataset: StoryObj<Required<PrevalenceOverTimeComponentProps>> =
|
|
|
181
177
|
confidenceIntervalMethods: ['wilson'],
|
|
182
178
|
width: '100%',
|
|
183
179
|
height: '700px',
|
|
184
|
-
headline: 'Prevalence over time',
|
|
185
180
|
lapisDateField: 'date',
|
|
186
181
|
pageSize: 10,
|
|
187
182
|
yAxisMaxLinear: 1,
|
|
@@ -109,12 +109,6 @@ export class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyle
|
|
|
109
109
|
@property({ type: Array })
|
|
110
110
|
confidenceIntervalMethods: ('wilson' | 'none')[] = ['wilson'];
|
|
111
111
|
|
|
112
|
-
/**
|
|
113
|
-
* The headline of the component. Set to an empty string to hide the headline.
|
|
114
|
-
*/
|
|
115
|
-
@property({ type: String })
|
|
116
|
-
headline: string = 'Prevalence over time';
|
|
117
|
-
|
|
118
112
|
/**
|
|
119
113
|
* The width of the component.
|
|
120
114
|
*
|
|
@@ -179,7 +173,6 @@ export class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyle
|
|
|
179
173
|
confidenceIntervalMethods={this.confidenceIntervalMethods}
|
|
180
174
|
width={this.width}
|
|
181
175
|
height={this.height}
|
|
182
|
-
headline={this.headline}
|
|
183
176
|
lapisDateField={this.lapisDateField}
|
|
184
177
|
pageSize={this.pageSize}
|
|
185
178
|
yAxisMaxConfig={{
|
|
@@ -18,7 +18,6 @@ const codeExample = String.raw`
|
|
|
18
18
|
views='["line"]'
|
|
19
19
|
width='100%'
|
|
20
20
|
height='700px'
|
|
21
|
-
headline="Relative growth advantage"
|
|
22
21
|
lapisDateField="date"
|
|
23
22
|
yAxisMaxLinear="1"
|
|
24
23
|
yAxisMaxLogarithmic="limitTo1"
|
|
@@ -37,7 +36,6 @@ const meta: Meta<RelativeGrowthAdvantageComponentProps> = {
|
|
|
37
36
|
},
|
|
38
37
|
width: { control: 'text' },
|
|
39
38
|
height: { control: 'text' },
|
|
40
|
-
headline: { control: 'text' },
|
|
41
39
|
yAxisMaxLinear: { control: 'object' },
|
|
42
40
|
yAxisMaxLogarithmic: { control: 'object' },
|
|
43
41
|
},
|
|
@@ -63,7 +61,6 @@ const Template: StoryObj<Required<RelativeGrowthAdvantageComponentProps>> = {
|
|
|
63
61
|
.views=${args.views}
|
|
64
62
|
.width=${args.width}
|
|
65
63
|
.height=${args.height}
|
|
66
|
-
.headline=${args.headline}
|
|
67
64
|
.lapisDateField=${args.lapisDateField}
|
|
68
65
|
.yAxisMaxLinear=${args.yAxisMaxLinear}
|
|
69
66
|
.yAxisMaxLogarithmic=${args.yAxisMaxLogarithmic}
|
|
@@ -86,7 +83,6 @@ export const Default: StoryObj<Required<RelativeGrowthAdvantageComponentProps>>
|
|
|
86
83
|
views: ['line'],
|
|
87
84
|
width: '100%',
|
|
88
85
|
height: '700px',
|
|
89
|
-
headline: 'Relative growth advantage',
|
|
90
86
|
lapisDateField: 'date',
|
|
91
87
|
yAxisMaxLinear: 1,
|
|
92
88
|
yAxisMaxLogarithmic: 'limitTo1',
|
|
@@ -69,12 +69,6 @@ export class RelativeGrowthAdvantageComponent extends PreactLitAdapter {
|
|
|
69
69
|
@property({ type: Array })
|
|
70
70
|
views: 'line'[] = ['line'];
|
|
71
71
|
|
|
72
|
-
/**
|
|
73
|
-
* The headline of the component. Set to an empty string to hide the headline.
|
|
74
|
-
*/
|
|
75
|
-
@property({ type: String })
|
|
76
|
-
headline: string = 'Relative growth advantage';
|
|
77
|
-
|
|
78
72
|
/**
|
|
79
73
|
* The width of the component.
|
|
80
74
|
*
|
|
@@ -130,7 +124,6 @@ export class RelativeGrowthAdvantageComponent extends PreactLitAdapter {
|
|
|
130
124
|
views={this.views}
|
|
131
125
|
width={this.width}
|
|
132
126
|
height={this.height}
|
|
133
|
-
headline={this.headline}
|
|
134
127
|
lapisDateField={this.lapisDateField}
|
|
135
128
|
yAxisMaxConfig={{
|
|
136
129
|
linear: this.yAxisMaxLinear,
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { type Meta, type StoryObj } from '@storybook/preact';
|
|
2
|
-
import { expect, within } from '@storybook/test';
|
|
3
|
-
|
|
4
|
-
import Headline, { type HeadlineProps } from './headline';
|
|
5
|
-
|
|
6
|
-
const meta: Meta<HeadlineProps> = {
|
|
7
|
-
title: 'Component/Headline',
|
|
8
|
-
component: Headline,
|
|
9
|
-
parameters: { fetchMock: {} },
|
|
10
|
-
argTypes: {
|
|
11
|
-
heading: { control: 'text' },
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default meta;
|
|
16
|
-
|
|
17
|
-
export const HeadlineStory: StoryObj<HeadlineProps> = {
|
|
18
|
-
render: (args) => (
|
|
19
|
-
<Headline {...args}>
|
|
20
|
-
<div class='flex justify-center px-4 py-16 bg-base-200'>Some Content</div>
|
|
21
|
-
</Headline>
|
|
22
|
-
),
|
|
23
|
-
args: {
|
|
24
|
-
heading: 'My Headline',
|
|
25
|
-
},
|
|
26
|
-
play: async ({ canvasElement }) => {
|
|
27
|
-
const canvas = within(canvasElement);
|
|
28
|
-
|
|
29
|
-
await expect(canvas.getByText('My Headline')).toBeInTheDocument();
|
|
30
|
-
await expect(canvas.getByText('Some Content')).toBeInTheDocument();
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const NoHeadlineStory: StoryObj<HeadlineProps> = {
|
|
35
|
-
render: (args) => (
|
|
36
|
-
<Headline {...args}>
|
|
37
|
-
<div class='flex justify-center px-4 py-16 bg-base-200'>Some Content</div>
|
|
38
|
-
</Headline>
|
|
39
|
-
),
|
|
40
|
-
args: {},
|
|
41
|
-
play: async ({ canvasElement }) => {
|
|
42
|
-
const canvas = within(canvasElement);
|
|
43
|
-
|
|
44
|
-
await expect(canvas.queryByText('My Headline')).not.toBeInTheDocument();
|
|
45
|
-
await expect(canvas.getByText('Some Content')).toBeInTheDocument();
|
|
46
|
-
},
|
|
47
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { type FunctionComponent } from 'preact';
|
|
2
|
-
import { useEffect, useRef, useState } from 'preact/hooks';
|
|
3
|
-
|
|
4
|
-
export interface HeadlineProps {
|
|
5
|
-
heading?: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const Headline: FunctionComponent<HeadlineProps> = ({ heading, children }) => {
|
|
9
|
-
if (!heading) {
|
|
10
|
-
return <>{children}</>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return <ResizingHeadline heading={heading}>{children}</ResizingHeadline>;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const ResizingHeadline: FunctionComponent<HeadlineProps> = ({ heading, children }) => {
|
|
17
|
-
const ref = useRef<HTMLHeadingElement>(null);
|
|
18
|
-
|
|
19
|
-
const [h1Height, setH1Height] = useState('2rem');
|
|
20
|
-
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (ref.current) {
|
|
23
|
-
const h1Height = ref.current.getBoundingClientRect().height;
|
|
24
|
-
setH1Height(`${h1Height}px`);
|
|
25
|
-
}
|
|
26
|
-
}, []);
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<div className='h-full w-full'>
|
|
30
|
-
<h1 ref={ref}>{heading}</h1>
|
|
31
|
-
<div style={{ height: `calc(100% - ${h1Height})` }}>{children}</div>
|
|
32
|
-
</div>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default Headline;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export type ScaleType = 'linear' | 'logarithmic' | 'logit';
|
|
2
|
-
|
|
3
|
-
export function getYAxisScale(scaleType: ScaleType) {
|
|
4
|
-
switch (scaleType) {
|
|
5
|
-
case 'linear': {
|
|
6
|
-
return { beginAtZero: true, type: 'linear' as const };
|
|
7
|
-
}
|
|
8
|
-
case 'logarithmic': {
|
|
9
|
-
return { type: 'logarithmic' as const };
|
|
10
|
-
}
|
|
11
|
-
case 'logit':
|
|
12
|
-
return { type: 'logit' as const };
|
|
13
|
-
default:
|
|
14
|
-
return { beginAtZero: true, type: 'linear' as const };
|
|
15
|
-
}
|
|
16
|
-
}
|