ChartDataLabelPosition

ChartDataLabelPosition enumeration

Specifies the position for a chart data label.

public enum ChartDataLabelPosition

Values

NameValueDescription
Center0Specifies that a data label should be displayed centered on a data marker.
Left1Specifies that a data label should be displayed to the left of a data marker.
Right2Specifies that a data label should be displayed to the right of a data marker.
Above3Specifies that a data label should be displayed above a data marker.
Below4Specifies that a data label should be displayed below 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.
OutsideEnd7Specifies that a data label should be displayed outside the end of a data marker.
BestFit8Specifies that a data label should be displayed in the most appropriate position.

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.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert column chart.
Shape shape = builder.InsertChart(ChartType.Column, 432, 252);
Chart chart = shape.Chart;
ChartSeriesCollection seriesColl = chart.Series;

// Delete default generated series.
seriesColl.Clear();

// Add series.
ChartSeries series = seriesColl.Add(
    "Series 1",
    new string[] { "Category 1", "Category 2", "Category 3" },
    new double[] { 4, 5, 6 });

// Show data labels and set font color.
series.HasDataLabels = true;
ChartDataLabelCollection dataLabels = series.DataLabels;
dataLabels.ShowValue = true;
dataLabels.Font.Color = Color.White;

// Set data label position.
dataLabels.Position = ChartDataLabelPosition.InsideBase;
dataLabels[0].Position = ChartDataLabelPosition.OutsideEnd;
dataLabels[0].Font.Color = Color.DarkRed;

doc.Save(ArtifactsDir + "Charts.LabelPosition.docx");

See Also