Skip to content

Commit c883e57

Browse files
authored
Merge pull request #1133 from plotly/fix-relayout-array
quick fix - allow relayout array elements
2 parents 89c68e2 + 4db2ba9 commit c883e57

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/plot_api/plot_api.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1959,6 +1959,7 @@ function _relayout(gd, aobj) {
19591959
}
19601960
// alter gd.layout
19611961
else {
1962+
var pp1 = String(p.parts[1] || '');
19621963
// check whether we can short-circuit a full redraw
19631964
// 3d or geo at this point just needs to redraw.
19641965
if(p.parts[0].indexOf('scene') === 0) flags.doplot = true;
@@ -1973,17 +1974,17 @@ function _relayout(gd, aobj) {
19731974
else if(ai.indexOf('title') !== -1) flags.doticks = true;
19741975
else if(p.parts[0].indexOf('bgcolor') !== -1) flags.dolayoutstyle = true;
19751976
else if(p.parts.length > 1 &&
1976-
Lib.containsAny(p.parts[1], ['tick', 'exponent', 'grid', 'zeroline'])) {
1977+
Lib.containsAny(pp1, ['tick', 'exponent', 'grid', 'zeroline'])) {
19771978
flags.doticks = true;
19781979
}
19791980
else if(ai.indexOf('.linewidth') !== -1 &&
19801981
ai.indexOf('axis') !== -1) {
19811982
flags.doticks = flags.dolayoutstyle = true;
19821983
}
1983-
else if(p.parts.length > 1 && p.parts[1].indexOf('line') !== -1) {
1984+
else if(p.parts.length > 1 && pp1.indexOf('line') !== -1) {
19841985
flags.dolayoutstyle = true;
19851986
}
1986-
else if(p.parts.length > 1 && p.parts[1] === 'mirror') {
1987+
else if(p.parts.length > 1 && pp1 === 'mirror') {
19871988
flags.doticks = flags.dolayoutstyle = true;
19881989
}
19891990
else if(ai === 'margin.pad') {

test/jasmine/tests/plot_api_test.js

+15
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,21 @@ describe('Test plot api', function() {
148148
})
149149
.then(done);
150150
});
151+
152+
it('can set items in array objects', function(done) {
153+
Plotly.plot(gd, [{ x: [1, 2, 3], y: [1, 2, 3] }])
154+
.then(function() {
155+
return Plotly.relayout(gd, {rando: [1, 2, 3]});
156+
})
157+
.then(function() {
158+
expect(gd.layout.rando).toEqual([1, 2, 3]);
159+
return Plotly.relayout(gd, {'rando[1]': 45});
160+
})
161+
.then(function() {
162+
expect(gd.layout.rando).toEqual([1, 45, 3]);
163+
})
164+
.then(done);
165+
});
151166
});
152167

153168
describe('Plotly.restyle', function() {

0 commit comments

Comments
 (0)