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.data.HighLowDataset; 45 import org.jfree.ui.ApplicationFrame; 46 import org.jfree.ui.RefineryUtilities; 47 48 53 public class CandlestickDemo extends ApplicationFrame { 54 55 60 public CandlestickDemo(String title) { 61 62 super(title); 63 64 HighLowDataset dataset = DemoDatasetFactory.createHighLowDataset(); 65 JFreeChart chart = createChart(dataset); 66 chart.getXYPlot().setOrientation(PlotOrientation.VERTICAL); 67 ChartPanel chartPanel = new ChartPanel(chart); 68 chartPanel.setPreferredSize(new java.awt.Dimension (500, 270)); 69 setContentPane(chartPanel); 70 71 } 72 73 80 private JFreeChart createChart(HighLowDataset dataset) { 81 JFreeChart chart = ChartFactory.createCandlestickChart( 82 "Candlestick Demo", 83 "Time", 84 "Value", 85 dataset, 86 true 87 ); 88 return chart; 89 } 90 91 102 107 public static void main(String [] args) { 108 109 CandlestickDemo demo = new CandlestickDemo("Candlestick Demo"); 110 demo.pack(); 111 RefineryUtilities.centerFrameOnScreen(demo); 112 demo.setVisible(true); 113 114 } 115 116 } 117 | Popular Tags |