ExcelScript.ChartDataLabels interface
表示图表点上的所有数据标签的集合。
注解
示例
/**
* This sample configures data labels on a chart series.
* This assumes the active worksheet has a pie chart.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the first chart on the active worksheet.
const sheet = workbook.getActiveWorksheet();
const chart = sheet.getCharts()[0];
// Configure the data labels.
const series = chart.getSeries()[0];
const dataLabels = series.getDataLabels();
dataLabels.setShowPercentage(true);
dataLabels.setShowSeriesName(false);
dataLabels.setShowCategoryName(false);
dataLabels.setShowValue(false);
}
方法
| get |
指定数据标签是否根据上下文自动生成适当的文本。 |
| get |
指定图表数据标签的格式,其中包括填充和字体格式。 |
| get |
指定数据标签的几何形状类型。 有关详细信息,请参阅 |
| get |
指定图表数据标签的水平对齐方式。 有关详细信息,请参阅 |
| get |
获取一个 对象,该对象表示数据标签的前导线。 |
| get |
指定数字格式是否链接到单元格。 如果 |
| get |
指定数据标签的格式代码。 |
| get |
表示数据标签位置的值。 有关详细信息,请参阅 |
| get |
表示用于图表中数据标签的分隔符的字符串。 |
| get |
指定数据标签是否显示为带有尾锚附加到数据点的标注。 如果 |
| get |
指定数据标签气泡大小是否可见。 |
| get |
指定数据标签类别名称是否可见。 |
| get |
指定是否为数据标签显示引线。
|
| get |
指定数据标签图例键是否可见。 |
| get |
指定数据标签百分比是否可见。 |
| get |
指定数据标签系列名称是否可见。 |
| get |
指定数据标签值是否可见。 |
| get |
表示文本针对数据标签的方向。 对于垂直方向文本,该值应为 -90 到 90 的整数或整数 180。 |
| get |
表示图表数据标签垂直对齐。 有关详细信息,请参阅 |
| set |
指定数据标签是否根据上下文自动生成适当的文本。 |
| set |
指定数据标签的几何形状类型。 有关详细信息,请参阅 |
| set |
指定图表数据标签的水平对齐方式。 有关详细信息,请参阅 |
| set |
指定数字格式是否链接到单元格。 如果 |
| set |
指定数据标签的格式代码。 |
| set |
表示数据标签位置的值。 有关详细信息,请参阅 |
| set |
表示用于图表中数据标签的分隔符的字符串。 |
| set |
指定数据标签气泡大小是否可见。 |
| set |
指定数据标签类别名称是否可见。 |
| set |
指定是否为数据标签显示引线。
|
| set |
指定数据标签图例键是否可见。 |
| set |
指定数据标签百分比是否可见。 |
| set |
指定数据标签系列名称是否可见。 |
| set |
指定数据标签值是否可见。 |
| set |
表示文本针对数据标签的方向。 对于垂直方向文本,该值应为 -90 到 90 的整数或整数 180。 |
| set |
表示图表数据标签垂直对齐。 有关详细信息,请参阅 |
方法详细信息
getAutoText()
指定数据标签是否根据上下文自动生成适当的文本。
getAutoText(): boolean;
返回
boolean
getFormat()
getGeometricShapeType()
指定数据标签的几何形状类型。 有关详细信息,请参阅 ExcelScript.GeometricShapeType。
null如果数据标签不是几何形状,则值为 。
getGeometricShapeType(): GeometricShapeType;
返回
getHorizontalAlignment()
指定图表数据标签的水平对齐方式。 有关详细信息,请参阅 ExcelScript.ChartTextHorizontalAlignment。 仅当数据标签的 为 0 时, TextOrientation 此属性才有效。
getHorizontalAlignment(): ChartTextHorizontalAlignment;
返回
getLeaderLines()
getLinkNumberFormat()
指定数字格式是否链接到单元格。 如果 true为 ,则当单元格中更改时,标签中的数字格式将更改。
getLinkNumberFormat(): boolean;
返回
boolean
getNumberFormat()
指定数据标签的格式代码。
getNumberFormat(): string;
返回
string
getPosition()
表示数据标签位置的值。 有关详细信息,请参阅 ExcelScript.ChartDataLabelPosition。
getPosition(): ChartDataLabelPosition;
返回
getSeparator()
表示用于图表中数据标签的分隔符的字符串。
getSeparator(): string;
返回
string
getShowAsStickyCallout()
指定数据标签是否显示为带有尾锚附加到数据点的标注。 如果 true为 ,则标注为以下值之一:“AccentCallout1”、“AccentCallout2”、“BorderCallout1”、“BorderCallout2”、“WedgeRectCallout”、“WedgeRectCallout”或“WedgeEllipseCallout”。
getShowAsStickyCallout(): boolean;
返回
boolean
getShowBubbleSize()
指定数据标签气泡大小是否可见。
getShowBubbleSize(): boolean;
返回
boolean
getShowCategoryName()
指定数据标签类别名称是否可见。
getShowCategoryName(): boolean;
返回
boolean
getShowLeaderLines()
指定是否为数据标签显示引线。
true 如果显示前导线,则为 ;否则为 false。
getShowLeaderLines(): boolean;
返回
boolean
getShowLegendKey()
指定数据标签图例键是否可见。
getShowLegendKey(): boolean;
返回
boolean
getShowPercentage()
指定数据标签百分比是否可见。
getShowPercentage(): boolean;
返回
boolean
getShowSeriesName()
指定数据标签系列名称是否可见。
getShowSeriesName(): boolean;
返回
boolean
getShowValue()
指定数据标签值是否可见。
getShowValue(): boolean;
返回
boolean
getTextOrientation()
表示文本针对数据标签的方向。 对于垂直方向文本,该值应为 -90 到 90 的整数或整数 180。
getTextOrientation(): number;
返回
number
getVerticalAlignment()
表示图表数据标签垂直对齐。 有关详细信息,请参阅 ExcelScript.ChartTextVerticalAlignment。 仅当数据标签为 -90、90 或 180 时 TextOrientation ,此属性才有效。
getVerticalAlignment(): ChartTextVerticalAlignment;
返回
setAutoText(autoText)
指定数据标签是否根据上下文自动生成适当的文本。
setAutoText(autoText: boolean): void;
参数
- autoText
-
boolean
返回
void
setGeometricShapeType(geometricShapeType)
指定数据标签的几何形状类型。 有关详细信息,请参阅 ExcelScript.GeometricShapeType。
null如果数据标签不是几何形状,则值为 。
setGeometricShapeType(geometricShapeType: GeometricShapeType): void;
参数
- geometricShapeType
- ExcelScript.GeometricShapeType
返回
void
setHorizontalAlignment(horizontalAlignment)
指定图表数据标签的水平对齐方式。 有关详细信息,请参阅 ExcelScript.ChartTextHorizontalAlignment。 仅当数据标签的 为 0 时, TextOrientation 此属性才有效。
setHorizontalAlignment(
horizontalAlignment: ChartTextHorizontalAlignment
): void;
参数
- horizontalAlignment
- ExcelScript.ChartTextHorizontalAlignment
返回
void
setLinkNumberFormat(linkNumberFormat)
指定数字格式是否链接到单元格。 如果 true为 ,则当单元格中更改时,标签中的数字格式将更改。
setLinkNumberFormat(linkNumberFormat: boolean): void;
参数
- linkNumberFormat
-
boolean
返回
void
setNumberFormat(numberFormat)
指定数据标签的格式代码。
setNumberFormat(numberFormat: string): void;
参数
- numberFormat
-
string
返回
void
setPosition(position)
表示数据标签位置的值。 有关详细信息,请参阅 ExcelScript.ChartDataLabelPosition。
setPosition(position: ChartDataLabelPosition): void;
参数
- position
- ExcelScript.ChartDataLabelPosition
返回
void
示例
/**
* This sample sets the position of data labels.
* This assumes the active worksheet has a chart with data labels enabled.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the first chart on the active worksheet.
const sheet = workbook.getActiveWorksheet();
const chart = sheet.getCharts()[0];
// Set the data label position to best fit.
const series = chart.getSeries()[0];
series.getDataLabels().setPosition(ExcelScript.ChartDataLabelPosition.bestFit);
}
setSeparator(separator)
表示用于图表中数据标签的分隔符的字符串。
setSeparator(separator: string): void;
参数
- separator
-
string
返回
void
setShowBubbleSize(showBubbleSize)
指定数据标签气泡大小是否可见。
setShowBubbleSize(showBubbleSize: boolean): void;
参数
- showBubbleSize
-
boolean
返回
void
setShowCategoryName(showCategoryName)
指定数据标签类别名称是否可见。
setShowCategoryName(showCategoryName: boolean): void;
参数
- showCategoryName
-
boolean
返回
void
示例
/**
* This sample shows category names in data labels.
* This assumes the active worksheet has a chart with data labels enabled.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the first chart on the active worksheet.
const sheet = workbook.getActiveWorksheet();
const chart = sheet.getCharts()[0];
// Show category names in the data labels.
const series = chart.getSeries()[0];
series.getDataLabels().setShowCategoryName(true);
}
setShowLeaderLines(showLeaderLines)
指定是否为数据标签显示引线。
true 如果显示前导线,则为 ;否则为 false。
setShowLeaderLines(showLeaderLines: boolean): void;
参数
- showLeaderLines
-
boolean
返回
void
示例
/**
* This sample enables leader lines for data labels.
* This assumes the active worksheet has a chart with data labels enabled.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the first chart on the active worksheet.
const sheet = workbook.getActiveWorksheet();
const chart = sheet.getCharts()[0];
// Enable leader lines.
const series = chart.getSeries()[0];
series.getDataLabels().setShowLeaderLines(true);
}
setShowLegendKey(showLegendKey)
指定数据标签图例键是否可见。
setShowLegendKey(showLegendKey: boolean): void;
参数
- showLegendKey
-
boolean
返回
void
setShowPercentage(showPercentage)
指定数据标签百分比是否可见。
setShowPercentage(showPercentage: boolean): void;
参数
- showPercentage
-
boolean
返回
void
示例
/**
* This sample shows percentages in data labels.
* This assumes the active worksheet has a pie chart with data labels enabled.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the first chart on the active worksheet.
const sheet = workbook.getActiveWorksheet();
const chart = sheet.getCharts()[0];
// Show percentages in the data labels.
const series = chart.getSeries()[0];
series.getDataLabels().setShowPercentage(true);
}
setShowSeriesName(showSeriesName)
指定数据标签系列名称是否可见。
setShowSeriesName(showSeriesName: boolean): void;
参数
- showSeriesName
-
boolean
返回
void
示例
/**
* This sample controls series name visibility in data labels.
* This assumes the active worksheet has a chart with data labels enabled.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the first chart on the active worksheet.
const sheet = workbook.getActiveWorksheet();
const chart = sheet.getCharts()[0];
// Hide the series name in data labels.
const series = chart.getSeries()[0];
series.getDataLabels().setShowSeriesName(false);
}
setShowValue(showValue)
指定数据标签值是否可见。
setShowValue(showValue: boolean): void;
参数
- showValue
-
boolean
返回
void
示例
/**
* This sample shows values in data labels.
* This assumes the active worksheet has a chart with data labels enabled.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the first chart on the active worksheet.
const sheet = workbook.getActiveWorksheet();
const chart = sheet.getCharts()[0];
// Show values in the data labels.
const series = chart.getSeries()[0];
series.getDataLabels().setShowValue(true);
}
setTextOrientation(textOrientation)
表示文本针对数据标签的方向。 对于垂直方向文本,该值应为 -90 到 90 的整数或整数 180。
setTextOrientation(textOrientation: number): void;
参数
- textOrientation
-
number
返回
void
setVerticalAlignment(verticalAlignment)
表示图表数据标签垂直对齐。 有关详细信息,请参阅 ExcelScript.ChartTextVerticalAlignment。 仅当数据标签为 -90、90 或 180 时 TextOrientation ,此属性才有效。
setVerticalAlignment(
verticalAlignment: ChartTextVerticalAlignment
): void;
参数
- verticalAlignment
- ExcelScript.ChartTextVerticalAlignment
返回
void