mirror of https://github.com/MISP/misp-dashboard
Added a limit for the number of displayed item in piechart
parent
95faae3fd2
commit
2216b96c6c
|
@ -144,6 +144,13 @@ function generateEmptyAndFillData(data) {
|
|||
return toPlot;
|
||||
}
|
||||
|
||||
function compareObj(a,b) {
|
||||
if (a.data < b.data)
|
||||
return -1;
|
||||
if (a.data > b.data)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
/* UPDATES */
|
||||
|
||||
function updatePie(pie, data) {
|
||||
|
@ -166,6 +173,9 @@ function updatePie(pie, data) {
|
|||
toPlot_obj[itemStr] += count;
|
||||
}
|
||||
}
|
||||
if (Object.keys(toPlot_obj).length == 0) { // no data
|
||||
toPlot = [{ label: 'No data', data: 100 }];
|
||||
} else {
|
||||
toPlot = [];
|
||||
for (var itemStr in toPlot_obj) {
|
||||
if (toPlot_obj.hasOwnProperty(itemStr)) {
|
||||
|
@ -173,7 +183,9 @@ function updatePie(pie, data) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
toPlot.sort(compareObj).reverse();
|
||||
toPlot = toPlot.slice(0,15); // take at max 12 elements
|
||||
}
|
||||
if (!(pieWidget === undefined)) {
|
||||
pieWidget.setData(toPlot);
|
||||
pieWidget.setupGrid();
|
||||
|
|
|
@ -54,7 +54,7 @@ class Trendings_helper:
|
|||
|
||||
''' GETTER '''
|
||||
|
||||
def getGenericTrending(self, trendingType, dateS, dateE, topNum=12):
|
||||
def getGenericTrending(self, trendingType, dateS, dateE, topNum=0):
|
||||
to_ret = []
|
||||
prev_days = (dateE - dateS).days
|
||||
for curDate in util.getXPrevDaysSpan(dateE, prev_days):
|
||||
|
|
Loading…
Reference in New Issue