← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2053: (GIS) Image legend fixed for point layer.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 2053 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: trunk
timestamp: Sat 2010-09-04 11:39:58 +0530
message:
  (GIS) Image legend fixed for point layer.
modified:
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat/Symbol.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.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/webapp/dhis-web-mapping/mapping/script/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-09-04 05:33:45 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-09-04 06:08:10 +0000
@@ -139,37 +139,21 @@
 function getExportDataValueJSON(mapvalues){var json='{';json+='"datavalues":';json+='[';mapvalues.sort(sortByValue);for(var i=0;i<mapvalues.length;i++){json+='{';json+='"organisation": "'+mapvalues[i].orgUnitId+'",';json+='"value": "'+mapvalues[i].value+'" ';json+=i<mapvalues.length-1?'},':'}'}json+=']';json+='}';return json}
 
 function getLegendsJSON(){
+    var widget = ACTIVEPANEL == thematicMap ? choropleth : proportionalSymbol;
     var json = '{';
 	json += '"legends":';
 	json += '[';
-	for(var i = 0; i < choropleth.imageLegend.length; i++) {
+	for(var i = 0; i < widget.imageLegend.length; i++) {
 		json += '{';
-		json += '"label": "' + choropleth.imageLegend[i].label + '",';
-		json += '"color": "' + choropleth.imageLegend[i].color + '" ';
-		json += i < choropleth.imageLegend.length-1 ? '},' : '}';
+		json += '"label": "' + widget.imageLegend[i].label + '",';
+		json += '"color": "' + widget.imageLegend[i].color + '" ';
+		json += i < widget.imageLegend.length-1 ? '},' : '}';
 	}
 	json += ']';
 	json += '}';
 	return json;
 }
 
-function getSvgDivId(svgChildren) {
-	var svgNode;
-	var svgDivId;
-
-	for (i=0; i<svgChildren.length; i++) {
-		svgNode = svgChildren[i];
-		svgDivId = svgNode.getAttribute('id');		
-
-		while (svgNode.hasChildNodes()) {
-			svgNode = svgNode.firstChild;
-			if ( svgNode.nodeName && svgNode.nodeName == 'path' ) {
-				return svgDivId;
-			}
-		}
-	}
-}
-
 Ext.onReady( function() {
     Ext.BLANK_IMAGE_URL = '../resources/ext/resources/images/default/s.gif';
 	/* Cookie provider */
@@ -628,10 +612,17 @@
 
                     if (vcb && dcb && mcb && lcb) {
                     	var svgChildren = document.getElementById('_OpenLayers_Container').childNodes;
-						var svgDivId = getSvgDivId(svgChildren);
+						var svgDivId = null;
+
+						for (i = 0; i < svgChildren.length; i++) { // Search for div containing SVG
+							svgDivId = svgChildren[i].getAttribute('id');
+							if (svgDivId && svgDivId.indexOf('OpenLayers.Layer.Vector_') != -1) {
+								break;
+							}
+						}
 
 						var svg = document.getElementById(svgDivId).innerHTML;
-						var objectSVGDocument = document.getElementById(svgDivId).firstChild;
+						var objectSVGDocument = document.getElementById(svgDivId).childNodes[0];
 						
                         var viewBox = objectSVGDocument.getAttribute('viewBox');
                         var title = Ext.getCmp('exportimagetitle_tf').getValue();

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat/Symbol.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat/Symbol.js	2010-09-03 14:54:54 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat/Symbol.js	2010-09-04 06:08:10 +0000
@@ -117,7 +117,8 @@
     createColorInterpolation: function() {
         var initialColors = this.colors;
         var numColors = this.classification.bins.length;
-		var mapLegendType = ACTIVEPANEL == organisationUnitAssignment ? map_legend_type_automatic : Ext.getCmp('maplegendtype_cb2').getValue();
+		var mapLegendType = ACTIVEPANEL == organisationUnitAssignment ?
+            map_legend_type_automatic : Ext.getCmp('maplegendtype_cb2').getValue();
 		
 		if (mapLegendType == map_legend_type_automatic) {
 			this.colorInterpolation = proportionalSymbol.colorInterpolation = mapfish.ColorRgb.getColorsArrayByRgbInterpolation(initialColors[0], initialColors[1], numColors);

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js	2010-09-03 12:59:16 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js	2010-09-04 06:08:10 +0000
@@ -171,7 +171,7 @@
 		});
 	},
     
-    validateForm: function() {
+    validateForm2: function() {
         if (!Ext.getCmp('indicator_cb2').getValue() && !Ext.getCmp('dataelement_cb2').getValue()) {
             return false;
         }