Skip to content

Enable restyle to redraw parcoords #3101 #3125

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

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
18 changes: 10 additions & 8 deletions src/traces/parcoords/parcoords.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,18 +456,20 @@ module.exports = function(root, svg, parcoordsLineLayers, styledData, layout, ca

parcoordsLineLayer
.each(function(d) {

if(d.viewModel) {
if(d.lineLayer) d.lineLayer.update(d);
else d.lineLayer = lineLayerMaker(this, d);
if((!d.lineLayer) ||
Copy link
Contributor

@etpinard etpinard Oct 23, 2018

Choose a reason for hiding this comment

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

That extra ( ) style feels somewhat new to our codebase. Maybe we could add https://eslint.org/docs/rules/no-extra-parens to our lintinting rules.

(callbacks)) { // recreate in case of having callbacks e.g. restyle. Should we test for callback to be a restyle?
d.lineLayer = lineLayerMaker(this, d);
} else d.lineLayer.update(d);

d.viewModel[d.key] = d.lineLayer;
if(d.key) {
d.viewModel[d.key] = d.lineLayer;

var setChanged = ((d.key) &&
(((d.key !== 'contextLayer') || (callbacks)) || // unless there is callback on this line layer
(!d.context))); // don't update background
var setChanged = ((!d.context) || // don't update background
((d.key !== 'contextLayer') || (callbacks))); // unless there is a callback on the context layer. Should we test the callback?

d.lineLayer.render(d.viewModel.panels, setChanged);
d.lineLayer.render(d.viewModel.panels, setChanged);
}
}
});

Expand Down
7 changes: 4 additions & 3 deletions test/jasmine/tests/config_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var click = require('../assets/click');
var mouseEvent = require('../assets/mouse_event');
var failTest = require('../assets/fail_test');
var delay = require('../assets/delay');
var RESIZE_DELAY = 300;
Copy link
Collaborator

Choose a reason for hiding this comment

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

cc @antoinerg - bad day for circleci it seems, we were getting repeated test failures here so I encouraged @archmoj to try increasing this delay. At some point we may want to change this so we're waiting on some event (listen for plotly_afterplot perhaps?) rather than a fixed delay, that should be more robust (and usually faster!)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@antoinerg What value you suggest we use here for RESIZE_DELAY now that the CI is back to normal?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't bother reducing it (if the goal is essentially to save time) - just leave it until we get around to exploring an event-based delay, rather than time-based.


describe('config argument', function() {

Expand Down Expand Up @@ -585,7 +586,7 @@ describe('config argument', function() {
viewport.set(width / 2, height / 2);

return Promise.resolve()
.then(delay(200))
.then(delay(RESIZE_DELAY))
.then(function() {
checkLayoutSize(elWidth / 2, elHeight / 2);
})
Expand Down Expand Up @@ -639,7 +640,7 @@ describe('config argument', function() {
Plotly.plot(gd, data, {}, {responsive: true})
.then(function() {return Plotly.restyle(gd, 'y[0]', data[0].y[0] + 2);})
.then(function() {viewport.set(width / 2, width / 2);})
.then(delay(200))
.then(delay(RESIZE_DELAY))
// .then(function() {viewport.set(newWidth, 2 * newHeight);}).then(delay(200))
.then(function() {
expect(cntWindowResize).toBe(1);
Expand Down Expand Up @@ -667,7 +668,7 @@ describe('config argument', function() {
// Resize viewport
.then(function() {viewport.set(width / 2, height / 2);})
// Wait for resize to happen (Plotly.resize has an internal timeout)
.then(delay(200))
.then(delay(RESIZE_DELAY))
// Check that final figure's size hasn't changed
.then(function() {checkLayoutSize(width, height);})
.catch(failTest)
Expand Down