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

Refactor scattergl selection #2311

Merged
merged 9 commits into from
Feb 2, 2018
Merged

Refactor scattergl selection #2311

merged 9 commits into from
Feb 2, 2018

Conversation

dy
Copy link
Contributor

@dy dy commented Jan 30, 2018

@dy dy requested a review from etpinard January 30, 2018 23:55
@@ -278,7 +278,7 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
else {
// TODO: remove in v2 - this was probably never intended to work as it does,
// but in case anyone depends on it we don't want to break it now.
gd.emit('plotly_selected', undefined);
gd.emit('plotly_selected', {points: [], range: null});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

That gets triggered whenever we click on a point in select/lasso mode. The event receives undefined data object, which makes user check it manually. Simple compatibility is better.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, simple compatibility is better. That's why we'll do this in v2. Until then, we must preserve backward compatibility. Please undo this change.

if(dragmode === 'lasso' || dragmode === 'select') {
if(scene.select2d && scene.selectBatch) {
scene.scatter2d.update(scene.unselectedOptions);
// update selection
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Separated code chunks are in single location now

Copy link
Contributor

Choose a reason for hiding this comment

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

On the gl2d_12 mock, calling Plotly.restyle(gd, 'selected.marker.color', 'blue') leads to:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be fixed with 98cddf3

@etpinard etpinard added bug something broken status: in progress labels Jan 31, 2018
@etpinard etpinard added this to the v1.34.0 milestone Jan 31, 2018
@@ -82,6 +83,10 @@ var attrs = module.exports = overrideAll({
marker: scatterAttrs.unselected.marker
},

opacity: extendFlat({}, plotAttrs.opacity, {
editType: 'calc'
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Thanks!

I think the best way to test this would be to spy on ScatterGl.calc checking that Plotly.relayout(gd, 'opacity', /**/) does invoke it - similar to this suite.

return Plotly.restyle(gd, {'opacity': 0.1});
})
.then(function() {
expect(ScatterGl.calc).toHaveBeenCalledTimes(2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Brilliant test ✨

@etpinard
Copy link
Contributor

Adding a test for #2298 will be tricky. @dfcreative is their a way to assert that some internal field (I guessing in gd._fullLayout._plots.xy._scene) update properly after appendTraces?

@dy
Copy link
Contributor Author

dy commented Jan 31, 2018

@etpinard it is possible to test scene.markerOptions, since they directly affect regl-scatter2d state, thanks for the hint! Otherwise I'd just readPixels, which is bulletproof solution :)

@etpinard
Copy link
Contributor

etpinard commented Feb 2, 2018

Wow. Nice job @dfcreative this is looking very solid.

💃 (cc @alexcjohnson )

@etpinard
Copy link
Contributor

etpinard commented Feb 2, 2018

... @dfcreative make sure to close all the related issues after you merge this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants