ExcelScript.ChartAxis interface

代表图表中的单个坐标轴。

注解

示例

/**
 * This sample customizes the value axis of a chart.
 * This assumes the active worksheet has a chart.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the first chart on the active worksheet.
  const sheet = workbook.getActiveWorksheet();
  const chart = sheet.getCharts()[0];
  
  // Customize the value axis.
  const valueAxis = chart.getAxes().getValueAxis();
  valueAxis.setMinimum(40000);
  valueAxis.setMaximum(60000);
  valueAxis.setDisplayUnit(ExcelScript.ChartAxisDisplayUnit.thousands);
}

方法

getAlignment()

指定指定轴刻度线标签的对齐方式。 有关详细信息,请参阅 ExcelScript.ChartTextHorizontalAlignment

getAxisGroup()

指定指定轴的组。 有关详细信息,请参阅 ExcelScript.ChartAxisGroup

getBaseTimeUnit()

指定指定类别轴的基本单位。

getCategoryType()

指定类别轴类型。

getCustomDisplayUnit()

指定自定义轴显示单位值。 若要设置此属性,请使用 SetCustomDisplayUnit(double) 方法。

getDisplayUnit()

表示轴显示单位。 有关详细信息,请参阅 ExcelScript.ChartAxisDisplayUnit

getFormat()

表示 chart 对象的格式,包括线条和字体格式。

getHeight()

指定图表轴的高度(以磅为单位)。 null如果轴不可见,则返回 。

getIsBetweenCategories()

指定值轴是否与类别之间的分类轴交叉。

getLeft()

指定从轴的左边缘到图表区左侧的距离(以磅为单位)。 null如果轴不可见,则返回 。

getLinkNumberFormat()

指定数字格式是否链接到单元格。 如果 true为 ,则当单元格中更改时,标签中的数字格式将更改。

getLogBase()

指定使用对数刻度时对数的基数。

getMajorGridlines()

返回一个 对象,该对象代表指定轴的主要网格线。

getMajorTickMark()

指定指定轴的主要刻度线的类型。 有关详细信息,请参阅 ExcelScript.ChartAxisTickMark

getMajorTimeUnitScale()

当 属性设置为 dateAxis时,categoryType指定类别轴的主要单位刻度值。

getMajorUnit()

指定两个主要刻度线之间的间隔。

getMaximum()

指定数值轴上的最大值。

getMinimum()

指定数值轴上的最小值。

getMinorGridlines()

返回一个 对象,该对象代表指定轴的次要网格线。

getMinorTickMark()

指定指定轴的次要刻度线的类型。 有关详细信息,请参阅 ExcelScript.ChartAxisTickMark

getMinorTimeUnitScale()

当 属性设置为 dateAxiscategoryType,指定类别轴的次要单位刻度值。

getMinorUnit()

指定两个次要刻度线之间的间隔。

getMultiLevel()

指定轴是否为多级轴。

getNumberFormat()

指定轴刻度线标签的格式代码。

getOffset()

指定标签级别之间的距离,以及第一级与轴线之间的距离。 此值应该是 0 到 1000 之间的整数。

getPosition()

指定其他轴交叉处的指定轴位置。 有关详细信息,请参阅 ExcelScript.ChartAxisPosition

getPositionAt()

指定其他轴交叉的轴位置。 应使用 SetPositionAt(double) 方法设置此属性。

getReversePlotOrder()

指定 Excel 是否从最后一个到第一个绘制数据点。

getScaleType()

指定数值轴刻度类型。 有关详细信息,请参阅 ExcelScript.ChartAxisScaleType

getShowDisplayUnitLabel()

指定轴显示单位标签是否可见。

getTextOrientation()

为图表轴刻度标签指定文本的方向。 对于垂直方向文本,该值应为 -90 到 90 的整数或整数 180。

getTickLabelPosition()

在指定坐标轴上指定刻度线标签的位置。 有关详细信息,请参阅 ExcelScript.ChartAxisTickLabelPosition

getTickLabelSpacing()

指定刻度线标签之间的类别或系列数。 可以是 1 到 31999 之间的一个数值。

getTickMarkSpacing()

指定刻度线之间的类别或系列数。

getTitle()

表示坐标轴标题。

getTop()

指定从轴的上边缘到图表区顶部的距离(以磅为单位)。 null如果轴不可见,则返回 。

getType()

指定坐标轴类型。 有关详细信息,请参阅 ExcelScript.ChartAxisType

getVisible()

指定轴是否可见。

getWidth()

指定图表轴的宽度(以磅为单位)。 null如果轴不可见,则返回 。

setAlignment(alignment)

指定指定轴刻度线标签的对齐方式。 有关详细信息,请参阅 ExcelScript.ChartTextHorizontalAlignment

setBaseTimeUnit(baseTimeUnit)

指定指定类别轴的基本单位。

setCategoryNames(sourceData)

设置指定轴的所有分类名称。

setCategoryType(categoryType)

指定类别轴类型。

setCustomDisplayUnit(value)

将轴显示单位设为自定义值。

setDisplayUnit(displayUnit)

表示轴显示单位。 有关详细信息,请参阅 ExcelScript.ChartAxisDisplayUnit

setIsBetweenCategories(isBetweenCategories)

指定值轴是否与类别之间的分类轴交叉。

setLinkNumberFormat(linkNumberFormat)

指定数字格式是否链接到单元格。 如果 true为 ,则当单元格中更改时,标签中的数字格式将更改。

setLogBase(logBase)

指定使用对数刻度时对数的基数。

setMajorTickMark(majorTickMark)

指定指定轴的主要刻度线的类型。 有关详细信息,请参阅 ExcelScript.ChartAxisTickMark

setMajorTimeUnitScale(majorTimeUnitScale)

当 属性设置为 dateAxis时,categoryType指定类别轴的主要单位刻度值。

setMajorUnit(majorUnit)

指定两个主要刻度线之间的间隔。

setMaximum(maximum)

指定数值轴上的最大值。

setMinimum(minimum)

指定数值轴上的最小值。

setMinorTickMark(minorTickMark)

指定指定轴的次要刻度线的类型。 有关详细信息,请参阅 ExcelScript.ChartAxisTickMark

setMinorTimeUnitScale(minorTimeUnitScale)

当 属性设置为 dateAxiscategoryType,指定类别轴的次要单位刻度值。

setMinorUnit(minorUnit)

指定两个次要刻度线之间的间隔。

setMultiLevel(multiLevel)

指定轴是否为多级轴。

setNumberFormat(numberFormat)

指定轴刻度线标签的格式代码。

setOffset(offset)

指定标签级别之间的距离,以及第一级与轴线之间的距离。 此值应该是 0 到 1000 之间的整数。

setPosition(position)

指定其他轴交叉处的指定轴位置。 有关详细信息,请参阅 ExcelScript.ChartAxisPosition

setPositionAt(value)

设置其他轴交叉处的指定轴位置。

setReversePlotOrder(reversePlotOrder)

指定 Excel 是否从最后一个到第一个绘制数据点。

setScaleType(scaleType)

指定数值轴刻度类型。 有关详细信息,请参阅 ExcelScript.ChartAxisScaleType

setShowDisplayUnitLabel(showDisplayUnitLabel)

指定轴显示单位标签是否可见。

setTextOrientation(textOrientation)

为图表轴刻度标签指定文本的方向。 对于垂直方向文本,该值应为 -90 到 90 的整数或整数 180。

setTickLabelPosition(tickLabelPosition)

在指定坐标轴上指定刻度线标签的位置。 有关详细信息,请参阅 ExcelScript.ChartAxisTickLabelPosition

setTickLabelSpacing(tickLabelSpacing)

指定刻度线标签之间的类别或系列数。 可以是 1 到 31999 之间的一个数值。

setTickMarkSpacing(tickMarkSpacing)

指定刻度线之间的类别或系列数。

setVisible(visible)

指定轴是否可见。

方法详细信息

getAlignment()

指定指定轴刻度线标签的对齐方式。 有关详细信息,请参阅 ExcelScript.ChartTextHorizontalAlignment

getAlignment(): ChartTickLabelAlignment;

返回

getAxisGroup()

指定指定轴的组。 有关详细信息,请参阅 ExcelScript.ChartAxisGroup

getAxisGroup(): ChartAxisGroup;

返回

getBaseTimeUnit()

指定指定类别轴的基本单位。

getBaseTimeUnit(): ChartAxisTimeUnit;

返回

getCategoryType()

指定类别轴类型。

getCategoryType(): ChartAxisCategoryType;

返回

getCustomDisplayUnit()

指定自定义轴显示单位值。 若要设置此属性,请使用 SetCustomDisplayUnit(double) 方法。

getCustomDisplayUnit(): number;

返回

number

getDisplayUnit()

表示轴显示单位。 有关详细信息,请参阅 ExcelScript.ChartAxisDisplayUnit

getDisplayUnit(): ChartAxisDisplayUnit;

返回

getFormat()

表示 chart 对象的格式,包括线条和字体格式。

getFormat(): ChartAxisFormat;

返回

getHeight()

指定图表轴的高度(以磅为单位)。 null如果轴不可见,则返回 。

getHeight(): number;

返回

number

getIsBetweenCategories()

指定值轴是否与类别之间的分类轴交叉。

getIsBetweenCategories(): boolean;

返回

boolean

getLeft()

指定从轴的左边缘到图表区左侧的距离(以磅为单位)。 null如果轴不可见,则返回 。

getLeft(): number;

返回

number

getLinkNumberFormat()

指定数字格式是否链接到单元格。 如果 true为 ,则当单元格中更改时,标签中的数字格式将更改。

getLinkNumberFormat(): boolean;

返回

boolean

getLogBase()

指定使用对数刻度时对数的基数。

getLogBase(): number;

返回

number

getMajorGridlines()

返回一个 对象,该对象代表指定轴的主要网格线。

getMajorGridlines(): ChartGridlines;

返回

示例

/**
 * This sample customizes the gridline color on a chart's value axis.
 * This assumes the active worksheet has a chart.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the first chart on the active worksheet.
  const sheet = workbook.getActiveWorksheet();
  const chart = sheet.getCharts()[0];
  
  // Set the gridline color to gray.
  chart.getAxes().getValueAxis().getMajorGridlines().getFormat().getLine().setColor("gray");
}

getMajorTickMark()

指定指定轴的主要刻度线的类型。 有关详细信息,请参阅 ExcelScript.ChartAxisTickMark

getMajorTickMark(): ChartAxisTickMark;

返回

getMajorTimeUnitScale()

当 属性设置为 dateAxis时,categoryType指定类别轴的主要单位刻度值。

getMajorTimeUnitScale(): ChartAxisTimeUnit;

返回

getMajorUnit()

指定两个主要刻度线之间的间隔。

getMajorUnit(): number;

返回

number

getMaximum()

指定数值轴上的最大值。

getMaximum(): number;

返回

number

getMinimum()

指定数值轴上的最小值。

getMinimum(): number;

返回

number

getMinorGridlines()

返回一个 对象,该对象代表指定轴的次要网格线。

getMinorGridlines(): ChartGridlines;

返回

getMinorTickMark()

指定指定轴的次要刻度线的类型。 有关详细信息,请参阅 ExcelScript.ChartAxisTickMark

getMinorTickMark(): ChartAxisTickMark;

返回

getMinorTimeUnitScale()

当 属性设置为 dateAxiscategoryType,指定类别轴的次要单位刻度值。

getMinorTimeUnitScale(): ChartAxisTimeUnit;

返回

getMinorUnit()

指定两个次要刻度线之间的间隔。

getMinorUnit(): number;

返回

number

getMultiLevel()

指定轴是否为多级轴。

getMultiLevel(): boolean;

返回

boolean

getNumberFormat()

指定轴刻度线标签的格式代码。

getNumberFormat(): string;

返回

string

getOffset()

指定标签级别之间的距离,以及第一级与轴线之间的距离。 此值应该是 0 到 1000 之间的整数。

getOffset(): number;

返回

number

getPosition()

指定其他轴交叉处的指定轴位置。 有关详细信息,请参阅 ExcelScript.ChartAxisPosition

getPosition(): ChartAxisPosition;

返回

getPositionAt()

指定其他轴交叉的轴位置。 应使用 SetPositionAt(double) 方法设置此属性。

getPositionAt(): number;

返回

number

getReversePlotOrder()

指定 Excel 是否从最后一个到第一个绘制数据点。

getReversePlotOrder(): boolean;

返回

boolean

getScaleType()

指定数值轴刻度类型。 有关详细信息,请参阅 ExcelScript.ChartAxisScaleType

getScaleType(): ChartAxisScaleType;

返回

getShowDisplayUnitLabel()

指定轴显示单位标签是否可见。

getShowDisplayUnitLabel(): boolean;

返回

boolean

getTextOrientation()

为图表轴刻度标签指定文本的方向。 对于垂直方向文本,该值应为 -90 到 90 的整数或整数 180。

getTextOrientation(): number;

返回

number

getTickLabelPosition()

在指定坐标轴上指定刻度线标签的位置。 有关详细信息,请参阅 ExcelScript.ChartAxisTickLabelPosition

getTickLabelPosition(): ChartAxisTickLabelPosition;

返回

getTickLabelSpacing()

指定刻度线标签之间的类别或系列数。 可以是 1 到 31999 之间的一个数值。

getTickLabelSpacing(): number;

返回

number

getTickMarkSpacing()

指定刻度线之间的类别或系列数。

getTickMarkSpacing(): number;

返回

number

getTitle()

表示坐标轴标题。

getTitle(): ChartAxisTitle;

返回

getTop()

指定从轴的上边缘到图表区顶部的距离(以磅为单位)。 null如果轴不可见,则返回 。

getTop(): number;

返回

number

getType()

指定坐标轴类型。 有关详细信息,请参阅 ExcelScript.ChartAxisType

getType(): ChartAxisType;

返回

getVisible()

指定轴是否可见。

getVisible(): boolean;

返回

boolean

getWidth()

指定图表轴的宽度(以磅为单位)。 null如果轴不可见,则返回 。

getWidth(): number;

返回

number

setAlignment(alignment)

指定指定轴刻度线标签的对齐方式。 有关详细信息,请参阅 ExcelScript.ChartTextHorizontalAlignment

setAlignment(alignment: ChartTickLabelAlignment): void;

参数

返回

void

setBaseTimeUnit(baseTimeUnit)

指定指定类别轴的基本单位。

setBaseTimeUnit(baseTimeUnit: ChartAxisTimeUnit): void;

参数

返回

void

setCategoryNames(sourceData)

设置指定轴的所有分类名称。

setCategoryNames(sourceData: Range): void;

参数

sourceData
ExcelScript.Range

对应于 Range 源数据的对象。

返回

void

setCategoryType(categoryType)

指定类别轴类型。

setCategoryType(categoryType: ChartAxisCategoryType): void;

参数

返回

void

setCustomDisplayUnit(value)

将轴显示单位设为自定义值。

setCustomDisplayUnit(value: number): void;

参数

value

number

显示单元的自定义值。

返回

void

setDisplayUnit(displayUnit)

表示轴显示单位。 有关详细信息,请参阅 ExcelScript.ChartAxisDisplayUnit

setDisplayUnit(displayUnit: ChartAxisDisplayUnit): void;

参数

返回

void

示例

/**
 * This sample sets the display unit of the value axis to thousands.
 * This assumes the active worksheet has a chart.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the first chart on the active worksheet.
  const sheet = workbook.getActiveWorksheet();
  const chart = sheet.getCharts()[0];
  
  // Set the value axis to display in thousands.
  chart.getAxes().getValueAxis().setDisplayUnit(ExcelScript.ChartAxisDisplayUnit.thousands);
}

setIsBetweenCategories(isBetweenCategories)

指定值轴是否与类别之间的分类轴交叉。

setIsBetweenCategories(isBetweenCategories: boolean): void;

参数

isBetweenCategories

boolean

返回

void

setLinkNumberFormat(linkNumberFormat)

指定数字格式是否链接到单元格。 如果 true为 ,则当单元格中更改时,标签中的数字格式将更改。

setLinkNumberFormat(linkNumberFormat: boolean): void;

参数

linkNumberFormat

boolean

返回

void

setLogBase(logBase)

指定使用对数刻度时对数的基数。

setLogBase(logBase: number): void;

参数

logBase

number

返回

void

setMajorTickMark(majorTickMark)

指定指定轴的主要刻度线的类型。 有关详细信息,请参阅 ExcelScript.ChartAxisTickMark

setMajorTickMark(majorTickMark: ChartAxisTickMark): void;

参数

返回

void

setMajorTimeUnitScale(majorTimeUnitScale)

当 属性设置为 dateAxis时,categoryType指定类别轴的主要单位刻度值。

setMajorTimeUnitScale(majorTimeUnitScale: ChartAxisTimeUnit): void;

参数

majorTimeUnitScale
ExcelScript.ChartAxisTimeUnit

返回

void

setMajorUnit(majorUnit)

指定两个主要刻度线之间的间隔。

setMajorUnit(majorUnit: number): void;

参数

majorUnit

number

返回

void

setMaximum(maximum)

指定数值轴上的最大值。

setMaximum(maximum: number): void;

参数

maximum

number

返回

void

示例

/**
 * This sample sets the maximum value on the value axis.
 * This assumes the active worksheet has a chart.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the first chart on the active worksheet.
  const sheet = workbook.getActiveWorksheet();
  const chart = sheet.getCharts()[0];
  
  // Set the maximum value to 10.
  chart.getAxes().getValueAxis().setMaximum(10);
}

setMinimum(minimum)

指定数值轴上的最小值。

setMinimum(minimum: number): void;

参数

minimum

number

返回

void

示例

/**
 * This sample sets the minimum value on the value axis.
 * This assumes the active worksheet has a chart.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the first chart on the active worksheet.
  const sheet = workbook.getActiveWorksheet();
  const chart = sheet.getCharts()[0];
  
  // Set the minimum value to 145.
  chart.getAxes().getValueAxis().setMinimum(145);
}

setMinorTickMark(minorTickMark)

指定指定轴的次要刻度线的类型。 有关详细信息,请参阅 ExcelScript.ChartAxisTickMark

setMinorTickMark(minorTickMark: ChartAxisTickMark): void;

参数

返回

void

setMinorTimeUnitScale(minorTimeUnitScale)

当 属性设置为 dateAxiscategoryType,指定类别轴的次要单位刻度值。

setMinorTimeUnitScale(minorTimeUnitScale: ChartAxisTimeUnit): void;

参数

minorTimeUnitScale
ExcelScript.ChartAxisTimeUnit

返回

void

setMinorUnit(minorUnit)

指定两个次要刻度线之间的间隔。

setMinorUnit(minorUnit: number): void;

参数

minorUnit

number

返回

void

setMultiLevel(multiLevel)

指定轴是否为多级轴。

setMultiLevel(multiLevel: boolean): void;

参数

multiLevel

boolean

返回

void

setNumberFormat(numberFormat)

指定轴刻度线标签的格式代码。

setNumberFormat(numberFormat: string): void;

参数

numberFormat

string

返回

void

setOffset(offset)

指定标签级别之间的距离,以及第一级与轴线之间的距离。 此值应该是 0 到 1000 之间的整数。

setOffset(offset: number): void;

参数

offset

number

返回

void

setPosition(position)

指定其他轴交叉处的指定轴位置。 有关详细信息,请参阅 ExcelScript.ChartAxisPosition

setPosition(position: ChartAxisPosition): void;

参数

返回

void

setPositionAt(value)

设置其他轴交叉处的指定轴位置。

setPositionAt(value: number): void;

参数

value

number

交叉点的自定义值。

返回

void

setReversePlotOrder(reversePlotOrder)

指定 Excel 是否从最后一个到第一个绘制数据点。

setReversePlotOrder(reversePlotOrder: boolean): void;

参数

reversePlotOrder

boolean

返回

void

示例

/**
 * This sample reverses the plot order of the category axis.
 * This assumes the active worksheet has a chart.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the first chart on the active worksheet.
  const sheet = workbook.getActiveWorksheet();
  const chart = sheet.getCharts()[0];
  
  // Set the category axis to reverse the plot order.
  chart.getAxes().getCategoryAxis().setReversePlotOrder(true);
}

setScaleType(scaleType)

指定数值轴刻度类型。 有关详细信息,请参阅 ExcelScript.ChartAxisScaleType

setScaleType(scaleType: ChartAxisScaleType): void;

参数

返回

void

setShowDisplayUnitLabel(showDisplayUnitLabel)

指定轴显示单位标签是否可见。

setShowDisplayUnitLabel(showDisplayUnitLabel: boolean): void;

参数

showDisplayUnitLabel

boolean

返回

void

setTextOrientation(textOrientation)

为图表轴刻度标签指定文本的方向。 对于垂直方向文本,该值应为 -90 到 90 的整数或整数 180。

setTextOrientation(textOrientation: number): void;

参数

textOrientation

number

返回

void

setTickLabelPosition(tickLabelPosition)

在指定坐标轴上指定刻度线标签的位置。 有关详细信息,请参阅 ExcelScript.ChartAxisTickLabelPosition

setTickLabelPosition(
            tickLabelPosition: ChartAxisTickLabelPosition
        ): void;

参数

返回

void

示例

/**
 * This sample sets the tick label position on the category axis.
 * This assumes the active worksheet has a chart.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the first chart on the active worksheet.
  const sheet = workbook.getActiveWorksheet();
  const chart = sheet.getCharts()[0];
  
  // Set the tick label position to low.
  chart.getAxes().getCategoryAxis().setTickLabelPosition(
    ExcelScript.ChartAxisTickLabelPosition.low
  );
}

setTickLabelSpacing(tickLabelSpacing)

指定刻度线标签之间的类别或系列数。 可以是 1 到 31999 之间的一个数值。

setTickLabelSpacing(tickLabelSpacing: number): void;

参数

tickLabelSpacing

number

返回

void

setTickMarkSpacing(tickMarkSpacing)

指定刻度线之间的类别或系列数。

setTickMarkSpacing(tickMarkSpacing: number): void;

参数

tickMarkSpacing

number

返回

void

setVisible(visible)

指定轴是否可见。

setVisible(visible: boolean): void;

参数

visible

boolean

返回

void