refactoring
This commit is contained in:
@@ -6,22 +6,26 @@ class HistogramView {
|
|||||||
show(batchcode, uiContainer) {
|
show(batchcode, uiContainer) {
|
||||||
fetch(`data/histograms/${batchcode}.json`)
|
fetch(`data/histograms/${batchcode}.json`)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(json => {
|
.then(histoDescr => {
|
||||||
const data = json.histograms[3].histogram;
|
|
||||||
const canvas = document.createElement("canvas");
|
const canvas = document.createElement("canvas");
|
||||||
uiContainer.appendChild(canvas);
|
uiContainer.appendChild(canvas);
|
||||||
new Chart(
|
this.#displayChart(histoDescr, canvas);
|
||||||
canvas,
|
|
||||||
{
|
|
||||||
type: 'bar',
|
|
||||||
data: {
|
|
||||||
datasets: [{
|
|
||||||
label: 'Acquisitions by year',
|
|
||||||
data: data
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#displayChart(histoDescr, canvas) {
|
||||||
|
// FK-TODO: brauchen Slider wie bei intensivstationen
|
||||||
|
new Chart(
|
||||||
|
canvas,
|
||||||
|
{
|
||||||
|
type: 'bar',
|
||||||
|
data: {
|
||||||
|
datasets: [{
|
||||||
|
label: histoDescr.batchcode,
|
||||||
|
data: histoDescr.histograms[0].histogram
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user