dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16239
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6131: (DV) Base line implemented.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 6131 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-02-28 12:47:37 +0100
message:
(DV) Base line implemented.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.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-visualizer/src/main/java/org/hisp/dhis/visualizer/action/AddOrUpdateChartAction.java
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/app.js
dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/css/style.css
dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/i18n.vm
--
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 2012-01-23 19:44:06 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2012-02-28 10:53:00 +0000
@@ -112,6 +112,10 @@
private String targetLineLabel;
+ private Double baseLineValue;
+
+ private String baseLineLabel;
+
private List<Indicator> indicators = new ArrayList<Indicator>();
private List<DataElement> dataElements = new ArrayList<DataElement>();
@@ -301,6 +305,11 @@
return targetLineValue != null;
}
+ public boolean isBaseLine()
+ {
+ return baseLineValue != null;
+ }
+
public int getWidth()
{
return 700;
@@ -437,6 +446,30 @@
@XmlElement
@JsonProperty
+ public Double getBaseLineValue()
+ {
+ return baseLineValue;
+ }
+
+ public void setBaseLineValue( Double baseLineValue )
+ {
+ this.baseLineValue = baseLineValue;
+ }
+
+ @XmlElement
+ @JsonProperty
+ public String getBaseLineLabel()
+ {
+ return baseLineLabel;
+ }
+
+ public void setBaseLineLabel( String baseLineLabel )
+ {
+ this.baseLineLabel = baseLineLabel;
+ }
+
+ @XmlElement
+ @JsonProperty
public boolean isHideSubtitle()
{
return hideSubtitle;
=== 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 2012-02-20 16:09:57 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml 2012-02-28 10:53:00 +0000
@@ -40,6 +40,10 @@
<property name="targetLineLabel" />
+ <property name="baseLineValue" />
+
+ <property name="baseLineLabel" />
+
<list name="indicators" table="chart_indicators">
<cache usage="read-write" />
<key column="chartid" foreign-key="fk_chart_indicators_chartid" />
=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/AddOrUpdateChartAction.java'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/AddOrUpdateChartAction.java 2012-02-27 16:33:08 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/AddOrUpdateChartAction.java 2012-02-28 10:53:00 +0000
@@ -292,6 +292,20 @@
{
this.targetLineLabel = targetLineLabel;
}
+
+ private Double baseLineValue;
+
+ public void setBaseLineValue( Double baseLineValue )
+ {
+ this.baseLineValue = baseLineValue;
+ }
+
+ private String baseLineLabel;
+
+ public void setBaseLineLabel( String baseLineLabel )
+ {
+ this.baseLineLabel = baseLineLabel;
+ }
// -------------------------------------------------------------------------
// Action implementation
@@ -434,6 +448,9 @@
chart.setTargetLineValue( targetLineValue );
chart.setTargetLineLabel( targetLineLabel );
+
+ chart.setBaseLineValue( baseLineValue );
+ chart.setBaseLineLabel( baseLineLabel );
chartService.saveOrUpdate( chart );
=== 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 2012-02-27 19:24:45 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties 2012-02-28 11:43:07 +0000
@@ -89,6 +89,9 @@
datasets=Data sets
no_datasets_selected=No data sets selected
reporting_rates=Reporting rates
+base_line_value=Base line value
+base_line_label=Base line label
+base=Base
et_no_data=No data returned from server
em_no_data=Please ensure that there is stored data in the database and that data mart has been run properly.
et_invalid_dimension_setup=Invalid dimension setup
@@ -107,6 +110,7 @@
em_svg_browser=Please use Chrome, Firefox, Opera or Safari to export images.
wm_trendline_deactivated=Trend line deactivated
wm_targetline_deactivated=Target line deactivated
+wm_baseline_deactivated=Base line deactivated
wm_not_applicable=not applicable for
wm_stacked_chart=stacked charts
wm_pie_chart=pie charts
=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js 2012-02-27 19:39:46 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js 2012-02-28 11:43:07 +0000
@@ -146,6 +146,7 @@
data: {
domain: 'domain_',
targetline: 'targetline_',
+ baseline: 'baseline_',
trendline: 'trendline_'
},
image: {
@@ -184,8 +185,10 @@
window_favorite_ypos: 100,
window_confirm_width: 250,
grid_favorite_width: 420,
+ treepanel_minheight: 135,
treepanel_maxheight: 400,
treepanel_fill_default: 310,
+ multiselect_minheight: 100,
multiselect_maxheight: 250,
multiselect_fill_default: 345,
multiselect_fill_reportingrates: 315
@@ -325,9 +328,10 @@
var h1 = DV.cmp.region.west.getHeight();
var h2 = DV.cmp.options.panel.getHeight();
var h = h1 - h2 - fill;
- var m = DV.conf.layout.multiselect_maxheight;
+ var mx = DV.conf.layout.multiselect_maxheight;
+ var mn = DV.conf.layout.multiselect_minheight;
for (var i = 0; i < ms.length; i++) {
- ms[i].setHeight(h > m ? m : h);
+ ms[i].setHeight(h > mx ? mx : h < mn ? mn : h);
}
}
},
@@ -370,8 +374,9 @@
var h1 = DV.cmp.region.west.getHeight();
var h2 = DV.cmp.options.panel.getHeight();
var h = h1 - h2 - DV.conf.layout.treepanel_fill_default;
- var m = DV.conf.layout.treepanel_maxheight;
- return h > m ? m : h;
+ var mx = DV.conf.layout.treepanel_maxheight;
+ var mn = DV.conf.layout.treepanel_minheight;
+ return h > mx ? mx : h < mn ? mn : h;
}
},
button: {
@@ -806,6 +811,26 @@
title: title
};
},
+ getBaseLine: function() {
+ var title = DV.state.baseLineLabel || DV.i18n.base;
+ title += ' (' + DV.state.baseLineValue + ')';
+ return {
+ type: 'line',
+ axis: 'left',
+ xField: DV.conf.finals.data.domain,
+ yField: DV.conf.finals.data.baseline,
+ style: {
+ opacity: 1,
+ lineWidth: 3,
+ stroke: '#051a2e'
+ },
+ markerConfig: {
+ type: 'circle',
+ radius: 0
+ },
+ title: title
+ };
+ },
getTrendLineArray: function() {
var a = [];
for (var i = 0; i < DV.chart.trendLine.length; i++) {
@@ -830,9 +855,15 @@
},
setTheme: function() {
var colors = DV.conf.chart.theme.dv1.slice(0, DV.state.series.names.length);
+ if (DV.state.targetLineValue || DV.state.baseLine) {
+ colors.push('#051a2e');
+ }
if (DV.state.targetLineValue) {
- colors.push('#051a2e', '#051a2e');
- }
+ colors.push('#051a2e');
+ }
+ if (DV.state.baseLineValue) {
+ colors.push('#051a2e');
+ }
Ext.chart.theme.dv1 = Ext.extend(Ext.chart.theme.Base, {
constructor: function(config) {
Ext.chart.theme.Base.prototype.constructor.call(this, Ext.apply({
@@ -876,11 +907,18 @@
};
},
getTargetLine: function() {
- var tl = DV.util.chart.default.series.getTargetLine();
- tl.axis = 'bottom';
- tl.xField = DV.conf.finals.data.targetline;
- tl.yField = DV.conf.finals.data.domain;
- return tl;
+ var line = DV.util.chart.default.series.getTargetLine();
+ line.axis = 'bottom';
+ line.xField = DV.conf.finals.data.targetline;
+ line.yField = DV.conf.finals.data.domain;
+ return line;
+ },
+ getBaseLine: function() {
+ var line = DV.util.chart.default.series.getBaseLine();
+ line.axis = 'bottom';
+ line.xField = DV.conf.finals.data.baseline;
+ line.yField = DV.conf.finals.data.domain;
+ return line;
},
getTrendLineArray: function() {
var a = [];
@@ -1239,6 +1277,7 @@
isLoaded: false,
listeners: {
load: function(s) {
+ this.isLoaded = true;
DV.util.store.addToStorage(s);
DV.util.multiselect.filterAvailable(DV.cmp.dimension.dataset.available, DV.cmp.dimension.dataset.selected);
}
@@ -1392,6 +1431,8 @@
this.validation.targetline.call(this);
+ this.validation.baseline.call(this);
+
this.validation.render.call(this);
if (exe) {
@@ -1407,6 +1448,8 @@
this.rangeAxisLabel = DV.cmp.favorite.rangeaxislabel.getValue();
this.targetLineValue = parseFloat(DV.cmp.favorite.targetlinevalue.getValue());
this.targetLineLabel = DV.cmp.favorite.targetlinelabel.getValue();
+ this.baseLineValue = parseFloat(DV.cmp.favorite.baselinevalue.getValue());
+ this.baseLineLabel = DV.cmp.favorite.baselinelabel.getValue();
},
getParams: function() {
var obj = {};
@@ -1420,6 +1463,8 @@
obj.rangeAxisLabel = DV.cmp.favorite.rangeaxislabel.getValue();
obj.targetLineValue = DV.cmp.favorite.targetlinevalue.getValue();
obj.targetLineLabel = (obj.targetLineValue && !DV.cmp.favorite.targetlinelabel.isDisabled()) ? DV.cmp.favorite.targetlinelabel.getValue() : null;
+ obj.baseLineValue = DV.cmp.favorite.baselinevalue.getValue();
+ obj.baseLineLabel = (obj.baseLineValue && !DV.cmp.favorite.baselinelabel.isDisabled()) ? DV.cmp.favorite.baselinelabel.getValue() : null;
obj.series = this.series.dimension.toUpperCase();
obj.category = this.category.dimension.toUpperCase();
@@ -1456,8 +1501,8 @@
f.type = f.type.toLowerCase();
f.series = f.series.toLowerCase();
f.category = f.category.toLowerCase();
- f.filter = f.filter.toLowerCase();
-
+ f.filter = f.filter.toLowerCase();
+
f.names = {
data: [],
period: [],
@@ -1467,13 +1512,15 @@
this.type = f.type;
this.hideSubtitle = f.hideSubtitle;
- this.hideLegend = f.hideLegend;
+ this.hideLegend = f.hideLegend;
this.trendLine = f.regression;
this.userOrganisationUnit = f.userOrganisationUnit;
this.domainAxisLabel = f.domainAxisLabel;
this.rangeAxisLabel = f.rangeAxisLabel;
this.targetLineValue = f.targetLineValue ? parseFloat(f.targetLineValue) : null;
this.targetLineLabel = f.targetLineLabel ? f.targetLineLabel : null;
+ this.baseLineValue = f.baseLineValue ? parseFloat(f.baseLineValue) : null;
+ this.baseLineLabel = f.baseLineLabel ? f.baseLineLabel : null;
this.series.dimension = f.series;
this.category.dimension = f.category;
@@ -1487,6 +1534,8 @@
this.validation.targetline.call(this);
+ this.validation.baseline.call(this);
+
if (f.indicators) {
for (var i = 0; i < f.indicators.length; i++) {
indiment.push(f.indicators[i]);
@@ -1558,6 +1607,9 @@
DV.cmp.favorite.targetlinevalue.setValue(f.targetLineValue);
DV.cmp.favorite.targetlinelabel.xable();
DV.cmp.favorite.targetlinelabel.setValue(f.targetLineLabel);
+ DV.cmp.favorite.baselinevalue.setValue(f.baseLineValue);
+ DV.cmp.favorite.baselinelabel.xable();
+ DV.cmp.favorite.baselinelabel.setValue(f.baseLineLabel);
DV.cmp.settings.series.setValue(DV.conf.finals.dimension[f.series].value);
DV.util.combobox.filter.category();
@@ -1701,6 +1753,34 @@
}
}
},
+ baseline: function() {
+ if (this.baseLineValue) {
+ var reasons = [];
+ if (this.type === DV.conf.finals.chart.stackedcolumn || this.type === DV.conf.finals.chart.stackedbar || this.type === DV.conf.finals.chart.area) {
+ reasons.push(DV.i18n.wm_not_applicable + ' ' + DV.i18n.wm_stacked_chart);
+ this.baseLineValue = null;
+ }
+ else if (this.type === DV.conf.finals.chart.pie) {
+ reasons.push(DV.i18n.wm_not_applicable + ' ' + DV.i18n.wm_pie_chart);
+ this.baseLineValue = null;
+ }
+
+ if (this.category.names.length < 2) {
+ reasons.push(DV.i18n.wm_required_categories);
+ this.baseLineValue = null;
+ }
+
+ if (reasons.length) {
+ var text = DV.i18n.wm_baseline_deactivated + ' (';
+ for (var i = 0; i < reasons.length; i++) {
+ text += i > 0 ? ' + ' : '';
+ text += reasons[i];
+ }
+ text += ').';
+ DV.exe.warnings.push(text);
+ }
+ }
+ },
render: function() {
if (!this.isRendered) {
DV.cmp.toolbar.datatable.enable();
@@ -1827,6 +1907,12 @@
item[DV.conf.finals.data.targetline] = DV.state.targetLineValue;
});
}
+
+ if (DV.state.baseLineValue) {
+ Ext.Array.each(DV.chart.data, function(item) {
+ item[DV.conf.finals.data.baseline] = DV.state.baseLineValue;
+ });
+ }
if (exe) {
DV.store.getChartStore(true);
@@ -1868,6 +1954,9 @@
if (DV.state.targetLineValue) {
series.push(DV.util.chart.default.series.getTargetLine());
}
+ if (DV.state.baseLineValue) {
+ series.push(DV.util.chart.default.series.getBaseLine());
+ }
var axes = [];
var numeric = DV.util.chart.default.axis.getNumeric(stacked);
@@ -1903,6 +1992,9 @@
if (DV.state.targetLineValue) {
series.push(DV.util.chart.bar.series.getTargetLine());
}
+ if (DV.state.baseLineValue) {
+ series.push(DV.util.chart.bar.series.getBaseLine());
+ }
var axes = [];
var numeric = DV.util.chart.bar.axis.getNumeric(stacked);
@@ -1927,6 +2019,9 @@
if (DV.state.targetLineValue) {
series.push(DV.util.chart.default.series.getTargetLine());
}
+ if (DV.state.baseLineValue) {
+ series.push(DV.util.chart.default.series.getBaseLine());
+ }
var axes = [];
var numeric = DV.util.chart.default.axis.getNumeric();
@@ -2730,6 +2825,7 @@
{
xtype: 'fieldset',
cls: 'dv-fieldset',
+ style: 'padding-bottom:7px',
name: DV.conf.finals.dimension.period.value,
title: '<a href="javascript:DV.util.fieldset.togglePeriod();" class="dv-fieldset-title-link">' + DV.i18n.periods +'</a>',
collapsed: true,
@@ -3109,7 +3205,7 @@
{
xtype: 'panel',
layout: 'column',
- bodyStyle: 'border:0 none; background-color:transparent; padding-bottom:5px',
+ bodyStyle: 'border:0 none; background-color:transparent; padding-bottom:8px',
items: [
{
xtype: 'numberfield',
@@ -3158,6 +3254,59 @@
}
}
]
+ },
+ {
+ xtype: 'panel',
+ layout: 'column',
+ bodyStyle: 'border:0 none; background-color:transparent; padding-bottom:5px',
+ items: [
+ {
+ xtype: 'numberfield',
+ cls: 'dv-textfield-alt1',
+ style: 'margin-right:5px',
+ hideTrigger: true,
+ fieldLabel: DV.i18n.base_line_value,
+ labelAlign: 'top',
+ labelSeparator: '',
+ maxLength: 100,
+ enforceMaxLength: true,
+ width: 199,
+ spinUpEnabled: true,
+ spinDownEnabled: true,
+ listeners: {
+ added: function() {
+ DV.cmp.favorite.baselinevalue = this;
+ },
+ change: function() {
+ DV.cmp.favorite.baselinelabel.xable();
+ }
+ }
+ },
+ {
+ xtype: 'textfield',
+ cls: 'dv-textfield-alt1',
+ fieldLabel: DV.i18n.base_line_label,
+ labelAlign: 'top',
+ labelSeparator: '',
+ maxLength: 100,
+ enforceMaxLength: true,
+ width: 199,
+ disabled: true,
+ xable: function() {
+ if (DV.cmp.favorite.baselinevalue.getValue()) {
+ this.enable();
+ }
+ else {
+ this.disable();
+ }
+ },
+ listeners: {
+ added: function() {
+ DV.cmp.favorite.baselinelabel = this;
+ }
+ }
+ }
+ ]
}
],
listeners: {
=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/css/style.css'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/css/style.css 2012-02-27 19:24:45 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/css/style.css 2012-02-28 08:28:39 +0000
@@ -67,7 +67,7 @@
-khtml-border-radius: 2px 2px 2px 2px;
border-radius: 2px 2px 2px 2px;
padding-top: 8px;
- padding-bottom: 8px;
+ padding-bottom: 4px;
}
/* Fieldset header */
=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/i18n.vm'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/i18n.vm 2012-02-27 19:24:45 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/i18n.vm 2012-02-28 11:43:07 +0000
@@ -90,6 +90,9 @@
datasets:'$encoder.jsEscape($i18n.getString( 'datasets' ) , "'")',
no_datasets_selected:'$encoder.jsEscape($i18n.getString( 'no_datasets_selected' ) , "'")',
reporting_rates:'$encoder.jsEscape($i18n.getString( 'reporting_rates' ) , "'")',
+base_line_value:'$encoder.jsEscape($i18n.getString( 'base_line_value' ) , "'")',
+base_line_label:'$encoder.jsEscape($i18n.getString( 'base_line_label' ) , "'")',
+base:'$encoder.jsEscape($i18n.getString( 'base' ) , "'")',
et_no_data:'$encoder.jsEscape($i18n.getString( 'et_no_data' ) , "'")',
em_no_data:'$encoder.jsEscape($i18n.getString( 'em_no_data' ) , "'")',
et_invalid_dimension_setup:'$encoder.jsEscape($i18n.getString( 'et_invalid_dimension_setup' ) , "'")',
@@ -108,6 +111,7 @@
em_svg_browser:'$encoder.jsEscape($i18n.getString( 'em_svg_browser' ) , "'")',
wm_trendline_deactivated:'$encoder.jsEscape($i18n.getString( 'wm_trendline_deactivated' ) , "'")',
wm_targetline_deactivated:'$encoder.jsEscape($i18n.getString( 'wm_targetline_deactivated' ) , "'")',
+wm_baseline_deactivated:'$encoder.jsEscape($i18n.getString( 'wm_baseline_deactivated' ) , "'")',
wm_not_applicable:'$encoder.jsEscape($i18n.getString( 'wm_not_applicable' ) , "'")',
wm_stacked_chart:'$encoder.jsEscape($i18n.getString( 'wm_stacked_chart' ) , "'")',
wm_pie_chart:'$encoder.jsEscape($i18n.getString( 'wm_pie_chart' ) , "'")',