Skip to content

Commit

Permalink
add titles for filter handler functions, and clarify a bit
Browse files Browse the repository at this point in the history
fixes #737
  • Loading branch information
gordonwoodhull committed Nov 29, 2014
1 parent 0a5e877 commit a701c49
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 74 deletions.
43 changes: 28 additions & 15 deletions dc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1177,9 +1177,10 @@ dc.baseMixin = function (_chart) {
};

/**
Set or get the has filter handler. The has filter handler is a function that performs the logical check if the
current chart's filters have a specific filter. Using a custom has filter handler allows you to perform additional
logic upon checking if a filter exists.
#### .hasFilterHandler([function])
Set or get the has filter handler. The has filter handler is a function that checks to see if
the chart's current filters include a specific filter. Using a custom has filter handler allows
you to change the way filters are checked for and replaced.
```js
// default has filter handler
Expand All @@ -1193,7 +1194,7 @@ dc.baseMixin = function (_chart) {
}
// custom filter handler (no-op)
chart.hasFilterHandler(function(filter) {
chart.hasFilterHandler(function(filters, filter) {
return false;
});
```
Expand Down Expand Up @@ -1227,9 +1228,13 @@ dc.baseMixin = function (_chart) {
};

/**
Set or get the remove filter handler. The remove filter handler is a function that performs the removal of a filter
from the chart's current filters. Using a custom remove filter handler allows you to perform additional logic
upon removing a filter. Any changes should modify the `filters` argument reference and return that reference.
#### .removeFilterHandler([function])
Set or get the remove filter handler. The remove filter handler is a function that removes a
filter from the chart's current filters. Using a custom remove filter handler allows you to
change how filters are removed or perform additional work when removing a filter, e.g. when
using a filter server other than crossfilter.
Any changes should modify the `filters` array argument and return that array.
```js
// default remove filter handler
Expand Down Expand Up @@ -1263,9 +1268,13 @@ dc.baseMixin = function (_chart) {
};

/**
Set or get the add filter handler. The add filter handler is a function that performs the addition of a filter
to the charts filter list. Using a custom add filter handler allows you to perform additional logic
upon adding a filter. Any changes should modify the `filters` argument reference and return that reference.
#### .addFilterHandler([function])
Set or get the add filter handler. The add filter handler is a function that adds a filter to
the chart's filter list. Using a custom add filter handler allows you to change the way filters
are added or perform additional work when adding a filter, e.g. when using a filter server other
than crossfilter.
Any changes should modify the `filters` array argument and return that array.
```js
// default add filter handler
Expand All @@ -1288,14 +1297,18 @@ dc.baseMixin = function (_chart) {
return _chart;
};

var _resetFilterHandler = function () {
var _resetFilterHandler = function (filters) {
return [];
};

/**
Set or get the reset filter handler. The reset filter handler is a function that performs the reset of the filters
list by returning the new list. Using a custom reset filter handler allows you to perform additional logic
upon reseting the filters. This function should return an array.
#### .resetFilterHandler([function])
Set or get the reset filter handler. The reset filter handler is a function that resets the
chart's filter list by returning a new list. Using a custom reset filter handler allows you to
change the way filters are reset, or perform additional work when resetting the filters,
e.g. when using a filter server other than crossfilter.
This function should return an array.
```js
// default remove filter handler
Expand All @@ -1304,7 +1317,7 @@ dc.baseMixin = function (_chart) {
}
// custom filter handler (no-op)
chart.addFilterHandler(function(filters) {
chart.resetFilterHandler(function(filters) {
return filters;
});
```
Expand Down
2 changes: 1 addition & 1 deletion dc.min.js.map

Large diffs are not rendered by default.

43 changes: 28 additions & 15 deletions src/base-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,10 @@ dc.baseMixin = function (_chart) {
};

/**
Set or get the has filter handler. The has filter handler is a function that performs the logical check if the
current chart's filters have a specific filter. Using a custom has filter handler allows you to perform additional
logic upon checking if a filter exists.
#### .hasFilterHandler([function])
Set or get the has filter handler. The has filter handler is a function that checks to see if
the chart's current filters include a specific filter. Using a custom has filter handler allows
you to change the way filters are checked for and replaced.
```js
// default has filter handler
Expand All @@ -557,7 +558,7 @@ dc.baseMixin = function (_chart) {
}
// custom filter handler (no-op)
chart.hasFilterHandler(function(filter) {
chart.hasFilterHandler(function(filters, filter) {
return false;
});
```
Expand Down Expand Up @@ -591,9 +592,13 @@ dc.baseMixin = function (_chart) {
};

/**
Set or get the remove filter handler. The remove filter handler is a function that performs the removal of a filter
from the chart's current filters. Using a custom remove filter handler allows you to perform additional logic
upon removing a filter. Any changes should modify the `filters` argument reference and return that reference.
#### .removeFilterHandler([function])
Set or get the remove filter handler. The remove filter handler is a function that removes a
filter from the chart's current filters. Using a custom remove filter handler allows you to
change how filters are removed or perform additional work when removing a filter, e.g. when
using a filter server other than crossfilter.
Any changes should modify the `filters` array argument and return that array.
```js
// default remove filter handler
Expand Down Expand Up @@ -627,9 +632,13 @@ dc.baseMixin = function (_chart) {
};

/**
Set or get the add filter handler. The add filter handler is a function that performs the addition of a filter
to the charts filter list. Using a custom add filter handler allows you to perform additional logic
upon adding a filter. Any changes should modify the `filters` argument reference and return that reference.
#### .addFilterHandler([function])
Set or get the add filter handler. The add filter handler is a function that adds a filter to
the chart's filter list. Using a custom add filter handler allows you to change the way filters
are added or perform additional work when adding a filter, e.g. when using a filter server other
than crossfilter.
Any changes should modify the `filters` array argument and return that array.
```js
// default add filter handler
Expand All @@ -652,14 +661,18 @@ dc.baseMixin = function (_chart) {
return _chart;
};

var _resetFilterHandler = function () {
var _resetFilterHandler = function (filters) {
return [];
};

/**
Set or get the reset filter handler. The reset filter handler is a function that performs the reset of the filters
list by returning the new list. Using a custom reset filter handler allows you to perform additional logic
upon reseting the filters. This function should return an array.
#### .resetFilterHandler([function])
Set or get the reset filter handler. The reset filter handler is a function that resets the
chart's filter list by returning a new list. Using a custom reset filter handler allows you to
change the way filters are reset, or perform additional work when resetting the filters,
e.g. when using a filter server other than crossfilter.
This function should return an array.
```js
// default remove filter handler
Expand All @@ -668,7 +681,7 @@ dc.baseMixin = function (_chart) {
}
// custom filter handler (no-op)
chart.addFilterHandler(function(filters) {
chart.resetFilterHandler(function(filters) {
return filters;
});
```
Expand Down
41 changes: 27 additions & 14 deletions web/docs/api-latest.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,10 @@ events (in particular [dc.redrawAll](#dcredrawallchartgroup)); therefore, you on
manually invoke this function if data is manipulated outside of dc's control (for example if
data is loaded in the background using `crossfilter.add()`).
Set or get the has filter handler. The has filter handler is a function that performs the logical check if the
current chart's filters have a specific filter. Using a custom has filter handler allows you to perform additional
logic upon checking if a filter exists.
#### .hasFilterHandler([function])
Set or get the has filter handler. The has filter handler is a function that checks to see if
the chart's current filters include a specific filter. Using a custom has filter handler allows
you to change the way filters are checked for and replaced.
```js
// default has filter handler
Expand All @@ -313,7 +314,7 @@ function (filters, filter) {
}

// custom filter handler (no-op)
chart.hasFilterHandler(function(filter) {
chart.hasFilterHandler(function(filters, filter) {
return false;
});
```
Expand All @@ -322,9 +323,13 @@ chart.hasFilterHandler(function(filter) {
Check whether any active filter or a specific filter is associated with particular chart instance.
This function is **not chainable**.
Set or get the remove filter handler. The remove filter handler is a function that performs the removal of a filter
from the chart's current filters. Using a custom remove filter handler allows you to perform additional logic
upon removing a filter. Any changes should modify the `filters` argument reference and return that reference.
#### .removeFilterHandler([function])
Set or get the remove filter handler. The remove filter handler is a function that removes a
filter from the chart's current filters. Using a custom remove filter handler allows you to
change how filters are removed or perform additional work when removing a filter, e.g. when
using a filter server other than crossfilter.
Any changes should modify the `filters` array argument and return that array.
```js
// default remove filter handler
Expand All @@ -344,9 +349,13 @@ chart.removeFilterHandler(function(filters, filter) {
});
```
Set or get the add filter handler. The add filter handler is a function that performs the addition of a filter
to the charts filter list. Using a custom add filter handler allows you to perform additional logic
upon adding a filter. Any changes should modify the `filters` argument reference and return that reference.
#### .addFilterHandler([function])
Set or get the add filter handler. The add filter handler is a function that adds a filter to
the chart's filter list. Using a custom add filter handler allows you to change the way filters
are added or perform additional work when adding a filter, e.g. when using a filter server other
than crossfilter.
Any changes should modify the `filters` array argument and return that array.
```js
// default add filter handler
Expand All @@ -361,9 +370,13 @@ chart.addFilterHandler(function(filters, filter) {
});
```
Set or get the reset filter handler. The reset filter handler is a function that performs the reset of the filters
list by returning the new list. Using a custom reset filter handler allows you to perform additional logic
upon reseting the filters. This function should return an array.
#### .resetFilterHandler([function])
Set or get the reset filter handler. The reset filter handler is a function that resets the
chart's filter list by returning a new list. Using a custom reset filter handler allows you to
change the way filters are reset, or perform additional work when resetting the filters,
e.g. when using a filter server other than crossfilter.
This function should return an array.
```js
// default remove filter handler
Expand All @@ -372,7 +385,7 @@ function (filters) {
}

// custom filter handler (no-op)
chart.addFilterHandler(function(filters) {
chart.resetFilterHandler(function(filters) {
return filters;
});
```
Expand Down
38 changes: 24 additions & 14 deletions web/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,10 @@ <h4 id="-redraw-">.redraw()</h4>
events (in particular <a href="#dcredrawallchartgroup">dc.redrawAll</a>); therefore, you only need to
manually invoke this function if data is manipulated outside of dc&#39;s control (for example if
data is loaded in the background using <code>crossfilter.add()</code>).</p>
<p>Set or get the has filter handler. The has filter handler is a function that performs the logical check if the
current chart&#39;s filters have a specific filter. Using a custom has filter handler allows you to perform additional
logic upon checking if a filter exists.</p>
<h4 id="-hasfilterhandler-function-">.hasFilterHandler([function])</h4>
<p>Set or get the has filter handler. The has filter handler is a function that checks to see if
the chart&#39;s current filters include a specific filter. Using a custom has filter handler allows
you to change the way filters are checked for and replaced.</p>
<pre><code class="lang-js"><span class="comment">// default has filter handler</span>
<span class="function"><span class="keyword">function</span> <span class="params">(filters, filter)</span> {</span>
<span class="keyword">if</span> (filter === <span class="literal">null</span> || <span class="keyword">typeof</span>(filter) === <span class="string">'undefined'</span>) {
Expand All @@ -357,15 +358,18 @@ <h4 id="-redraw-">.redraw()</h4>
}

<span class="comment">// custom filter handler (no-op)</span>
chart.hasFilterHandler(<span class="keyword">function</span>(filter) {
chart.hasFilterHandler(<span class="keyword">function</span>(filters, filter) {
<span class="keyword">return</span> <span class="literal">false</span>;
});</code></pre>
<h4 id="-hasfilter-filter-">.hasFilter([filter])</h4>
<p>Check whether any active filter or a specific filter is associated with particular chart instance.
This function is <strong>not chainable</strong>.</p>
<p>Set or get the remove filter handler. The remove filter handler is a function that performs the removal of a filter
from the chart&#39;s current filters. Using a custom remove filter handler allows you to perform additional logic
upon removing a filter. Any changes should modify the <code>filters</code> argument reference and return that reference.</p>
<h4 id="-removefilterhandler-function-">.removeFilterHandler([function])</h4>
<p>Set or get the remove filter handler. The remove filter handler is a function that removes a
filter from the chart&#39;s current filters. Using a custom remove filter handler allows you to
change how filters are removed or perform additional work when removing a filter, e.g. when
using a filter server other than crossfilter.</p>
<p>Any changes should modify the <code>filters</code> array argument and return that array.</p>
<pre><code class="lang-js"><span class="comment">// default remove filter handler</span>
<span class="function"><span class="keyword">function</span> <span class="params">(filters, filter)</span> {</span>
<span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; filters.length; i++) {
Expand All @@ -381,9 +385,12 @@ <h4 id="-hasfilter-filter-">.hasFilter([filter])</h4>
chart.removeFilterHandler(<span class="keyword">function</span>(filters, filter) {
<span class="keyword">return</span> filters;
});</code></pre>
<p>Set or get the add filter handler. The add filter handler is a function that performs the addition of a filter
to the charts filter list. Using a custom add filter handler allows you to perform additional logic
upon adding a filter. Any changes should modify the <code>filters</code> argument reference and return that reference.</p>
<h4 id="-addfilterhandler-function-">.addFilterHandler([function])</h4>
<p>Set or get the add filter handler. The add filter handler is a function that adds a filter to
the chart&#39;s filter list. Using a custom add filter handler allows you to change the way filters
are added or perform additional work when adding a filter, e.g. when using a filter server other
than crossfilter.</p>
<p>Any changes should modify the <code>filters</code> array argument and return that array.</p>
<pre><code class="lang-js"><span class="comment">// default add filter handler</span>
<span class="function"><span class="keyword">function</span> <span class="params">(filters, filter)</span> <span class="comment">{
filters.push(filter);
Expand All @@ -394,16 +401,19 @@ <h4 id="-hasfilter-filter-">.hasFilter([filter])</h4>
<span class="title">chart</span>.<span class="title">addFilterHandler</span><span class="params">(<span class="keyword">function</span>(filters, filter)</span> <span class="comment">{
return filters;
}</span>);</span></code></pre>
<p>Set or get the reset filter handler. The reset filter handler is a function that performs the reset of the filters
list by returning the new list. Using a custom reset filter handler allows you to perform additional logic
upon reseting the filters. This function should return an array.</p>
<h4 id="-resetfilterhandler-function-">.resetFilterHandler([function])</h4>
<p>Set or get the reset filter handler. The reset filter handler is a function that resets the
chart&#39;s filter list by returning a new list. Using a custom reset filter handler allows you to
change the way filters are reset, or perform additional work when resetting the filters,
e.g. when using a filter server other than crossfilter.</p>
<p>This function should return an array.</p>
<pre><code class="lang-js"><span class="comment">// default remove filter handler</span>
<span class="function"><span class="keyword">function</span> <span class="params">(filters)</span> <span class="comment">{
return [];
}</span>

// <span class="title">custom</span> <span class="title">filter</span> <span class="title">handler</span> <span class="params">(no-op)</span>
<span class="title">chart</span>.<span class="title">addFilterHandler</span><span class="params">(<span class="keyword">function</span>(filters)</span> <span class="comment">{
<span class="title">chart</span>.<span class="title">resetFilterHandler</span><span class="params">(<span class="keyword">function</span>(filters)</span> <span class="comment">{
return filters;
}</span>);</span></code></pre>
<h4 id="-filter-filtervalue-">.filter([filterValue])</h4>
Expand Down
Loading

0 comments on commit a701c49

Please sign in to comment.