ChartSeries class

ChartSeries class

Represents chart series properties. To learn more, visit the Working with Charts documentation article.

Interfaces: IChartDataPoint

Properties

NameDescription
bubble_3dSpecifies whether the bubbles in Bubble chart should have a 3-D effect applied to them.
bubble_sizesGets a collection of bubble sizes for this chart series.
data_labelsSpecifies the settings for the data labels for the entire series.
data_pointsReturns a collection of formatting objects for all data points in this series.
explosionSpecifies the amount the data point shall be moved from the center of the pie. Can be negative, negative means that property is not set and no explosion should be applied. Applies only to Pie charts.
formatProvides access to fill and line formatting of the series.
has_data_labelsGets or sets a flag indicating whether data labels are displayed for the series.
invert_if_negativeSpecifies whether the parent element shall inverts its colors if the value is negative.
legend_entryGets a legend entry for this chart series.
markerSpecifies a data marker. Marker is automatically created when requested.
nameGets or sets the name of the series, if name is not set explicitly it is generated using index. By default returns Series plus one based index.
series_typeGets the type of this chart series.
smoothAllows to specify whether the line connecting the points on the chart shall be smoothed using Catmull-Rom splines.
x_valuesGets a collection of X values for this chart series.
y_valuesGets a collection of Y values for this chart series.

Methods

NameDescription
add(x_value)Adds the specified X value to the chart series. If the series supports Y values and bubble sizes, they will be empty for the X value.
add(x_value, y_value)Adds the specified X and Y values to the chart series.
add(x_value, y_value, bubble_size)Adds the specified X value, Y value and bubble size to the chart series.
clear()Removes all data values from the chart series. Format of all individual data points and data labels is cleared.
clear_values()Removes all data values from the chart series with preserving the format of the data points and data labels.
copy_format_from(data_point_index)Copies default data point format from the data point with the specified index.
insert(index, x_value)Inserts the specified X value into the chart series at the specified index. If the series supports Y values and bubble sizes, they will be empty for the X value.
insert(index, x_value, y_value)Inserts the specified X and Y values into the chart series at the specified index.
insert(index, x_value, y_value, bubble_size)Inserts the specified X value, Y value and bubble size into the chart series at the specified index.
remove(index)Removes the X value, Y value, and bubble size, if supported, from the chart series at the specified index. The corresponding data point and data label are also removed.

Examples

Shows how to apply labels to data points in a line chart.

def data_labels():
    doc = aw.Document()
    builder = aw.DocumentBuilder(doc)
    chart_shape = builder.insert_chart(aw.drawing.charts.ChartType.LINE, 400, 300)
    chart = chart_shape.chart
    self.assertEqual(3, chart.series.count)
    self.assertEqual('Series 1', chart.series[0].name)
    self.assertEqual('Series 2', chart.series[1].name)
    self.assertEqual('Series 3', chart.series[2].name)
    # Apply data labels to every series in the chart.
    # These labels will appear next to each data point in the graph and display its value.
    for series in chart.series:
        apply_data_labels(series, 4, '000.0', ', ')
        self.assertEqual(4, series.data_labels.count)
    # Change the separator string for every data label in a series.
    for label in chart.series[0].data_labels:
        self.assertEqual(', ', label.separator)
        label.separator = ' & '
    # For a cleaner looking graph, we can remove data labels individually.
    chart.series[1].data_labels[2].clear_format()
    # We can also strip an entire series of its data labels at once.
    chart.series[2].data_labels.clear_format()
    doc.save(ARTIFACTS_DIR + 'Charts.data_labels.docx')

def apply_data_labels(series: aw.drawing.charts.ChartSeries, labels_count: int, number_format: str, separator: str):
    """Apply data labels with custom number format and separator to several data points in a series."""
    for i in range(labels_count):
        series.has_data_labels = True
        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
        series.data_labels[i].is_hidden = False
        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)

See Also