1 41 42 package org.jfree.chart.demo; 43 44 import org.jfree.chart.ChartFactory; 45 import org.jfree.chart.ChartPanel; 46 import org.jfree.chart.JFreeChart; 47 import org.jfree.chart.axis.NumberAxis; 48 import org.jfree.chart.plot.PlotOrientation; 49 import org.jfree.chart.plot.XYPlot; 50 import org.jfree.data.IntervalXYDataset; 51 import org.jfree.ui.ApplicationFrame; 52 import org.jfree.ui.RefineryUtilities; 53 54 59 public class XYBarChartDemo3 extends ApplicationFrame { 60 61 66 public XYBarChartDemo3(String title) { 67 68 super(title); 69 70 IntervalXYDataset dataset = new SimpleIntervalXYDataset(); 72 73 JFreeChart chart = createChart(dataset); 75 76 ChartPanel chartPanel = new ChartPanel(chart); 78 chartPanel.setPreferredSize(new java.awt.Dimension (500, 300)); 79 setContentPane(chartPanel); 80 81 } 82 83 94 101 private JFreeChart createChart(IntervalXYDataset dataset) { 102 103 JFreeChart chart = ChartFactory.createXYBarChart( 104 "Sample", "X", "Y", dataset, PlotOrientation.VERTICAL, 109 true, true, 111 false 112 ); 113 114 XYPlot plot = chart.getXYPlot(); 115 plot.setDomainAxis(new NumberAxis("X")); 116 117 return chart; 118 119 } 120 121 126 public static void main(String [] args) { 127 128 XYBarChartDemo3 demo = new XYBarChartDemo3("XY Bar Chart Demo 3"); 129 demo.pack(); 130 RefineryUtilities.centerFrameOnScreen(demo); 131 demo.setVisible(true); 132 133 } 134 135 } 136 | Popular Tags |