dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20220
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9144: Made the stacked bar PNG charts have same color scheme as the other chart types
------------------------------------------------------------
revno: 9144
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-11-28 13:58:49 +0100
message:
Made the stacked bar PNG charts have same color scheme as the other chart types
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 2012-10-09 10:30:12 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2012-11-28 12:58:49 +0000
@@ -92,6 +92,7 @@
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.chart.renderer.category.LineAndShapeRenderer;
+import org.jfree.chart.renderer.category.StackedBarRenderer;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
@@ -470,6 +471,21 @@
}
/**
+ * Returns a stacked bar renderer.
+ */
+ private StackedBarRenderer getStackedBarRenderer()
+ {
+ StackedBarRenderer renderer = new StackedBarRenderer();
+
+ for ( int i = 0; i < colors.length; i++ )
+ {
+ renderer.setSeriesPaint( i, colors[i] );
+ }
+
+ return renderer;
+ }
+
+ /**
* Returns a horizontal line marker for the given x value and label.
*/
private Marker getMarker( Double value, String label )
@@ -593,6 +609,7 @@
plot.setBackgroundPaint( Color.WHITE );
plot.setOutlinePaint( Color.WHITE );
plot.setOrientation( horizontal ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL );
+ plot.setRenderer( getStackedBarRenderer() );
CategoryAxis xAxis = plot.getDomainAxis();
xAxis.setCategoryLabelPositions( CategoryLabelPositions.UP_45 );