Skip to content

Commit 28a2e44

Browse files
committed
contour and colorscale push the applied auto back to input
1 parent 117542f commit 28a2e44

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

src/components/colorscale/calc.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@ module.exports = function calc(trace, vals, containerStr, cLetter) {
2727
inputContainer = trace._input;
2828
}
2929

30-
var auto = container[cLetter + 'auto'],
31-
min = container[cLetter + 'min'],
32-
max = container[cLetter + 'max'],
30+
var autoAttr = cLetter + 'auto',
31+
minAttr = cLetter + 'min',
32+
maxAttr = cLetter + 'max',
33+
auto = container[autoAttr],
34+
min = container[minAttr],
35+
max = container[maxAttr],
3336
scl = container.colorscale;
3437

3538
if(auto !== false || min === undefined) {
@@ -45,11 +48,21 @@ module.exports = function calc(trace, vals, containerStr, cLetter) {
4548
max += 0.5;
4649
}
4750

48-
container[cLetter + 'min'] = min;
49-
container[cLetter + 'max'] = max;
51+
container[minAttr] = min;
52+
container[maxAttr] = max;
5053

51-
inputContainer[cLetter + 'min'] = min;
52-
inputContainer[cLetter + 'max'] = max;
54+
inputContainer[minAttr] = min;
55+
inputContainer[maxAttr] = max;
56+
57+
/*
58+
* If auto was explicitly false but min or max was missing,
59+
* we filled in the missing piece here but later the trace does
60+
* not look auto.
61+
* Otherwise make sure the trace still looks auto as far as later
62+
* changes are concerned.
63+
*/
64+
inputContainer[autoAttr] = (auto !== false ||
65+
(min === undefined && max === undefined));
5366

5467
if(container.autocolorscale) {
5568
if(min * max < 0) scl = scales.RdBu;

src/traces/contour/calc.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,15 @@ module.exports = function calc(gd, trace) {
4242
}
4343

4444
// copy auto-contour info back to the source data.
45-
trace._input.contours = extendFlat({}, contours);
45+
// previously we copied the whole contours object back, but that had
46+
// other info (coloring, showlines) that should be left to supplyDefaults
47+
if(!trace._input.contours) trace._input.contours = {};
48+
extendFlat(trace._input.contours, {
49+
start: contours.start,
50+
end: contours.end,
51+
size: contours.size
52+
});
53+
trace._input.autocontour = true;
4654
}
4755
else {
4856
// sanity checks on manually-supplied start/end/size

test/jasmine/tests/contour_test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,11 @@ describe('contour calc', function() {
305305
// all these get copied back to the input trace
306306
expect(out._input.contours[attr]).toBe(spec[attr], [contoursIn, attr]);
307307
});
308+
309+
expect(out._input.autocontour).toBe(true);
310+
expect(out._input.zauto).toBe(true);
311+
expect(out._input.zmin).toBe(0);
312+
expect(out._input.zmax).toBe(5);
308313
});
309314
});
310315
});

0 commit comments

Comments
 (0)