LegendPosition

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

FieldDescription
BOTTOMSpecifies that the legend shall be drawn at the bottom of the chart.
LEFTSpecifies that the legend shall be drawn at the left of the chart.
NONENo legend will be shown for the chart.
RIGHTSpecifies that the legend shall be drawn at the right of the chart.
TOPSpecifies that the legend shall be drawn at the top of the chart.
TOP_RIGHTSpecifies that the legend shall be drawn at the top right of the chart.
length

Methods

MethodDescription
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.

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:

ParameterTypeDescription
legendPositionNamejava.lang.String

Returns: int

getName(int legendPosition)

public static String getName(int legendPosition)

Parameters:

ParameterTypeDescription
legendPositionint

Returns: java.lang.String

getValues()

public static int[] getValues()

Returns: int[]

toString(int legendPosition)

public static String toString(int legendPosition)

Parameters:

ParameterTypeDescription
legendPositionint

Returns: java.lang.String