LegendPosition
Contents
[
Hide
]Inheritance: java.lang.Object
public class LegendPosition
Specifies the possible positions for a chart legend.
Examples:
Shows how to edit the appearance of a chart’s legend.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertChart(ChartType.LINE, 450.0, 300.0);
Chart chart = shape.getChart();
Assert.assertEquals(3, chart.getSeries().getCount());
Assert.assertEquals("Series 1", chart.getSeries().get(0).getName());
Assert.assertEquals("Series 2", chart.getSeries().get(1).getName());
Assert.assertEquals("Series 3", chart.getSeries().get(2).getName());
// Move the chart's legend to the top right corner.
ChartLegend legend = chart.getLegend();
legend.setPosition(LegendPosition.TOP_RIGHT);
// Give other chart elements, such as the graph, more room by allowing them to overlap the legend.
legend.setOverlay(true);
doc.save(getArtifactsDir() + "Charts.ChartLegend.docx");
Fields
Field | Description |
---|---|
BOTTOM | Specifies that the legend shall be drawn at the bottom of the chart. |
LEFT | Specifies that the legend shall be drawn at the left of the chart. |
NONE | No legend will be shown for the chart. |
RIGHT | Specifies that the legend shall be drawn at the right of the chart. |
TOP | Specifies that the legend shall be drawn at the top of the chart. |
TOP_RIGHT | Specifies that the legend shall be drawn at the top right of the chart. |
length |
Methods
Method | Description |
---|---|
fromName(String legendPositionName) | |
getName(int legendPosition) | |
getValues() | |
toString(int legendPosition) |
BOTTOM
public static int BOTTOM
Specifies that the legend shall be drawn at the bottom of the chart.
LEFT
public static int LEFT
Specifies that the legend shall be drawn at the left of the chart.
NONE
public static int NONE
No legend will be shown for the chart.
RIGHT
public static int RIGHT
Specifies that the legend shall be drawn at the right of the chart.
TOP
public static int TOP
Specifies that the legend shall be drawn at the top of the chart.
TOP_RIGHT
public static int TOP_RIGHT
Specifies that the legend shall be drawn at the top right of the chart.
length
public static int length
fromName(String legendPositionName)
public static int fromName(String legendPositionName)
Parameters:
Parameter | Type | Description |
---|---|---|
legendPositionName | java.lang.String |
Returns: int
getName(int legendPosition)
public static String getName(int legendPosition)
Parameters:
Parameter | Type | Description |
---|---|---|
legendPosition | int |
Returns: java.lang.String
getValues()
public static int[] getValues()
Returns: int[]
toString(int legendPosition)
public static String toString(int legendPosition)
Parameters:
Parameter | Type | Description |
---|---|---|
legendPosition | int |
Returns: java.lang.String