Skip to content
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

Array support for trace hoverinfo #1761

Merged
merged 10 commits into from
Jun 6, 2017
1 change: 1 addition & 0 deletions src/plot_api/plot_schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ exports.findArrayAttributes = function(trace) {
return stack.join('.');
}

exports.crawl(baseAttributes, callback);
Copy link
Collaborator

Choose a reason for hiding this comment

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

ha nice, that's a lot simpler than I was afraid it might be!

exports.crawl(trace._module.attributes, callback);

if(trace.transforms) {
Expand Down
19 changes: 19 additions & 0 deletions test/jasmine/tests/transform_filter_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,25 @@ describe('filter transforms calc:', function() {
expect(out[0].marker.color).toEqual([0.3, 0.3, 0.4]);
});

it('filters should handle array on base trace attributes', function() {
var out = _transform([Lib.extendDeep({}, base, {
hoverinfo: ['x', 'y', 'text', 'name', 'none', 'skip', 'all'],
hoverlabel: {
bgcolor: ['red', 'green', 'blue', 'black', 'yellow', 'cyan', 'pink'],
},
transforms: [{
type: 'filter',
operation: '>',
value: 0
}]
})]);

expect(out[0].x).toEqual([1, 2, 3]);
expect(out[0].y).toEqual([2, 3, 1]);
expect(out[0].hoverinfo).toEqual(['none', 'skip', 'all']);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before this patch, we had

out[0].hoverinfo 
// => ['x', 'y', 'text', 'name', 'none', 'skip', 'all']

expect(out[0].hoverlabel.bgcolor).toEqual(['yellow', 'cyan', 'pink']);
});

it('filters should skip if *enabled* is false', function() {
var out = _transform([Lib.extendDeep({}, base, {
transforms: [{
Expand Down