refactoring
This commit is contained in:
@@ -3,13 +3,15 @@ class HistogramView {
|
|||||||
constructor() {
|
constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
show(batchcode, div) {
|
show(batchcode, uiContainer) {
|
||||||
fetch(`data/histograms/${batchcode}.json`)
|
fetch(`data/histograms/${batchcode}.json`)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(json => {
|
.then(json => {
|
||||||
const data = json.histograms[3].histogram;
|
const data = json.histograms[3].histogram;
|
||||||
|
const canvas = document.createElement("canvas");
|
||||||
|
uiContainer.appendChild(canvas);
|
||||||
new Chart(
|
new Chart(
|
||||||
div.querySelector('#symptomByBatchcodeHisto'),
|
canvas,
|
||||||
{
|
{
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -16,13 +16,6 @@ class BatchCodeTableInitializer {
|
|||||||
this.#countrySelect.addEventListener('change', event => this.#displayCountry(event.target.value));
|
this.#countrySelect.addEventListener('change', event => this.#displayCountry(event.target.value));
|
||||||
this.#displayCountry('Global')
|
this.#displayCountry('Global')
|
||||||
const histogramView = new HistogramView();
|
const histogramView = new HistogramView();
|
||||||
function createDiv() {
|
|
||||||
const div = document.createElement("div");
|
|
||||||
const canvas = document.createElement("canvas");
|
|
||||||
canvas.setAttribute("id", "symptomByBatchcodeHisto");
|
|
||||||
div.appendChild(canvas);
|
|
||||||
return div;
|
|
||||||
}
|
|
||||||
const thisClassInstance = this;
|
const thisClassInstance = this;
|
||||||
$(`#${this.#batchCodeTableElement[0].id} tbody`).on(
|
$(`#${this.#batchCodeTableElement[0].id} tbody`).on(
|
||||||
'click',
|
'click',
|
||||||
@@ -34,10 +27,10 @@ class BatchCodeTableInitializer {
|
|||||||
row.child.hide();
|
row.child.hide();
|
||||||
tr.removeClass('shown');
|
tr.removeClass('shown');
|
||||||
} else {
|
} else {
|
||||||
const div = createDiv();
|
const uiContainer = document.createElement("div");
|
||||||
row.child(div).show();
|
row.child(uiContainer).show();
|
||||||
tr.addClass('shown');
|
tr.addClass('shown');
|
||||||
histogramView.show('FD6840', div);
|
histogramView.show('FD6840', uiContainer);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user