Grid

The Grid node controls the drawing of grid lines on a chart. The Grid is created by Axis1D as its child. It can be retrieved using the method Axis1D.getGrid().

By default, Grid nodes are not drawn. To enable them, set their Paint attribute to true. Grid nodes control the drawing of the grid lines perpendicular to their parent axis. So the x-axis Grid node controls the drawing of the vertical grid lines.

Example

In this example, the x-axis grid lines are painted light gray and the y-axis grid lines are pink.

 

(Download Code)

 

import com.imsl.chart.*;

 

public class SampleGrid extends JFrameChart {

 

    public SampleGrid() {       

        Chart chart = getChart();

        AxisXY axis = new AxisXY(chart);

       

        axis.getAxisX().getGrid().setPaint(true);

        axis.getAxisY().getGrid().setPaint(true);

        axis.getAxisX().getGrid().setLineColor(java.awt.Color.lightGray);

        axis.getAxisY().getGrid().setLineColor(java.awt.Color.pink);

        double y[] = {4, 6, 2, 1, 8};

        Data data = new Data(axis, y);

        data.setDataType(Data.DATA_TYPE_LINE);

        data.setLineColor(java.awt.Color.blue);

    }

   

    public static void main(String argv[]) {

        new SampleGrid().setVisible(true);

    }

}

 

 



Visual Numerics - Developers of IMSL and PV-WAVE
http://www.vni.com/
PHONE: 713.784.3131
FAX:713.781.9260