Skip to content

Commit

Permalink
tag the custom filters and use filterRange
Browse files Browse the repository at this point in the history
fixes #478
helps #819
  • Loading branch information
gordonwoodhull committed Sep 18, 2015
1 parent 4d62f65 commit 9b2b007
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/base-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ dc.baseMixin = function (_chart) {
} else if (filters.length === 1 && !filters[0].isFiltered) {
// single value and not a function-based filter
dimension.filterExact(filters[0]);
} else if (filters.length === 1 && filters[0].filterType==='RangedFilter') {
// single value and not a function-based filter
dimension.filterRange(filters[0]);
} else {
dimension.filterFunction(function (d) {
for (var i = 0; i < filters.length; i++) {
Expand Down
3 changes: 3 additions & 0 deletions src/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dc.filters.RangedFilter = function (low, high) {
range.isFiltered = function (value) {
return value >= this[0] && value < this[1];
};
range.filterType = 'RangedFilter';

return range;
};
Expand All @@ -50,6 +51,7 @@ dc.filters.TwoDimensionalFilter = function (filter) {
return value.length && value.length === f.length &&
value[0] === f[0] && value[1] === f[1];
};
f.filterType = 'TwoDimensionalFilter';

return f;
};
Expand Down Expand Up @@ -103,6 +105,7 @@ dc.filters.RangedTwoDimensionalFilter = function (filter) {
return x >= fromBottomLeft[0][0] && x < fromBottomLeft[1][0] &&
y >= fromBottomLeft[0][1] && y < fromBottomLeft[1][1];
};
f.filterType = 'RangedTwoDimensionalFilter';

return f;
};

0 comments on commit 9b2b007

Please sign in to comment.