As explained here, a GraphSet is an object used to group series and plot them against different scales. JetChart
uses the full extension of the vertical axis to arrange scales. If series are grouped into more than one GraphSet object, each GraphSet scale is,
by default, arranged along the left vertical axis, in which case the scales labels overlap each other. If only two scales are displayed, a
workaround is to move one of the scales to the right vertical axis. However, if more than two scales are displayed, the only solution is to
stack the GraphSet objects vertically, setting the start and end scale points in terms of fractions of the full vertical y axis extension.
Scale edges can be manually set or automatically calculated. The following example displays three series grouped into three GraphSet objects. The
scales edges are manually adjusted to prevent scales labels from overlapping each other.
To let JetChart automatically calculate the start and end scale points, set the method
Graph.setAutoScalePositioningEnabled(boolean isAutoScalePositioningEnabled) to true.
import javax.swing.*; import java.awt.*; import com.jinsight.jetchart.*; public class Main extends JFrame { public Main() { Graph graph=new Graph(); graph.setTitle(new String[]{"The JetChart Library","Stacking GraphSet objects"}); // Creates two secondary GraphSet objects and adds them to chart context. GraphSet graphSet1=new GraphSet(); GraphSet graphSet2=new GraphSet(); graph.addGraphSet(graphSet1); graph.addGraphSet(graphSet2); // Sets the scales start and end points of the primary and secondary GraphSet objects. GraphSet graphSet0=graph.getGraphSet(0); graphSet0.getScale().setStartPoint(0F); graphSet0.getScale().setEndPoint(.3F); graphSet1.getScale().setStartPoint(.38F); graphSet1.getScale().setEndPoint(.63F); graphSet2.getScale().setStartPoint(.70F); graphSet2.getScale().setEndPoint(1F); // Sets the position of the secondary scales. graphSet1.getScale().setPosition(Scale.LEFT_RIGHT); graphSet2.getScale().setPosition(Scale.RIGHT); // Sets the format of the scale values. graphSet0.getScale().setValueFormat("US$ ###,###"); graphSet1.getScale().setValueFormat("###M"); graphSet2.getScale().setValueFormat("###%"); // Creates the series, adding the bar series and the area series to the // secondary GraphSet objects. LineSerie ls=new LineSerie(new double[]{45200,32100,35450,40000,38000,30000},"Line series"); ls.setColor(Color.red); BarSerie bs=new BarSerie(new double[]{130,150,90,110,70,85},"Bar series"); bs.setColor(new Color(00,99,00)); graphSet1.addSerie(bs); AreaSerie as=new AreaSerie(new double[]{.45,.30,.35,.50,.53,.40},"Area series"); as.setColor(Color.yellow); graphSet2.addSerie(as); // The series has to be also added to the chart context. graph.addSerie(ls); graph.addSerie(bs); graph.addSerie(as); Container ct=getContentPane(); ct.add(graph); setSize(450,350); setVisible(true); } public static void main(String[] args) { new Main(); } }