← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4984: (DV) Numeric chart axis label improved.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 4984 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-10-20 11:54:31 +0200
message:
  (DV) Numeric chart axis label improved.
modified:
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js	2011-10-19 07:56:57 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js	2011-10-19 14:19:45 +0000
@@ -390,7 +390,28 @@
                     });
                 }
             }
-        }               
+        },
+        number: {
+            isInteger: function(n) {
+                var str = new String(n);
+                if (str.indexOf('.') > -1) {
+                    var d = str.substr(str.indexOf('.') + 1);
+                    return (d.length === 1 && d == '0');
+                }
+                return false;
+            },
+            allValuesAreIntegers: function(values) {
+                for (var i = 0; i < values.length; i++) {
+                    if (!this.isInteger(values[i].v)) {
+                        return false;
+                    }
+                }
+                return true;
+            },
+            getChartAxisFormatRenderer: function() {
+                return this.allValuesAreIntegers(DV.value.values) ? '0' : '0.0';
+            }
+        }
     };
     
     DV.store = {
@@ -577,7 +598,7 @@
     };
     
     DV.value = {
-        values: null,        
+        values: [],
         getValues: function(exe) {
             var params = [],
                 indicator = DV.conf.finals.dimension.indicator.value,
@@ -605,7 +626,7 @@
                     if (!DV.value.values.length) {
                         alert('no data values');
                         return;
-                    }
+                    }              
                     
                     Ext.Array.each(DV.value.values, function(item) {
                         item[indiment] = DV.store[indiment].available.storage[item.i].name;
@@ -686,11 +707,11 @@
                         position: 'left',
                         minimum: 0,
                         fields: DV.store.chart.left,
-                        label: {
-                            renderer: Ext.util.Format.numberRenderer('0,0')
-                        },
                         grid: {
                             even: DV.util.chart.getGrid()
+                        },
+                        label: {
+                            renderer: Ext.util.Format.numberRenderer(DV.util.number.getChartAxisFormatRenderer())
                         }
                     },
                     {
@@ -738,7 +759,7 @@
                         minimum: 0,
                         fields: DV.store.chart.bottom,
                         label: {
-                            renderer: Ext.util.Format.numberRenderer('0,0')
+                            renderer: Ext.util.Format.numberRenderer(DV.util.number.getChartAxisFormatRenderer())
                         },
                         grid: {
                             even: DV.util.chart.getGrid()
@@ -777,7 +798,7 @@
                         minimum: 0,
                         fields: DV.store.chart.left,
                         label: {
-                            renderer: Ext.util.Format.numberRenderer('0,0')
+                            renderer: Ext.util.Format.numberRenderer(DV.util.number.getChartAxisFormatRenderer())
                         },
                         grid: {
                             even: DV.util.chart.getGrid()
@@ -808,7 +829,7 @@
                         minimum: 0,
                         fields: DV.store.chart.left,
                         label: {
-                            renderer: Ext.util.Format.numberRenderer('0,0')
+                            renderer: Ext.util.Format.numberRenderer(DV.util.number.getChartAxisFormatRenderer())
                         },
                         grid: {
                             even: DV.util.chart.getGrid()