diff --git a/docs/IntensiveCareCapacitiesChartView.js b/docs/IntensiveCareCapacitiesChartView.js new file mode 100644 index 00000000000..6f70325f16b --- /dev/null +++ b/docs/IntensiveCareCapacitiesChartView.js @@ -0,0 +1,62 @@ +class IntensiveCareCapacitiesChartView { + + displayChart({ data, canvas, title }) { + new Chart( + canvas, + { + type: 'bar', + data: this.#getData(data), + options: this.#getOptions(title) + }); + } + + #getData(data) { + return { + datasets: [ + { + label: 'Belegte Betten', + data: data, + parsing: { + yAxisKey: 'betten_belegt' + }, + backgroundColor: 'rgba(255, 0, 0, 1)', + }, + { + label: 'Freie Betten', + data: data, + parsing: { + yAxisKey: 'betten_frei' + }, + backgroundColor: 'rgba(0, 255, 0, 1)', + } + ] + }; + } + + #getOptions(title) { + return { + plugins: { + title: { + display: true, + text: title + }, + }, + responsive: true, + scales: { + x: { + stacked: true, + type: 'time', + time: { + unit: 'month' + } + }, + y: { + stacked: true + } + }, + parsing: { + xAxisKey: 'date' + } + }; + } +} \ No newline at end of file diff --git a/docs/UIUtils.js b/docs/UIUtils.js new file mode 100644 index 00000000000..a3e80645278 --- /dev/null +++ b/docs/UIUtils.js @@ -0,0 +1,15 @@ +class UIUtils { + + static instantiateTemplate(templateId) { + return document.getElementById(templateId).content.firstElementChild.cloneNode(true); + } + + static createChartViewElementWithHeading(heading) { + const chartViewElement = UIUtils.instantiateTemplate('template-ChartView'); + chartViewElement.querySelector(".heading").textContent = heading; + return { + chartViewElement: chartViewElement, + canvas: chartViewElement.querySelector(".canvas") + }; + } +} diff --git a/docs/intensivstationen.html b/docs/intensivstationen.html index 76d1b1522d8..325c529b849 100644 --- a/docs/intensivstationen.html +++ b/docs/intensivstationen.html @@ -11,99 +11,28 @@ + + +
-- -
-- -
-- -
++ +
+