new SelectMenu(parent [, chartGroup])
Create a Select Menu.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
parent |
String | node | d3.selection | CompositeChart | Any valid d3 single selector specifying a dom block element such as a div; or a dom element or d3 selection. |
|
chartGroup |
String |
<optional> |
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:
Example
// create a select menu under #select-container using the default global chart group var select = new SelectMenu('#select-container') .dimension(states) .group(stateGroup); // the option text can be set via the title() function // by default the option text is '`key`: `value`' select.title(function (d){ return 'STATE: ' + d.key; })
Classes
Methods
-
filterDisplayed( [filterDisplayed])
-
Get or set the function that filters option tags prior to display. By default options with a value of < 1 are not displayed.
Parameters:
Name Type Argument Description filterDisplayed
function <optional>
- Source:
Returns:
- Type
- function | SelectMenu
Example
// display all options override the `filterDisplayed` function: chart.filterDisplayed(function () { return true; });
-
multiple( [multiple])
-
Controls the type of select menu. Setting it to true converts the underlying HTML tag into a multiple select.
Parameters:
Name Type Argument Default Description multiple
boolean <optional>
false - Source:
Returns:
- Type
- boolean | SelectMenu
Example
chart.multiple(true);
-
numberVisible( [numberVisible])
-
Controls the number of items to show in the select menu, when
.multiple()
is true. This controls thesize
attribute of theselect
element. Ifnull
(the default), uses the browser's default height.Parameters:
Name Type Argument Default Description numberVisible
number <optional>
<nullable>
null - Source:
Returns:
- Type
- number | SelectMenu
Example
chart.numberVisible(10);
-
order( [order])
-
Get or set the function that controls the ordering of option tags in the select menu. By default options are ordered by the group key in ascending order.
Parameters:
Name Type Argument Description order
function <optional>
- Source:
Returns:
- Type
- function | SelectMenu
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 <optional>
'Select all' - Source:
Returns:
- Type
- String | SelectMenu
Example
chart.promptText('All states');
-
promptValue( [promptValue])
-
Controls the default value to be used for dimension.filter when 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
* <optional>
<nullable>
null - Source:
Returns:
- Type
- * | SelectMenu