Skip to content

Commit 627aeab

Browse files
authored
Merge pull request #1536 from plotly/restyle-recalc-attr-containers
Assume recalc is needed when restyling attribute containers
2 parents 5871718 + e10c57f commit 627aeab

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/plot_api/plot_api.js

+6
Original file line numberDiff line numberDiff line change
@@ -1580,6 +1580,12 @@ function _restyle(gd, aobj, _traces) {
15801580
var moduleAttrs = (contFull._module || {}).attributes || {};
15811581
var valObject = Lib.nestedProperty(moduleAttrs, ai).get() || {};
15821582

1583+
// if restyling entire attribute container, assume worse case
1584+
if(!valObject.valType) {
1585+
flags.docalc = true;
1586+
}
1587+
1588+
// must redo calcdata when restyling array values of arrayOk attributes
15831589
if(valObject.arrayOk && (Array.isArray(newVal) || Array.isArray(oldVal))) {
15841590
flags.docalc = true;
15851591
}

test/jasmine/tests/plot_api_test.js

+19
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,25 @@ describe('Test plot api', function() {
330330
expect(PlotlyInternal.plot).toHaveBeenCalled();
331331
});
332332

333+
it('should do full replot when attribute container are updated', function() {
334+
var gd = {
335+
data: [{x: [1, 2, 3], y: [1, 2, 3]}],
336+
layout: {
337+
xaxis: { range: [0, 4] },
338+
yaxis: { range: [0, 4] }
339+
}
340+
};
341+
342+
mockDefaultsAndCalc(gd);
343+
Plotly.restyle(gd, {
344+
marker: {
345+
color: ['red', 'blue', 'green']
346+
}
347+
});
348+
expect(gd.calcdata).toBeUndefined();
349+
expect(PlotlyInternal.plot).toHaveBeenCalled();
350+
});
351+
333352
it('calls plot on xgap and ygap styling', function() {
334353
var gd = {
335354
data: [{z: [[1, 2, 3], [4, 5, 6], [7, 8, 9]], showscale: false, type: 'heatmap'}],

0 commit comments

Comments
 (0)