ChartDataLabelPosition

Inheritance: java.lang.Object

public class ChartDataLabelPosition

Specifies the position for a chart data label.

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.0, 252.0);
 Chart chart = shape.getChart();
 ChartSeriesCollection seriesColl = chart.getSeries();

 // 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.0, 5.0, 6.0 });

 // Show data labels and set font color.
 series.hasDataLabels(true);
 ChartDataLabelCollection dataLabels = series.getDataLabels();
 dataLabels.setShowValue(true);
 dataLabels.getFont().setColor(Color.WHITE);

 // Set data label position.
 dataLabels.setPosition(ChartDataLabelPosition.INSIDE_BASE);
 dataLabels.get(0).setPosition(ChartDataLabelPosition.OUTSIDE_END);
 dataLabels.get(0).getFont().setColor(Color.RED);

 doc.save(getArtifactsDir() + "Charts.LabelPosition.docx");
 

Fields

FieldDescription
ABOVESpecifies that a data label should be displayed above a data marker.
BELOWSpecifies that a data label should be displayed below a data marker.
BEST_FITSpecifies that a data label should be displayed in the most appropriate position.
CENTERSpecifies that a data label should be displayed centered on a data marker.
INSIDE_BASESpecifies that a data label should be displayed inside the base of a data marker.
INSIDE_ENDSpecifies that a data label should be displayed inside the end of a data marker.
LEFTSpecifies that a data label should be displayed to the left of a data marker.
OUTSIDE_ENDSpecifies that a data label should be displayed outside the end of a data marker.
RIGHTSpecifies that a data label should be displayed to the right of a data marker.
length

Methods

MethodDescription
fromName(String chartDataLabelPositionName)
getName(int chartDataLabelPosition)
getValues()
toString(int chartDataLabelPosition)

ABOVE

public static int ABOVE

Specifies that a data label should be displayed above a data marker.

BELOW

public static int BELOW

Specifies that a data label should be displayed below a data marker.

BEST_FIT

public static int BEST_FIT

Specifies that a data label should be displayed in the most appropriate position.

CENTER

public static int CENTER

Specifies that a data label should be displayed centered on a data marker.

INSIDE_BASE

public static int INSIDE_BASE

Specifies that a data label should be displayed inside the base of a data marker.

INSIDE_END

public static int INSIDE_END

Specifies that a data label should be displayed inside the end of a data marker.

LEFT

public static int LEFT

Specifies that a data label should be displayed to the left of a data marker.

OUTSIDE_END

public static int OUTSIDE_END

Specifies that a data label should be displayed outside the end of a data marker.

public static int RIGHT

Specifies that a data label should be displayed to the right of a data marker.

length

public static int length

fromName(String chartDataLabelPositionName)

public static int fromName(String chartDataLabelPositionName)

Parameters:

ParameterTypeDescription
chartDataLabelPositionNamejava.lang.String

Returns: int

getName(int chartDataLabelPosition)

public static String getName(int chartDataLabelPosition)

Parameters:

ParameterTypeDescription
chartDataLabelPositionint

Returns: java.lang.String

getValues()

public static int[] getValues()

Returns: int[]

toString(int chartDataLabelPosition)

public static String toString(int chartDataLabelPosition)

Parameters:

ParameterTypeDescription
chartDataLabelPositionint

Returns: java.lang.String