The scrolling label and the scrolling bar

Charts built with the Graph class automatically control labels spacing along the horizontal or vertical axis, to prevent labels from overlapping each other. The labels coordinates are sequentially checked, and should one label overlaps a previous one, it is not displayed.
A drawback to this approach is that some series data points cannot be identified by its respective label, since it is not displayed. A scrolling label can be used to address this shortcoming. It can be configured to be displayed at two different locations while mouse is moved across the chart area.

A scrolling bar is simply a line that crosses the chart area to help identify series data points while mouse cursor is moved. It can be used in conjunction with tooltips to accurately identify which series data points are associated with tooltips values.

The following application displays a line series and the scrolling label is enabled and placed above the top of the graph area. A vertical scrolling bar is also enabled.


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

public class Main extends JFrame  {

   public Main() {

        Graph graph=new Graph();
        graph.setTitle(new String[]{"The JetChart Library","The scrolling label and the scrolling bar"});
        
        ScrollingLabel sl=graph.getScrollingLabel();
        sl.setEnabled(true);

        GraphSet graphSet=graph.getGraphSet(0);
        ScrollingBar sb=graphSet.getScrollingBar();
        sb.setEnabled(true);
        
        graph.setStartDate("05012002");
        graph.setMonthLabelsEnabled(true);

        ToolTip tt=graph.getToolTip();
        tt.setEnabled(true);
        tt.setMultipleEnabled(true);
        tt.setPointerType(ToolTip.NONE);
        tt.setMatchingBorderEnabled(true);

        // Disables automatic scale and sets maximum, minimum and increment values.
        Scale scale=graphSet.getScale();
        scale.setAutoScaleEnabled(false);
        scale.setMaxValue(140);
        scale.setMinValue(90);
        scale.setIncrement(10);

        // Enables grid.
        Grid grid=graphSet.getGrid();
        grid.setEnabled(true);
        grid.setStyle(Grid.DASHED);
        grid.setColor(Color.lightGray);

        // Creates a line series
        double[] values={131.90,132.80,130.50,131.00,136.75,135.00,131.50,130.50,
                         132.40,133.30,130.90,123.40,122.25,118.00,120.00,116.10,
                         115.00,103.45,107.50,103.80,99.00,96.75,94.00,95.90,97.50,
                         98.40,100.20,102.00,110.40,104.50,108.70,107.75,107.45};

       LineSerie ls=new LineSerie(values,"Line series");
       ls.setColor(Color.blue);
       ls.setMarksEnabled(false);
       ls.setThickness(2);

       graph.addSerie(ls);

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

       setSize(450,300);
       setVisible(true);
   }

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

}