← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4539: Added customizable legends for x and y axis in charts

 

------------------------------------------------------------
revno: 4539
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-09-07 15:14:46 +0200
message:
  Added customizable legends for x and y axis in charts
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java
  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/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml
  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/resources/org/hisp/dhis/reporting/i18n_module.properties
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.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	2011-09-05 17:12:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java	2011-09-07 13:14:46 +0000
@@ -86,6 +86,10 @@
     private int id;
 
     private String title;
+    
+    private String domainAxixLabel;
+    
+    private String rangeAxisLabel;
 
     private String type;
 
@@ -330,6 +334,26 @@
         this.title = title;
     }
 
+    public String getDomainAxixLabel()
+    {
+        return domainAxixLabel;
+    }
+
+    public void setDomainAxixLabel( String domainAxixLabel )
+    {
+        this.domainAxixLabel = domainAxixLabel;
+    }
+
+    public String getRangeAxisLabel()
+    {
+        return rangeAxisLabel;
+    }
+
+    public void setRangeAxisLabel( String rangeAxisLabel )
+    {
+        this.rangeAxisLabel = rangeAxisLabel;
+    }
+
     public String getType()
     {
         return type;

=== 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-05 21:57:06 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2011-09-07 13:14:46 +0000
@@ -92,6 +92,7 @@
 import org.jfree.chart.axis.CategoryAxis;
 import org.jfree.chart.axis.CategoryLabelPositions;
 import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.axis.ValueAxis;
 import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
 import org.jfree.chart.plot.CategoryPlot;
 import org.jfree.chart.plot.DatasetRenderingOrder;
@@ -651,6 +652,10 @@
         CategoryAxis xAxis = plot.getDomainAxis();
         xAxis.setCategoryLabelPositions( chart.isVerticalLabels() ? CategoryLabelPositions.UP_45
             : CategoryLabelPositions.STANDARD );
+        xAxis.setLabel( chart.getDomainAxixLabel() );
+        
+        ValueAxis yAxis = plot.getRangeAxis();
+        yAxis.setLabel( chart.getRangeAxisLabel() );
 
         // ---------------------------------------------------------------------
         // Color & antialias
@@ -672,12 +677,12 @@
         if ( chart.isType( TYPE_STACKED_BAR ) )
         {
             stackedBarChart = ChartFactory.createStackedBarChart( chart.getTitle(), 
-                null, null, dataSet, orientation, true, false, false );
+                chart.getDomainAxixLabel(), chart.getRangeAxisLabel(), dataSet, orientation, true, false, false );
         }
         else
         {
             stackedBarChart = ChartFactory.createStackedBarChart3D( chart.getTitle(), 
-                null, null, dataSet, orientation, true, false, false );
+                chart.getDomainAxixLabel(), chart.getRangeAxisLabel(), dataSet, orientation, true, false, false );
         }
         
         CategoryPlot plot = (CategoryPlot) stackedBarChart.getPlot();

=== 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-07-21 03:29:35 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml	2011-09-07 13:14:46 +0000
@@ -14,6 +14,10 @@
 
     <property name="title" not-null="true" unique="true" />
 
+	<property name="domainAxixLabel" />
+	
+	<property name="rangeAxisLabel" />
+
     <property name="type" />
 
     <property name="size" />

=== 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-07-07 13:29:56 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java	2011-09-07 13:14:46 +0000
@@ -105,6 +105,20 @@
         this.id = id;
     }
 
+    private String domainAxisLabel;
+
+    public void setDomainAxisLabel( String domainAxisLabel )
+    {
+        this.domainAxisLabel = domainAxisLabel;
+    }
+
+    private String rangeAxisLabel;
+    
+    public void setRangeAxisLabel( String rangeAxisLabel )
+    {
+        this.rangeAxisLabel = rangeAxisLabel;
+    }
+
     private String title;
 
     public void setTitle( String title )
@@ -304,6 +318,8 @@
         Collections.sort( periods, new AscendingPeriodComparator() );
 
         chart.setTitle( title );
+        chart.setDomainAxixLabel( domainAxisLabel );
+        chart.setRangeAxisLabel( rangeAxisLabel );
         chart.setHideSubtitle( hideSubtitle );
         chart.setType( type );
         chart.setSize( size );

=== 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-09-05 17:12:10 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2011-09-07 13:14:46 +0000
@@ -381,4 +381,6 @@
 intro_report_table_groups = Create, modify, view and delete report table groups. Groups are used for improved analysis.
 confirm_delete = Are you sure you want to delete this object ?
 stacked_bar_chart = Stacked bar chart
-stacked_bar3d_chart = Stacked 3D bar chart
\ No newline at end of file
+stacked_bar3d_chart = Stacked 3D bar chart
+domain_axis_label_x = Domain axis label (x)
+range_axis_label_y = Range axis label (y)
\ No newline at end of file

=== 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-09-05 17:12:10 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm	2011-09-07 13:14:46 +0000
@@ -57,12 +57,18 @@
         <td><label for="title">$i18n.getString( "title" )</label></td>
         <td><input type="text" id="title" name="title" style="width:300px" value="$!chart.title"></td>
     </tr>
-
+    <tr>
+        <td><label for="domainAxisLabel">$i18n.getString( "domain_axis_label_x" )</label></td>
+        <td><input type="text" id="domainAxisLabel" name="domainAxisLabel" style="width:300px" value="$!chart.domainAxisLabel"></td>
+    </tr>
+    <tr>
+        <td><label for="rangeAxisLabel">$i18n.getString( "range_axis_label_y" )</label></td>
+        <td><input type="text" id="rangeAxisLabel" name="rangeAxisLabel" style="width:300px" value="$!chart.rangeAxisLabel"></td>
+    </tr>
     <tr>
         <td><label for="hideSubtitle">$i18n.getString( "hide_subtitle" )</label></td>
         <td><input type="checkbox" id="hideSubtitle" name="hideSubtitle" value="true"#if( $!chart.hideSubtitle ) checked#end></td>
     </tr>
-
     <tr>
     	<td><label for="type">$i18n.getString( "chart_type" )</label></td>
     	<td>