Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8321959

Browse files
committed
make sure arrayOk resyle logic works for hoverlabel attributes
- and all (future) plots/attributes.js declarations.
1 parent 9eeadcf commit 8321959

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

src/plot_api/plot_api.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,9 @@ function _restyle(gd, aobj, _traces) {
16081608
}
16091609
else {
16101610
var moduleAttrs = (contFull._module || {}).attributes || {};
1611-
var valObject = Lib.nestedProperty(moduleAttrs, ai).get() || {};
1611+
var valObject = Lib.nestedProperty(moduleAttrs, ai).get() ||
1612+
Lib.nestedProperty(Plots.attributes, ai).get() ||
1613+
{};
16121614

16131615
// if restyling entire attribute container, assume worse case
16141616
if(!valObject.valType) {

test/jasmine/tests/plot_api_test.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ describe('Test plot api', function() {
254254
});
255255
});
256256

257-
describe('Plotly.restyle', function() {
257+
describe('Plotly.restyle subroutines switchboard', function() {
258258
beforeEach(function() {
259259
spyOn(PlotlyInternal, 'plot');
260260
spyOn(Plots, 'previousPromises');
@@ -330,6 +330,36 @@ describe('Test plot api', function() {
330330
expect(PlotlyInternal.plot).toHaveBeenCalled();
331331
});
332332

333+
it('should do full replot when arrayOk base attributes are updated', function() {
334+
var gd = {
335+
data: [{x: [1, 2, 3], y: [1, 2, 3]}],
336+
layout: {}
337+
};
338+
339+
mockDefaultsAndCalc(gd);
340+
Plotly.restyle(gd, 'hoverlabel.bgcolor', [['red', 'green', 'blue']]);
341+
expect(gd.calcdata).toBeUndefined();
342+
expect(PlotlyInternal.plot).toHaveBeenCalled();
343+
344+
mockDefaultsAndCalc(gd);
345+
PlotlyInternal.plot.calls.reset();
346+
Plotly.restyle(gd, 'hoverlabel.bgcolor', 'yellow');
347+
expect(gd.calcdata).toBeUndefined();
348+
expect(PlotlyInternal.plot).toHaveBeenCalled();
349+
350+
mockDefaultsAndCalc(gd);
351+
PlotlyInternal.plot.calls.reset();
352+
Plotly.restyle(gd, 'hoverlabel.bgcolor', 'blue');
353+
expect(gd.calcdata).toBeDefined();
354+
expect(PlotlyInternal.plot).not.toHaveBeenCalled();
355+
356+
mockDefaultsAndCalc(gd);
357+
PlotlyInternal.plot.calls.reset();
358+
Plotly.restyle(gd, 'hoverlabel.bgcolor', [['red', 'blue', 'green']]);
359+
expect(gd.calcdata).toBeUndefined();
360+
expect(PlotlyInternal.plot).toHaveBeenCalled();
361+
});
362+
333363
it('should do full replot when attribute container are updated', function() {
334364
var gd = {
335365
data: [{x: [1, 2, 3], y: [1, 2, 3]}],

0 commit comments

Comments
 (0)