1 39 40 package org.jfree.chart.demo; 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.PlotOrientation; 46 import org.jfree.data.XYSeries; 47 import org.jfree.data.XYSeriesCollection; 48 import org.jfree.ui.ApplicationFrame; 49 import org.jfree.ui.RefineryUtilities; 50 51 56 public class XYSeriesDemo extends ApplicationFrame { 57 58 63 public XYSeriesDemo(String title) { 64 65 super(title); 66 XYSeries series = new XYSeries("Random Data"); 67 series.add(1.0, 500.2); 68 series.add(5.0, 694.1); 69 series.add(4.0, 100.0); 70 series.add(12.5, 734.4); 71 series.add(17.3, 453.2); 72 series.add(21.2, 500.2); 73 series.add(21.9, null); 74 series.add(25.6, 734.4); 75 series.add(30.0, 453.2); 76 XYSeriesCollection data = new XYSeriesCollection(series); 77 JFreeChart chart = ChartFactory.createXYLineChart( 78 "XY Series Demo", 79 "X", 80 "Y", 81 data, 82 PlotOrientation.VERTICAL, 83 true, 84 true, 85 false 86 ); 87 88 ChartPanel chartPanel = new ChartPanel(chart); 89 chartPanel.setPreferredSize(new java.awt.Dimension (500, 270)); 90 setContentPane(chartPanel); 91 92 } 93 94 105 110 public static void main(String [] args) { 111 112 XYSeriesDemo demo = new XYSeriesDemo("XY Series Demo"); 113 demo.pack(); 114 RefineryUtilities.centerFrameOnScreen(demo); 115 demo.setVisible(true); 116 117 } 118 119 } 120 | Popular Tags |