Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/traces/scattermapbox/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function makeCircleGeoJSON(calcTrace, hash) {
// Translate vals in trace arrayOk containers
// into a val-to-index hash object
function translate(props, key, val, index) {
if(!hash[key][val]) hash[key][val] = index;
if(hash[key][val] === undefined) hash[key][val] = index;
Copy link
Contributor Author

@etpinard etpinard Jul 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here hash[key][val] store indices in of arrayOk attribute. This check ⏫ was failing if a repeated value was found in the first marker.size or marker.color item as 0 is falsy.


props[key] = hash[key][val];
}
Expand Down
21 changes: 21 additions & 0 deletions test/jasmine/tests/scattermapbox_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ describe('scattermapbox calc', function() {
describe('scattermapbox convert', function() {
'use strict';

beforeAll(function() {
jasmine.addMatchers(customMatchers);
});

function _convert(trace) {
var gd = { data: [trace] };

Expand Down Expand Up @@ -397,6 +401,23 @@ describe('scattermapbox convert', function() {
});
});

it('for markers + circle bubbles traces with repeated values, should', function() {
var opts = _convert(Lib.extendFlat({}, base, {
lon: ['-96.796988', '-81.379236', '-85.311819', ''],
lat: ['32.776664', '28.538335', '35.047157', '' ],
marker: { size: ['5', '49', '5', ''] }
}));

expect(opts.circle.paint['circle-radius'].stops)
.toBeCloseTo2DArray([[0, 2.5], [1, 24.5]], 'not replicate stops');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

N.B. there are as many stop items as unique marker.size values.


var radii = opts.circle.geojson.features.map(function(f) {
return f.properties['circle-radius'];
});

expect(radii).toBeCloseToArray([0, 1, 0], 'link features to correct stops');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and the geojson feature properties are mapped to repeated stops.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💥! Sweet.

});

function assertVisibility(opts, expectations) {
var actual = ['fill', 'line', 'circle', 'symbol'].map(function(l) {
return opts[l].layout.visibility;
Expand Down