dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #11675
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3387: simplified targetLine code
------------------------------------------------------------
revno: 3387
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-04-15 11:56:12 +0200
message:
simplified targetLine code
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 2011-04-14 13:06:10 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2011-04-15 09:56:12 +0000
@@ -40,6 +40,7 @@
import static org.hisp.dhis.options.SystemSettingManager.KEY_AGGREGATION_STRATEGY;
import static org.hisp.dhis.system.util.ConversionUtils.getArray;
+import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.util.ArrayList;
@@ -83,9 +84,11 @@
import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.DatasetRenderingOrder;
+import org.jfree.chart.plot.Marker;
import org.jfree.chart.plot.MultiplePiePlot;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.chart.plot.ValueMarker;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.chart.renderer.category.LineAndShapeRenderer;
@@ -414,25 +417,12 @@
}
/**
- * Returns a line and shape renderer (for target lines).
- */
- private LineAndShapeRenderer getTargetLineRenderer()
- {
- LineAndShapeRenderer renderer = new LineAndShapeRenderer();
- renderer.setBaseShapesVisible( false );
- renderer.setBasePaint( Color.BLUE );
-
- return renderer;
- }
-
- /**
* Returns a JFreeChart of type defined in the chart argument.
*/
private JFreeChart getJFreeChart( Chart chart, boolean subTitle )
{
final BarRenderer barRenderer = getBarRenderer();
final LineAndShapeRenderer lineRenderer = getLineRenderer();
- final LineAndShapeRenderer targetLineRenderer = getTargetLineRenderer();
// ---------------------------------------------------------------------
// Plot
@@ -504,8 +494,11 @@
if ( chart.isTargetLine() )
{
- plot.setDataset( 2, dataSets[2] );
- plot.setRenderer( 2, targetLineRenderer );
+ Marker marker = new ValueMarker( chart.getTargetLineValue() );
+ marker.setPaint( Color.BLUE );
+ marker.setStroke( new BasicStroke( 1.0f ) );
+
+ plot.addRangeMarker( marker );
}
JFreeChart jFreeChart = new JFreeChart( chart.getTitle(), titleFont, plot, !chart.isHideLegend() );
@@ -619,15 +612,6 @@
}
}
}
-
- if ( chart.isTargetLine() )
- {
- for ( Period period : chart.getAllPeriods() )
- {
- targetDataSet.addValue( chart.getTargetLineValue(), indicator.getShortName(), chart
- .getFormat().formatPeriod( period ) );
- }
- }
}
else if ( chart.isDimension( DIMENSION_ORGANISATIONUNIT ) )
{