The method Scale.setVisibleLabelsIndexes(int[] visibleLabelsIndexes)
gives control over what scale labels shall be displayed or not. It takes an
array of integer containing the indexes of the only visible labels, ranging
from 0 to the maximum number of labels minus 1.
The labels indexes increase from top to bottom or left to right, whether
chart is vertical or horizontal, respectively.
The following example sets the indexes of the only visible scale labels to
0, 2 and 4.
import javax.swing.*; import java.awt.*; import com.jinsight.jetchart.*; public class Main extends JFrame { public Main() { Graph graph=new Graph(new String[]{"l1","l2","l3","l4","l5","l6","l7","l8","l9"}); graph.setTitle(new String[]{"The JetChart Library","Configuring scales"}); double[] values={20007,20005,20006,20004,20003,20005,20007,20009,20006}; AreaSerie as=new AreaSerie(values,"Area series"); as.setColor(new Color(00,99,00)); GraphSet graphSet=graph.getGraphSet(0); Scale scale=graphSet.getScale(); // The maximum, minimum and increment values only can be configured if the // automatic scale is disabled. scale.setAutoScaleEnabled(false); scale.setMaxValue(20010); scale.setMinValue(20000); scale.setIncrement(2); scale.setValueFormat("##,###"); int[] visibleLabelsIndexes={0,2,4}; scale.setVisibleLabelsIndexes(visibleLabelsIndexes); graphSet.getGrid().setEnabled(true); graphSet.getGrid().setColor(Color.gray); graphSet.getGrid().setStyle(Grid.DASHED); graph.addSerie(as); Container ct=getContentPane(); ct.add(graph); setSize(450,350); setVisible(true); } public static void main(String[] args) { new Main(); } }