Skip to content

Commit b2b68cd

Browse files
authored
Merge pull request #959 from plotly/surface-colormap-discontinuity
Fix surface colormap discontinuity for circular colorscales
2 parents 9b249c2 + 5eeac80 commit b2b68cd

File tree

4 files changed

+1038
-2
lines changed

4 files changed

+1038
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"gl-select-box": "^1.0.1",
7575
"gl-shader": "4.2.0",
7676
"gl-spikes2d": "^1.0.1",
77-
"gl-surface3d": "^1.2.3",
77+
"gl-surface3d": "^1.3.0",
7878
"mapbox-gl": "^0.22.0",
7979
"mouse-change": "^1.1.1",
8080
"mouse-wheel": "^1.0.2",

src/traces/surface/convert.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,18 @@ function parseColorScale(colorscale, alpha) {
9797
});
9898
}
9999

100+
function isColormapCircular(colormap) {
101+
var first = colormap[0].rgb,
102+
last = colormap[colormap.length - 1].rgb;
103+
104+
return (
105+
first[0] === last[0] &&
106+
first[1] === last[1] &&
107+
first[2] === last[2] &&
108+
first[3] === last[3]
109+
);
110+
}
111+
100112
// Pad coords by +1
101113
function padField(field) {
102114
var shape = field.shape;
@@ -317,6 +329,11 @@ proto.update = function(data) {
317329
}
318330
}
319331

332+
// see https://github.com/plotly/plotly.js/issues/940
333+
if(isColormapCircular(colormap)) {
334+
params.vertexColor = true;
335+
}
336+
320337
params.coords = coords;
321338

322339
surface.update(params);
@@ -343,7 +360,6 @@ proto.update = function(data) {
343360
}
344361
};
345362

346-
347363
proto.dispose = function() {
348364
this.scene.glplot.remove(this.surface);
349365
this.surface.dispose();
Loading

0 commit comments

Comments
 (0)