← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6867: (DV plugin) Destroy chart function added + Series style updated + Series order bug fixed.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 6867 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-05-06 01:24:59 +0000
message:
  (DV plugin) Destroy chart function added + Series style updated + Series order bug fixed.
modified:
  dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/GetAggregatedValuesPluginAction.java
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/index.html
  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/jsonminAggregatedValuesPlugin.vm


--
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/java/org/hisp/dhis/visualizer/action/GetAggregatedValuesPluginAction.java'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/GetAggregatedValuesPluginAction.java	2012-04-06 14:30:50 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/GetAggregatedValuesPluginAction.java	2012-05-06 01:10:33 +0000
@@ -30,6 +30,7 @@
 import static org.hisp.dhis.api.utils.ContextUtils.CONTENT_TYPE_JSON;
 import static org.hisp.dhis.system.util.ConversionUtils.getIdentifiers;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
@@ -227,7 +228,21 @@
     {
         return periods;
     }
-
+    
+    private Collection<String> dataNames = new ArrayList<String>();
+
+    public Collection<String> getDataNames()
+    {
+        return dataNames;
+    }
+    
+    private Collection<String> organisationUnitNames = new ArrayList<String>();
+
+    public Collection<String> getOrganisationUnitNames()
+    {
+        return organisationUnitNames;
+    }
+    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -264,6 +279,11 @@
 
             Set<OrganisationUnit> organisationUnits = organisationUnitService
                 .getOrganisationUnitsByUid( organisationUnitIds );
+            
+            for ( String id : organisationUnitIds )
+            {
+                organisationUnitNames.add( organisationUnitService.getOrganisationUnit( id ).getName() );
+            }
 
             if ( indicatorIds != null )
             {
@@ -280,6 +300,11 @@
                     value.setOrganisationUnitName( organisationUnitService.getOrganisationUnit(
                         value.getOrganisationUnitId() ).getName() );
                 }
+                
+                for ( String id : indicatorIds )
+                {
+                    dataNames.add( indicatorService.getIndicator( id ).getDisplayShortName() );
+                }
             }
 
             if ( dataElementIds != null )
@@ -297,6 +322,11 @@
                     value.setOrganisationUnitName( organisationUnitService.getOrganisationUnit(
                         value.getOrganisationUnitId() ).getName() );
                 }
+                
+                for ( String id : dataElementIds )
+                {
+                    dataNames.add( dataElementService.getDataElement( id ).getDisplayShortName() );
+                }
             }
         }
 

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/index.html'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/index.html	2012-04-27 12:10:44 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/index.html	2012-05-06 01:10:33 +0000
@@ -1,7 +1,7 @@
 <html>
 <head>
-    <link rel="stylesheet" type="text/css" href="http://extjs-public.googlecode.com/svn/tags/extjs-4.0.7/release/resources/css/ext-all-gray.css"; />
-    <script type="text/javascript" src="http://extjs-public.googlecode.com/svn/tags/extjs-4.0.7/release/ext-all.js";></script>
+    <link rel="stylesheet" type="text/css" href="../../../dhis-web-commons/javascripts/ext/resources/css/ext-all-gray.css" />
+    <script type="text/javascript" src="../../../dhis-web-commons/javascripts/ext/ext-all.js"></script>
     <script type="text/javascript" src="plugin.js"></script>
     
     <style>
@@ -47,11 +47,11 @@
 			var url = '../../../'; // http://apps.dhis2.org/dev/
 		
 			DHIS.getChart({
-				uid: 'gnymLKrv6l8',
+				uid: 'EbRN2VIbPdV',
 				el: 'chart1',
 				url: url
 			});
-						
+			
 			DHIS.getChart({
 				type: 'stackedcolumn',
 				indicators: ['Uvn6LCg7dVU', 'OdiHJayrsKo'],

=== 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	2012-04-26 22:55:53 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/plugin.js	2012-05-06 01:10:33 +0000
@@ -54,9 +54,10 @@
         DHIS.store.pie = DHIS.store.defaultChartStore;
         
         DHIS.getChart = DHIS.exe.addToQueue;
+        DHIS.destroyChart = DHIS.exe.destroy;
     };
     
-    DHIS.projects = [];
+    DHIS.projects = {};
     
     DHIS.util = {
         dimension: {
@@ -161,7 +162,7 @@
                     trackMouse: true,
                     style: 'border-width:2px; background-color:#eee',
                     renderer: function(r, item) {
-						this.update('<span style="font-size:22px">' + item.value[1] + '</span>');
+						this.update('<span style="font-size:21px">' + '' + item.value[1] + '</span>');
                     }
                 };
             },
@@ -204,6 +205,10 @@
                             axis: 'left',
                             xField: project.store.bottom,
                             yField: project.store.left[i],
+							style: {
+								opacity: 0.8,
+								lineWidth: 3
+							},
 							tips: DHIS.util.chart.getTips()
                         });
                     }
@@ -282,7 +287,9 @@
             jsonfy: function(r) {                
                 var object = {
                     values: [],
-                    periods: r.p
+                    periods: r.p,
+                    datanames: [],
+                    organisationunitnames: []
                 };
                 for (var i = 0; i < r.v.length; i++) {
                     var obj = {};
@@ -292,6 +299,12 @@
                     obj[DHIS.conf.finals.dimension.organisationunit.value] = r.v[i][3];
                     object.values.push(obj);
                 }
+                for (var j = 0; j < r.d.length; j++) {
+					object.datanames.push(DHIS.util.string.getEncodedString(r.d[j]));
+				}
+                for (var k = 0; k < r.o.length; k++) {
+					object.organisationunitnames.push(DHIS.util.string.getEncodedString(r.o[k]));
+				}
                 return object;
             }
         }
@@ -303,9 +316,11 @@
         },
         defaultChartStore: function(project) {
             var keys = [];
+            
             Ext.Array.each(project.data, function(item) {
                 keys = Ext.Array.merge(keys, Ext.Object.getKeys(item));
             });
+            
             project.store = Ext.create('Ext.data.Store', {
                 fields: keys,
                 data: project.data
@@ -375,6 +390,10 @@
             project.state.conf.category = project.state.conf.category.toLowerCase();
             project.state.conf.filter = project.state.conf.filter.toLowerCase();
             
+            project.state.conf[project.state.conf.series] = DHIS.conf.finals.chart.series;
+            project.state.conf[project.state.conf.category] = DHIS.conf.finals.chart.category;
+            project.state.conf[project.state.conf.filter] = DHIS.conf.finals.chart.filter;
+            
             project.state.type = project.state.conf.type;
             project.state.series.dimension = project.state.conf.series;
             project.state.category.dimension = project.state.conf.category;
@@ -414,7 +433,8 @@
                     }
                 });
             }
-        }
+        },
+        storage: {}
     };
     
     DHIS.value = {
@@ -445,12 +465,12 @@
                         project.values[i][DHIS.conf.finals.dimension.data.value] = DHIS.util.string.getEncodedString(project.values[i][DHIS.conf.finals.dimension.data.value]);
                         project.values[i][DHIS.conf.finals.dimension.period.value] = DHIS.util.string.getEncodedString(project.values[i][DHIS.conf.finals.dimension.period.value]);
                         project.values[i][DHIS.conf.finals.dimension.organisationunit.value] = DHIS.util.string.getEncodedString(project.values[i][DHIS.conf.finals.dimension.organisationunit.value]);
-                    }                        
+                    }
                     
-                    Ext.Array.each(project.values, function(item) {
-                        Ext.Array.include(project.state.series.names, DHIS.util.string.getEncodedString(item[project.state.series.dimension]));
-                        Ext.Array.include(project.state.category.names, DHIS.util.string.getEncodedString(item[project.state.category.dimension]));
-                        Ext.Array.include(project.state.filter.names, DHIS.util.string.getEncodedString(item[project.state.filter.dimension]));
+                    project.state[project.state.conf.data].names = json.datanames;
+                    project.state[project.state.conf.organisationunit].names = json.organisationunitnames;
+                    Ext.Array.each(project.values, function(item) {						
+                        Ext.Array.include(project.state[project.state.conf.period].names, DHIS.util.string.getEncodedString(item[project.state[project.state.conf.period].dimension]));
                         item.v = parseFloat(item.v);
                     });
                     
@@ -503,7 +523,7 @@
             this[project.state.type](project);
             DHIS.exe.execute();
         },
-        column: function(project, isStacked) {
+        column: function(project, isStacked) {			
             project.chart = Ext.create('Ext.chart.Chart', {
 				renderTo: project.state.conf.el,
                 width: project.state.conf.width || this.el.getWidth(),
@@ -537,15 +557,16 @@
                         xField: project.store.bottom,
                         yField: project.store.left,
                         stacked: isStacked,
-                        style: {
-                            opacity: 0.8
-                        },
+						style: {
+							opacity: 0.8,
+							stroke: '#333'
+						},
 						tips: DHIS.util.chart.getTips()
                     }
                 ]
             });
             
-            DHIS.projects.push(project);
+            DHIS.projects[project.state.conf.el] = project;
         },
         stackedcolumn: function(project) {
             this.column(project, true);
@@ -584,15 +605,16 @@
                         xField: project.store.left,
                         yField: project.store.bottom,
                         stacked: isStacked,
-                        style: {
-                            opacity: 0.8
-                        },
+						style: {
+							opacity: 0.8,
+							stroke: '#333'
+						},
 						tips: DHIS.util.chart.getTips()
                     }
                 ]
             });
             
-            DHIS.projects.push(project);
+            DHIS.projects[project.state.conf.el] = project;
         },
         stackedbar: function(project) {
             this.bar(project, true);
@@ -627,7 +649,7 @@
                 series: DHIS.util.chart.line.getSeriesArray(project)
             });
             
-            DHIS.projects.push(project);
+            DHIS.projects[project.state.conf.el] = project;
         },
         area: function(project) {
             project.chart = Ext.create('Ext.chart.Chart', {
@@ -661,13 +683,14 @@
                     axis: 'left',
                     xField: project.store.bottom[0],
                     yField: project.store.left,
-                    style: {
-                        opacity: 0.65
-                    }
+					style: {
+						opacity: 0.65,
+						stroke: '#555'
+					}
                 }]
             });
             
-            DHIS.projects.push(project);
+            DHIS.projects[project.state.conf.el] = project;
         },
         pie: function(project) {
             project.chart = Ext.create('Ext.chart.Chart', {
@@ -693,13 +716,14 @@
                         }
                     },
                     style: {
-                        opacity: 0.9
+                        opacity: 0.9,
+						stroke: '#555'
                     },
                     tips: DHIS.util.chart.pie.getTips(project.store.left[0])
                 }]
             });
             
-            DHIS.projects.push(project);
+            DHIS.projects[project.state.conf.el] = project;
         }
     };
     
@@ -707,7 +731,7 @@
         allow: true,
         queue: [],
         addToQueue: function(conf) {
-            DHIS.exe.queue.push(conf);            
+            DHIS.exe.queue.push(conf);
             if (DHIS.exe.allow) {
                 DHIS.exe.allow = false;
                 DHIS.exe.execute();
@@ -716,6 +740,7 @@
         execute: function() {
             if (this.queue.length) {
                 var conf = this.queue.shift();
+                this.destroy(conf.el);
                 if (conf.uid) {
                     DHIS.state.setState(conf);
                 }
@@ -723,6 +748,14 @@
                     DHIS.state.getState(conf);
                 }
             }
+            else {
+				DHIS.exe.allow = true;
+			}
+		},
+		destroy: function(el) {
+			if (DHIS.projects[el]) {
+				DHIS.projects[el].chart.destroy();
+			}
 		}
     };
     

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/jsonminAggregatedValuesPlugin.vm'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/jsonminAggregatedValuesPlugin.vm	2012-03-27 15:30:24 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/jsonminAggregatedValuesPlugin.vm	2012-05-06 01:10:33 +0000
@@ -1,2 +1,2 @@
-#set( $indicatorSize = $indicatorValues.size() )#set( $dataSize = $dataValues.size() )#set( $periodSize = $periods.size() )
-${callback}({"v":[#if( $indicatorSize > 0 )#foreach( $iv in $indicatorValues )["$!{iv.value}","$!{iv.indicatorName}","$!{iv.periodName}","$!{iv.organisationUnitName}"]#if( $velocityCount < $indicatorSize ),#end#end#end#if( $dataSize > 0 )#if( $indicatorSize > 0 ),#end#foreach( $dv in $dataValues )["$!{dv.value}","$!{dv.dataElementName}","$!{dv.periodName}","$!{dv.organisationUnitName}"]#if( $velocityCount < $dataSize ),#end#end#end],"p":[#foreach($p in $periods)"$!encoder.jsonEncode(${p.name})"#if($velocityCount<$periodSize),#end#end]})
\ No newline at end of file
+#set( $indicatorSize = $indicatorValues.size() )#set( $dataSize = $dataValues.size() )#set( $periodSize = $periods.size() )#set( $dataNamesSize = $dataNames.size() )#set( $organisationUnitNamesSize = $organisationUnitNames.size() )
+${callback}({"v":[#if( $indicatorSize > 0 )#foreach( $iv in $indicatorValues )["$!{iv.value}","$!{iv.indicatorName}","$!{iv.periodName}","$!{iv.organisationUnitName}"]#if( $velocityCount < $indicatorSize ),#end#end#end#if( $dataSize > 0 )#if( $indicatorSize > 0 ),#end#foreach( $dv in $dataValues )["$!{dv.value}","$!{dv.dataElementName}","$!{dv.periodName}","$!{dv.organisationUnitName}"]#if( $velocityCount < $dataSize ),#end#end#end],"p":[#foreach($p in $periods)"$!encoder.jsonEncode(${p.name})"#if($velocityCount<$periodSize),#end#end],"d":[#foreach($dn in $dataNames)"$!encoder.jsonEncode(${dn})"#if($velocityCount<$dataNamesSize),#end#end],"o":[#foreach($oun in $organisationUnitNames)"$!encoder.jsonEncode(${oun})"#if($velocityCount<$organisationUnitNamesSize),#end#end]})
\ No newline at end of file