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:

Direct Known Subclasses

c3.Legend.PlotLegend

Variables Summary

version =
0.2
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

list_item_options =
undefined

[c3.Selection.Options] Options to set the styles and events for the li items in the list.

item_options =
undefined

[c3.Selection.Options] Options to set the text, html, and other styles and events for the content span for items in the list. By default it will display data elements by converting them to a string.

item_option =
undefined

[Function] A callback to get a c3.Selection.Options object for the content span based on a datum as an input parameter

nested_list_item_options =
undefined

[c3.Selection.Options] Options for nested li list items. These will default to list_item_options unless specified.

nested_item_options =
undefined

[c3.Selection.Options] Options for nested content spans for 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 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

_next_uid anchor height width anchor_styles handlers

Instance Method Summary

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:

    Control the navigation frame:

    You can focus and blur the search input: