dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #31054
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15796: PNG charts, added missig subtitles
------------------------------------------------------------
revno: 15796
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2014-06-21 15:22:29 +0200
message:
PNG charts, added missig subtitles
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-04-28 11:24:08 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2014-06-21 13:22:29 +0000
@@ -573,6 +573,8 @@
JFreeChart jFreeChart = new JFreeChart( chart.getName(), titleFont, plot, !chart.isHideLegend() );
+ setBasicConfig( jFreeChart, chart );
+
if ( chart.isTargetLine() )
{
plot.addRangeMarker( getMarker( chart.getTargetLineValue(), chart.getTargetLineLabel() ) );
@@ -589,7 +591,6 @@
}
plot.setDatasetRenderingOrder( DatasetRenderingOrder.FORWARD );
- plot.setBackgroundPaint( COLOR_TRANSPARENT );
plot.setOutlinePaint( COLOR_TRANSPARENT );
// ---------------------------------------------------------------------
@@ -603,13 +604,6 @@
ValueAxis rangeAxis = plot.getRangeAxis();
rangeAxis.setLabel( chart.getRangeAxisLabel() );
- // ---------------------------------------------------------------------
- // Color & antialias
- // ---------------------------------------------------------------------
-
- jFreeChart.setBackgroundPaint( COLOR_TRANSPARENT );
- jFreeChart.setAntiAlias( true );
-
return jFreeChart;
}
@@ -618,6 +612,8 @@
JFreeChart areaChart = ChartFactory.createAreaChart( chart.getName(), chart.getDomainAxisLabel(),
chart.getRangeAxisLabel(), dataSet, PlotOrientation.VERTICAL, true, false, false );
+ setBasicConfig( areaChart, chart );
+
CategoryPlot plot = (CategoryPlot) areaChart.getPlot();
plot.setOrientation( PlotOrientation.VERTICAL );
plot.setRenderer( getAreaRenderer() );
@@ -628,11 +624,6 @@
xAxis.setCategoryLabelPositions( CategoryLabelPositions.UP_45 );
xAxis.setLabelFont( labelFont );
- areaChart.getTitle().setFont( titleFont );
- areaChart.addSubtitle( getSubTitle( chart ) );
- areaChart.setBackgroundPaint( COLOR_TRANSPARENT );
- areaChart.setAntiAlias( true );
-
return areaChart;
}
@@ -644,8 +635,8 @@
plot.setLabelFont( labelFont );
JFreeChart radarChart = new JFreeChart( chart.getName(), titleFont, plot, !chart.isHideLegend() );
- radarChart.setAntiAlias( true );
- radarChart.setBackgroundPaint( COLOR_TRANSPARENT );
+
+ setBasicConfig( radarChart, chart );
return radarChart;
}
@@ -655,6 +646,8 @@
JFreeChart stackedBarChart = ChartFactory.createStackedBarChart( chart.getName(), chart.getDomainAxisLabel(),
chart.getRangeAxisLabel(), dataSet, PlotOrientation.VERTICAL, true, false, false );
+ setBasicConfig( stackedBarChart, chart );
+
CategoryPlot plot = (CategoryPlot) stackedBarChart.getPlot();
plot.setBackgroundPaint( COLOR_TRANSPARENT );
plot.setOutlinePaint( COLOR_TRANSPARENT );
@@ -663,25 +656,18 @@
CategoryAxis xAxis = plot.getDomainAxis();
xAxis.setCategoryLabelPositions( CategoryLabelPositions.UP_45 );
-
- stackedBarChart.getTitle().setFont( titleFont );
- stackedBarChart.addSubtitle( getSubTitle( chart ) );
- stackedBarChart.setBackgroundPaint( COLOR_TRANSPARENT );
- stackedBarChart.setAntiAlias( true );
-
+
return stackedBarChart;
}
-
+
private JFreeChart getMultiplePieChart( Chart chart, CategoryDataset[] dataSets )
{
JFreeChart multiplePieChart = ChartFactory.createMultiplePieChart( chart.getName(), dataSets[0], TableOrder.BY_ROW,
!chart.isHideLegend(), false, false );
- multiplePieChart.getTitle().setFont( titleFont );
- multiplePieChart.addSubtitle( getSubTitle( chart ) );
+ setBasicConfig( multiplePieChart, chart );
+
multiplePieChart.getLegend().setItemFont( subTitleFont );
- multiplePieChart.setBackgroundPaint( COLOR_TRANSPARENT );
- multiplePieChart.setAntiAlias( true );
MultiplePiePlot multiplePiePlot = (MultiplePiePlot) multiplePieChart.getPlot();
multiplePiePlot.setBackgroundPaint( COLOR_TRANSPARENT );
@@ -708,6 +694,18 @@
return multiplePieChart;
}
+ /**
+ * Sets basic configuration including title font, subtitle, background paint and
+ * anti-alias on the given JFreeChart.
+ */
+ private void setBasicConfig( JFreeChart jFreeChart, Chart chart)
+ {
+ jFreeChart.getTitle().setFont( titleFont );
+ jFreeChart.addSubtitle( getSubTitle( chart ) );
+ jFreeChart.setBackgroundPaint( COLOR_TRANSPARENT );
+ jFreeChart.setAntiAlias( true );
+ }
+
private CategoryDataset[] getCategoryDataSet( Chart chart )
{
Map<String, Double> valueMap = analyticsService.getAggregatedDataValueMapping( chart, chart.getFormat() );