← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16614: Area and pie PNG charts, respecting hide legend option

 

------------------------------------------------------------
revno: 16614
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-09-02 13:50:55 -0400
message:
  Area and pie PNG charts, respecting hide legend option
modified:
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java


--
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	2014-08-31 20:38:25 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2014-09-02 17:50:55 +0000
@@ -128,7 +128,7 @@
 
     private static final String TREND_PREFIX = "Trend - ";
 
-    private static final Color[] colors = { Color.decode( "#88be3b" ), Color.decode( "#3b6286" ),
+    private static final Color[] COLORS = { Color.decode( "#88be3b" ), Color.decode( "#3b6286" ),
         Color.decode( "#b7404c" ), Color.decode( "#ff9f3a" ), Color.decode( "#968f8f" ), Color.decode( "#b7409f" ),
         Color.decode( "#ffda64" ), Color.decode( "#4fbdae" ), Color.decode( "#b78040" ), Color.decode( "#676767" ),
         Color.decode( "#6a33cf" ), Color.decode( "#4a7833" ) };
@@ -450,9 +450,9 @@
 
         renderer.setMaximumBarWidth( 0.07 );
 
-        for ( int i = 0; i < colors.length; i++ )
+        for ( int i = 0; i < COLORS.length; i++ )
         {
-            renderer.setSeriesPaint( i, colors[i] );
+            renderer.setSeriesPaint( i, COLORS[i] );
             renderer.setShadowVisible( false );
         }
 
@@ -466,9 +466,9 @@
     {
         LineAndShapeRenderer renderer = new LineAndShapeRenderer();
 
-        for ( int i = 0; i < colors.length; i++ )
+        for ( int i = 0; i < COLORS.length; i++ )
         {
-            renderer.setSeriesPaint( i, colors[i] );
+            renderer.setSeriesPaint( i, COLORS[i] );
         }
 
         return renderer;
@@ -481,9 +481,9 @@
     {
         StackedBarRenderer renderer = new StackedBarRenderer();
 
-        for ( int i = 0; i < colors.length; i++ )
+        for ( int i = 0; i < COLORS.length; i++ )
         {
-            renderer.setSeriesPaint( i, colors[i] );
+            renderer.setSeriesPaint( i, COLORS[i] );
             renderer.setShadowVisible( false );
         }
 
@@ -499,9 +499,9 @@
     {
         AreaRenderer renderer = new AreaRenderer();
 
-        for ( int i = 0; i < colors.length; i++ )
+        for ( int i = 0; i < COLORS.length; i++ )
         {
-            renderer.setSeriesPaint( i, colors[i] );
+            renderer.setSeriesPaint( i, COLORS[i] );
         }
 
         return renderer;
@@ -622,7 +622,7 @@
     private JFreeChart getAreaChart( BaseChart chart, CategoryDataset dataSet )
     {
         JFreeChart areaChart = ChartFactory.createAreaChart( chart.getName(), chart.getDomainAxisLabel(),
-            chart.getRangeAxisLabel(), dataSet, PlotOrientation.VERTICAL, true, false, false );
+            chart.getRangeAxisLabel(), dataSet, PlotOrientation.VERTICAL, !chart.isHideLegend(), false, false );
 
         setBasicConfig( areaChart, chart );
 
@@ -652,7 +652,7 @@
     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 );
+            chart.getRangeAxisLabel(), dataSet, PlotOrientation.VERTICAL, !chart.isHideLegend(), false, false );
 
         setBasicConfig( stackedBarChart, chart );
 
@@ -696,7 +696,7 @@
 
         for ( int i = 0; i < dataSets[0].getColumnCount(); i++ )
         {
-            piePlot.setSectionPaint( dataSets[0].getColumnKey( i ), colors[(i % colors.length)] );
+            piePlot.setSectionPaint( dataSets[0].getColumnKey( i ), COLORS[(i % COLORS.length)] );
         }
 
         return multiplePieChart;