[]
        
(Showing Draft Content)

IGridlines

Interface IGridlines


public interface IGridlines
Represents major or minor gridlines on a chart axis.

Use this interface to access the formatting of chart axis gridlines and to navigate to the owning IAxis. Gridlines are typically obtained from IAxis.getMajorGridlines() or IAxis.getMinorGridlines().


 IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 250, 20, 360, 230);
 worksheet.getRange("A1:B4").setValue(new Object[][] {{"Month", "Sales"}, {"Jan", 10}, {"Feb", 25}, {"Mar", 18}});
 shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
 IAxis valueAxis = shape.getChart().getAxes().item(AxisType.Value);
 valueAxis.setHasMajorGridlines(true);
 IGridlines gridlines = valueAxis.getMajorGridlines();
 gridlines.getFormat().getLine().getColor().setRGB(Color.GetGray());
 
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the format of the gridlines.
    Gets the IAxis object that contains these gridlines.
  • Method Details

    • getParent

      IAxis getParent()
      Gets the IAxis object that contains these gridlines.

      Use this method to access the parent axis of major or minor gridlines on a chart.

      
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
       IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
       axis.setHasMajorGridlines(true);
       IGridlines gridlines = axis.getMajorGridlines();
       IAxis parentAxis = gridlines.getParent();
       
      Returns:
      The parent IAxis object that contains these gridlines.
    • getFormat

      IChartFormat getFormat()
      Gets the format of the gridlines.

      Use the returned IChartFormat object to access and modify the formatting applied to major or minor gridlines on a chart axis.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Month", "Sales"},
           {"Jan", 10},
           {"Feb", 15}
       });
       IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 0, 0, 300, 200);
       shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B3"));
       IGridlines gridlines = shape.getChart().getAxes().item(AxisType.Value).getMajorGridlines();
       IChartFormat format = gridlines.getFormat();
       format.getLine().getColor().setRGB(Color.GetBlue());
       
      Returns:
      The IChartFormat object that represents the gridline formatting.