Skip to content

Commit c898252

Browse files
committed
make sure restyle 'cmin' or 'cmax' clears 'cauto'
1 parent 5d37bd6 commit c898252

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

src/plot_api/plot_api.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,7 @@ function _restyle(gd, aobj, _traces) {
13831383
];
13841384

13851385
var zscl = ['zmin', 'zmax'],
1386+
cscl = ['cmin', 'cmax'],
13861387
xbins = ['xbins.start', 'xbins.end', 'xbins.size'],
13871388
ybins = ['ybins.start', 'ybins.end', 'ybins.size'],
13881389
contourAttrs = ['contours.start', 'contours.end', 'contours.size'];
@@ -1482,6 +1483,9 @@ function _restyle(gd, aobj, _traces) {
14821483
if(zscl.indexOf(ai) !== -1) {
14831484
doextra('zauto', false, i);
14841485
}
1486+
if(cscl.indexOf(ai) !== -1) {
1487+
doextra('cauto', false, i);
1488+
}
14851489
else if(ai === 'colorscale') {
14861490
doextra('autocolorscale', false, i);
14871491
}

test/jasmine/tests/mesh3d_test.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
var Plotly = require('@lib');
2+
var createGraphDiv = require('../assets/create_graph_div');
3+
var destroyGraphDiv = require('../assets/destroy_graph_div');
4+
var fail = require('../assets/fail_test');
5+
6+
describe('Test mesh3d restyle', function() {
7+
afterEach(destroyGraphDiv);
8+
9+
it('should clear *cauto* when restyle *cmin* and/or *cmax*', function(done) {
10+
var gd = createGraphDiv();
11+
12+
function _assert(user, full) {
13+
var trace = gd.data[0];
14+
var fullTrace = gd._fullData[0];
15+
16+
expect(trace.cauto).toBe(user[0], 'user cauto');
17+
expect(trace.cmin).toEqual(user[1], 'user cmin');
18+
expect(trace.cmax).toEqual(user[2], 'user cmax');
19+
expect(fullTrace.cauto).toBe(full[0], 'full cauto');
20+
expect(fullTrace.cmin).toEqual(full[1], 'full cmin');
21+
expect(fullTrace.cmax).toEqual(full[2], 'full cmax');
22+
}
23+
24+
Plotly.plot(gd, [{
25+
type: 'mesh3d',
26+
x: [0, 1, 2, 0],
27+
y: [0, 0, 1, 2],
28+
z: [0, 2, 0, 1],
29+
i: [0, 0, 0, 1],
30+
j: [1, 2, 3, 2],
31+
k: [2, 3, 1, 3],
32+
intensity: [0, 0.33, 0.66, 3]
33+
}])
34+
.then(function() {
35+
_assert([true, 0, 3], [true, 0, 3]);
36+
37+
return Plotly.restyle(gd, 'cmin', 0);
38+
})
39+
.then(function() {
40+
_assert([false, 0, 3], [false, 0, 3]);
41+
42+
return Plotly.restyle(gd, 'cmax', 10);
43+
})
44+
.then(function() {
45+
_assert([false, 0, 10], [false, 0, 10]);
46+
47+
return Plotly.restyle(gd, 'cauto', true);
48+
})
49+
.then(function() {
50+
_assert([true, 0, 3], [true, 0, 3]);
51+
52+
return Plotly.purge(gd);
53+
})
54+
.catch(fail)
55+
.then(done);
56+
});
57+
});

0 commit comments

Comments
 (0)