← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4633: bugfix, chart by DE does not show subtitle

 

------------------------------------------------------------
revno: 4633
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-09-21 21:14:40 +0200
message:
  bugfix, chart by DE does not show subtitle
modified:
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java
  dhis-2/dhis-web/dhis-web-commons/pom.xml


--
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-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-09-21 17:22:32 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2011-09-21 19:14:40 +0000
@@ -235,15 +235,15 @@
 
         return getJFreeChart( chart, !chart.getHideSubtitle() );
     }
-    
+
     public JFreeChart getJFreeChart( Indicator indicator, OrganisationUnit unit, I18nFormat format )
     {
         RelativePeriods relatives = new RelativePeriods();
         relatives.setMonthsThisYear( true );
         List<Period> periods = relatives.getRelativePeriods( 1, format, true );
-        
+
         Chart chart = new Chart();
-        
+
         chart.setTitle( indicator.getName() );
         chart.setType( TYPE_LINE3D );
         chart.setSize( SIZE_NORMAL );
@@ -253,10 +253,10 @@
         chart.setPeriods( periods );
         chart.setOrganisationUnit( unit );
         chart.setFormat( format );
-        
+
         chart.init();
-        
-        return getJFreeChart( chart, true );        
+
+        return getJFreeChart( chart, true );
     }
 
     public JFreeChart getJFreeChart( List<Indicator> indicators, List<DataElement> dataElements, List<Period> periods,
@@ -314,7 +314,7 @@
         int historyLength, I18nFormat format )
     {
         lastPeriod = periodService.reloadPeriod( lastPeriod );
-        
+
         List<Period> periods = periodService.getPeriods( lastPeriod, historyLength );
 
         MinMaxDataElement minMax = minMaxDataElementService.getMinMaxDataElement( organisationUnit, dataElement,
@@ -631,7 +631,7 @@
         {
             return getMultiplePieChart( chart, dataSets );
         }
-        else if ( chart.isType( TYPE_STACKED_BAR ) || chart.isType( TYPE_STACKED_BAR3D ))
+        else if ( chart.isType( TYPE_STACKED_BAR ) || chart.isType( TYPE_STACKED_BAR3D ) )
         {
             return getStackedBarChart( chart, dataSets[0] );
         }
@@ -677,7 +677,7 @@
         xAxis.setCategoryLabelPositions( chart.isVerticalLabels() ? CategoryLabelPositions.UP_45
             : CategoryLabelPositions.STANDARD );
         xAxis.setLabel( chart.getDomainAxixLabel() );
-        
+
         ValueAxis yAxis = plot.getRangeAxis();
         yAxis.setLabel( chart.getRangeAxisLabel() );
 
@@ -695,20 +695,20 @@
     {
         PlotOrientation orientation = chart.isHorizontalPlotOrientation() ? PlotOrientation.HORIZONTAL
             : PlotOrientation.VERTICAL;
-        
+
         JFreeChart stackedBarChart = null;
-        
+
         if ( chart.isType( TYPE_STACKED_BAR ) )
         {
-            stackedBarChart = ChartFactory.createStackedBarChart( chart.getTitle(), 
-                chart.getDomainAxixLabel(), chart.getRangeAxisLabel(), dataSet, orientation, true, false, false );
+            stackedBarChart = ChartFactory.createStackedBarChart( chart.getTitle(), chart.getDomainAxixLabel(),
+                chart.getRangeAxisLabel(), dataSet, orientation, true, false, false );
         }
         else
         {
-            stackedBarChart = ChartFactory.createStackedBarChart3D( chart.getTitle(), 
-                chart.getDomainAxixLabel(), chart.getRangeAxisLabel(), dataSet, orientation, true, false, false );
+            stackedBarChart = ChartFactory.createStackedBarChart3D( chart.getTitle(), chart.getDomainAxixLabel(),
+                chart.getRangeAxisLabel(), dataSet, orientation, true, false, false );
         }
-        
+
         CategoryPlot plot = (CategoryPlot) stackedBarChart.getPlot();
         plot.setBackgroundPaint( Color.WHITE );
 
@@ -717,23 +717,23 @@
             : CategoryLabelPositions.STANDARD );
 
         stackedBarChart.setAntiAlias( true );
-        
+
         return stackedBarChart;
     }
-    
+
     private JFreeChart getMultiplePieChart( Chart chart, CategoryDataset[] dataSets )
     {
         JFreeChart multiplePieChart = null;
 
         if ( chart.isType( TYPE_PIE ) )
         {
-            multiplePieChart = ChartFactory.createMultiplePieChart( chart.getTitle(), dataSets[0],
-                TableOrder.BY_ROW, !chart.getHideLegend(), false, false );
+            multiplePieChart = ChartFactory.createMultiplePieChart( chart.getTitle(), dataSets[0], TableOrder.BY_ROW,
+                !chart.getHideLegend(), false, false );
         }
         else
         {
-            multiplePieChart = ChartFactory.createMultiplePieChart3D( chart.getTitle(), dataSets[0],
-                TableOrder.BY_ROW, !chart.getHideLegend(), false, false );
+            multiplePieChart = ChartFactory.createMultiplePieChart3D( chart.getTitle(), dataSets[0], TableOrder.BY_ROW,
+                !chart.getHideLegend(), false, false );
         }
 
         multiplePieChart.setBackgroundPaint( Color.WHITE );
@@ -766,7 +766,7 @@
 
         return multiplePieChart;
     }
-    
+
     /**
      * Returns a DefaultCategoryDataSet based on aggregated data for the chart.
      */
@@ -826,15 +826,15 @@
                         if ( isIndicatorChart )
                         {
                             value = aggregationStrategy.equals( AGGREGATION_STRATEGY_REAL_TIME ) ? aggregationService
-                                .getAggregatedIndicatorValue( indicators.get( i ), period.getStartDate(), period
-                                    .getEndDate(), selectedOrganisationUnit ) : aggregatedDataValueService
+                                .getAggregatedIndicatorValue( indicators.get( i ), period.getStartDate(),
+                                    period.getEndDate(), selectedOrganisationUnit ) : aggregatedDataValueService
                                 .getAggregatedValue( indicators.get( i ), period, selectedOrganisationUnit );
                         }
                         else if ( isDataElementChart )
                         {
                             value = aggregationStrategy.equals( AGGREGATION_STRATEGY_REAL_TIME ) ? aggregationService
-                                .getAggregatedDataValue( dataElements.get( i ), null, period.getStartDate(), period
-                                    .getEndDate(), selectedOrganisationUnit ) : aggregatedDataValueService
+                                .getAggregatedDataValue( dataElements.get( i ), null, period.getStartDate(),
+                                    period.getEndDate(), selectedOrganisationUnit ) : aggregatedDataValueService
                                 .getAggregatedValue( dataElements.get( i ), period, selectedOrganisationUnit );
                         }
 
@@ -979,6 +979,18 @@
         {
             subTitle.setText( chart.getAllOrganisationUnits().get( 0 ).getName() );
         }
+        else if ( chart.isDimension( DIMENSION_PERIOD_DATAELEMENT ) && chart.getAllOrganisationUnits().size() > 0 )
+        {
+            subTitle.setText( chart.getAllOrganisationUnits().get( 0 ).getName() );
+        }
+        else if ( chart.isDimension( DIMENSION_ORGANISATIONUNIT_DATAELEMENT ) && chart.getAllPeriods().size() > 0 )
+        {
+            subTitle.setText( format.formatPeriod( chart.getAllPeriods().get( 0 ) ) );
+        }
+        else if ( chart.isDimension( DIMENSION_DATAELEMENT_PERIOD ) && chart.getIndicators().size() > 0 )
+        {
+            subTitle.setText( chart.getAllOrganisationUnits().get( 0 ).getName() );
+        }
 
         return subTitle;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-commons/pom.xml'
--- dhis-2/dhis-web/dhis-web-commons/pom.xml	2011-08-28 17:52:59 +0000
+++ dhis-2/dhis-web/dhis-web-commons/pom.xml	2011-09-21 19:14:40 +0000
@@ -1,5 +1,4 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0";
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+<project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd";>
   <modelVersion>4.0.0</modelVersion>
   <parent>
@@ -7,31 +6,31 @@
     <artifactId>dhis-web</artifactId>
     <version>2.5-SNAPSHOT</version>
   </parent>
-  
+
   <artifactId>dhis-web-commons</artifactId>
   <packaging>jar</packaging>
   <name>DHIS Common Functionality for Web</name>
-  
+
   <build>
     <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-antrun-plugin</artifactId>
-		<version>1.6</version>
+        <version>1.6</version>
         <executions>
           <execution>
             <phase>generate-resources</phase>
             <configuration>
               <target>
                 <tstamp>
-                  <format property="now" pattern="yyyy-MM-dd HH:mm:ss"/>
+                  <format property="now" pattern="yyyy-MM-dd HH:mm:ss" />
                 </tstamp>
-                <mkdir dir="${project.build.outputDirectory}"/>
+                <mkdir dir="${project.build.outputDirectory}" />
                 <exec executable="bzr" outputproperty="revision" failifexecutionfails="false">
-                      <arg value="revno"/>
+                  <arg value="revno" />
                 </exec>
                 <echo file="${project.build.outputDirectory}/build.properties"
-                  message="build.version = ${project.version}&#10;build.time = ${now}&#10;build.revision = ${revision}&#10;"/>
+                  message="build.version = ${project.version}&#10;build.time = ${now}&#10;build.revision = ${revision}&#10;" />
               </target>
             </configuration>
             <goals>
@@ -42,11 +41,11 @@
       </plugin>
     </plugins>
   </build>
-  
+
   <dependencies>
-    
+
     <!-- DHIS -->
-    
+
     <dependency>
       <groupId>org.hisp.dhis</groupId>
       <artifactId>dhis-api</artifactId>
@@ -79,9 +78,9 @@
       <groupId>org.hisp.dhis</groupId>
       <artifactId>dhis-support-system</artifactId>
     </dependency>
-    
+
     <!-- Web -->
-    
+
     <dependency>
       <groupId>org.apache.struts</groupId>
       <artifactId>struts2-core</artifactId>
@@ -102,9 +101,13 @@
       <groupId>javax.servlet</groupId>
       <artifactId>servlet-api</artifactId>
     </dependency>
-    
+    <dependency>
+      <groupId>org.springframework.mobile</groupId>
+      <artifactId>spring-mobile-device</artifactId>
+    </dependency>
+
     <!-- Other -->
-	
+
     <dependency>
       <groupId>org.springframework.security</groupId>
       <artifactId>spring-security-config</artifactId>
@@ -137,10 +140,10 @@
       <groupId>jfree</groupId>
       <artifactId>jcommon</artifactId>
     </dependency>
-	<dependency>
-	  <groupId>net.fckeditor</groupId>
-	  <artifactId>java-core</artifactId>
-	</dependency>
+    <dependency>
+      <groupId>net.fckeditor</groupId>
+      <artifactId>java-core</artifactId>
+    </dependency>
   </dependencies>
   <properties>
     <rootDir>../../</rootDir>