Merge authors: Jan Henrik Ă˜verland (janhenrik-overland) ------------------------------------------------------------ revno: 2179 [merge] committer: Jan Henrik Overland <janhenrik.overl...@gmail.com> branch nick: trunk timestamp: Mon 2010-09-20 04:54:25 +0200 message: Improved code. 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.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/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-19 23:12:37 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js 2010-09-20 02:50:50 +0000 @@ -8,9 +8,7 @@ var MAPDATETYPE; /* A map object */ var MAPDATA = new Object(); -MAPDATA[thematicMap] = new Object(); -MAPDATA[thematicMap2] = new Object(); -MAPDATA[organisationUnitAssignment] = new Object(); +MAPDATA[thematicMap] = MAPDATA[thematicMap2] = MAPDATA[organisationUnitAssignment] = new Object(); /* Filename or level */ var URL; /* Active mapview object */ @@ -21,32 +19,27 @@ var ACTIVEPANEL; /* Mask */ var MASK; -/* Boolean */ +/* Labels activated (boolean) */ var LABELS = new Object(); -LABELS[thematicMap] = false; -LABELS[thematicMap2] = false; -LABELS[organisationUnitAssignment] = false; +LABELS[thematicMap] = LABELS[thematicMap2] = LABELS[organisationUnitAssignment] = false; /* Legend colors for export */ var COLORINTERPOLATION; /* Export values */ var EXPORTVALUES; /* Currently selected vector feature */ var FEATURE = new Object(); -FEATURE[thematicMap] = new Object(); -FEATURE[thematicMap2] = new Object(); +FEATURE[thematicMap] = FEATURE[thematicMap2] = new Object(); /* Global chart for show/hide */ var CHART; /* Current legend type and method */ var LEGEND = new Object(); -LEGEND[thematicMap] = new Object(); -LEGEND[thematicMap2] = new Object(); +LEGEND[thematicMap] = LEGEND[thematicMap2] = new Object(); LEGEND[thematicMap].type = LEGEND[thematicMap2].type = map_legend_type_automatic; LEGEND[thematicMap].method = LEGEND[thematicMap2].method = 2; LEGEND[thematicMap].classes = LEGEND[thematicMap2].classes = 5; /* Current map value types */ var VALUETYPE = new Object(); -VALUETYPE.polygon = map_value_type_indicator; -VALUETYPE.point = map_value_type_indicator; +VALUETYPE.polygon = VALUETYPE.point = map_value_type_indicator; /* Top level organisation unit */ var TOPLEVELUNIT = new Object(); /* Locate feature window */ === 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 2010-09-19 23:12:37 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js 2010-09-20 02:50:50 +0000 @@ -350,8 +350,8 @@ * Property: labelGenerator * Generator for bin labels */ - labelGenerator: function(bin, binIndex, nbBins) { - return this.defaultLabelGenerator(bin, binIndex, nbBins) + labelGenerator: function(bin, binIndex, nbBins, maxDec) { + return this.defaultLabelGenerator(bin, binIndex, nbBins, maxDec) }, values: null, @@ -379,14 +379,16 @@ * binIndex - {Integer} Current bin index * nBins - {Integer} Total number of bins */ - defaultLabelGenerator: function(bin, binIndex, nbBins) { + defaultLabelGenerator: function(bin, binIndex, nbBins, maxDec) { if (ACTIVEPANEL == organisationUnitAssignment) { return bin.upperBound < 1 ? 'Available' + ' ( ' + bin.nbVal + ' )' : 'Assigned' + ' ( ' + bin.nbVal + ' )'; } else { - lower = getNumberOfDecimals(bin.lowerBound.toString(), ".") > 2 ? Math.round(parseFloat(bin.lowerBound) * 100) / 100 : parseFloat(bin.lowerBound); - upper = getNumberOfDecimals(bin.upperBound.toString(), ".") > 2 ? Math.round(parseFloat(bin.upperBound) * 100) / 100 : parseFloat(bin.upperBound); + // lower = getNumberOfDecimals(bin.lowerBound.toString(), ".") > 2 ? Math.round(parseFloat(bin.lowerBound) * 100) / 100 : parseFloat(bin.lowerBound); + // upper = getNumberOfDecimals(bin.upperBound.toString(), ".") > 2 ? Math.round(parseFloat(bin.upperBound) * 100) / 100 : parseFloat(bin.upperBound); + lower = parseFloat(bin.lowerBound).toFixed(maxDec); + upper = parseFloat(bin.upperBound).toFixed(maxDec); return lower + ' - ' + upper + ' ( ' + bin.nbVal + ' )'; } }, @@ -417,11 +419,19 @@ binCount[nbBins - 1] = this.nbVal - mapfish.Util.sum(binCount); var imageLegend = new Array(); + var maxDec = 0; + + for (var i = 0; i < bounds.length; i++) { + var dec = getNumberOfDecimals(bounds[i].toString(), "."); + maxDec = dec > maxDec ? dec : maxDec; + } + + maxDec = maxDec > 2 ? 2 : maxDec; for (var i = 0; i < nbBins; i++) { bins[i] = new mapfish.GeoStat.Bin(binCount[i], bounds[i], bounds[i + 1], i == (nbBins - 1)); var labelGenerator = this.labelGenerator || this.defaultLabelGenerator; - bins[i].label = labelGenerator(bins[i], i, nbBins); + bins[i].label = labelGenerator(bins[i], i, nbBins, maxDec); imageLegend[i] = new Object(); imageLegend[i].label = bins[i].label; } @@ -528,12 +538,9 @@ Ext.getCmp('bounds_tf2').setValue(newInput); } - for (var i = 0; i < bounds.length; i++) - { + for (var i = 0; i < bounds.length; i++) { bounds[i] = parseFloat(bounds[i]); - - if (bounds[i] < this.minVal || bounds[i] > this.maxVal) - { + if (bounds[i] < this.minVal || bounds[i] > this.maxVal) { Ext.message.msg(false, 'Class breaks must be higher than <span class="x-msg-hl">' + this.minVal + '</span> and lower than <span class="x-msg-hl">' + this.maxVal + '</span>.'); } } === 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 2010-09-19 23:12:37 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js 2010-09-20 02:50:50 +0000 @@ -777,11 +777,11 @@ } Ext.getCmp('colorA_cf').showField(); Ext.getCmp('colorB_cf').showField(); - Ext.getCmp('maplegendset_cb').hideField(); + Ext.getCmp('maplegendset_cb').hideField(); + + choropleth.classify(false, true); } - } - - choropleth.classify(false, true); + } }, failure: function() { @@ -1554,7 +1554,7 @@ } params.id = indicatorOrDataElementId; params.parentId = choropleth.parentId; - + Ext.Ajax.request({ url: path_mapping + dataUrl + type, method: 'POST', @@ -1673,7 +1673,6 @@ for (var j = 0; j < FEATURE[thematicMap].length; j++) { var value = mv[mour[FEATURE[thematicMap][j].attributes[nameColumn]]]; - var name = FEATURE[thematicMap][j].attributes[nameColumn]; FEATURE[thematicMap][j].attributes.value = value ? parseFloat(value) : ''; FEATURE[thematicMap][j].data.id = FEATURE[thematicMap][j].attributes[nameColumn]; FEATURE[thematicMap][j].data.name = FEATURE[thematicMap][j].attributes[nameColumn]; === 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-19 23:12:37 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js 2010-09-20 02:50:50 +0000 @@ -762,8 +762,26 @@ proportionalSymbol.applyPredefinedLegend(); } + else { + if (LEGEND[thematicMap2].type == map_legend_type_predefined) { + LEGEND[thematicMap2].type = map_legend_type_automatic; + Ext.getCmp('maplegendtype_cb2').setValue(LEGEND[thematicMap2].type); + Ext.getCmp('method_cb2').showField(); + if (Ext.getCmp('method_cb2').getValue() == classify_with_bounds) { + Ext.getCmp('bounds_tf2').showField(); + Ext.getCmp('numClasses_cb2').hideField(); + } + else { + Ext.getCmp('bounds_tf2').hideField(); + Ext.getCmp('numClasses_cb2').showField(); + } + Ext.getCmp('colorA_cf2').showField(); + Ext.getCmp('colorB_cf2').showField(); + Ext.getCmp('maplegendset_cb2').hideField(); - proportionalSymbol.classify(false, true); + proportionalSymbol.classify(false, true); + } + } }, failure: function() {
_______________________________________________ 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