ExcelScript.ChartDataLabels interface
Represents a collection of all the data labels on a chart point.
Remarks
Examples
/**
* 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);
}
Methods
| get |
Specifies if data labels automatically generate appropriate text based on context. |
| get |
Specifies the format of chart data labels, which includes fill and font formatting. |
| get |
Specifies the geometric shape type of the data labels. See |
| get |
Specifies the horizontal alignment for chart data label. See |
| get |
Gets an object that represents the leader lines of the data labels. |
| get |
Specifies if the number format is linked to the cells. If |
| get |
Specifies the format code for data labels. |
| get |
Value that represents the position of the data label. See |
| get |
String representing the separator used for the data labels on a chart. |
| get |
Specifies if the data labels are shown as a callout with the tail anchor attached to the data point. If |
| get |
Specifies if the data label bubble size is visible. |
| get |
Specifies if the data label category name is visible. |
| get |
Specifies if leader lines are displayed for the data labels. |
| get |
Specifies if the data label legend key is visible. |
| get |
Specifies if the data label percentage is visible. |
| get |
Specifies if the data label series name is visible. |
| get |
Specifies if the data label value is visible. |
| get |
Represents the angle to which the text is oriented for data labels. The value should either be an integer from -90 to 90 or the integer 180 for vertically-oriented text. |
| get |
Represents the vertical alignment of chart data label. See |
| set |
Specifies if data labels automatically generate appropriate text based on context. |
| set |
Specifies the geometric shape type of the data labels. See |
| set |
Specifies the horizontal alignment for chart data label. See |
| set |
Specifies if the number format is linked to the cells. If |
| set |
Specifies the format code for data labels. |
| set |
Value that represents the position of the data label. See |
| set |
String representing the separator used for the data labels on a chart. |
| set |
Specifies if the data label bubble size is visible. |
| set |
Specifies if the data label category name is visible. |
| set |
Specifies if leader lines are displayed for the data labels. |
| set |
Specifies if the data label legend key is visible. |
| set |
Specifies if the data label percentage is visible. |
| set |
Specifies if the data label series name is visible. |
| set |
Specifies if the data label value is visible. |
| set |
Represents the angle to which the text is oriented for data labels. The value should either be an integer from -90 to 90 or the integer 180 for vertically-oriented text. |
| set |
Represents the vertical alignment of chart data label. See |
Method Details
getAutoText()
Specifies if data labels automatically generate appropriate text based on context.
getAutoText(): boolean;
Returns
boolean
getFormat()
Specifies the format of chart data labels, which includes fill and font formatting.
getFormat(): ChartDataLabelFormat;
Returns
getGeometricShapeType()
Specifies the geometric shape type of the data labels. See ExcelScript.GeometricShapeType for more details. Value is null if the data labels are not geometric shapes.
getGeometricShapeType(): GeometricShapeType;
Returns
getHorizontalAlignment()
Specifies the horizontal alignment for chart data label. See ExcelScript.ChartTextHorizontalAlignment for details. This property is valid only when the TextOrientation of data label is 0.
getHorizontalAlignment(): ChartTextHorizontalAlignment;
Returns
getLeaderLines()
Gets an object that represents the leader lines of the data labels.
getLeaderLines(): ChartLeaderLines;
Returns
getLinkNumberFormat()
Specifies if the number format is linked to the cells. If true, the number format will change in the labels when it changes in the cells.
getLinkNumberFormat(): boolean;
Returns
boolean
getNumberFormat()
Specifies the format code for data labels.
getNumberFormat(): string;
Returns
string
getPosition()
Value that represents the position of the data label. See ExcelScript.ChartDataLabelPosition for details.
getPosition(): ChartDataLabelPosition;
Returns
getSeparator()
String representing the separator used for the data labels on a chart.
getSeparator(): string;
Returns
string
getShowAsStickyCallout()
Specifies if the data labels are shown as a callout with the tail anchor attached to the data point. If true, the callout is one of the following values: "AccentCallout1", "AccentCallout2", "BorderCallout1", "BorderCallout2", "WedgeRectCallout", "WedgeRRectCallout" or "WedgeEllipseCallout".
getShowAsStickyCallout(): boolean;
Returns
boolean
getShowBubbleSize()
Specifies if the data label bubble size is visible.
getShowBubbleSize(): boolean;
Returns
boolean
getShowCategoryName()
Specifies if the data label category name is visible.
getShowCategoryName(): boolean;
Returns
boolean
getShowLeaderLines()
Specifies if leader lines are displayed for the data labels. true if leader lines are shown; otherwise, false.
getShowLeaderLines(): boolean;
Returns
boolean
getShowLegendKey()
Specifies if the data label legend key is visible.
getShowLegendKey(): boolean;
Returns
boolean
getShowPercentage()
Specifies if the data label percentage is visible.
getShowPercentage(): boolean;
Returns
boolean
getShowSeriesName()
Specifies if the data label series name is visible.
getShowSeriesName(): boolean;
Returns
boolean
getShowValue()
Specifies if the data label value is visible.
getShowValue(): boolean;
Returns
boolean
getTextOrientation()
Represents the angle to which the text is oriented for data labels. The value should either be an integer from -90 to 90 or the integer 180 for vertically-oriented text.
getTextOrientation(): number;
Returns
number
getVerticalAlignment()
Represents the vertical alignment of chart data label. See ExcelScript.ChartTextVerticalAlignment for details. This property is valid only when TextOrientation of the data label is -90, 90, or 180.
getVerticalAlignment(): ChartTextVerticalAlignment;
Returns
setAutoText(autoText)
Specifies if data labels automatically generate appropriate text based on context.
setAutoText(autoText: boolean): void;
Parameters
- autoText
-
boolean
Returns
void
setGeometricShapeType(geometricShapeType)
Specifies the geometric shape type of the data labels. See ExcelScript.GeometricShapeType for more details. Value is null if the data labels are not geometric shapes.
setGeometricShapeType(geometricShapeType: GeometricShapeType): void;
Parameters
- geometricShapeType
- ExcelScript.GeometricShapeType
Returns
void
setHorizontalAlignment(horizontalAlignment)
Specifies the horizontal alignment for chart data label. See ExcelScript.ChartTextHorizontalAlignment for details. This property is valid only when the TextOrientation of data label is 0.
setHorizontalAlignment(
horizontalAlignment: ChartTextHorizontalAlignment
): void;
Parameters
- horizontalAlignment
- ExcelScript.ChartTextHorizontalAlignment
Returns
void
setLinkNumberFormat(linkNumberFormat)
Specifies if the number format is linked to the cells. If true, the number format will change in the labels when it changes in the cells.
setLinkNumberFormat(linkNumberFormat: boolean): void;
Parameters
- linkNumberFormat
-
boolean
Returns
void
setNumberFormat(numberFormat)
Specifies the format code for data labels.
setNumberFormat(numberFormat: string): void;
Parameters
- numberFormat
-
string
Returns
void
setPosition(position)
Value that represents the position of the data label. See ExcelScript.ChartDataLabelPosition for details.
setPosition(position: ChartDataLabelPosition): void;
Parameters
- position
- ExcelScript.ChartDataLabelPosition
Returns
void
Examples
/**
* 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)
String representing the separator used for the data labels on a chart.
setSeparator(separator: string): void;
Parameters
- separator
-
string
Returns
void
setShowBubbleSize(showBubbleSize)
Specifies if the data label bubble size is visible.
setShowBubbleSize(showBubbleSize: boolean): void;
Parameters
- showBubbleSize
-
boolean
Returns
void
setShowCategoryName(showCategoryName)
Specifies if the data label category name is visible.
setShowCategoryName(showCategoryName: boolean): void;
Parameters
- showCategoryName
-
boolean
Returns
void
Examples
/**
* 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)
Specifies if leader lines are displayed for the data labels. true if leader lines are shown; otherwise, false.
setShowLeaderLines(showLeaderLines: boolean): void;
Parameters
- showLeaderLines
-
boolean
Returns
void
Examples
/**
* 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)
Specifies if the data label legend key is visible.
setShowLegendKey(showLegendKey: boolean): void;
Parameters
- showLegendKey
-
boolean
Returns
void
setShowPercentage(showPercentage)
Specifies if the data label percentage is visible.
setShowPercentage(showPercentage: boolean): void;
Parameters
- showPercentage
-
boolean
Returns
void
Examples
/**
* 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)
Specifies if the data label series name is visible.
setShowSeriesName(showSeriesName: boolean): void;
Parameters
- showSeriesName
-
boolean
Returns
void
Examples
/**
* 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)
Specifies if the data label value is visible.
setShowValue(showValue: boolean): void;
Parameters
- showValue
-
boolean
Returns
void
Examples
/**
* 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)
Represents the angle to which the text is oriented for data labels. The value should either be an integer from -90 to 90 or the integer 180 for vertically-oriented text.
setTextOrientation(textOrientation: number): void;
Parameters
- textOrientation
-
number
Returns
void
setVerticalAlignment(verticalAlignment)
Represents the vertical alignment of chart data label. See ExcelScript.ChartTextVerticalAlignment for details. This property is valid only when TextOrientation of the data label is -90, 90, or 180.
setVerticalAlignment(
verticalAlignment: ChartTextVerticalAlignment
): void;
Parameters
- verticalAlignment
- ExcelScript.ChartTextVerticalAlignment
Returns
void