1 37 38 package org.jfree.chart.demo; 39 40 import org.jfree.chart.ChartFactory; 41 import org.jfree.chart.ChartPanel; 42 import org.jfree.chart.JFreeChart; 43 import org.jfree.chart.plot.CategoryPlot; 44 import org.jfree.chart.plot.PlotOrientation; 45 import org.jfree.data.CategoryDataset; 46 import org.jfree.ui.ApplicationFrame; 47 import org.jfree.ui.RefineryUtilities; 48 import org.jfree.util.SortOrder; 49 50 56 public class StackedBarChart3DDemo extends ApplicationFrame { 57 58 63 public StackedBarChart3DDemo(String title) { 64 65 super(title); 66 67 CategoryDataset dataset = DemoDatasetFactory.createCategoryDataset(); 69 JFreeChart chart = createChart(dataset); 70 71 ChartPanel chartPanel = new ChartPanel(chart); 73 chartPanel.setPreferredSize(new java.awt.Dimension (500, 270)); 74 setContentPane(chartPanel); 75 76 } 77 78 85 private JFreeChart createChart(CategoryDataset dataset) { 86 87 JFreeChart chart = ChartFactory.createStackedBarChart3D( 88 "Stacked 3D Bar Chart Demo", "Category", "Value", dataset, PlotOrientation.HORIZONTAL, true, true, false ); 97 CategoryPlot plot = chart.getCategoryPlot(); 98 99 plot.setColumnRenderingOrder(SortOrder.DESCENDING); 101 102 return chart; 103 104 } 105 106 117 122 public static void main(String [] args) { 123 124 StackedBarChart3DDemo demo = new StackedBarChart3DDemo("Stacked 3D Bar Chart Demo"); 125 demo.pack(); 126 RefineryUtilities.centerFrameOnScreen(demo); 127 demo.setVisible(true); 128 129 } 130 131 } 132 | Popular Tags |