Skip to content

Commit 9d91e2c

Browse files
committed
fix mapbox hover label color for array marker.color values
1 parent 295659e commit 9d91e2c

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/traces/scattermapbox/convert.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,10 @@ function makeCircleGeoJSON(calcTrace, hash) {
200200
if(isBADNUM(lonlat)) continue;
201201

202202
var props = {};
203-
if(colorFn) translate(props, COLOR_PROP, colorFn(calcPt.mc), i);
203+
if(colorFn) {
204+
var mcc = calcPt.mcc = colorFn(calcPt.mc);
205+
translate(props, COLOR_PROP, mcc, i);
206+
}
204207
if(sizeFn) translate(props, SIZE_PROP, sizeFn(calcPt.ms), i);
205208

206209
features.push({

test/jasmine/tests/scattermapbox_test.js

+18
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,24 @@ describe('@noCI scattermapbox hover', function() {
490490
done();
491491
});
492492
});
493+
494+
it('should generate hover label (\'marker.color\' array case)', function(done) {
495+
Plotly.restyle(gd, 'marker.color', [['red', 'blue', 'green']]).then(function() {
496+
var out = hoverPoints(getPointData(gd), 11, 11)[0];
497+
498+
expect(out.color).toEqual('red');
499+
})
500+
.then(done);
501+
});
502+
503+
it('should generate hover label (\'marker.color\' w/ colorscale case)', function(done) {
504+
Plotly.restyle(gd, 'marker.color', [[10, 5, 30]]).then(function() {
505+
var out = hoverPoints(getPointData(gd), 11, 11)[0];
506+
507+
expect(out.color).toEqual('rgb(245, 195, 157)');
508+
})
509+
.then(done);
510+
});
493511
});
494512

495513

0 commit comments

Comments
 (0)