Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1a3d383

Browse filesBrowse files
authored
Merge pull request plotly#4366 from plotly/coloraxis-restyle-fix
Clear relinked cmin/cmax values in shared axes
2 parents 513491e + 85b04cf commit 1a3d383
Copy full SHA for 1a3d383

File tree

2 files changed

+45
-0
lines changed
Filter options

2 files changed

+45
-0
lines changed

‎src/plots/plots.js

Copy file name to clipboardExpand all lines: src/plots/plots.js
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2828,6 +2828,15 @@ plots.doCalcdata = function(gd, traces) {
28282828
);
28292829
}
28302830

2831+
// clear relinked cmin/cmax values in shared axes to start aggregation from scratch
2832+
for(var k in fullLayout._colorAxes) {
2833+
var cOpts = fullLayout[k];
2834+
if(cOpts.cauto !== false) {
2835+
delete cOpts.cmin;
2836+
delete cOpts.cmax;
2837+
}
2838+
}
2839+
28312840
var hasCalcTransform = false;
28322841

28332842
function transformCalci(i) {

‎test/jasmine/tests/colorscale_test.js

Copy file name to clipboardExpand all lines: test/jasmine/tests/colorscale_test.js
+36Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,42 @@ describe('Test colorscale restyle calls:', function() {
11011101
.then(done);
11021102
});
11031103

1104+
it('should update coloraxis cmin/cmax on color value changes', function(done) {
1105+
function fig(mc) {
1106+
return {
1107+
data: [{
1108+
mode: 'markers',
1109+
y: [1, 2, 3],
1110+
marker: {
1111+
coloraxis: 'coloraxis',
1112+
color: mc
1113+
}
1114+
}]
1115+
};
1116+
}
1117+
1118+
function _assert(msg, cmin, cmax) {
1119+
return function() {
1120+
var cOpts = gd._fullLayout.coloraxis;
1121+
expect(cOpts.cmin).toBe(cmin, msg + '| cmin');
1122+
expect(cOpts.cmax).toBe(cmax, msg + '| cmax');
1123+
};
1124+
}
1125+
1126+
Plotly.react(gd, fig([1, 2, 3]))
1127+
.then(_assert('marker.color [1,2,3]', 1, 3))
1128+
.then(function() { return Plotly.react(gd, fig([1, 5, 3])); })
1129+
.then(_assert('marker.color [1,5,3]', 1, 5))
1130+
.then(function() { return Plotly.react(gd, fig([1, 2, 3])); })
1131+
.then(_assert('back to marker.color [1,2,3]', 1, 3))
1132+
.then(function() { return Plotly.react(gd, fig([-1, 2, 3])); })
1133+
.then(_assert('marker.color [-1,2,3]', -1, 3))
1134+
.then(function() { return Plotly.react(gd, fig([1, 2, 3])); })
1135+
.then(_assert('back again to marker.color [1,2,3]', 1, 3))
1136+
.catch(failTest)
1137+
.then(done);
1138+
});
1139+
11041140
it('should work with templates', function(done) {
11051141
function _assert(msg, exp) {
11061142
var mcc = [];

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.