← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17189: DV EV chart rendering bug fixed + GIS assigned legend set bug fixed.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 17189 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-10-21 10:25:11 +0200
message:
  DV EV chart rendering bug fixed + GIS assigned legend set bug fixed.
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/core.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/app.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/core.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-apps/src/main/webapp/dhis-web-event-visualizer/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/core.js	2014-10-15 11:27:39 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/core.js	2014-10-20 13:12:14 +0000
@@ -264,8 +264,6 @@
 						return;
 					}
 
-					//config.id = config.id.replace('.', '-');
-
 					return config;
 				}();
 			};
@@ -329,7 +327,7 @@
 				// rows: [Dimension]
 
 				// filters: [Dimension]
-                
+
                 // showTrendLine: boolean (false)
 
                 // targetLineValue: number
@@ -505,7 +503,7 @@
                         alert('At least one fixed period, one relative period or start/end dates must be specified');
                         return;
                     }
-                    
+
 					config.columns = getValidatedDimensionArray(config.columns);
 					config.rows = getValidatedDimensionArray(config.rows);
 					config.filters = getValidatedDimensionArray(config.filters);
@@ -547,7 +545,7 @@
 					layout.columns = config.columns;
 					layout.rows = config.rows;
 					layout.filters = config.filters;
-                    
+
                     layout.type = Ext.isString(config.type) ? config.type : 'column';
                     layout.program = config.program;
                     layout.programStage = config.programStage;
@@ -578,7 +576,7 @@
                         (Ext.isString(config.rangeAxisTitle) && !Ext.isEmpty(config.rangeAxisTitle) ? config.rangeAxisTitle : null);
 					layout.domainAxisTitle = Ext.isString(config.domainAxisLabel) && !Ext.isEmpty(config.domainAxisLabel) ? config.domainAxisLabel :
                         (Ext.isString(config.domainAxisTitle) && !Ext.isEmpty(config.domainAxisTitle) ? config.domainAxisTitle : null);
-                        
+
                     layout.hideLegend = Ext.isBoolean(config.hideLegend) ? config.hideLegend : false;
                     layout.hideTitle = Ext.isBoolean(config.hideTitle) ? config.hideTitle : false;
                     layout.title = Ext.isString(config.title) &&  !Ext.isEmpty(config.title) ? config.title : null;
@@ -1301,7 +1299,7 @@
 
                                     if (dim.dimension === orgDim.dimension && dim.items && dim.items.length) {
                                         var items = [];
-                                        
+
                                         for (var k = 0, option; k < options.length; k++) {
                                             option = options[k];
 
@@ -1759,12 +1757,12 @@
 			service.response.aggregate = {};
 
 			service.response.aggregate.getExtendedResponse = function(xLayout, response) {
-				var emptyId = '(N/A)',
+				var emptyId = '[N/A]',
                     meta = ['ou', 'pe'],
                     ouHierarchy,
                     names,
 					headers;
-                    
+
 				response = Ext.clone(response);
 				headers = response.headers;
                 ouHierarchy = response.metaData.ouHierarchy,
@@ -1869,7 +1867,7 @@
 					for (var j = 0; j < idIndexOrder.length; j++) {
 						id += row[idIndexOrder[j]];
 					}
-                    
+
 					response.idValueMap[id] = row[valueHeaderIndex];
 				}
 
@@ -1966,7 +1964,7 @@
 				}
 
                 // filters
-                if (layout.filters) {                    
+                if (layout.filters) {
 					for (var i = 0, dim; i < layout.filters.length; i++) {
 						dim = layout.filters[i];
 
@@ -2064,16 +2062,27 @@
 			};
 
 			web.report.aggregate.createChart = function(layout, xLayout, xResponse, centerRegion) {
-                var dataTotalKey = Ext.data.IdGenerator.get('uuid').generate(),
-                    //columnIds = xLayout.columns[0] ? xLayout.columns[0].ids : [],
-                    columnIds = xLayout.columnDimensionNames[0] ? xLayout.dimensionNameIdsMap[xLayout.columnDimensionNames[0]] : [],
-                    replacedColumnIds = support.prototype.str.replaceAll(Ext.clone(columnIds), '.', ''),
-                    //rowIds = xLayout.rows[0] ? xLayout.rows[0].ids : [],
+                var columnIds = xLayout.columnDimensionNames[0] ? xLayout.dimensionNameIdsMap[xLayout.columnDimensionNames[0]] : [],
+                    failSafeColumnIds = [],
+                    failSafeColumnIdMap = {},
+                    createFailSafeIds = function() {
+                        for (var i = 0, uuid; i < columnIds.length; i++) {
+                            uuid = Ext.data.IdGenerator.get('uuid').generate();
+
+                            failSafeColumnIds.push(uuid);
+                            failSafeColumnIdMap[uuid] = columnIds[i];
+
+                            xResponse.metaData.names[uuid] = xResponse.metaData.names[columnIds[i]];
+                        }
+                    }(),
+
+                    // row ids
                     rowIds = xLayout.rowDimensionNames[0] ? xLayout.dimensionNameIdsMap[xLayout.rowDimensionNames[0]] : [],
-                    replacedRowIds = support.prototype.str.replaceAll(Ext.clone(rowIds), '.', ''),
+
+                    // filter ids
                     filterIds = function() {
                         var ids = [];
-                        
+
                         if (xLayout.filters) {
                             for (var i = 0; i < xLayout.filters.length; i++) {
                                 ids = ids.concat(xLayout.filters[i].ids || []);
@@ -2082,21 +2091,9 @@
 
                         return ids;
                     }(),
-                    replacedFilterIds = support.prototype.str.replaceAll(Ext.clone(filterIds), '.', ''),
-
-                    replacedIdMap = function() {
-                        var map = {},
-                            names = xResponse.metaData.names,
-                            ids = Ext.clean([].concat(columnIds || [], rowIds || [], filterIds || [])),
-                            replacedIds = Ext.clean([].concat(replacedColumnIds || [], replacedRowIds || [], replacedFilterIds || []));
-
-                        for (var i = 0; i < replacedIds.length; i++) {
-                            map[replacedIds[i]] = ids[i];
-                        }
-
-                        return map;
-                    }(),                          
-
+
+                    // totals
+                    dataTotalKey = Ext.data.IdGenerator.get('uuid').generate(),
                     addDataTotals = function(data, ids) {
                         for (var i = 0, obj, total; i < data.length; i++) {
                             obj = data[i];
@@ -2132,11 +2129,7 @@
                     generator = {};
 
                 getDefaultStore = function(isStacked) {
-                    var pe = conf.finals.dimension.period.dimensionName,
-                        columnDimensionName = xLayout.columns[0].dimensionName,
-                        rowDimensionName = xLayout.rows[0].dimensionName,
-
-                        data = [],
+                    var data = [],
                         trendLineFields = [],
                         targetLineFields = [],
                         baseLineFields = [],
@@ -2148,16 +2141,15 @@
                         category = rowIds[i];
                         rowValues = [];
                         isEmpty = false;
-                        
 
                         obj[conf.finals.data.domain] = xResponse.metaData.names[category];
-                        
+
                         for (var j = 0, id, value; j < columnIds.length; j++) {
                             id = support.prototype.str.replaceAll(columnIds[j], '#', '') + support.prototype.str.replaceAll(rowIds[i], '#', '');
                             value = xResponse.idValueMap[id];
                             rowValues.push(value);
 
-                            obj[columnIds[j]] = value ? parseFloat(value) : '0.0';
+                            obj[failSafeColumnIds[j]] = value ? parseFloat(value) : '0.0';
                         }
 
                         isEmpty = !(Ext.Array.clean(rowValues).length);
@@ -2169,13 +2161,13 @@
 
                     // stacked
                     if (isStacked) {
-                        addDataTotals(data, columnIds);
+                        addDataTotals(data, failSafeColumnIds);
                     }
-                    
+
                     // sort order
                     if (xLayout.sortOrder) {
-                        var sortingKey = isStacked ? dataTotalKey : columnIds[0];
-                        
+                        var sortingKey = isStacked ? dataTotalKey : failSafeColumnIds[0];
+
                         support.prototype.array.sort(data, xLayout.sortOrder === -1 ? 'ASC' : 'DESC', sortingKey);
                     }
 
@@ -2201,12 +2193,12 @@
                             xResponse.metaData.names[regressionKey] = NS.i18n.trend + ' (Total)';
                         }
                         else {
-                            for (var i = 0; i < columnIds.length; i++) {
+                            for (var i = 0; i < failSafeColumnIds.length; i++) {
                                 regression = new SimpleRegression();
-                                regressionKey = conf.finals.data.trendLine + columnIds[i];
+                                regressionKey = conf.finals.data.trendLine + failSafeColumnIds[i];
 
                                 for (var j = 0, value; j < data.length; j++) {
-                                    value = data[j][replacedColumnIds[i]];
+                                    value = data[j][failSafeColumnIds[i]];
                                     regression.addData(j, parseFloat(value));
                                 }
 
@@ -2215,11 +2207,11 @@
                                 }
 
                                 trendLineFields.push(regressionKey);
-                                xResponse.metaData.names[regressionKey] = NS.i18n.trend + ' (' + xResponse.metaData.names[columnIds[i]] + ')';
+                                xResponse.metaData.names[regressionKey] = NS.i18n.trend + ' (' + xResponse.metaData.names[failSafeColumnIds[i]] + ')';
                             }
                         }
                     }
-                    
+
                     // target line
                     if (Ext.isNumber(xLayout.targetLineValue) || Ext.isNumber(parseFloat(xLayout.targetLineValue))) {
                         for (var i = 0; i < data.length; i++) {
@@ -2240,7 +2232,7 @@
 
                     store = Ext.create('Ext.data.Store', {
                         fields: function() {
-                            var fields = Ext.clone(columnIds);
+                            var fields = Ext.clone(failSafeColumnIds);
                             fields.push(conf.finals.data.domain);
                             fields = fields.concat(trendLineFields, targetLineFields, baseLineFields);
 
@@ -2249,7 +2241,7 @@
                         data: data
                     });
 
-                    store.rangeFields = columnIds;
+                    store.rangeFields = failSafeColumnIds;
                     store.domainFields = [conf.finals.data.domain];
                     store.trendLineFields = trendLineFields;
                     store.targetLineFields = targetLineFields;
@@ -2295,11 +2287,11 @@
 
                     store.hasDecimals = function() {
                         var records = store.getRange();
-                        
+
                         for (var i = 0; i < records.length; i++) {
                             for (var j = 0, value; j < store.rangeFields.length; j++) {
                                 value = records[i].data[store.rangeFields[j]];
-                                
+
                                 if (Ext.isNumber(value) && (value % 1)) {
                                     return true;
                                 }
@@ -2312,11 +2304,11 @@
                     store.getNumberOfDecimals = function() {
                         var records = store.getRange(),
                             values = [];
-                        
+
                         for (var i = 0; i < records.length; i++) {
                             for (var j = 0, value; j < store.rangeFields.length; j++) {
                                 value = records[i].data[store.rangeFields[j]];
-                                
+
                                 if (Ext.isNumber(value) && (value % 1)) {
                                     value = value.toString();
 
@@ -2329,6 +2321,7 @@
                     };
 
                     if (NS.isDebug) {
+                        console.log("store", store);
                         console.log("data", data);
                         console.log("rangeFields", store.rangeFields);
                         console.log("domainFields", store.domainFields);
@@ -2412,7 +2405,7 @@
 
 					if (xLayout.rangeAxisDecimals) {
 						axis.label.renderer = Ext.util.Format.numberRenderer(getRenderer(xLayout.rangeAxisDecimals));
-					}                    
+					}
 
                     if (xLayout.rangeAxisTitle) {
                         axis.title = xLayout.rangeAxisTitle;
@@ -2454,7 +2447,7 @@
                     }
                     else {
                         for (var i = 0, id, name, mxl, ids; i < store.rangeFields.length; i++) {
-                            id = store.rangeFields[i];
+                            id = failSafeColumnIdMap[store.rangeFields[i]];
                             name = xResponse.metaData.names[id];
 
                             if (Ext.isObject(xLayout.legend) && xLayout.legend.maxLength) {
@@ -2464,7 +2457,7 @@
                                     name = name.substr(0, mxl) + '..';
                                 }
                             }
-                            
+
                             a.push(name);
                         }
                     }
@@ -2497,7 +2490,7 @@
                             field: store.rangeFields,
                             font: conf.chart.style.fontFamily,
                             renderer: function(n) {
-                                return n === '0.0' ? '' : n;                                    
+                                return n === '0.0' ? '' : n;
                             }
                         };
                     }
@@ -2510,7 +2503,7 @@
 
                     for (var i = 0, strokeColor; i < store.trendLineFields.length; i++) {
                         strokeColor = isStacked ? '#000' : conf.chart.theme.dv1[i];
-                        
+
                         a.push({
                             type: 'line',
                             axis: 'left',
@@ -2704,7 +2697,7 @@
                                 if (Ext.Array.contains(meta, dim.dimension)) {
                                     var ids = xResponse.metaData[dim.dimension],
                                     tmpText = '';
-                                    
+
                                     for (var ii = 0; ii < ids.length; ii++) {
                                         tmpText += (tmpText.length ? ', ' : '') + names[ids[ii]];
                                     }
@@ -2714,7 +2707,7 @@
                                 else {
                                     if (dim.filter) {
                                         var a = dim.filter.split(':');
-                                        
+
                                         if (a.length === 2) {
                                             var operator = a[0],
                                                 valueArray = a[1].split(';'),
@@ -3062,13 +3055,13 @@
 
                     // NB, always true for area charts as extjs area charts cannot handle nulls
                     xLayout.hideEmptyRows = true;
-                    
+
                     var store = getDefaultStore(true),
                         numericAxis = getDefaultNumericAxis(store),
                         categoryAxis = getDefaultCategoryAxis(store),
                         axes = [numericAxis, categoryAxis],
                         series = getDefaultSeries(store);
-                        
+
                     series.type = 'area';
                     series.style.opacity = 0.7;
                     series.style.lineWidth = 0;
@@ -3161,7 +3154,7 @@
                         store: store,
                         series: series
                     });
-                    
+
                     //chart.legend.position = 'right';
                     //chart.legend.isVertical = true;
                     chart.insetPadding = 40;
@@ -3209,7 +3202,7 @@
 
                         series.push(obj);
                     }
-                    
+
                     chart = getDefaultChart({
                         store: store,
                         axes: axes,

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js	2014-10-15 09:48:53 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js	2014-10-21 08:22:25 +0000
@@ -7181,18 +7181,18 @@
 					Ext.Ajax.request({
 						url: gis.init.contextPath + '/api/indicators.json?fields=legendSet[id]&paging=false&filter=id:eq:' + this.getValue(),
 						success: function(r) {
-							r = Ext.decode(r.responseText);
+							var set = Ext.decode(r.responseText).indicators[0].legendSet;
 
-							if (Ext.isObject(r.mapLegendSet) && r.mapLegendSet.id) {
+							if (Ext.isObject(set) && set.id) {
 								legendType.setValue(gis.conf.finals.widget.legendtype_predefined);
 								legendTypeToggler(gis.conf.finals.widget.legendtype_predefined);
 
 								if (gis.store.legendSets.isLoaded) {
-									legendSet.setValue(r.mapLegendSet.id);
+									legendSet.setValue(set.id);
 								}
 								else {
 									gis.store.legendSets.loadFn( function() {
-										legendSet.setValue(r.mapLegendSet.id);
+										legendSet.setValue(set.id);
 									});
 								}
 							}
@@ -7269,18 +7269,18 @@
 					Ext.Ajax.request({
 						url: gis.init.contextPath + '/api/dataElements.json?fields=legendSet[id]&paging=false&filter=id:eq:' + this.getValue(),
 						success: function(r) {
-							r = Ext.decode(r.responseText);
+							var set = Ext.decode(r.responseText).dataElements[0].legendSet;
 
-							if (Ext.isObject(r.mapLegendSet) && r.mapLegendSet.id) {
+							if (Ext.isObject(set) && set.id) {
 								legendType.setValue(gis.conf.finals.widget.legendtype_predefined);
 								legendTypeToggler(gis.conf.finals.widget.legendtype_predefined);
 
 								if (gis.store.legendSets.isLoaded) {
-									legendSet.setValue(r.mapLegendSet.id);
+									legendSet.setValue(set.id);
 								}
 								else {
 									gis.store.legendSets.loadFn( function() {
-										legendSet.setValue(r.mapLegendSet.id);
+										legendSet.setValue(set.id);
 									});
 								}
 							}
@@ -7342,7 +7342,35 @@
 			width: gis.conf.layout.widget.item_width,
 			labelWidth: gis.conf.layout.widget.itemlabel_width,
 			listConfig: {loadMask: false},
-			store: dataSetStore
+			store: dataSetStore,
+			listeners: {
+				select: function(cb) {
+					Ext.Ajax.request({
+						url: gis.init.contextPath + '/api/dataSets.json?fields=legendSet[id]&paging=false&filter=id:eq:' + this.getValue(),
+						success: function(r) {
+							var set = Ext.decode(r.responseText).dataSets[0].legendSet;
+
+							if (Ext.isObject(set) && set.id) {
+								legendType.setValue(gis.conf.finals.widget.legendtype_predefined);
+								legendTypeToggler(gis.conf.finals.widget.legendtype_predefined);
+
+								if (gis.store.legendSets.isLoaded) {
+									legendSet.setValue(set.id);
+								}
+								else {
+									gis.store.legendSets.loadFn( function() {
+										legendSet.setValue(set.id);
+									});
+								}
+							}
+							else {
+								legendType.setValue(gis.conf.finals.widget.legendtype_automatic);
+								legendTypeToggler(gis.conf.finals.widget.legendtype_automatic);
+							}
+						}
+					});
+				}
+			}
 		});
 
         onPeriodTypeSelect = function() {

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/app.js	2014-10-14 15:40:58 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/app.js	2014-10-20 13:12:14 +0000
@@ -15,7 +15,7 @@
 		core: {},
 		app: {}
 	};
-	
+
 	// set app config
 	(function() {
 
@@ -214,7 +214,7 @@
 
 					ms.store.on('add', function(store, addedRecords) {
                         var range = store.getRange();
-                        
+
                         if (range.length > 1) {
                             var addedIds = Ext.Array.pluck(addedRecords, 'internalId'),
                                 records = Ext.clone(range);
@@ -230,10 +230,10 @@
                                 }
                             }
                         }
-                        
+
 						Ext.defer( function() {
 							ms.boundList.getSelectionModel().deselectAll();
-						}, 10);                        
+						}, 10);
 					});
 				}
 			}
@@ -266,7 +266,7 @@
 
 					ms.store.on('add', function(store, addedRecords) {
                         var range = store.getRange();
-                        
+
                         if (range.length > 1) {
                             var addedIds = Ext.Array.pluck(addedRecords, 'internalId'),
                                 records = Ext.clone(range);
@@ -282,10 +282,10 @@
                                 }
                             }
                         }
-                        
+
 						Ext.defer( function() {
 							ms.boundList.getSelectionModel().deselectAll();
-						}, 10);                        
+						}, 10);
 					});
 				}
 			}
@@ -514,7 +514,7 @@
             rangeAxisDecimals,
 			rangeAxisTitle,
 			domainAxisTitle,
-            
+
 			hideLegend,
 			hideTitle,
 			title,
@@ -686,7 +686,7 @@
 			enforceMaxLength: true,
 			style: 'margin-bottom:1px'
 		});
-		
+
 		domainAxisTitle = Ext.create('Ext.form.field.Text', {
 			width: cmpWidth,
 			fieldLabel: NS.i18n.domain_axis_label,
@@ -760,7 +760,7 @@
 				rangeAxisTitle,
 				domainAxisTitle
 			]
-		};			
+		};
 
 		general = {
 			bodyStyle: 'border:0 none',
@@ -885,7 +885,7 @@
 				else {
 					domainAxisTitle.reset();
 				}
-				
+
 				hideLegend.setValue(Ext.isBoolean(layout.hideLegend) ? layout.hideLegend : false);
 				hideTitle.setValue(Ext.isBoolean(layout.hideTitle) ? layout.hideTitle : false);
 
@@ -966,7 +966,7 @@
 					w.rangeAxisDecimals = rangeAxisDecimals;
 					w.rangeAxisTitle = rangeAxisTitle;
 					w.domainAxisTitle = domainAxisTitle;
-					
+
 					w.hideLegend = hideLegend;
 					w.hideTitle = hideTitle;
 					w.title = title;
@@ -1949,7 +1949,7 @@
 
 				svg = Ext.get(svg[0]);
 				svg = svg.parent().dom.innerHTML;
-
+console.log(svg);
 				Ext.query('#svgField')[0].value = svg;
 				Ext.query('#filenameField')[0].value = 'test';
 
@@ -2223,7 +2223,7 @@
 
 					for (var j = 0, dimName, dim; j < dimNames.length; j++) {
 						dimName = dimNames[j];
-                        
+
 						if (dimName === co) {
 							axes[i].push({
 								dimension: co,
@@ -2342,7 +2342,7 @@
                     fn;
 
                 fn = function() {
-                    
+
                     // create chart
                     ns.app.chart = ns.core.web.chart.createChart(ns ,legendSet);
 
@@ -2749,7 +2749,7 @@
             loadStore: function(data, pager, append) {
                 this.loadData(data, append);
                 this.sortStore();
-                
+
                 this.lastPage = this.nextPage;
 
                 if (pager.pageCount > this.nextPage) {
@@ -2929,7 +2929,7 @@
             loadStore: function(data, pager, append) {
                 this.loadData(data, append);
                 this.sortStore();
-                
+
                 this.lastPage = this.nextPage;
 
                 if (pager.pageCount > this.nextPage) {
@@ -3033,7 +3033,7 @@
             loadStore: function(data, pager, append) {
                 this.loadData(data, append);
                 this.sortStore();
-                
+
                 this.lastPage = this.nextPage;
 
                 if (pager.pageCount > this.nextPage) {
@@ -3083,7 +3083,7 @@
 			data: []
 		});
 		ns.app.stores.fixedPeriodSelected = fixedPeriodSelectedStore;
-        
+
 		chartStore = Ext.create('Ext.data.Store', {
 			fields: ['id', 'name', 'lastUpdated', 'access'],
 			proxy: {
@@ -3156,7 +3156,7 @@
 		isScrolled = function(e) {
 			var el = e.srcElement,
 				scrollBottom = el.scrollTop + ((el.clientHeight / el.scrollHeight) * el.scrollHeight);
-                
+
 			return scrollBottom / el.scrollHeight > 0.9;
 		};
 
@@ -4199,7 +4199,7 @@
             var type = periodType.getValue(),
                 periodOffset = periodType.periodOffset,
                 generator = ns.core.init.periodGenerator,
-                periods = generator.generateReversedPeriods(type, type === 'Yearly' ? periodOffset - 5 : periodOffset);           
+                periods = generator.generateReversedPeriods(type, type === 'Yearly' ? periodOffset - 5 : periodOffset);
 
             for (var i = 0; i < periods.length; i++) {
                 periods[i].id = periods[i].iso;
@@ -4208,7 +4208,7 @@
             fixedPeriodAvailableStore.setIndex(periods);
             fixedPeriodAvailableStore.loadData(periods);
             ns.core.web.multiSelect.filterAvailable(fixedPeriodAvailable, fixedPeriodSelected);
-        };            
+        };
 
         periodType = Ext.create('Ext.form.field.ComboBox', {
             cls: 'ns-combo',
@@ -5077,7 +5077,7 @@
 		};
 
 		// viewport
-        
+
 		update = function() {
 			var config = ns.core.web.chart.getLayoutConfig(),
 				layout = ns.core.api.layout.Layout(config);
@@ -5850,7 +5850,7 @@
 
 			// Layout
 			ns.app.viewport.chartType.setChartType(layout.type);
-            
+
 			ns.app.stores.dimension.removeAll();
 			ns.app.stores.col.removeAll();
 			ns.app.stores.row.removeAll();
@@ -5922,7 +5922,7 @@
             if (!ns.app.layoutWindow.hasDimension(dimConf.data.dimensionName)) {
                 ns.app.stores.dimension.add({id: dimConf.data.dimensionName, name: dimConf.data.name});
             }
-            
+
             // add orgunit as dimension
             if (!ns.app.layoutWindow.hasDimension(dimConf.organisationUnit.dimensionName)) {
                 ns.app.stores.dimension.add({id: dimConf.organisationUnit.dimensionName, name: dimConf.organisationUnit.name});
@@ -6274,7 +6274,7 @@
                                         });
 
                                         // dimensions
-                                        requests.push({ 
+                                        requests.push({
                                             url: contextPath + '/api/dimensions.json?links=false&paging=false',
                                             success: function(r) {
                                                 init.dimensions = Ext.decode(r.responseText).dimensions || [];

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/core.js	2014-10-17 11:15:46 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/core.js	2014-10-20 14:33:20 +0000
@@ -212,7 +212,7 @@
             conf.chart = {
                 style: {
                     inset: 30,
-                    fontFamily: 'Arial,Sans-serif,Lucida Grande,Ubuntu'
+                    fontFamily: 'Arial,Sans-serif,Helvetica,Helvetica Neue,Lucida Grande,Ubuntu'
                 },
                 theme: {
                     dv1: ['#94ae0a', '#1d5991', '#a61120', '#ff8809', '#7c7474', '#a61187', '#ffd13e', '#24ad9a', '#a66111', '#414141', '#4500c4', '#1d5700']
@@ -226,7 +226,7 @@
                     ok: 'ok.png'
                 }
             };
-            
+
             conf.url = {
                 analysisFields: [
                     '*',
@@ -614,7 +614,7 @@
                         (Ext.isString(config.rangeAxisTitle) && !Ext.isEmpty(config.rangeAxisTitle) ? config.rangeAxisTitle : null);
 					layout.domainAxisTitle = Ext.isString(config.domainAxisLabel) && !Ext.isEmpty(config.domainAxisLabel) ? config.domainAxisLabel :
                         (Ext.isString(config.domainAxisTitle) && !Ext.isEmpty(config.domainAxisTitle) ? config.domainAxisTitle : null);
-                        
+
                     layout.hideLegend = Ext.isBoolean(config.hideLegend) ? config.hideLegend : false;
                     layout.hideTitle = Ext.isBoolean(config.hideTitle) ? config.hideTitle : false;
                     layout.title = Ext.isString(config.title) &&  !Ext.isEmpty(config.title) ? config.title : null;
@@ -686,7 +686,7 @@
 						console.log('Response: no valid headers');
 						return;
 					}
-                    
+
 					if (!(Ext.isArray(config.rows) && config.rows.length > 0)) {
                         if (!NS.plugin) {
                             alert('No values found');
@@ -1295,7 +1295,7 @@
 				if (el) {
 					layout.el = el;
 				}
-				
+
 				if (Ext.isString(layout.id)) {
 					return {id: layout.id};
 				}
@@ -1559,93 +1559,6 @@
 				}());
 
 				return response;
-
-                    //response.nameHeaderMap = {};
-                    //response.idValueMap = {};
-                    //ids = [];
-
-                    //var extendHeaders = function() {
-                        //// Extend headers: index, items, size
-                        //for (var i = 0, header; i < response.headers.length; i++) {
-                            //header = response.headers[i];
-
-                            //// Index
-                            //header.index = i;
-
-                            //if (header.meta) {
-
-                                //// Items
-                                //header.items = Ext.clone(xLayout.dimensionNameIdsMap[header.name]) || [];
-
-                                //// Size
-                                //header.size = header.items.length;
-
-                                //// Collect ids, used by extendMetaData
-                                //ids = ids.concat(header.items);
-                            //}
-                        //}
-
-                        //// nameHeaderMap (headerName: header)
-                        //for (var i = 0, header; i < response.headers.length; i++) {
-                            //header = response.headers[i];
-
-                            //response.nameHeaderMap[header.name] = header;
-                        //}
-                    //}();
-
-                    //var extendMetaData = function() {
-                        //for (var i = 0, id, splitId ; i < ids.length; i++) {
-                            //id = ids[i];
-
-                            //if (id.indexOf('-') !== -1) {
-                                //splitId = id.split('-');
-                                //response.metaData.names[id] = response.metaData.names[splitId[0]] + ' ' + response.metaData.names[splitId[1]];
-                            //}
-                        //}
-                    //}();
-
-                    //var createValueIdMap = function() {
-                        //var valueHeaderIndex = response.nameHeaderMap[conf.finals.dimension.value.value].index,
-                            //coHeader = response.nameHeaderMap[conf.finals.dimension.category.dimensionName],
-                            //axisDimensionNames = xLayout.axisDimensionNames,
-                            //idIndexOrder = [];
-
-                        //// idIndexOrder
-                        //for (var i = 0; i < axisDimensionNames.length; i++) {
-                            //idIndexOrder.push(response.nameHeaderMap[axisDimensionNames[i]].index);
-
-                            //// If co exists in response, add co after dx
-                            //if (coHeader && axisDimensionNames[i] === conf.finals.dimension.data.dimensionName) {
-                                //idIndexOrder.push(coHeader.index);
-                            //}
-                        //}
-
-                        //// idValueMap
-                        //for (var i = 0, row, id; i < response.rows.length; i++) {
-                            //row = response.rows[i];
-                            //id = '';
-
-                            //for (var j = 0; j < idIndexOrder.length; j++) {
-                                //id += row[idIndexOrder[j]];
-                            //}
-
-                            //response.idValueMap[id] = parseFloat(row[valueHeaderIndex]);
-                        //}
-                    //}();
-
-                    //var getMinMax = function() {
-                        //var valueIndex = response.nameHeaderMap.value.index,
-                            //values = [];
-
-                        //for (var i = 0; i < response.rows.length; i++) {
-                            //values.push(parseFloat(response.rows[i][valueIndex]));
-                        //}
-
-                        //response.min = Ext.Array.min(values);
-                        //response.max = Ext.Array.max(values);
-                    //}();
-
-                    //return response;
 			};
 
             // legend set
@@ -1653,11 +1566,11 @@
 
             service.mapLegend.getColorByValue = function(legendSet, value) {
                 var color;
-                
+
                 if (!(legendSet && value)) {
                     return;
                 }
-                
+
                 for (var i = 0, legend; i < legendSet.mapLegends.length; i++) {
                     legend = legendSet.mapLegends[i];
 
@@ -1797,18 +1710,29 @@
 			web.chart = {};
 
 			web.chart.createChart = function(ns, legendSet) {
-                var dataTotalKey = Ext.data.IdGenerator.get('uuid').generate(),
-                    xLayout = ns.app.xLayout,
+                var xLayout = ns.app.xLayout,
                     xResponse = ns.app.xResponse,
-                    //columnIds = xLayout.columns[0] ? xLayout.columns[0].ids : [],
                     columnIds = xLayout.columnDimensionNames[0] ? xLayout.dimensionNameIdsMap[xLayout.columnDimensionNames[0]] : [],
-                    replacedColumnIds = support.prototype.str.replaceAll(Ext.clone(columnIds), '.', ''),
-                    //rowIds = xLayout.rows[0] ? xLayout.rows[0].ids : [],
+                    failSafeColumnIds = [],
+                    failSafeColumnIdMap = {},
+                    createFailSafeIds = function() {
+                        for (var i = 0, uuid; i < columnIds.length; i++) {
+                            uuid = Ext.data.IdGenerator.get('uuid').generate();
+
+                            failSafeColumnIds.push(uuid);
+                            failSafeColumnIdMap[uuid] = columnIds[i];
+
+                            xResponse.metaData.names[uuid] = xResponse.metaData.names[columnIds[i]];
+                        }
+                    }(),
+
+                    // row ids
                     rowIds = xLayout.rowDimensionNames[0] ? xLayout.dimensionNameIdsMap[xLayout.rowDimensionNames[0]] : [],
-                    replacedRowIds = support.prototype.str.replaceAll(Ext.clone(rowIds), '.', ''),
+
+                    // filter ids
                     filterIds = function() {
                         var ids = [];
-                        
+
                         if (xLayout.filters) {
                             for (var i = 0; i < xLayout.filters.length; i++) {
                                 ids = ids.concat(xLayout.filters[i].ids || []);
@@ -1817,19 +1741,9 @@
 
                         return ids;
                     }(),
-                    replacedFilterIds = support.prototype.str.replaceAll(Ext.clone(filterIds), '.', ''),
-                    replacedIdMap = function() {
-                        var map = {},
-                            names = xResponse.metaData.names,
-                            ids = Ext.clean([].concat(columnIds || [], rowIds || [], filterIds || [])),
-                            replacedIds = Ext.clean([].concat(replacedColumnIds || [], replacedRowIds || [], replacedFilterIds || []));
-
-                        for (var i = 0; i < replacedIds.length; i++) {
-                            map[replacedIds[i]] = ids[i];
-                        }
-
-                        return map;
-                    }(),
+
+                    // totals
+                    dataTotalKey = Ext.data.IdGenerator.get('uuid').generate(),
                     addDataTotals = function(data, ids) {
                         for (var i = 0, obj, total; i < data.length; i++) {
                             obj = data[i];
@@ -1861,7 +1775,7 @@
                     getDefaultChartSizeHandler,
                     getDefaultChartTitlePositionHandler,
                     getDefaultChart,
-                    
+
                     generator = {};
 
                 getDefaultStore = function(isStacked) {
@@ -1876,16 +1790,16 @@
                         obj = {};
                         category = rowIds[i];
                         rowValues = [];
-                        isEmpty = false;                        
+                        isEmpty = false;
 
                         obj[conf.finals.data.domain] = xResponse.metaData.names[category];
-                        
+
                         for (var j = 0, id, value; j < columnIds.length; j++) {
                             id = support.prototype.str.replaceAll(columnIds[j], '#', '') + support.prototype.str.replaceAll(rowIds[i], '#', '');
                             value = xResponse.idValueMap[id];
                             rowValues.push(value);
 
-                            obj[columnIds[j]] = value ? parseFloat(value) : '0.0';
+                            obj[failSafeColumnIds[j]] = value ? parseFloat(value) : '0.0';
                         }
 
                         isEmpty = !(Ext.Array.clean(rowValues).length);
@@ -1897,13 +1811,13 @@
 
                     // stacked
                     if (isStacked) {
-                        addDataTotals(data, columnIds);
+                        addDataTotals(data, failSafeColumnIds);
                     }
-                    
+
                     // sort order
                     if (xLayout.sortOrder) {
-                        var sortingKey = isStacked ? dataTotalKey : columnIds[0];
-                        
+                        var sortingKey = isStacked ? dataTotalKey : failSafeColumnIds[0];
+
                         support.prototype.array.sort(data, xLayout.sortOrder === -1 ? 'ASC' : 'DESC', sortingKey);
                     }
 
@@ -1929,12 +1843,12 @@
                             xResponse.metaData.names[regressionKey] = NS.i18n.trend + ' (Total)';
                         }
                         else {
-                            for (var i = 0; i < columnIds.length; i++) {
+                            for (var i = 0; i < failSafeColumnIds.length; i++) {
                                 regression = new SimpleRegression();
-                                regressionKey = conf.finals.data.trendLine + columnIds[i];
+                                regressionKey = conf.finals.data.trendLine + failSafeColumnIds[i];
 
                                 for (var j = 0, value; j < data.length; j++) {
-                                    value = data[j][replacedColumnIds[i]];
+                                    value = data[j][failSafeColumnIds[i]];
                                     regression.addData(j, parseFloat(value));
                                 }
 
@@ -1943,11 +1857,11 @@
                                 }
 
                                 trendLineFields.push(regressionKey);
-                                xResponse.metaData.names[regressionKey] = NS.i18n.trend + ' (' + xResponse.metaData.names[columnIds[i]] + ')';
+                                xResponse.metaData.names[regressionKey] = NS.i18n.trend + ' (' + xResponse.metaData.names[failSafeColumnIds[i]] + ')';
                             }
                         }
                     }
-                    
+
                     // target line
                     if (Ext.isNumber(xLayout.targetLineValue) || Ext.isNumber(parseFloat(xLayout.targetLineValue))) {
                         for (var i = 0; i < data.length; i++) {
@@ -1968,7 +1882,7 @@
 
                     store = Ext.create('Ext.data.Store', {
                         fields: function() {
-                            var fields = Ext.clone(columnIds);
+                            var fields = Ext.clone(failSafeColumnIds);
                             fields.push(conf.finals.data.domain);
                             fields = fields.concat(trendLineFields, targetLineFields, baseLineFields);
 
@@ -1977,7 +1891,7 @@
                         data: data
                     });
 
-                    store.rangeFields = columnIds;
+                    store.rangeFields = failSafeColumnIds;
                     store.domainFields = [conf.finals.data.domain];
                     store.trendLineFields = trendLineFields;
                     store.targetLineFields = targetLineFields;
@@ -2023,11 +1937,11 @@
 
                     store.hasDecimals = function() {
                         var records = store.getRange();
-                        
+
                         for (var i = 0; i < records.length; i++) {
                             for (var j = 0, value; j < store.rangeFields.length; j++) {
                                 value = records[i].data[store.rangeFields[j]];
-                                
+
                                 if (Ext.isNumber(value) && (value % 1)) {
                                     return true;
                                 }
@@ -2040,11 +1954,11 @@
                     store.getNumberOfDecimals = function() {
                         var records = store.getRange(),
                             values = [];
-                        
+
                         for (var i = 0; i < records.length; i++) {
                             for (var j = 0, value; j < store.rangeFields.length; j++) {
                                 value = records[i].data[store.rangeFields[j]];
-                                
+
                                 if (Ext.isNumber(value) && (value % 1)) {
                                     value = value.toString();
 
@@ -2140,7 +2054,7 @@
 
 					if (xLayout.rangeAxisDecimals) {
 						axis.label.renderer = Ext.util.Format.numberRenderer(getRenderer(xLayout.rangeAxisDecimals));
-					}                    
+					}
 
                     if (xLayout.rangeAxisTitle) {
                         axis.title = xLayout.rangeAxisTitle;
@@ -2182,7 +2096,7 @@
                     }
                     else {
                         for (var i = 0, id, name, mxl, ids; i < store.rangeFields.length; i++) {
-                            id = store.rangeFields[i];
+                            id = failSafeColumnIdMap[store.rangeFields[i]];
                             name = xResponse.metaData.names[id];
 
                             if (Ext.isObject(xLayout.legend) && xLayout.legend.maxLength) {
@@ -2192,7 +2106,7 @@
                                     name = name.substr(0, mxl) + '..';
                                 }
                             }
-                            
+
                             a.push(name);
                         }
                     }
@@ -2225,7 +2139,7 @@
                             field: store.rangeFields,
                             font: conf.chart.style.fontFamily,
                             renderer: function(n) {
-                                return n === '0.0' ? '' : n;                                    
+                                return n === '0.0' ? '' : n;
                             }
                         };
                     }
@@ -2238,7 +2152,7 @@
 
                     for (var i = 0, strokeColor; i < store.trendLineFields.length; i++) {
                         strokeColor = isStacked ? '#000' : conf.chart.theme.dv1[i];
-                        
+
                         a.push({
                             type: 'line',
                             axis: 'left',
@@ -2719,13 +2633,13 @@
 
                     // NB, always true for area charts as extjs area charts cannot handle nulls
                     xLayout.hideEmptyRows = true;
-                    
+
                     var store = getDefaultStore(true),
                         numericAxis = getDefaultNumericAxis(store),
                         categoryAxis = getDefaultCategoryAxis(store),
                         axes = [numericAxis, categoryAxis],
                         series = getDefaultSeries(store);
-                        
+
                     series.type = 'area';
                     series.style.opacity = 0.7;
                     series.style.lineWidth = 0;
@@ -2818,7 +2732,7 @@
                         store: store,
                         series: series
                     });
-                    
+
                     //chart.legend.position = 'right';
                     //chart.legend.isVertical = true;
                     chart.insetPadding = 40;
@@ -2866,7 +2780,7 @@
 
                         series.push(obj);
                     }
-                    
+
                     chart = getDefaultChart({
                         store: store,
                         axes: axes,
@@ -2898,13 +2812,12 @@
 
                     // overwrite items
                     columnIds = [columnIds[0]];
-                    replacedColumnIds = [replacedColumnIds[0]];
+                    failSafeColumnIds = [failSafeColumnIds[0]];
                     rowIds = [rowIds[0]];
-                    replacedRowIds = [replacedRowIds[0]];
 
                     // store
                     store = getDefaultStore();
-                    
+
                     // axis
                     axis = {
                         type: 'gauge',
@@ -2917,16 +2830,16 @@
 
                     // series, legendset
                     if (legendSet) {
-                        valueColor = service.mapLegend.getColorByValue(legendSet, store.getRange()[0].data[columnIds[0]]) || valueColor;
+                        valueColor = service.mapLegend.getColorByValue(legendSet, store.getRange()[0].data[failSafeColumnIds[0]]) || valueColor;
                     }
-                        
+
                     series = {
                         type: 'gauge',
                         field: store.rangeFields[0],
                         //donut: 5,
                         colorSet: [valueColor, '#ddd']
                     };
-                    
+
                     chart = getDefaultChart({
                         axes: [axis],
                         series: [series],
@@ -2944,7 +2857,7 @@
                     if (xLayout.showValues) {
                         chart.items.push(Ext.create('Ext.draw.Sprite', {
                             type: 'text',
-                            text: store.getRange()[0].data[columnIds[0]],
+                            text: store.getRange()[0].data[failSafeColumnIds[0]],
                             font: 'normal 26px ' + conf.chart.style.fontFamily,
                             fill: '#111',
                             height: 40,