dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #35243
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18093: Dashboard, event chart title bug fixed.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 18093 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-01-21 20:46:28 +0100
message:
Dashboard, event chart title bug fixed.
modified:
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-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-01-21 19:13:50 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/eventchart.js 2015-01-21 19:45:39 +0000
@@ -2635,7 +2635,8 @@
};
web.report.aggregate.createChart = function(ns, legendSet) {
- var xLayout = ns.app.xLayout,
+ var layout = ns.app.layout,
+ xLayout = ns.app.xLayout,
xResponse = ns.app.xResponse,
columnIds = xLayout.columnDimensionNames[0] ? xLayout.dimensionNameIdsMap[xLayout.columnDimensionNames[0]] : [],
failSafeColumnIds = [],
@@ -3424,31 +3425,102 @@
};
getDefaultChartTitle = function(store) {
- var ids = [],
+ var a = [],
text = '',
titleFont,
titleColor,
- isPie = xLayout.type === conf.finals.chart.pie,
- isGauge = xLayout.type === conf.finals.chart.gauge;
-
- if (isPie) {
- ids.push(columnIds[0]);
- }
- else if (isGauge) {
- ids.push(columnIds[0], rowIds[0]);
- }
-
- ids = Ext.Array.clean(ids.concat(filterIds || []));
-
- if (Ext.isArray(ids) && ids.length) {
- for (var i = 0; i < ids.length; i++) {
- text += xResponse.metaData.names[ids[i]];
- text += i < ids.length - 1 ? ', ' : '';
- }
+ names = xResponse.metaData.names,
+ operatorMap = {
+ 'EQ': '=',
+ 'GT': '>',
+ 'GE': '>=',
+ 'LT': '<',
+ 'LE': '<=',
+ 'NE': '!='
+ };
+
+ if (xLayout.startDate && xLayout.endDate) {
+ text = xLayout.startDate + ' - ' + xLayout.endDate;
}
if (xLayout.title) {
- text = xLayout.title;
+ text += (text.length ? ', ' : '') + xLayout.title;
+ }
+ else if (xLayout.type === conf.finals.chart.pie) {
+ var ids = Ext.Array.clean([].concat(columnIds || []));
+
+ if (Ext.isArray(ids) && ids.length) {
+ for (var i = 0; i < ids.length; i++) {
+ text += xResponse.metaData.names[ids[i]];
+ text += i < ids.length - 1 ? ', ' : '';
+ }
+ }
+ }
+ else {
+ var meta = ['pe', 'ou'];
+
+ if (layout.filters) {
+ for (var i = 0, dim; i < layout.filters.length; i++) {
+ dim = layout.filters[i];
+ text += (text.length ? ', ' : '');
+
+ 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]];
+ }
+
+ text += tmpText;
+ }
+ else {
+ if (dim.filter) {
+ var a = dim.filter.split(':');
+
+ if (a.length === 2) {
+ var operator = a[0],
+ valueArray = a[1].split(';'),
+ tmpText = '';
+
+ if (operator === 'IN') {
+ for (var ii = 0; ii < valueArray.length; ii++) {
+ tmpText += (tmpText.length ? ', ' : '') + valueArray[ii];
+ }
+
+ text += tmpText;
+ }
+ else {
+ text += names[dim.dimension] + ' ' + operatorMap[operator] + ' ' + a[1];
+ }
+ }
+ else {
+ var operators = [],
+ values = [],
+ tmpText = '';
+
+ for (var ii = 0; ii < a.length; ii++) {
+ if (ii % 2) {
+ values.push(a[ii]);
+ }
+ else {
+ operators.push(a[ii]);
+ }
+ }
+
+ for (var ii = 0; ii < operators.length; ii++) {
+ tmpText += (tmpText.length ? ', ' : '') + names[dim.dimension] + ' ' + (operatorMap[operators[ii]] || '') + ' ' + values[ii];
+ }
+
+ text += tmpText;
+ }
+ }
+ else {
+ text += names[dim.dimension];
+ }
+ }
+ }
+ }
}
fontSize = (ns.app.centerRegion.getWidth() / text.length) < 11.6 ? 12 : 17;