The series displayed on charts generated with the Graph class have
data points distributed in a regular sequence that follows the labels progression.
This sequence is continuous, in that for each label there is always a
visible data point.
In certain conditions, however, there might be series with a discontinuous sequence
of values, in which case gaps have to be inserted where no data points are to be
displayed.
Series data points are always a continuous sequence of values,
typically passed as arrays of double precision numbers, which can't have empty
entries that could be taken as indicators as to the positions where a series sequence
should be interrupted.
The method GraphSerie.setCoordinatesStatus(int[] coordinatesStatus)
overcomes this problem using a sequence of binary digits to indicate what data points
shall be displayed or not. A value of '0' means that the corresponding data point
is hidden, whereas a value of '1' keeps the data point visible.
The 'coordinatesStatus' array follows the same sequence of a series data points.
The LineSerie class overloads the method above to take a second parameter, a boolean
flag, to indicate whether a fragmented sequence of lines shall be connected or not.
Except for the AreaSerie class, all subclasses of GraphSerie support
the coordinates status method.
The following example displays a line series using the overloaded version of the method
'setCoordinatesStatus'. There are points which are ignored and the line segments are
sequentially connected to each other.
import javax.swing.*; import java.awt.*; import com.jinsight.jetchart.*; public class Main extends JFrame { public Main() { Graph graph=new Graph(); String[] labels={"l1","l2","l3","l4","l5","l6","l7","l8","l9","l10"}; graph.setLabels(labels); GraphSet graphSet=graph.getGraphSet(0); Grid grid=graphSet.getGrid(); grid.setEnabled(true); grid.setColor(Color.gray); String[] title={"The JetChart Library","Controlling grid lines visibility"}; graph.setTitle(title); Container ct=getContentPane(); ct.add("Center",graph); LineSerie ls=new LineSerie(); ls.setTitle("Line series"); ls.setColor(Color.red); double[] values={100,80,90,110,55,60,73,83,110,120}; ls.setValues(values); int[] coordinatesStatus={1,0,0,0,1,1,1,0,0,1}; ls.setCoordinatesStatus(coordinatesStatus,true); graph.addSerie(ls); setSize(400,300); setVisible(true); } public static void main(String[] args) { new Main(); } }