Combining series

JetChart represents a series as an individual object, which has to be created, configured and added to the chart context. This approach makes it possible to create instances of different types of series and simultaneously display them on the same chart context. Unlike Graph and ScatterGraph, the PieGraph class only supports one series.
It is not possible to combine Graph series with ScatterGraph series. However, it is possible to combine an unlimited number of different types of series belonging to the same type of chart context.

The application below creates one line series and one bar series, adding them to the same chart context.

import javax.swing.*;
import java.awt.*;
import com.jinsight.jetchart.*;

public class Main extends JFrame {

   public Main() { 

        Graph graph=new Graph();

        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();
  }

}