Skip to content

Commit 4fe90c7

Browse files
committed
[#67] fix filtered listener interaction problem and updated api doc
1 parent fdd92e7 commit 4fe90c7

File tree

6 files changed

+38
-16
lines changed

6 files changed

+38
-16
lines changed

dc.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -652,17 +652,14 @@ dc.baseChart = function(_chart) {
652652
return result;
653653
};
654654

655-
_chart.filter = function(f) {
656-
var result = _chart.doFilter(f);
657-
658-
if(arguments.length) _listeners.filtered(_chart, f);
659-
660-
return result;
655+
_chart.invokeFilteredListener = function(chart, f) {
656+
if(f !== undefined) _listeners.filtered(_chart, f);
661657
};
662658

663659
// abstract function stub
664-
_chart.doFilter = function(f) {
660+
_chart.filter = function(f) {
665661
// do nothing in base, should be overridden by sub-function
662+
_chart.invokeFilteredListener(_chart, f);
666663
return _chart;
667664
};
668665

@@ -1108,6 +1105,8 @@ dc.coordinateGridChart = function (_chart) {
11081105
_chart.turnOffControls();
11091106
}
11101107

1108+
_chart.invokeFilteredListener(_chart, _);
1109+
11111110
return _chart;
11121111
};
11131112

@@ -1404,6 +1403,8 @@ dc.singleSelectionChart = function(_chart) {
14041403
_chart.turnOffControls();
14051404
}
14061405

1406+
_chart.invokeFilteredListener(_chart, _);
1407+
14071408
return _chart;
14081409
};
14091410

dc.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/base-chart.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,14 @@ dc.baseChart = function(_chart) {
185185
return result;
186186
};
187187

188-
_chart.filter = function(f) {
189-
var result = _chart.doFilter(f);
190-
191-
if(arguments.length) _listeners.filtered(_chart, f);
192-
193-
return result;
188+
_chart.invokeFilteredListener = function(chart, f) {
189+
if(f !== undefined) _listeners.filtered(_chart, f);
194190
};
195191

196192
// abstract function stub
197-
_chart.doFilter = function(f) {
193+
_chart.filter = function(f) {
198194
// do nothing in base, should be overridden by sub-function
195+
_chart.invokeFilteredListener(_chart, f);
199196
return _chart;
200197
};
201198

src/coordinate-grid-chart.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ dc.coordinateGridChart = function (_chart) {
368368
_chart.turnOffControls();
369369
}
370370

371+
_chart.invokeFilteredListener(_chart, _);
372+
371373
return _chart;
372374
};
373375

src/single-selection-chart.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ dc.singleSelectionChart = function(_chart) {
1919
_chart.turnOffControls();
2020
}
2121

22+
_chart.invokeFilteredListener(_chart, _);
23+
2224
return _chart;
2325
};
2426

wiki/api.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ The entire dc.js library is scoped under **dc** name space. It does not introduc
1515
* [Geo Choropleth Chart [concrete] < Single Selection Chart < Color Chart < Base Chart](#geo-choropleth-chart)
1616
* [Data Count Widget [concrete] < Base Chart](#data-count)
1717
* [Data Table Widget [concrete] < Base Chart](#data-table)
18+
* [Listeners](#listeners)
1819
* [Utilities](#utilities)
1920

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

797+
## <a name="listeners" href="#listeners">#</a> Listeners
798+
All dc chart instance supports the following listeners.
799+
800+
### .on("preRender", function(chart){...})
801+
This listener function will be invoked before chart rendering.
802+
803+
### .on("postRender", function(chart){...})
804+
This listener function will be invoked after chart finish rendering including all renderlets' logic.
805+
806+
### .on("preRedraw", function(chart){...})
807+
This listener function will be invoked before chart redrawing.
808+
809+
### .on("postRedraw", function(chart){...})
810+
This listener function will be invoked after chart finish redrawing including all renderlets' logic.
811+
812+
### .on("filtered", function(chart, filter){...})
813+
This listener function will be invoked after a filter is applied.
814+
815+
796816
## <a name="utilities" href="#utilities">#</a> Utilities
797817

798818
### dc.renderAll([chartGroup])

0 commit comments

Comments
 (0)