# Class: Legend

## Legend(parent)

An SVG object used to display contextual information about a panel. Panel layouts determine basic features of a legend - its position in the panel, orientation, title, etc. Layouts of child data layers of the panel determine the actual content of the legend.

## Constructor

#### new Legend(parent)

##### Parameters:

Name | Type | Description
--- | --- | ---
`parent` | Panel |

Source:
  - components/legend.js, line 32

### Members

#### background_rect :d3.selection

##### Type:

- d3.selection

Source:
  - components/legend.js, line 49

#### elements :Array.<d3.selection>

##### Type:

- Array.<d3.selection>

Source:
  - components/legend.js, line 51

#### (protected) elements_group :d3.selection|null

SVG selector for the group containing all elements in the legend

##### Type:

- d3.selection | null

Source:
  - components/legend.js, line 57

#### (protected) hidden :Boolean

TODO: Not sure if this property is used; the external-facing methods are setting `layout.hidden` instead. Tentatively mark deprecated.

##### Type:

- Boolean

Deprecated:
  - Yes
Source:
  - components/legend.js, line 65

#### id :String

##### Type:

- String

Source:
  - components/legend.js, line 40

#### layout :Object

##### Type:

- Object

Source:
  - components/legend.js, line 44

#### parent :Panel

##### Type:

- Panel

Source:
  - components/legend.js, line 38

#### selector :d3.selection

##### Type:

- d3.selection

Source:
  - components/legend.js, line 47

### Methods

#### hide()

Hide the legend (triggers a re-render)

Source:
  - components/legend.js, line 302

#### position() → {Legend|null}

Place the legend in position relative to the panel, as specified in the layout configuration

Source:
  - components/legend.js, line 284

##### Returns:

TODO: should this always be chainable?

Type
  Legend | null

#### render()

Render the legend in the parent panel

Source:
  - components/legend.js, line 73

#### show()

Show the legend (triggers a re-render)

Source:
  - components/legend.js, line 311