2 petits correctif maison comme je ne suis pas un grand spécialiste le pose ici parcequ'il sont moche :
le premier : on enleve le pourcentage de la bulle :
rdv sur
limesurvey/scripts/admin/statistics.js
ligne 180 à peu pret
on modifie :
Code:
var $options = {
tooltipTemplate: "<%if (label){%><%=label %>: <%}%><%= value + '%' %>",
};
par
Code:
var $options = {
tooltipTemplate: "<%if (label){%><%=label %>: <%}%><%= value %>",
};
voila c'est moche, mais juste
le deuxieme
on decide de convertir les chiffre en pourcentage on garde le signe % mais on calcul le percentage associé :
code original :
ligne 140 a peu pret
rdv sur
limesurvey/scripts/admin/statistics.js
Code:
/**
* This function load the graphs needing datas (pie chart, polar, Doughnut)
*/
function init_chart_js_graph_with_datas($type,$qid)
{
var canvasId = 'chartjs-'+$qid;
var $canvas = document.getElementById(canvasId).getContext("2d");
var $canva = $('#'+canvasId);
var $color = $canva.data('color');
var $statistics = statisticsData['quid'+$qid];
if($statistics == undefined) return;
var $labels = $statistics.labels
var $grawdata = $statistics.grawdata
var $chartDef = new Array();
$('#legend-no-percent-'+$qid).hide();
$('#legend-percent-'+$qid).show();
$('#stat-no-answer-'+$qid).show();
$.each($labels, function($i, $label) {
$colori = (parseInt($i)+$color);
$chartDef[$i] = {
value: $grawdata[$i],
color:"rgba("+COLORS_FOR_SURVEY[$colori]+",0.6)",
highlight: "rgba("+COLORS_FOR_SURVEY[$colori]+",0.9)",
label: $label,
};
});
var $options = {
tooltipTemplate: "<%if (label){%><%=label %>: <%}%><%= value + '%' %>",
};
if (typeof chartjs != "undefined") {
if (typeof chartjs[$qid] != "undefined") {
window.chartjs[$qid].destroy();
}
}
window.chartjs[$qid] = new Chart($canvas)[$type](
$chartDef,
$options
);
}
en :
Code:
/**
* This function load the graphs needing datas (pie chart, polar, Doughnut)
*/
function init_chart_js_graph_with_datas($type,$qid)
{
var canvasId = 'chartjs-'+$qid;
var $canvas = document.getElementById(canvasId).getContext("2d");
var $canva = $('#'+canvasId);
var $color = $canva.data('color');
var $statistics = statisticsData['quid'+$qid];
if($statistics == undefined) return;
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: Math.floor(($grawdata[$i]/max)*100),
color:"rgba("+COLORS_FOR_SURVEY[$colori]+",0.6)",
highlight: "rgba("+COLORS_FOR_SURVEY[$colori]+",0.9)",
label: $label,
};
});
var $options = {
tooltipTemplate: "<%if (label){%><%=label %>: <%}%><%= value + '%' %>",
};
if (typeof chartjs != "undefined") {
if (typeof chartjs[$qid] != "undefined") {
window.chartjs[$qid].destroy();
}
}
window.chartjs[$qid] = new Chart($canvas)[$type](
$chartDef,
$options
);
}
explication : création d'une variable "max" qui calcul le total des valeur de chaque camenbert
Code:
[
va max=0;
$.each($labels, function($i, $label) {
max = max + parseInt($grawdata[$i]);
});
/code]
voila, c'est nul mais ça fonctionne
remplacement de la simple valeur par le calcul du pourcentage
[code type="javascript"]
Math.floor(($grawdata[$i]/max)*100)