From 2651ee8017fbafc3738e29ce78df2c81d8449a33 Mon Sep 17 00:00:00 2001 From: frankknoll Date: Sat, 28 Jan 2023 22:51:28 +0100 Subject: [PATCH] refactoring --- docs/HistogramView.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/HistogramView.js b/docs/HistogramView.js index d1c0dd54b26..efe47133898 100644 --- a/docs/HistogramView.js +++ b/docs/HistogramView.js @@ -7,12 +7,9 @@ class HistogramView { } displayHistogramsForBatchcode(batchcode) { - const loadingText = document.createTextNode('Loading...'); - this.#uiContainer.appendChild(loadingText); - fetch(`data/histograms/${batchcode}.json`) - .then(response => response.json()) + this + .#loadHistoDescrsForBatchcode(batchcode) .then(histoDescrs => { - loadingText.remove(); for (const histoDescr of histoDescrs.histograms) { const canvas = document.createElement("canvas"); this.#uiContainer.appendChild(canvas); @@ -21,6 +18,16 @@ class HistogramView { }); } + #loadHistoDescrsForBatchcode(batchcode) { + const loadingText = document.createTextNode('Loading...'); + this.#uiContainer.appendChild(loadingText); + return fetch(`data/histograms/${batchcode}.json`) + .then(response => { + loadingText.remove(); + return response.json(); + }) + } + #displayHistogram(histoDescr, canvas) { // FK-TODO: brauchen Slider wie bei intensivstationen new Chart(