/soc/2012/sanket/www-statscollector: 495c52323add: [ENHANCEMENT]...

sanket sanket at soc.pidgin.im
Tue Aug 7 16:15:54 EDT 2012


Changeset: 495c52323add4717ae4600cb91d060c8a20341c6
Author:	 sanket <sanket at soc.pidgin.im>
Date:	 2012-08-07 13:15 +0530
Branch:	 default
URL: http://hg.pidgin.im/soc/2012/sanket/www-statscollector/rev/495c52323add

Description:

[ENHANCEMENT] Round numbers off in UI

diffstat:

 pidgin_stats_collector/media/js/charts.js |  13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diffs (48 lines):

diff --git a/pidgin_stats_collector/media/js/charts.js b/pidgin_stats_collector/media/js/charts.js
--- a/pidgin_stats_collector/media/js/charts.js
+++ b/pidgin_stats_collector/media/js/charts.js
@@ -1,3 +1,8 @@
+function roundNumber(num, dec) {
+    var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
+    return result;
+}
+
 function drawPie(dat, e, ttle){
     var chart;
     $(document).ready(function() {
@@ -13,7 +18,7 @@ function drawPie(dat, e, ttle){
             },
             tooltip: {
                 formatter: function() {
-                    return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
+                    return '<b>'+ this.point.name +'</b>: '+ roundNumber(this.percentage, 2) +' %';
                 }
             },
             plotOptions: {
@@ -25,7 +30,7 @@ function drawPie(dat, e, ttle){
                         color: '#000000',
                         connectorColor: '#000000',
                         formatter: function() {
-                            return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
+                            return '<b>'+ this.point.name +'</b>: '+ roundNumber(this.percentage, 2) +' %';
                         }
                     }
                 }
@@ -112,7 +117,7 @@ function drawChart(cat, dat, e, title)
                         fontWeight: 'bold'
                     },
                     formatter: function() {
-                        return this.y;
+                        return roundNumber(this.y, 2);
                     }
                 }
             }
@@ -120,7 +125,7 @@ function drawChart(cat, dat, e, title)
         tooltip: {
             formatter: function() {
                 var point = this.point,
-                    s = this.x +':<b>'+ this.y + '</b><br/>';
+                    s = this.x +':<b>'+ roundNumber(this.y, 2) + '</b><br/>';
                 if (point.drilldown) {
                     s += 'Click to view more';
                 } else if(chart.drilled) {



More information about the Commits mailing list