Class DataLabels

DataLabels class

Encapsulates a collection of all the DataLabel objects for the specified Series.

public class DataLabels : ChartTextFrame

Properties

NameDescription
override Area { get; }Gets the area.
virtual AutoScaleFont { get; set; }True if the text in the object changes font size when the object size changes. The default value is True.(Inherited from ChartFrame.)
Background { get; set; }(Obsolete.) Gets and sets the display mode of the background(Inherited from ChartFrame.)
BackgroundMode { get; set; }Gets and sets the display mode of the background
override Border { get; }Gets the border.
DefaultHeight { get; }Represents height of default position(Inherited from ChartFrame.)
DefaultWidth { get; }Represents width of default position(Inherited from ChartFrame.)
DefaultX { get; }Represents x of default position(Inherited from ChartFrame.)
DefaultY { get; }Represents y of default position(Inherited from ChartFrame.)
override DirectionType { get; set; }Gets and sets the direction of text.
override Font { get; }Gets the font of the DataLabels;
virtual Height { get; set; }Gets or sets the height of frame in units of 1/4000 of the chart area.(Inherited from ChartFrame.)
IsAutomaticRotation { get; }Indicates whether the text of the chart is automatically rotated.(Inherited from ChartTextFrame.)
virtual IsAutomaticSize { get; set; }Indicates whether the chart frame is automatic sized.(Inherited from ChartFrame.)
override IsAutoText { get; set; }Indicates the text is auto generated.
IsDefaultPosBeSet { get; }Indicates whether default position(DefaultX, DefaultY, DefaultWidth and DefaultHeight) are set.(Inherited from ChartFrame.)
IsDeleted { get; set; }Indicates whether this data labels is deleted.(Inherited from ChartTextFrame.)
IsInnerMode { get; set; }Indicates whether the size of the plot area size includes the tick marks, and the axis labels. False specifies that the size shall determine the size of the plot area, the tick marks, and the axis labels.(Inherited from ChartFrame.)
IsNeverOverlap { get; set; }Indicates whether the datalabels display never overlap. (For Pie chart)
IsResizeShapeToFitText { get; set; }Gets or sets whether a shape should be auto-fit to fully contain the text described within it. Auto-fitting is when text within a shape is scaled in order to contain all the text inside.(Inherited from ChartTextFrame.)
override IsTextWrapped { get; set; }Gets or sets a value indicating whether the text is wrapped.
virtual LinkedSource { get; set; }Gets and sets a reference to the worksheet.(Inherited from ChartTextFrame.)
Number { get; set; }Gets and sets the built-in number format.
NumberFormat { get; set; }Represents the format string for the DataLabels object.
NumberFormatLinked { get; set; }True if the number format is linked to the cells (so that the number format changes in the labels when it changes in the cells).
Position { get; set; }Represents the position of the data label.
ReadingOrder { get; set; }Represents text reading order.(Inherited from ChartTextFrame.)
RotationAngle { get; set; }Represents text rotation angle.(Inherited from ChartTextFrame.)
SeparatorType { get; set; }Gets or sets the separator type used for the data labels on a chart.
SeparatorValue { get; set; }Gets or sets the separator value used for the data labels on a chart.
Shadow { get; set; }True if the frame has a shadow.(Inherited from ChartFrame.)
ShapeProperties { get; }Gets the ShapeProperties object.(Inherited from ChartFrame.)
ShapeType { get; set; }Gets or sets shape type of data label.
ShowBubbleSize { get; set; }Represents a specified chart’s data label percentage value display behavior. True displays the percentage value. False to hide.
ShowCategoryName { get; set; }Represents a specified chart’s data label category name display behavior.True to display the category name for the data labels on a chart. False to hide.
ShowCellRange { get; set; }Indicates whether showing cell range as the data labels.
ShowLegendKey { get; set; }Represents a specified chart’s data label legend key display behavior. True if the data label legend key is visible.
ShowPercentage { get; set; }Represents a specified chart’s data label percentage value display behavior. True displays the percentage value. False to hide.
ShowSeriesName { get; set; }Indicates whether the series name displays for the data labels on a chart. True to show the series name. False to hide.
ShowValue { get; set; }Represents a specified chart’s data label values display behavior. True displays the values. False to hide.
override Text { get; set; }Gets or sets the text of data label.
TextDirection { get; set; }(Obsolete.) Represents text reading order.(Inherited from ChartTextFrame.)
virtual TextFont { get; }(Obsolete.) Gets a Font object of the specified ChartFrame object.(Inherited from ChartFrame.)
TextHorizontalAlignment { get; set; }Gets and sets the text horizontal alignment.(Inherited from ChartTextFrame.)
virtual TextOptions { get; }Gets and sets the options of the text.(Inherited from ChartFrame.)
TextVerticalAlignment { get; set; }Gets or sets the text vertical alignment of text.(Inherited from ChartTextFrame.)
virtual Width { get; set; }Gets or sets the width of frame in units of 1/4000 of the chart area.(Inherited from ChartFrame.)
virtual X { get; set; }Gets or sets the x coordinate of the upper left corner in units of 1/4000 of the chart area.(Inherited from ChartFrame.)
virtual Y { get; set; }Gets or sets the y coordinate of the upper left corner in units of 1/4000 of the chart area.(Inherited from ChartFrame.)

Methods

NameDescription
ApplyFont()Apply the font of the datalabels to all child nodes.
Characters(int, int)Returns a Characters object that represents a range of characters within the text.(Inherited from ChartTextFrame.)
virtual SetPositionAuto()Set position of the frame to automatic(Inherited from ChartFrame.)

Examples


[C#]

//Set the DataLabels in the chart
Workbook wb = new Workbook("chart.xlsx");
Chart chart = wb.Worksheets[0].Charts[0];
DataLabels datalabels;
for (int i = 0; i  <chart.NSeries.Count; i++)
{
    datalabels = chart.NSeries[i].DataLabels;
    //Set the position of DataLabels
    datalabels.Position = LabelPositionType.InsideBase;
    //Show the category name in the DataLabels
    datalabels.ShowCategoryName = true;
    //Show the value in the DataLabels
    datalabels.ShowValue = true;
    //Not show the percentage in the DataLabels
    datalabels.ShowPercentage = false;
    //Not show the legend key.
    datalabels.ShowLegendKey = false;
}

[Visual Basic]

'Set the DataLabels in the chart
Dim datalabels As DataLabels
Dim i As Integer
For i = 0 To chart.NSeries.Count - 1 Step 1
    datalabels = chart.NSeries(i).DataLabels
    'Set the position of DataLabels
    datalabels.Position = LabelPositionType.InsideBase
    'Show the category name in the DataLabels
    datalabels.ShowCategoryName= True
    'Show the value in the DataLabels
    datalabels.ShowValue = True
    'Not show the percentage in the DataLabels
    datalabels.ShowPercentage = False
    'Not show the legend key.
    datalabels.ShowLegendKey = False
Next

See Also