adding median
This commit is contained in:
@@ -57,6 +57,14 @@ class FreeBedsChartView {
|
||||
yAxisKey: 'free_beds_divided_by_all_beds_in_percent'
|
||||
},
|
||||
backgroundColor: 'rgba(0, 0, 150, 1)'
|
||||
},
|
||||
{
|
||||
label: 'Median des Anteils freier Betten',
|
||||
data: data,
|
||||
parsing: {
|
||||
yAxisKey: 'median_free_beds_in_percent'
|
||||
},
|
||||
backgroundColor: 'rgba(0, 150, 150, 1)'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
9
docs/Utils.js
Normal file
9
docs/Utils.js
Normal file
@@ -0,0 +1,9 @@
|
||||
class Utils {
|
||||
|
||||
// adapted from https://www.w3resource.com/javascript-exercises/fundamental/javascript-fundamental-exercise-88.php
|
||||
static median(arr) {
|
||||
const mid = Math.floor(arr.length / 2);
|
||||
const nums = [...arr].sort((a, b) => a - b);
|
||||
return arr.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@^3"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/moment@^2"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-moment@^1"></script>
|
||||
<script src="./Utils.js"></script>
|
||||
<script src="./UIUtils.js"></script>
|
||||
<script src="./IntensiveCareCapacitiesChartView.js"></script>
|
||||
<script src="./FreeBedsChartView.js"></script>
|
||||
|
||||
@@ -16,12 +16,18 @@ function displayFreeBedsChart({ freeBedsChartView, kreisText, kreisValue }) {
|
||||
.then(json =>
|
||||
freeBedsChartView.displayChart(
|
||||
{
|
||||
data: get_free_beds_divided_by_all_beds_in_percent(json.data),
|
||||
data: getDataDicts(json.data),
|
||||
title: kreisText
|
||||
}));
|
||||
}
|
||||
|
||||
function get_free_beds_divided_by_all_beds_in_percent(data) {
|
||||
function getDataDicts(data) {
|
||||
const dataDicts = get_free_beds_divided_by_all_beds_in_percent_dataDicts(data);
|
||||
add_median_free_beds_in_percent(dataDicts);
|
||||
return dataDicts;
|
||||
}
|
||||
|
||||
function get_free_beds_divided_by_all_beds_in_percent_dataDicts(data) {
|
||||
return data.map(({ date, betten_frei, betten_belegt }) =>
|
||||
(
|
||||
{
|
||||
@@ -30,3 +36,12 @@ function get_free_beds_divided_by_all_beds_in_percent(data) {
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
function add_median_free_beds_in_percent(dataDicts) {
|
||||
const median_free_beds_in_percent =
|
||||
Utils.median(
|
||||
dataDicts.map(dataDict => dataDict.free_beds_divided_by_all_beds_in_percent));
|
||||
for (const dataDict of dataDicts) {
|
||||
dataDict["median_free_beds_in_percent"] = median_free_beds_in_percent;
|
||||
}
|
||||
}
|
||||
@@ -47,8 +47,8 @@ man 5 fcrontab
|
||||
fcrontab -e
|
||||
|
||||
fcrontab -l
|
||||
# each day at 14:00 Uhr
|
||||
00 14 * * * /home/frankknoll/Dokumente/Corona/projects/HowBadIsMyBatch-pages/src/intensivstationen/intensivstationen.sh
|
||||
# each day at 13:30 Uhr
|
||||
30 13 * * * /home/frankknoll/Dokumente/Corona/projects/HowBadIsMyBatch-pages/src/intensivstationen/intensivstationen.sh
|
||||
|
||||
systemctl status fcron
|
||||
tail -f /var/log/syslog
|
||||
|
||||
Reference in New Issue
Block a user