Skip to content

Commit

Permalink
lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Aug 29, 2024
1 parent c11a02a commit e609834
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
50 changes: 25 additions & 25 deletions src/plots/mapbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ exports.supplyLayoutDefaults = require('./layout_defaults');
var firstPlot = true;

exports.plot = function plot(gd) {
if (firstPlot) {
if(firstPlot) {
firstPlot = false;
Lib.warn(deprecationWarning);
}
Expand All @@ -62,25 +62,25 @@ exports.plot = function plot(gd) {
var calcData = gd.calcdata;
var mapboxIds = fullLayout._subplots[MAPBOX];

if (mapboxgl.version !== constants.requiredVersion) {
if(mapboxgl.version !== constants.requiredVersion) {
throw new Error(constants.wrongVersionErrorMsg);
}

var accessToken = findAccessToken(gd, mapboxIds);
mapboxgl.accessToken = accessToken;

for (var i = 0; i < mapboxIds.length; i++) {
for(var i = 0; i < mapboxIds.length; i++) {
var id = mapboxIds[i];
var subplotCalcData = getSubplotCalcData(calcData, MAPBOX, id);
var opts = fullLayout[id];
var mapbox = opts._subplot;

if (!mapbox) {
if(!mapbox) {
mapbox = new Mapbox(gd, id);
fullLayout[id]._subplot = mapbox;
}

if (!mapbox.viewInitial) {
if(!mapbox.viewInitial) {
mapbox.viewInitial = {
center: Lib.extendFlat({}, opts.center),
zoom: opts.zoom,
Expand All @@ -93,24 +93,24 @@ exports.plot = function plot(gd) {
}
};

exports.clean = function (newFullData, newFullLayout, oldFullData, oldFullLayout) {
exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
var oldMapboxKeys = oldFullLayout._subplots[MAPBOX] || [];

for (var i = 0; i < oldMapboxKeys.length; i++) {
for(var i = 0; i < oldMapboxKeys.length; i++) {
var oldMapboxKey = oldMapboxKeys[i];

if (!newFullLayout[oldMapboxKey] && !!oldFullLayout[oldMapboxKey]._subplot) {
if(!newFullLayout[oldMapboxKey] && !!oldFullLayout[oldMapboxKey]._subplot) {
oldFullLayout[oldMapboxKey]._subplot.destroy();
}
}
};

exports.toSVG = function (gd) {
exports.toSVG = function(gd) {
var fullLayout = gd._fullLayout;
var subplotIds = fullLayout._subplots[MAPBOX];
var size = fullLayout._size;

for (var i = 0; i < subplotIds.length; i++) {
for(var i = 0; i < subplotIds.length; i++) {
var opts = fullLayout[subplotIds[i]];
var domain = opts.domain;
var mapbox = opts._subplot;
Expand All @@ -132,7 +132,7 @@ exports.toSVG = function (gd) {

// Append logo if visible
var hidden = subplotDiv.select('.mapboxgl-ctrl-logo').node().offsetParent === null;
if (!hidden) {
if(!hidden) {
var logo = fullLayout._glimages.append('g');
logo.attr('transform', strTranslate(size.l + size.w * domain.x[0] + 10, size.t + size.h * (1 - domain.y[0]) - 31));
logo.append('path')
Expand Down Expand Up @@ -185,7 +185,7 @@ exports.toSVG = function (gd) {

// Break into multiple lines twice larger than domain
var maxWidth = size.w * (domain.x[1] - domain.x[0]);
if ((bBox.width > maxWidth / 2)) {
if((bBox.width > maxWidth / 2)) {
var multilineAttributions = attributions.split('|').join('<br>');
attributionText
.text(multilineAttributions)
Expand All @@ -209,7 +209,7 @@ exports.toSVG = function (gd) {

// Scale down if larger than domain
var scaleRatio = 1;
if ((bBox.width + 6) > maxWidth) scaleRatio = maxWidth / (bBox.width + 6);
if((bBox.width + 6) > maxWidth) scaleRatio = maxWidth / (bBox.width + 6);

var offset = [(size.l + size.w * domain.x[1]), (size.t + size.h * (1 - domain.y[0]))];
attributionGroup.attr('transform', strTranslate(offset[0], offset[1]) + strScale(scaleRatio));
Expand All @@ -223,7 +223,7 @@ function findAccessToken(gd, mapboxIds) {
var context = gd._context;

// special case for Mapbox Atlas users
if (context.mapboxAccessToken === '') return '';
if(context.mapboxAccessToken === '') return '';

var tokensUseful = [];
var tokensListed = [];
Expand All @@ -232,42 +232,42 @@ function findAccessToken(gd, mapboxIds) {

// Take the first token we find in a mapbox subplot.
// These default to the context value but may be overridden.
for (var i = 0; i < mapboxIds.length; i++) {
for(var i = 0; i < mapboxIds.length; i++) {
var opts = fullLayout[mapboxIds[i]];
var token = opts.accesstoken;

if (isStyleRequireAccessToken(opts.style)) {
if (token) {
if(isStyleRequireAccessToken(opts.style)) {
if(token) {
Lib.pushUnique(tokensUseful, token);
} else {
if (isStyleRequireAccessToken(opts._input.style)) {
if(isStyleRequireAccessToken(opts._input.style)) {
Lib.error('Uses Mapbox map style, but did not set an access token.');
hasOneSetMapboxStyle = true;
}
wontWork = true;
}
}

if (token) {
if(token) {
Lib.pushUnique(tokensListed, token);
}
}

if (wontWork) {
if(wontWork) {
var msg = hasOneSetMapboxStyle ?
constants.noAccessTokenErrorMsg :
constants.missingStyleErrorMsg;
Lib.error(msg);
throw new Error(msg);
}

if (tokensUseful.length) {
if (tokensUseful.length > 1) {
if(tokensUseful.length) {
if(tokensUseful.length > 1) {
Lib.warn(constants.multipleTokensErrorMsg);
}
return tokensUseful[0];
} else {
if (tokensListed.length) {
if(tokensListed.length) {
Lib.log([
'Listed mapbox access token(s)', tokensListed.join(','),
'but did not use a Mapbox map style, ignoring token(s).'
Expand All @@ -285,11 +285,11 @@ function isStyleRequireAccessToken(s) {
);
}

exports.updateFx = function (gd) {
exports.updateFx = function(gd) {
var fullLayout = gd._fullLayout;
var subplotIds = fullLayout._subplots[MAPBOX];

for (var i = 0; i < subplotIds.length; i++) {
for(var i = 0; i < subplotIds.length; i++) {
var subplotObj = fullLayout[subplotIds[i]]._subplot;
subplotObj.updateFx(fullLayout);
}
Expand Down
14 changes: 7 additions & 7 deletions src/traces/choroplethmapbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,28 @@ module.exports = {
eventData: require('../choropleth/event_data'),
selectPoints: require('../choropleth/select'),

styleOnSelect: function (_, cd) {
if (cd) {
styleOnSelect: function(_, cd) {
if(cd) {
var trace = cd[0].trace;
trace._glTrace.updateOnSelect(cd);
}
},

getBelow: function (trace, subplot) {
getBelow: function(trace, subplot) {
var mapLayers = subplot.getMapLayers();

// find layer just above top-most "water" layer
// that is not a plotly layer
for (var i = mapLayers.length - 2; i >= 0; i--) {
for(var i = mapLayers.length - 2; i >= 0; i--) {
var layerId = mapLayers[i].id;

if (typeof layerId === 'string' &&
if(typeof layerId === 'string' &&
layerId.indexOf('water') === 0
) {
for (var j = i + 1; j < mapLayers.length; j++) {
for(var j = i + 1; j < mapLayers.length; j++) {
layerId = mapLayers[j].id;

if (typeof layerId === 'string' &&
if(typeof layerId === 'string' &&
layerId.indexOf('plotly-') === -1
) {
return layerId;
Expand Down
6 changes: 3 additions & 3 deletions src/traces/densitymapbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ module.exports = {
hoverPoints: require('./hover'),
eventData: require('./event_data'),

getBelow: function (trace, subplot) {
getBelow: function(trace, subplot) {
var mapLayers = subplot.getMapLayers();

// find first layer with `type: 'symbol'`,
// that is not a plotly layer
for (var i = 0; i < mapLayers.length; i++) {
for(var i = 0; i < mapLayers.length; i++) {
var layer = mapLayers[i];
var layerId = layer.id;
if (layer.type === 'symbol' &&
if(layer.type === 'symbol' &&
typeof layerId === 'string' && layerId.indexOf('plotly-') === -1
) {
return layerId;
Expand Down
4 changes: 2 additions & 2 deletions src/traces/scattermapbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ module.exports = {
eventData: require('./event_data'),
selectPoints: require('./select'),

styleOnSelect: function (_, cd) {
if (cd) {
styleOnSelect: function(_, cd) {
if(cd) {
var trace = cd[0].trace;
trace._glTrace.update(cd);
}
Expand Down

0 comments on commit e609834

Please sign in to comment.