Skip to content

Commit ce8bc87

Browse files
committed
[#68] improve empty brush handling
1 parent e0242e4 commit ce8bc87

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

dc.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -970,12 +970,6 @@ dc.coordinateGridChart = function(_chart) {
970970
return _chart;
971971
};
972972

973-
_chart._filter = function(_) {
974-
if (!arguments.length) return _filter;
975-
_filter = _;
976-
return _chart;
977-
};
978-
979973
_chart.filter = function(_) {
980974
if (!arguments.length) return _filter;
981975

@@ -1038,19 +1032,26 @@ dc.coordinateGridChart = function(_chart) {
10381032

10391033
_chart.redrawBrush(_g);
10401034

1041-
dc.events.trigger(function() {
1042-
_chart.filter(_brush.empty() ? null : [extent[0], extent[1]]);
1043-
dc.redrawAll(_chart.chartGroup());
1044-
}, dc.constants.EVENT_DELAY);
1035+
if(_brush.empty()){
1036+
dc.events.trigger(function() {
1037+
_chart.filter(null);
1038+
dc.redrawAll(_chart.chartGroup());
1039+
});
1040+
}else{
1041+
dc.events.trigger(function() {
1042+
_chart.filter([extent[0], extent[1]]);
1043+
dc.redrawAll(_chart.chartGroup());
1044+
}, dc.constants.EVENT_DELAY);
1045+
}
10451046
}
10461047

10471048
function brushEnd(p) {
10481049
}
10491050

10501051
_chart.redrawBrush = function(g) {
10511052
if (_brushOn) {
1052-
if (_chart._filter() && _chart.brush().empty())
1053-
_chart.brush().extent(_chart._filter());
1053+
if (_chart.filter() && _chart.brush().empty())
1054+
_chart.brush().extent(_chart.filter());
10541055

10551056
var gBrush = g.select("g.brush");
10561057
gBrush.call(_chart.brush().x(_chart.x()));

0 commit comments

Comments
 (0)