=== 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 2011-04-08 10:48:03 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2011-04-14 13:06:10 +0000 @@ -77,6 +77,10 @@ private Boolean horizontalPlotOrientation; private Boolean regression; + + private Boolean targetLine; + + private Double targetLineValue; private List indicators = new ArrayList(); @@ -204,6 +208,11 @@ { return regression != null && regression; } + + public boolean isTargetLine() + { + return targetLine != null && targetLine; + } public int getWidth() { @@ -327,6 +336,26 @@ { this.regression = regression; } + + public void setTargetLine( Boolean targetLine ) + { + this.targetLine = targetLine; + } + + public Boolean getTargetLine() + { + return targetLine; + } + + public void setTargetLineValue( Double targetLineValue ) + { + this.targetLineValue = targetLineValue; + } + + public Double getTargetLineValue() + { + return targetLineValue; + } public List getIndicators() { === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java' --- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2011-04-10 10:59:28 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2011-04-14 13:06:10 +0000 @@ -414,12 +414,25 @@ } /** + * Returns a line and shape renderer (for target lines). + */ + private LineAndShapeRenderer getTargetLineRenderer() + { + LineAndShapeRenderer renderer = new LineAndShapeRenderer(); + renderer.setBaseShapesVisible( false ); + renderer.setBasePaint( Color.BLUE ); + + return renderer; + } + + /** * Returns a JFreeChart of type defined in the chart argument. */ private JFreeChart getJFreeChart( Chart chart, boolean subTitle ) { final BarRenderer barRenderer = getBarRenderer(); final LineAndShapeRenderer lineRenderer = getLineRenderer(); + final LineAndShapeRenderer targetLineRenderer = getTargetLineRenderer(); // --------------------------------------------------------------------- // Plot @@ -489,6 +502,12 @@ plot.setRenderer( 1, lineRenderer ); } + if ( chart.isTargetLine() ) + { + plot.setDataset( 2, dataSets[2] ); + plot.setRenderer( 2, targetLineRenderer ); + } + JFreeChart jFreeChart = new JFreeChart( chart.getTitle(), titleFont, plot, !chart.isHideLegend() ); if ( subTitle ) @@ -532,6 +551,7 @@ final DefaultCategoryDataset regularDataSet = new DefaultCategoryDataset(); final DefaultCategoryDataset regressionDataSet = new DefaultCategoryDataset(); + final DefaultCategoryDataset targetDataSet = new DefaultCategoryDataset(); if ( chart != null ) { @@ -599,6 +619,15 @@ } } } + + if ( chart.isTargetLine() ) + { + for ( Period period : chart.getAllPeriods() ) + { + targetDataSet.addValue( chart.getTargetLineValue(), indicator.getShortName(), chart + .getFormat().formatPeriod( period ) ); + } + } } else if ( chart.isDimension( DIMENSION_ORGANISATIONUNIT ) ) { @@ -625,7 +654,7 @@ } } - return new CategoryDataset[] { regularDataSet, regressionDataSet }; + return new CategoryDataset[] { regularDataSet, regressionDataSet, targetDataSet }; } /** === 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 2011-04-12 13:30:10 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml 2011-04-14 13:06:10 +0000 @@ -26,6 +26,10 @@ + + + + === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java' --- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java 2011-01-13 15:44:09 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java 2011-04-14 13:06:10 +0000 @@ -77,14 +77,14 @@ { this.periodService = periodService; } - + private OrganisationUnitService organisationUnitService; public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) { this.organisationUnitService = organisationUnitService; } - + // ------------------------------------------------------------------------- // Input // ------------------------------------------------------------------------- @@ -95,7 +95,7 @@ { this.id = id; } - + private String title; public void setTitle( String title ) @@ -109,7 +109,7 @@ { this.type = type; } - + private String size; public void setSize( String size ) @@ -123,21 +123,21 @@ { this.dimension = dimension; } - + private boolean hideLegend; public void setHideLegend( boolean hideLegend ) { this.hideLegend = hideLegend; } - + private boolean verticalLabels; public void setVerticalLabels( boolean verticalLabels ) { this.verticalLabels = verticalLabels; } - + private boolean horizontalPlotOrientation; public void setHorizontalPlotOrientation( boolean horizontalPlotOrientation ) @@ -151,9 +151,23 @@ { this.regression = regression; } - + + private boolean targetLine; + + public void setTargetLine( boolean targetLine ) + { + this.targetLine = targetLine; + } + + private Double targetLineValue; + + public void setTargetLineValue( Double targetLineValue ) + { + this.targetLineValue = targetLineValue; + } + private boolean userOrganisationUnit; - + public void setUserOrganisationUnit( boolean userOrganisationUnit ) { this.userOrganisationUnit = userOrganisationUnit; @@ -223,7 +237,7 @@ } private boolean lastYear; - + public void setLastYear( boolean lastYear ) { this.lastYear = lastYear; @@ -240,19 +254,19 @@ List indicators = new ArrayList(); List organisationUnits = new ArrayList(); List periods = new ArrayList( periodService.getPeriodsByExternalIds( selectedPeriods ) ); - + for ( Integer id : getIntegerCollection( selectedIndicators ) ) { indicators.add( indicatorService.getIndicator( id ) ); } - + for ( Integer id : getIntegerCollection( selectedOrganisationUnits ) ) { organisationUnits.add( organisationUnitService.getOrganisationUnit( id ) ); } - + Collections.sort( periods, new AscendingPeriodComparator() ); - + chart.setTitle( title ); chart.setType( type ); chart.setSize( size ); @@ -261,17 +275,20 @@ chart.setVerticalLabels( verticalLabels ); chart.setHorizontalPlotOrientation( horizontalPlotOrientation ); chart.setRegression( regression ); + chart.setTargetLine( targetLine ); + chart.setTargetLineValue( targetLineValue ); chart.setUserOrganisationUnit( userOrganisationUnit ); chart.setIndicators( indicators ); chart.setPeriods( periods ); chart.setOrganisationUnits( organisationUnits ); - RelativePeriods relatives = new RelativePeriods( reportingMonth, monthsThisYear, quartersThisYear, thisYear, monthsLastYear, quartersLastYear, lastYear ); - + RelativePeriods relatives = new RelativePeriods( reportingMonth, monthsThisYear, quartersThisYear, thisYear, + monthsLastYear, quartersLastYear, lastYear ); + chart.setRelatives( relatives ); - + chartService.saveChart( chart ); - + return SUCCESS; } } === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2011-04-08 10:48:03 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2011-04-14 13:06:10 +0000 @@ -199,6 +199,8 @@ data= Data include_regression_line= Include regression line include_regression= Include regression +include_target_line= Include target line +target_line_value= Target line value select = Select criteria = Criteria this_indicator_and_periods = This indicator and periods === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm 2011-04-08 10:48:03 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm 2011-04-14 13:06:10 +0000 @@ -1,4 +1,15 @@