Aspose::Words::Drawing::Charts::ChartDataLabelPosition enum

ChartDataLabelPosition enum

Specifies the position for a chart data label.

enum class ChartDataLabelPosition : int

Values

NameValueDescription
Above3Specifies that a data label should be displayed above a data marker.
Below4Specifies that a data label should be displayed below a data marker.
BestFit8Specifies that a data label should be displayed in the most appropriate position.
Center0Specifies that a data label should be displayed centered on a data marker.
InsideBase5Specifies that a data label should be displayed inside the base of a data marker.
InsideEnd6Specifies that a data label should be displayed inside the end of a data marker.
Left1Specifies that a data label should be displayed to the left of a data marker.
OutsideEnd7Specifies that a data label should be displayed outside the end of a data marker.
Right2Specifies that a data label should be displayed to the right of a data marker.

Remarks

Not all series types allow you to specify label positions. And those that do, do not support all values.

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(ChartType::Column, static_cast<double>(432), static_cast<double>(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(ChartDataLabelPosition::InsideBase);
dataLabels->idx_get(0)->set_Position(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