← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19134: EV plugin/dashboard title fix.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 19134 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-05-11 20:51:57 +0200
message:
  EV plugin/dashboard title fix.
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-event-visualizer/scripts/eventchart.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/eventchart.js
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/eventchart.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	2015-05-11 13:04:51 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/core.js	2015-05-11 18:50:29 +0000
@@ -842,9 +842,8 @@
 				}();
 			};
 
-			api.layout.Layout = function(config) {
-				var config = Ext.clone(config),
-					layout = {},
+			api.layout.Layout = function(config, applyConfig) {
+				var layout = {},
 					getValidatedDimensionArray,
 					validateSpecialCases;
 
@@ -1157,7 +1156,7 @@
 						return;
 					}
 
-					return layout;
+                    return Ext.apply(layout, applyConfig);
 				}();
 			};
 
@@ -3851,6 +3850,8 @@
                     var a = [],
                         text = '',
                         fontSize,
+                        titleFont,
+                        titleColor,
                         md = xResponse.metaData,
                         operatorMap = {
                             'EQ': '=',
@@ -3865,7 +3866,10 @@
                         text = xLayout.startDate + ' - ' + xLayout.endDate;
                     }
 
-                    if (xLayout.title) {
+                    if (ns.dashboard && Ext.isString(xLayout.name)) {
+                        text = xLayout.name;
+                    }
+                    else if (xLayout.title) {
                         text += (text.length ? ', ' : '') + xLayout.title;
                     }
                     else if (xLayout.type === conf.finals.chart.pie) {
@@ -3949,22 +3953,40 @@
                     }
 
                     // aggregation type
-                    if (Ext.isObject(layout.value) && layout.value.id && layout.aggregationType) {
+                    if (!ns.dashboard && Ext.isObject(layout.value) && layout.value.id && layout.aggregationType) {
                         var value = layout.value.id;
 
                         text += text.length ? ', ' : '';
                         text += (md.booleanNames[value] || md.optionNames[value] || md.names[value] || value) + ' (' + conf.aggregationType.idNameMap[layout.aggregationType] + ')';
                     }
 
-                    fontSize = (centerRegion.getWidth() / text.length) < 11.6 ? 13 : 18;
+                    fontSize = (centerRegion.getWidth() / text.length) < 11.6 ? 12 : 17;
+                    titleFont = 'normal ' + fontSize + 'px ' + conf.chart.style.fontFamily;
+                    titleColor = 'black';
+
+                    // legend
+                    if (Ext.isObject(xLayout.legendStyle)) {
+                        var style = xLayout.legendStyle;
+
+                        titleColor = style.titleColor || titleColor;
+
+                        if (style.titleFont) {
+                            titleFont = style.titleFont;
+                        }
+                        else {
+                            titleFont = style.titleFontWeight ? style.titleFontWeight + ' ' : 'normal ';
+                            titleFont += style.titleFontSize ? parseFloat(style.titleFontSize) + 'px ' : (fontSize + 'px ');
+                            titleFont +=  style.titleFontFamily ? style.titleFontFamily : conf.chart.style.fontFamily;
+                        }
+                    }
 
                     return Ext.create('Ext.draw.Sprite', {
                         type: 'text',
                         text: text,
-                        font: 'bold ' + fontSize + 'px ' + conf.chart.style.fontFamily,
-                        fill: '#111',
+                        font: titleFont,
+                        fill: titleColor,
                         height: 20,
-                        y: 	20
+                        y: ns.dashboard ? 7 : 20
                     });
                 };
 

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/eventchart.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/eventchart.js	2015-05-11 13:04:51 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/eventchart.js	2015-05-11 18:48:22 +0000
@@ -925,9 +925,8 @@
 				}();
 			};
 
-			api.layout.Layout = function(config) {
-				var config = Ext.clone(config),
-					layout = {},
+			api.layout.Layout = function(config, applyConfig) {
+				var layout = {},
 					getValidatedDimensionArray,
 					validateSpecialCases;
 
@@ -1240,7 +1239,7 @@
 						return;
 					}
 
-					return layout;
+                    return Ext.apply(layout, applyConfig);
 				}();
 			};
 
@@ -3950,7 +3949,10 @@
                         text = xLayout.startDate + ' - ' + xLayout.endDate;
                     }
 
-                    if (xLayout.title) {
+                    if (ns.dashboard && Ext.isString(xLayout.name)) {
+                        text = xLayout.name;
+                    }
+                    else if (xLayout.title) {
                         text += (text.length ? ', ' : '') + xLayout.title;
                     }
                     else if (xLayout.type === conf.finals.chart.pie) {
@@ -4034,7 +4036,7 @@
                     }
 
                     // aggregation type
-                    if (Ext.isObject(layout.value) && layout.value.id && layout.aggregationType) {
+                    if (!ns.dashboard && Ext.isObject(layout.value) && layout.value.id && layout.aggregationType) {
                         var value = layout.value.id;
 
                         text += text.length ? ', ' : '';

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/eventchart.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/eventchart.js	2015-05-11 13:44:29 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/eventchart.js	2015-05-11 18:48:22 +0000
@@ -925,9 +925,8 @@
 				}();
 			};
 
-			api.layout.Layout = function(config) {
-				var config = Ext.clone(config),
-					layout = {},
+			api.layout.Layout = function(config, applyConfig) {
+				var layout = {},
 					getValidatedDimensionArray,
 					validateSpecialCases;
 
@@ -1240,7 +1239,7 @@
 						return;
 					}
 
-					return layout;
+                    return Ext.apply(layout, applyConfig);
 				}();
 			};
 
@@ -3950,7 +3949,10 @@
                         text = xLayout.startDate + ' - ' + xLayout.endDate;
                     }
 
-                    if (xLayout.title) {
+                    if (ns.dashboard && Ext.isString(xLayout.name)) {
+                        text = xLayout.name;
+                    }
+                    else if (xLayout.title) {
                         text += (text.length ? ', ' : '') + xLayout.title;
                     }
                     else if (xLayout.type === conf.finals.chart.pie) {
@@ -4034,7 +4036,7 @@
                     }
 
                     // aggregation type
-                    if (Ext.isObject(layout.value) && layout.value.id && layout.aggregationType) {
+                    if (!ns.dashboard && Ext.isObject(layout.value) && layout.value.id && layout.aggregationType) {
                         var value = layout.value.id;
 
                         text += text.length ? ', ' : '';

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/eventchart.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/eventchart.js	2015-05-11 13:44:29 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/eventchart.js	2015-05-11 18:48:22 +0000
@@ -925,9 +925,8 @@
 				}();
 			};
 
-			api.layout.Layout = function(config) {
-				var config = Ext.clone(config),
-					layout = {},
+			api.layout.Layout = function(config, applyConfig) {
+				var layout = {},
 					getValidatedDimensionArray,
 					validateSpecialCases;
 
@@ -1240,7 +1239,7 @@
 						return;
 					}
 
-					return layout;
+                    return Ext.apply(layout, applyConfig);
 				}();
 			};
 
@@ -3950,7 +3949,10 @@
                         text = xLayout.startDate + ' - ' + xLayout.endDate;
                     }
 
-                    if (xLayout.title) {
+                    if (ns.dashboard && Ext.isString(xLayout.name)) {
+                        text = xLayout.name;
+                    }
+                    else if (xLayout.title) {
                         text += (text.length ? ', ' : '') + xLayout.title;
                     }
                     else if (xLayout.type === conf.finals.chart.pie) {
@@ -4034,7 +4036,7 @@
                     }
 
                     // aggregation type
-                    if (Ext.isObject(layout.value) && layout.value.id && layout.aggregationType) {
+                    if (!ns.dashboard && Ext.isObject(layout.value) && layout.value.id && layout.aggregationType) {
                         var value = layout.value.id;
 
                         text += text.length ? ', ' : '';