making Countries column orderable
This commit is contained in:
@@ -59,8 +59,7 @@ class BatchCodeTableInitializer {
|
|||||||
targets:
|
targets:
|
||||||
[
|
[
|
||||||
this.#getColumnIndex('Batch'),
|
this.#getColumnIndex('Batch'),
|
||||||
this.#getColumnIndex('Company'),
|
this.#getColumnIndex('Company')
|
||||||
this.#getColumnIndex('Countries')
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -75,8 +74,13 @@ class BatchCodeTableInitializer {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
width: "1000px",
|
width: "1000px",
|
||||||
render: function (data, type, row, meta) {
|
render: (data, type, row, meta) => {
|
||||||
return null;
|
if (type === 'sort') {
|
||||||
|
return this.#getJensenShannonDistance(
|
||||||
|
row[this.#getColumnIndex('Batch')],
|
||||||
|
barChartDescriptions);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
},
|
},
|
||||||
createdCell: (cell, cellData, row, rowIndex, colIndex) => {
|
createdCell: (cell, cellData, row, rowIndex, colIndex) => {
|
||||||
if (showCountriesColumn) {
|
if (showCountriesColumn) {
|
||||||
@@ -93,7 +97,6 @@ class BatchCodeTableInitializer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#getColumnIndex(columnName) {
|
#getColumnIndex(columnName) {
|
||||||
switch (columnName) {
|
switch (columnName) {
|
||||||
case 'Batch':
|
case 'Batch':
|
||||||
@@ -117,14 +120,27 @@ class BatchCodeTableInitializer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#getJensenShannonDistance(batchcode, barChartDescriptions) {
|
||||||
|
const barChartDescription = this.#getBarChartDescription(barChartDescriptions, batchcode);
|
||||||
|
const maximally_different = 1;
|
||||||
|
if (barChartDescription === null) {
|
||||||
|
return maximally_different;
|
||||||
|
}
|
||||||
|
const jensenShannonDistance = barChartDescription['Jensen-Shannon distance'];
|
||||||
|
return jensenShannonDistance === null ? maximally_different : jensenShannonDistance;
|
||||||
|
}
|
||||||
|
|
||||||
#displayBatchcodeByCountryBarChart(batchcode, barChartDescriptions, uiContainer) {
|
#displayBatchcodeByCountryBarChart(batchcode, barChartDescriptions, uiContainer) {
|
||||||
if (batchcode in barChartDescriptions.barChartDescriptions) {
|
const barChartDescription = this.#getBarChartDescription(barChartDescriptions, batchcode);
|
||||||
new BatchcodeByCountryBarChartView(uiContainer)
|
if (barChartDescription !== null) {
|
||||||
.displayBatchcodeByCountryBarChart(this.#getBarChartDescription(barChartDescriptions, batchcode));
|
new BatchcodeByCountryBarChartView(uiContainer).displayBatchcodeByCountryBarChart(barChartDescription);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#getBarChartDescription(barChartDescriptions, batchcode) {
|
#getBarChartDescription(barChartDescriptions, batchcode) {
|
||||||
|
if (!(batchcode in barChartDescriptions.barChartDescriptions)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
const barChartDescription = barChartDescriptions.barChartDescriptions[batchcode];
|
const barChartDescription = barChartDescriptions.barChartDescriptions[batchcode];
|
||||||
barChartDescription.batchcode = batchcode;
|
barChartDescription.batchcode = batchcode;
|
||||||
barChartDescription['date range guessed'] = barChartDescriptions['date range guessed'];
|
barChartDescription['date range guessed'] = barChartDescriptions['date range guessed'];
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ class BatchcodeByCountryBarChart {
|
|||||||
labels: barChartDescription.countries,
|
labels: barChartDescription.countries,
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
label: `Known (${this.#dateRange2str(barChartDescription['date range known'])})`,
|
// FK-TODO: do not display Jensen-Shannon distance here or do not display at all
|
||||||
|
label: `Known (${this.#dateRange2str(barChartDescription['date range known'])}) ${barChartDescription['Jensen-Shannon distance']}`,
|
||||||
data: barChartDescription["Adverse Reaction Reports known"]
|
data: barChartDescription["Adverse Reaction Reports known"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user