Class Legend
- java.lang.Object
-
- org.pepstock.charba.client.configuration.Legend
-
- All Implemented Interfaces:
AddHandlerEventHandler
,EventHandler
,RemoveHandlerEventHandler
public class Legend extends Object
The chart legend displays data about the datasets that area appearing on the chart.- Author:
- Andrea "Stock" Stocchero
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ElementAlign
getAlign()
Returns the alignment of the legend.IsChart
getChart()
Returns the chart instanceprotected ExtendedOptions
getConfiguration()
Returns the configuration element.Set<Event>
getEvents()
Returns the browser events that the legend should listen to.LegendLabels
getLabels()
Returns the legend labels element.int
getMaxHeight()
Returns the maximum width of the legend, in pixels.int
getMaxWidth()
Returns the maximum width of the legend, in pixels.protected ConfigurationOptions
getOptions()
Returns the configuration options.Position
getPosition()
Returns the position of the legend.TextDirection
getTextDirection()
Returns the text direction of the legend that will force the text direction on the canvas for rendering the legend, regardless of the CSS specified on the canvas.LegendTitle
getTitle()
Returns the legend title element.boolean
hasClickHandlers()
Returnstrue
if there is any legend click handler, otherwisefalse
.boolean
hasHoverHandlers()
Returnstrue
if there is any legend hover handler, otherwisefalse
.boolean
hasLeaveHandlers()
Returnstrue
if there is any legend leave handler, otherwisefalse
.boolean
isDisplay()
Returns if the legend is shown.boolean
isFullSize()
Returns if marks that this box should take the full width/height of the canvas (moving other boxes).boolean
isReverse()
Returns if the legend will show datasets in reverse order.boolean
isRtl()
Returnstrue
for rendering the legends from right to left.void
onAdd(AddHandlerEvent event)
Invoked when a new event handler is added.void
onRemove(RemoveHandlerEvent event)
Invoked when a chart event handler is removed.void
setAlign(ElementAlign alignment)
Sets the alignment of the legend.void
setDisplay(boolean display)
Sets if the legend is shown.void
setEvents(Event... events)
Sets the browser events that the legend should listen to.void
setFullSize(boolean fullSize)
Marks that this box should take the full width/height of the canvas (moving other boxes).void
setMaxHeight(int maxHeight)
Sets the maximum height of the legend, in pixels.void
setMaxWidth(int maxWidth)
Sets the maximum width of the legend, in pixels.void
setPosition(Position position)
Sets the position of the legend.void
setReverse(boolean reverse)
Sets the legend will show datasets in reverse order.void
setRtl(boolean rtl)
Setstrue
for rendering the legends from right to left.void
setTextDirection(TextDirection textDirection)
Sets the text direction of the legend that will force the text direction on the canvas for rendering the legend, regardless of the CSS specified on the canvas.
-
-
-
Method Detail
-
getLabels
public LegendLabels getLabels()
Returns the legend labels element.- Returns:
- the labels
-
getTitle
public LegendTitle getTitle()
Returns the legend title element.- Returns:
- the title
-
setEvents
public void setEvents(Event... events)
Sets the browser events that the legend should listen to.- Parameters:
events
- the browser events that the legend should listen to.
-
getEvents
public Set<Event> getEvents()
Returns the browser events that the legend should listen to.- Returns:
- the browser events that the legend should listen to.
-
onAdd
public final void onAdd(AddHandlerEvent event)
Description copied from interface:AddHandlerEventHandler
Invoked when a new event handler is added.- Specified by:
onAdd
in interfaceAddHandlerEventHandler
- Parameters:
event
- event to be consumed
-
onRemove
public final void onRemove(RemoveHandlerEvent event)
Description copied from interface:RemoveHandlerEventHandler
Invoked when a chart event handler is removed.- Specified by:
onRemove
in interfaceRemoveHandlerEventHandler
- Parameters:
event
- event to be consumed
-
hasClickHandlers
public final boolean hasClickHandlers()
Returnstrue
if there is any legend click handler, otherwisefalse
.- Returns:
true
if there is any legend click handler, otherwisefalse
.
-
hasHoverHandlers
public final boolean hasHoverHandlers()
Returnstrue
if there is any legend hover handler, otherwisefalse
.- Returns:
true
if there is any legend hover handler, otherwisefalse
.
-
hasLeaveHandlers
public final boolean hasLeaveHandlers()
Returnstrue
if there is any legend leave handler, otherwisefalse
.- Returns:
true
if there is any legend leave handler, otherwisefalse
.
-
setDisplay
public void setDisplay(boolean display)
Sets if the legend is shown.- Parameters:
display
- if the legend is shown.
-
isDisplay
public boolean isDisplay()
Returns if the legend is shown.- Returns:
- if the legend is shown.
-
setFullSize
public void setFullSize(boolean fullSize)
Marks that this box should take the full width/height of the canvas (moving other boxes).- Parameters:
fullSize
- Marks that this box should take the full width/height of the canvas (moving other boxes)
-
isFullSize
public boolean isFullSize()
Returns if marks that this box should take the full width/height of the canvas (moving other boxes).- Returns:
- Marks that this box should take the full width/height of the canvas (moving other boxes)
-
setReverse
public void setReverse(boolean reverse)
Sets the legend will show datasets in reverse order.- Parameters:
reverse
- legend will show datasets in reverse order.
-
isReverse
public boolean isReverse()
Returns if the legend will show datasets in reverse order.- Returns:
- Legend will show datasets in reverse order.
-
setPosition
public void setPosition(Position position)
Sets the position of the legend.- Parameters:
position
- Position of the legend.
-
getPosition
public Position getPosition()
Returns the position of the legend.- Returns:
- Position of the legend.
-
setAlign
public void setAlign(ElementAlign alignment)
Sets the alignment of the legend.- Parameters:
alignment
- alignment of the legend.
-
getAlign
public ElementAlign getAlign()
Returns the alignment of the legend.- Returns:
- alignment of the legend.
-
setRtl
public void setRtl(boolean rtl)
Setstrue
for rendering the legends from right to left.- Parameters:
rtl
-true
for rendering the legends from right to left
-
isRtl
public boolean isRtl()
Returnstrue
for rendering the legends from right to left.- Returns:
true
for rendering the legends from right to left.
-
setTextDirection
public void setTextDirection(TextDirection textDirection)
Sets the text direction of the legend that will force the text direction on the canvas for rendering the legend, regardless of the CSS specified on the canvas.- Parameters:
textDirection
- the text direction of the legend.
-
getTextDirection
public TextDirection getTextDirection()
Returns the text direction of the legend that will force the text direction on the canvas for rendering the legend, regardless of the CSS specified on the canvas.- Returns:
- the text direction of the legend.
-
setMaxWidth
public void setMaxWidth(int maxWidth)
Sets the maximum width of the legend, in pixels.- Parameters:
maxWidth
- the maximum width of the legend, in pixels
-
getMaxWidth
public int getMaxWidth()
Returns the maximum width of the legend, in pixels.- Returns:
- the maximum width of the legend, in pixels
-
setMaxHeight
public void setMaxHeight(int maxHeight)
Sets the maximum height of the legend, in pixels.- Parameters:
maxHeight
- the maximum height of the legend, in pixels
-
getMaxHeight
public int getMaxHeight()
Returns the maximum width of the legend, in pixels.- Returns:
- the maximum width of the legend, in pixels
-
getOptions
protected final ConfigurationOptions getOptions()
Returns the configuration options.- Returns:
- the configuration options.
-
getConfiguration
protected final ExtendedOptions getConfiguration()
Returns the configuration element.- Returns:
- the configuration element.
-
getChart
public final IsChart getChart()
Returns the chart instance- Returns:
- the chart
-
-