adding bars to table's frequency column
This commit is contained in:
@@ -2,6 +2,7 @@ class HistogramTable {
|
|||||||
|
|
||||||
#tableElement;
|
#tableElement;
|
||||||
#table;
|
#table;
|
||||||
|
#sumFrequencies;
|
||||||
|
|
||||||
constructor(tableElement) {
|
constructor(tableElement) {
|
||||||
this.#tableElement = tableElement;
|
this.#tableElement = tableElement;
|
||||||
@@ -12,8 +13,8 @@ class HistogramTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
display(frequencyBySymptom) {
|
display(frequencyBySymptom) {
|
||||||
const symptom_frequency_arrays = Object.entries(frequencyBySymptom);
|
const symptom_frequency_pairs = Object.entries(frequencyBySymptom);
|
||||||
this.#setTableRows(symptom_frequency_arrays);
|
this.#setTableRows(symptom_frequency_pairs);
|
||||||
}
|
}
|
||||||
|
|
||||||
#createEmptyTable() {
|
#createEmptyTable() {
|
||||||
@@ -38,6 +39,18 @@ class HistogramTable {
|
|||||||
this.#getColumnIndex('Symptom')
|
this.#getColumnIndex('Symptom')
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
render: (data, type, row, meta) => {
|
||||||
|
// FK-TODO: refactor
|
||||||
|
const numberWithBar = UIUtils.instantiateTemplate('template-number-with-bar');
|
||||||
|
const bar = numberWithBar.querySelector('.bar');
|
||||||
|
bar.style.width = (data / this.#sumFrequencies * 100).toString() + "%";
|
||||||
|
const number = numberWithBar.querySelector('.number');
|
||||||
|
number.textContent = data;
|
||||||
|
return numberWithBar.outerHTML;
|
||||||
|
},
|
||||||
|
targets: [this.#getColumnIndex('Frequency')]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -51,10 +64,16 @@ class HistogramTable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#setTableRows(rows) {
|
#setTableRows(symptom_frequency_pairs) {
|
||||||
|
this.#sumFrequencies = this.#getSumFrequencies(symptom_frequency_pairs);
|
||||||
this.#table
|
this.#table
|
||||||
.clear()
|
.clear()
|
||||||
.rows.add(rows)
|
.rows.add(symptom_frequency_pairs)
|
||||||
.draw();
|
.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#getSumFrequencies(symptom_frequency_pairs) {
|
||||||
|
const frequencies = symptom_frequency_pairs.map(symptom_frequency_pair => symptom_frequency_pair[1])
|
||||||
|
return Utils.sum(frequencies);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ class Utils {
|
|||||||
return arr.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;
|
return arr.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static sum(numbers) {
|
||||||
|
return numbers.reduce((a, b) => a + b, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static getKeysAlignedWithValues(dict) {
|
static getKeysAlignedWithValues(dict) {
|
||||||
const keys = [];
|
const keys = [];
|
||||||
const values = [];
|
const values = [];
|
||||||
|
|||||||
@@ -14938,6 +14938,12 @@
|
|||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
<template id="template-number-with-bar">
|
||||||
|
<div>
|
||||||
|
<div class="number"></div>
|
||||||
|
<div class="bar"></div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
<!-- jQuery -->
|
<!-- jQuery -->
|
||||||
<script src="gentelella/vendors/jquery/dist/jquery.min.js"></script>
|
<script src="gentelella/vendors/jquery/dist/jquery.min.js"></script>
|
||||||
<!-- Bootstrap -->
|
<!-- Bootstrap -->
|
||||||
|
|||||||
@@ -4917,4 +4917,9 @@ table thead .checkbox.radio { margin-top:-7px;margin-top:-21px; }
|
|||||||
|
|
||||||
.chartWithSlider .sliderContainer {
|
.chartWithSlider .sliderContainer {
|
||||||
flex: 5%;
|
flex: 5%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bar {
|
||||||
|
height: 3px;
|
||||||
|
background-color: #1a73e8;
|
||||||
}
|
}
|
||||||
@@ -4,8 +4,7 @@ FK-FIXME:
|
|||||||
|
|
||||||
FK-TODO:
|
FK-TODO:
|
||||||
- add google captcha to batchCodeTable.html
|
- add google captcha to batchCodeTable.html
|
||||||
- "Frequencies of Reported Symptoms" als Tabelle (datatables) darstellen
|
- aus den JSON-Dateien lethality und severity entfernen.
|
||||||
- aus den Json-Dateien lethality und severity entfernen.
|
|
||||||
|
|
||||||
anacron job:
|
anacron job:
|
||||||
sudo cp src/intensivstationen_howbadismybatch.sh /etc/cron.daily/intensivstationen_howbadismybatch
|
sudo cp src/intensivstationen_howbadismybatch.sh /etc/cron.daily/intensivstationen_howbadismybatch
|
||||||
|
|||||||
Reference in New Issue
Block a user