Files
HowBadIsMyBatch/docs/IntensiveCareCapacitiesChartView.js
frankknoll 57e9d1b62b refactoring
2022-02-28 19:14:03 +01:00

62 lines
1.5 KiB
JavaScript

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'
}
};
}
}