public class ChartLegend
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 |
---|
Property Getters/Setters Summary | ||
---|---|---|
boolean | getOverlay() | |
void | setOverlay(booleanvalue) | |
Determines whether other chart elements shall be allowed to overlap legend. Default value is false. | ||
int | getPosition() | |
void | setPosition(intvalue) | |
Specifies the position of the legend on a chart.
Default value is |
public boolean getOverlay() / public void setOverlay(boolean value)
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");
public int getPosition() / public void setPosition(int value)
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");