position property
ChartDataLabel.position property
Gets or sets the position of the data label.
@property
def position(self) -> aspose.words.drawing.charts.ChartDataLabelPosition:
...
@position.setter
def position(self, value: aspose.words.drawing.charts.ChartDataLabelPosition):
...
Remarks
The position can be set for data labels of the following chart series types:
ChartSeriesType.BAR, ChartSeriesType.COLUMN, ChartSeriesType.HISTOGRAM, ChartSeriesType.PARETO, ChartSeriesType.WATERFALL; allowed values: ChartDataLabelPosition.CENTER, ChartDataLabelPosition.INSIDE_BASE, ChartDataLabelPosition.INSIDE_END and ChartDataLabelPosition.OUTSIDE_END;
ChartSeriesType.BAR_STACKED, ChartSeriesType.BAR_PERCENT_STACKED, ChartSeriesType.COLUMN_STACKED, ChartSeriesType.COLUMN_PERCENT_STACKED; allowed values: ChartDataLabelPosition.CENTER, ChartDataLabelPosition.INSIDE_BASE and ChartDataLabelPosition.INSIDE_END;
ChartSeriesType.BUBBLE, ChartSeriesType.BUBBLE_3D, ChartSeriesType.LINE, ChartSeriesType.LINE_STACKED, ChartSeriesType.LINE_PERCENT_STACKED, ChartSeriesType.SCATTER, ChartSeriesType.STOCK; allowed values: ChartDataLabelPosition.CENTER, ChartDataLabelPosition.LEFT, ChartDataLabelPosition.RIGHT, ChartDataLabelPosition.ABOVE and ChartDataLabelPosition.BELOW;
ChartSeriesType.PIE, ChartSeriesType.PIE_3D, ChartSeriesType.PIE_OF_BAR, ChartSeriesType.PIE_OF_PIE; allowed values: ChartDataLabelPosition.CENTER, ChartDataLabelPosition.INSIDE_END, ChartDataLabelPosition.OUTSIDE_END and ChartDataLabelPosition.BEST_FIT;
ChartSeriesType.BOX_AND_WHISKER; allowed values: ChartDataLabelPosition.LEFT, ChartDataLabelPosition.RIGHT, ChartDataLabelPosition.ABOVE and ChartDataLabelPosition.BELOW.
Examples
Shows how to set the position of the data label.
doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
# Insert column chart.
shape = builder.insert_chart(chart_type=aw.drawing.charts.ChartType.COLUMN, width=432, height=252)
chart = shape.chart
series_coll = chart.series
# Delete default generated series.
series_coll.clear()
# Add series.
series = series_coll.add(series_name='Series 1', categories=['Category 1', 'Category 2', 'Category 3'], values=[4, 5, 6])
# Show data labels and set font color.
series.has_data_labels = True
data_labels = series.data_labels
data_labels.show_value = True
data_labels.font.color = aspose.pydrawing.Color.white
# Set data label position.
data_labels.position = aw.drawing.charts.ChartDataLabelPosition.INSIDE_BASE
data_labels[0].position = aw.drawing.charts.ChartDataLabelPosition.OUTSIDE_END
data_labels[0].font.color = aspose.pydrawing.Color.dark_red
doc.save(file_name=ARTIFACTS_DIR + 'Charts.LabelPosition.docx')
See Also
- module aspose.words.drawing.charts
- class ChartDataLabel