1 37 38 package org.jfree.chart.demo; 39 40 import java.awt.Color ; 41 42 import org.jfree.chart.ChartFactory; 43 import org.jfree.chart.ChartPanel; 44 import org.jfree.chart.JFreeChart; 45 import org.jfree.chart.plot.PiePlot; 46 import org.jfree.data.CategoryDataset; 47 import org.jfree.data.DatasetUtilities; 48 import org.jfree.ui.ApplicationFrame; 49 import org.jfree.ui.RefineryUtilities; 50 51 56 public class MultiPieChartDemo2 extends ApplicationFrame { 57 58 63 public MultiPieChartDemo2(String title) { 64 65 super(title); 66 67 double[][] data = new double[][] { 69 {3.0, 4.0, 3.0, 5.0}, 70 {5.0, 7.0, 6.0, 8.0}, 71 {5.0, 7.0, 3.0, 8.0}, 72 {1.0, 2.0, 3.0, 4.0}, 73 {2.0, 3.0, 2.0, 3.0} 74 }; 75 76 CategoryDataset dataset = DatasetUtilities.createCategoryDataset("Region ", 77 "Sales/Q", 78 data); 79 80 JFreeChart chart = ChartFactory.createPieChart( 82 "Multi Pie Chart 2", dataset, PiePlot.PER_COLUMN, 85 true, true, 87 false 88 ); 89 90 92 chart.setBackgroundPaint(Color.yellow); 93 PiePlot plot = (PiePlot) chart.getPlot(); 94 plot.setSectionLabelType(PiePlot.VALUE_AND_PERCENT_LABELS); 95 96 98 ChartPanel chartPanel = new ChartPanel(chart, true, true, true, false, true); 100 chartPanel.setPreferredSize(new java.awt.Dimension (600, 380)); 101 setContentPane(chartPanel); 102 103 } 104 105 116 121 public static void main(String [] args) { 122 123 MultiPieChartDemo2 demo = new MultiPieChartDemo2("Multi Pie Chart Demo 2"); 124 demo.pack(); 125 RefineryUtilities.centerFrameOnScreen(demo); 126 demo.setVisible(true); 127 128 } 129 130 } 131 | Popular Tags |