@genspectrum/dashboard-components 0.5.5 → 0.5.6
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 +16 -0
- package/dist/dashboard-components.js +43 -1
- package/dist/dashboard-components.js.map +1 -1
- package/dist/genspectrum-components.d.ts +2 -2
- package/package.json +1 -1
- package/src/preact/numberSequencesOverTime/number-sequences-over-time-line-chart.tsx +59 -0
- package/src/preact/numberSequencesOverTime/number-sequences-over-time.tsx +2 -1
- package/src/web-components/visualization/gs-number-sequences-over-time.stories.ts +11 -0
|
@@ -876,14 +876,14 @@ declare global {
|
|
|
876
876
|
|
|
877
877
|
declare global {
|
|
878
878
|
interface HTMLElementTagNameMap {
|
|
879
|
-
'gs-
|
|
879
|
+
'gs-prevalence-over-time': PrevalenceOverTimeComponent;
|
|
880
880
|
}
|
|
881
881
|
}
|
|
882
882
|
|
|
883
883
|
|
|
884
884
|
declare global {
|
|
885
885
|
interface HTMLElementTagNameMap {
|
|
886
|
-
'gs-
|
|
886
|
+
'gs-relative-growth-advantage': RelativeGrowthAdvantageComponent;
|
|
887
887
|
}
|
|
888
888
|
}
|
|
889
889
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Chart, type ChartConfiguration, type ChartDataset, registerables } from 'chart.js';
|
|
2
|
+
import { useMemo } from 'preact/hooks';
|
|
3
|
+
|
|
4
|
+
import { getNumberOfSequencesOverTimeTableData } from './getNumberOfSequencesOverTimeTableData';
|
|
5
|
+
import { type NumberOfSequencesDatasets } from '../../query/queryNumberOfSequencesOverTime';
|
|
6
|
+
import GsChart from '../components/chart';
|
|
7
|
+
import { singleGraphColorRGBAById } from '../shared/charts/colors';
|
|
8
|
+
|
|
9
|
+
interface NumberSequencesOverBarChartProps {
|
|
10
|
+
data: NumberOfSequencesDatasets;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
Chart.register(...registerables);
|
|
14
|
+
|
|
15
|
+
export const NumberSequencesOverTimeLineChart = ({ data }: NumberSequencesOverBarChartProps) => {
|
|
16
|
+
const config: ChartConfiguration = useMemo(
|
|
17
|
+
() => ({
|
|
18
|
+
type: 'line',
|
|
19
|
+
data: {
|
|
20
|
+
datasets: getDatasets(data),
|
|
21
|
+
},
|
|
22
|
+
options: {
|
|
23
|
+
maintainAspectRatio: false,
|
|
24
|
+
animation: false,
|
|
25
|
+
plugins: {
|
|
26
|
+
legend: {
|
|
27
|
+
display: false,
|
|
28
|
+
},
|
|
29
|
+
tooltip: {
|
|
30
|
+
mode: 'index',
|
|
31
|
+
intersect: false,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
36
|
+
[data],
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
return <GsChart configuration={config} />;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const getDatasets = (data: NumberOfSequencesDatasets) => {
|
|
43
|
+
const tableData = getNumberOfSequencesOverTimeTableData(data, 'date');
|
|
44
|
+
|
|
45
|
+
return data.map(
|
|
46
|
+
({ displayName }, index) =>
|
|
47
|
+
({
|
|
48
|
+
borderWidth: 1,
|
|
49
|
+
pointRadius: 0,
|
|
50
|
+
label: displayName,
|
|
51
|
+
backgroundColor: singleGraphColorRGBAById(index, 0.3),
|
|
52
|
+
borderColor: singleGraphColorRGBAById(index),
|
|
53
|
+
data: tableData.map((row) => ({
|
|
54
|
+
x: row.date,
|
|
55
|
+
y: row[displayName],
|
|
56
|
+
})),
|
|
57
|
+
}) as ChartDataset<'line', { x: string; y: number }[]>,
|
|
58
|
+
);
|
|
59
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useContext } from 'preact/hooks';
|
|
2
2
|
|
|
3
3
|
import { NumberSequencesOverTimeBarChart } from './number-sequences-over-time-bar-chart';
|
|
4
|
+
import { NumberSequencesOverTimeLineChart } from './number-sequences-over-time-line-chart';
|
|
4
5
|
import { NumberSequencesOverTimeTable } from './number-sequences-over-time-table';
|
|
5
6
|
import {
|
|
6
7
|
type NumberOfSequencesDatasets,
|
|
@@ -90,7 +91,7 @@ const NumberSequencesOverTimeTabs = ({ views, data, granularity, pageSize }: Num
|
|
|
90
91
|
case 'bar':
|
|
91
92
|
return { title: 'Bar', content: <NumberSequencesOverTimeBarChart data={data} /> };
|
|
92
93
|
case 'line':
|
|
93
|
-
return { title: 'Line', content: <
|
|
94
|
+
return { title: 'Line', content: <NumberSequencesOverTimeLineChart data={data} /> };
|
|
94
95
|
case 'table':
|
|
95
96
|
return {
|
|
96
97
|
title: 'Table',
|
|
@@ -116,6 +116,17 @@ export const OneDatasetBarChart: StoryObj<NumberSequencesOverTimeProps> = {
|
|
|
116
116
|
},
|
|
117
117
|
};
|
|
118
118
|
|
|
119
|
+
export const OneDatasetLineChart: StoryObj<NumberSequencesOverTimeProps> = {
|
|
120
|
+
...Template,
|
|
121
|
+
play: async ({ canvasElement }) => {
|
|
122
|
+
const canvas = await withinShadowRoot(canvasElement, 'gs-number-sequences-over-time');
|
|
123
|
+
|
|
124
|
+
await waitFor(() => expect(canvas.getByRole('button', { name: 'Line' })).toBeVisible());
|
|
125
|
+
|
|
126
|
+
await fireEvent.click(canvas.getByRole('button', { name: 'Line' }));
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
|
|
119
130
|
export const OneDatasetTable: StoryObj<NumberSequencesOverTimeProps> = {
|
|
120
131
|
...Template,
|
|
121
132
|
play: async ({ canvasElement }) => {
|