Class: LegendItem

LegendItem

A legendItem is used to add text to a map legend. Individual Features and Plots can be linked to a legendItem, so that the feature or plot color will use the swatchColor of legendItem.

Action and Events

Action Legend Method LegendItem Method Event
Add addItems() - legendItems-add
Update updateItems() update() legendItems-update
Remove removeItems() remove() legendItems-remove
Reorder moveItem() move() legendItems-reorder
Read items() - -

Attributes

Attribute Type Description
name String Name to diplay for legendItem
font String A string describing the font [Default: 'SansSerif, plain, 8']. See Font for details.
fontColor String A string describing the font color [Default: 'black']. See Color for details.
decoration String How the features should be drawn. Choices: 'arc' [Default], 'arrow', 'score', 'none' [Default: 'arc']
swatchColor String A string describing the legendItem display color [Default: 'black']. See Color for details.
minArcLength Number Minimum length in pixels to use when drawing arcs. From 0 to 2 pixels [Default: 1]
drawSwatch Boolean Draw the swatch beside the legendItem name [Default: true]
favorite Boolean LegendItem is a favorite [Default: false]
visible Boolean LegendItem is visible [Default: true]
meta Object Meta data

Examples

new LegendItem(viewer, options, meta)

Create a new legendItem. By default a legendItem will use its parent legend defaultFont, and defaultFontColor.

Name Type Description
viewer Viewer

The viewer

options Object

Attributes used to create the legendItem

meta Object optional

User-defined Meta data to add to the legendItem.

Extends

Members

canvasCanvas

Get the canvas.

decorationString

Get or set the decoration. Choices are arc [Default], arrow, score, none.

drawSwatchBoolean

Get or set the drawSwatch property. If true a swatch will be drawn beside the legendItem text.

fontFont

Get or set the font. When setting the font, a string representing the font or a Font object can be used. For details see Font.

fontColorColor

Get or set the fontColor. When setting the color, a string representing the color or a Color object can be used. For details see Color.

heightNumber

Get the height in pixels. This will be the same as the font size.

layoutLayout

Get the layout.

legendLegend

Get the Legend

metaBoolean

Get or Set the meta data of this object. See the meta data tutorial for details.

minArcLengthNumber

Get or set the minArcLength for legend items. The value must be between 0 to 2 pixels [Default: 1]. Minimum arc length refers to the minimum size (in pixels) an arc will be drawn. At some scales, small features will have an arc length of a fraction of a pixel. In these cases, the arcs are hard to see. A minArcLength of 0 means no adjustments will be made.

nameString

Get or set the name. The name is the text shown for the legendItem. When setting a name, if it's not unique it will be appended with a number. For example, if 'my_name' already exists, it will be changed to 'my_name-2'.

sequenceSequence

Get the sequence.

swatchColorColor

Get or set the swatchColor. When setting the color, a string representing the color or a Color object can be used. For details see Color.

swatchWidthNumber

Get the swatch width (same as legendItem height).

usingDefaultFontBoolean

Returns true if using the default legend font

usingDefaultMinArcLengthBoolean

Returns true if using the default min arc length

viewerViewer

Get the viewer.

visibleBoolean

Get or Set the visibility of this object.

widthNumber

Get the width in pixels.

Methods

inherited deleteFromObjects()

Remove the object from Viewer.objects

Returns the features that have this legendItem

Name Type Description
term Integer | String | Array

See CGArray.get for details.

Returns:
Type Description
Feature | CGArray

highlight(color)

Highlight this legendItem

Name Type Description
color Color

Color for the highlight

invertColors()

Invert the swatch color

move(newIndex)

Move this legendItem to a new index in the array of Legend legendItems.

Name Type Description
newIndex Number

New index for this caption (0-based)

Returns the plots that have this legendItem

Name Type Description
term Integer | String | Array

See CGArray.get for details.

Returns:
Type Description
Feature | CGArray

Remove legendItem

Returns JSON representing the object

toString(){String}

Return the class name as a string.

Returns:
Type Description
String
  • 'LegendItem'

update(attributes)

Update legendItem attributes. See updating records for details.

Name Type Description
attributes Object

Object describing the properties to change