@genspectrum/dashboard-components 0.4.4 → 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.
- package/README.md +2 -2
- package/custom-elements.json +279 -108
- package/dist/dashboard-components.js +495 -283
- package/dist/dashboard-components.js.map +1 -1
- package/dist/genspectrum-components.d.ts +115 -55
- package/dist/style.css +34 -7
- package/package.json +5 -5
- package/src/preact/aggregatedData/aggregate-table.tsx +3 -2
- package/src/preact/aggregatedData/aggregate.stories.tsx +2 -0
- package/src/preact/aggregatedData/aggregate.tsx +8 -3
- package/src/preact/components/table.stories.tsx +51 -1
- package/src/preact/components/table.tsx +4 -3
- package/src/preact/locationFilter/location-filter.stories.tsx +12 -1
- package/src/preact/locationFilter/location-filter.tsx +10 -3
- package/src/preact/mutationComparison/mutation-comparison-table.tsx +7 -2
- package/src/preact/mutationComparison/mutation-comparison-venn.tsx +1 -1
- package/src/preact/mutationComparison/mutation-comparison.stories.tsx +21 -18
- package/src/preact/mutationComparison/mutation-comparison.tsx +30 -8
- package/src/preact/mutationComparison/queryMutationData.ts +4 -4
- package/src/preact/mutations/mutations-grid.tsx +8 -2
- package/src/preact/mutations/mutations-insertions-table.tsx +3 -2
- package/src/preact/mutations/mutations-table.tsx +3 -2
- package/src/preact/mutations/mutations.stories.tsx +6 -3
- package/src/preact/mutations/mutations.tsx +30 -10
- package/src/preact/mutations/queryMutations.ts +3 -3
- package/src/preact/prevalenceOverTime/__mockData__/{denominatorOneVariant.json → denominatorFilterOneDataset.json} +1 -1
- package/src/preact/prevalenceOverTime/__mockData__/{numeratorOneVariant.json → numeratorFilterOneDataset.json} +1 -1
- package/src/preact/prevalenceOverTime/prevalence-over-time-bar-chart.tsx +42 -5
- package/src/preact/prevalenceOverTime/prevalence-over-time-bubble-chart.tsx +26 -7
- package/src/preact/prevalenceOverTime/prevalence-over-time-line-chart.tsx +62 -28
- package/src/preact/prevalenceOverTime/prevalence-over-time-table.tsx +3 -2
- package/src/preact/prevalenceOverTime/prevalence-over-time.stories.tsx +30 -16
- package/src/preact/prevalenceOverTime/prevalence-over-time.tsx +46 -12
- package/src/preact/relativeGrowthAdvantage/relative-growth-advantage-chart.tsx +39 -7
- package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.stories.tsx +10 -4
- package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.tsx +19 -10
- package/src/preact/shared/charts/confideceInterval.ts +7 -2
- package/src/preact/shared/charts/getYAxisMax.ts +24 -0
- package/src/preact/shared/charts/getYAxisScale.ts +1 -3
- package/src/query/queryAggregateData.ts +2 -2
- package/src/query/queryInsertions.ts +7 -2
- package/src/query/querySubstitutionsOrDeletions.ts +2 -2
- package/src/web-components/input/gs-date-range-selector.tsx +1 -1
- package/src/web-components/input/gs-location-filter.stories.ts +11 -0
- package/src/web-components/input/gs-location-filter.tsx +15 -2
- package/src/web-components/input/gs-mutation-filter.tsx +1 -1
- package/src/web-components/input/gs-text-input.tsx +1 -1
- package/src/web-components/visualization/gs-aggregate.stories.ts +4 -0
- package/src/web-components/visualization/gs-aggregate.tsx +10 -2
- package/src/web-components/visualization/gs-mutation-comparison.stories.ts +16 -12
- package/src/web-components/visualization/gs-mutation-comparison.tsx +26 -19
- package/src/web-components/visualization/gs-mutations.stories.ts +8 -4
- package/src/web-components/visualization/gs-mutations.tsx +18 -11
- package/src/web-components/visualization/gs-prevalence-over-time.stories.ts +51 -35
- package/src/web-components/visualization/gs-prevalence-over-time.tsx +66 -24
- package/src/web-components/visualization/gs-relative-growth-advantage.stories.ts +32 -18
- package/src/web-components/visualization/gs-relative-growth-advantage.tsx +51 -13
- /package/src/preact/mutationComparison/__mockData__/{nucleotideMutationsOtherVariant.json → nucleotideMutationsOtherDataset.json} +0 -0
- /package/src/preact/mutationComparison/__mockData__/{nucleotideMutationsSomeVariant.json → nucleotideMutationsSomeDataset.json} +0 -0
- /package/src/preact/prevalenceOverTime/__mockData__/{denominator.json → denominatorFilter.json} +0 -0
- /package/src/preact/prevalenceOverTime/__mockData__/{numeratorEG.json → numeratorFilterEG.json} +0 -0
- /package/src/preact/prevalenceOverTime/__mockData__/{numeratorJN1.json → numeratorFilterJN1.json} +0 -0
- /package/src/preact/relativeGrowthAdvantage/__mockData__/{denominator.json → denominatorFilter.json} +0 -0
- /package/src/preact/relativeGrowthAdvantage/__mockData__/{numerator.json → numeratorFilter.json} +0 -0
|
@@ -10,12 +10,12 @@ import { type DisplayedSegment } from '../components/SegmentSelector';
|
|
|
10
10
|
import { type DisplayedMutationType } from '../components/mutation-type-selector';
|
|
11
11
|
|
|
12
12
|
export async function queryMutationsData(
|
|
13
|
-
|
|
13
|
+
lapisFilter: LapisFilter,
|
|
14
14
|
sequenceType: 'nucleotide' | 'amino acid',
|
|
15
15
|
lapis: string,
|
|
16
16
|
) {
|
|
17
|
-
const substitutionsOrDeletions = (await querySubstitutionsOrDeletions(
|
|
18
|
-
const insertions = (await queryInsertions(
|
|
17
|
+
const substitutionsOrDeletions = (await querySubstitutionsOrDeletions(lapisFilter, sequenceType, lapis)).content;
|
|
18
|
+
const insertions = (await queryInsertions(lapisFilter, sequenceType, lapis)).content;
|
|
19
19
|
|
|
20
20
|
return {
|
|
21
21
|
substitutionsOrDeletions,
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { Chart, type ChartConfiguration, registerables, type TooltipItem } from 'chart.js';
|
|
2
2
|
import { BarWithErrorBar, BarWithErrorBarsController } from 'chartjs-chart-error-bars';
|
|
3
3
|
|
|
4
|
+
import { maxInData } from './prevalence-over-time';
|
|
4
5
|
import { type PrevalenceOverTimeData, type PrevalenceOverTimeVariantData } from '../../query/queryPrevalenceOverTime';
|
|
6
|
+
import type { Temporal } from '../../utils/temporal';
|
|
5
7
|
import GsChart from '../components/chart';
|
|
6
8
|
import { LogitScale } from '../shared/charts/LogitScale';
|
|
7
9
|
import { singleGraphColorRGBAById } from '../shared/charts/colors';
|
|
8
10
|
import { type ConfidenceIntervalMethod, wilson95PercentConfidenceInterval } from '../shared/charts/confideceInterval';
|
|
11
|
+
import { getYAxisMax, type YAxisMaxConfig } from '../shared/charts/getYAxisMax';
|
|
9
12
|
import { getYAxisScale, type ScaleType } from '../shared/charts/getYAxisScale';
|
|
10
13
|
|
|
11
14
|
interface PrevalenceOverTimeBarChartProps {
|
|
12
15
|
data: PrevalenceOverTimeData;
|
|
13
16
|
yAxisScaleType: ScaleType;
|
|
14
17
|
confidenceIntervalMethod: ConfidenceIntervalMethod;
|
|
18
|
+
yAxisMaxConfig: YAxisMaxConfig;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
Chart.register(...registerables, LogitScale, BarWithErrorBarsController, BarWithErrorBar);
|
|
@@ -20,18 +24,32 @@ const PrevalenceOverTimeBarChart = ({
|
|
|
20
24
|
data,
|
|
21
25
|
yAxisScaleType,
|
|
22
26
|
confidenceIntervalMethod,
|
|
27
|
+
yAxisMaxConfig,
|
|
23
28
|
}: PrevalenceOverTimeBarChartProps) => {
|
|
29
|
+
const nullFirstData = data.map((variantData) => {
|
|
30
|
+
return {
|
|
31
|
+
content: variantData.content.sort(sortNullToBeginningThenByDate),
|
|
32
|
+
displayName: variantData.displayName,
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const datasets = nullFirstData.map((graphData, index) => getDataset(graphData, index, confidenceIntervalMethod));
|
|
37
|
+
|
|
38
|
+
const maxY =
|
|
39
|
+
yAxisScaleType !== 'logit'
|
|
40
|
+
? getYAxisMax(maxInData(nullFirstData), yAxisMaxConfig?.[yAxisScaleType])
|
|
41
|
+
: undefined;
|
|
42
|
+
|
|
24
43
|
const config: ChartConfiguration = {
|
|
25
44
|
type: BarWithErrorBarsController.id,
|
|
26
45
|
data: {
|
|
27
|
-
|
|
28
|
-
datasets: data.map((graphData, index) => datasets(graphData, index, confidenceIntervalMethod)),
|
|
46
|
+
datasets,
|
|
29
47
|
},
|
|
30
48
|
options: {
|
|
31
49
|
maintainAspectRatio: false,
|
|
32
50
|
animation: false,
|
|
33
51
|
scales: {
|
|
34
|
-
y: getYAxisScale(yAxisScaleType),
|
|
52
|
+
y: { ...getYAxisScale(yAxisScaleType), max: maxY },
|
|
35
53
|
},
|
|
36
54
|
plugins: {
|
|
37
55
|
legend: {
|
|
@@ -45,7 +63,23 @@ const PrevalenceOverTimeBarChart = ({
|
|
|
45
63
|
return <GsChart configuration={config} />;
|
|
46
64
|
};
|
|
47
65
|
|
|
48
|
-
|
|
66
|
+
function sortNullToBeginningThenByDate(
|
|
67
|
+
a: { count: number; prevalence: number; total: number; dateRange: Temporal | null },
|
|
68
|
+
b: {
|
|
69
|
+
count: number;
|
|
70
|
+
prevalence: number;
|
|
71
|
+
total: number;
|
|
72
|
+
dateRange: Temporal | null;
|
|
73
|
+
},
|
|
74
|
+
) {
|
|
75
|
+
return a.dateRange === null
|
|
76
|
+
? -1
|
|
77
|
+
: b.dateRange === null
|
|
78
|
+
? 1
|
|
79
|
+
: a.dateRange.toString().localeCompare(b.dateRange.toString());
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const getDataset = (
|
|
49
83
|
prevalenceOverTimeVariant: PrevalenceOverTimeVariantData,
|
|
50
84
|
index: number,
|
|
51
85
|
confidenceIntervalMethod: ConfidenceIntervalMethod,
|
|
@@ -66,12 +100,15 @@ const datasets = (
|
|
|
66
100
|
y: dataPoint.prevalence,
|
|
67
101
|
yMin: wilson95PercentConfidenceInterval(dataPoint.count, dataPoint.total).lowerLimit,
|
|
68
102
|
yMax: wilson95PercentConfidenceInterval(dataPoint.count, dataPoint.total).upperLimit,
|
|
103
|
+
x: dataPoint.dateRange?.toString() ?? 'Unknown',
|
|
69
104
|
})),
|
|
70
105
|
};
|
|
71
106
|
default:
|
|
72
107
|
return {
|
|
73
108
|
...generalConfig,
|
|
74
|
-
data: prevalenceOverTimeVariant.content.map((dataPoint) =>
|
|
109
|
+
data: prevalenceOverTimeVariant.content.map((dataPoint) => {
|
|
110
|
+
return { y: dataPoint.prevalence, x: dataPoint.dateRange };
|
|
111
|
+
}),
|
|
75
112
|
};
|
|
76
113
|
}
|
|
77
114
|
};
|
|
@@ -1,32 +1,51 @@
|
|
|
1
1
|
import { Chart, type ChartConfiguration, registerables } from 'chart.js';
|
|
2
2
|
|
|
3
|
+
import { maxInData } from './prevalence-over-time';
|
|
3
4
|
import { type PrevalenceOverTimeData } from '../../query/queryPrevalenceOverTime';
|
|
4
5
|
import { addUnit, minusTemporal } from '../../utils/temporal';
|
|
5
6
|
import { getMinMaxNumber } from '../../utils/utils';
|
|
6
7
|
import GsChart from '../components/chart';
|
|
7
8
|
import { LogitScale } from '../shared/charts/LogitScale';
|
|
8
9
|
import { singleGraphColorRGBAById } from '../shared/charts/colors';
|
|
10
|
+
import { getYAxisMax, type YAxisMaxConfig } from '../shared/charts/getYAxisMax';
|
|
9
11
|
import { getYAxisScale, type ScaleType } from '../shared/charts/getYAxisScale';
|
|
10
12
|
|
|
11
13
|
interface PrevalenceOverTimeBubbleChartProps {
|
|
12
14
|
data: PrevalenceOverTimeData;
|
|
13
15
|
yAxisScaleType: ScaleType;
|
|
16
|
+
yAxisMaxConfig: YAxisMaxConfig;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
Chart.register(...registerables, LogitScale);
|
|
17
20
|
|
|
18
|
-
const PrevalenceOverTimeBubbleChart = ({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
const PrevalenceOverTimeBubbleChart = ({
|
|
22
|
+
data,
|
|
23
|
+
yAxisScaleType,
|
|
24
|
+
yAxisMaxConfig,
|
|
25
|
+
}: PrevalenceOverTimeBubbleChartProps) => {
|
|
26
|
+
const nonNullDateRangeData = data.map((variantData) => {
|
|
27
|
+
return {
|
|
28
|
+
content: variantData.content.filter((dataPoint) => dataPoint.dateRange !== null),
|
|
29
|
+
displayName: variantData.displayName,
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const firstDate = nonNullDateRangeData[0].content[0].dateRange!;
|
|
34
|
+
const total = nonNullDateRangeData.map((graphData) => graphData.content.map((dataPoint) => dataPoint.total)).flat();
|
|
21
35
|
const [minTotal, maxTotal] = getMinMaxNumber(total)!;
|
|
22
36
|
const scaleBubble = (value: number) => {
|
|
23
37
|
return ((value - minTotal) / (maxTotal - minTotal)) * 4.5 + 0.5;
|
|
24
38
|
};
|
|
25
39
|
|
|
40
|
+
const maxY =
|
|
41
|
+
yAxisScaleType !== 'logit'
|
|
42
|
+
? getYAxisMax(maxInData(nonNullDateRangeData), yAxisMaxConfig?.[yAxisScaleType])
|
|
43
|
+
: undefined;
|
|
44
|
+
|
|
26
45
|
const config: ChartConfiguration = {
|
|
27
46
|
type: 'bubble',
|
|
28
47
|
data: {
|
|
29
|
-
datasets:
|
|
48
|
+
datasets: nonNullDateRangeData.map((graphData, index) => ({
|
|
30
49
|
label: graphData.displayName,
|
|
31
50
|
data: graphData.content
|
|
32
51
|
.filter((dataPoint) => dataPoint.dateRange !== null)
|
|
@@ -50,7 +69,7 @@ const PrevalenceOverTimeBubbleChart = ({ data, yAxisScaleType }: PrevalenceOverT
|
|
|
50
69
|
callback: (value) => addUnit(firstDate, value as number).toString(),
|
|
51
70
|
},
|
|
52
71
|
},
|
|
53
|
-
y: getYAxisScale(yAxisScaleType),
|
|
72
|
+
y: { ...getYAxisScale(yAxisScaleType), max: maxY },
|
|
54
73
|
},
|
|
55
74
|
plugins: {
|
|
56
75
|
legend: {
|
|
@@ -61,12 +80,12 @@ const PrevalenceOverTimeBubbleChart = ({ data, yAxisScaleType }: PrevalenceOverT
|
|
|
61
80
|
intersect: false,
|
|
62
81
|
callbacks: {
|
|
63
82
|
title: (context) => {
|
|
64
|
-
const dataset =
|
|
83
|
+
const dataset = nonNullDateRangeData[context[0].datasetIndex!];
|
|
65
84
|
const dataPoint = dataset.content[context[0].dataIndex!];
|
|
66
85
|
return dataPoint.dateRange?.toString();
|
|
67
86
|
},
|
|
68
87
|
label: (context) => {
|
|
69
|
-
const dataset =
|
|
88
|
+
const dataset = nonNullDateRangeData[context.datasetIndex!];
|
|
70
89
|
const dataPoint = dataset.content[context.dataIndex!];
|
|
71
90
|
|
|
72
91
|
const percentage = (dataPoint.prevalence * 100).toFixed(2);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Chart, type ChartConfiguration, registerables } from 'chart.js';
|
|
2
2
|
import { type TooltipItem } from 'chart.js/dist/types';
|
|
3
3
|
|
|
4
|
+
import { maxInData } from './prevalence-over-time';
|
|
4
5
|
import { type PrevalenceOverTimeData, type PrevalenceOverTimeVariantData } from '../../query/queryPrevalenceOverTime';
|
|
5
6
|
import GsChart from '../components/chart';
|
|
6
7
|
import { LogitScale } from '../shared/charts/LogitScale';
|
|
@@ -10,12 +11,14 @@ import {
|
|
|
10
11
|
type ConfidenceIntervalMethod,
|
|
11
12
|
wilson95PercentConfidenceInterval,
|
|
12
13
|
} from '../shared/charts/confideceInterval';
|
|
14
|
+
import { getYAxisMax, type YAxisMaxConfig } from '../shared/charts/getYAxisMax';
|
|
13
15
|
import { getYAxisScale, type ScaleType } from '../shared/charts/getYAxisScale';
|
|
14
16
|
|
|
15
17
|
interface PrevalenceOverTimeLineChartProps {
|
|
16
18
|
data: PrevalenceOverTimeData;
|
|
17
19
|
yAxisScaleType: ScaleType;
|
|
18
20
|
confidenceIntervalMethod: ConfidenceIntervalMethod;
|
|
21
|
+
yAxisMaxConfig: YAxisMaxConfig;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
Chart.register(...registerables, LogitScale);
|
|
@@ -24,21 +27,34 @@ const PrevalenceOverTimeLineChart = ({
|
|
|
24
27
|
data,
|
|
25
28
|
yAxisScaleType,
|
|
26
29
|
confidenceIntervalMethod,
|
|
30
|
+
yAxisMaxConfig,
|
|
27
31
|
}: PrevalenceOverTimeLineChartProps) => {
|
|
28
|
-
const
|
|
29
|
-
|
|
32
|
+
const nonNullDateRangeData = data.map((variantData) => {
|
|
33
|
+
return {
|
|
34
|
+
content: variantData.content.filter((dataPoint) => dataPoint.dateRange !== null),
|
|
35
|
+
displayName: variantData.displayName,
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const datasets = nonNullDateRangeData
|
|
40
|
+
.map((graphData, index) => getDataset(graphData, index, confidenceIntervalMethod))
|
|
41
|
+
.flat();
|
|
42
|
+
|
|
43
|
+
const maxY =
|
|
44
|
+
yAxisScaleType !== 'logit'
|
|
45
|
+
? getYAxisMax(maxInData(nonNullDateRangeData), yAxisMaxConfig?.[yAxisScaleType])
|
|
46
|
+
: undefined;
|
|
30
47
|
|
|
31
48
|
const config: ChartConfiguration = {
|
|
32
49
|
type: 'line',
|
|
33
50
|
data: {
|
|
34
|
-
labels,
|
|
35
51
|
datasets,
|
|
36
52
|
},
|
|
37
53
|
options: {
|
|
38
54
|
animation: false,
|
|
39
55
|
maintainAspectRatio: false,
|
|
40
56
|
scales: {
|
|
41
|
-
y: getYAxisScale(yAxisScaleType),
|
|
57
|
+
y: { ...getYAxisScale(yAxisScaleType), max: maxY },
|
|
42
58
|
},
|
|
43
59
|
plugins: {
|
|
44
60
|
legend: {
|
|
@@ -71,9 +87,12 @@ const getDataset = (
|
|
|
71
87
|
|
|
72
88
|
const getDatasetCIUpper = (prevalenceOverTimeVariant: PrevalenceOverTimeVariantData, dataIndex: number) => ({
|
|
73
89
|
label: `${prevalenceOverTimeVariant.displayName} CI upper`,
|
|
74
|
-
data: prevalenceOverTimeVariant.content.map(
|
|
75
|
-
|
|
76
|
-
|
|
90
|
+
data: prevalenceOverTimeVariant.content.map((dataPoint): Datapoint => {
|
|
91
|
+
return {
|
|
92
|
+
y: wilson95PercentConfidenceInterval(dataPoint.count, dataPoint.total).upperLimit,
|
|
93
|
+
x: dataPoint.dateRange?.toString(),
|
|
94
|
+
};
|
|
95
|
+
}),
|
|
77
96
|
borderWidth: 0,
|
|
78
97
|
pointRadius: 0,
|
|
79
98
|
fill: '+1',
|
|
@@ -82,9 +101,12 @@ const getDatasetCIUpper = (prevalenceOverTimeVariant: PrevalenceOverTimeVariantD
|
|
|
82
101
|
|
|
83
102
|
const getDatasetCILower = (prevalenceOverTimeVariant: PrevalenceOverTimeVariantData, dataIndex: number) => ({
|
|
84
103
|
label: `${prevalenceOverTimeVariant.displayName} CI lower`,
|
|
85
|
-
data: prevalenceOverTimeVariant.content.map(
|
|
86
|
-
|
|
87
|
-
|
|
104
|
+
data: prevalenceOverTimeVariant.content.map((dataPoint): Datapoint => {
|
|
105
|
+
return {
|
|
106
|
+
y: wilson95PercentConfidenceInterval(dataPoint.count, dataPoint.total).lowerLimit,
|
|
107
|
+
x: dataPoint.dateRange?.toString(),
|
|
108
|
+
};
|
|
109
|
+
}),
|
|
88
110
|
borderWidth: 0,
|
|
89
111
|
pointRadius: 0,
|
|
90
112
|
fill: '-1',
|
|
@@ -93,13 +115,29 @@ const getDatasetCILower = (prevalenceOverTimeVariant: PrevalenceOverTimeVariantD
|
|
|
93
115
|
|
|
94
116
|
const getDatasetLine = (prevalenceOverTimeVariant: PrevalenceOverTimeVariantData, dataIndex: number) => ({
|
|
95
117
|
label: prevalenceOverTimeVariant.displayName,
|
|
96
|
-
data: prevalenceOverTimeVariant.content.map((dataPoint) =>
|
|
118
|
+
data: prevalenceOverTimeVariant.content.map((dataPoint): Datapoint => {
|
|
119
|
+
const ciLimits = wilson95PercentConfidenceInterval(dataPoint.count, dataPoint.total);
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
y: dataPoint.prevalence,
|
|
123
|
+
x: dataPoint.dateRange?.toString(),
|
|
124
|
+
yCiUpper: ciLimits.upperLimit,
|
|
125
|
+
yCiLower: ciLimits.lowerLimit,
|
|
126
|
+
};
|
|
127
|
+
}),
|
|
97
128
|
borderWidth: 1,
|
|
98
129
|
pointRadius: 0,
|
|
99
130
|
borderColor: singleGraphColorRGBAById(dataIndex),
|
|
100
131
|
backgroundColor: singleGraphColorRGBAById(dataIndex),
|
|
101
132
|
});
|
|
102
133
|
|
|
134
|
+
interface Datapoint {
|
|
135
|
+
y: number;
|
|
136
|
+
yCiLower?: number;
|
|
137
|
+
yCiUpper?: number;
|
|
138
|
+
x?: string;
|
|
139
|
+
}
|
|
140
|
+
|
|
103
141
|
const tooltip = (confidenceIntervalMethod?: ConfidenceIntervalMethod) => {
|
|
104
142
|
const generalConfig = {
|
|
105
143
|
mode: 'index' as const,
|
|
@@ -111,26 +149,18 @@ const tooltip = (confidenceIntervalMethod?: ConfidenceIntervalMethod) => {
|
|
|
111
149
|
return {
|
|
112
150
|
...generalConfig,
|
|
113
151
|
filter: ({ datasetIndex }: TooltipItem<'line'>) => {
|
|
114
|
-
return datasetIndex
|
|
152
|
+
return isNotCiIndex(datasetIndex);
|
|
115
153
|
},
|
|
116
154
|
callbacks: {
|
|
117
155
|
label: (context: TooltipItem<'line'>) => {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
typeof ciUpper !== 'number'
|
|
127
|
-
) {
|
|
128
|
-
return '';
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return confidenceIntervalDataLabel(value, ciLower, ciUpper, context.dataset.label);
|
|
132
|
-
}
|
|
133
|
-
return context.dataset.label;
|
|
156
|
+
const dataPoint = context.dataset.data[context.dataIndex] as unknown as Datapoint;
|
|
157
|
+
|
|
158
|
+
return confidenceIntervalDataLabel(
|
|
159
|
+
dataPoint.y,
|
|
160
|
+
dataPoint.yCiLower,
|
|
161
|
+
dataPoint.yCiUpper,
|
|
162
|
+
context.dataset.label,
|
|
163
|
+
);
|
|
134
164
|
},
|
|
135
165
|
},
|
|
136
166
|
};
|
|
@@ -139,4 +169,8 @@ const tooltip = (confidenceIntervalMethod?: ConfidenceIntervalMethod) => {
|
|
|
139
169
|
}
|
|
140
170
|
};
|
|
141
171
|
|
|
172
|
+
function isNotCiIndex(datasetIndex: number) {
|
|
173
|
+
return datasetIndex % 3 === 1;
|
|
174
|
+
}
|
|
175
|
+
|
|
142
176
|
export default PrevalenceOverTimeLineChart;
|
|
@@ -7,9 +7,10 @@ import { formatProportion } from '../shared/table/formatProportion';
|
|
|
7
7
|
interface PrevalenceOverTimeTableProps {
|
|
8
8
|
data: PrevalenceOverTimeData;
|
|
9
9
|
granularity: TemporalGranularity;
|
|
10
|
+
pageSize: boolean | number;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
const PrevalenceOverTimeTable = ({ data, granularity }: PrevalenceOverTimeTableProps) => {
|
|
13
|
+
const PrevalenceOverTimeTable = ({ data, granularity, pageSize }: PrevalenceOverTimeTableProps) => {
|
|
13
14
|
const getSplitColumns = (data: PrevalenceOverTimeData) => {
|
|
14
15
|
return data.map((dataset) => ({
|
|
15
16
|
name: dataset.displayName,
|
|
@@ -40,7 +41,7 @@ const PrevalenceOverTimeTable = ({ data, granularity }: PrevalenceOverTimeTableP
|
|
|
40
41
|
return Object.values(dataByHeader).map((row) => Object.values(row));
|
|
41
42
|
};
|
|
42
43
|
|
|
43
|
-
return <Table data={getData(data, granularity)} columns={getColumns(data)}
|
|
44
|
+
return <Table data={getData(data, granularity)} columns={getColumns(data)} pageSize={pageSize} />;
|
|
44
45
|
};
|
|
45
46
|
|
|
46
47
|
export default PrevalenceOverTimeTable;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import denominatorFilter from './__mockData__/denominatorFilter.json';
|
|
2
|
+
import denominatorOneDataset from './__mockData__/denominatorFilterOneDataset.json';
|
|
3
|
+
import numeratorFilterEG from './__mockData__/numeratorFilterEG.json';
|
|
4
|
+
import numeratorFilterJN1 from './__mockData__/numeratorFilterJN1.json';
|
|
5
|
+
import numeratorOneDataset from './__mockData__/numeratorFilterOneDataset.json';
|
|
6
6
|
import { PrevalenceOverTime, type PrevalenceOverTimeProps } from './prevalence-over-time';
|
|
7
7
|
import { AGGREGATED_ENDPOINT, LAPIS_URL } from '../../constants';
|
|
8
8
|
import { LapisUrlContext } from '../LapisUrlContext';
|
|
@@ -32,6 +32,8 @@ export default {
|
|
|
32
32
|
width: { control: 'text' },
|
|
33
33
|
height: { control: 'text' },
|
|
34
34
|
headline: { control: 'text' },
|
|
35
|
+
pageSize: { control: 'object' },
|
|
36
|
+
yAxisMaxConfig: { control: 'object' },
|
|
35
37
|
},
|
|
36
38
|
};
|
|
37
39
|
|
|
@@ -39,8 +41,8 @@ const Template = {
|
|
|
39
41
|
render: (args: PrevalenceOverTimeProps) => (
|
|
40
42
|
<LapisUrlContext.Provider value={LAPIS_URL}>
|
|
41
43
|
<PrevalenceOverTime
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
numeratorFilter={args.numeratorFilter}
|
|
45
|
+
denominatorFilter={args.denominatorFilter}
|
|
44
46
|
granularity={args.granularity}
|
|
45
47
|
smoothingWindow={args.smoothingWindow}
|
|
46
48
|
views={args.views}
|
|
@@ -49,6 +51,8 @@ const Template = {
|
|
|
49
51
|
height={args.height}
|
|
50
52
|
headline={args.headline}
|
|
51
53
|
lapisDateField={args.lapisDateField}
|
|
54
|
+
pageSize={args.pageSize}
|
|
55
|
+
yAxisMaxConfig={args.yAxisMaxConfig}
|
|
52
56
|
/>
|
|
53
57
|
</LapisUrlContext.Provider>
|
|
54
58
|
),
|
|
@@ -57,11 +61,11 @@ const Template = {
|
|
|
57
61
|
export const TwoVariants = {
|
|
58
62
|
...Template,
|
|
59
63
|
args: {
|
|
60
|
-
|
|
64
|
+
numeratorFilter: [
|
|
61
65
|
{ displayName: 'EG', lapisFilter: { country: 'USA', pangoLineage: 'EG*', dateFrom: '2023-01-01' } },
|
|
62
66
|
{ displayName: 'JN.1', lapisFilter: { country: 'USA', pangoLineage: 'JN.1*', dateFrom: '2023-01-01' } },
|
|
63
67
|
],
|
|
64
|
-
|
|
68
|
+
denominatorFilter: { country: 'USA', dateFrom: '2023-01-01' },
|
|
65
69
|
granularity: 'month',
|
|
66
70
|
smoothingWindow: 0,
|
|
67
71
|
views: ['bar', 'line', 'bubble', 'table'],
|
|
@@ -70,6 +74,11 @@ export const TwoVariants = {
|
|
|
70
74
|
height: '700px',
|
|
71
75
|
headline: 'Prevalence over time',
|
|
72
76
|
lapisDateField: 'date',
|
|
77
|
+
pageSize: 10,
|
|
78
|
+
yAxisMaxConfig: {
|
|
79
|
+
linear: 1,
|
|
80
|
+
logarithmic: 1,
|
|
81
|
+
},
|
|
73
82
|
},
|
|
74
83
|
parameters: {
|
|
75
84
|
fetchMock: {
|
|
@@ -87,7 +96,7 @@ export const TwoVariants = {
|
|
|
87
96
|
},
|
|
88
97
|
response: {
|
|
89
98
|
status: 200,
|
|
90
|
-
body:
|
|
99
|
+
body: numeratorFilterEG,
|
|
91
100
|
},
|
|
92
101
|
},
|
|
93
102
|
{
|
|
@@ -103,7 +112,7 @@ export const TwoVariants = {
|
|
|
103
112
|
},
|
|
104
113
|
response: {
|
|
105
114
|
status: 200,
|
|
106
|
-
body:
|
|
115
|
+
body: numeratorFilterJN1,
|
|
107
116
|
},
|
|
108
117
|
},
|
|
109
118
|
{
|
|
@@ -118,7 +127,7 @@ export const TwoVariants = {
|
|
|
118
127
|
},
|
|
119
128
|
response: {
|
|
120
129
|
status: 200,
|
|
121
|
-
body:
|
|
130
|
+
body: denominatorFilter,
|
|
122
131
|
},
|
|
123
132
|
},
|
|
124
133
|
],
|
|
@@ -129,11 +138,11 @@ export const TwoVariants = {
|
|
|
129
138
|
export const OneVariant = {
|
|
130
139
|
...Template,
|
|
131
140
|
args: {
|
|
132
|
-
|
|
141
|
+
numeratorFilter: {
|
|
133
142
|
displayName: 'EG',
|
|
134
143
|
lapisFilter: { country: 'USA', pangoLineage: 'BA.2.86*', dateFrom: '2023-10-01' },
|
|
135
144
|
},
|
|
136
|
-
|
|
145
|
+
denominatorFilter: { country: 'USA', dateFrom: '2023-10-01' },
|
|
137
146
|
granularity: 'day',
|
|
138
147
|
smoothingWindow: 7,
|
|
139
148
|
views: ['bar', 'line', 'bubble', 'table'],
|
|
@@ -142,6 +151,11 @@ export const OneVariant = {
|
|
|
142
151
|
height: '700px',
|
|
143
152
|
headline: 'Prevalence over time',
|
|
144
153
|
lapisDateField: 'date',
|
|
154
|
+
pageSize: 10,
|
|
155
|
+
yAxisMaxConfig: {
|
|
156
|
+
linear: 1,
|
|
157
|
+
logarithmic: 1,
|
|
158
|
+
},
|
|
145
159
|
},
|
|
146
160
|
parameters: {
|
|
147
161
|
fetchMock: {
|
|
@@ -159,7 +173,7 @@ export const OneVariant = {
|
|
|
159
173
|
},
|
|
160
174
|
response: {
|
|
161
175
|
status: 200,
|
|
162
|
-
body:
|
|
176
|
+
body: numeratorOneDataset,
|
|
163
177
|
},
|
|
164
178
|
},
|
|
165
179
|
{
|
|
@@ -174,7 +188,7 @@ export const OneVariant = {
|
|
|
174
188
|
},
|
|
175
189
|
response: {
|
|
176
190
|
status: 200,
|
|
177
|
-
body:
|
|
191
|
+
body: denominatorOneDataset,
|
|
178
192
|
},
|
|
179
193
|
},
|
|
180
194
|
],
|