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.PlotOrientation; 44 import org.jfree.chart.plot.XYPlot; 45 import org.jfree.chart.renderer.YIntervalRenderer; 46 import org.jfree.data.IntervalXYDataset; 47 import org.jfree.ui.ApplicationFrame; 48 import org.jfree.ui.RefineryUtilities; 49 50 55 public class YIntervalChartDemo extends ApplicationFrame { 56 57 62 public YIntervalChartDemo(String title) { 63 64 super(title); 65 66 IntervalXYDataset dataset = new SimpleIntervalXYDataset2(100); 68 69 JFreeChart chart = createChart(dataset); 71 72 ChartPanel chartPanel = new ChartPanel(chart); 74 chartPanel.setPreferredSize(new java.awt.Dimension (500, 300)); 75 setContentPane(chartPanel); 76 77 } 78 79 86 private JFreeChart createChart(IntervalXYDataset dataset) { 87 88 JFreeChart chart = ChartFactory.createScatterPlot( 89 "Y Interval Chart Demo", "X", "Y", dataset, PlotOrientation.VERTICAL, 94 true, true, 96 false 97 ); 98 99 XYPlot plot = chart.getXYPlot(); 100 plot.setRenderer(new YIntervalRenderer()); 101 102 return chart; 103 104 } 105 106 117 122 public static void main(String [] args) { 123 124 YIntervalChartDemo demo = new YIntervalChartDemo("Y Interval Chart Demo"); 125 demo.pack(); 126 RefineryUtilities.centerFrameOnScreen(demo); 127 demo.setVisible(true); 128 129 } 130 131 } 132 | Popular Tags |