ceTe Software Help Library for Java August - 2020
DynamicPDF Generator for Java / Programming with Generator for Java / Charts / Chart Elements / Grid Lines
In This Topic
    Grid Lines
    In This Topic

    GridLines are vertical and horizontal lines that are added in conjunction to the Tick Marks on the XAxis and the YAxis respectively. Adding Grid lines makes data in the chart easier to read and interpret. There are two types of Grid lines:

    XAxisGridLines are added vertically to the Plot Area. MajorGridLines are drawn for each MajorTickMark and MinorGridLines are drawn for each MinorTickMark on the XAxis. By default the XAxisGridLines are turned off.

    The below code shows how to add XAxisGridLines:

    [Java]
         Chart chart = new Chart(0, 0, 300, 200);
         PlotArea plotArea = chart.getPrimaryPlotArea();
         plotArea.getXAxes().getDefaultNumericXAxis().setMajorGridLines(new XAxisGridLines());
         plotArea.getXAxes().getDefaultNumericXAxis().setMinorGridLines( new XAxisGridLines());                 
    
    YAxisGridLines are added horizontally to the Plot Area. MajorGridLines are drawn for each MajorTickMark and MinorGridLines are drawn for each MinorTickMark on the YAxis. By default the YAxisGridLines are turned off.

    The below code shows how to add YAxisGridLines:

    [Java]  
         Chart chart = new Chart(0, 0, 300, 200);
         PlotArea plotArea = chart.getPrimaryPlotArea();
         plotArea.getYAxes().getDefaultNumericYAxis().setMajorGridLines(new YAxisGridLines());
         plotArea.getYAxes().getDefaultNumericYAxis().setMinorGridLines(new YAxisGridLines());
    
    See Also