Skip to content

Refactor scattergl selection#2311

Merged
dy merged 9 commits into
masterfrom
unify-selection
Feb 2, 2018
Merged

Refactor scattergl selection#2311
dy merged 9 commits into
masterfrom
unify-selection

Conversation

@dy

@dy dy commented Jan 30, 2018

Copy link
Copy Markdown
Contributor

@dy
dy requested a review from etpinard January 30, 2018 23:55
Comment thread src/plots/cartesian/select.js Outdated
// 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
Copy Markdown
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
Copy Markdown
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.

Comment thread src/traces/scattergl/index.js Outdated
if(dragmode === 'lasso' || dragmode === 'select') {
if(scene.select2d && scene.selectBatch) {
scene.scatter2d.update(scene.unselectedOptions);
// update selection

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

dy commented Jan 31, 2018

Copy link
Copy Markdown
Contributor Author

@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

etpinard commented Feb 2, 2018

Copy link
Copy Markdown
Contributor

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

💃 (cc @alexcjohnson )

@etpinard

etpinard commented Feb 2, 2018

Copy link
Copy Markdown
Contributor

... @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