Skip to content

Commit 4cd9edf

Browse files
committed
transforms: add support for date 3D z-axes
- using axisIds.getFromTrace !
1 parent ad77818 commit 4cd9edf

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/transforms/filter.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ exports.calcTransform = function(gd, trace, opts) {
120120

121121
if(!opts.enabled || !filtersrcOk) return;
122122

123-
var dataToCoord = getDataToCoordFunc(gd, filtersrc),
123+
var dataToCoord = getDataToCoordFunc(gd, trace, filtersrc),
124124
filterFunc = getFilterFunc(opts, dataToCoord);
125125

126126
var filterArr = Lib.nestedProperty(trace, filtersrc).get(),
@@ -157,8 +157,8 @@ exports.calcTransform = function(gd, trace, opts) {
157157
}
158158
};
159159

160-
function getDataToCoordFunc(gd, filtersrc) {
161-
var ax = axisIds.getFromId(gd, filtersrc);
160+
function getDataToCoordFunc(gd, trace, filtersrc) {
161+
var ax = axisIds.getFromTrace(gd, trace, filtersrc);
162162

163163
// if 'filtersrc' has corresponding axis
164164
// -> use setConvert method
@@ -168,7 +168,8 @@ function getDataToCoordFunc(gd, filtersrc) {
168168
// -> cast to String
169169
if(filtersrc === 'ids') return function(v) { return String(v); };
170170

171-
// otherwise -> cast to Number
171+
// otherwise
172+
// -> cast to Number
172173
return function(v) { return +v; };
173174
}
174175

test/jasmine/tests/transform_filter_test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,23 @@ describe('filter transforms calc:', function() {
120120
expect(out[0].y).toEqual(base.y);
121121
});
122122

123+
it('filters should handle 3D *z* data', function() {
124+
var out = _transform([Lib.extendDeep({}, base, {
125+
type: 'scatter3d',
126+
z: ['2015-07-20', '2016-08-01', '2016-09-01', '2016-10-21', '2016-12-02'],
127+
transforms: [{
128+
type: 'filter',
129+
operation: '>',
130+
value: '2016-10-01',
131+
filtersrc: 'z'
132+
}]
133+
})]);
134+
135+
expect(out[0].x).toEqual([0, 1]);
136+
expect(out[0].y).toEqual([1, 2]);
137+
expect(out[0].z).toEqual(['2016-10-21', '2016-12-02']);
138+
});
139+
123140
it('filters should handle geographical *lon* data', function() {
124141
var trace0 = {
125142
type: 'scattergeo',

0 commit comments

Comments
 (0)