# Class: c3.Legend

Defined in: | js/c3-legend.coffee
Inherits: | c3.Base

## Overview

A Legend to display a list of items.

It is important to set `item_options.text` or `item_options.html` to define how to display each element in the legend. By default, the data elements will be converted to strings and displayed as raw text. However, you will likely want to set a different accessor callback.

## Styling

The list is created as a `ul` element. The `hoverable` class is applied if appropriate. The `li` elements get the `parent` class if they have children. `li` elements have spans with either the `content` or `bullet` class as appropriate.

### Author:

- Douglas Armstrong

## Direct Known Subclasses

c3.Legend.PlotLegend

## Variables Summary

version =

      0.1

type =

      'legend'

data =

      []

  [Array] An array of data elements for the legend to display

key =

      undefined

  [Function] A callback used to determine a unique identification for each data element. This is useful, for example, with animations when the dataset changes.

filter =

      undefined

  [Function] A callback used to determine if a data element in the `data` array should be displayed. It is passed with a data element as a parameter and should return `true` or `false`. By default, legend items with no text or html defined will be omitted.

nest =

      undefined

  [Boolean, Function] Set to false to disable nested legend items. Set to a function to return an array of nested items based on a data element in `data`. By default it will treat `data` elements that are arrays as nested items.

nest_key =

      undefined

  [Function] A callback used to uniquely identify nested legend items.

hoverable =

      true

  [Boolean] enables hoverable behaviour for the legend such as highlighting when the mouse hovers or with a touch event.

list_options =

      undefined

  [{c3.selection.options}] Options for the legend `ul` as a whole

item_options =

      undefined

  [{c3.selection.options}] Options to set the text, html, and other styles and events for the `li` items in the list. By default it will display data elements by converting them to a string.

nested_item_options =

      undefined

  [{c3.selection.options}] Options for nested `li` list items. These will default to `item_options` unless specified.

bullet_options =

      undefined

  [Boolean, {c3.selection.options}] Set to `false` to disable bullets for legend items. Otherwise it is the {c3.selection.options options} to set the text, html, or other options for the list item bullets.

nested_bullet_options =

      undefined

  [Boolean, {c3.selection.options}] Options for bullets of nested list items. This will default to `bullet_options` unless specified.

### Variable inherited from c3.Base

anchor height width anchor_styles handlers

## Instance Method Summary

- # (void) _init() Bound
- # (void) _update() Bound
- # (void) _style(style_new) Bound

## Inherited Method Summary

### Methods inherited from c3.Base

#render #resize #redraw #restyle #init #_prep #_init #size #_size #update #_update #draw #_draw #style #_style

## Instance Method Details

# (void) _init() Bound

# (void) _update() Bound

# (void) _style(style_new) Bound

Quickly fuzzy find classes, mixins, methods, file:

- T Open fuzzy finder dialog

Control the navigation frame:

- L Toggle list view
- C Show class list
- I Show mixin list
- F Show file list
- M Show method list
- E Show extras list

You can focus and blur the search input:

- S Focus search input
- Esc Blur search input