Skip to content

Commit

Permalink
[#67] fix filtered listener interaction problem and updated api doc
Browse files Browse the repository at this point in the history
  • Loading branch information
NickQiZhu committed Jan 13, 2013
1 parent fdd92e7 commit 4fe90c7
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 16 deletions.
15 changes: 8 additions & 7 deletions dc.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,17 +652,14 @@ dc.baseChart = function(_chart) {
return result;
};

_chart.filter = function(f) {
var result = _chart.doFilter(f);

if(arguments.length) _listeners.filtered(_chart, f);

return result;
_chart.invokeFilteredListener = function(chart, f) {
if(f !== undefined) _listeners.filtered(_chart, f);
};

// abstract function stub
_chart.doFilter = function(f) {
_chart.filter = function(f) {
// do nothing in base, should be overridden by sub-function
_chart.invokeFilteredListener(_chart, f);
return _chart;
};

Expand Down Expand Up @@ -1108,6 +1105,8 @@ dc.coordinateGridChart = function (_chart) {
_chart.turnOffControls();
}

_chart.invokeFilteredListener(_chart, _);

return _chart;
};

Expand Down Expand Up @@ -1404,6 +1403,8 @@ dc.singleSelectionChart = function(_chart) {
_chart.turnOffControls();
}

_chart.invokeFilteredListener(_chart, _);

return _chart;
};

Expand Down
4 changes: 2 additions & 2 deletions dc.min.js

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions src/base-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,14 @@ dc.baseChart = function(_chart) {
return result;
};

_chart.filter = function(f) {
var result = _chart.doFilter(f);

if(arguments.length) _listeners.filtered(_chart, f);

return result;
_chart.invokeFilteredListener = function(chart, f) {
if(f !== undefined) _listeners.filtered(_chart, f);
};

// abstract function stub
_chart.doFilter = function(f) {
_chart.filter = function(f) {
// do nothing in base, should be overridden by sub-function
_chart.invokeFilteredListener(_chart, f);
return _chart;
};

Expand Down
2 changes: 2 additions & 0 deletions src/coordinate-grid-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ dc.coordinateGridChart = function (_chart) {
_chart.turnOffControls();
}

_chart.invokeFilteredListener(_chart, _);

return _chart;
};

Expand Down
2 changes: 2 additions & 0 deletions src/single-selection-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ dc.singleSelectionChart = function(_chart) {
_chart.turnOffControls();
}

_chart.invokeFilteredListener(_chart, _);

return _chart;
};

Expand Down
20 changes: 20 additions & 0 deletions wiki/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The entire dc.js library is scoped under **dc** name space. It does not introduc
* [Geo Choropleth Chart [concrete] < Single Selection Chart < Color Chart < Base Chart](#geo-choropleth-chart)
* [Data Count Widget [concrete] < Base Chart](#data-count)
* [Data Table Widget [concrete] < Base Chart](#data-table)
* [Listeners](#listeners)
* [Utilities](#utilities)

### Function Chain
Expand Down Expand Up @@ -793,6 +794,25 @@ Get or set sort order. Default value: ``` d3.ascending ```
chart.order(d3.descending);
```

## <a name="listeners" href="#listeners">#</a> Listeners
All dc chart instance supports the following listeners.

### .on("preRender", function(chart){...})
This listener function will be invoked before chart rendering.

### .on("postRender", function(chart){...})
This listener function will be invoked after chart finish rendering including all renderlets' logic.

### .on("preRedraw", function(chart){...})
This listener function will be invoked before chart redrawing.

### .on("postRedraw", function(chart){...})
This listener function will be invoked after chart finish redrawing including all renderlets' logic.

### .on("filtered", function(chart, filter){...})
This listener function will be invoked after a filter is applied.


## <a name="utilities" href="#utilities">#</a> Utilities

### dc.renderAll([chartGroup])
Expand Down

0 comments on commit 4fe90c7

Please sign in to comment.