adding "Select batchcode combination"
This commit is contained in:
@@ -1,15 +1,17 @@
|
|||||||
class HistogramView {
|
class HistogramView {
|
||||||
|
|
||||||
#uiContainer;
|
#uiContainer;
|
||||||
|
#chartWithSlider;
|
||||||
|
#histogramChartView;
|
||||||
|
|
||||||
constructor(uiContainer) {
|
constructor(uiContainer) {
|
||||||
this.#uiContainer = uiContainer
|
this.#uiContainer = uiContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
displayHistogramsForBatchcode(batchcode) {
|
displayHistogramViewForBatchcode(batchcode) {
|
||||||
this
|
this
|
||||||
.#loadHistoDescrsForBatchcode(batchcode)
|
.#loadHistoDescrsForBatchcode(batchcode)
|
||||||
.then(histoDescrs => this.#displayHistograms(histoDescrs));
|
.then(histoDescrs => this.#displayHistogramViewForHistoDescrs(histoDescrs));
|
||||||
}
|
}
|
||||||
|
|
||||||
#loadHistoDescrsForBatchcode(batchcode) {
|
#loadHistoDescrsForBatchcode(batchcode) {
|
||||||
@@ -22,29 +24,59 @@ class HistogramView {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#displayHistograms(histoDescrs) {
|
#displayHistogramViewForHistoDescrs(histoDescrs) {
|
||||||
this.#uiContainer.appendChild(document.createTextNode(histoDescrs.batchcode));
|
this.#displaySelectBatchcodeCombination(histoDescrs.histograms);
|
||||||
for (const histoDescr of histoDescrs.histograms) {
|
this.#chartWithSlider = UIUtils.instantiateTemplate('template-chartWithSlider');
|
||||||
this.#displayHistogram(histoDescr);
|
this.#uiContainer.appendChild(this.#chartWithSlider);
|
||||||
|
this.#histogramChartView = new HistogramChartView(this.#getCanvas());
|
||||||
|
this.#displayHistogram(histoDescrs.histograms[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#getCanvas() {
|
||||||
|
return this.#chartWithSlider.querySelector("canvas");
|
||||||
|
}
|
||||||
|
|
||||||
|
#displaySelectBatchcodeCombination(histograms) {
|
||||||
|
const selectBatchcodeCombination = UIUtils.instantiateTemplate('template-selectBatchcodeCombination');
|
||||||
|
const batchcodesSelect = selectBatchcodeCombination.querySelector('#batchcodesSelect');
|
||||||
|
this.#addBatchcodeCombinationOptions(batchcodesSelect, histograms);
|
||||||
|
batchcodesSelect.addEventListener(
|
||||||
|
'change',
|
||||||
|
event => {
|
||||||
|
const histoDescr = histograms[event.target.value];
|
||||||
|
this.#displayHistogram(histoDescr);
|
||||||
|
});
|
||||||
|
this.#uiContainer.appendChild(selectBatchcodeCombination);
|
||||||
|
}
|
||||||
|
|
||||||
|
#addBatchcodeCombinationOptions(batchcodesSelect, histograms) {
|
||||||
|
this.#getBatchcodeCombinationOptions(histograms).forEach(option => batchcodesSelect.add(option));
|
||||||
|
}
|
||||||
|
|
||||||
|
#getBatchcodeCombinationOptions(histograms) {
|
||||||
|
// FK-TODO: zuerst das Histogramm für den einzelnen batchcode, dann batchcodes-Array-Länge 2, 3, 4, ...
|
||||||
|
return histograms.map(this.#getBatchcodeCombinationOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
#getBatchcodeCombinationOption(histoDescr, index) {
|
||||||
|
const option = document.createElement("option");
|
||||||
|
option.text = histoDescr.batchcodes.join(', ');
|
||||||
|
option.value = index;
|
||||||
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
#displayHistogram(histoDescr) {
|
#displayHistogram(histoDescr) {
|
||||||
const chartWithSlider = UIUtils.instantiateTemplate('template-chartWithSlider');
|
this.#histogramChartView.displayChart(histoDescr);
|
||||||
this.#uiContainer.appendChild(chartWithSlider);
|
|
||||||
const canvas = chartWithSlider.querySelector("canvas");
|
|
||||||
const histogramChartView = new HistogramChartView(canvas);
|
|
||||||
histogramChartView.displayChart(histoDescr);
|
|
||||||
this.#createSlider(
|
this.#createSlider(
|
||||||
{
|
{
|
||||||
sliderElement: chartWithSlider.querySelector(".slider"),
|
sliderElement: this.#chartWithSlider.querySelector(".slider"),
|
||||||
range: {
|
range: {
|
||||||
min: 0,
|
min: 0,
|
||||||
max: Object.keys(histoDescr.histogram).length
|
max: Object.keys(histoDescr.histogram).length
|
||||||
},
|
},
|
||||||
orientation: 'vertical',
|
orientation: 'vertical',
|
||||||
height: canvas.style.height,
|
height: this.#getCanvas().style.height,
|
||||||
onUpdate: range => histogramChartView.setData(this.#slice(histoDescr, range))
|
onUpdate: range => this.#histogramChartView.setData(this.#slice(histoDescr, range))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -186,6 +186,15 @@
|
|||||||
<canvas></canvas>
|
<canvas></canvas>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template id="template-selectBatchcodeCombination">
|
||||||
|
<div>
|
||||||
|
<label>Select batchcode combination:
|
||||||
|
<select id="batchcodesSelect" name="batchcodes">
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template id="template-chartWithSlider">
|
<template id="template-chartWithSlider">
|
||||||
<div class="chartWithSlider">
|
<div class="chartWithSlider">
|
||||||
<div class="chartContainer">
|
<div class="chartContainer">
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ class BatchCodeTableInitializer {
|
|||||||
row.child(uiContainer).show();
|
row.child(uiContainer).show();
|
||||||
tr.addClass('shown');
|
tr.addClass('shown');
|
||||||
const batchcode = row.data()[thisClassInstance.#getColumnIndex('Batch')];
|
const batchcode = row.data()[thisClassInstance.#getColumnIndex('Batch')];
|
||||||
new HistogramView(uiContainer).displayHistogramsForBatchcode(batchcode);
|
new HistogramView(uiContainer).displayHistogramViewForBatchcode(batchcode);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user