refactoring

This commit is contained in:
frankknoll
2022-03-15 02:44:29 +01:00
parent a7171ceef2
commit 359a4f6080
2 changed files with 4 additions and 3 deletions

View File

@@ -27,7 +27,7 @@ class FreeBedsChartView {
label: 'Anteil freier Betten', label: 'Anteil freier Betten',
data: data, data: data,
parsing: { parsing: {
yAxisKey: 'free_beds_divided_by_all_beds' yAxisKey: 'free_beds_divided_by_all_beds_in_percent'
}, },
backgroundColor: 'rgba(0, 255, 0, 1)' backgroundColor: 'rgba(0, 255, 0, 1)'
} }

View File

@@ -66,11 +66,12 @@
kreisText: selectedOption.text, kreisText: selectedOption.text,
kreisValue: selectedOption.value kreisValue: selectedOption.value
}); });
// FK-TODO: extract method
fetch(`data/intensivstationen/intensivstationen-${selectedOption.value}.json`) fetch(`data/intensivstationen/intensivstationen-${selectedOption.value}.json`)
.then(response => response.json()) .then(response => response.json())
.then(json => { .then(json => {
for (const dataElement of json.data) { for (const dataElement of json.data) {
dataElement.free_beds_divided_by_all_beds = dataElement.betten_frei / (dataElement.betten_frei + dataElement.betten_belegt) * 100; dataElement.free_beds_divided_by_all_beds_in_percent = dataElement.betten_frei / (dataElement.betten_frei + dataElement.betten_belegt) * 100;
} }
freeBedsChartView.displayChart({ data: json.data, title: selectedOption.text }); freeBedsChartView.displayChart({ data: json.data, title: selectedOption.text });
}); });
@@ -87,7 +88,7 @@
.then(response => response.json()) .then(response => response.json())
.then(json => { .then(json => {
for (const dataElement of json.data) { for (const dataElement of json.data) {
dataElement.free_beds_divided_by_all_beds = dataElement.betten_frei / (dataElement.betten_frei + dataElement.betten_belegt) * 100; dataElement.free_beds_divided_by_all_beds_in_percent = dataElement.betten_frei / (dataElement.betten_frei + dataElement.betten_belegt) * 100;
} }
freeBedsChartView.displayChart({ data: json.data, title: 'Alle Landkreise' }); freeBedsChartView.displayChart({ data: json.data, title: 'Alle Landkreise' });
}); });