From b72ab3b06bf6c805849f7e6d391ca32accc10370 Mon Sep 17 00:00:00 2001 From: Dominik Vitt Date: Mon, 12 Nov 2018 15:11:19 +0100 Subject: [PATCH] Fixed issue #14238: statistics chart tooltip shows incorrect data --- assets/scripts/admin/statistics.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/assets/scripts/admin/statistics.js b/assets/scripts/admin/statistics.js index ecff147564e..0d05024881a 100644 --- a/assets/scripts/admin/statistics.js +++ b/assets/scripts/admin/statistics.js @@ -130,15 +130,20 @@ function init_chart_js_graph_with_datas($type, $qid) { var $labels = $statistics.labels var $grawdata = $statistics.grawdata var $chartDef = new Array(); + var $max = 0; $('#legend-no-percent-' + $qid).hide(); $('#legend-percent-' + $qid).show(); $('#stat-no-answer-' + $qid).show(); + $.each($labels, function($i, $label) { + $max = $max + parseInt($grawdata[$i]); + }); + $.each($labels, function ($i, $label) { $colori = (parseInt($i) + $color); $chartDef[$i] = { - value: $grawdata[$i], + value: Math.round($grawdata[$i]/$max * 100 * 100) / 100, color: "rgba(" + COLORS_FOR_SURVEY[$colori] + ",0.6)", highlight: "rgba(" + COLORS_FOR_SURVEY[$colori] + ",0.9)", label: $label,