@genspectrum/dashboard-components 0.5.1 → 0.5.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.
|
@@ -805,14 +805,14 @@ declare global {
|
|
|
805
805
|
|
|
806
806
|
declare global {
|
|
807
807
|
interface HTMLElementTagNameMap {
|
|
808
|
-
'gs-
|
|
808
|
+
'gs-prevalence-over-time': PrevalenceOverTimeComponent;
|
|
809
809
|
}
|
|
810
810
|
}
|
|
811
811
|
|
|
812
812
|
|
|
813
813
|
declare global {
|
|
814
814
|
interface HTMLElementTagNameMap {
|
|
815
|
-
'gs-
|
|
815
|
+
'gs-relative-growth-advantage': RelativeGrowthAdvantageComponent;
|
|
816
816
|
}
|
|
817
817
|
}
|
|
818
818
|
|
package/package.json
CHANGED
|
@@ -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(
|