Skip to content

Commit 3d0aeff

Browse files
committed
scattermapbox: implement placeholder logic
- so plotting that data-pt less traces do result in mapbox errors.
1 parent dd05c6e commit 3d0aeff

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

src/traces/scattermapbox/convert.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ module.exports = function convert(calcTrace) {
4242
symbol: symbol
4343
};
4444

45-
// early return is not visible
46-
if(!isVisible) return opts;
45+
// early return if not visible or placeholder
46+
if(!isVisible || calcTrace[0].placeholder) return opts;
4747

4848
// fill layer and line layer use the same coords
4949
var coords;

src/traces/scattermapbox/hover.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ module.exports = function hoverPoints(pointData, xval, yval) {
1919
xa = pointData.xa,
2020
ya = pointData.ya;
2121

22+
if(cd[0].placeholder) return;
23+
2224
// compute winding number about [-180, 180] globe
2325
var winding = (xval >= 0) ?
2426
Math.floor((xval + 180) / 360) :

test/jasmine/tests/scattermapbox_test.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,12 @@ describe('scattermapbox convert', function() {
244244

245245
function _convert(trace) {
246246
var gd = { data: [trace] };
247-
248247
Plots.supplyDefaults(gd);
249248

250249
var fullTrace = gd._fullData[0];
251-
var calcTrace = ScatterMapbox.calc(gd, fullTrace);
252-
calcTrace[0].trace = fullTrace;
250+
Plots.doCalcdata(gd, fullTrace);
253251

252+
var calcTrace = gd.calcdata[0];
254253
return convert(calcTrace);
255254
}
256255

@@ -353,9 +352,9 @@ describe('scattermapbox convert', function() {
353352

354353
assertVisibility(opts, ['none', 'visible', 'none', 'visible']);
355354

356-
var lineCoords = [[
355+
var lineCoords = [
357356
[10, 20], [20, 20], [30, 10], [20, 10], [10, 20]
358-
]];
357+
];
359358

360359
expect(opts.line.geojson.coordinates).toEqual(lineCoords, 'have correct line coords');
361360

@@ -413,6 +412,20 @@ describe('scattermapbox convert', function() {
413412
expect(radii).toBeCloseToArray([0, 1, 0], 'link features to correct stops');
414413
});
415414

415+
it('for input only blank pts', function() {
416+
var opts = _convert(Lib.extendFlat({}, base, {
417+
mode: 'lines',
418+
lon: ['', null],
419+
lat: [null, ''],
420+
fill: 'toself'
421+
}));
422+
423+
assertVisibility(opts, ['none', 'none', 'none', 'none']);
424+
425+
expect(opts.line.geojson.coordinates).toEqual([], 'have correct line coords');
426+
expect(opts.fill.geojson.coordinates).toEqual([], 'have correct fill coords');
427+
});
428+
416429
function assertVisibility(opts, expectations) {
417430
var actual = ['fill', 'line', 'circle', 'symbol'].map(function(l) {
418431
return opts[l].layout.visibility;

0 commit comments

Comments
 (0)