-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(components): number of sequences over time: implement bar chart …
…view closes #316
- Loading branch information
1 parent
83b0868
commit f7af2c9
Showing
14 changed files
with
1,999 additions
and
295 deletions.
There are no files selected for viewing
1,640 changes: 1,354 additions & 286 deletions
1,640
components/src/preact/numberSequencesOverTime/__mockData__/twoVariantsEG.json
Large diffs are not rendered by default.
Oops, something went wrong.
506 changes: 506 additions & 0 deletions
506
components/src/preact/numberSequencesOverTime/__mockData__/twoVariantsXBB.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
components/src/preact/numberSequencesOverTime/number-sequences-over-time-bar-chart.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Chart, type ChartConfiguration, type ChartDataset, registerables } from 'chart.js'; | ||
import { useMemo } from 'preact/hooks'; | ||
|
||
import { getNumberOfSequencesOverTimeTableData } from './getNumberOfSequencesOverTimeTableData'; | ||
import { type NumberOfSequencesDatasets } from '../../query/queryNumberOfSequencesOverTime'; | ||
import GsChart from '../components/chart'; | ||
import { singleGraphColorRGBAById } from '../shared/charts/colors'; | ||
|
||
interface NumberSequencesOverBarChartProps { | ||
data: NumberOfSequencesDatasets; | ||
} | ||
|
||
Chart.register(...registerables); | ||
|
||
export const NumberSequencesOverTimeBarChart = ({ data }: NumberSequencesOverBarChartProps) => { | ||
const config: ChartConfiguration = useMemo( | ||
() => ({ | ||
type: 'bar', | ||
data: { | ||
datasets: getDatasets(data), | ||
}, | ||
options: { | ||
maintainAspectRatio: false, | ||
animation: false, | ||
plugins: { | ||
legend: { | ||
display: false, | ||
}, | ||
tooltip: { | ||
mode: 'index', | ||
intersect: false, | ||
}, | ||
}, | ||
}, | ||
}), | ||
[data], | ||
); | ||
|
||
return <GsChart configuration={config} />; | ||
}; | ||
|
||
const getDatasets = (data: NumberOfSequencesDatasets) => { | ||
const tableData = getNumberOfSequencesOverTimeTableData(data, 'date'); | ||
|
||
return data.map( | ||
({ displayName }, index) => | ||
({ | ||
borderWidth: 1, | ||
label: displayName, | ||
backgroundColor: singleGraphColorRGBAById(index, 0.3), | ||
borderColor: singleGraphColorRGBAById(index), | ||
data: tableData.map((row) => ({ | ||
x: row.date, | ||
y: row[displayName], | ||
})), | ||
}) as ChartDataset<'bar', { x: string; y: number }[]>, | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+21.6 KB
...izatio-43ba6-one-dataset-bar-chart-should-match-screenshot-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+58 KB
...lizatio-43ba6-one-dataset-bar-chart-should-match-screenshot-1-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+30.7 KB
...izatio-a36f3-non-overlapping-dates-should-match-screenshot-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+70.5 KB
...lizatio-a36f3-non-overlapping-dates-should-match-screenshot-1-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+11.6 KB
(190%)
...izatio-ffd47-er-time--two-datasets-should-match-screenshot-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+35.5 KB
(230%)
...lizatio-ffd47-er-time--two-datasets-should-match-screenshot-1-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters