From 2d7a8d2c9b234cedbe3cd9ba1b9d1a9941a8e45b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 25 Feb 2016 11:23:39 -0500 Subject: [PATCH 1/3] add force redraw step in scene.plot, - so that Plotly.plot promise is returned when rendering is completed --- src/plots/gl3d/scene.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plots/gl3d/scene.js b/src/plots/gl3d/scene.js index a7800eb7f9b..feaccfbdc56 100644 --- a/src/plots/gl3d/scene.js +++ b/src/plots/gl3d/scene.js @@ -542,6 +542,9 @@ proto.plot = function(sceneData, fullLayout, layout) { containerStyle.width = (size.w * (domain.x[1] - domain.x[0])) + 'px'; containerStyle.height = (size.h * (domain.y[1] - domain.y[0])) + 'px'; } + + // force redraw so that promise is returned when rendering is completed + this.glplot.redraw(); }; proto.destroy = function() { From aa64e21373ee50174ad892e3a364376610223f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Wed, 13 Apr 2016 12:15:01 -0400 Subject: [PATCH 2/3] add force redraw step in scene2d.plot --- src/plots/gl2d/scene2d.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plots/gl2d/scene2d.js b/src/plots/gl2d/scene2d.js index fc0af4a335f..fb16dffb638 100644 --- a/src/plots/gl2d/scene2d.js +++ b/src/plots/gl2d/scene2d.js @@ -166,7 +166,7 @@ proto.toImage = function(format) { if(this.staticPlot) this.container.appendChild(STATIC_CANVAS); // force redraw - this.glplot.setDirty(true); + this.glplot.setDirty(); this.glplot.draw(); // grab context and yank out pixels @@ -408,6 +408,9 @@ proto.plot = function(fullData, fullLayout) { options.merge(fullLayout); glplot.update(options); + + // force redraw so that promise is returned when rendering is completed + this.glplot.draw(); }; proto.draw = function() { From bf1f65fafdfced3d3c3712069fafd3e9a489ad06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Wed, 13 Apr 2016 12:21:49 -0400 Subject: [PATCH 3/3] set gl mouse and plot delay down to 0 zero: - promise are now returned after initial plot call - still need a 0 zero so that hover labels appear reliably in promise chains. --- test/jasmine/tests/gl_plot_interact_test.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/test/jasmine/tests/gl_plot_interact_test.js b/test/jasmine/tests/gl_plot_interact_test.js index ab5274be3f6..add05802397 100644 --- a/test/jasmine/tests/gl_plot_interact_test.js +++ b/test/jasmine/tests/gl_plot_interact_test.js @@ -16,8 +16,6 @@ var customMatchers = require('../assets/custom_matchers'); * */ -var PLOT_DELAY = 200; -var MOUSE_DELAY = 20; var MODEBAR_DELAY = 500; @@ -54,10 +52,9 @@ describe('Test gl plot interactions', function() { destroyGraphDiv(); }); + // ... function delay(done) { - setTimeout(function() { - done(); - }, PLOT_DELAY); + setTimeout(done, 0); } describe('gl3d plots', function() { @@ -99,9 +96,7 @@ describe('Test gl plot interactions', function() { mouseEventScatter3d('mouseover'); - setTimeout(function() { - done(); - }, MOUSE_DELAY); + delay(done); }); it('should have', function() { @@ -139,9 +134,7 @@ describe('Test gl plot interactions', function() { // with button 1 pressed mouseEventScatter3d('mouseover', {buttons: 1}); - setTimeout(function() { - done(); - }, MOUSE_DELAY); + delay(done); }); it('should have', function() {