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.data.MovingAverage; 44 import org.jfree.data.time.TimeSeries; 45 import org.jfree.data.time.TimeSeriesCollection; 46 import org.jfree.ui.ApplicationFrame; 47 import org.jfree.ui.RefineryUtilities; 48 49 54 public class TimeSeriesDemo8 extends ApplicationFrame { 55 56 61 public TimeSeriesDemo8(String title) { 62 63 super(title); 64 65 String chartTitle = "Time Series Demo"; 67 TimeSeries eur = DemoDatasetFactory.createEURTimeSeries(); 68 TimeSeries mav = MovingAverage.createMovingAverage(eur, "30 day moving average", 30, 30); 69 TimeSeriesCollection dataset = new TimeSeriesCollection(); 70 dataset.addSeries(eur); 71 dataset.addSeries(mav); 72 73 JFreeChart chart = ChartFactory.createTimeSeriesChart( 74 chartTitle, 75 "Date", 76 "Value", 77 dataset, 78 true, 79 true, 80 false 81 ); 82 83 ChartPanel chartPanel = new ChartPanel(chart); 84 chartPanel.setPreferredSize(new java.awt.Dimension (500, 270)); 85 chartPanel.setMouseZoomable(true, false); 86 setContentPane(chartPanel); 87 88 } 89 90 101 106 public static void main(String [] args) { 107 108 TimeSeriesDemo8 demo = new TimeSeriesDemo8("Time Series Demo 8"); 109 demo.pack(); 110 RefineryUtilities.centerFrameOnScreen(demo); 111 demo.setVisible(true); 112 113 } 114 115 } 116 | Popular Tags |