API Docs for:
Show:

Legend Class

Defined in: src/core/legend.js:14
Module: core
Parent Module: multigraph

Legend is a Jermaine model that supports the rendering of Multigraph Legends.

The methods for this object take a parameter called graphicsContext, which is a driver-specific object that stores whatever state/configuration is needed by the driver. Each driver is responsible for creating its own graphicsContext object and passing it to these methods, which in turn pass that object on to the driver-specific methods that they call.

Constructor

Legend

()

Methods

initializeGeometry

(
  • graph
  • graphicsContext
)
chainable

Initializes the Legend's geometry. Determines values for the internal attributes maxLabelWidth, maxLabelHeight, blockWidth, blockHeight, width, height, x and y; these values determine the size and position of the legend and its various internal components, and need to be recomputed whenever the geometry of the containing graph changes; this method is called by Graph.initializeGeometry().

Parameters:

  • graph Graph

    Jermaine Graph model

  • graphicsContext Object

    driver-specific graphics context object

render

(
  • graphicsContext
)
chainable

Renders the legend; calls various driver-specific graphics functions to do the actual drawing of the various parts of the legend (background, borders, icons, text).

Parameters:

  • graphicsContext Object

    driver-specific graphics context object

Properties

anchor

Point

The value which gives the location of the Legend's anchor point to be attached to the base point.

base

Point

The value which gives the location of the base point relative to the Legend's frame.

blockHeight

Float private final

Computed height of an individual plot entry.

blockWidth

Float private final

Computed width of an individual plot entry.

border

Integer

The value which determines the thickness of the border drawn around the Legend; a value of 0 turns the border off.

bordercolor

RGBColor

The value which determines the bordercolor of the Legend.

color

RGBColor

The value which determines the background color of the Legend.

columns

Integer

The value which determines the number of columns to be used for Plot entries in the Legend. If rows is set while columns is left unspecified then columns will be inserted to account for each Plot entry.

cornerradius

Integer

The value which determines whether the corners of the legend box are rounded when drawn. A value of 0 means that the corners will be drawn square while values greater than 0 mean that the corners are rounded off with circles whose radius in pixels is this value.

frame

String

The value which determines whether the legend is positioned relative to the plot area or the padding box. A value of plot means the Legend will be drawn relative to the plot area while padding means that it will the padding box.

height

Float private final

Computed value of the height of the Legend.

icon

Icon

A optional sub-model which determines the appearance of the Icons for the Plot entries.

iconOffset

Integer private final

Internal value which determines the number of pixels between an entries icon and its border.

Default: 5

labelEnding

Integer private final

Internal value which determines the number of pixels between the right end of an entries label and its border

Default: 15

labelOffset

private final

Internal value which determines the number of pixels between an entries label and its icon.

Default: 5

maxLabelHeight

Float private final

Maximum value of the Icon's height and the computed height of the tallest label of all plot entries.

maxLabelWidth

Float private final

Computed width of the longest label of all plot entries.

opacity

Float

The value which determines the opacity of the Legend; depending on where the Legend is positioned it may obscure parts of the plot data.

padding

Integer

The value which determines the pixel width of the padding between the Legend border and its entries.

plots

Plot

Pointers to Plot models that have entries in the Legend.

position

Point

A coordinate pair of pixel offsets for the base point.

rows

Integer

The value which determines the number of rows to be used for Plot entries in the Legend. If left unspecified then rows will be inserted to account for each Plot entry.

visible

Boolean

The value which determines if the legend will be rendered; a value of true means the Legend will be drawn while false means that it will not.

width

Float private final

Computed value of the width of the Legend.

x

Float private final

Computed x value of the Legend's lower left corner relative to its frame.

y

Float private final

Computed y value of the Legend's lower left corner relative to its frame.