@genspectrum/dashboard-components 0.10.0 → 0.10.1
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 +163 -0
- package/dist/assets/mutationOverTimeWorker-CvZg52rf.js.map +1 -1
- package/dist/components.d.ts +48 -0
- package/dist/components.js +251 -120
- package/dist/components.js.map +1 -1
- package/dist/style.css +41 -0
- package/dist/util.d.ts +16 -0
- package/package.json +2 -2
- package/src/preact/components/min-max-range-slider.tsx +4 -4
- package/src/preact/components/percent-intput.tsx +2 -2
- package/src/preact/mutationFilter/mutation-filter.tsx +0 -1
- package/src/preact/statistic/__mockData__/denominator.json +13 -0
- package/src/preact/statistic/__mockData__/numerator.json +13 -0
- package/src/preact/statistic/statistics.stories.tsx +81 -0
- package/src/preact/statistic/statistics.tsx +78 -0
- package/src/query/queryGeneralStatistics.ts +18 -0
- package/src/web-components/visualization/gs-statistics.stories.ts +95 -0
- package/src/web-components/visualization/gs-statistics.tsx +83 -0
- package/src/web-components/visualization/index.ts +1 -0
- package/standalone-bundle/assets/mutationOverTimeWorker-CypX_PYM.js.map +1 -1
- package/standalone-bundle/dashboard-components.js +4209 -4142
- package/standalone-bundle/dashboard-components.js.map +1 -1
- package/standalone-bundle/style.css +1 -1
package/dist/style.css
CHANGED
|
@@ -1561,6 +1561,38 @@ html {
|
|
|
1561
1561
|
.select[multiple] {
|
|
1562
1562
|
height: auto;
|
|
1563
1563
|
}
|
|
1564
|
+
.stat {
|
|
1565
|
+
display: inline-grid;
|
|
1566
|
+
width: 100%;
|
|
1567
|
+
grid-template-columns: repeat(1, 1fr);
|
|
1568
|
+
-moz-column-gap: 1rem;
|
|
1569
|
+
column-gap: 1rem;
|
|
1570
|
+
border-color: var(--fallback-bc,oklch(var(--bc)/var(--tw-border-opacity)));
|
|
1571
|
+
--tw-border-opacity: 0.1;
|
|
1572
|
+
padding-left: 1.5rem;
|
|
1573
|
+
padding-right: 1.5rem;
|
|
1574
|
+
padding-top: 1rem;
|
|
1575
|
+
padding-bottom: 1rem;
|
|
1576
|
+
}
|
|
1577
|
+
.stat-title {
|
|
1578
|
+
grid-column-start: 1;
|
|
1579
|
+
white-space: nowrap;
|
|
1580
|
+
color: var(--fallback-bc,oklch(var(--bc)/0.6));
|
|
1581
|
+
}
|
|
1582
|
+
.stat-value {
|
|
1583
|
+
grid-column-start: 1;
|
|
1584
|
+
white-space: nowrap;
|
|
1585
|
+
font-size: 2.25rem;
|
|
1586
|
+
line-height: 2.5rem;
|
|
1587
|
+
font-weight: 800;
|
|
1588
|
+
}
|
|
1589
|
+
.stat-desc {
|
|
1590
|
+
grid-column-start: 1;
|
|
1591
|
+
white-space: nowrap;
|
|
1592
|
+
font-size: 0.75rem;
|
|
1593
|
+
line-height: 1rem;
|
|
1594
|
+
color: var(--fallback-bc,oklch(var(--bc)/0.6));
|
|
1595
|
+
}
|
|
1564
1596
|
.steps {
|
|
1565
1597
|
display: inline-grid;
|
|
1566
1598
|
grid-auto-flow: column;
|
|
@@ -3427,6 +3459,15 @@ input.tab:checked + .tab-content,
|
|
|
3427
3459
|
.sm\:max-w-5xl {
|
|
3428
3460
|
max-width: 64rem;
|
|
3429
3461
|
}
|
|
3462
|
+
|
|
3463
|
+
.sm\:flex-row {
|
|
3464
|
+
flex-direction: row;
|
|
3465
|
+
}
|
|
3466
|
+
|
|
3467
|
+
.sm\:text-4xl {
|
|
3468
|
+
font-size: 2.25rem;
|
|
3469
|
+
line-height: 2.5rem;
|
|
3470
|
+
}
|
|
3430
3471
|
}.flatpickr-calendar{background:transparent;opacity:0;display:none;text-align:center;visibility:hidden;padding:0;-webkit-animation:none;animation:none;direction:ltr;border:0;font-size:14px;line-height:24px;border-radius:5px;position:absolute;width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-touch-action:manipulation;touch-action:manipulation;background:#fff;-webkit-box-shadow:1px 0 0 #e6e6e6,-1px 0 0 #e6e6e6,0 1px 0 #e6e6e6,0 -1px 0 #e6e6e6,0 3px 13px rgba(0,0,0,0.08);box-shadow:1px 0 0 #e6e6e6,-1px 0 0 #e6e6e6,0 1px 0 #e6e6e6,0 -1px 0 #e6e6e6,0 3px 13px rgba(0,0,0,0.08)}.flatpickr-calendar.open,.flatpickr-calendar.inline{opacity:1;max-height:640px;visibility:visible}.flatpickr-calendar.open{display:inline-block;z-index:99999}.flatpickr-calendar.animate.open{-webkit-animation:fpFadeInDown 300ms cubic-bezier(.23,1,.32,1);animation:fpFadeInDown 300ms cubic-bezier(.23,1,.32,1)}.flatpickr-calendar.inline{display:block;position:relative;top:2px}.flatpickr-calendar.static{position:absolute;top:calc(100% + 2px)}.flatpickr-calendar.static.open{z-index:999;display:block}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+1) .flatpickr-day.inRange:nth-child(7n+7){-webkit-box-shadow:none !important;box-shadow:none !important}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+2) .flatpickr-day.inRange:nth-child(7n+1){-webkit-box-shadow:-2px 0 0 #e6e6e6,5px 0 0 #e6e6e6;box-shadow:-2px 0 0 #e6e6e6,5px 0 0 #e6e6e6}.flatpickr-calendar .hasWeeks .dayContainer,.flatpickr-calendar .hasTime .dayContainer{border-bottom:0;border-bottom-right-radius:0;border-bottom-left-radius:0}.flatpickr-calendar .hasWeeks .dayContainer{border-left:0}.flatpickr-calendar.hasTime .flatpickr-time{height:40px;border-top:1px solid #e6e6e6}.flatpickr-calendar.noCalendar.hasTime .flatpickr-time{height:auto}.flatpickr-calendar:before,.flatpickr-calendar:after{position:absolute;display:block;pointer-events:none;border:solid transparent;content:'';height:0;width:0;left:22px}.flatpickr-calendar.rightMost:before,.flatpickr-calendar.arrowRight:before,.flatpickr-calendar.rightMost:after,.flatpickr-calendar.arrowRight:after{left:auto;right:22px}.flatpickr-calendar.arrowCenter:before,.flatpickr-calendar.arrowCenter:after{left:50%;right:50%}.flatpickr-calendar:before{border-width:5px;margin:0 -5px}.flatpickr-calendar:after{border-width:4px;margin:0 -4px}.flatpickr-calendar.arrowTop:before,.flatpickr-calendar.arrowTop:after{bottom:100%}.flatpickr-calendar.arrowTop:before{border-bottom-color:#e6e6e6}.flatpickr-calendar.arrowTop:after{border-bottom-color:#fff}.flatpickr-calendar.arrowBottom:before,.flatpickr-calendar.arrowBottom:after{top:100%}.flatpickr-calendar.arrowBottom:before{border-top-color:#e6e6e6}.flatpickr-calendar.arrowBottom:after{border-top-color:#fff}.flatpickr-calendar:focus{outline:0}.flatpickr-wrapper{position:relative;display:inline-block}.flatpickr-months{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.flatpickr-months .flatpickr-month{background:transparent;color:rgba(0,0,0,0.9);fill:rgba(0,0,0,0.9);height:34px;line-height:1;text-align:center;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.flatpickr-months .flatpickr-prev-month,.flatpickr-months .flatpickr-next-month{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;text-decoration:none;cursor:pointer;position:absolute;top:0;height:34px;padding:10px;z-index:3;color:rgba(0,0,0,0.9);fill:rgba(0,0,0,0.9)}.flatpickr-months .flatpickr-prev-month.flatpickr-disabled,.flatpickr-months .flatpickr-next-month.flatpickr-disabled{display:none}.flatpickr-months .flatpickr-prev-month i,.flatpickr-months .flatpickr-next-month i{position:relative}.flatpickr-months .flatpickr-prev-month.flatpickr-prev-month,.flatpickr-months .flatpickr-next-month.flatpickr-prev-month{/*
|
|
3431
3472
|
/*rtl:begin:ignore*/left:0/*
|
|
3432
3473
|
/*rtl:end:ignore*/}/*
|
package/dist/util.d.ts
CHANGED
|
@@ -196,6 +196,22 @@ declare global {
|
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
|
|
199
|
+
declare global {
|
|
200
|
+
interface HTMLElementTagNameMap {
|
|
201
|
+
'gs-statistics': StatisticsComponent;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
declare global {
|
|
207
|
+
namespace JSX {
|
|
208
|
+
interface IntrinsicElements {
|
|
209
|
+
'gs-statistics': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
|
|
199
215
|
declare global {
|
|
200
216
|
interface HTMLElementTagNameMap {
|
|
201
217
|
'gs-date-range-selector': DateRangeSelectorComponent;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genspectrum/dashboard-components",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "GenSpectrum web components for building dashboards",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"storybook": "^8.0.9",
|
|
133
133
|
"storybook-addon-fetch-mock": "^2.0.0",
|
|
134
134
|
"tailwindcss": "^3.4.3",
|
|
135
|
-
"typescript": "~5.
|
|
135
|
+
"typescript": "~5.7.2",
|
|
136
136
|
"vite": "^5.2.10",
|
|
137
137
|
"vite-plugin-dts": "^4.0.3",
|
|
138
138
|
"vitest": "^2.0.1"
|
|
@@ -75,8 +75,8 @@ export const MinMaxRangeSlider: FunctionComponent<MinMaxPercentSliderProps> = ({
|
|
|
75
75
|
type='range'
|
|
76
76
|
value={min}
|
|
77
77
|
onInput={onMinChange}
|
|
78
|
-
min={rangeMin}
|
|
79
|
-
max={rangeMax}
|
|
78
|
+
min={`${rangeMin}`}
|
|
79
|
+
max={`${rangeMax}`}
|
|
80
80
|
step={step}
|
|
81
81
|
style={{ background, zIndex: 1, height: 0 }}
|
|
82
82
|
/>
|
|
@@ -84,8 +84,8 @@ export const MinMaxRangeSlider: FunctionComponent<MinMaxPercentSliderProps> = ({
|
|
|
84
84
|
id='toSlider'
|
|
85
85
|
type='range'
|
|
86
86
|
value={max}
|
|
87
|
-
min={rangeMin}
|
|
88
|
-
max={rangeMax}
|
|
87
|
+
min={`${rangeMin}`}
|
|
88
|
+
max={`${rangeMax}`}
|
|
89
89
|
step={step}
|
|
90
90
|
onInput={onMaxChange}
|
|
91
91
|
style={{ background, zIndex: zIndexTo }}
|
|
@@ -303,7 +303,6 @@ const SelectedFilter = ({ handleRemoveValue, mutationFilter }: SelectedFilterPro
|
|
|
303
303
|
return (
|
|
304
304
|
<span
|
|
305
305
|
key={mutationFilter.value.toString()}
|
|
306
|
-
name={mutationFilter.value.toString()}
|
|
307
306
|
className='center p-2 m-1 inline-flex text-black rounded-md'
|
|
308
307
|
style={{
|
|
309
308
|
backgroundColor: backgroundColorMap(mutationFilter),
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": [
|
|
3
|
+
{
|
|
4
|
+
"count": 2468
|
|
5
|
+
}
|
|
6
|
+
],
|
|
7
|
+
"info": {
|
|
8
|
+
"dataVersion": "1712315293",
|
|
9
|
+
"requestId": "4603a85e-ae5e-495d-aee5-778a3af862c1",
|
|
10
|
+
"requestInfo": "sars_cov-2_nextstrain_open on s1.int.genspectrum.org at 2024-04-24T15:31:40.596677441",
|
|
11
|
+
"reportTo": "Please report to https://github.com/GenSpectrum/LAPIS/issues in case you encounter any unexpected issues. Please include the request ID and the requestInfo in your report."
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": [
|
|
3
|
+
{
|
|
4
|
+
"count": 1234
|
|
5
|
+
}
|
|
6
|
+
],
|
|
7
|
+
"info": {
|
|
8
|
+
"dataVersion": "1712315293",
|
|
9
|
+
"requestId": "4603a85e-ae5e-495d-aee5-778a3af862c1",
|
|
10
|
+
"requestInfo": "sars_cov-2_nextstrain_open on s1.int.genspectrum.org at 2024-04-24T15:31:40.596677441",
|
|
11
|
+
"reportTo": "Please report to https://github.com/GenSpectrum/LAPIS/issues in case you encounter any unexpected issues. Please include the request ID and the requestInfo in your report."
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type Meta, type StoryObj } from '@storybook/preact';
|
|
2
|
+
import { expect, waitFor, within } from '@storybook/test';
|
|
3
|
+
|
|
4
|
+
import { AGGREGATED_ENDPOINT, LAPIS_URL } from '../../constants';
|
|
5
|
+
import { LapisUrlContext } from '../LapisUrlContext';
|
|
6
|
+
import denominatorData from './__mockData__/denominator.json';
|
|
7
|
+
import numeratorData from './__mockData__/numerator.json';
|
|
8
|
+
import { Statistics, type StatisticsProps } from './statistics';
|
|
9
|
+
|
|
10
|
+
const meta: Meta<StatisticsProps> = {
|
|
11
|
+
title: 'Visualization/Statistics',
|
|
12
|
+
component: Statistics,
|
|
13
|
+
argTypes: {
|
|
14
|
+
width: { control: 'text' },
|
|
15
|
+
height: { control: 'text' },
|
|
16
|
+
},
|
|
17
|
+
parameters: {
|
|
18
|
+
fetchMock: {
|
|
19
|
+
mocks: [
|
|
20
|
+
{
|
|
21
|
+
matcher: {
|
|
22
|
+
name: 'denominatorData',
|
|
23
|
+
url: AGGREGATED_ENDPOINT,
|
|
24
|
+
body: {
|
|
25
|
+
fields: [],
|
|
26
|
+
country: 'USA',
|
|
27
|
+
division: 'Alabama',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
response: {
|
|
31
|
+
status: 200,
|
|
32
|
+
body: denominatorData,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
matcher: {
|
|
37
|
+
name: 'numeratorData',
|
|
38
|
+
url: AGGREGATED_ENDPOINT,
|
|
39
|
+
body: {
|
|
40
|
+
fields: [],
|
|
41
|
+
country: 'USA',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
response: {
|
|
45
|
+
status: 200,
|
|
46
|
+
body: numeratorData,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default meta;
|
|
55
|
+
|
|
56
|
+
export const Default: StoryObj<StatisticsProps> = {
|
|
57
|
+
render: (args) => (
|
|
58
|
+
<LapisUrlContext.Provider value={LAPIS_URL}>
|
|
59
|
+
<Statistics {...args} />
|
|
60
|
+
</LapisUrlContext.Provider>
|
|
61
|
+
),
|
|
62
|
+
args: {
|
|
63
|
+
numeratorFilter: {
|
|
64
|
+
country: 'USA',
|
|
65
|
+
},
|
|
66
|
+
denominatorFilter: {
|
|
67
|
+
country: 'USA',
|
|
68
|
+
division: 'Alabama',
|
|
69
|
+
},
|
|
70
|
+
width: '100%',
|
|
71
|
+
height: '100%',
|
|
72
|
+
},
|
|
73
|
+
play: async ({ canvasElement }) => {
|
|
74
|
+
const canvas = within(canvasElement);
|
|
75
|
+
|
|
76
|
+
await waitFor(async () => {
|
|
77
|
+
await expect(canvas.getByText('1,234')).toBeInTheDocument();
|
|
78
|
+
await expect(canvas.getByText('50.00%')).toBeInTheDocument();
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type FunctionComponent } from 'preact';
|
|
2
|
+
import { useContext } from 'preact/hooks';
|
|
3
|
+
|
|
4
|
+
import { queryGeneralStatistics } from '../../query/queryGeneralStatistics';
|
|
5
|
+
import { type LapisFilter } from '../../types';
|
|
6
|
+
import { LapisUrlContext } from '../LapisUrlContext';
|
|
7
|
+
import { ErrorBoundary } from '../components/error-boundary';
|
|
8
|
+
import { LoadingDisplay } from '../components/loading-display';
|
|
9
|
+
import { NoDataDisplay } from '../components/no-data-display';
|
|
10
|
+
import { ResizeContainer } from '../components/resize-container';
|
|
11
|
+
import { formatProportion } from '../shared/table/formatProportion';
|
|
12
|
+
import { useQuery } from '../useQuery';
|
|
13
|
+
|
|
14
|
+
export type StatisticsProps = {
|
|
15
|
+
width: string;
|
|
16
|
+
height: string;
|
|
17
|
+
numeratorFilter: LapisFilter;
|
|
18
|
+
denominatorFilter: LapisFilter;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const Statistics: FunctionComponent<StatisticsProps> = (componentProps) => {
|
|
22
|
+
const { width, height } = componentProps;
|
|
23
|
+
const size = { height, width };
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<ErrorBoundary size={size}>
|
|
27
|
+
<ResizeContainer size={size}>
|
|
28
|
+
<StatisticsInner {...componentProps} />
|
|
29
|
+
</ResizeContainer>
|
|
30
|
+
</ErrorBoundary>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const StatisticsInner: FunctionComponent<StatisticsProps> = (componentProps) => {
|
|
35
|
+
const { numeratorFilter, denominatorFilter } = componentProps;
|
|
36
|
+
const lapis = useContext(LapisUrlContext);
|
|
37
|
+
|
|
38
|
+
const { data, error, isLoading } = useQuery(async () => {
|
|
39
|
+
return queryGeneralStatistics(numeratorFilter, denominatorFilter, lapis);
|
|
40
|
+
}, [numeratorFilter, denominatorFilter, lapis]);
|
|
41
|
+
|
|
42
|
+
if (isLoading) {
|
|
43
|
+
return <LoadingDisplay />;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (error !== null) {
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (data === null) {
|
|
51
|
+
return <NoDataDisplay />;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return <MetricDataTabs data={data} />;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
type MetricDataTabsProps = {
|
|
58
|
+
data: { count: number; proportion: number };
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const MetricDataTabs: FunctionComponent<MetricDataTabsProps> = ({ data }) => {
|
|
62
|
+
const { count, proportion } = data;
|
|
63
|
+
return (
|
|
64
|
+
<div className='flex flex-col sm:flex-row rounded-md border-2 border-gray-100'>
|
|
65
|
+
<div className='stat'>
|
|
66
|
+
<div className='stat-title'>Sequences</div>
|
|
67
|
+
<div className='stat-value text-2xl sm:text-4xl'>{count.toLocaleString('en-us')}</div>
|
|
68
|
+
<div className='stat-desc'>The total number of sequenced samples</div>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<div className='stat'>
|
|
72
|
+
<div className='stat-title'>Overall proportion</div>
|
|
73
|
+
<div className='stat-value text-2xl sm:text-4xl'>{formatProportion(proportion)}</div>
|
|
74
|
+
<div className='stat-desc'>The proportion among all sequenced samples</div>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type LapisFilter } from '../types';
|
|
2
|
+
import { queryAggregateData } from './queryAggregateData';
|
|
3
|
+
|
|
4
|
+
export async function queryGeneralStatistics(
|
|
5
|
+
numeratorFilter: LapisFilter,
|
|
6
|
+
denominatorFilter: LapisFilter,
|
|
7
|
+
lapis: string,
|
|
8
|
+
signal?: AbortSignal,
|
|
9
|
+
) {
|
|
10
|
+
const numeratorCount = await queryAggregateData(numeratorFilter, [], lapis, undefined, signal);
|
|
11
|
+
const denominatorCount = await queryAggregateData(denominatorFilter, [], lapis, undefined, signal);
|
|
12
|
+
|
|
13
|
+
if (numeratorCount.length === 0 || denominatorCount.length === 0) {
|
|
14
|
+
throw new Error('No data found for the given filters');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return { proportion: numeratorCount[0].count / denominatorCount[0].count, count: numeratorCount[0].count };
|
|
18
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type Meta, type StoryObj } from '@storybook/web-components';
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
|
|
4
|
+
import { withComponentDocs } from '../../../.storybook/ComponentDocsBlock';
|
|
5
|
+
import { AGGREGATED_ENDPOINT, LAPIS_URL } from '../../constants';
|
|
6
|
+
import denominatorData from '../../preact/statistic/__mockData__/denominator.json';
|
|
7
|
+
import numeratorData from '../../preact/statistic/__mockData__/numerator.json';
|
|
8
|
+
import { type StatisticsProps } from '../../preact/statistic/statistics';
|
|
9
|
+
|
|
10
|
+
import './gs-statistics';
|
|
11
|
+
import '../app';
|
|
12
|
+
|
|
13
|
+
const codeExample = `
|
|
14
|
+
<gs-statistics
|
|
15
|
+
numeratorFilter='{"country": "USA", "division": "Alabama}'
|
|
16
|
+
denominatorFilter='{"country": "USA"}'
|
|
17
|
+
width='100%'
|
|
18
|
+
height='700px'
|
|
19
|
+
></gs-statistics>`;
|
|
20
|
+
|
|
21
|
+
const meta: Meta<Required<StatisticsProps>> = {
|
|
22
|
+
title: 'Visualization/Statistics',
|
|
23
|
+
component: 'gs-statistics',
|
|
24
|
+
argTypes: {
|
|
25
|
+
width: { control: 'text' },
|
|
26
|
+
height: { control: 'text' },
|
|
27
|
+
},
|
|
28
|
+
parameters: withComponentDocs({
|
|
29
|
+
fetchMock: {
|
|
30
|
+
mocks: [
|
|
31
|
+
{
|
|
32
|
+
matcher: {
|
|
33
|
+
name: 'denominatorData',
|
|
34
|
+
url: AGGREGATED_ENDPOINT,
|
|
35
|
+
body: {
|
|
36
|
+
fields: [],
|
|
37
|
+
country: 'USA',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
response: {
|
|
41
|
+
status: 200,
|
|
42
|
+
body: denominatorData,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
matcher: {
|
|
47
|
+
name: 'numeratorData',
|
|
48
|
+
url: AGGREGATED_ENDPOINT,
|
|
49
|
+
body: {
|
|
50
|
+
fields: [],
|
|
51
|
+
country: 'USA',
|
|
52
|
+
division: 'Alabama',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
response: {
|
|
56
|
+
status: 200,
|
|
57
|
+
body: numeratorData,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
componentDocs: {
|
|
63
|
+
opensShadowDom: true,
|
|
64
|
+
expectsChildren: false,
|
|
65
|
+
codeExample,
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
68
|
+
tags: ['autodocs'],
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default meta;
|
|
72
|
+
|
|
73
|
+
export const Default: StoryObj<Required<StatisticsProps>> = {
|
|
74
|
+
render: (args) => html`
|
|
75
|
+
<gs-app lapis="${LAPIS_URL}">
|
|
76
|
+
<gs-statistics
|
|
77
|
+
.numeratorFilter=${args.numeratorFilter}
|
|
78
|
+
.denominatorFilter=${args.denominatorFilter}
|
|
79
|
+
.width=${args.width}
|
|
80
|
+
.height=${args.height}
|
|
81
|
+
></gs-statistics>
|
|
82
|
+
</gs-app>
|
|
83
|
+
`,
|
|
84
|
+
args: {
|
|
85
|
+
denominatorFilter: {
|
|
86
|
+
country: 'USA',
|
|
87
|
+
},
|
|
88
|
+
numeratorFilter: {
|
|
89
|
+
country: 'USA',
|
|
90
|
+
division: 'Alabama',
|
|
91
|
+
},
|
|
92
|
+
width: '100%',
|
|
93
|
+
height: '700px',
|
|
94
|
+
},
|
|
95
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
2
|
+
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
import { Statistics, type StatisticsProps } from '../../preact/statistic/statistics';
|
|
5
|
+
import type { LapisFilter } from '../../types';
|
|
6
|
+
import type { Equals, Expect } from '../../utils/typeAssertions';
|
|
7
|
+
import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsStyles';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* ## Context
|
|
11
|
+
*
|
|
12
|
+
* This component displays general statistics (number of sequences, overall proportion)
|
|
13
|
+
* for a given numerator and denominator filter.
|
|
14
|
+
*/
|
|
15
|
+
@customElement('gs-statistics')
|
|
16
|
+
export class StatisticsComponent extends PreactLitAdapterWithGridJsStyles {
|
|
17
|
+
/**
|
|
18
|
+
* The filter to apply to the data for the overall number of sequences and as the numerator for the proportion.
|
|
19
|
+
* It must be a valid LAPIS filter object.
|
|
20
|
+
*/
|
|
21
|
+
@property({ type: Object })
|
|
22
|
+
numeratorFilter: LapisFilter = {};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The filter to apply to the data for the denominator of the proportion.
|
|
26
|
+
* It must be a valid LAPIS filter object.
|
|
27
|
+
*/
|
|
28
|
+
@property({ type: Object })
|
|
29
|
+
denominatorFilter: LapisFilter = {};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The width of the component.
|
|
33
|
+
*
|
|
34
|
+
* Visit https://genspectrum.github.io/dashboard-components/?path=/docs/components-size-of-components--docs for more information.
|
|
35
|
+
*/
|
|
36
|
+
@property({ type: String })
|
|
37
|
+
width: string = '100%';
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The height of the component.
|
|
41
|
+
*
|
|
42
|
+
* Visit https://genspectrum.github.io/dashboard-components/?path=/docs/components-size-of-components--docs for more information.
|
|
43
|
+
*/
|
|
44
|
+
@property({ type: String })
|
|
45
|
+
height: string = '100%';
|
|
46
|
+
|
|
47
|
+
override render() {
|
|
48
|
+
return (
|
|
49
|
+
<Statistics
|
|
50
|
+
numeratorFilter={this.numeratorFilter}
|
|
51
|
+
denominatorFilter={this.denominatorFilter}
|
|
52
|
+
width={this.width}
|
|
53
|
+
height={this.height}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
declare global {
|
|
60
|
+
interface HTMLElementTagNameMap {
|
|
61
|
+
'gs-statistics': StatisticsComponent;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
declare global {
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
67
|
+
namespace JSX {
|
|
68
|
+
interface IntrinsicElements {
|
|
69
|
+
'gs-statistics': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
|
|
75
|
+
type WidthMatches = Expect<Equals<typeof StatisticsComponent.prototype.width, StatisticsProps['width']>>;
|
|
76
|
+
type HeightMatches = Expect<Equals<typeof StatisticsComponent.prototype.height, StatisticsProps['height']>>;
|
|
77
|
+
type DenominatorFilterMatches = Expect<
|
|
78
|
+
Equals<typeof StatisticsComponent.prototype.denominatorFilter, StatisticsProps['denominatorFilter']>
|
|
79
|
+
>;
|
|
80
|
+
type NumeratorFilterMatches = Expect<
|
|
81
|
+
Equals<typeof StatisticsComponent.prototype.numeratorFilter, StatisticsProps['numeratorFilter']>
|
|
82
|
+
>;
|
|
83
|
+
/* eslint-enable @typescript-eslint/no-unused-vars, no-unused-vars */
|
|
@@ -5,3 +5,4 @@ export { RelativeGrowthAdvantageComponent } from './gs-relative-growth-advantage
|
|
|
5
5
|
export { AggregateComponent } from './gs-aggregate';
|
|
6
6
|
export { NumberSequencesOverTimeComponent } from './gs-number-sequences-over-time';
|
|
7
7
|
export { MutationsOverTimeComponent } from './gs-mutations-over-time';
|
|
8
|
+
export { StatisticsComponent } from './gs-statistics';
|