Target lines

A target line is used to compare series data points values against an indicator that acts as a delimiter, which usually represents a goal to achieve or a boundary beyond which data points might be considered as undesired deviations.

Target lines are represented by the TargetLine class. Instances of this class are held by GraphSet objects, and there is no limitation on the number of target lines that can be added to the chart context. A target line is an exclusive implementation of the chart context represented by the Graph class. ScatterGraph and PieGraph does not support target lines.

The code below displays a 3D bar chart and a horizontal target line.

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

public class Main extends JFrame  {

   public Main() {

        Graph graph=new Graph();

        graph.setTitle(new String[]{"The JetChart Library","Target lines"});

        graph.set3DEnabled(true);
        graph.setVDepth(5);

        graph.setBackground(Color.decode("#ccffff"));
        
        TargetLine tl=new TargetLine(7);
        tl.setColor(Color.red);
        
        GraphSet graphSet=graph.getGraphSet(0);
        graphSet.addTargetLine(tl);
        
        double[] values={4.5,6.3,7.8,9.2,5.5,8.1,6.5,3.9,7.8,8.6};
        Color[] colors={Color.red,Color.red,Color.green,Color.green,Color.red,Color.green,
                        Color.red,Color.red,Color.green,Color.green};

        BarSerie bs=new BarSerie(values);
        bs.setColors(colors);
        bs.setTitle("Bar series");
        bs.setBorderEnabled(false);
        bs.setLegendEnabled(false);

        graph.addSerie(bs);

        Container ct=getContentPane();
        ct.add(graph);

        setSize(500,250);
        setVisible(true);
   }

   public static void main(String[] args) {
       new Main();
   }

}