ChartDataLabelCollection class
ChartDataLabelCollection class
Represents a collection of ChartDataLabel.
To learn more, visit the Working with Charts documentation article.
Indexers
Properties
| Name | Description |
|---|
| count | Returns the number of ChartDataLabel in this collection. |
| font | Provides access to the font formatting of the data labels of the entire series. |
| format | Provides access to fill and line formatting of the data labels. |
| number_format | Gets an ChartNumberFormat instance allowing to set number format for the data labels of the entire series. |
| orientation | Gets or sets the text orientation of the data labels of the entire series. |
| position | Gets or sets the position of the data labels. |
| rotation | Gets or sets the rotation of the data labels of the entire series in degrees. |
| separator | Gets or sets string separator used for the data labels of the entire series. The default is a comma, except for pie charts showing only category name and percentage, when a line break shall be used instead. |
| show_bubble_size | Allows to specify whether bubble size is to be displayed for the data labels of the entire series. Applies only to Bubble charts. Default value is False. |
| show_category_name | Allows to specify whether category name is to be displayed for the data labels of the entire series. Default value is False. |
| show_data_labels_range | Allows to specify whether values from data labels range to be displayed in the data labels of the entire series. Default value is False. |
| show_leader_lines | Allows to specify whether data label leader lines need be shown for the data labels of the entire series. Default value is False. |
| show_legend_key | Allows to specify whether legend key is to be displayed for the data labels of the entire series. Default value is False. |
| show_percentage | Allows to specify whether percentage value is to be displayed for the data labels of the entire series. Default value is False. Applies only to Pie charts. |
| show_series_name | Returns or sets a Boolean to indicate the series name display behavior for the data labels of the entire series. True to show the series name; False to hide. By default False. |
| show_value | Allows to specify whether values are to be displayed in the data labels of the entire series. Default value is False. |
Methods
Examples
Shows how to apply labels to data points in a line chart (ApplyDataLabels).
@staticmethod
def _apply_data_labels(series, labels_count, number_format, separator):
series.has_data_labels = True
series.explosion = 40
i = 0
while i < labels_count:
self.assertFalse(series.data_labels[i].is_visible)
series.data_labels[i].show_category_name = True
series.data_labels[i].show_series_name = True
series.data_labels[i].show_value = True
series.data_labels[i].show_leader_lines = True
series.data_labels[i].show_legend_key = True
series.data_labels[i].show_percentage = False
self.assertFalse(series.data_labels[i].is_hidden)
self.assertFalse(series.data_labels[i].show_data_labels_range)
series.data_labels[i].number_format.format_code = number_format
series.data_labels[i].separator = separator
self.assertFalse(series.data_labels[i].show_data_labels_range)
self.assertTrue(series.data_labels[i].is_visible)
self.assertFalse(series.data_labels[i].is_hidden)
i += 1
See Also