From 1b46461593a5de4410b80ef4b1c0c9ae7b4898b4 Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi Date: Mon, 12 Aug 2024 12:12:41 -0400 Subject: [PATCH 1/8] add deprecation warning for mapbox traces and subplot --- src/plots/mapbox/index.js | 6 ++++++ src/traces/choroplethmapbox/index.js | 6 ++++++ src/traces/densitymapbox/index.js | 6 ++++++ src/traces/scattermapbox/index.js | 6 ++++++ test/plot-schema.json | 12 ++++++------ 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/plots/mapbox/index.js b/src/plots/mapbox/index.js index 1dfb85b75fa..867f9457767 100644 --- a/src/plots/mapbox/index.js +++ b/src/plots/mapbox/index.js @@ -25,12 +25,18 @@ exports.idRoot = MAPBOX; exports.idRegex = exports.attrRegex = Lib.counterRegex(MAPBOX); +var deprecationWarning = [ + 'mapbox subplots and traces are deprecated!', + 'Please consider switching to `map` subplots and traces.' +].join(' '); + exports.attributes = { subplot: { valType: 'subplotid', dflt: 'mapbox', editType: 'calc', description: [ + deprecationWarning, 'Sets a reference between this trace\'s data coordinates and', 'a mapbox subplot.', 'If *mapbox* (the default value), the data refer to `layout.mapbox`.', diff --git a/src/traces/choroplethmapbox/index.js b/src/traces/choroplethmapbox/index.js index 5c1f1ce8f43..b5d770277f7 100644 --- a/src/traces/choroplethmapbox/index.js +++ b/src/traces/choroplethmapbox/index.js @@ -1,5 +1,10 @@ 'use strict'; +var deprecationWarning = [ + '*choroplethmapbox* trace is deprecated!', + 'Please consider switching to the *scattermap* trace type and `map` subplots.' +].join(' '); + module.exports = { attributes: require('./attributes'), supplyDefaults: require('./defaults'), @@ -48,6 +53,7 @@ module.exports = { meta: { hr_name: 'choropleth_mapbox', description: [ + deprecationWarning, 'GeoJSON features to be filled are set in `geojson`', 'The data that describes the choropleth value-to-color mapping', 'is set in `locations` and `z`.' diff --git a/src/traces/densitymapbox/index.js b/src/traces/densitymapbox/index.js index bda9660b475..80fc5539084 100644 --- a/src/traces/densitymapbox/index.js +++ b/src/traces/densitymapbox/index.js @@ -1,5 +1,10 @@ 'use strict'; +var deprecationWarning = [ + '*densitymapbox* trace is deprecated!', + 'Please consider switching to the *scattermap* trace type and `map` subplots.' +].join(' '); + module.exports = { attributes: require('./attributes'), supplyDefaults: require('./defaults'), @@ -33,6 +38,7 @@ module.exports = { meta: { hr_name: 'density_mapbox', description: [ + deprecationWarning, 'Draws a bivariate kernel density estimation with a Gaussian kernel', 'from `lon` and `lat` coordinates and optional `z` values using a colorscale.' ].join(' ') diff --git a/src/traces/scattermapbox/index.js b/src/traces/scattermapbox/index.js index 5a93d8e2c70..03c42886939 100644 --- a/src/traces/scattermapbox/index.js +++ b/src/traces/scattermapbox/index.js @@ -1,5 +1,10 @@ 'use strict'; +var deprecationWarning = [ + '*scattermapbox* trace is deprecated!', + 'Please consider switching to the *scattermap* trace type and `map` subplots.' +].join(' '); + module.exports = { attributes: require('./attributes'), supplyDefaults: require('./defaults'), @@ -25,6 +30,7 @@ module.exports = { meta: { hrName: 'scatter_mapbox', description: [ + deprecationWarning, 'The data visualized as scatter point, lines or marker symbols', 'on a Mapbox GL geographic map', 'is provided by longitude/latitude pairs in `lon` and `lat`.' diff --git a/test/plot-schema.json b/test/plot-schema.json index a40625eeaca..588054cc86b 100644 --- a/test/plot-schema.json +++ b/test/plot-schema.json @@ -29751,7 +29751,7 @@ } }, "subplot": { - "description": "Sets a reference between this trace's data coordinates and a mapbox subplot. If *mapbox* (the default value), the data refer to `layout.mapbox`. If *mapbox2*, the data refer to `layout.mapbox2`, and so on.", + "description": "mapbox subplots and traces are deprecated! Please consider switching to `map` subplots and traces. Sets a reference between this trace's data coordinates and a mapbox subplot. If *mapbox* (the default value), the data refer to `layout.mapbox`. If *mapbox2*, the data refer to `layout.mapbox2`, and so on.", "dflt": "mapbox", "editType": "calc", "valType": "subplotid" @@ -29865,7 +29865,7 @@ "showLegend" ], "meta": { - "description": "GeoJSON features to be filled are set in `geojson` The data that describes the choropleth value-to-color mapping is set in `locations` and `z`.", + "description": "*choroplethmapbox* trace is deprecated! Please consider switching to the *scattermap* trace type and `map` subplots. GeoJSON features to be filled are set in `geojson` The data that describes the choropleth value-to-color mapping is set in `locations` and `z`.", "hr_name": "choropleth_mapbox" }, "type": "choroplethmapbox" @@ -37184,7 +37184,7 @@ } }, "subplot": { - "description": "Sets a reference between this trace's data coordinates and a mapbox subplot. If *mapbox* (the default value), the data refer to `layout.mapbox`. If *mapbox2*, the data refer to `layout.mapbox2`, and so on.", + "description": "mapbox subplots and traces are deprecated! Please consider switching to `map` subplots and traces. Sets a reference between this trace's data coordinates and a mapbox subplot. If *mapbox* (the default value), the data refer to `layout.mapbox`. If *mapbox2*, the data refer to `layout.mapbox2`, and so on.", "dflt": "mapbox", "editType": "calc", "valType": "subplotid" @@ -37282,7 +37282,7 @@ "showLegend" ], "meta": { - "description": "Draws a bivariate kernel density estimation with a Gaussian kernel from `lon` and `lat` coordinates and optional `z` values using a colorscale.", + "description": "*densitymapbox* trace is deprecated! Please consider switching to the *scattermap* trace type and `map` subplots. Draws a bivariate kernel density estimation with a Gaussian kernel from `lon` and `lat` coordinates and optional `z` values using a colorscale.", "hr_name": "density_mapbox" }, "type": "densitymapbox" @@ -80422,7 +80422,7 @@ } }, "subplot": { - "description": "Sets a reference between this trace's data coordinates and a mapbox subplot. If *mapbox* (the default value), the data refer to `layout.mapbox`. If *mapbox2*, the data refer to `layout.mapbox2`, and so on.", + "description": "mapbox subplots and traces are deprecated! Please consider switching to `map` subplots and traces. Sets a reference between this trace's data coordinates and a mapbox subplot. If *mapbox* (the default value), the data refer to `layout.mapbox`. If *mapbox2*, the data refer to `layout.mapbox2`, and so on.", "dflt": "mapbox", "editType": "calc", "valType": "subplotid" @@ -80580,7 +80580,7 @@ "scatter-like" ], "meta": { - "description": "The data visualized as scatter point, lines or marker symbols on a Mapbox GL geographic map is provided by longitude/latitude pairs in `lon` and `lat`.", + "description": "*scattermapbox* trace is deprecated! Please consider switching to the *scattermap* trace type and `map` subplots. The data visualized as scatter point, lines or marker symbols on a Mapbox GL geographic map is provided by longitude/latitude pairs in `lon` and `lat`.", "hrName": "scatter_mapbox" }, "type": "scattermapbox" From 7013fbba40c13df671701e6beb2639795ef6451a Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi Date: Mon, 12 Aug 2024 12:39:48 -0400 Subject: [PATCH 2/8] add draftlog --- draftlogs/7087_change.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 draftlogs/7087_change.md diff --git a/draftlogs/7087_change.md b/draftlogs/7087_change.md new file mode 100644 index 00000000000..6a47e9c27c7 --- /dev/null +++ b/draftlogs/7087_change.md @@ -0,0 +1 @@ + - deprecate mapbox traces and mapbox subplot [[#7087](https://github.com/plotly/plotly.js/pull/7087)] From 2b51c41d77991c2792233dd3b7ca507c0895d95e Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi Date: Tue, 13 Aug 2024 11:30:28 -0400 Subject: [PATCH 3/8] fix trace names --- src/traces/choroplethmapbox/index.js | 2 +- src/traces/densitymapbox/index.js | 2 +- test/plot-schema.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/traces/choroplethmapbox/index.js b/src/traces/choroplethmapbox/index.js index b5d770277f7..87062325e99 100644 --- a/src/traces/choroplethmapbox/index.js +++ b/src/traces/choroplethmapbox/index.js @@ -2,7 +2,7 @@ var deprecationWarning = [ '*choroplethmapbox* trace is deprecated!', - 'Please consider switching to the *scattermap* trace type and `map` subplots.' + 'Please consider switching to the *choroplethmap* trace type and `map` subplots.' ].join(' '); module.exports = { diff --git a/src/traces/densitymapbox/index.js b/src/traces/densitymapbox/index.js index 80fc5539084..f82c5726400 100644 --- a/src/traces/densitymapbox/index.js +++ b/src/traces/densitymapbox/index.js @@ -2,7 +2,7 @@ var deprecationWarning = [ '*densitymapbox* trace is deprecated!', - 'Please consider switching to the *scattermap* trace type and `map` subplots.' + 'Please consider switching to the *densitymap* trace type and `map` subplots.' ].join(' '); module.exports = { diff --git a/test/plot-schema.json b/test/plot-schema.json index 588054cc86b..c1eac35c9c2 100644 --- a/test/plot-schema.json +++ b/test/plot-schema.json @@ -29865,7 +29865,7 @@ "showLegend" ], "meta": { - "description": "*choroplethmapbox* trace is deprecated! Please consider switching to the *scattermap* trace type and `map` subplots. GeoJSON features to be filled are set in `geojson` The data that describes the choropleth value-to-color mapping is set in `locations` and `z`.", + "description": "*choroplethmapbox* trace is deprecated! Please consider switching to the *choroplethmap* trace type and `map` subplots. GeoJSON features to be filled are set in `geojson` The data that describes the choropleth value-to-color mapping is set in `locations` and `z`.", "hr_name": "choropleth_mapbox" }, "type": "choroplethmapbox" @@ -37282,7 +37282,7 @@ "showLegend" ], "meta": { - "description": "*densitymapbox* trace is deprecated! Please consider switching to the *scattermap* trace type and `map` subplots. Draws a bivariate kernel density estimation with a Gaussian kernel from `lon` and `lat` coordinates and optional `z` values using a colorscale.", + "description": "*densitymapbox* trace is deprecated! Please consider switching to the *densitymap* trace type and `map` subplots. Draws a bivariate kernel density estimation with a Gaussian kernel from `lon` and `lat` coordinates and optional `z` values using a colorscale.", "hr_name": "density_mapbox" }, "type": "densitymapbox" From 08222545fc96ea70e3e9e8238d52f227b4cf2301 Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi Date: Tue, 13 Aug 2024 12:08:49 -0400 Subject: [PATCH 4/8] add console.warn when using mapbox subplots --- src/plots/mapbox/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/plots/mapbox/index.js b/src/plots/mapbox/index.js index 867f9457767..3168919f761 100644 --- a/src/plots/mapbox/index.js +++ b/src/plots/mapbox/index.js @@ -49,7 +49,14 @@ exports.layoutAttributes = require('./layout_attributes'); exports.supplyLayoutDefaults = require('./layout_defaults'); +var firstPlot = true; + exports.plot = function plot(gd) { + if(firstPlot) { + firstPlot = false; + console.warn(deprecationWarning); + } + var fullLayout = gd._fullLayout; var calcData = gd.calcdata; var mapboxIds = fullLayout._subplots[MAPBOX]; From 6a906bbf4ed1a8fb38c6870c0fc764be7e8db680 Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi Date: Tue, 13 Aug 2024 12:23:49 -0400 Subject: [PATCH 5/8] use Lib.warn instead of console.log --- src/plots/mapbox/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plots/mapbox/index.js b/src/plots/mapbox/index.js index 3168919f761..c70413851d8 100644 --- a/src/plots/mapbox/index.js +++ b/src/plots/mapbox/index.js @@ -54,7 +54,7 @@ var firstPlot = true; exports.plot = function plot(gd) { if(firstPlot) { firstPlot = false; - console.warn(deprecationWarning); + Lib.warn(deprecationWarning); } var fullLayout = gd._fullLayout; From 4cbe129032c2ff9cb94d7b382f870063d17a39e2 Mon Sep 17 00:00:00 2001 From: Nathan Date: Thu, 29 Aug 2024 10:12:44 -0400 Subject: [PATCH 6/8] Add link to migration guide to deprecation warning --- src/plots/mapbox/index.js | 133 ++++++++++++++------------- src/traces/choroplethmapbox/index.js | 19 ++-- src/traces/densitymapbox/index.js | 9 +- src/traces/scattermapbox/index.js | 7 +- 4 files changed, 86 insertions(+), 82 deletions(-) diff --git a/src/plots/mapbox/index.js b/src/plots/mapbox/index.js index c70413851d8..f03ca62ac03 100644 --- a/src/plots/mapbox/index.js +++ b/src/plots/mapbox/index.js @@ -27,7 +27,8 @@ exports.idRegex = exports.attrRegex = Lib.counterRegex(MAPBOX); var deprecationWarning = [ 'mapbox subplots and traces are deprecated!', - 'Please consider switching to `map` subplots and traces.' + 'Please consider switching to `map` subplots and traces.', + 'Learn more at: https://plotly.com/javascript/maplibre-migration/' ].join(' '); exports.attributes = { @@ -52,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); } @@ -61,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, @@ -92,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; @@ -131,65 +132,65 @@ 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') - .attr('d', constants.mapboxLogo.path0) - .style({ - opacity: 0.9, - fill: '#ffffff', - 'enable-background': 'new' - }); + .attr('d', constants.mapboxLogo.path0) + .style({ + opacity: 0.9, + fill: '#ffffff', + 'enable-background': 'new' + }); logo.append('path') - .attr('d', constants.mapboxLogo.path1) - .style('opacity', 0.35) - .style('enable-background', 'new'); + .attr('d', constants.mapboxLogo.path1) + .style('opacity', 0.35) + .style('enable-background', 'new'); logo.append('path') - .attr('d', constants.mapboxLogo.path2) - .style('opacity', 0.35) - .style('enable-background', 'new'); + .attr('d', constants.mapboxLogo.path2) + .style('opacity', 0.35) + .style('enable-background', 'new'); logo.append('polygon') - .attr('points', constants.mapboxLogo.polygon) - .style({ - opacity: 0.9, - fill: '#ffffff', - 'enable-background': 'new' - }); + .attr('points', constants.mapboxLogo.polygon) + .style({ + opacity: 0.9, + fill: '#ffffff', + 'enable-background': 'new' + }); } // Add attributions var attributions = subplotDiv - .select('.mapboxgl-ctrl-attrib').text() - .replace('Improve this map', ''); + .select('.mapboxgl-ctrl-attrib').text() + .replace('Improve this map', ''); var attributionGroup = fullLayout._glimages.append('g'); var attributionText = attributionGroup.append('text'); attributionText - .text(attributions) - .classed('static-attribution', true) - .attr({ - 'font-size': 12, - 'font-family': 'Arial', - color: 'rgba(0, 0, 0, 0.75)', - 'text-anchor': 'end', - 'data-unformatted': attributions - }); + .text(attributions) + .classed('static-attribution', true) + .attr({ + 'font-size': 12, + 'font-family': 'Arial', + color: 'rgba(0, 0, 0, 0.75)', + 'text-anchor': 'end', + 'data-unformatted': attributions + }); var bBox = Drawing.bBox(attributionText.node()); // 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('
'); attributionText - .text(multilineAttributions) - .attr('data-unformatted', multilineAttributions) - .call(svgTextUtils.convertToTspans, gd); + .text(multilineAttributions) + .attr('data-unformatted', multilineAttributions) + .call(svgTextUtils.convertToTspans, gd); bBox = Drawing.bBox(attributionText.node()); } @@ -197,18 +198,18 @@ exports.toSVG = function(gd) { // Draw white rectangle behind text attributionGroup - .insert('rect', '.static-attribution') - .attr({ - x: -bBox.width - 6, - y: -bBox.height - 3, - width: bBox.width + 6, - height: bBox.height + 3, - fill: 'rgba(255, 255, 255, 0.75)' - }); + .insert('rect', '.static-attribution') + .attr({ + x: -bBox.width - 6, + y: -bBox.height - 3, + width: bBox.width + 6, + height: bBox.height + 3, + fill: 'rgba(255, 255, 255, 0.75)' + }); // 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)); @@ -222,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 = []; @@ -231,15 +232,15 @@ 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; } @@ -247,12 +248,12 @@ function findAccessToken(gd, mapboxIds) { } } - if(token) { + if (token) { Lib.pushUnique(tokensListed, token); } } - if(wontWork) { + if (wontWork) { var msg = hasOneSetMapboxStyle ? constants.noAccessTokenErrorMsg : constants.missingStyleErrorMsg; @@ -260,13 +261,13 @@ function findAccessToken(gd, mapboxIds) { 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).' @@ -284,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); } diff --git a/src/traces/choroplethmapbox/index.js b/src/traces/choroplethmapbox/index.js index 87062325e99..1b34359a5d5 100644 --- a/src/traces/choroplethmapbox/index.js +++ b/src/traces/choroplethmapbox/index.js @@ -2,7 +2,8 @@ var deprecationWarning = [ '*choroplethmapbox* trace is deprecated!', - 'Please consider switching to the *choroplethmap* trace type and `map` subplots.' + 'Please consider switching to the *choroplethmap* trace type and `map` subplots.', + 'Learn more at: https://plotly.com/javascript/maplibre-migration/' ].join(' '); module.exports = { @@ -15,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; diff --git a/src/traces/densitymapbox/index.js b/src/traces/densitymapbox/index.js index f82c5726400..a5d8d9d009e 100644 --- a/src/traces/densitymapbox/index.js +++ b/src/traces/densitymapbox/index.js @@ -2,7 +2,8 @@ var deprecationWarning = [ '*densitymapbox* trace is deprecated!', - 'Please consider switching to the *densitymap* trace type and `map` subplots.' + 'Please consider switching to the *densitymap* trace type and `map` subplots.', + 'Learn more at: https://plotly.com/javascript/maplibre-migration/' ].join(' '); module.exports = { @@ -15,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; diff --git a/src/traces/scattermapbox/index.js b/src/traces/scattermapbox/index.js index 03c42886939..803223548e5 100644 --- a/src/traces/scattermapbox/index.js +++ b/src/traces/scattermapbox/index.js @@ -2,7 +2,8 @@ var deprecationWarning = [ '*scattermapbox* trace is deprecated!', - 'Please consider switching to the *scattermap* trace type and `map` subplots.' + 'Please consider switching to the *scattermap* trace type and `map` subplots.', + 'Learn more at: https://plotly.com/javascript/maplibre-migration/' ].join(' '); module.exports = { @@ -16,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); } From c11a02a4b23de6da354f69948cb5a2a61101b4b1 Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi Date: Thu, 29 Aug 2024 10:30:47 -0400 Subject: [PATCH 7/8] update plot schema --- test/plot-schema.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/plot-schema.json b/test/plot-schema.json index c1eac35c9c2..289445a355f 100644 --- a/test/plot-schema.json +++ b/test/plot-schema.json @@ -29751,7 +29751,7 @@ } }, "subplot": { - "description": "mapbox subplots and traces are deprecated! Please consider switching to `map` subplots and traces. Sets a reference between this trace's data coordinates and a mapbox subplot. If *mapbox* (the default value), the data refer to `layout.mapbox`. If *mapbox2*, the data refer to `layout.mapbox2`, and so on.", + "description": "mapbox subplots and traces are deprecated! Please consider switching to `map` subplots and traces. Learn more at: https://plotly.com/javascript/maplibre-migration/ Sets a reference between this trace's data coordinates and a mapbox subplot. If *mapbox* (the default value), the data refer to `layout.mapbox`. If *mapbox2*, the data refer to `layout.mapbox2`, and so on.", "dflt": "mapbox", "editType": "calc", "valType": "subplotid" @@ -29865,7 +29865,7 @@ "showLegend" ], "meta": { - "description": "*choroplethmapbox* trace is deprecated! Please consider switching to the *choroplethmap* trace type and `map` subplots. GeoJSON features to be filled are set in `geojson` The data that describes the choropleth value-to-color mapping is set in `locations` and `z`.", + "description": "*choroplethmapbox* trace is deprecated! Please consider switching to the *choroplethmap* trace type and `map` subplots. Learn more at: https://plotly.com/javascript/maplibre-migration/ GeoJSON features to be filled are set in `geojson` The data that describes the choropleth value-to-color mapping is set in `locations` and `z`.", "hr_name": "choropleth_mapbox" }, "type": "choroplethmapbox" @@ -37184,7 +37184,7 @@ } }, "subplot": { - "description": "mapbox subplots and traces are deprecated! Please consider switching to `map` subplots and traces. Sets a reference between this trace's data coordinates and a mapbox subplot. If *mapbox* (the default value), the data refer to `layout.mapbox`. If *mapbox2*, the data refer to `layout.mapbox2`, and so on.", + "description": "mapbox subplots and traces are deprecated! Please consider switching to `map` subplots and traces. Learn more at: https://plotly.com/javascript/maplibre-migration/ Sets a reference between this trace's data coordinates and a mapbox subplot. If *mapbox* (the default value), the data refer to `layout.mapbox`. If *mapbox2*, the data refer to `layout.mapbox2`, and so on.", "dflt": "mapbox", "editType": "calc", "valType": "subplotid" @@ -37282,7 +37282,7 @@ "showLegend" ], "meta": { - "description": "*densitymapbox* trace is deprecated! Please consider switching to the *densitymap* trace type and `map` subplots. Draws a bivariate kernel density estimation with a Gaussian kernel from `lon` and `lat` coordinates and optional `z` values using a colorscale.", + "description": "*densitymapbox* trace is deprecated! Please consider switching to the *densitymap* trace type and `map` subplots. Learn more at: https://plotly.com/javascript/maplibre-migration/ Draws a bivariate kernel density estimation with a Gaussian kernel from `lon` and `lat` coordinates and optional `z` values using a colorscale.", "hr_name": "density_mapbox" }, "type": "densitymapbox" @@ -80422,7 +80422,7 @@ } }, "subplot": { - "description": "mapbox subplots and traces are deprecated! Please consider switching to `map` subplots and traces. Sets a reference between this trace's data coordinates and a mapbox subplot. If *mapbox* (the default value), the data refer to `layout.mapbox`. If *mapbox2*, the data refer to `layout.mapbox2`, and so on.", + "description": "mapbox subplots and traces are deprecated! Please consider switching to `map` subplots and traces. Learn more at: https://plotly.com/javascript/maplibre-migration/ Sets a reference between this trace's data coordinates and a mapbox subplot. If *mapbox* (the default value), the data refer to `layout.mapbox`. If *mapbox2*, the data refer to `layout.mapbox2`, and so on.", "dflt": "mapbox", "editType": "calc", "valType": "subplotid" @@ -80580,7 +80580,7 @@ "scatter-like" ], "meta": { - "description": "*scattermapbox* trace is deprecated! Please consider switching to the *scattermap* trace type and `map` subplots. The data visualized as scatter point, lines or marker symbols on a Mapbox GL geographic map is provided by longitude/latitude pairs in `lon` and `lat`.", + "description": "*scattermapbox* trace is deprecated! Please consider switching to the *scattermap* trace type and `map` subplots. Learn more at: https://plotly.com/javascript/maplibre-migration/ The data visualized as scatter point, lines or marker symbols on a Mapbox GL geographic map is provided by longitude/latitude pairs in `lon` and `lat`.", "hrName": "scatter_mapbox" }, "type": "scattermapbox" From e60983484b72a10a26bc463fb078fc88048befac Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi Date: Thu, 29 Aug 2024 10:31:21 -0400 Subject: [PATCH 8/8] lint fix --- src/plots/mapbox/index.js | 50 ++++++++++++++-------------- src/traces/choroplethmapbox/index.js | 14 ++++---- src/traces/densitymapbox/index.js | 6 ++-- src/traces/scattermapbox/index.js | 4 +-- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/plots/mapbox/index.js b/src/plots/mapbox/index.js index f03ca62ac03..2ec253b5411 100644 --- a/src/plots/mapbox/index.js +++ b/src/plots/mapbox/index.js @@ -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); } @@ -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, @@ -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; @@ -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') @@ -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('
'); attributionText .text(multilineAttributions) @@ -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)); @@ -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 = []; @@ -232,15 +232,15 @@ 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; } @@ -248,12 +248,12 @@ function findAccessToken(gd, mapboxIds) { } } - if (token) { + if(token) { Lib.pushUnique(tokensListed, token); } } - if (wontWork) { + if(wontWork) { var msg = hasOneSetMapboxStyle ? constants.noAccessTokenErrorMsg : constants.missingStyleErrorMsg; @@ -261,13 +261,13 @@ function findAccessToken(gd, mapboxIds) { 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).' @@ -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); } diff --git a/src/traces/choroplethmapbox/index.js b/src/traces/choroplethmapbox/index.js index 1b34359a5d5..2fa2fae0dcf 100644 --- a/src/traces/choroplethmapbox/index.js +++ b/src/traces/choroplethmapbox/index.js @@ -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; diff --git a/src/traces/densitymapbox/index.js b/src/traces/densitymapbox/index.js index a5d8d9d009e..7e334b0ce61 100644 --- a/src/traces/densitymapbox/index.js +++ b/src/traces/densitymapbox/index.js @@ -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; diff --git a/src/traces/scattermapbox/index.js b/src/traces/scattermapbox/index.js index 803223548e5..f1b5b707398 100644 --- a/src/traces/scattermapbox/index.js +++ b/src/traces/scattermapbox/index.js @@ -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); }