Aspose::Words::Drawing::Charts::ChartDataLabelCollection::get_Position method
Contents
[
Hide
]ChartDataLabelCollection::get_Position method
Gets or sets the position of the data labels.
Aspose::Words::Drawing::Charts::ChartDataLabelPosition Aspose::Words::Drawing::Charts::ChartDataLabelCollection::get_Position()
Remarks
The position can be set for data labels of the following chart series types:
- Bar, Column, Histogram, Pareto, Waterfall; allowed values: Center, InsideBase, InsideEnd and OutsideEnd;
- BarStacked, BarPercentStacked, ColumnStacked, ColumnPercentStacked; allowed values: Center, InsideBase and InsideEnd;
- Bubble, Bubble3D, Line, LineStacked, LinePercentStacked, Scatter, Stock; allowed values: Center, Left, Right, Above and Below;
- Pie, Pie3D, PieOfBar, PieOfPie; allowed values: Center, InsideEnd, OutsideEnd and BestFit;
- BoxAndWhisker; allowed values: Left, Right, Above and Below.
Examples
Shows how to set the position of the data label.
auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);
// Insert column chart.
System::SharedPtr<Aspose::Words::Drawing::Shape> shape = builder->InsertChart(Aspose::Words::Drawing::Charts::ChartType::Column, 432, 252);
System::SharedPtr<Aspose::Words::Drawing::Charts::Chart> chart = shape->get_Chart();
System::SharedPtr<Aspose::Words::Drawing::Charts::ChartSeriesCollection> seriesColl = chart->get_Series();
// Delete default generated series.
seriesColl->Clear();
// Add series.
System::SharedPtr<Aspose::Words::Drawing::Charts::ChartSeries> series = seriesColl->Add(u"Series 1", System::MakeArray<System::String>({u"Category 1", u"Category 2", u"Category 3"}), System::MakeArray<double>({4, 5, 6}));
// Show data labels and set font color.
series->set_HasDataLabels(true);
System::SharedPtr<Aspose::Words::Drawing::Charts::ChartDataLabelCollection> dataLabels = series->get_DataLabels();
dataLabels->set_ShowValue(true);
dataLabels->get_Font()->set_Color(System::Drawing::Color::get_White());
// Set data label position.
dataLabels->set_Position(Aspose::Words::Drawing::Charts::ChartDataLabelPosition::InsideBase);
dataLabels->idx_get(0)->set_Position(Aspose::Words::Drawing::Charts::ChartDataLabelPosition::OutsideEnd);
dataLabels->idx_get(0)->get_Font()->set_Color(System::Drawing::Color::get_DarkRed());
doc->Save(get_ArtifactsDir() + u"Charts.LabelPosition.docx");
See Also
- Enum ChartDataLabelPosition
- Class ChartDataLabelCollection
- Namespace Aspose::Words::Drawing::Charts
- Library Aspose.Words for C++