1 28 29 33 34 import net.sf.jasperreports.engine.JRDefaultScriptlet; 35 import net.sf.jasperreports.engine.JRScriptletException; 36 import net.sf.jasperreports.renderers.JCommonDrawableRenderer; 37 38 import org.jfree.chart.ChartFactory; 39 import org.jfree.chart.JFreeChart; 40 import org.jfree.chart.plot.PiePlot3D; 41 import org.jfree.data.general.DefaultPieDataset; 42 import org.jfree.util.Rotation; 43 44 45 49 public class JFreeChartScriptlet extends JRDefaultScriptlet 50 { 51 52 53 56 public void afterReportInit() throws JRScriptletException 57 { 58 DefaultPieDataset dataset = new DefaultPieDataset(); 59 dataset.setValue("Java", new Double (43.2)); 60 dataset.setValue("Visual Basic", new Double (10.0)); 61 dataset.setValue("C/C++", new Double (17.5)); 62 dataset.setValue("PHP", new Double (32.5)); 63 dataset.setValue("Perl", new Double (1.0)); 64 65 JFreeChart chart = 66 ChartFactory.createPieChart3D( 67 "Pie Chart 3D Demo 1", 68 dataset, 69 true, 70 true, 71 false 72 ); 73 74 PiePlot3D plot = (PiePlot3D) chart.getPlot(); 75 plot.setStartAngle(290); 76 plot.setDirection(Rotation.CLOCKWISE); 77 plot.setForegroundAlpha(0.5f); 78 plot.setNoDataMessage("No data to display"); 79 80 81 this.setVariableValue("Chart", new JCommonDrawableRenderer(chart)); 82 } 83 84 85 } 86 | Popular Tags |