Skip to content

Commit bcde048

Browse files
authored
Merge pull request #624 from plotly/fixup-relayout-images
Fixup relayout images in { astr: val } notation
2 parents 7f7c2fe + fd659f2 commit bcde048

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/plot_api/plot_api.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,8 +2278,9 @@ Plotly.relayout = function relayout(gd, astr, val) {
22782278
// as it is we get separate calls for x and y (or ax and ay) on move
22792279
objModule.draw(gd, objNum, p.parts.slice(2).join('.'), aobj[ai]);
22802280
delete aobj[ai];
2281-
} else if(p.parts[0] === 'images') {
2282-
var update = Lib.objectFromPath(astr, vi);
2281+
}
2282+
else if(p.parts[0] === 'images') {
2283+
var update = Lib.objectFromPath(ai, vi);
22832284
Lib.extendDeepAll(gd.layout, update);
22842285

22852286
Images.supplyLayoutDefaults(gd.layout, gd._fullLayout);

test/jasmine/tests/layout_images_test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,22 @@ describe('Layout images', function() {
260260
}).then(done);
261261
});
262262

263+
it('should update the image position if changed', function(done) {
264+
var update = {
265+
'images[0].x': 0,
266+
'images[0].y': 1
267+
};
268+
269+
var img = Plotly.d3.select('image');
270+
271+
expect([+img.attr('x'), +img.attr('y')]).toEqual([1160, -170]);
272+
273+
Plotly.relayout(gd, update).then(function() {
274+
var newImg = Plotly.d3.select('image');
275+
expect([+newImg.attr('x'), +newImg.attr('y')]).toEqual([80, 100]);
276+
}).then(done);
277+
});
278+
263279
it('should remove the image tag if an invalid source', function(done) {
264280

265281
var selection = Plotly.d3.select('image');

0 commit comments

Comments
 (0)