dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #11734
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3422: add support for bar3d/line3d charts. we should consider using other colors in the future...
------------------------------------------------------------
revno: 3422
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-04-18 14:06:28 +0200
message:
add support for bar3d/line3d charts. we should consider using other colors in the future...
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm
--
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-api/src/main/java/org/hisp/dhis/chart/Chart.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2011-04-14 13:06:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2011-04-18 12:06:28 +0000
@@ -52,7 +52,9 @@
public static final String DIMENSION_INDICATOR = "indicator";
public static final String TYPE_BAR = "bar";
+ public static final String TYPE_BAR3D = "bar3d";
public static final String TYPE_LINE = "line";
+ public static final String TYPE_LINE3D = "line3d";
public static final String TYPE_PIE = "pie";
public static final String TYPE_PIE3D = "pie3d";
=== 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-15 10:08:22 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2011-04-18 12:06:28 +0000
@@ -32,7 +32,9 @@
import static org.hisp.dhis.chart.Chart.DIMENSION_PERIOD;
import static org.hisp.dhis.chart.Chart.SIZE_NORMAL;
import static org.hisp.dhis.chart.Chart.TYPE_BAR;
+import static org.hisp.dhis.chart.Chart.TYPE_BAR3D;
import static org.hisp.dhis.chart.Chart.TYPE_LINE;
+import static org.hisp.dhis.chart.Chart.TYPE_LINE3D;
import static org.hisp.dhis.chart.Chart.TYPE_PIE;
import static org.hisp.dhis.chart.Chart.TYPE_PIE3D;
import static org.hisp.dhis.options.SystemSettingManager.AGGREGATION_STRATEGY_REAL_TIME;
@@ -90,8 +92,10 @@
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.BarRenderer3D;
import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.chart.renderer.category.LineAndShapeRenderer;
+import org.jfree.chart.renderer.category.LineRenderer3D;
import org.jfree.chart.title.LegendTitle;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.category.CategoryDataset;
@@ -402,6 +406,24 @@
}
/**
+ * Returns a bar3d renderer.
+ */
+ private BarRenderer getBar3DRenderer()
+ {
+ BarRenderer3D renderer = new BarRenderer3D();
+
+ renderer.setMaximumBarWidth( 0.07 );
+
+ for ( int i = 0; i < colors.length; i++ )
+ {
+ renderer.setSeriesPaint( i, colors[i] );
+ renderer.setShadowVisible( false );
+ }
+
+ return renderer;
+ }
+
+ /**
* Returns a line and shape renderer.
*/
private LineAndShapeRenderer getLineRenderer()
@@ -417,12 +439,29 @@
}
/**
+ * Returns a line3d renderer.
+ */
+ private LineRenderer3D getLineRenderer3D()
+ {
+ LineRenderer3D renderer = new LineRenderer3D();
+
+ for ( int i = 0; i < colors.length; i++ )
+ {
+ renderer.setSeriesPaint( i, colors[i] );
+ }
+
+ return renderer;
+ }
+
+ /**
* Returns a JFreeChart of type defined in the chart argument.
*/
private JFreeChart getJFreeChart( Chart chart, boolean subTitle )
{
final BarRenderer barRenderer = getBarRenderer();
+ final BarRenderer bar3dRenderer = getBar3DRenderer();
final LineAndShapeRenderer lineRenderer = getLineRenderer();
+ final LineAndShapeRenderer line3dRenderer = getLineRenderer3D();
// ---------------------------------------------------------------------
// Plot
@@ -436,6 +475,10 @@
{
plot = new CategoryPlot( dataSets[0], new CategoryAxis(), new NumberAxis(), lineRenderer );
}
+ if ( chart.isType( TYPE_LINE3D ) )
+ {
+ plot = new CategoryPlot( dataSets[0], new CategoryAxis(), new NumberAxis(), line3dRenderer );
+ }
else if ( chart.isType( TYPE_PIE ) || chart.isType( TYPE_PIE3D ) )
{
JFreeChart multiplePieChart = null;
@@ -481,10 +524,14 @@
return multiplePieChart;
}
- else
+ else if ( chart.isType( TYPE_BAR ) )
{
plot = new CategoryPlot( dataSets[0], new CategoryAxis(), new NumberAxis(), barRenderer );
}
+ else if ( chart.isType( TYPE_BAR3D ) )
+ {
+ plot = new CategoryPlot( dataSets[0], new CategoryAxis(), new NumberAxis(), bar3dRenderer );
+ }
if ( chart.isRegression() )
{
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2011-04-15 13:48:42 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2011-04-18 12:06:28 +0000
@@ -171,7 +171,9 @@
horizontal_plot_orientation= Horizontal plot orientation
chart_type= Chart type
bar_chart= Bar chart
+bar3d_chart= Bar 3D chart
line_chart= Line chart
+line3d_chart= Line 3D chart
pie_chart= Pie chart
pie3d_chart= Pie 3D chart
chart_size= Chart size
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm 2011-04-15 13:48:42 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm 2011-04-18 12:06:28 +0000
@@ -47,7 +47,9 @@
<td>
<select id="type" name="type" style="width:300px">
<option value="bar"#if ( $!chart.type == "bar" ) selected#end>$i18n.getString( "bar_chart" )</option>
+ <option value="bar3d"#if ( $!chart.type == "bar3d" ) selected#end>$i18n.getString( "bar3d_chart" )</option>
<option value="line"#if ( $!chart.type == "line" ) selected#end>$i18n.getString( "line_chart" )</option>
+ <option value="line3d"#if ( $!chart.type == "line3d" ) selected#end>$i18n.getString( "line3d_chart" )</option>
<option value="pie"#if ( $!chart.type == "pie" ) selected#end>$i18n.getString( "pie_chart" )</option>
<option value="pie3d"#if ( $!chart.type == "pie3d" ) selected#end>$i18n.getString( "pie3d_chart" )</option>
</select>