starting to fetch histogram data

This commit is contained in:
frankknoll
2023-01-28 12:13:33 +01:00
parent 864e1c0bc0
commit fe2289fb39

View File

@@ -16,7 +16,7 @@ class BatchCodeTableInitializer {
this.#countrySelect.addEventListener('change', event => this.#displayCountry(event.target.value));
this.#displayCountry('Global')
// FK-TODO: refactor
function format(d) {
function createDiv() {
const div = document.createElement("div");
const canvas = document.createElement("canvas");
canvas.setAttribute("id", "symptomByBatchcodeHisto");
@@ -34,10 +34,14 @@ class BatchCodeTableInitializer {
row.child.hide();
tr.removeClass('shown');
} else {
const d = row.data();
const data = JSON.parse(d[10]);
const div = format(d);
const div = createDiv();
row.child(div).show();
tr.addClass('shown');
const batchcode = 'FD6840';
fetch(`data/histograms/${batchcode}.json`)
.then(response => response.json())
.then(json => {
const data = json.histograms[3].histogram;
new Chart(
div.querySelector('#symptomByBatchcodeHisto'),
{
@@ -50,7 +54,7 @@ class BatchCodeTableInitializer {
}
}
);
tr.addClass('shown');
});
}
});
}