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.chart.axis.ValueAxis; 45 import org.jfree.chart.plot.PlotOrientation; 46 import org.jfree.chart.plot.XYPlot; 47 import org.jfree.chart.renderer.StandardXYItemRenderer; 48 import org.jfree.chart.renderer.XYItemRenderer; 49 import org.jfree.data.XYSeries; 50 import org.jfree.data.XYSeriesCollection; 51 52 57 public class Second { 58 59 64 public static void main(String [] args) { 65 66 XYSeries series1 = new XYSeries("Advisory Range"); 68 series1.add(new Integer (1200), new Integer (1)); 69 series1.add(new Integer (1500), new Integer (1)); 70 71 XYSeries series2 = new XYSeries("Normal Range"); 72 series2.add(new Integer (2000), new Integer (4)); 73 series2.add(new Integer (2300), new Integer (4)); 74 75 XYSeries series3 = new XYSeries("Recommended"); 76 series3.add(new Integer (2100), new Integer (2)); 77 78 XYSeries series4 = new XYSeries("Current"); 79 series4.add(new Integer (2400), new Integer (3)); 80 81 XYSeriesCollection data = new XYSeriesCollection(); 82 data.addSeries(series1); 83 data.addSeries(series2); 84 data.addSeries(series3); 85 data.addSeries(series4); 86 87 JFreeChart chart = ChartFactory.createXYLineChart( 89 "My Chart", 90 "Calories", 91 "Y", 92 data, 93 PlotOrientation.VERTICAL, 94 true, 95 true, 96 false 97 ); 98 99 110 XYItemRenderer renderer 111 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES, null); 112 XYPlot plot = (XYPlot) chart.getPlot(); 113 plot.setRenderer(renderer); 114 ValueAxis axis = plot.getRangeAxis(); 115 axis.setTickLabelsVisible(false); 116 axis.setRange(0.0, 5.0); 117 118 ChartFrame frame = new ChartFrame("Test", chart); 120 frame.pack(); 121 frame.setVisible(true); 122 123 } 124 125 } 126 | Popular Tags |