← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11705: PNG charts, transparent plots

 

------------------------------------------------------------
revno: 11705
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-08-19 22:36:04 +0200
message:
  PNG charts, transparent plots
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	2013-08-18 20:23:08 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2013-08-19 20:36:04 +0000
@@ -124,6 +124,8 @@
         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" ) };
+    
+    private static final Color COLOR_TRANSPARENT = new Color( 255, 255, 255, 0 );
 
     // -------------------------------------------------------------------------
     // Dependencies
@@ -585,6 +587,8 @@
         }
 
         plot.setDatasetRenderingOrder( DatasetRenderingOrder.FORWARD );
+        plot.setBackgroundPaint( COLOR_TRANSPARENT );
+        plot.setOutlinePaint( COLOR_TRANSPARENT );
 
         // ---------------------------------------------------------------------
         // Category label positions
@@ -601,7 +605,7 @@
         // Color & antialias
         // ---------------------------------------------------------------------
 
-        jFreeChart.setBackgroundPaint( Color.WHITE );
+        jFreeChart.setBackgroundPaint( COLOR_TRANSPARENT );
         jFreeChart.setAntiAlias( true );
 
         return jFreeChart;
@@ -613,10 +617,10 @@
             chart.getRangeAxisLabel(), dataSet, PlotOrientation.VERTICAL, true, false, false );
         
         CategoryPlot plot = (CategoryPlot) areaChart.getPlot();
-        plot.setBackgroundPaint( Color.WHITE );
-        plot.setOutlinePaint( Color.WHITE );
         plot.setOrientation( PlotOrientation.VERTICAL );
         plot.setRenderer( getAreaRenderer() );
+        plot.setBackgroundPaint( COLOR_TRANSPARENT );
+        plot.setOutlinePaint( COLOR_TRANSPARENT );
         
         CategoryAxis xAxis = plot.getDomainAxis();
         xAxis.setCategoryLabelPositions( CategoryLabelPositions.UP_45 );
@@ -624,6 +628,7 @@
         
         areaChart.getTitle().setFont( titleFont );
         areaChart.addSubtitle( getSubTitle( chart ) );
+        areaChart.setBackgroundPaint( COLOR_TRANSPARENT );
         areaChart.setAntiAlias( true );
         
         return areaChart;
@@ -632,15 +637,15 @@
     private JFreeChart getRadarChart( Chart chart, CategoryDataset dataSet )
     {
         SpiderWebPlot plot = new SpiderWebPlot( dataSet, TableOrder.BY_ROW );
-        plot.setBackgroundPaint( Color.WHITE );
-        plot.setOutlinePaint( Color.WHITE );
+        plot.setBackgroundPaint( COLOR_TRANSPARENT );
+        plot.setOutlinePaint( COLOR_TRANSPARENT );
         plot.setLabelFont( labelFont );
         
-        JFreeChart jFreeChart = new JFreeChart( chart.getName(), titleFont, plot, !chart.isHideLegend() );
-        jFreeChart.setAntiAlias( true );
-        jFreeChart.setBackgroundPaint( Color.WHITE );
+        JFreeChart radarChart = new JFreeChart( chart.getName(), titleFont, plot, !chart.isHideLegend() );
+        radarChart.setAntiAlias( true );
+        radarChart.setBackgroundPaint( COLOR_TRANSPARENT );
         
-        return jFreeChart;
+        return radarChart;
     }
     
     private JFreeChart getStackedBarChart( Chart chart, CategoryDataset dataSet, boolean horizontal )
@@ -649,8 +654,8 @@
             chart.getRangeAxisLabel(), dataSet, PlotOrientation.VERTICAL, true, false, false );
 
         CategoryPlot plot = (CategoryPlot) stackedBarChart.getPlot();
-        plot.setBackgroundPaint( Color.WHITE );
-        plot.setOutlinePaint( Color.WHITE );
+        plot.setBackgroundPaint( COLOR_TRANSPARENT );
+        plot.setOutlinePaint( COLOR_TRANSPARENT );
         plot.setOrientation( horizontal ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL );
         plot.setRenderer( getStackedBarRenderer() );
 
@@ -659,6 +664,7 @@
 
         stackedBarChart.getTitle().setFont( titleFont );
         stackedBarChart.addSubtitle( getSubTitle( chart ) );
+        stackedBarChart.setBackgroundPaint( COLOR_TRANSPARENT );
         stackedBarChart.setAntiAlias( true );
 
         return stackedBarChart;
@@ -672,15 +678,18 @@
         multiplePieChart.getTitle().setFont( titleFont );
         multiplePieChart.addSubtitle( getSubTitle( chart ) );
         multiplePieChart.getLegend().setItemFont( subTitleFont );
-        multiplePieChart.setBackgroundPaint( Color.WHITE );
+        multiplePieChart.setBackgroundPaint( COLOR_TRANSPARENT );
         multiplePieChart.setAntiAlias( true );
 
         MultiplePiePlot multiplePiePlot = (MultiplePiePlot) multiplePieChart.getPlot();
+        multiplePiePlot.setBackgroundPaint( COLOR_TRANSPARENT );
         JFreeChart pieChart = multiplePiePlot.getPieChart();
+        pieChart.setBackgroundPaint( COLOR_TRANSPARENT );
         pieChart.getTitle().setFont( subTitleFont );
 
         PiePlot piePlot = (PiePlot) pieChart.getPlot();
-        piePlot.setBackgroundPaint( Color.WHITE );
+        piePlot.setBackgroundPaint( COLOR_TRANSPARENT );
+        piePlot.setOutlinePaint( COLOR_TRANSPARENT );
         piePlot.setLabelFont( labelFont );
         piePlot.setLabelGenerator( new StandardPieSectionLabelGenerator( "{2}" ) );
         piePlot.setSimpleLabels( true );