@genspectrum/dashboard-components 0.5.1 → 0.5.3
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/dist/dashboard-components.js +20 -21
- package/dist/dashboard-components.js.map +1 -1
- package/package.json +2 -2
- package/src/preact/prevalenceOverTime/prevalence-over-time-bar-chart.tsx +26 -17
- package/src/query/queryPrevalenceOverTime.ts +8 -1
- package/src/web-components/input/gs-mutation-filter.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genspectrum/dashboard-components",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "GenSpectrum web components for building dashboards",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
@@ -109,6 +109,6 @@
|
|
|
109
109
|
"typescript": "~5.5.2",
|
|
110
110
|
"vite": "^5.2.10",
|
|
111
111
|
"vite-plugin-dts": "^3.8.3",
|
|
112
|
-
"vitest": "^
|
|
112
|
+
"vitest": "^2.0.1"
|
|
113
113
|
}
|
|
114
114
|
}
|
|
@@ -2,7 +2,11 @@ import { Chart, type ChartConfiguration, registerables, type TooltipItem } from
|
|
|
2
2
|
import { BarWithErrorBar, BarWithErrorBarsController } from 'chartjs-chart-error-bars';
|
|
3
3
|
|
|
4
4
|
import { maxInData } from './prevalence-over-time';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
type PrevalenceOverTimeData,
|
|
7
|
+
type PrevalenceOverTimeVariantData,
|
|
8
|
+
type PrevalenceOverTimeVariantDataPoint,
|
|
9
|
+
} from '../../query/queryPrevalenceOverTime';
|
|
6
10
|
import type { Temporal } from '../../utils/temporal';
|
|
7
11
|
import GsChart from '../components/chart';
|
|
8
12
|
import { LogitScale } from '../shared/charts/LogitScale';
|
|
@@ -84,32 +88,37 @@ const getDataset = (
|
|
|
84
88
|
index: number,
|
|
85
89
|
confidenceIntervalMethod: ConfidenceIntervalMethod,
|
|
86
90
|
) => {
|
|
87
|
-
|
|
91
|
+
return {
|
|
88
92
|
borderWidth: 1,
|
|
89
93
|
pointRadius: 0,
|
|
90
94
|
label: prevalenceOverTimeVariant.displayName,
|
|
91
95
|
backgroundColor: singleGraphColorRGBAById(index, 0.3),
|
|
92
96
|
borderColor: singleGraphColorRGBAById(index),
|
|
97
|
+
data: prevalenceOverTimeVariant.content.map(mapDataPoint(confidenceIntervalMethod)),
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const mapDataPoint = (confidenceIntervalMethod: ConfidenceIntervalMethod) => {
|
|
102
|
+
return (dataPoint: PrevalenceOverTimeVariantDataPoint) => {
|
|
103
|
+
const confidenceInterval = getConfidenceInterval(dataPoint, confidenceIntervalMethod);
|
|
104
|
+
return {
|
|
105
|
+
y: dataPoint.prevalence,
|
|
106
|
+
yMin: confidenceInterval.lowerLimit,
|
|
107
|
+
yMax: confidenceInterval.upperLimit,
|
|
108
|
+
x: dataPoint.dateRange?.toString() ?? 'Unknown',
|
|
109
|
+
};
|
|
93
110
|
};
|
|
111
|
+
};
|
|
94
112
|
|
|
113
|
+
const getConfidenceInterval = (
|
|
114
|
+
dataPoint: PrevalenceOverTimeVariantDataPoint,
|
|
115
|
+
confidenceIntervalMethod: ConfidenceIntervalMethod,
|
|
116
|
+
) => {
|
|
95
117
|
switch (confidenceIntervalMethod) {
|
|
96
118
|
case 'wilson':
|
|
97
|
-
return
|
|
98
|
-
...generalConfig,
|
|
99
|
-
data: prevalenceOverTimeVariant.content.map((dataPoint) => ({
|
|
100
|
-
y: dataPoint.prevalence,
|
|
101
|
-
yMin: wilson95PercentConfidenceInterval(dataPoint.count, dataPoint.total).lowerLimit,
|
|
102
|
-
yMax: wilson95PercentConfidenceInterval(dataPoint.count, dataPoint.total).upperLimit,
|
|
103
|
-
x: dataPoint.dateRange?.toString() ?? 'Unknown',
|
|
104
|
-
})),
|
|
105
|
-
};
|
|
119
|
+
return wilson95PercentConfidenceInterval(dataPoint.count, dataPoint.total);
|
|
106
120
|
default:
|
|
107
|
-
return {
|
|
108
|
-
...generalConfig,
|
|
109
|
-
data: prevalenceOverTimeVariant.content.map((dataPoint) => {
|
|
110
|
-
return { y: dataPoint.prevalence, x: dataPoint.dateRange };
|
|
111
|
-
}),
|
|
112
|
-
};
|
|
121
|
+
return { lowerLimit: undefined, upperLimit: undefined };
|
|
113
122
|
}
|
|
114
123
|
};
|
|
115
124
|
|
|
@@ -19,7 +19,14 @@ export type PrevalenceOverTimeData = PrevalenceOverTimeVariantData[];
|
|
|
19
19
|
|
|
20
20
|
export type PrevalenceOverTimeVariantData = {
|
|
21
21
|
displayName: string;
|
|
22
|
-
content:
|
|
22
|
+
content: PrevalenceOverTimeVariantDataPoint[];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type PrevalenceOverTimeVariantDataPoint = {
|
|
26
|
+
count: number;
|
|
27
|
+
prevalence: number;
|
|
28
|
+
total: number;
|
|
29
|
+
dateRange: Temporal | null;
|
|
23
30
|
};
|
|
24
31
|
|
|
25
32
|
export function queryPrevalenceOverTime(
|
|
@@ -72,7 +72,7 @@ export class MutationFilterComponent extends PreactLitAdapter {
|
|
|
72
72
|
* All values provided must be valid mutations or insertions.
|
|
73
73
|
* Invalid values will be ignored.
|
|
74
74
|
*/
|
|
75
|
-
@property()
|
|
75
|
+
@property({ type: Object })
|
|
76
76
|
initialValue:
|
|
77
77
|
{
|
|
78
78
|
nucleotideMutations: string[];
|