fix: lump into other category better

This commit is contained in:
Anna 2021-10-10 20:11:05 -04:00
parent 85f743ceb3
commit 69a4ecc4b0
1 changed files with 23 additions and 1 deletions

View File

@ -53,6 +53,28 @@
return newData;
}
function combineTopN(data, n) {
let newData = [];
let other = {
x: 'Other',
y: 0,
};
for (let i = 0; i < data.length; i++) {
if (i < n) {
newData.push(data[i]);
continue;
}
other.y += 1;
}
newData.push(other);
return newData;
}
function makeChart(tableId, chartId, chartType, combine = false) {
let table = document.getElementById(tableId);
let data = [];
@ -65,7 +87,7 @@
}
if (combine) {
data = combineUnderMedian(data);
data = combineTopN(data, 15);
}
new Chart(