1 import org.faceless.graph2.*; 2 import java.awt.Color ; 3 import java.io.FileOutputStream ; 4 import java.io.IOException ; 5 6 public class LineBarExample 7 { 8 public static void main (String args[]) throws IOException 9 { 10 BarSeries barseries1 = new BarSeries("bars"); 13 barseries1.set("apples", 10); 14 barseries1.set("bananas", 30); 15 barseries1.set("cranberries", 25); 16 barseries1.set("dates", 15); 17 barseries1.set("eggs", 10); 18 barseries1.set("figs", 50); 19 barseries1.set("guava", 6); 20 21 LineSeries lineseries1 = new LineSeries("lines"); 24 lineseries1.set(0,10); 25 lineseries1.set(1,32); 26 lineseries1.set(2,18); 27 lineseries1.set(3,24); 28 lineseries1.set(4,27); 29 lineseries1.set(5,32); 30 lineseries1.set(6,22); 31 32 Style style = new Style(Color.yellow); 35 style.setLineDash(new double[] { 5, 5 }); 36 lineseries1.setStyle(style); 37 38 AxesGraph graph = new AxesGraph(); 41 graph.addSeries(lineseries1); 42 graph.addSeries(barseries1); 43 graph.setXRotation(30); 44 graph.setYRotation(20); 45 46 graph.getAxis(Axis.LEFT).setLabel("Y Axis Label", new TextStyle("Default", 11, Color.black)); 49 graph.getAxis(Axis.BOTTOM).setLabel("X Axis Label", new TextStyle("Default", 11, Color.black)); 50 51 Key key = new Key(new Style(Color.ORANGE)); 54 key.addSeries(lineseries1, new TextStyle("Courier", 12, Color.BLACK)); 55 key.addSeries(barseries1, new TextStyle("Arial", 12, Color.BLUE)); 56 graph.addKey(key, Align.RIGHT); 57 58 ImageOutput image = new ImageOutput(500,500); 61 graph.draw(image); 62 FileOutputStream out = new FileOutputStream ("LineBarExample.png"); 63 image.writePNG(out, 0); 64 out.close(); 65 } 66 } 67 | Popular Tags |