Last updated

API / geotoolkit / controls / shapes / Legend / Legend

Class: Legend

shapes.Legend.Legend

This class defines a legend container in which legends items are laid out using specified layout. Items can be located in the legend vertically using VerticalPriorityLayout or horizontally using HorizontalPriorityLayout or in any location inside the legend with other layout or manually. The legend has an anchor position in the parent coordinates and width and height of the legend in model or device coordinates. This position can be specified with setAnchor method and size with setSize method. In addition it is possible to use automatic calculation of the legend size, which is supported for device size legend only. Legends can be customized using .setOptions().

Example

// Example of creating a legend with automatic size calculation in the device coordinates
import {Collection} from '@int/geotoolkit/util/Collection';
import {SymbolLegendItem} from '@int/geotoolkit/controls/shapes/SymbolLegendItem';
import {HorizontalLinePainter} from '@int/geotoolkit/scene/shapes/painters/HorizontalLinePainter';
import {Legend} from '@int/geotoolkit/controls/shapes/Legend';
import {AnchorType} from '@int/geotoolkit/util/AnchorType';
import {Point} from '@int/geotoolkit/util/Point';
import {VerticalPriorityLayout} from '@int/geotoolkit/layout/VerticalPriorityLayout';
const dataCollection = new Collection();
dataCollection.add(new SymbolLegendItem(null, {
'text': 'Item',
'textstyle': {'font': '12px Arial'},
'symbol': {
'painter': HorizontalLinePainter,
'width': 10,
'height': 10,
'linestyle': {'color': 'red' }
}
}));
const legendShape = new Legend({
'data': dataCollection,
'linestyle': {'color': 'red'}
'sizeisindevicespace': true,
'alignment': AnchorType.Center,
'autosize': true
});
legendShape.setAnchor(new Point(40, 10));
legendShape.setLayout(new VerticalPriorityLayout());

Example

// Example of creating a legend with manual size in model coordinates
const legendShape = new Legend({
'data': dataCollection,
'linestyle': {'color': 'red'}
'sizeisindevicespace': false,
'alignment': AnchorType.Center
});
legendShape.setAnchor(new Point(0.5, 0.5));
legendShape.setSize(0.5, 0.5);
legendShape.setLayout(new VerticalPriorityLayout());

Hierarchy

Implements

Table of contents

Constructors
Methods
addChildaddCssClassaddInvalidateHandler
applyOpacityapplyResponsiveStylecheckCollision
clearChildrencloneconnectStyle
copyConstructordisconnectStyledispose
enableClippingenableEventPropagationenumerateNodes
executefiltergetAnchor
getAnchorTypegetAnchorXgetAnchorY
getAnimationStylegetAspectRatiogetAutoSize
getBoundsgetChildrengetClassName
getClipStylegetCssgetCssClass
getCssClassesgetCssTransformgetData
getDesiredHeightgetDesiredWidthgetFillStyle
getHeightgetIdgetInvalidateMethod
getIsPointingUpgetLayoutgetLayoutStyle
getLegendDeviceSizegetLineStylegetLocalTransform
getMarginsStylegetMaxSizegetMinSize
getModelLimitsgetNamegetOpacity
getOpacityBlendModegetPaddingStylegetParent
getPreserveAspectRatiogetPreserveReadingOrientationgetPreserveRightAngle
getPropertiesgetPropertygetPropertyKeys
getRenderingFiltergetResponsiveStylegetRoot
getRotationAnglegetScaleScrollStrategygetSceneTransform
getSizegetSizeIsInDeviceSpacegetTag
getUseMinMaxSizegetVisiblegetWidth
getWorldTransformgetZIndexhasCssClass
hasEventListenerinvalidateinvalidateParent
isClippingEnabledisDisposedisEventPropagationEnabled
isNotificationEnabledisSelectableisSilent
notifyoffon
onParentChangedonVisibilityChangedpostRendering
preRenderingregisterAnimationStyleremoveChild
removeCssClassremoveInvalidateHandlerrender
renderAsyncrotatescale
setAnchorsetAnchorTypesetAnchorX
setAnchorYsetAnimationStylesetAutoSize
setBoundssetClipStylesetCss
setCssClasssetCssTransformsetDesiredHeight
setDesiredWidthsetFillStylesetHeight
setIdsetIsPointingUpsetLayout
setLayoutStylesetLineStylesetLocalTransform
setMarginsStylesetMaxSizesetMinSize
setModelLimitssetNamesetNotification
setOpacitysetOptionssetPaddingStyle
setPreserveAspectRatiosetPreserveReadingOrientationsetPreserveRightAngle
setPropertiessetPropertysetRenderingFilter
setResponsiveStylesetRotationAnglesetScaleScrollStrategy
setSelectablesetSilentsetSize
setSizeIsInDeviceSpacesetTagsetUseMinMaxSize
setVisiblesetWidthsetZIndex
sheartoStringtranslate
unregisterAnimationStyleupdateLayoutupdateSceneTransformation
updateSizeupdateStateupdateTimeStamp
enableSceneGraphNotificationfindParentgetAnchorPosition
getClassNameintersectsBoundsisSceneGraphNotificationEnabled

Contents

Constructors

new Legend(options)

new Legend(options?)

Parameters

Name Type
Optional optionsstring | number | Options

Overrides

AnchoredShape.constructor

Methods

addChild

Protected addChild(node): Legend

Add a child node

Parameters

Name Type Description
nodeLegendItem | LegendItem[] | Iterator<LegendItem>the child node to be added

Returns

Legend

this


addCssClass

addCssClass(cssclass): Legend

Adds new css class to node

Parameters

Name Type Description
cssclassstring | string[]css class name('s)

Returns

Legend

this

Inherited from

AnchoredShape.addCssClass


addInvalidateHandler

addInvalidateHandler(handler): Legend

Add invalidate handler

Deprecated

since 4.0, use Node.on instead

Parameters

Name Type Description
handlerFunctionhandler to be notified about invalidation

Returns

Legend

this

Inherited from

AnchoredShape.addInvalidateHandler


applyOpacity

Protected applyOpacity(context): Legend

This method is called to apply opacity if it is specified on the rendering context. The default implementation sets global alpha on the rendering context

Parameters

Name Type Description
contextRenderingContextRendering Context

Returns

Legend

this

Inherited from

AnchoredShape.applyOpacity


applyResponsiveStyle

Protected applyResponsiveStyle(): void

Apply a responsive style rules it is exists

Returns

void

Inherited from

AnchoredShape.applyResponsiveStyle


checkCollision

checkCollision(context): boolean

Check if this node is within the area being rendered by the context

Parameters

Name Type Description
contextRenderingContextRendering Context

Returns

boolean

true if object is inside of renderable area

Inherited from

AnchoredShape.checkCollision


clearChildren

Protected clearChildren(disposeChildren?): Legend

Remove all child nodes from this composite group

Parameters

Name Type Description
Optional disposeChildrenbooleanautomatically dispose children. If it is true then method dispose is called for each child.

Returns

Legend

this


clone

clone(): Node

All subclasses should override copyConstructor or provide custom implementation for this method

Returns

Node

clone

Inherited from

AnchoredShape.clone


connectStyle

connectStyle(style, type, callback): Legend

Connects style.

This convenience method subscribes a listener to given style for the specified type.
And automatically un-subscribes listener if node is disposed to prevent memory leaks

Parameters

Name Type Description
styleEventDispatcherconnect style
typestringtype of event or property
callbackAttributeCallback<EventDispatcher>function to be called

Returns

Legend

this

Inherited from

AnchoredShape.connectStyle


copyConstructor

Protected copyConstructor(src, deepCopy?): Legend

Copy constructor function.
Function used as part of the cloning mechanism.
Implementations should copy the given instance state to this instance.

Parameters

Name Type Description
srcAnchoredShapeSource to copy from
Optional deepCopybooleandeep copy

Returns

Legend

this

Inherited from

AnchoredShape.copyConstructor


disconnectStyle

disconnectStyle(style, type, callback): Legend

Disconnect style
This convenience method un-subscribes a listener to given style for the specified type.

Parameters

Name Type Description
styleEventDispatcherconnect style
typestringtype of event or property
callbackAttributeCallback<EventDispatcher>function to be called

Returns

Legend

this

Inherited from

AnchoredShape.disconnectStyle


dispose

dispose(): void

Disposes this node, once disposes a node should not be used anymore.
Clear all listeners, and disconnect styles to avoid memory leaks.
Also aggressively 'cleanup' this node by setting some of its members to null.

Returns

void

Inherited from

AnchoredShape.dispose


enableClipping

enableClipping(doClip): Legend

Enables or disables clipping of this node. If enabled, shapes will not be rendered outside of its bounds.

Parameters

Name Type Description
doClipbooleanenable clipping on this node

Returns

Legend

this


enableEventPropagation

enableEventPropagation(enable): Legend

Enable event propagation from the node hierarchy from bottom to top

This option is similar to DOM Event bubbling, which allows to get any event from child node. By default it is disabled for better performance.

Example

import {Group} from '@int/geotoolkit/scene/Group';
import {Events as SceneEvents} from '@int/geotoolkit/scene/Node';
const parentGroup = new Group()
.setName('ParentGroup')
.enableEventPropagation(true);
const childGroup = new Group()
.setName('ChildGroup');

parentGroup.addChild(childGroup);
parentGroup.on(SceneEvents.Invalidate, (eventName, sender, args) => {
// Got notifications from all children of parent group
});
childGroup.invalidate();

Parameters

Name Type Description
enablebooleanenable

Returns

Legend

this

Inherited from

AnchoredShape.enableEventPropagation


enumerateNodes

enumerateNodes(callback, target?): void

Enumerate children nodes

Parameters

Name Type Description
callbackCallback<Node>callback
Optional targetQueryBuilder<any>target

Returns

void

Implementation of

INodeEnumerable.enumerateNodes


execute

execute(delegate): Legend

Executes delegate and return the result. It allows us to keep all initialization calls in one place,
and we do not need to scroll up or down in IDE to find how and where it was initialized.

Example

// All setters (.setName() for example) returns reference to the this.
// In order to modify inner object like LineStyle or Pattern, to get this object (property) we should call getter to get object reference.
// Then modify it as shown below in Option 1 or you can use execute methods shown in Option 2.
import {Group} from '@int/geotoolkit/scene/Group';
import {Rect} from '@int/geotoolkit/util/Rect';
// Option 1
const group = new Group()
.setName('MyGroup')
.setBounds(new Rect(0, 0, 42, 16))
.enableClipping(true)
.setTag({'type': 'sometype'});

group.getLineStyle().setPattern('pattern');
return group;

// Options 2 ( using execute method )
return group
.execute(function () {
this.getLineStyle()
.setPattern("pattern");
});

Parameters

Name Type Description
delegate(this: Legend) => voidFunction to execute

Returns

Legend

The result if any or this

Inherited from

AnchoredShape.execute

execute<T>(delegate): T

Type parameters

Name
T

Parameters

Name Type
delegate(this: Legend) => T

Returns

T

Inherited from

AnchoredShape.execute


filter

Protected filter(context): boolean

Filter node

Parameters

Name Type Description
contextRenderingContextRendering Context

Returns

boolean

flag filter flag ("true" to render node; "false" otherwise)

Inherited from

AnchoredShape.filter


getAnchor

getAnchor(tr?): Point

Gets the anchor

Parameters

Name Type Description
Optional trTransformationtransformation to transform anchor

Returns

Point

Inherited from

AnchoredShape.getAnchor


getAnchorType

getAnchorType(): AnchorType

Returns the current anchor type.

Returns

AnchorType

current anchor type

Inherited from

AnchoredShape.getAnchorType


getAnchorX

getAnchorX(): number

Return anchored x position

Returns

number

Inherited from

AnchoredShape.getAnchorX


getAnchorY

getAnchorY(): number

Return anchored y position

Returns

number

Inherited from

AnchoredShape.getAnchorY


getAnimationStyle

getAnimationStyle(): AnimationStyle

Return animation style

Returns

AnimationStyle

animationStyle current animation style

Inherited from

AnchoredShape.getAnimationStyle


getAspectRatio

getAspectRatio(): number

Returns aspect ratio of the content of the shape Returns 1

Returns

number

Inherited from

AnchoredShape.getAspectRatio


getAutoSize

getAutoSize(): boolean

Returns auto size flag

Returns

boolean


getBounds

getBounds(): Rect

Return bound in the parent coordinates

Returns

Rect

Inherited from

AnchoredShape.getBounds


getChildren

getChildren(filter?): Iterator<LegendItem>

Return iterator by child nodes

Parameters

Name Type Description
Optional filter(node: Node) => booleana filter function. Returns all nodes if null

Returns

Iterator<LegendItem>


getClassName

getClassName(): string

Returns

string

Inherited from

AnchoredShape.getClassName


getClipStyle

getClipStyle(): ClipStyle

Gets the current clipping style

Returns

ClipStyle

clipping style

Inherited from

AnchoredShape.getClipStyle


getCss

getCss(): CssStyle

Return CSS style

Returns

CssStyle

Inherited from

AnchoredShape.getCss


getCssClass

getCssClass(): string

Returns css class name to be used to apply CSS style

Returns

string

the css class name

Inherited from

AnchoredShape.getCssClass


getCssClasses

getCssClasses(): string[]

Gets list of css class names which applied to this node

Returns

string[]

Inherited from

AnchoredShape.getCssClasses


getCssTransform

getCssTransform(): string

Returns CSS transformation

Returns

string

Inherited from

AnchoredShape.getCssTransform


getData

getData(): Collection<LegendItem | ShapeLegendAdapter>

Return the collection to be displayed

Returns

Collection<LegendItem | ShapeLegendAdapter>

a collection of items to be displayed


getDesiredHeight

getDesiredHeight(): string | number

Returns desired height of the group as a layoutable object This method is a helper method to get access to getLayoutStyle()

Returns

string | number

desired height ("undefined" by default)


getDesiredWidth

getDesiredWidth(): string | number

Returns desired width of the group as a layoutable object. This method is a helper method to get access to getLayoutStyle()

Returns

string | number

desired width ("undefined" by default)


getFillStyle

getFillStyle(): FillStyle

Return fill style

Returns

FillStyle

fillStyle current fill style

Inherited from

AnchoredShape.getFillStyle


getHeight

getHeight(): number

Return height of the shape

Returns

number

Inherited from

AnchoredShape.getHeight


getId

getId(): string | number

Returns the associated identifier of the node

Returns

string | number

The node's id

Inherited from

AnchoredShape.getId


getInvalidateMethod

Protected getInvalidateMethod(): AttributeCallback<EventDispatcher>

Gets invalidate method

Returns

AttributeCallback<EventDispatcher>

method to invalidate this object

Inherited from

AnchoredShape.getInvalidateMethod


getIsPointingUp

getIsPointingUp(): boolean

Returns true if the shape is always pointing up

Returns

boolean

true if the shape is always pointing up

Inherited from

AnchoredShape.getIsPointingUp


getLayout

getLayout(): Layout

Returns layout associated with the group

Returns

Layout

layout


getLayoutStyle

getLayoutStyle(): LayoutStyle<string | number>

Return desired layout style

Returns

LayoutStyle<string | number>

Inherited from

AnchoredShape.getLayoutStyle


getLegendDeviceSize

getLegendDeviceSize(legendToDevice): Rect

Return device area occupied by legend shape

Parameters

Name Type Description
legendToDeviceTransformationtransformation of the unit rectangle [0,0,1,1] to device

Returns

Rect


getLineStyle

getLineStyle(): LineStyle

Return line style

Returns

LineStyle

lineStyle current line style

Inherited from

AnchoredShape.getLineStyle


getLocalTransform

getLocalTransform(): Transformation

Retrieves the transformation of bounds to parent

Returns

Transformation

transform the local transform.

Inherited from

AnchoredShape.getLocalTransform


getMarginsStyle

getMarginsStyle(): SpaceStyle<string | number>

Return margins style

Returns

SpaceStyle<string | number>

Inherited from

AnchoredShape.getMarginsStyle


getMaxSize

getMaxSize(): Dimension

returns the maximum device space rendering dimension only works when setUseMinMaxSize is enabled.

Returns

Dimension

max size

Inherited from

AnchoredShape.getMaxSize


getMinSize

getMinSize(): Dimension

returns the minimum device space rendering dimension only works when setUseMinMaxSize is enabled.

Returns

Dimension

min size

Inherited from

AnchoredShape.getMinSize


getModelLimits

getModelLimits(): Rect

Gets model limits, the limits of this groups inside space

Returns

Rect

the current model limits


getName

getName(): string

Returns the node name

Returns

string

The node name

Inherited from

AnchoredShape.getName


getOpacity

getOpacity(): number

Returns current node opacity

Returns

number

opacity

Inherited from

AnchoredShape.getOpacity


getOpacityBlendMode

getOpacityBlendMode(): BlendMode

Returns current node opacity

Returns

BlendMode

opacity blend mode

Inherited from

AnchoredShape.getOpacityBlendMode


getPaddingStyle

getPaddingStyle(): SpaceStyle<string | number>

Return padding style

Returns

SpaceStyle<string | number>

padding


getParent

getParent(): Node

Return parent node

Returns

Node

parent node

Inherited from

AnchoredShape.getParent


getPreserveAspectRatio

getPreserveAspectRatio(): boolean

Returns true if aspect ratio is preserved

Returns

boolean

true if aspect ratio is preserved

Inherited from

AnchoredShape.getPreserveAspectRatio


getPreserveReadingOrientation

getPreserveReadingOrientation(): boolean

Returns true if the shape is always in a readable orientation

Returns

boolean

true if the shape is always in a readable orientation

Inherited from

AnchoredShape.getPreserveReadingOrientation


getPreserveRightAngle

getPreserveRightAngle(): boolean

Returns true if right angles are preserved

Returns

boolean

true if right angles are preserved

Inherited from

AnchoredShape.getPreserveRightAngle


getProperties

getProperties(): OptionsOut

Gets all the properties pertaining to this object

Returns

OptionsOut

object containing the properties

Overrides

AnchoredShape.getProperties


getProperty

getProperty(name): any

Gets dynamic property by name. These properties can be used as a property bags

Parameters

Name Type Description
namestringproperty name

Returns

any

Inherited from

AnchoredShape.getProperty


getPropertyKeys

getPropertyKeys(): string[]

Returns known properties keys

Returns

string[]

Inherited from

AnchoredShape.getPropertyKeys


getRenderingFilter

getRenderingFilter(): IFilter

Return filter to be used for rendering and picking

Returns

IFilter

current filter

Inherited from

AnchoredShape.getRenderingFilter


getResponsiveStyle

getResponsiveStyle(): ResponsiveStyle

Return responsive style

Returns

ResponsiveStyle

Inherited from

AnchoredShape.getResponsiveStyle


getRoot

getRoot(): Node

Returns root node.
If node doesn't have parent then it returns itself.

Returns

Node

the root node

Inherited from

AnchoredShape.getRoot


getRotationAngle

getRotationAngle(): number

Returns rotation angle (in radians)

Returns

number

rotationAngle rotation angle at anchor

Inherited from

AnchoredShape.getRotationAngle


getScaleScrollStrategy

getScaleScrollStrategy(): Delegate

Gets scale scroll strategy

Returns

Delegate

scale scroll strategy

Inherited from

AnchoredShape.getScaleScrollStrategy


getSceneTransform

getSceneTransform(): Transformation

Returns transformation from node to root scene

Returns

Transformation

a transformation from node to root scene

Inherited from

AnchoredShape.getSceneTransform


getSize

getSize(): Dimension

Returns the size as a dimension object.

Returns

Dimension

size

Inherited from

AnchoredShape.getSize


getSizeIsInDeviceSpace

getSizeIsInDeviceSpace(): boolean

Returns true if the shape size is set in device space

Returns

boolean

true if size is defined in device space

Inherited from

AnchoredShape.getSizeIsInDeviceSpace


getTag

getTag(): any

Returns the object associated with the node by user.

Returns

any

The node's user-object

Inherited from

AnchoredShape.getTag


getUseMinMaxSize

getUseMinMaxSize(): boolean

true if using the min max device space sizes

Returns

boolean

true if using the min max device space sizes

Inherited from

AnchoredShape.getUseMinMaxSize


getVisible

getVisible(): boolean

Return visibility of the node

Returns

boolean

true if node is visible

Inherited from

AnchoredShape.getVisible


getWidth

getWidth(): number

Return width of the shape

Returns

number

Inherited from

AnchoredShape.getWidth


getWorldTransform

getWorldTransform(): Transformation

Retrieves the local transformation of the node which represents multiplication of parent to bounds and contents transformations.

Returns

Transformation

transform the world transform.

Inherited from

AnchoredShape.getWorldTransform


getZIndex

getZIndex(): number

Returns node z-index (null if not set)

Returns

number

Inherited from

AnchoredShape.getZIndex


hasCssClass

hasCssClass(cssClass): boolean

Check if node has specified css class

Parameters

Name Type Description
cssClassstringcss class name

Returns

boolean

Inherited from

AnchoredShape.hasCssClass


hasEventListener

hasEventListener(type, callback?): boolean

Check if a list of event listeners for this type contains this listener

Parameters

Name Type Description
typestringtype of event or property
Optional callbackFunctionto be called, if null, check if any callback is registered

Returns

boolean

Inherited from

AnchoredShape.hasEventListener


invalidate

invalidate(bounds?, force?): Legend

Invalidate area of the shape. This method invalidates parent by default. invalidated from parent to root node.

Parameters

Name Type Description
Optional boundsRectbounds of the invalid rectangle in the inner node coordinates
Optional forcebooleantrue if parent should be invalidated immediately if null is provided then cache (if any will be completely refreshed) otherwise only specified rect or node.bounds will be refreshed

Returns

Legend

this

Inherited from

AnchoredShape.invalidate


invalidateParent

invalidateParent(bounds?, force?): Legend

Invalidate bounds

Parameters

Name Type Description
Optional boundsRectif null is provided then cache (if any will be completely refreshed) otherwise only specified rect or node.bounds will be refreshed
Optional forcebooleanflag indicating if the parent must be forcibly invalidated

Returns

Legend

this

Inherited from

AnchoredShape.invalidateParent


isClippingEnabled

isClippingEnabled(): boolean

Returns if clipping is enabled or not for this node.

Returns

boolean


isDisposed

isDisposed(): boolean

Returns whether this object has been disposed

Returns

boolean

Inherited from

AnchoredShape.isDisposed


isEventPropagationEnabled

isEventPropagationEnabled(): boolean

Return true if event propagation is enabled from child to parent

Returns

boolean

Inherited from

AnchoredShape.isEventPropagationEnabled


isNotificationEnabled

isNotificationEnabled(): boolean

return state of notification

Returns

boolean

current notification state

Inherited from

AnchoredShape.isNotificationEnabled


isSelectable

isSelectable(): boolean

Returns true if node can be picked/selected.

Returns

boolean

The selectable flag

Inherited from

AnchoredShape.isSelectable


isSilent

isSilent(): boolean

Return true if the event dispatcher doesn't notify any events

Returns

boolean

Inherited from

AnchoredShape.isSilent


notify

notify<E>(type, source, args?): Legend

Notify listeners of the Node

Type parameters

NameType
Eextends string

Parameters

Name Type Description
typeEtype of event
sourceLegendsource who called the event
Optional argsEventMap[E]event arguments

Returns

Legend

this

Overrides

AnchoredShape.notify


off

off<E>(type?, callback?): Legend

Detach listener on event. Calling .off() with no arguments removes all attached listeners. Calling .off(type) with no callback removes all attached listeners for specific type.

Type parameters

NameType
Eextends string

Parameters

Name Type Description
Optional typeEtype of the event
Optional callback(eventType: E, sender: Legend, args: EventMap[E]) => voidfunction to be called

Returns

Legend

this

Overrides

AnchoredShape.off


on

on<E>(type, callback): Legend

Attach listener on event that will be called whenever the specified event is delivered to the target

If the callback function is already in the list of event listeners for this target, the function is not added a second time.

If a particular anonymous function is in the list of event listeners registered for a certain target, and then later in the code, an identical anonymous function is given in an "on" call, the second function will also be added to the list of event listeners for that target.

Type parameters

NameType
Eextends string

Parameters

Name Type Description
typeEtype of event or property
callback(eventType: E, sender: Legend, args: EventMap[E]) => voidto be called

Returns

Legend

this

Overrides

AnchoredShape.on


onParentChanged

Protected onParentChanged(node): Legend

This method is called when parent changes. Do not call it directly.

Parameters

Name Type Description
nodeNodenode to change parent

Returns

Legend

this

Inherited from

AnchoredShape.onParentChanged


onVisibilityChanged

Protected onVisibilityChanged(): void

This method is called if visibility is changed. Send event Events.VisibilityChanged

Returns

void

Inherited from

AnchoredShape.onVisibilityChanged


postRendering

Protected postRendering(context): void

To be called after rendering. Call this method if you override method render

Parameters

Name Type Description
contextRenderingContextRendering Context

Returns

void

Inherited from

AnchoredShape.postRendering


preRendering

Protected preRendering(context): void

Occurs before rendering this method sets clipping by default. Call this method if you override method render

Parameters

Name Type Description
contextRenderingContextRendering Context

Returns

void

Inherited from

AnchoredShape.preRendering


registerAnimationStyle

registerAnimationStyle(root): void

Register animation style.

Parameters

Name Type Description
rootNoderoot node for node

Returns

void

Inherited from

AnchoredShape.registerAnimationStyle


removeChild

Protected removeChild(node): Legend

Remove child node

Parameters

Name Type Description
nodeLegendItem | LegendItem[]node or array of nodes to be removed

Returns

Legend

this


removeCssClass

removeCssClass(cssclass): Legend

Removes css class from node

Parameters

Name Type Description
cssclassstring | string[]css class name('s)

Returns

Legend

this

Inherited from

AnchoredShape.removeCssClass


removeInvalidateHandler

removeInvalidateHandler(handler): Legend

Remove invalidate handler

Deprecated

since 4.0, use Node.off instead

Parameters

Name Type Description
handlerFunctionhandler to be notified about invalidation

Returns

Legend

this

Inherited from

AnchoredShape.removeInvalidateHandler


render

render(context): void

Renders node

Parameters

Name Type Description
contextRenderingContextThe rendering context to be used to draw the node

Returns

void

Overrides

AnchoredShape.render


renderAsync

renderAsync(context, callback): void

Render node in asynchronous mode. Default implementation creates call method "render" inside

Parameters

Name Type Description
contextRenderingContextThe rendering context to be used to draw the node
callback() => voidcallback function

Returns

void

Inherited from

AnchoredShape.renderAsync


rotate

rotate(theta, x?, y?): Legend

Rotate bounds around a given coordinate or anchor point

Parameters

Name Type Description
thetanumberangle to rotate node, in radians
Optional xnumberx coordinate to rotate around, use anchor-x if not specified
Optional ynumbery coordinate to rotate around, use anchor-y if not specified

Returns

Legend

this

Inherited from

AnchoredShape.rotate


scale

scale(xx, yy): Legend

Scale node

Parameters

Name Type Description
xxnumberx scale factor
yynumbery scale factor

Returns

Legend

this

Inherited from

AnchoredShape.scale


setAnchor

setAnchor(p): Legend

Sets anchor point to given position

Parameters

Name Type Description
pPointpoint

Returns

Legend

this

Inherited from

AnchoredShape.setAnchor

setAnchor(x, y): Legend

Sets anchor point to given position

Parameters

Name Type Description
xnumberx coordinate
ynumbery coordinate

Returns

Legend

this

Inherited from

AnchoredShape.setAnchor


setAnchorType

setAnchorType(alignment): Legend

Sets the anchor type.

Parameters

Name Type Description
alignmentAnchorTypeanchor alignment

Returns

Legend

this

Inherited from

AnchoredShape.setAnchorType


setAnchorX

setAnchorX(ax): Legend

Sets x anchor position

Parameters

Name Type Description
axnumberanchor x position

Returns

Legend

this

Inherited from

AnchoredShape.setAnchorX


setAnchorY

setAnchorY(ay): Legend

Sets y anchor position

Parameters

Name Type Description
aynumberanchor x position

Returns

Legend

this

Inherited from

AnchoredShape.setAnchorY


setAnimationStyle

setAnimationStyle(animationStyle): Legend

Sets animation style

Parameters

Name Type Description
animationStyleTypeanimation style

Returns

Legend

Inherited from

AnchoredShape.setAnimationStyle


setAutoSize

setAutoSize(autoSize): Legend

Set auto size flag

Parameters

Name Type
autoSizeboolean

Returns

Legend


setBounds

setBounds(bounds): Legend

Sets bounds of the node in the parent coordinates. This method takes anchor position and width and height if size is not in device space

Parameters

Name Type Description
boundsRectbound of the node in the parent coordinates

Returns

Legend

this

Overrides

AnchoredShape.setBounds


setClipStyle

setClipStyle(style): Legend

Sets a new clipping style

Parameters

Name Type Description
styleGraphicsPath | ClipStyle | Optionsa new clipping style

Returns

Legend

this

Inherited from

AnchoredShape.setClipStyle


setCss

setCss(style, merge?): Legend

Sets CSS style. This style will be applied for all inserted elements

Parameters

Name Type Description
styleTypeCSS style to be applied to inserted elements
Optional mergebooleanmerge flag

Returns

Legend

this

Inherited from

AnchoredShape.setCss


setCssClass

setCssClass(name): Legend

Sets css class name of the node to be used to apply CSS style

Parameters

Name Type Description
namestringcss class name of the node

Returns

Legend

this

Inherited from

AnchoredShape.setCssClass


setCssTransform

setCssTransform(transform): Legend

Set CSS transformation

Parameters

Name Type Description
transformstring | Transformationtransformation css transformation instruction or Transformation instance

Returns

Legend

this

Inherited from

AnchoredShape.setCssTransform


setDesiredHeight

setDesiredHeight(value): Legend

Sets desired height of the group as a layoutable object

Parameters

Name Type Description
valuestring | numberdesired height to set

Returns

Legend

this


setDesiredWidth

setDesiredWidth(value): Legend

Sets desired width of the group as a layoutable object

Parameters

Name Type Description
valuestring | numberdesired width to set

Returns

Legend

this


setFillStyle

setFillStyle(fillStyle, merge?): Legend

Sets fill style

Parameters

Name Type Description
fillStyleTypea new fill style
Optional mergebooleantrue if you want to merge fillStyle with existing attribute, false by default

Returns

Legend

this

Inherited from

AnchoredShape.setFillStyle


setHeight

setHeight(height): Legend

Sets height of the shape

Parameters

Name Type Description
heightnumberheight of the shape

Returns

Legend

this

Inherited from

AnchoredShape.setHeight


setId

setId(id): Legend

Allows the user to associate any identifier

Parameters

Name Type Description
idstring | numberobject id

Returns

Legend

this

Inherited from

AnchoredShape.setId


setIsPointingUp

setIsPointingUp(isPointingUp): Legend

Sets whether the shape is always pointing up. Particularly useful for text.

Parameters

Name Type Description
isPointingUpbooleanflag setting whether the shape is always pointing up

Returns

Legend

this

Inherited from

AnchoredShape.setIsPointingUp


setLayout

setLayout(layout): Legend

Associate layout with a group.

Parameters

Name Type Description
layoutLayoutlayout to be set

Returns

Legend

this


setLayoutStyle

setLayoutStyle(layoutStyle, merge?): Legend

Specify desired layout style

Parameters

Name Type Description
layoutStyleLayoutStyle<string | number> | Options<string | number>desired layout style
Optional mergebooleantrue if you want to merge layoutStyle with existing attribute, false by default

Returns

Legend

Inherited from

AnchoredShape.setLayoutStyle


setLineStyle

setLineStyle(lineStyle, merge?): Legend

Sets line style

Parameters

Name Type Description
lineStyleTypeline style or options
Optional mergebooleantrue if you want to merge lineStyle with existing attribute, false by default

Returns

Legend

this

Inherited from

AnchoredShape.setLineStyle


setLocalTransform

setLocalTransform(localTransform, force?): Legend

Sets local transformation to be used to transform from local to parent coordinate

Parameters

Name Type Description
localTransformTransformationlocal transformation for this node
Optional forcebooleanboolean flag to force update event if transformations are equal, false by default

Returns

Legend

this

Inherited from

AnchoredShape.setLocalTransform


setMarginsStyle

setMarginsStyle(margins, merge?): Legend

Sets margins style

Parameters

Name Type Description
marginsType<string | number>margins style
Optional mergebooleantrue if you want to merge marginsStyle with existing attribute, false by default

Returns

Legend

this

Inherited from

AnchoredShape.setMarginsStyle


setMaxSize

setMaxSize(maxSize): Legend

sets the maximum device space rendering dimension

Parameters

Name Type Description
maxSizeDimensionmaximum device space rendering dimension

Returns

Legend

Inherited from

AnchoredShape.setMaxSize


setMinSize

setMinSize(minSize): Legend

sets the minimum device space rendering dimension only works when setUseMinMaxSize is enabled.

Parameters

Name Type Description
minSizeDimensionminimum device space rendering dimension

Returns

Legend

this

Inherited from

AnchoredShape.setMinSize


setModelLimits

setModelLimits(limits): Legend

Sets inner model limits for legends' items

Parameters

Name Type Description
limitsRectinner limits

Returns

Legend

this


setName

setName(name): Legend

Sets name of the node

Parameters

Name Type Description
namestringThe node name

Returns

Legend

this

Inherited from

AnchoredShape.setName


setNotification

setNotification(notify, force?): Legend

set notification state

Parameters

Name Type Description
notifybooleanflag set to invalidate parent or not
Optional forcebooleantrue if parent should be invalidated immediately

Returns

Legend

this

Inherited from

AnchoredShape.setNotification


setOpacity

setOpacity(opacity, blendMode?): Legend

Sets node opacity

Parameters

Name Type Description
opacitynumbernode opacity from 0 to 1
Optional blendModeBlendModeopacity blend mode. If it is normal, opacity will be replaced.

Returns

Legend

this

Inherited from

AnchoredShape.setOpacity


setOptions

setOptions(options): Legend

Sets visualization options

Parameters

Name Type Description
optionsOptionsBaseoptions

Returns

Legend

this


setPaddingStyle

setPaddingStyle(paddingStyle, merge?): Legend

Sets padding style. Legend supports only numbers as padding

Parameters

Name Type Description
paddingStyleType<string | number>padding style
Optional mergebooleantrue if you want to merge paddingStyle with existing attribute, false by default

Returns

Legend


setPreserveAspectRatio

setPreserveAspectRatio(preserveAspectRatio): Legend

Sets whether aspect ratio is preserved

Parameters

Name Type Description
preserveAspectRatiobooleanflag Sets whether aspect ratio is preserved

Returns

Legend

this

Inherited from

AnchoredShape.setPreserveAspectRatio


setPreserveReadingOrientation

setPreserveReadingOrientation(preserveReadingOrientation): Legend

Sets whether the shape is always in a readable orientation. Particularly useful for text. Prevents mirror effects

Parameters

Name Type Description
preserveReadingOrientationbooleansets flag whether the shape is always in a readable orientation

Returns

Legend

this

Inherited from

AnchoredShape.setPreserveReadingOrientation


setPreserveRightAngle

setPreserveRightAngle(preserveRightAngle): Legend

Sets whether right angles are preserved

Parameters

Name Type Description
preserveRightAnglebooleanflag setting if right angles are preserved

Returns

Legend

this

Inherited from

AnchoredShape.setPreserveRightAngle


setProperties

setProperties(properties?): Legend

Sets all the properties pertaining to this object

Parameters

Name Type Description
Optional propertiesOptionsobject containing the properties to set

Returns

Legend

this

Overrides

AnchoredShape.setProperties


setProperty

setProperty(name, value): Legend

Sets dynamic property by name

Parameters

Name Type Description
namestringproperty name
valueanyproperty value

Returns

Legend

this

Inherited from

AnchoredShape.setProperty


setRenderingFilter

setRenderingFilter(filter): Legend

Sets filter to be applied before rendering and picking

Parameters

Name Type Description
filterIFilterfilter to set

Returns

Legend

this

Inherited from

AnchoredShape.setRenderingFilter


setResponsiveStyle

setResponsiveStyle(style): Legend

Sets responsive style.

Parameters

Name Type Description
styleOptions | ResponsiveStyleresponsive style

Returns

Legend

this

Inherited from

AnchoredShape.setResponsiveStyle


setRotationAngle

setRotationAngle(rotationAngle): Legend

Set rotation angle

Parameters

Name Type Description
rotationAnglenumberrotation angle (in radians) at anchor

Returns

Legend

this

Inherited from

AnchoredShape.setRotationAngle


setScaleScrollStrategy

setScaleScrollStrategy(strategy?): Legend

Sets scale scroll strategy

Parameters

Name Type Description
Optional strategyDelegatescale scroll strategy

Returns

Legend

this

Inherited from

AnchoredShape.setScaleScrollStrategy


setSelectable

setSelectable(selectable): Legend

Allows to select node. If node is not selectable then child node is not selectable.

Parameters

Name Type Description
selectablebooleanflag to allow node selection

Returns

Legend

this

Inherited from

AnchoredShape.setSelectable


setSilent

setSilent(bool): Legend

Set silent mode

Parameters

Name Type Description
boolbooleanflag to enable silent mode

Returns

Legend

this

Inherited from

AnchoredShape.setSilent


setSize

setSize(width, height?): Legend

Sets size of the shape, will accept a width and height number or a Dimension object.

Parameters

Name Type Description
widthnumber | Dimension | Optionswidth of the shape
Optional heightnumberheight of the shape

Returns

Legend

this

Inherited from

AnchoredShape.setSize


setSizeIsInDeviceSpace

setSizeIsInDeviceSpace(sizeIsInDeviceSpace): Legend

Sets whether the shape size is set in device space.

Parameters

Name Type Description
sizeIsInDeviceSpacebooleantrue if the shape size is fixed in device space; otherwise, false.

Returns

Legend

this

Inherited from

AnchoredShape.setSizeIsInDeviceSpace


setTag

setTag(tag): Legend

Allows the user to associate any arbitrary object with the node.

Parameters

Name Type Description
taganyThe object to be associated with the node.

Returns

Legend

this

Inherited from

AnchoredShape.setTag


setUseMinMaxSize

setUseMinMaxSize(useMinMaxSize): Legend

Sets whether to use the min max device space sizes

Parameters

Name Type Description
useMinMaxSizebooleantrue if using the min max device space sizes otherwise, false.

Returns

Legend

this

Inherited from

AnchoredShape.setUseMinMaxSize


setVisible

setVisible(value): Legend

Sets visibility of the node. Send event Events.VisibilityChanged

Parameters

Name Type Description
valuebooleanflag specifying visibility of the node

Returns

Legend

this

Inherited from

AnchoredShape.setVisible


setWidth

setWidth(width): Legend

Sets width of the shape

Parameters

Name Type Description
widthnumberwidth of the shape

Returns

Legend

this

Inherited from

AnchoredShape.setWidth


setZIndex

setZIndex(value): Legend

Sets z-index for node (set null for default)

Parameters

Name Type Description
valuenumberindex determining node z-position

Returns

Legend

this

Inherited from

AnchoredShape.setZIndex


shear

shear(shx, shy): Legend

Shear this node's bounds

Parameters

Name Type Description
shxnumberx-axis shear
shynumbery-axis shear

Returns

Legend

this

Inherited from

AnchoredShape.shear


toString

toString(): string

Returns a string representation of this object (generally the classname)

Returns

string

A string representation

Inherited from

AnchoredShape.toString


translate

translate(tx, ty): Legend

Translate bounds

Parameters

Name Type Description
txnumberx translation
tynumbery translation

Returns

Legend

this

Inherited from

AnchoredShape.translate


unregisterAnimationStyle

unregisterAnimationStyle(root): void

Unregister animation style.

Parameters

Name Type Description
rootNoderoot node for node

Returns

void

Inherited from

AnchoredShape.unregisterAnimationStyle


updateLayout

updateLayout(targets?): Legend

Updates layout(s)

Parameters

Name Type Description
Optional targetsILayoutable[]optional parameter about which element to layout

Returns

Legend

this


updateSceneTransformation

updateSceneTransformation(): Legend

Update scene transformation

Returns

Legend

this

Inherited from

AnchoredShape.updateSceneTransformation


updateSize

updateSize(): void

Calculate and update size based on legend items

Returns

void


updateState

updateState(regions?, changes?): Legend

Update state. These methods reset node state and update state for children. this method is useful to refresh a scene graph

Parameters

Name Type Description
Optional regionsRect[]optional array to return invalid rectangles in the parent coordinates
Optional changesStateChangesoptional parameter to specify a reason of changes

Returns

Legend

this

Inherited from

AnchoredShape.updateState


updateTimeStamp

Protected updateTimeStamp(): Legend

Update time stamp to indicate that Node or Children has been changed.

Returns

Legend

this

Inherited from

AnchoredShape.updateTimeStamp


enableSceneGraphNotification

Static enableSceneGraphNotification(enabled): void

Enable / disable all notifications

Parameters

Name Type Description
enabledbooleansets if this object sends notifications

Returns

void

Inherited from

AnchoredShape.enableSceneGraphNotification


findParent

Static findParent<T>(node, classType, filter?): InstanceType<T>

Find root of the node with specified type

Type parameters

NameType
Textends Constructor<any>

Parameters

Name Type Description
nodeNodenode to start search
classTypeTtype of the class to search for
Optional filter(node: Node) => booleanadditional filter to apply

Returns

InstanceType<T>

Inherited from

AnchoredShape.findParent

Static findParent(node, classType, filter?): Node

Find root of the node with specified type

Parameters

Name Type Description
nodeNodenode to start search
classTypestringinterface name to search for
Optional filter(node: Node) => booleanadditional filter to apply

Returns

Node

Inherited from

AnchoredShape.findParent


getAnchorPosition

Static getAnchorPosition(rect, anchorType): Point

Return anchor position

Parameters

Name Type Description
rectRectrectangle to get anchor position
anchorTypeAnchorTypeanchor type

Returns

Point

anchor

Inherited from

AnchoredShape.getAnchorPosition


getClassName

Static getClassName(): string

Returns

string

Inherited from

AnchoredShape.getClassName


intersectsBounds

Static intersectsBounds(bounds, localTransformation, parentInvalidArea, expand?): boolean

Check collision of the shape bounds with parent invalid area

Parameters

Name Type Description
boundsRectshape bounds
localTransformationTransformationlocal transformation of the bounds
parentInvalidAreaRectinvalid parent area
Optional expandDimensionoptional expand the bounds in model coordinate

Returns

boolean

true if bounds intersect the invalid area

Inherited from

AnchoredShape.intersectsBounds


isSceneGraphNotificationEnabled

Static isSceneGraphNotificationEnabled(): boolean

Return status of the global notification for all nodes.

Returns

boolean

Inherited from

AnchoredShape.isSceneGraphNotificationEnabled