[]
        
(Showing Draft Content)

ITickLabels

Interface ITickLabels


public interface ITickLabels
Represents the tick-mark labels associated with a chart axis.

Use this interface to format and position axis labels, including their font, number format, text direction, text orientation, and label offset. An ITickLabels object is returned by IAxis.getTickLabels().


 worksheet.getRange("A1:B4").setValue(new Object[][] {
     {"Month", "Sales"},
     {"Jan", 1200}, {"Feb", 1500}, {"Mar", 1800}
 });
 IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 230);
 shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
 IAxis categoryAxis = shape.getChart().getAxes().item(AxisType.Category);
 ITickLabels tickLabels = categoryAxis.getTickLabels();
 tickLabels.setDirection(TextDirection.Vertical);
 
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the text direction for the tick-mark labels.
    Gets the IFontFormat object for the tick labels.
    Gets the number format code for the tick labels.
    boolean
    Gets whether the tick label number format is linked to the source cells.
    int
    Gets the distance between label levels and between the first label level and the axis line.
    int
    Gets the text orientation of the tick-mark labels.
    Gets the parent IAxis that contains these tick labels.
    void
    Sets the text direction for the tick-mark labels.
    void
    Sets the number format code for the tick labels.
    void
    setNumberFormatLinked(boolean value)
    Sets whether the tick label number format is linked to the source cells.
    void
    setOffset(int value)
    Sets the distance between label levels and between the first label level and the axis line.
    void
    setOrientation(int value)
    Sets the text orientation of the tick-mark labels.
  • Method Details

    • getFont

      IFontFormat getFont()
      Gets the IFontFormat object for the tick labels.

      Use the returned font format to read or modify font settings for the text displayed in the chart axis tick labels.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Month", "Sales"},
           {"Jan", 1200},
           {"Feb", 1500},
           {"Mar", 1100}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
       IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
       IFontFormat font = axis.getTickLabels().getFont();
       font.getColor().setRGB(Color.GetBlue());
       
      Returns:
      The IFontFormat object for the tick labels.
    • getNumberFormat

      String getNumberFormat()
      Gets the number format code for the tick labels.

      The returned format code controls how numeric values are displayed on the chart axis, such as currency, percentage, or decimal formatting.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Month", "Sales"},
           {"Jan", 1200},
           {"Feb", 1500},
           {"Mar", 1100}
       });
       worksheet.getRange("B2:B4").setNumberFormat("$#,##0");
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
       IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
       String numberFormat = axis.getTickLabels().getNumberFormat();
       
      Returns:
      The number format code for the tick labels.
    • setNumberFormat

      void setNumberFormat(String value)
      Sets the number format code for the tick labels.

      The returned format code controls how numeric values are displayed on the chart axis, such as currency, percentage, or decimal formatting.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Month", "Sales"},
           {"Jan", 1200},
           {"Feb", 1500},
           {"Mar", 1100}
       });
       worksheet.getRange("B2:B4").setNumberFormat("$#,##0");
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
       IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
       axis.getTickLabels().setNumberFormat("Sample");
       
      Parameters:
      value - The number format code for the tick labels.
    • getNumberFormatLinked

      boolean getNumberFormatLinked()
      Gets whether the tick label number format is linked to the source cells.

      If this property is true, changes to the number format in the source cells are reflected in the axis tick labels.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Month", "Sales"},
           {"Jan", 1200},
           {"Feb", 1500},
           {"Mar", 1100}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
       IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
       axis.getTickLabels().setNumberFormatLinked(false);
       boolean linked = axis.getTickLabels().getNumberFormatLinked();
       
      Returns:
      true if the tick label number format is linked to the source cells; otherwise, false.
    • setNumberFormatLinked

      void setNumberFormatLinked(boolean value)
      Sets whether the tick label number format is linked to the source cells.

      If this property is true, changes to the number format in the source cells are reflected in the axis tick labels.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Month", "Sales"},
           {"Jan", 1200},
           {"Feb", 1500},
           {"Mar", 1100}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
       IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
       axis.getTickLabels().setNumberFormatLinked(false);
       
      Parameters:
      value - true if the tick label number format is linked to the source cells; otherwise, false.
    • getOffset

      int getOffset()
      Gets the distance between label levels and between the first label level and the axis line.

      Use this property to read the current spacing applied to tick-mark labels on a chart axis.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Month", "Sales"},
           {"Jan", 120},
           {"Feb", 150},
           {"Mar", 110}
       });
       IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, worksheet.getRange("A1:B4"));
       IAxis axis = shape.getChart().getAxes().item(AxisType.Category);
       int offset = axis.getTickLabels().getOffset();
       
      Returns:
      The distance between label levels and between the first label level and the axis line.
    • setOffset

      void setOffset(int value)
      Sets the distance between label levels and between the first label level and the axis line.

      Use this property to set the spacing applied to tick-mark labels on a chart axis.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Month", "Sales"},
           {"Jan", 120},
           {"Feb", 150},
           {"Mar", 110}
       });
       IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, worksheet.getRange("A1:B4"));
       IAxis axis = shape.getChart().getAxes().item(AxisType.Category);
       axis.getTickLabels().setOffset(0);
       
      Parameters:
      value - The distance between label levels and between the first label level and the axis line.
    • getOrientation

      int getOrientation()
      Gets the text orientation of the tick-mark labels.

      The returned value represents the rotation angle of the tick-mark label text, in degrees.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Month", "Sales"},
           {"Jan", 100},
           {"Feb", 200}
       });
       IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, worksheet.getRange("A1:B3"));
       IAxis axis = shape.getChart().getAxes().item(AxisType.Category);
       int orientation = axis.getTickLabels().getOrientation();
       
      Returns:
      The text orientation of the tick-mark labels, in degrees.
    • setOrientation

      void setOrientation(int value)
      Sets the text orientation of the tick-mark labels.

      Set this property to specify the rotation angle of the tick-mark label text, in degrees.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Month", "Sales"},
           {"Jan", 100},
           {"Feb", 200}
       });
       IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, worksheet.getRange("A1:B3"));
       IAxis axis = shape.getChart().getAxes().item(AxisType.Category);
       axis.getTickLabels().setOrientation(0);
       
      Parameters:
      value - The text orientation of the tick-mark labels, in degrees.
    • getDirection

      TextDirection getDirection()
      Gets the text direction for the tick-mark labels.

      Use this method to determine how the text in chart axis tick labels is oriented, such as horizontal or vertical layout.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Month", "Sales"},
           {"Jan", 1200},
           {"Feb", 1500},
           {"Mar", 1100}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
       IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
       TextDirection direction = axis.getTickLabels().getDirection();
       
      Returns:
      The TextDirection value that specifies the text direction for the tick-mark labels.
    • setDirection

      void setDirection(TextDirection value)
      Sets the text direction for the tick-mark labels.

      Use this method to control how the axis tick-label text is displayed, such as horizontal or vertical layout.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Month", "Sales"},
           {"Jan", 1200},
           {"Feb", 1500},
           {"Mar", 1100}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
       IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
       axis.getTickLabels().setDirection(TextDirection.Vertical);
       
      Parameters:
      value - The text direction to apply to the tick-mark labels.
    • getParent

      IAxis getParent()
      Gets the parent IAxis that contains these tick labels.

      Use this method to access the axis associated with the current tick labels when you need to continue configuring the axis after working with its labels.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Month", "Sales"},
           {"Jan", 100},
           {"Feb", 200}
       });
       IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 230);
       shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
       IAxis parentAxis = shape.getChart().getAxes().item(AxisType.Category).getTickLabels().getParent();
       
      Returns:
      The parent IAxis that contains these tick labels.