From c0ef366fa3e895575785c3cec3ee71375d56f2cb Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Mon, 19 Sep 2022 09:21:40 +0200 Subject: [PATCH] [Statistics] Hide labels with percentage below 1% --- assets/js/sections/statistics.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/assets/js/sections/statistics.js b/assets/js/sections/statistics.js index e7ffcfe5..e8b38db6 100644 --- a/assets/js/sections/statistics.js +++ b/assets/js/sections/statistics.js @@ -271,6 +271,7 @@ function totalBandQsos() { '
'); var labels = []; var dataQso = []; + var totalQso = Number(0); var $myTable = $('.bandtable'); var i = 1; @@ -295,6 +296,7 @@ function totalBandQsos() { $.each(data, function () { labels.push(this.band); dataQso.push(this.count); + totalQso = Number(totalQso) + Number(this.count); }); const COLORS = ["#3366cc", "#dc3912", "#ff9900", "#109618", "#990099", "#0099c6", "#dd4477", "#66aa00", "#b82e2e", "#316395", "#994499"] @@ -336,6 +338,9 @@ function totalBandQsos() { align: "middle" }, outlabels: { + display: function(context) { // Hide labels with low percentage + return ((context.dataset.data[context.dataIndex] / totalQso * 100) > 1) + }, backgroundColor: COLORS, borderColor: COLORS, borderRadius: 2, // Border radius of Label @@ -395,6 +400,7 @@ function totalSatQsos() { var labels = []; var dataQso = []; + var totalQso = Number(0); var $myTable = $('.sattable'); var i = 1; @@ -419,6 +425,7 @@ function totalSatQsos() { $.each(data, function () { labels.push(this.sat); dataQso.push(this.count); + totalQso = Number(totalQso) + Number(this.count); }); const COLORS = ["#3366cc", "#dc3912", "#ff9900", "#109618", "#990099", "#0099c6", "#dd4477", "#66aa00", "#b82e2e", "#316395", "#994499"] @@ -462,6 +469,9 @@ function totalSatQsos() { align: "middle" }, outlabels: { + display: function(context) { // Hide labels with low percentage + return ((context.dataset.data[context.dataIndex] / totalQso * 100) > 1) + }, backgroundColor: COLORS, borderColor: COLORS, borderRadius: 2, // Border radius of Label