dc.js Class: htmlLegend (original) (raw)

dc. htmlLegend


new htmlLegend()

htmlLegend is a attachable widget that can be added to other dc charts to render horizontal/vertical legend labels.

Source:

Returns:

Type

dc.htmlLegend

Example

chart.legend(dc.htmlLegend().container(legendContainerElement).horizontal(false))

Methods


container( [container])

Set the container selector for the legend widget. Required.

Parameters:
Name Type Argument Description
container String

Source:

Returns:

Type

String|dc.htmlLegend


highlightSelected( [highlightSelected])

This can be optionally used to enable highlighting legends for the selections/filters for the chart.

Parameters:
Name Type Argument Description
highlightSelected String

Source:

Returns:

Type

String|dc.htmlLegend


horizontal( [horizontal])

Display the legend horizontally instead of vertically

Parameters:
Name Type Argument Description
horizontal String

Source:

Returns:

Type

String|dc.htmlLegend


legendItemClass( [legendItemClass])

This can be optionally used to override class for legenditem and just use this class style. This is helpful for overriding the style of a particular chart rather than overriding the style for all charts.

Setting this will disable the highlighting of selected items also.

Parameters:
Name Type Argument Description
legendItemClass String

Source:

Returns:

Type

String|dc.htmlLegend


legendText( [legendText])

Set or get the legend text function. The legend widget uses this function to render the legend text for each item. If no function is specified the legend widget will display the names associated with each group.

Parameters:
Name Type Argument Description
legendText function

Source:

Returns:

Type

function|dc.htmlLegend

Example

// default legendText legend.legendText(dc.pluck('name'))

// create numbered legend items chart.legend(dc.htmlLegend().legendText(function(d, i) { return i + '. ' + d.name; }))

// create legend displaying group counts chart.legend(dc.htmlLegend().legendText(function(d) { return d.name + ': ' d.data; }))


maxItems( [maxItems])

Maximum number of legend items to display

Parameters:
Name Type Argument Description
maxItems Number

Source:

Returns:

Type

dc.htmlLegend