Skip to content

Commit 7ae437b

Browse files
authored
Merge pull request #747 from plotly/mapbox-repeated-vals
Fix repeated val case in scattermapbox convert step
2 parents 2d8a0da + f94accc commit 7ae437b

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/traces/scattermapbox/convert.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ function makeCircleGeoJSON(calcTrace, hash) {
184184
// Translate vals in trace arrayOk containers
185185
// into a val-to-index hash object
186186
function translate(props, key, val, index) {
187-
if(!hash[key][val]) hash[key][val] = index;
187+
if(hash[key][val] === undefined) hash[key][val] = index;
188188

189189
props[key] = hash[key][val];
190190
}

test/jasmine/tests/scattermapbox_test.js

+21
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ describe('scattermapbox calc', function() {
243243
describe('scattermapbox convert', function() {
244244
'use strict';
245245

246+
beforeAll(function() {
247+
jasmine.addMatchers(customMatchers);
248+
});
249+
246250
function _convert(trace) {
247251
var gd = { data: [trace] };
248252

@@ -397,6 +401,23 @@ describe('scattermapbox convert', function() {
397401
});
398402
});
399403

404+
it('for markers + circle bubbles traces with repeated values, should', function() {
405+
var opts = _convert(Lib.extendFlat({}, base, {
406+
lon: ['-96.796988', '-81.379236', '-85.311819', ''],
407+
lat: ['32.776664', '28.538335', '35.047157', '' ],
408+
marker: { size: ['5', '49', '5', ''] }
409+
}));
410+
411+
expect(opts.circle.paint['circle-radius'].stops)
412+
.toBeCloseTo2DArray([[0, 2.5], [1, 24.5]], 'not replicate stops');
413+
414+
var radii = opts.circle.geojson.features.map(function(f) {
415+
return f.properties['circle-radius'];
416+
});
417+
418+
expect(radii).toBeCloseToArray([0, 1, 0], 'link features to correct stops');
419+
});
420+
400421
function assertVisibility(opts, expectations) {
401422
var actual = ['fill', 'line', 'circle', 'symbol'].map(function(l) {
402423
return opts[l].layout.visibility;

0 commit comments

Comments
 (0)