starting to fetch histogram data
This commit is contained in:
@@ -16,7 +16,7 @@ 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')
|
||||||
// FK-TODO: refactor
|
// FK-TODO: refactor
|
||||||
function format(d) {
|
function createDiv() {
|
||||||
const div = document.createElement("div");
|
const div = document.createElement("div");
|
||||||
const canvas = document.createElement("canvas");
|
const canvas = document.createElement("canvas");
|
||||||
canvas.setAttribute("id", "symptomByBatchcodeHisto");
|
canvas.setAttribute("id", "symptomByBatchcodeHisto");
|
||||||
@@ -34,23 +34,27 @@ class BatchCodeTableInitializer {
|
|||||||
row.child.hide();
|
row.child.hide();
|
||||||
tr.removeClass('shown');
|
tr.removeClass('shown');
|
||||||
} else {
|
} else {
|
||||||
const d = row.data();
|
const div = createDiv();
|
||||||
const data = JSON.parse(d[10]);
|
|
||||||
const div = format(d);
|
|
||||||
row.child(div).show();
|
row.child(div).show();
|
||||||
new Chart(
|
|
||||||
div.querySelector('#symptomByBatchcodeHisto'),
|
|
||||||
{
|
|
||||||
type: 'bar',
|
|
||||||
data: {
|
|
||||||
datasets: [{
|
|
||||||
label: 'Acquisitions by year',
|
|
||||||
data: data
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
tr.addClass('shown');
|
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'),
|
||||||
|
{
|
||||||
|
type: 'bar',
|
||||||
|
data: {
|
||||||
|
datasets: [{
|
||||||
|
label: 'Acquisitions by year',
|
||||||
|
data: data
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user