Skip to content

Commit 775dbb5

Browse files
committed
transforms: clear _categories after transform calc loop
- so that only post-transform categories are displayed on graph
1 parent 30a7960 commit 775dbb5

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

src/plots/plots.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1984,10 +1984,11 @@ plots.doCalcdata = function(gd, traces) {
19841984
}
19851985
}
19861986

1987-
// clear stuff ...
1987+
// clear stuff that should recomputed in 'regular' loop
19881988
for(i = 0; i < axList.length; i++) {
19891989
axList[i]._min = [];
19901990
axList[i]._max = [];
1991+
axList[i]._categories = [];
19911992
}
19921993

19931994
// 'regular' loop

test/jasmine/tests/transform_filter_test.js

+44
Original file line numberDiff line numberDiff line change
@@ -999,4 +999,48 @@ describe('filter transforms interactions', function() {
999999
done();
10001000
});
10011001
});
1002+
1003+
it('should update axie categories', function(done) {
1004+
var data = [{
1005+
type: 'bar',
1006+
x: ['a', 'b', 'c', 'd', 'e', 'f', 'g'],
1007+
y: [1, 10, 100, 25, 50, -25, 100],
1008+
transforms: [{
1009+
type: 'filter',
1010+
operation: '<',
1011+
value: 10,
1012+
target: [1, 10, 100, 25, 50, -25, 100]
1013+
}]
1014+
}];
1015+
1016+
var gd = createGraphDiv();
1017+
1018+
Plotly.plot(gd, data).then(function() {
1019+
expect(gd._fullLayout.xaxis._categories).toEqual(['a', 'f']);
1020+
expect(gd._fullLayout.yaxis._categories).toEqual([]);
1021+
1022+
return Plotly.addTraces(gd, [{
1023+
type: 'bar',
1024+
x: ['h', 'i'],
1025+
y: [2, 1],
1026+
transforms: [{
1027+
type: 'filter',
1028+
operation: '=',
1029+
value: 'i'
1030+
}]
1031+
}]);
1032+
})
1033+
.then(function() {
1034+
expect(gd._fullLayout.xaxis._categories).toEqual(['a', 'f', 'i']);
1035+
expect(gd._fullLayout.yaxis._categories).toEqual([]);
1036+
1037+
return Plotly.deleteTraces(gd, [0]);
1038+
})
1039+
.then(function() {
1040+
expect(gd._fullLayout.xaxis._categories).toEqual(['i']);
1041+
expect(gd._fullLayout.yaxis._categories).toEqual([]);
1042+
1043+
})
1044+
.then(done);
1045+
});
10021046
});

0 commit comments

Comments
 (0)