com.aspose.words
Class ChartLegend

java.lang.Object
    extended by com.aspose.words.ChartLegend
All Implemented Interfaces:
java.lang.Cloneable

public class ChartLegend 
extends java.lang.Object

Represents chart legend properties.

Example:

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");

Constructor Summary
ChartLegend()
          
 
Property Getters/Setters Summary
booleangetOverlay()
voidsetOverlay(boolean value)
           Determines whether other chart elements shall be allowed to overlap legend. Default value is false.
intgetPosition()
voidsetPosition(int value)
           Specifies the position of the legend on a chart. Default value is LegendPosition.RIGHT. The value of the property is LegendPosition integer constant.
 

Constructor Detail

ChartLegend

public ChartLegend()

Property Getters/Setters Detail

getOverlay/setOverlay

public boolean getOverlay() / public void setOverlay(boolean value)
Determines whether other chart elements shall be allowed to overlap legend. Default value is false.

Example:

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");

getPosition/setPosition

public int getPosition() / public void setPosition(int value)
Specifies the position of the legend on a chart. Default value is LegendPosition.RIGHT. The value of the property is LegendPosition integer constant.

Example:

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");

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.