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

dc. cboxMenu


The cboxMenu is a simple widget designed to filter a dimension by selecting option(s) from a set of HTML <input /> elements. The menu can be made into a set of radio buttons (single select) or checkboxes (multiple).

Parameters:
Name Type Argument Description
parent String|node d3.selection dc.compositeChart
chartGroup String The name of the chart group this widget should be placed in. Interaction with the widget will only trigger events and redraws within its group.

Mixes In:

Source:

Returns:

Type

cboxMenu

Example

// create a cboxMenu under #cbox-container using the default global chart group var cbox = dc.cboxMenu('#cbox-container') .dimension(states) .group(stateGroup); // the option text can be set via the title() function // by default the option text is 'key: value' cbox.title(function (d){ return 'STATE: ' + d.key; })

Methods


filterDisplayed( [filterDisplayed])

Get or set the function that filters options prior to display. By default options with a value of < 1 are not displayed.

Parameters:
Name Type Argument Description
filterDisplayed function

Source:

Returns:

Type

function|dc.cboxMenu

Example

// display all options override the filterDisplayed function: chart.filterDisplayed(function () { return true; });


multiple( [multiple])

Controls the type of input element. Setting it to true converts the HTML input tags from radio buttons to checkboxes.

Parameters:
Name Type Argument Default Description
multiple boolean false

Source:

Returns:

Type

Boolean|dc.cboxMenu

Example

chart.multiple(true);


order( [order])

Get or set the function that controls the ordering of option tags in the cbox menu. By default options are ordered by the group key in ascending order.

Parameters:
Name Type Argument Description
order function

Source:

Returns:

Type

function|dc.cboxMenu

Example

// order by the group's value chart.order(function (a,b) { return a.value > b.value ? 1 : b.value > a.value ? -1 : 0; });


promptText( [promptText])

Get or set the text displayed in the options used to prompt selection.

Parameters:
Name Type Argument Default Description
promptText String 'Select all'

Source:

Returns:

Type

String|dc.cboxMenu

Example

chart.promptText('All states');


promptValue( [promptValue])

Controls the default value to be used fordimension.filterwhen only the prompt value is selected. If null (the default), no filtering will occur when just the prompt is selected.

Parameters:
Name Type Argument Default Description
promptValue * null

Source:

Returns:

Type

*|dc.cboxMenu