← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14404: DV, new option: hide empty category items + zeros/nulls visually separated.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 14404 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-03-25 15:17:45 +0100
message:
  DV, new option: hide empty category items + zeros/nulls visually separated.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml
  dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js
  dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/i18n.json
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/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-api/src/main/java/org/hisp/dhis/chart/Chart.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java	2014-03-25 14:01:51 +0000
@@ -105,6 +105,8 @@
     private String baseLineLabel;
 
     private boolean showData;
+    
+    private boolean hideEmptyRows;
 
     // -------------------------------------------------------------------------
     // Transient properties
@@ -492,6 +494,19 @@
     @JsonProperty
     @JsonView({ DetailedView.class, ExportView.class, DimensionalView.class })
     @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    public boolean isHideEmptyRows()
+    {
+        return hideEmptyRows;
+    }
+
+    public void setHideEmptyRows( boolean hideEmptyRows )
+    {
+        this.hideEmptyRows = hideEmptyRows;
+    }
+
+    @JsonProperty
+    @JsonView({ DetailedView.class, ExportView.class, DimensionalView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public boolean isRewindRelativePeriods()
     {
         return rewindRelativePeriods;
@@ -558,6 +573,7 @@
             baseLineValue = chart.getBaseLineValue() == null ? baseLineValue : chart.getBaseLineValue();
             baseLineLabel = chart.getBaseLineLabel() == null ? baseLineLabel : chart.getBaseLineLabel();
             showData = chart.isShowData();
+            hideEmptyRows = chart.isHideEmptyRows();
             rewindRelativePeriods = chart.isRewindRelativePeriods();
 
             filterDimensions.clear();

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2014-03-24 19:24:58 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2014-03-25 14:01:51 +0000
@@ -412,6 +412,7 @@
         executeSql( "update chart set regression = false where regression is null" );
         executeSql( "update chart set hidesubtitle = false where hidesubtitle is null" );
         executeSql( "update chart set userorganisationunit = false where userorganisationunit is null" );
+        executeSql( "update chart set hideemptyrows = false where hideemptyrows is null" );
         executeSql( "update indicator set annualized = false where annualized is null" );
         executeSql( "update indicatortype set indicatornumber = false where indicatornumber is null" );
         executeSql( "update dataset set mobile = false where mobile is null" );

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml	2014-02-12 15:47:58 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml	2014-03-25 14:01:51 +0000
@@ -158,6 +158,8 @@
 
     <property name="showData" />
 
+    <property name="hideEmptyRows" />
+
     <property name="rewindRelativePeriods" />
 
     <!-- Access properties -->

=== modified file 'dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js	2014-03-24 13:36:22 +0000
+++ dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js	2014-03-25 11:01:29 +0000
@@ -574,7 +574,7 @@
 			selectPanel,
 			window,
 
-			margin = 2,
+			margin = 1,
 			defaultWidth = 160,
 			defaultHeight = 158,
 			maxHeight = (ns.app.viewport.getHeight() - 100) / 2;
@@ -718,7 +718,14 @@
 							ms.boundList.getSelectionModel().deselectAll();
 						}, 10);
 					});
-				}
+				},
+                added: function(n1, n2, n3, n4) {
+                    console.log(arguments);
+                    nissa1 = n1;
+                    nissa2 = n2;
+                    nissa3 = n3;
+                    nissa4 = n4;
+                }
 			}
 		});
 
@@ -876,7 +883,7 @@
 
 		window = Ext.create('Ext.window.Window', {
 			title: NS.i18n.table_layout,
-			bodyStyle: 'background-color:#fff; padding:2px',
+			bodyStyle: 'background-color:#fff; padding:' + margin + 'px',
 			closeAction: 'hide',
 			autoShow: true,
 			modal: true,
@@ -963,7 +970,7 @@
 			dimensionPanel,
 			window,
 
-			margin = 2,
+			margin = 1,
 			defaultWidth = 160,
 			defaultHeight = 158,
 			maxHeight = (ns.app.viewport.getHeight() - 100) / 2;
@@ -1127,7 +1134,7 @@
 		window = Ext.create('Ext.window.Window', {
 			title: NS.i18n.table_layout,
             layout: 'column',
-			bodyStyle: 'background-color:#fff; padding:2px',
+			bodyStyle: 'background-color:#fff; padding:' + margin + 'px',
 			closeAction: 'hide',
 			autoShow: true,
 			modal: true,

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties	2014-02-08 18:09:18 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties	2014-03-25 14:13:37 +0000
@@ -214,4 +214,5 @@
 financial_july=Financial July
 financial_april=Financial April
 all_indicators=All indicators
-all_data_elements=All data elements
\ No newline at end of file
+all_data_elements=All data elements
+hide_empty_category_items=Hide empty category items
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/i18n.json'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/i18n.json	2014-02-08 18:09:18 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/i18n.json	2014-03-25 14:13:37 +0000
@@ -214,5 +214,6 @@
 "financial_july",
 "financial_april",
 "all_indicators",
-"all_data_elements"
+"all_data_elements",
+"hide_empty_category_items"
 ]

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js	2014-03-21 14:13:20 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js	2014-03-25 14:13:37 +0000
@@ -42,6 +42,7 @@
 			baseLineTitle,
 
 			showValues,
+            hideEmptyRows,
 			hideLegend,
 			hideTitle,
 			title,
@@ -114,6 +115,11 @@
 			checked: true
 		});
 
+		hideEmptyRows = Ext.create('Ext.form.field.Checkbox', {
+			boxLabel: NS.i18n.hide_empty_category_items,
+			style: 'margin-bottom:4px'
+		});
+
 		hideLegend = Ext.create('Ext.form.field.Checkbox', {
 			boxLabel: NS.i18n.hide_legend,
 			style: 'margin-bottom:4px'
@@ -204,6 +210,7 @@
 			style: 'margin-left:14px',
 			items: [
 				showValues,
+                hideEmptyRows,
 				hideLegend,
 				hideTitle,
 				title,
@@ -228,6 +235,7 @@
 					baseLineValue: baseLineValue.getValue(),
 					baseLineTitle: baseLineTitle.getValue(),
 					showValues: showValues.getValue(),
+                    hideEmptyRows: hideEmptyRows.getValue(),
 					hideLegend: hideLegend.getValue(),
 					hideTitle: hideTitle.getValue(),
 					title: title.getValue(),
@@ -238,6 +246,7 @@
 			setOptions: function(layout) {
 				showTrendLine.setValue(Ext.isBoolean(layout.showTrendLine) ? layout.showTrendLine : false);
 				showValues.setValue(Ext.isBoolean(layout.showValues) ? layout.showValues : false);
+				hideEmptyRows.setValue(Ext.isBoolean(layout.hideEmptyRows) ? layout.hideEmptyRows : false);
 				hideLegend.setValue(Ext.isBoolean(layout.hideLegend) ? layout.hideLegend : false);
 				hideTitle.setValue(Ext.isBoolean(layout.hideTitle) ? layout.hideTitle : false);
 
@@ -353,6 +362,7 @@
 					w.baseLineValue = baseLineValue;
 					w.baseLineTitle = baseLineTitle;
 					w.showValues = showValues;
+                    w.hideEmptyRows = hideEmptyRows;
 					w.hideLegend = hideLegend;
 					w.hideTitle = hideTitle;
 					w.title = title;

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js	2014-03-25 08:50:07 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js	2014-03-25 14:13:37 +0000
@@ -315,6 +315,8 @@
 
                 // showValues: boolean (true)
 
+                // hideEmptyRows: boolean (false)
+
                 // hideLegend: boolean (false)
 
                 // hideTitle: boolean (false)
@@ -541,6 +543,7 @@
                     // properties
                     layout.showTrendLine = Ext.isBoolean(config.regression) ? config.regression : (Ext.isBoolean(config.showTrendLine) ? config.showTrendLine : false);
                     layout.showValues = Ext.isBoolean(config.showData) ? config.showData : (Ext.isBoolean(config.showValues) ? config.showValues : true);
+                    layout.hideEmptyRows = Ext.isBoolean(config.hideEmptyRows) ? config.hideEmptyRows : (Ext.isBoolean(config.hideEmptyRows) ? config.hideEmptyRows : true);
 
                     layout.hideLegend = Ext.isBoolean(config.hideLegend) ? config.hideLegend : false;
                     layout.hideTitle = Ext.isBoolean(config.hideTitle) ? config.hideTitle : false;
@@ -1698,18 +1701,28 @@
                         store;
 
                     // data
-                    for (var i = 0, obj, category; i < rowIds.length; i++) {
+                    for (var i = 0, obj, category, rowValues, isEmpty; i < rowIds.length; i++) {
                         obj = {};
                         category = rowIds[i];
+                        rowValues = [];
+                        isEmpty = false;
+                        
 
                         obj[conf.finals.data.domain] = xResponse.metaData.names[category];
-                        for (var j = 0, id; j < columnIds.length; j++) {
+                        
+                        for (var j = 0, id, value; j < columnIds.length; j++) {
                             id = support.prototype.str.replaceAll(columnIds[j], '#', '') + support.prototype.str.replaceAll(rowIds[i], '#', '');
-
-                            obj[columnIds[j]] = parseFloat(xResponse.idValueMap[id]) || 0;
-                        }
-
-                        data.push(obj);
+                            value = xResponse.idValueMap[id];
+                            rowValues.push(value);
+
+                            obj[columnIds[j]] = value ? parseFloat(value) : '0.0';
+                        }
+
+                        isEmpty = !(Ext.Array.clean(rowValues).length);
+
+                        if (!(isEmpty && xLayout.hideEmptyRows)) {
+                            data.push(obj);
+                        }
                     }
 
                     // trend lines
@@ -1943,7 +1956,10 @@
                             display: 'outside',
                             'text-anchor': 'middle',
                             field: store.rangeFields,
-                            font: conf.chart.style.fontFamily
+                            font: conf.chart.style.fontFamily,
+                            renderer: function(n) {
+                                return n === '0.0' ? '-' : n;                                    
+                            }
                         };
                     }
 
@@ -2014,7 +2030,8 @@
                         trackMouse: true,
                         cls: 'dv-chart-tips',
                         renderer: function(si, item) {
-                            this.update('<div style="text-align:center"><div style="font-size:17px; font-weight:bold">' + item.value[1] + '</div><div style="font-size:10px">' + si.data[conf.finals.data.domain] + '</div></div>');
+                            var value = item.value[1] === '0.0' ? '-' : item.value[1];
+                            this.update('<div style="text-align:center"><div style="font-size:17px; font-weight:bold">' + value + '</div><div style="font-size:10px">' + si.data[conf.finals.data.domain] + '</div></div>');
                         }
                     };
                 };