Skip to content
Extraits de code Groupes Projets
Valider e42975ce rédigé par sgiehl's avatar sgiehl
Parcourir les fichiers

improve jqplot number formatter and use it for data in tooltips

parent a9b59fd7
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -114,7 +114,7 @@ ...@@ -114,7 +114,7 @@
axes: { axes: {
yaxis: { yaxis: {
tickOptions: { tickOptions: {
formatString: '%d', formatString: '%s',
formatter: $.jqplot.NumberFormatter formatter: $.jqplot.NumberFormatter
} }
} }
...@@ -529,7 +529,7 @@ ...@@ -529,7 +529,7 @@
var axisId = this.jqplotParams.series[seriesIndex].yaxis; var axisId = this.jqplotParams.series[seriesIndex].yaxis;
var formatString = this.jqplotParams.axes[axisId].tickOptions.formatString; var formatString = this.jqplotParams.axes[axisId].tickOptions.formatString;
return formatString.replace('%s', value); return $.jqplot.NumberFormatter(formatString, value);
}, },
/** /**
...@@ -794,14 +794,14 @@ RowEvolutionSeriesToggle.prototype.beforeReplot = function () { ...@@ -794,14 +794,14 @@ RowEvolutionSeriesToggle.prototype.beforeReplot = function () {
var minimumFractionDigits = 0; var minimumFractionDigits = 0;
var maximumFractionDigits = 2; var maximumFractionDigits = 2;
$.jqplot.NumberFormatter = function (format, value) { $.jqplot.NumberFormatter = function (format, value, pattern) {
if (!$.isNumeric(value)) { if (!$.isNumeric(value)) {
return value; return format.replace(/%s/, value);
} }
// Ensure that the value is positive and has the right number of digits. // Ensure that the value is positive and has the right number of digits.
var negative = value < 0; var negative = value < 0;
var pattern = negative ? piwik.numbers.patternNegative : piwik.numbers.patternPositive; pattern = pattern || (negative ? piwik.numbers.patternNegative : piwik.numbers.patternPositive);
var signMultiplier = negative ? '-1' : '1'; var signMultiplier = negative ? '-1' : '1';
value = value * signMultiplier; value = value * signMultiplier;
// Split the number into major and minor digits. // Split the number into major and minor digits.
...@@ -839,7 +839,7 @@ RowEvolutionSeriesToggle.prototype.beforeReplot = function () { ...@@ -839,7 +839,7 @@ RowEvolutionSeriesToggle.prototype.beforeReplot = function () {
value = pattern.replace(/#(?:[\.,]#+)*0(?:[,\.][0#]+)*/, value); value = pattern.replace(/#(?:[\.,]#+)*0(?:[,\.][0#]+)*/, value);
// Localize the number. // Localize the number.
value = replaceSymbols(value); value = replaceSymbols(value);
return value; return format.replace(/%s/, value);
} }
})(jQuery); })(jQuery);
......
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
var percentage = ''; var percentage = '';
if (typeof this.tooltip.percentages != 'undefined') { if (typeof this.tooltip.percentages != 'undefined') {
percentage = this.tooltip.percentages[seriesIndex][valueIndex]; percentage = this.tooltip.percentages[seriesIndex][valueIndex];
percentage = ' (' + percentage + '%)'; percentage = ' (' + $.jqplot.NumberFormatter('%s', percentage, piwik.numbers.patternPercent) + ')';
} }
var label = this.jqplotParams.axes.xaxis.labels[valueIndex]; var label = this.jqplotParams.axes.xaxis.labels[valueIndex];
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
var label = this.data[0][valueIndex][0]; var label = this.data[0][valueIndex][0];
var text = '<strong>' + percentage + '%</strong> (' + value + ' ' + series + ')'; var text = '<strong>' + $.jqplot.NumberFormatter('%s', percentage, piwik.numbers.patternPercent) + '</strong> (' + value + ' ' + series + ')';
$(element).tooltip({ $(element).tooltip({
track: true, track: true,
items: '*', items: '*',
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter