=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/BaseChart.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/BaseChart.java 2014-07-12 12:52:17 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/BaseChart.java 2014-07-12 13:08:26 +0000 @@ -32,8 +32,11 @@ import java.util.List; import org.hisp.dhis.common.BaseAnalyticalObject; +import org.hisp.dhis.common.DimensionalObject; import org.hisp.dhis.common.DxfNamespaces; import org.hisp.dhis.common.IdentifiableObject; +import org.hisp.dhis.common.IdentifiableObjectUtils; +import org.hisp.dhis.common.NameableObject; import org.hisp.dhis.common.view.DetailedView; import org.hisp.dhis.common.view.DimensionalView; import org.hisp.dhis.common.view.ExportView; @@ -142,6 +145,29 @@ return baseLineValue != null; } + public List getFilterItems() + { + List filterItems = new ArrayList(); + + for ( String filter : filterDimensions ) + { + DimensionalObject object = getDimensionalObject( filter, relativePeriodDate, user, true, + organisationUnitsAtLevel, organisationUnitsInGroups, format ); + + if ( object != null ) + { + filterItems.addAll( object.getItems() ); + } + } + + return filterItems; + } + + public String generateTitle() + { + return IdentifiableObjectUtils.join( getFilterItems() ); + } + // ------------------------------------------------------------------------- // Getters and setters // ------------------------------------------------------------------------- === 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-07-12 12:52:17 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2014-07-12 13:08:26 +0000 @@ -35,7 +35,6 @@ import org.hisp.dhis.common.DimensionalObject; import org.hisp.dhis.common.DxfNamespaces; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.common.IdentifiableObjectUtils; import org.hisp.dhis.common.NameableObject; import org.hisp.dhis.common.view.DetailedView; import org.hisp.dhis.common.view.DimensionalView; @@ -116,29 +115,6 @@ return object != null ? object.getItems() : null; } - public List filters() - { - List filterItems = new ArrayList(); - - for ( String filter : filterDimensions ) - { - DimensionalObject object = getDimensionalObject( filter, relativePeriodDate, user, true, - organisationUnitsAtLevel, organisationUnitsInGroups, format ); - - if ( object != null ) - { - filterItems.addAll( object.getItems() ); - } - } - - return filterItems; - } - - public String generateTitle() - { - return IdentifiableObjectUtils.join( filters() ); - } - @Override public void populateAnalyticalProperties() { === 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 2014-07-01 07:53:19 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2014-07-12 13:08:26 +0000 @@ -55,6 +55,7 @@ import org.apache.commons.math.analysis.UnivariateRealInterpolator; import org.apache.commons.math.stat.regression.SimpleRegression; import org.hisp.dhis.analytics.AnalyticsService; +import org.hisp.dhis.chart.BaseChart; import org.hisp.dhis.chart.Chart; import org.hisp.dhis.chart.ChartService; import org.hisp.dhis.common.AnalyticalObjectStore; @@ -605,7 +606,7 @@ return jFreeChart; } - private JFreeChart getAreaChart( Chart chart, CategoryDataset dataSet ) + private JFreeChart getAreaChart( BaseChart chart, CategoryDataset dataSet ) { JFreeChart areaChart = ChartFactory.createAreaChart( chart.getName(), chart.getDomainAxisLabel(), chart.getRangeAxisLabel(), dataSet, PlotOrientation.VERTICAL, true, false, false ); @@ -623,7 +624,7 @@ return areaChart; } - private JFreeChart getRadarChart( Chart chart, CategoryDataset dataSet ) + private JFreeChart getRadarChart( BaseChart chart, CategoryDataset dataSet ) { SpiderWebPlot plot = new SpiderWebPlot( dataSet, TableOrder.BY_ROW ); plot.setLabelFont( LABEL_FONT ); @@ -635,7 +636,7 @@ return radarChart; } - private JFreeChart getStackedBarChart( Chart chart, CategoryDataset dataSet, boolean horizontal ) + private JFreeChart getStackedBarChart( BaseChart chart, CategoryDataset dataSet, boolean horizontal ) { JFreeChart stackedBarChart = ChartFactory.createStackedBarChart( chart.getName(), chart.getDomainAxisLabel(), chart.getRangeAxisLabel(), dataSet, PlotOrientation.VERTICAL, true, false, false ); @@ -652,7 +653,7 @@ return stackedBarChart; } - private JFreeChart getMultiplePieChart( Chart chart, CategoryDataset[] dataSets ) + private JFreeChart getMultiplePieChart( BaseChart chart, CategoryDataset[] dataSets ) { JFreeChart multiplePieChart = ChartFactory.createMultiplePieChart( chart.getName(), dataSets[0], TableOrder.BY_ROW, !chart.isHideLegend(), false, false ); @@ -689,7 +690,7 @@ * Sets basic configuration including title font, subtitle, background paint and * anti-alias on the given JFreeChart. */ - private void setBasicConfig( JFreeChart jFreeChart, Chart chart) + private void setBasicConfig( JFreeChart jFreeChart, BaseChart chart) { jFreeChart.getTitle().setFont( TITLE_FONT ); jFreeChart.addSubtitle( getSubTitle( chart ) ); @@ -700,7 +701,17 @@ plot.setBackgroundPaint( COLOR_TRANSPARENT ); plot.setOutlinePaint( COLOR_TRANSPARENT ); } - + + private TextTitle getSubTitle( BaseChart chart ) + { + TextTitle title = new TextTitle(); + + title.setFont( SUB_TITLE_FONT ); + title.setText( chart.generateTitle() ); + + return title; + } + private CategoryDataset[] getCategoryDataSet( Chart chart ) { Map valueMap = analyticsService.getAggregatedDataValueMapping( chart, chart.getFormat() ); @@ -755,16 +766,6 @@ return new CategoryDataset[]{ regularDataSet, regressionDataSet }; } - private TextTitle getSubTitle( Chart chart ) - { - TextTitle title = new TextTitle(); - - title.setFont( SUB_TITLE_FONT ); - title.setText( chart.generateTitle() ); - - return title; - } - // ------------------------------------------------------------------------- // CRUD operations // -------------------------------------------------------------------------