Skip to content

Commit af15b34

Browse files
committed
assume redoing calcdata is neccessary when restyling attr containers
1 parent caade64 commit af15b34

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/plot_api/plot_api.js

+5
Original file line numberDiff line numberDiff line change
@@ -1580,6 +1580,11 @@ 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+
15831588
if(valObject.arrayOk && (Array.isArray(newVal) || Array.isArray(oldVal))) {
15841589
flags.docalc = true;
15851590
}

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)