DataLabels class

DataLabels class

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

Inheritance: DataLabelsChartTextFrameChartFrame

The DataLabels type exposes the following members:

Properties

PropertyDescription
is_inner_modeIndicates 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.
borderGets the Line.
areaGets the DataLabels.area.
text_fontGets a ChartFrame.font object of the specified ChartFrame object.
text_optionsGets and sets the options of the text.
fontGets the font of the DataLabels;
auto_scale_fontTrue if the text in the object changes font size when the object size changes. The default value is True.
background_modeGets and sets the display mode of the background
backgroundGets and sets the display mode of the background
is_automatic_sizeIndicates whether the chart frame is automatic sized.
xGets or sets the x coordinate of the upper left corner in units of 1/4000 of the chart area.
yGets or sets the y coordinate of the upper left corner in units of 1/4000 of the chart area.
heightGets or sets the height of frame in units of 1/4000 of the chart area.
widthGets or sets the width of frame in units of 1/4000 of the chart area.
shadowTrue if the frame has a shadow.
shape_propertiesGets the ChartFrame.shape_properties object.
is_default_pos_be_setIndicates whether default position(DefaultX, DefaultY, DefaultWidth and DefaultHeight) are set.
default_xRepresents x of default position
default_yRepresents y of default position
default_widthRepresents width of default position
default_heightRepresents height of default position
is_auto_textIndicates the text is auto generated.
is_deletedIndicates whether this data labels is deleted.
text_horizontal_alignmentGets and sets the text horizontal alignment.
text_vertical_alignmentGets or sets the text vertical alignment of text.
rotation_angleRepresents text rotation angle.
is_automatic_rotationIndicates whether the text of the chart is automatically rotated.
textGets or sets the text of data label.
linked_sourceGets and sets a reference to the worksheet.
text_directionRepresents text reading order.
reading_orderRepresents text reading order.
direction_typeGets and sets the direction of text.
is_text_wrappedGets or sets a value indicating whether the text is wrapped.
is_resize_shape_to_fit_textGets 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.
show_valueRepresents a specified chart’s data label values display behavior. True displays the values. False to hide.
show_cell_rangeIndicates whether showing cell range as the data labels.
show_percentageRepresents a specified chart’s data label percentage value display behavior. True displays the percentage value. False to hide.
show_bubble_sizeRepresents a specified chart’s data label percentage value display behavior. True displays the percentage value. False to hide.
show_category_nameRepresents 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.
show_series_nameIndicates whether the series name displays for the data labels on a chart.
True to show the series name. False to hide.
show_legend_keyRepresents a specified chart’s data label legend key display behavior.
True if the data label legend key is visible.
number_formatRepresents the format string for the DataLabels object.
numberGets and sets the built-in number format.
number_format_linkedTrue if the number format is linked to the cells
(so that the number format changes in the labels when it changes in the cells).
separator_typeGets or sets the separator type used for the data labels on a chart.
separator_valueGets or sets the separator value used for the data labels on a chart.
positionRepresents the position of the data label.
is_never_overlapIndicates whether the datalabels display never overlap. (For Pie chart)
shape_typeGets or sets shape type of data label.

Methods

MethodDescription
set_position_autoSet position of the frame to automatic
charactersReturns a Characters object that represents a range of characters within the text.
apply_fontApply the font of the datalabels to all child nodes.

Example

from aspose.cells import Workbook
from aspose.cells.charts import LabelPositionType

# Set the DataLabels in the chart
wb = Workbook("chart.xlsx")
chart = wb.worksheets[0].charts[0]
for i in range(len(chart.n_series)):
    datalabels = chart.n_series[i].data_labels
    # Set the position of DataLabels
    datalabels.position = LabelPositionType.INSIDE_BASE
    # Show the category name in the DataLabels
    datalabels.show_category_name = True
    # Show the value in the DataLabels
    datalabels.show_value = True
    # Not show the percentage in the DataLabels
    datalabels.show_percentage = False
    # Not show the legend key.
    datalabels.show_legend_key = False

See Also