Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/transforms/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,13 @@ function getDataToCoordFunc(gd, trace, target) {
type: autoType(target),
_categories: []
};

setConvert(ax);

// build up ax._categories (usually done during ax.makeCalcdata()
for(var i = 0; i < target.length; i++) {
ax.d2c(target[i]);
}
}
else {
ax = axisIds.getFromTrace(gd, trace, target);
Expand Down
32 changes: 31 additions & 1 deletion test/jasmine/tests/transform_filter_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ describe('filter transforms calc:', function() {
expect(out[0].transforms[0].target).toEqual([0, 0, 0]);
});

it('with categorical items', function() {
it('with categorical items and *{}*', function() {
var out = _transform([Lib.extendDeep({}, _base, {
transforms: [{
target: ['a', 'a', 'b', 'b', 'a', 'b', 'a'],
Expand All @@ -651,6 +651,36 @@ describe('filter transforms calc:', function() {
expect(out[0].transforms[0].target).toEqual(['b', 'b', 'b']);
});

it('with categorical items and *<* & *>=*', function() {
var out = _transform([{
x: [1, 2, 3],
y: [10, 20, 30],
transforms: [{
type: 'filter',
operation: '<',
target: ['a', 'b', 'c'],
value: 'c'
}]
}, {
x: [1, 2, 3],
y: [30, 20, 10],
transforms: [{
type: 'filter',
operation: '>=',
target: ['a', 'b', 'c'],
value: 'b'
}]
}]);

expect(out[0].x).toEqual([1, 2]);
expect(out[0].y).toEqual([10, 20]);
expect(out[0].transforms[0].target).toEqual(['a', 'b']);

expect(out[1].x).toEqual([2, 3]);
expect(out[1].y).toEqual([20, 10]);
expect(out[1].transforms[0].target).toEqual(['b', 'c']);
});

it('with dates items', function() {
var out = _transform([Lib.extendDeep({}, _base, {
transforms: [{
Expand Down