public class ChartDataLabelPosition
extends java.lang.Object
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");
| Modifier and Type | Field and Description |
|---|---|
static int |
ABOVE
Specifies that a data label should be displayed above a data marker.
|
static int |
BELOW
Specifies that a data label should be displayed below a data marker.
|
static int |
BEST_FIT
Specifies that a data label should be displayed in the most appropriate position.
|
static int |
CENTER
Specifies that a data label should be displayed centered on a data marker.
|
static int |
INSIDE_BASE
Specifies that a data label should be displayed inside the base of a data marker.
|
static int |
INSIDE_END
Specifies that a data label should be displayed inside the end of a data marker.
|
static int |
LEFT
Specifies that a data label should be displayed to the left of a data marker.
|
static int |
length |
static int |
OUTSIDE_END
Specifies that a data label should be displayed outside the end of a data marker.
|
static int |
RIGHT
Specifies that a data label should be displayed to the right of a data marker.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
fromName(java.lang.String chartDataLabelPositionName) |
static java.lang.String |
getName(int chartDataLabelPosition) |
static int[] |
getValues() |
static java.lang.String |
toString(int chartDataLabelPosition) |
public static int CENTER
public static int LEFT
public static int RIGHT
public static int ABOVE
public static int BELOW
public static int INSIDE_BASE
public static int INSIDE_END
public static int OUTSIDE_END
public static int BEST_FIT
public static int length