1 39 package org.jfree.chart.demo; 40 41 import java.awt.BasicStroke ; 42 import java.awt.Color ; 43 44 import org.jfree.chart.ChartFactory; 45 import org.jfree.chart.ChartFrame; 46 import org.jfree.chart.JFreeChart; 47 import org.jfree.chart.plot.PlotOrientation; 48 import org.jfree.chart.plot.XYPlot; 49 import org.jfree.data.XYDataset; 50 import org.jfree.ui.RefineryUtilities; 51 52 57 public class XYStepChartDemo { 58 59 60 private ChartFrame frame = null; 61 62 65 private void displayChart() { 66 67 if (frame == null) { 68 69 String title = "LCACs in use at given time"; 71 String xAxisLabel = "Time"; 72 String yAxisLabel = "Number of Transports"; 73 74 XYDataset data = DemoDatasetFactory.createStepXYDataset(); 75 76 JFreeChart chart = ChartFactory.createXYStepChart( 77 title, 78 xAxisLabel, yAxisLabel, 79 data, 80 PlotOrientation.VERTICAL, 81 true, true, false ); 85 86 chart.setBackgroundPaint(new Color (216, 216, 216)); 88 XYPlot plot = chart.getXYPlot(); 89 plot.getRenderer().setSeriesStroke(0, new BasicStroke (2.0f)); 90 plot.getRenderer().setSeriesStroke(1, new BasicStroke (2.0f)); 91 92 frame = new ChartFrame("Plan Comparison", chart); 94 frame.pack(); 95 RefineryUtilities.positionFrameRandomly(frame); 96 frame.show(); 97 98 } 99 else { 100 frame.show(); 101 frame.requestFocus(); 102 } 103 104 } 105 106 117 122 public static void main(String [] args) { 123 124 XYStepChartDemo demo = new XYStepChartDemo(); 125 demo.displayChart(); 126 127 } 128 129 } 130 | Popular Tags |