public class Legend extends ChartTextFrame
Example
Workbook workbook = new Workbook();
Worksheet sheet = workbook.getWorksheets().get(0);
Cells cells = sheet.getCells();
cells.get(0,1).putValue("Income");
cells.get(1,0).putValue("Company A");
cells.get(2,0).putValue("Company B");
cells.get(3,0).putValue("Company C");
cells.get(1,1).putValue(10000);
cells.get(2,1).putValue(20000);
cells.get(3,1).putValue(30000);
int chartIndex = sheet.getCharts().add(ChartType.COLUMN, 9, 9, 21, 15);
Chart chart = sheet.getCharts().get(chartIndex);
chart.setChartDataRange("A1:B4", true);
//Set Legend's width and height
Legend legend = chart.getLegend();
//Legend is at right side of chart by default.
//If the legend is at left or right side of the chart, setting Legend.X property will not take effect.
//If the legend is at top or bottom side of the chart, setting Legend.Y property will not take effect.
legend.setY(1500);
legend.setWidth(50);
legend.setHeight(50);
//Set legend's position
legend.setPosition(LegendPositionType.LEFT);
| Modifier and Type | Method and Description |
|---|---|
LegendEntryCollection |
getLegendEntries()
Gets a collection of all the LegendEntry objects in the specified chart legend.
|
java.util.ArrayList |
getLegendEntriesLabels()
Gets the labels of the legend entries after call Chart.Calculate() method.
|
int |
getPosition()
Gets the legend position type.
|
boolean |
isOverLay()
Gets whether other chart elements shall be allowed to overlap this chart element.
|
void |
setOverLay(boolean value)
Sets whether other chart elements shall be allowed to overlap this chart element.
|
void |
setPosition(int value)
Sets the legend position type.
|
characters, getDirectionType, getLinkedSource, getReadingOrder, getRotationAngle, getText, getTextDirection, getTextHorizontalAlignment, getTextVerticalAlignment, isAutomaticRotation, isAutoText, isDeleted, isResizeShapeToFitText, isTextWrapped, setAutoText, setDeleted, setDirectionType, setLinkedSource, setReadingOrder, setResizeShapeToFitText, setRotationAngle, setText, setTextDirection, setTextHorizontalAlignment, setTextVerticalAlignment, setTextWrappedgetArea, getAutoScaleFont, getBackground, getBackgroundMode, getBorder, getChart, getDefaultHeight, getDefaultWidth, getDefaultX, getDefaultY, getFont, getHeight, getShadow, getShapeProperties, getTextFont, getTextOptions, getWidth, getX, getY, isAutomaticSize, isDefaultPosBeSet, isInnerMode, setAutomaticSize, setAutoScaleFont, setBackground, setBackgroundMode, setHeight, setInnerMode, setPositionAuto, setShadow, setWidth, setX, setYpublic int getPosition()
See LegendPositionType.
Remarks
public void setPosition(int value)
See LegendPositionType.
Remarks
public LegendEntryCollection getLegendEntries()
public java.util.ArrayList getLegendEntriesLabels()
public boolean isOverLay()
public void setOverLay(boolean value)
See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2001-2023. All Rights Reserved.