Merge authors:
  Jan Henrik Ă˜verland (janhenrik-overland)
------------------------------------------------------------
revno: 5365 [merge]
committer: Jan Henrik Overland <janhenrik.overl...@gmail.com>
branch nick: dhis2
timestamp: Mon 2011-12-12 11:38:34 +0100
message:
  (GIS) Stored zeros shown on the map, false zeros filtered out = Automatic 
legend makes more sense. + Data element list sorted. + Zoom level not reset 
when applying labels.
modified:
  
dhis-2/dhis-web/dhis-web-mapping/src/main/resources/org/hisp/dhis/mapping/i18n_module.properties
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/i18n.vm
  
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js
  
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js
  
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js
  
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Centroid.js
  
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js
  
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Point.js
  
dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/css/plugin.css
  
dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/plugin.html
  
dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/plugin.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-mapping/src/main/resources/org/hisp/dhis/mapping/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/resources/org/hisp/dhis/mapping/i18n_module.properties	2011-08-11 20:49:21 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/resources/org/hisp/dhis/mapping/i18n_module.properties	2011-12-09 15:26:08 +0000
@@ -20,6 +20,7 @@
 applied								= applied
 show								= Show
 hide								= Hide
+showhide							= Show / hide
 toggle								= Toggle
 
 boundary							= Boundary

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/i18n.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/i18n.vm	2011-08-11 20:49:21 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/i18n.vm	2011-12-09 15:26:08 +0000
@@ -23,6 +23,7 @@
     applied: '$encoder.jsEscape($i18n.getString( 'applied' ) , "'")',
     show: '$encoder.jsEscape($i18n.getString( 'show' ) , "'")',
     hide: '$encoder.jsEscape($i18n.getString( 'hide' ) , "'")',
+    showhide: '$encoder.jsEscape($i18n.getString( 'showhide' ) , "'")',
     toggle: '$encoder.jsEscape($i18n.getString( 'toggle' ) , "'")',
 
     boundary: '$encoder.jsEscape($i18n.getString( 'boundary' ) , "'")',

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js	2011-12-06 17:41:41 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js	2011-12-09 14:32:33 +0000
@@ -280,7 +280,8 @@
                 else {
                     activateLabels.call(this);
                 }
-            
+                
+                G.vars.lockPosition = true;
                 widget.applyValues();
             }
         },
@@ -1091,7 +1092,7 @@
                                                         xtype: 'button',
                                                         iconCls: 'icon-assign',
                                                         hideLabel: true,
-                                                        text: G.i18n.toggle,
+                                                        text: G.i18n.showhide,
                                                         scope: this,
                                                         handler: function() {
                                                             if (layer.features.length) {

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js	2011-12-06 17:41:41 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js	2011-12-12 10:31:20 +0000
@@ -62,6 +62,7 @@
         url: G.conf.path_mapping + 'getAllIndicators' + G.conf.type,
         root: 'indicators',
         fields: ['id', 'shortName'],
+        sortInfo: {field: 'shortName', direction: 'ASC'},
         autoLoad: false,
         isLoaded: false,
         listeners: {
@@ -85,6 +86,7 @@
         url: G.conf.path_mapping + 'getAllDataElements' + G.conf.type,
         root: 'dataElements',
         fields: ['id', 'shortName'],
+        sortInfo: {field: 'shortName', direction: 'ASC'},
         autoLoad: false,
         isLoaded: false,
         listeners: {
@@ -1328,7 +1330,7 @@
                                 displayField: 'shortName',
                                 width:G.conf.multiselect_width,
                                 height: G.util.getMultiSelectHeight(),
-                                store:G.stores.indicator
+                                store: G.stores.indicator
                             }
                         ]
                     }

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js	2011-12-05 16:53:11 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js	2011-12-09 14:32:33 +0000
@@ -98,6 +98,7 @@
         this.layer.removeFeatures(this.layer.features);
         this.layer.addFeatures(format.read(doc));
 		this.layer.features = G.util.getTransformedFeatureArray(this.layer.features);
+        G.vars.activeWidget.featureStorage = this.layer.features.slice(0);
         this.requestSuccess(request);
         
         G.vars.activeWidget.classify();
@@ -109,6 +110,10 @@
             doc = request.responseText;
         }
         
+        if (doc.length && G.vars.activeWidget != symbol) {
+            doc = G.util.geoJsonDecode(doc);
+        }
+        
         var format = this.format || new OpenLayers.Format.GeoJSON();
         this.layer.removeFeatures(this.layer.features);
         
@@ -118,6 +123,7 @@
 		}
 		
         this.layer.addFeatures(geo);
+        G.vars.activeWidget.featureStorage = this.layer.features.slice(0);
         this.requestSuccess(request);
   
 		if (!G.vars.activeWidget.formValidation.validateForm.call(G.vars.activeWidget)) {

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Centroid.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Centroid.js	2011-12-05 17:37:00 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Centroid.js	2011-12-09 14:32:33 +0000
@@ -84,6 +84,8 @@
     
     requireUpdate: false,
     
+    featureStorage: [],
+    
     filtering: {
         cache: [],
         options: {
@@ -1023,10 +1025,12 @@
         G.vars.activeWidget = this;
         this.updateValues = true;
         
-        this.setUrl(G.conf.path_mapping + 'getGeoJson.action?' +
-            'parentId=' + this.organisationUnitSelection.parent.id +
-            '&level=' + this.organisationUnitSelection.level.level
-        );
+        var url = G.conf.path_mapping + 'getGeoJsonWithValues.action?' + 
+            'periodId=' + this.cmp.period.getValue() +
+            '&parentId=' + this.organisationUnitSelection.parent.id +
+            '&level=' + this.organisationUnitSelection.level.level;            
+        url += this.valueType.isIndicator() ? '&indicatorId=' + this.cmp.indicator.getValue() : '&dataElementId=' + this.cmp.dataElement.getValue();
+        this.setUrl(url);
     },
 
     classify: function(exception, lockPosition) {
@@ -1060,14 +1064,8 @@
                     params: params,
                     scope: this,
                     success: function(r) {
-alert(r);                        
                         var mapvalues = G.util.mapValueDecode(r);
-                        
-                        if (!this.layer.features.length) {
-                            Ext.message.msg(false, 'No coordinates found');
-                            G.vars.mask.hide();
-                            return;
-                        }
+                        this.layer.features = this.featureStorage.slice(0);
                         
                         if (mapvalues.length === 0) {
                             Ext.message.msg(false, G.i18n.current_selection_no_data);
@@ -1075,20 +1073,13 @@
                             return;
                         }
                         
-                        for (var j = 0; j < this.layer.features.length; j++) {
-                            for (var i = 0; i < mapvalues.length; i++) {
-                                if (this.layer.features[j].attributes.id == mapvalues[i].oi) {
-                                    this.layer.features[j].attributes.value = parseFloat(mapvalues[i].v);
-                                    this.layer.features[j].attributes.labelString = this.layer.features[j].attributes.name + ' (' + this.layer.features[j].attributes.value + ')';
-                                    this.layer.features[j].attributes.fixedName = G.util.cutString(this.layer.features[j].attributes.name, 30);
+                        for (var i = 0; i < this.layer.features.length; i++) {
+                            for (var j = 0; j < mapvalues.length; j++) {
+                                if (this.layer.features[i].attributes.id == mapvalues[j].oi) {
+                                    this.layer.features[i].attributes.value = parseFloat(mapvalues[j].v);
                                     break;
                                 }
                             }
-                            if (!this.layer.features[j].attributes.value) {
-                                this.layer.features[j].attributes.value = 0;
-                                this.layer.features[j].attributes.labelString = this.layer.features[j].attributes.name + ' (0)';
-                                this.layer.features[j].attributes.fixedName = G.util.cutString(this.layer.features[j].attributes.name, 30);
-                            }
                         }
                         
                         this.updateValues = false;
@@ -1103,6 +1094,18 @@
     },
 
     applyValues: function() {
+        for (var i = 0; i < this.layer.features.length; i++) {
+            var f = this.layer.features[i];
+            if (!f.attributes.value) {
+                this.layer.features.splice(i,1);
+                i--;
+            }
+            else {
+                f.attributes.labelString = f.attributes.name + ' (' + f.attributes.value + ')';
+                f.attributes.fixedName = G.util.cutString(f.attributes.name, 30);
+            }
+        }
+        
 		var options = {
             indicator: 'value',
             method: G.conf.classify_by_equal_intervals

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2011-12-05 17:37:00 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2011-12-12 10:31:20 +0000
@@ -84,6 +84,8 @@
     
     requireUpdate: false,
     
+    featureStorage: [],
+    
     filtering: {
         cache: [],
         options: {
@@ -1693,12 +1695,7 @@
                     scope: this,
                     success: function(r) {
                         var mapvalues = G.util.mapValueDecode(r);
-                        
-                        if (!this.layer.features.length) {
-                            Ext.message.msg(false, 'No coordinates found');
-                            G.vars.mask.hide();
-                            return;
-                        }
+                        this.layer.features = this.featureStorage.slice(0);
                         
                         if (mapvalues.length === 0) {
                             Ext.message.msg(false, G.i18n.current_selection_no_data);
@@ -1706,16 +1703,13 @@
                             return;
                         }
                         
-                        for (var j = 0; j < this.layer.features.length; j++) {
-                            for (var i = 0; i < mapvalues.length; i++) {
-                                if (this.layer.features[j].attributes.id == mapvalues[i].oi) {
-                                    this.layer.features[j].attributes.value = parseFloat(mapvalues[i].v);
+                        for (var i = 0; i < this.layer.features.length; i++) {
+                            for (var j = 0; j < mapvalues.length; j++) {
+                                if (this.layer.features[i].attributes.id == mapvalues[j].oi) {
+                                    this.layer.features[i].attributes.value = parseFloat(mapvalues[j].v);
                                     break;
                                 }
                             }
-                            if (!this.layer.features[j].attributes.value) {
-                                this.layer.features[j].attributes.value = 0;
-                            }
                         }
                         
                         this.updateValues = false;
@@ -1730,10 +1724,16 @@
     },
     
     applyValues: function() {
-        for (var i = 0, f; i < this.layer.features.length; i++) {
-            f = this.layer.features[i];
-            f.attributes.labelString = f.attributes.name + ' (' + f.attributes.value + ')';
-            f.attributes.fixedName = G.util.cutString(f.attributes.name, 30);
+        for (var i = 0; i < this.layer.features.length; i++) {
+            var f = this.layer.features[i];            
+            if (!f.attributes.value) {
+                this.layer.features.splice(i,1);
+                i--;
+            }
+            else {
+                f.attributes.labelString = f.attributes.name + ' (' + f.attributes.value + ')';
+                f.attributes.fixedName = G.util.cutString(f.attributes.name, 30);
+            }
         }
         
         this.button.menu.find('name','history')[0].addItem(this);

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Point.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Point.js	2011-12-05 17:37:00 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Point.js	2011-12-09 14:32:33 +0000
@@ -84,6 +84,8 @@
     
     requireUpdate: false,
     
+    featureStorage: [],
+    
     filtering: {
         cache: [],
         options: {
@@ -1693,12 +1695,7 @@
                     scope: this,
                     success: function(r) {
                         var mapvalues = G.util.mapValueDecode(r);
-                        
-                        if (!this.layer.features.length) {
-                            Ext.message.msg(false, 'No coordinates found');
-                            G.vars.mask.hide();
-                            return;
-                        }
+                        this.layer.features = this.featureStorage.slice(0);
                         
                         if (mapvalues.length === 0) {
                             Ext.message.msg(false, G.i18n.current_selection_no_data);
@@ -1706,16 +1703,13 @@
                             return;
                         }
                         
-                        for (var j = 0; j < this.layer.features.length; j++) {
-                            for (var i = 0; i < mapvalues.length; i++) {
-                                if (this.layer.features[j].attributes.id == mapvalues[i].oi) {
-                                    this.layer.features[j].attributes.value = parseFloat(mapvalues[i].v);
+                        for (var i = 0; i < this.layer.features.length; i++) {
+                            for (var j = 0; j < mapvalues.length; j++) {
+                                if (this.layer.features[i].attributes.id == mapvalues[j].oi) {
+                                    this.layer.features[i].attributes.value = parseFloat(mapvalues[j].v);
                                     break;
                                 }
                             }
-                            if (!this.layer.features[j].attributes.value) {
-                                this.layer.features[j].attributes.value = 0;
-                            }
                         }
                         
                         this.updateValues = false;
@@ -1728,12 +1722,18 @@
             }
         }
     },
-
+    
     applyValues: function() {
-        for (var i = 0, f; i < this.layer.features.length; i++) {
-            f = this.layer.features[i];
-            f.attributes.labelString = f.attributes.name + ' (' + f.attributes.value + ')';
-            f.attributes.fixedName = G.util.cutString(f.attributes.name, 30);
+        for (var i = 0; i < this.layer.features.length; i++) {
+            var f = this.layer.features[i];
+            if (!f.attributes.value) {
+                this.layer.features.splice(i,1);
+                i--;
+            }
+            else {
+                f.attributes.labelString = f.attributes.name + ' (' + f.attributes.value + ')';
+                f.attributes.fixedName = G.util.cutString(f.attributes.name, 30);
+            }
         }
 
         this.button.menu.find('name','history')[0].addItem(this);

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/css/plugin.css'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/css/plugin.css	2011-12-07 17:05:24 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/css/plugin.css	2011-12-12 10:31:20 +0000
@@ -8,16 +8,16 @@
 }
 
 #chart1 {
-	width: 1000px;
-	height: 600px;
+	width: 600px;
+	height: 400px;
 	border: 2px solid #ddd;
     margin-bottom: 100px;
 }
 
 #chart2 {
-	width: 600px;
+	width: 1400px;
 	height: 400px;
-	border: 2px solid #ddd;
+	border: 2px solid #ccc;
     margin-bottom: 100px;
 }
 
@@ -28,27 +28,3 @@
 	border: 2px solid #ccc;
     margin-bottom: 100px;
 }
-
-/* Tooltip */
-.x-tip {
-    -moz-border-radius: 2px 2px 2px 2px;
-    -webkit-border-radius: 2px 2px 2px 2px;
-    -o-border-radius: 2px 2px 2px 2px;
-    -ms-border-radius: 2px 2px 2px 2px;
-    -khtml-border-radius: 2px 2px 2px 2px;
-    border-radius: 2px 2px 2px 2px;
-    padding: 2px 5px 2px 0;
-    border-width: 2px;
-    border-style: solid;
-    background-color: #eee;
-}
-
-/* Chart tips (tooltip) */
-.x-tip .x-tip-header .x-box-item {
-    text-align: center;
-}
-
-.dv-chart-tips {
-    font: normal 13px arial, ubuntu;
-    padding: 0 0 3px 3px;
-}

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/plugin.html'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/plugin.html	2011-12-07 17:05:24 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/plugin.html	2011-12-12 10:31:20 +0000
@@ -7,36 +7,15 @@
     <link rel="stylesheet" type="text/css" href="../css/plugin.css" />
 </head>
 
-<body>	
+<body>
+	
 	<h1>My chart 1</h1>
 	<div id="chart1"></div>
-    
-	<h1>My chart 2</h1>
-	<div id="chart2"></div>
-    
-    <script>
+	
+	<script>
 		Ext.onReady( function() {
 			var url = 'http://localhost:8180/dhis/dhis-web-visualizer/app';
             
-            DHIS.getChart({
-                stacked: true,
-                indicators: [31664, 32414],
-				dataelements: [20911],
-				organisationunits: [18],
-				el: 'chart1',
-				url: url
-			});
-            
-			DHIS.getChart({
-                type: 'pie',
-                indicators: [31664],
-				dataelements: [20911],
-				organisationunits: [18],
-                legendPosition: 'right',
-				el: 'chart2',
-				url: url
-			});    
-            
 /*
 CONFIG              TYPE            DEFAULT             DESCRIPTION
     
@@ -52,10 +31,18 @@
 el                  string                              (Required) The element to render the chart.
 width               integer         <el width>          (Optional) Chart width. Default is the element width.
 height              integer         <el height>         (Optional) Chart height. Default is the element height.
-titlePosition       string          'top'               (Optional) Positions: 'top' or 'bottom'
 legendPosition      string          'top'               (Optional) Positions: 'top', 'right', 'bottom' or 'left'
 url                 string                              (Required) The web service url.
-*/	
+*/
+			
+			DHIS.getChart({
+                indicators: [31664],
+				dataelements: [20911],
+				organisationunits: [18],
+				el: 'chart1',
+				url: url
+			});
+	
 		});
 	</script>
 	

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/plugin.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/plugin.js	2011-12-07 17:05:24 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/plugin.js	2011-12-12 10:31:20 +0000
@@ -42,9 +42,6 @@
             area: 'area',
             pie: 'pie'
         }
-    },
-    chart: {
-        inset: 10
     }
 };
 
@@ -97,9 +94,10 @@
             }
         },
         chart: {
-            getLegend: function(pos) {
+            getLegend: function(len) {
+                len = len ? len : 1;
                 return {
-                    position: pos,
+                    position: len > 5 ? 'right' : 'top',
                     labelFont: '11px arial',
                     boxStroke: '#ffffff',
                     boxStrokeWidth: 0,
@@ -114,7 +112,7 @@
                     'stroke-width': 0.2
                 };
             },
-            getTitle: function(pos, size) {
+            getTitle: function() {
                 return {
                     type: 'text',
                     text: DHIS.state.state.filter.names[0],
@@ -122,8 +120,8 @@
                     fill: '#222',
                     width: 300,
                     height: 20,
-                    x: DHIS.util.chart.getTitlePosition(pos, size).x,
-                    y: DHIS.util.chart.getTitlePosition(pos, size).y
+                    x: 28,
+                    y: 16
                 };
             },
             getTips: function() {
@@ -134,20 +132,6 @@
                     }
                 };
             },
-            getSize: function(scope, project) {
-                return {
-                    width: project.state.conf.width || scope.el.getWidth(),
-                    height: project.state.conf.height || scope.el.getHeight()
-                };
-            },
-            getTitlePosition: function(pos, size) {
-                if (pos === 'bottom') {
-                    return {x:28, y:size.height-16};
-                }
-                else {
-                    return {x:28, y:16};
-                }                    
-            },
             setMask: function(str) {
                 if (DHIS.mask) {
                     DHIS.mask.hide();
@@ -217,13 +201,13 @@
                         }
                     ];                        
                 },
-                getTips: function(store) {
+                getTips: function() {
                     return {
                         trackMouse: true,
                         height: 47,
                         renderer: function(item) {
                             this.setWidth((item.data.x.length * 8) + 15);
-                            this.setTitle('<span class="dv-chart-tips">' + item.data.x + '<br/><b>' + item.data[store.left[0]] + '</b></span>');
+                            this.setTitle('<span class="dv-chart-tips">' + item.data.x + '<br/><b>' + item.data[DV.store.chart.left[0]] + '</b></span>');
                         }
                     };
                 }
@@ -265,8 +249,7 @@
             jsonfy: function(r) {
                 r = Ext.JSON.decode(r.responseText);
                 var values = [];
-                for (var i = 0; i < r.length; i++) {
-                    var obj = {};
+                for (var i = 0, obj = {}; i < r.length; i++) {
                     obj.v = r[i][0];
                     obj[DHIS.conf.finals.dimension.data.value] = r[i][1];
                     obj[DHIS.conf.finals.dimension.period.value] = r[i][2];
@@ -346,8 +329,7 @@
                 category: 'period',
                 filter: 'organisationunit',
                 el: '',
-                titlePosition: 'top',
-                legendPosition: 'top',
+                legendPosition: false,
                 url: ''
             };
             
@@ -393,7 +375,8 @@
                         item.v = parseFloat(item.v);
                     });
                     
-                    DHIS.state.state = project.state;                    
+                    DHIS.state.state = project.state;
+                    
 					DHIS.chart.getData(project);
                 }
             });
@@ -432,13 +415,12 @@
         column: function(project) {
             project.chart = Ext.create('Ext.chart.Chart', {
 				renderTo: project.state.conf.el,
-                width: DHIS.util.chart.getSize(this, project).width,
-                height: DHIS.util.chart.getSize(this, project).height,
+                width: project.state.conf.width || this.el.getWidth(),
+                height: project.state.conf.height || this.el.getHeight(),
                 animate: true,
                 store: project.store,
-                insetPadding: DHIS.conf.chart.inset,
-                items: DHIS.util.chart.getTitle(project.state.conf.titlePosition, DHIS.util.chart.getSize(this, project)),
-                legend: DHIS.util.chart.getLegend(project.state.conf.legendPosition),
+                items: DHIS.util.chart.getTitle(),
+                legend: DHIS.util.chart.getLegend(project.store.left.length),
                 axes: [
                     {
                         type: 'Numeric',
@@ -481,7 +463,7 @@
                 animate: true,
                 store: project.store,
                 items: DHIS.util.chart.getTitle(),
-                legend: DHIS.util.chart.getLegend(project.state.conf.legendPosition),
+                legend: DHIS.util.chart.getLegend(project.store.chart.bottom.length),
                 axes: [
                     {
                         type: 'Category',
@@ -524,7 +506,7 @@
                 animate: true,
                 store: project.store,
                 items: DHIS.util.chart.getTitle(),
-                legend: DHIS.util.chart.getLegend(project.state.conf.legendPosition),
+                legend: DHIS.util.chart.getLegend(project.store.chart.left.length),
                 axes: [
                     {
                         type: 'Numeric',
@@ -540,7 +522,7 @@
                         type: 'Category',
                         position: 'bottom',
                         fields: project.store.bottom,
-                        label: DHIS.util.chart.label.getCategoryLabel()
+                        label: DV.util.chart.label.getCategoryLabel()
                     }
                 ],
                 series: DHIS.util.chart.line.getSeriesArray(project)
@@ -556,7 +538,7 @@
                 animate: true,
                 store: project.store,
                 items: DHIS.util.chart.getTitle(),
-                legend: DHIS.util.chart.getLegend(project.state.conf.legendPosition),
+                legend: DHIS.util.chart.getLegend(project.store.chart.left.length),
                 axes: [
                     {
                         type: 'Numeric',
@@ -597,13 +579,13 @@
                 shadow: true,
                 store: project.store,
                 insetPadding: 60,
-                items: DHIS.util.chart.pie.getTitle(project.state.filter.names[0], project.store.left[0]),
-                legend: DHIS.util.chart.getLegend(project.state.conf.legendPosition),
+                items: DHIS.util.chart.pie.getTitle(project.state.state.filter.names[0], project.store.left[0]),
+                legend: DHIS.util.chart.getLegend(project.state.state.category.names.length),
                 series: [{
                     type: 'pie',
                     field: project.store.left[0],
                     showInLegend: true,
-                    tips: DHIS.util.chart.pie.getTips(project.store),
+                    tips: DHIS.util.chart.pie.getTips(),
                     label: {
                         field: project.store.bottom[0]
                     },

_______________________________________________
Mailing list: https://launchpad.net/~dhis2-devs
Post to     : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp

Reply via email to