new TextFilterWidget(parent [, chartGroup])
Create Text Filter widget
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 chart instance should be placed in. Interaction with a chart will only trigger events and redraws within the chart's group. |
- Mixes In:
- Source:
Example
var data = [{"firstName":"John","lastName":"Coltrane"}{"firstName":"Miles",lastName:"Davis"}]
var ndx = crossfilter(data);
var dimension = ndx.dimension(function(d) {
return d.lastName.toLowerCase() + ' ' + d.firstName.toLowerCase();
});
new TextFilterWidget('#search')
.dimension(dimension);
// you don't need the group() function
Classes
Methods
-
filterFunctionFactory( [filterFunctionFactory])
-
This function will be called with the search text, it needs to return a function that will be used to filter the data. The default function checks presence of the search text.
Parameters:
Name Type Argument Description filterFunctionFactoryfunction <optional>
- Source:
Returns:
- Type
- TextFilterWidget | function
Example
// This is the default function (query) { query = _normalize(query); return function (d) { return _normalize(d).indexOf(query) !== -1; }; }; -
normalize( [normalize])
-
This function will be called on values before calling the filter function.
Parameters:
Name Type Argument Description normalizefunction <optional>
- Source:
Returns:
- Type
- TextFilterWidget | function
Example
// This is the default chart.normalize(function (s) { return s.toLowerCase(); }); -
placeHolder( [placeHolder])
-
Placeholder text in the search box.
Parameters:
Name Type Argument Default Description placeHolderfunction <optional>
'search' - Source:
Returns:
- Type
- TextFilterWidget | string
Example
// This is the default chart.placeHolder('type to filter');