starting to add row details to DataTable
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -15,19 +15,58 @@ class BatchCodeTableInitializer {
|
|||||||
this.#batchCodeTable = this.#createEmptyBatchCodeTable();
|
this.#batchCodeTable = this.#createEmptyBatchCodeTable();
|
||||||
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')
|
||||||
|
function format(d) {
|
||||||
|
const div = document.createElement("div");
|
||||||
|
const canvas = document.createElement("canvas");
|
||||||
|
canvas.setAttribute("id", "acquisitions");
|
||||||
|
div.appendChild(canvas);
|
||||||
|
return div;
|
||||||
|
}
|
||||||
|
const thisClassInstance = this;
|
||||||
|
$('#' + this.#batchCodeTableElement[0].id + ' tbody').on(
|
||||||
|
'click',
|
||||||
|
'td.dt-control',
|
||||||
|
function () {
|
||||||
|
const tr = $(this).closest('tr');
|
||||||
|
const row = thisClassInstance.#batchCodeTable.row(tr);
|
||||||
|
if (row.child.isShown()) {
|
||||||
|
row.child.hide();
|
||||||
|
tr.removeClass('shown');
|
||||||
|
} else {
|
||||||
|
const div = format(row.data());
|
||||||
|
row.child(div).show();
|
||||||
|
new Chart(
|
||||||
|
div.querySelector('#acquisitions'),
|
||||||
|
{
|
||||||
|
type: 'bar',
|
||||||
|
data: {
|
||||||
|
datasets: [{
|
||||||
|
label: 'Acquisitions by year',
|
||||||
|
data: {
|
||||||
|
"Circulatory collapse": 1,
|
||||||
|
"Hyperhidrosis": 4
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
tr.addClass('shown');
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#createEmptyBatchCodeTable() {
|
#createEmptyBatchCodeTable() {
|
||||||
const columnIndex = {
|
const columnIndex = {
|
||||||
'Batch': 0,
|
'control': 0,
|
||||||
'Adverse Reaction Reports': 1,
|
'Batch': 1,
|
||||||
'Deaths': 2,
|
'Adverse Reaction Reports': 2,
|
||||||
'Disabilities': 3,
|
'Deaths': 3,
|
||||||
'Life Threatening Illnesses': 4,
|
'Disabilities': 4,
|
||||||
'Company': 5,
|
'Life Threatening Illnesses': 5,
|
||||||
'Countries': 6,
|
'Company': 6,
|
||||||
'Severe reports': 7,
|
'Countries': 7,
|
||||||
'Lethality': 8
|
'Severe reports': 8,
|
||||||
|
'Lethality': 9
|
||||||
};
|
};
|
||||||
return this.#batchCodeTableElement.DataTable(
|
return this.#batchCodeTableElement.DataTable(
|
||||||
{
|
{
|
||||||
@@ -44,6 +83,13 @@ class BatchCodeTableInitializer {
|
|||||||
order: [[columnIndex['Adverse Reaction Reports'], "desc"]],
|
order: [[columnIndex['Adverse Reaction Reports'], "desc"]],
|
||||||
columnDefs:
|
columnDefs:
|
||||||
[
|
[
|
||||||
|
{
|
||||||
|
className: 'dt-control',
|
||||||
|
orderable: false,
|
||||||
|
data: null,
|
||||||
|
defaultContent: '',
|
||||||
|
targets: columnIndex['control']
|
||||||
|
},
|
||||||
{
|
{
|
||||||
searchable: false,
|
searchable: false,
|
||||||
targets: [
|
targets: [
|
||||||
|
|||||||
Reference in New Issue
Block a user