1 38 39 package org.jfree.chart.demo; 40 41 import org.jfree.chart.ChartFactory; 42 import org.jfree.chart.ChartFrame; 43 import org.jfree.chart.JFreeChart; 44 import org.jfree.data.SeriesException; 45 import org.jfree.data.XYDataset; 46 import org.jfree.data.time.Day; 47 import org.jfree.data.time.TimeSeries; 48 import org.jfree.data.time.TimeSeriesCollection; 49 import org.jfree.ui.RefineryUtilities; 50 51 58 public class TimeSeriesDemo5 { 59 60 71 76 public static void main(String [] args) { 77 78 TimeSeries series = new TimeSeries("Random Data"); 79 80 Day current = new Day(1, 1, 1990); 81 double value = 100.0; 82 83 for (int i = 0; i < 4000; i++) { 84 try { 85 value = value + Math.random() - 0.5; 86 series.add(current, new Double (value)); 87 current = (Day) current.next(); 88 } 89 catch (SeriesException e) { 90 System.err.println("Error adding to series"); 91 } 92 } 93 94 XYDataset data = new TimeSeriesCollection(series); 95 96 JFreeChart chart = ChartFactory.createTimeSeriesChart( 97 "Test", 98 "Day", 99 "Value", 100 data, 101 false, 102 false, 103 false 104 ); 105 106 ChartFrame frame = new ChartFrame( 107 "\u20A2\u20A2\u20A2\u20A3\u20A4\u20A5\u20A6\u20A7\u20A8\u20A9\u20AA", chart 108 ); 109 frame.pack(); 110 RefineryUtilities.positionFrameRandomly(frame); 111 frame.setVisible(true); 112 113 } 114 115 } 116 | Popular Tags |