From 6a08dfa52cf118739641096e2c493c8eb9db29e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 9 Jun 2016 19:04:33 -0400 Subject: [PATCH 1/2] fix relayout for images update in { 'astr': val } --- src/plot_api/plot_api.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index 041e1ae3549..3d16e72fbe2 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -2278,8 +2278,9 @@ Plotly.relayout = function relayout(gd, astr, val) { // as it is we get separate calls for x and y (or ax and ay) on move objModule.draw(gd, objNum, p.parts.slice(2).join('.'), aobj[ai]); delete aobj[ai]; - } else if(p.parts[0] === 'images') { - var update = Lib.objectFromPath(astr, vi); + } + else if(p.parts[0] === 'images') { + var update = Lib.objectFromPath(ai, vi); Lib.extendDeepAll(gd.layout, update); Images.supplyLayoutDefaults(gd.layout, gd._fullLayout); From fd659f281f03a66e2441f310d599d630055692eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 9 Jun 2016 21:52:15 -0400 Subject: [PATCH 2/2] add test case for image relayout in { astr: val } --- test/jasmine/tests/layout_images_test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/jasmine/tests/layout_images_test.js b/test/jasmine/tests/layout_images_test.js index 88611b92c77..058cf3d8fd0 100644 --- a/test/jasmine/tests/layout_images_test.js +++ b/test/jasmine/tests/layout_images_test.js @@ -260,6 +260,22 @@ describe('Layout images', function() { }).then(done); }); + it('should update the image position if changed', function(done) { + var update = { + 'images[0].x': 0, + 'images[0].y': 1 + }; + + var img = Plotly.d3.select('image'); + + expect([+img.attr('x'), +img.attr('y')]).toEqual([1160, -170]); + + Plotly.relayout(gd, update).then(function() { + var newImg = Plotly.d3.select('image'); + expect([+newImg.attr('x'), +newImg.attr('y')]).toEqual([80, 100]); + }).then(done); + }); + it('should remove the image tag if an invalid source', function(done) { var selection = Plotly.d3.select('image');