handlich vaccines in UI

This commit is contained in:
frankknoll
2023-10-13 20:57:18 +02:00
parent f28ee6e400
commit 7b78a6f449
7 changed files with 259 additions and 17 deletions

View File

@@ -0,0 +1,72 @@
class PrrBySymptomTable {
#tableElement;
#table;
#sumPrrs;
constructor(tableElement) {
this.#tableElement = tableElement;
}
initialize() {
this.#table = this.#createEmptyTable();
}
display(prrBySymptom) {
const symptom_prr_pairs = Object.entries(prrBySymptom);
this.#setTableRows(symptom_prr_pairs);
}
#createEmptyTable() {
return this.#tableElement.DataTable(
{
search:
{
return: false
},
processing: true,
deferRender: true,
order: [[this.#getColumnIndex('Proportional Reporting Ratio > 1'), "desc"]],
columnDefs:
[
{
searchable: false,
targets: [this.#getColumnIndex('Proportional Reporting Ratio > 1')]
},
{
render: prr =>
NumberWithBarElementFactory
.createNumberWithBarElement(
{
number: prr,
barLenInPercent: prr / this.#sumPrrs * 100
})
.outerHTML,
targets: [this.#getColumnIndex('Proportional Reporting Ratio > 1')]
}
]
});
}
#getColumnIndex(columnName) {
switch (columnName) {
case 'Symptom':
return 0;
case 'Proportional Reporting Ratio > 1':
return 1;
}
}
#setTableRows(symptom_prr_pairs) {
this.#sumPrrs = this.#getSumPrrs(symptom_prr_pairs);
this.#table
.clear()
.rows.add(symptom_prr_pairs)
.draw();
}
#getSumPrrs(symptom_prr_pairs) {
const prrs = symptom_prr_pairs.map(symptom_prr_pair => symptom_prr_pair[1])
return Utils.sum(prrs);
}
}