Skip to content

Commit

Permalink
Attempt at non-filtered brushing
Browse files Browse the repository at this point in the history
  • Loading branch information
mtraynham committed Mar 25, 2015
1 parent 80fafeb commit 92ddb48
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/coordinate-grid-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ dc.coordinateGridMixin = function (_chart) {

var _brush = d3.svg.brush();
var _brushOn = true;
var _filterOnBrushEnd = false;
var _round;

var _renderHorizontalGridLine = false;
Expand Down Expand Up @@ -842,7 +843,13 @@ dc.coordinateGridMixin = function (_chart) {

_chart.renderBrush = function (g) {
if (_brushOn) {
_brush.on('brush', _chart._brushing);
if (!_filterOnBrushEnd) {
_brush.on('brush', _chart._brushing);
_brush.on('brushend.filter', null);
} else {
_brush.on('brush', _chart._nonFilteredBrushing);
_brush.on('brushend.filter', _chart._brushing);
}
_brush.on('brushstart', _chart._disableMouseZoom);
_brush.on('brushend', configureMouseZoom);

Expand Down Expand Up @@ -903,6 +910,11 @@ dc.coordinateGridMixin = function (_chart) {
}
};

_chart._nonFilteredBrushing = function () {
_chart.extendBrush();
_chart.redrawBrush(_g);
};

_chart.redrawBrush = function (g) {
if (_brushOn) {
if (_chart.filter() && _chart.brush().empty()) {
Expand Down Expand Up @@ -1131,10 +1143,27 @@ dc.coordinateGridMixin = function (_chart) {
if (!arguments.length) {
return _brushOn;
}
if (_brushOn !== _ && _chart.hasFilter()) {
_chart.filterAll();
}
_brushOn = _;
return _chart;
};

/**
#### .filterOnBrushEnd([boolean])
Allows one to specify when the brush filtering should be performed. If this is false,
filtering happens at every move of the brush. If this is true, filtering occurs when the
brush is dropped. Default: false
*/
_chart.filterOnBrushEnd = function (_) {
if (!arguments.length) {
return _filterOnBrushEnd;
}
_filterOnBrushEnd = _;
return _chart;
};

function hasRangeSelected(range) {
return range instanceof Array && range.length > 1;
}
Expand Down

0 comments on commit 92ddb48

Please sign in to comment.