refactoring

This commit is contained in:
frankknoll
2023-01-28 17:45:35 +01:00
parent e9e49154bd
commit f77bce94d6

View File

@@ -7,16 +7,19 @@ class HistogramView {
} }
displayHistogramsForBatchcode(batchcode) { displayHistogramsForBatchcode(batchcode) {
// FK-TODO: zeige "Loading..." bis Daten geladen sind.
fetch(`data/histograms/${batchcode}.json`) fetch(`data/histograms/${batchcode}.json`)
.then(response => response.json()) .then(response => response.json())
.then(histoDescr => { .then(histoDescrs => {
for (const histoDescr of histoDescrs.histograms) {
const canvas = document.createElement("canvas"); const canvas = document.createElement("canvas");
this.#uiContainer.appendChild(canvas); this.#uiContainer.appendChild(canvas);
this.#displayChart(histoDescr, canvas); this.#displayHistogram(histoDescr, canvas);
}
}); });
} }
#displayChart(histoDescr, canvas) { #displayHistogram(histoDescr, canvas) {
// FK-TODO: brauchen Slider wie bei intensivstationen // FK-TODO: brauchen Slider wie bei intensivstationen
new Chart( new Chart(
canvas, canvas,
@@ -24,8 +27,9 @@ class HistogramView {
type: 'bar', type: 'bar',
data: { data: {
datasets: [{ datasets: [{
label: histoDescr.batchcode, // FK-TODO: alle histoDescr.batchcodes zu einem String zusammenfassen
data: histoDescr.histograms[0].histogram label: histoDescr.batchcodes[0],
data: histoDescr.histogram
}] }]
} }
} }