Titles can be displayed at the top, left, right and bottom sides of the chart area. The
previous example was modified to display titles. The left, right and bottom titles are
objects internally created and held by the GenericGraph class, which is the superclass of
the Graph object. The constructors of these objects are not public.
There is no change as to the way titles are configured when displaying scatter charts and
pie charts.
import javax.swing.*; import java.awt.*; import com.jinsight.jetchart.*; public class Main extends JFrame { public Main() { Graph graph=new Graph(); String[] title={"The JetChart Library","Displaying titles"}; graph.setTitle(title); LeftTitle lt=graph.getLeftTitle(); lt.setText("Left title"); RightTitle rt=graph.getRightTitle(); rt.setText("Right title"); BottomTitle bt=graph.getBottomTitle(); bt.setText("Bottom title"); Container ct=getContentPane(); ct.add("Center",graph); LineSerie ls=new LineSerie(); ls.setTitle("Line series"); ls.setColor(Color.red); double[] values1={100,80,90,110}; ls.setValues(values1); BarSerie bs=new BarSerie(); bs.setTitle("Bar series"); bs.setColor(Color.blue); double[] values2={50,70,85,130}; bs.setValues(values2); graph.addSerie(ls); graph.addSerie(bs); setSize(400,300); setVisible(true); } public static void main(String[] args) { new Main(); } }