add method

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.

def add(self, x_value: aspose.words.drawing.charts.ChartXValue):
    ...
ParameterTypeDescription
x_valueChartXValue

add(x_value, y_value)

Adds the specified X and Y values to the chart series.

def add(self, x_value: aspose.words.drawing.charts.ChartXValue, y_value: aspose.words.drawing.charts.ChartYValue):
    ...
ParameterTypeDescription
x_valueChartXValue
y_valueChartYValue

add(x_value, y_value, bubble_size)

Adds the specified X value, Y value and bubble size to the chart series.

def add(self, x_value: aspose.words.drawing.charts.ChartXValue, y_value: aspose.words.drawing.charts.ChartYValue, bubble_size: float):
    ...
ParameterTypeDescription
x_valueChartXValue
y_valueChartYValue
bubble_sizefloat

Examples

Shows how to populate chart series with data.

doc = aw.Document()
builder = aw.DocumentBuilder()
shape = builder.insert_chart(chart_type=aw.drawing.charts.ChartType.COLUMN, width=432, height=252)
chart = shape.chart
series1 = chart.series[0]
# Clear X and Y values of the first series.
series1.clear_values()
# Populate the series with data.
series1.add(x_value=aw.drawing.charts.ChartXValue.from_double(3), y_value=aw.drawing.charts.ChartYValue.from_double(10))
series1.add(x_value=aw.drawing.charts.ChartXValue.from_double(5), y_value=aw.drawing.charts.ChartYValue.from_double(5))
series1.add(x_value=aw.drawing.charts.ChartXValue.from_double(7), y_value=aw.drawing.charts.ChartYValue.from_double(11))
series1.add(x_value=aw.drawing.charts.ChartXValue.from_double(9), y_value=aw.drawing.charts.ChartYValue.from_double(17))
series2 = chart.series[1]
# Clear X and Y values of the second series.
series2.clear_values()
# Populate the series with data.
series2.add(x_value=aw.drawing.charts.ChartXValue.from_double(2), y_value=aw.drawing.charts.ChartYValue.from_double(4))
series2.add(x_value=aw.drawing.charts.ChartXValue.from_double(4), y_value=aw.drawing.charts.ChartYValue.from_double(7))
series2.add(x_value=aw.drawing.charts.ChartXValue.from_double(6), y_value=aw.drawing.charts.ChartYValue.from_double(14))
series2.add(x_value=aw.drawing.charts.ChartXValue.from_double(8), y_value=aw.drawing.charts.ChartYValue.from_double(7))
doc.save(file_name=ARTIFACTS_DIR + 'Charts.PopulateChartWithData.docx')

Shows how to add/remove chart data values.

doc = aw.Document()
builder = aw.DocumentBuilder()
shape = builder.insert_chart(chart_type=aw.drawing.charts.ChartType.COLUMN, width=432, height=252)
chart = shape.chart
department_1_series = chart.series[0]
department_2_series = chart.series[1]
# Remove the first value in the both series.
department_1_series.remove(0)
department_2_series.remove(0)
# Add new values to the both series.
new_x_category = aw.drawing.charts.ChartXValue.from_string('Q1, 2023')
department_1_series.add(x_value=new_x_category, y_value=aw.drawing.charts.ChartYValue.from_double(10.3))
department_2_series.add(x_value=new_x_category, y_value=aw.drawing.charts.ChartYValue.from_double(5.7))
doc.save(file_name=ARTIFACTS_DIR + 'Charts.ChartDataValues.docx')

See Also