From 383662f027a71a94f270515a069a4a06b4a57c7a Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Fri, 26 May 2017 12:51:17 -0400 Subject: [PATCH 1/3] clear calcdata before redoing it in animations --- src/plots/plots.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plots/plots.js b/src/plots/plots.js index 1b6f45321f8..f853c2c003e 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -1813,6 +1813,10 @@ plots.transition = function(gd, data, layout, traces, frameOpts, transitionOpts) // of essentially the whole supplyDefaults step, so that it seems sensible to just use // supplyDefaults even though it's heavier than would otherwise be desired for // transitions: + + // first delete calcdata so supplyDefaults knows a calc step is coming + delete gd.calcdata; + plots.supplyDefaults(gd); plots.doCalcdata(gd); From afb6ce69dda3d3412b2a5748036930fd76d162f2 Mon Sep 17 00:00:00 2001 From: Ricky Reusser Date: Fri, 26 May 2017 16:54:40 -0400 Subject: [PATCH 2/3] Add failing test for sort + animate --- test/jasmine/tests/animate_test.js | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/jasmine/tests/animate_test.js b/test/jasmine/tests/animate_test.js index 53eb151c01c..cbc264cfa90 100644 --- a/test/jasmine/tests/animate_test.js +++ b/test/jasmine/tests/animate_test.js @@ -768,4 +768,36 @@ describe('animating scatter traces', function() { expect(trace.style('opacity')).toEqual('0.1'); }).catch(fail).then(done); }); + + it('computes calcdata correctly when transforms are present', function (done) { + var isChecked = false; + + Plotly.plot(gd, { + data: [{ + x: [1, 2, 3], + y: [1, 2, 3], + mode: 'markers', + transforms: [{ + type: 'sort', + target: [1, 3, 2] + }] + }], + frames: [ + {name: 'frame1', data: [{y: [1, 2, 3]}]}, + {name: 'frame2', data: [{y: [3, 1, 2]}]} + ] + }).then(function () {; + return Plotly.animate(gd, ['frame2'], {frame: {duration: 200, redraw: false}}); + }).then(function () { + expect(isChecked).toBe(true); + }).catch(fail).then(done); + + gd.on('plotly_animating', function () { + setTimeout(function () { + isChecked = true; + console.log('gd.calcdata[0][0].y:', gd.calcdata[0][0].y); + expect(gd.calcdata[0][0].y).toEqual(3); + }, 100); + }) + }); }); From 5bebe1386d1b73091c412df421ed099f730c3a82 Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Fri, 26 May 2017 17:21:40 -0400 Subject: [PATCH 3/3] lint and simplify ricky's test of animate+sort --- test/jasmine/tests/animate_test.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/test/jasmine/tests/animate_test.js b/test/jasmine/tests/animate_test.js index cbc264cfa90..bcb93fe4ca9 100644 --- a/test/jasmine/tests/animate_test.js +++ b/test/jasmine/tests/animate_test.js @@ -769,9 +769,7 @@ describe('animating scatter traces', function() { }).catch(fail).then(done); }); - it('computes calcdata correctly when transforms are present', function (done) { - var isChecked = false; - + it('computes calcdata correctly when transforms are present', function(done) { Plotly.plot(gd, { data: [{ x: [1, 2, 3], @@ -786,18 +784,10 @@ describe('animating scatter traces', function() { {name: 'frame1', data: [{y: [1, 2, 3]}]}, {name: 'frame2', data: [{y: [3, 1, 2]}]} ] - }).then(function () {; + }).then(function() { return Plotly.animate(gd, ['frame2'], {frame: {duration: 200, redraw: false}}); - }).then(function () { - expect(isChecked).toBe(true); + }).then(function() { + expect(gd.calcdata[0][0].y).toEqual(3); }).catch(fail).then(done); - - gd.on('plotly_animating', function () { - setTimeout(function () { - isChecked = true; - console.log('gd.calcdata[0][0].y:', gd.calcdata[0][0].y); - expect(gd.calcdata[0][0].y).toEqual(3); - }, 100); - }) }); });