Enabling tooltips

Tooltips are popup windows displayed when mouse cursor is moved over a valid data point area. The content of a tooltip is, by default, the value associated with a data point.

The class that represents tooltips is com.jinsight.jetchart.ToolTip. It is created and held by subclasses of the GenericGraph class and has no public constructor.

The following example displays a bar series and a point series. A tooltip instantly pops up if mouse is moved to an area within any bar or point displayed.


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","Enabling tooltips"});
       
       ToolTip tt=graph.getToolTip();
       tt.setEnabled(true);
       
       Grid grid=graph.getGraphSet(0).getGrid();
       grid.setEnabled(true);
       grid.setColor(Color.gray);
       grid.setStyle(Grid.DASHED);

       double[] values1={100,200,150,300,90};
       double[] values2={150,230,190,350,180};
       
       BarSerie bs=new BarSerie(values1,"Bar series");
       bs.setColor(Color.green);

       PointSerie ps=new PointSerie(values2,"Point series");
       ps.setColor(Color.yellow);

       graph.addSerie(bs);
       graph.addSerie(ps);

       Container ct=getContentPane();
       
       ct.add("Center",graph);
       
       setSize(400,300);
       
       setVisible(true);

  }

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

}