Legend
Inheritance: java.lang.Object, com.aspose.cells.ChartFrame, com.aspose.cells.ChartTextFrame
public class Legend extends ChartTextFrame
Encapsulates the object that represents the chart legend.
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);
Methods
Method | Description |
---|---|
characters(int startIndex, int length) | Returns a Characters object that represents a range of characters within the text. |
equals(Object arg0) | |
getArea() | Gets the Area. |
getAutoScaleFont() | True if the text in the object changes font size when the object size changes. |
getBackground() | Gets the display mode of the background |
getBackgroundMode() | Gets the display mode of the background |
getBorder() | Gets the Line. |
getChart() | Gets the chart to which this object belongs. |
getClass() | |
getDefaultHeight() | Represents height of default position |
getDefaultWidth() | Represents width of default position |
getDefaultX() | Represents x of default position |
getDefaultY() | Represents y of default position |
getDirectionType() | Gets the direction of text. |
getFont() | Gets a ChartArea.getFont() object of the specified ChartFrame object. |
getHeight() | Gets the height of frame in units of 1/4000 of the chart area. |
getLegendEntries() | Gets a collection of all the LegendEntry objects in the specified chart legend. |
getLegendEntriesLabels() | Gets the labels of the legend entries after call Chart.Calculate() method. |
getLegendLabels() | Gets the labels of the legend entries after call Chart.Calculate() method. |
getLinkedSource() | Gets a reference to the worksheet. |
getPosition() | Gets the legend position type. |
getReadingOrder() | Represents text reading order. |
getRotationAngle() | Represents text rotation angle. |
getShadow() | True if the frame has a shadow. |
getShapeProperties() | Gets the getShapeProperties() object. |
getText() | Gets the text of a frame’s title. |
getTextDirection() | Represents text reading order. |
getTextFont() | Gets a ChartArea.getFont() object of the specified ChartFrame object. |
getTextHorizontalAlignment() | Gets the text horizontal alignment. |
getTextOptions() | Gets the options of the text. |
getTextVerticalAlignment() | Gets the text vertical alignment of text. |
getWidth() | Gets the width of frame in units of 1/4000 of the chart area. |
getX() | Gets the x coordinate of the upper left corner in units of 1/4000 of the chart area. |
getY() | Gets the y coordinate of the upper left corner in units of 1/4000 of the chart area. |
hashCode() | |
isAutoText() | Indicates the text is auto generated. |
isAutomaticRotation() | Indicates whether the text of the chart is automatically rotated. |
isAutomaticSize() | Indicates whether the chart frame is automatic sized. |
isDefaultPosBeSet() | Indicates whether default position(DefaultX, DefaultY, DefaultWidth and DefaultHeight) are set. |
isDeleted() | Indicates whether this data labels is deleted. |
isInnerMode() | Indicates whether the size of the plot area size includes the tick marks, and the axis labels. |
isOverLay() | Gets whether showing the legend without overlapping the chart. |
isResizeShapeToFitText() | Gets whether a shape should be auto-fit to fully contain the text described within it. |
isTextWrapped() | Gets a value indicating whether the text is wrapped. |
notify() | |
notifyAll() | |
setAutoScaleFont(boolean value) | True if the text in the object changes font size when the object size changes. |
setAutoText(boolean value) | Indicates the text is auto generated. |
setAutomaticSize(boolean value) | Indicates whether the chart frame is automatic sized. |
setBackground(int value) | Sets the display mode of the background |
setBackgroundMode(int value) | Sets the display mode of the background |
setDeleted(boolean value) | Indicates whether this data labels is deleted. |
setDirectionType(int value) | Sets the direction of text. |
setHeight(int value) | Sets the height of frame in units of 1/4000 of the chart area. |
setInnerMode(boolean value) | Indicates whether the size of the plot area size includes the tick marks, and the axis labels. |
setLinkedSource(String value) | Sets a reference to the worksheet. |
setOverLay(boolean value) | Sets whether showing the legend without overlapping the chart. |
setPosition(int value) | Sets the legend position type. |
setPositionAuto() | Set position of the frame to automatic |
setReadingOrder(int value) | Represents text reading order. |
setResizeShapeToFitText(boolean value) | Sets whether a shape should be auto-fit to fully contain the text described within it. |
setRotationAngle(int value) | Represents text rotation angle. |
setShadow(boolean value) | True if the frame has a shadow. |
setText(String value) | Sets the text of a frame’s title. |
setTextDirection(int value) | Represents text reading order. |
setTextHorizontalAlignment(int value) | Sets the text horizontal alignment. |
setTextVerticalAlignment(int value) | Sets the text vertical alignment of text. |
setTextWrapped(boolean value) | Sets a value indicating whether the text is wrapped. |
setWidth(int value) | Sets the width of frame in units of 1/4000 of the chart area. |
setX(int value) | Sets the x coordinate of the upper left corner in units of 1/4000 of the chart area. |
setY(int value) | Sets the y coordinate of the upper left corner in units of 1/4000 of the chart area. |
toString() | |
wait() | |
wait(long arg0) | |
wait(long arg0, int arg1) |
characters(int startIndex, int length)
public FontSetting characters(int startIndex, int length)
Returns a Characters object that represents a range of characters within the text.
Parameters:
Parameter | Type | Description |
---|---|---|
startIndex | int | The index of the start of the character. |
length | int | The number of characters. |
Returns: FontSetting - Characters object.
equals(Object arg0)
public boolean equals(Object arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | java.lang.Object |
Returns: boolean
getArea()
public Area getArea()
Gets the Area.
Returns: Area
getAutoScaleFont()
public boolean getAutoScaleFont()
True if the text in the object changes font size when the object size changes. The default value is True.
Returns: boolean
getBackground()
public int getBackground()
Gets the display mode of the background
See BackgroundMode.
Remarks
NOTE: This member is now obsolete. Instead, please use ChartFrame.BackgroundMode property. This property will be removed 12 months later since JANUARY 2012. Aspose apologizes for any inconvenience you may have experienced.
Returns: int
getBackgroundMode()
public int getBackgroundMode()
Gets the display mode of the background
See BackgroundMode.
Returns: int
getBorder()
public Line getBorder()
Gets the Line.
Returns: Line
getChart()
public Chart getChart()
Gets the chart to which this object belongs.
Returns: Chart
getClass()
public final native Class<?> getClass()
Returns: java.lang.Class
getDefaultHeight()
public int getDefaultHeight()
Represents height of default position
Returns: int
getDefaultWidth()
public int getDefaultWidth()
Represents width of default position
Returns: int
getDefaultX()
public int getDefaultX()
Represents x of default position
Returns: int
getDefaultY()
public int getDefaultY()
Represents y of default position
Returns: int
getDirectionType()
public int getDirectionType()
Gets the direction of text.
Returns: int
getFont()
public Font getFont()
Gets a ChartArea.getFont() object of the specified ChartFrame object.
Returns: Font
getHeight()
public int getHeight()
Gets the height of frame in units of 1/4000 of the chart area.
Remarks
How to convert units of 1/4000 to pixels? Height In Pixels = Y * Chart.ChartObject.Height / 4000;
Returns: int
getLegendEntries()
public LegendEntryCollection getLegendEntries()
Gets a collection of all the LegendEntry objects in the specified chart legend. Setting the legend entries of the surface chart is not supported. So it will return null if the chart type is surface chart type.
Returns: LegendEntryCollection
getLegendEntriesLabels()
public ArrayList getLegendEntriesLabels()
Gets the labels of the legend entries after call Chart.Calculate() method.
Remarks
NOTE: This member is now obsolete. Instead, please use Legend.GetLegendLabels method. This property will be removed 12 months later since November 2023. Aspose apologizes for any inconvenience you may have experienced.
Returns: java.util.ArrayList
getLegendLabels()
public String[] getLegendLabels()
Gets the labels of the legend entries after call Chart.Calculate() method.
Returns: java.lang.String[]
getLinkedSource()
public String getLinkedSource()
Gets a reference to the worksheet.
Returns: java.lang.String
getPosition()
public int getPosition()
Gets the legend position type.
See LegendPositionType.
Remarks
Default position is right.
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.
Returns: int
getReadingOrder()
public int getReadingOrder()
Represents text reading order.
See TextDirectionType.
Returns: int
getRotationAngle()
public int getRotationAngle()
Represents text rotation angle.
Remarks
0: Not rotated.
255: Top to Bottom.
-90: Downward.
90: Upward.
Returns: int
getShadow()
public boolean getShadow()
True if the frame has a shadow.
Returns: boolean
getShapeProperties()
public ShapePropertyCollection getShapeProperties()
Gets the getShapeProperties() object.
Returns: ShapePropertyCollection
getText()
public String getText()
Gets the text of a frame’s title.
Returns: java.lang.String
getTextDirection()
public int getTextDirection()
Represents text reading order.
See TextDirectionType.
Remarks
NOTE: This member is now obsolete. Instead, please use ChartTextFrame.ReadingOrder property. This property will be removed 12 months later since March 2020. Aspose apologizes for any inconvenience you may have experienced.
Returns: int
getTextFont()
public Font getTextFont()
Gets a ChartArea.getFont() object of the specified ChartFrame object.
Remarks
NOTE: This member is now obsolete. Instead, please use ChartFrame.Font property. This property will be removed 12 months later since JANUARY 2012. Aspose apologizes for any inconvenience you may have experienced.
Returns: Font
getTextHorizontalAlignment()
public int getTextHorizontalAlignment()
Gets the text horizontal alignment.
See TextAlignmentType.
Returns: int
getTextOptions()
public TextOptions getTextOptions()
Gets the options of the text.
Returns: TextOptions
getTextVerticalAlignment()
public int getTextVerticalAlignment()
Gets the text vertical alignment of text.
See TextAlignmentType.
Returns: int
getWidth()
public int getWidth()
Gets the width of frame in units of 1/4000 of the chart area.
Remarks
How to convert units of 1/4000 to pixels? Width In Pixels = Width * Chart.ChartObject.Height / 4000;
Returns: int
getX()
public int getX()
Gets the x coordinate of the upper left corner in units of 1/4000 of the chart area.
Remarks
How to convert units of 1/4000 to pixels? X In Pixels = X * Chart.ChartObject.Width / 4000;
Returns: int
getY()
public int getY()
Gets the y coordinate of the upper left corner in units of 1/4000 of the chart area.
Remarks
How to convert units of 1/4000 to pixels? Y In Pixels = Y * Chart.ChartObject.Height / 4000;
Returns: int
hashCode()
public native int hashCode()
Returns: int
isAutoText()
public boolean isAutoText()
Indicates the text is auto generated.
Returns: boolean
isAutomaticRotation()
public boolean isAutomaticRotation()
Indicates whether the text of the chart is automatically rotated.
Returns: boolean
isAutomaticSize()
public boolean isAutomaticSize()
Indicates whether the chart frame is automatic sized.
Returns: boolean
isDefaultPosBeSet()
public boolean isDefaultPosBeSet()
Indicates whether default position(DefaultX, DefaultY, DefaultWidth and DefaultHeight) are set.
Returns: boolean
isDeleted()
public boolean isDeleted()
Indicates whether this data labels is deleted.
Returns: boolean
isInnerMode()
public boolean isInnerMode()
Indicates whether the size of the plot area size includes the tick marks, and the axis labels. False specifies that the size shall determine the size of the plot area, the tick marks, and the axis labels.
Remarks
Only for Xlsx file.
Returns: boolean
isOverLay()
public boolean isOverLay()
Gets whether showing the legend without overlapping the chart.
Returns: boolean
isResizeShapeToFitText()
public boolean isResizeShapeToFitText()
Gets whether a shape should be auto-fit to fully contain the text described within it. Auto-fitting is when text within a shape is scaled in order to contain all the text inside.
Returns: boolean
isTextWrapped()
public boolean isTextWrapped()
Gets a value indicating whether the text is wrapped.
Returns: boolean
notify()
public final native void notify()
notifyAll()
public final native void notifyAll()
setAutoScaleFont(boolean value)
public void setAutoScaleFont(boolean value)
True if the text in the object changes font size when the object size changes. The default value is True.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
setAutoText(boolean value)
public void setAutoText(boolean value)
Indicates the text is auto generated.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
setAutomaticSize(boolean value)
public void setAutomaticSize(boolean value)
Indicates whether the chart frame is automatic sized.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
setBackground(int value)
public void setBackground(int value)
Sets the display mode of the background
See BackgroundMode.
Remarks
NOTE: This member is now obsolete. Instead, please use ChartFrame.BackgroundMode property. This property will be removed 12 months later since JANUARY 2012. Aspose apologizes for any inconvenience you may have experienced.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setBackgroundMode(int value)
public void setBackgroundMode(int value)
Sets the display mode of the background
See BackgroundMode.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setDeleted(boolean value)
public void setDeleted(boolean value)
Indicates whether this data labels is deleted.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
setDirectionType(int value)
public void setDirectionType(int value)
Sets the direction of text.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setHeight(int value)
public void setHeight(int value)
Sets the height of frame in units of 1/4000 of the chart area.
Remarks
How to convert units of 1/4000 to pixels? Height In Pixels = Y * Chart.ChartObject.Height / 4000;
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setInnerMode(boolean value)
public void setInnerMode(boolean value)
Indicates whether the size of the plot area size includes the tick marks, and the axis labels. False specifies that the size shall determine the size of the plot area, the tick marks, and the axis labels.
Remarks
Only for Xlsx file.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
setLinkedSource(String value)
public void setLinkedSource(String value)
Sets a reference to the worksheet.
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String |
setOverLay(boolean value)
public void setOverLay(boolean value)
Sets whether showing the legend without overlapping the chart.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
setPosition(int value)
public void setPosition(int value)
Sets the legend position type.
See LegendPositionType.
Remarks
Default position is right.
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.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setPositionAuto()
public void setPositionAuto()
Set position of the frame to automatic
setReadingOrder(int value)
public void setReadingOrder(int value)
Represents text reading order.
See TextDirectionType.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setResizeShapeToFitText(boolean value)
public void setResizeShapeToFitText(boolean value)
Sets whether a shape should be auto-fit to fully contain the text described within it. Auto-fitting is when text within a shape is scaled in order to contain all the text inside.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
setRotationAngle(int value)
public void setRotationAngle(int value)
Represents text rotation angle.
Remarks
0: Not rotated.
255: Top to Bottom.
-90: Downward.
90: Upward.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setShadow(boolean value)
public void setShadow(boolean value)
True if the frame has a shadow.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
setText(String value)
public void setText(String value)
Sets the text of a frame’s title.
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String |
setTextDirection(int value)
public void setTextDirection(int value)
Represents text reading order.
See TextDirectionType.
Remarks
NOTE: This member is now obsolete. Instead, please use ChartTextFrame.ReadingOrder property. This property will be removed 12 months later since March 2020. Aspose apologizes for any inconvenience you may have experienced.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setTextHorizontalAlignment(int value)
public void setTextHorizontalAlignment(int value)
Sets the text horizontal alignment.
See TextAlignmentType.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setTextVerticalAlignment(int value)
public void setTextVerticalAlignment(int value)
Sets the text vertical alignment of text.
See TextAlignmentType.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setTextWrapped(boolean value)
public void setTextWrapped(boolean value)
Sets a value indicating whether the text is wrapped.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
setWidth(int value)
public void setWidth(int value)
Sets the width of frame in units of 1/4000 of the chart area.
Remarks
How to convert units of 1/4000 to pixels? Width In Pixels = Width * Chart.ChartObject.Height / 4000;
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setX(int value)
public void setX(int value)
Sets the x coordinate of the upper left corner in units of 1/4000 of the chart area.
Remarks
How to convert units of 1/4000 to pixels? X In Pixels = X * Chart.ChartObject.Width / 4000;
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setY(int value)
public void setY(int value)
Sets the y coordinate of the upper left corner in units of 1/4000 of the chart area.
Remarks
How to convert units of 1/4000 to pixels? Y In Pixels = Y * Chart.ChartObject.Height / 4000;
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
toString()
public String toString()
Returns: java.lang.String
wait()
public final void wait()
wait(long arg0)
public final native void wait(long arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long |
wait(long arg0, int arg1)
public final void wait(long arg0, int arg1)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long | |
arg1 | int |