Skip to content

Filter and groupby transforms in main bundle #978

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Oct 6, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6309837
fix linting in lib/filter.js
etpinard Sep 26, 2016
96bcbfc
lib: add groupby module + register it in main index
etpinard Sep 26, 2016
06c805d
lint: rm useless comments in transform modules
etpinard Sep 26, 2016
f6eb2f4
lint: rm uselss Plotly.register calls in test suites
etpinard Sep 26, 2016
0158f45
test: move user-defined transform test to transform_multi
etpinard Sep 26, 2016
64dc72a
transforms: make findArrayAttributes a lib function
etpinard Sep 28, 2016
1238236
transforms: add 'calcTransform' handler in doCalcdata
etpinard Sep 28, 2016
0e1e9a7
transforms: filter take II
etpinard Sep 28, 2016
f722c5d
transforms: fill in groupby descriptions
etpinard Sep 28, 2016
037fa5c
transforms: perf in groupby
etpinard Sep 28, 2016
01f8595
lint: some line spacing in plots.js
etpinard Sep 28, 2016
8a29a89
test: one big nasty commit untangling / adding transforms tests
etpinard Sep 28, 2016
ad5089e
test: make sure all '#graph' nodes are purged after toimage tests
etpinard Sep 29, 2016
7a98f15
test: fixup plotschema case for new filter attributes
etpinard Sep 29, 2016
c8a13b8
test: add case where axis type is set by user
etpinard Sep 29, 2016
f4b9dcc
transforms: replace 'active' attribute by 'enabled'
etpinard Sep 30, 2016
104123e
transforms: replace 'strictinterval' with MORE operation values
etpinard Sep 30, 2016
ba9b933
transforms: improve attribute descriptions
etpinard Sep 30, 2016
7fc7dfa
fix a few typos
etpinard Sep 30, 2016
7cfa4ff
transforms: fix logic for outside intervals
etpinard Sep 30, 2016
3e74c80
api: relax transform module requirements
etpinard Oct 3, 2016
2a7738e
api: improve register transform logging and tests
etpinard Oct 3, 2016
0aa4958
test: update transform case descriptions
etpinard Oct 3, 2016
ad77818
transforms: allow 'filtersrc' to be an arbitrary attr string
etpinard Oct 3, 2016
4cd9edf
transforms: add support for date 3D z-axes
etpinard Oct 3, 2016
f5c64d2
doc: add comment about transform in main index file
etpinard Oct 5, 2016
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
9 changes: 5 additions & 4 deletions src/transforms/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ exports.calcTransform = function(gd, trace, opts) {

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

var dataToCoord = getDataToCoordFunc(gd, filtersrc),
var dataToCoord = getDataToCoordFunc(gd, trace, filtersrc),
filterFunc = getFilterFunc(opts, dataToCoord);

var filterArr = Lib.nestedProperty(trace, filtersrc).get(),
Expand Down Expand Up @@ -157,8 +157,8 @@ exports.calcTransform = function(gd, trace, opts) {
}
};

function getDataToCoordFunc(gd, filtersrc) {
var ax = axisIds.getFromId(gd, filtersrc);
function getDataToCoordFunc(gd, trace, filtersrc) {
var ax = axisIds.getFromTrace(gd, trace, filtersrc);

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

// otherwise -> cast to Number
// otherwise
// -> cast to Number
return function(v) { return +v; };
}

Expand Down
17 changes: 17 additions & 0 deletions test/jasmine/tests/transform_filter_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,23 @@ describe('filter transforms calc:', function() {
expect(out[0].y).toEqual(base.y);
});

it('filters should handle 3D *z* data', function() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi @bpostlethwaite this works 🎉 !!!

var out = _transform([Lib.extendDeep({}, base, {
type: 'scatter3d',
z: ['2015-07-20', '2016-08-01', '2016-09-01', '2016-10-21', '2016-12-02'],
transforms: [{
type: 'filter',
operation: '>',
value: '2016-10-01',
filtersrc: 'z'
}]
})]);

expect(out[0].x).toEqual([0, 1]);
expect(out[0].y).toEqual([1, 2]);
expect(out[0].z).toEqual(['2016-10-21', '2016-12-02']);
});

it('filters should handle geographical *lon* data', function() {
var trace0 = {
type: 'scattergeo',
Expand Down