Skip to content

Commit 39b5929

Browse files
authored
Merge pull request #7087 from plotly/deprecate-mapbox
add deprecation warning for mapbox traces and mapbox subplot
2 parents 0b70a9c + e609834 commit 39b5929

File tree

6 files changed

+83
-47
lines changed

6 files changed

+83
-47
lines changed

draftlogs/7087_change.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- deprecate mapbox traces and mapbox subplot [[#7087](https://github.com/plotly/plotly.js/pull/7087)]

src/plots/mapbox/index.js

+54-40
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,19 @@ exports.idRoot = MAPBOX;
2525

2626
exports.idRegex = exports.attrRegex = Lib.counterRegex(MAPBOX);
2727

28+
var deprecationWarning = [
29+
'mapbox subplots and traces are deprecated!',
30+
'Please consider switching to `map` subplots and traces.',
31+
'Learn more at: https://plotly.com/javascript/maplibre-migration/'
32+
].join(' ');
33+
2834
exports.attributes = {
2935
subplot: {
3036
valType: 'subplotid',
3137
dflt: 'mapbox',
3238
editType: 'calc',
3339
description: [
40+
deprecationWarning,
3441
'Sets a reference between this trace\'s data coordinates and',
3542
'a mapbox subplot.',
3643
'If *mapbox* (the default value), the data refer to `layout.mapbox`.',
@@ -43,7 +50,14 @@ exports.layoutAttributes = require('./layout_attributes');
4350

4451
exports.supplyLayoutDefaults = require('./layout_defaults');
4552

53+
var firstPlot = true;
54+
4655
exports.plot = function plot(gd) {
56+
if(firstPlot) {
57+
firstPlot = false;
58+
Lib.warn(deprecationWarning);
59+
}
60+
4761
var fullLayout = gd._fullLayout;
4862
var calcData = gd.calcdata;
4963
var mapboxIds = fullLayout._subplots[MAPBOX];
@@ -122,50 +136,50 @@ exports.toSVG = function(gd) {
122136
var logo = fullLayout._glimages.append('g');
123137
logo.attr('transform', strTranslate(size.l + size.w * domain.x[0] + 10, size.t + size.h * (1 - domain.y[0]) - 31));
124138
logo.append('path')
125-
.attr('d', constants.mapboxLogo.path0)
126-
.style({
127-
opacity: 0.9,
128-
fill: '#ffffff',
129-
'enable-background': 'new'
130-
});
139+
.attr('d', constants.mapboxLogo.path0)
140+
.style({
141+
opacity: 0.9,
142+
fill: '#ffffff',
143+
'enable-background': 'new'
144+
});
131145

132146
logo.append('path')
133-
.attr('d', constants.mapboxLogo.path1)
134-
.style('opacity', 0.35)
135-
.style('enable-background', 'new');
147+
.attr('d', constants.mapboxLogo.path1)
148+
.style('opacity', 0.35)
149+
.style('enable-background', 'new');
136150

137151
logo.append('path')
138-
.attr('d', constants.mapboxLogo.path2)
139-
.style('opacity', 0.35)
140-
.style('enable-background', 'new');
152+
.attr('d', constants.mapboxLogo.path2)
153+
.style('opacity', 0.35)
154+
.style('enable-background', 'new');
141155

142156
logo.append('polygon')
143-
.attr('points', constants.mapboxLogo.polygon)
144-
.style({
145-
opacity: 0.9,
146-
fill: '#ffffff',
147-
'enable-background': 'new'
148-
});
157+
.attr('points', constants.mapboxLogo.polygon)
158+
.style({
159+
opacity: 0.9,
160+
fill: '#ffffff',
161+
'enable-background': 'new'
162+
});
149163
}
150164

151165
// Add attributions
152166
var attributions = subplotDiv
153-
.select('.mapboxgl-ctrl-attrib').text()
154-
.replace('Improve this map', '');
167+
.select('.mapboxgl-ctrl-attrib').text()
168+
.replace('Improve this map', '');
155169

156170
var attributionGroup = fullLayout._glimages.append('g');
157171

158172
var attributionText = attributionGroup.append('text');
159173
attributionText
160-
.text(attributions)
161-
.classed('static-attribution', true)
162-
.attr({
163-
'font-size': 12,
164-
'font-family': 'Arial',
165-
color: 'rgba(0, 0, 0, 0.75)',
166-
'text-anchor': 'end',
167-
'data-unformatted': attributions
168-
});
174+
.text(attributions)
175+
.classed('static-attribution', true)
176+
.attr({
177+
'font-size': 12,
178+
'font-family': 'Arial',
179+
color: 'rgba(0, 0, 0, 0.75)',
180+
'text-anchor': 'end',
181+
'data-unformatted': attributions
182+
});
169183

170184
var bBox = Drawing.bBox(attributionText.node());
171185

@@ -174,24 +188,24 @@ exports.toSVG = function(gd) {
174188
if((bBox.width > maxWidth / 2)) {
175189
var multilineAttributions = attributions.split('|').join('<br>');
176190
attributionText
177-
.text(multilineAttributions)
178-
.attr('data-unformatted', multilineAttributions)
179-
.call(svgTextUtils.convertToTspans, gd);
191+
.text(multilineAttributions)
192+
.attr('data-unformatted', multilineAttributions)
193+
.call(svgTextUtils.convertToTspans, gd);
180194

181195
bBox = Drawing.bBox(attributionText.node());
182196
}
183197
attributionText.attr('transform', strTranslate(-3, -bBox.height + 8));
184198

185199
// Draw white rectangle behind text
186200
attributionGroup
187-
.insert('rect', '.static-attribution')
188-
.attr({
189-
x: -bBox.width - 6,
190-
y: -bBox.height - 3,
191-
width: bBox.width + 6,
192-
height: bBox.height + 3,
193-
fill: 'rgba(255, 255, 255, 0.75)'
194-
});
201+
.insert('rect', '.static-attribution')
202+
.attr({
203+
x: -bBox.width - 6,
204+
y: -bBox.height - 3,
205+
width: bBox.width + 6,
206+
height: bBox.height + 3,
207+
fill: 'rgba(255, 255, 255, 0.75)'
208+
});
195209

196210
// Scale down if larger than domain
197211
var scaleRatio = 1;

src/traces/choroplethmapbox/index.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
'use strict';
22

3+
var deprecationWarning = [
4+
'*choroplethmapbox* trace is deprecated!',
5+
'Please consider switching to the *choroplethmap* trace type and `map` subplots.',
6+
'Learn more at: https://plotly.com/javascript/maplibre-migration/'
7+
].join(' ');
8+
39
module.exports = {
410
attributes: require('./attributes'),
511
supplyDefaults: require('./defaults'),
@@ -27,7 +33,7 @@ module.exports = {
2733

2834
if(typeof layerId === 'string' &&
2935
layerId.indexOf('water') === 0
30-
) {
36+
) {
3137
for(var j = i + 1; j < mapLayers.length; j++) {
3238
layerId = mapLayers[j].id;
3339

@@ -48,6 +54,7 @@ module.exports = {
4854
meta: {
4955
hr_name: 'choropleth_mapbox',
5056
description: [
57+
deprecationWarning,
5158
'GeoJSON features to be filled are set in `geojson`',
5259
'The data that describes the choropleth value-to-color mapping',
5360
'is set in `locations` and `z`.'

src/traces/densitymapbox/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
'use strict';
22

3+
var deprecationWarning = [
4+
'*densitymapbox* trace is deprecated!',
5+
'Please consider switching to the *densitymap* trace type and `map` subplots.',
6+
'Learn more at: https://plotly.com/javascript/maplibre-migration/'
7+
].join(' ');
8+
39
module.exports = {
410
attributes: require('./attributes'),
511
supplyDefaults: require('./defaults'),
@@ -33,6 +39,7 @@ module.exports = {
3339
meta: {
3440
hr_name: 'density_mapbox',
3541
description: [
42+
deprecationWarning,
3643
'Draws a bivariate kernel density estimation with a Gaussian kernel',
3744
'from `lon` and `lat` coordinates and optional `z` values using a colorscale.'
3845
].join(' ')

src/traces/scattermapbox/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
'use strict';
22

3+
var deprecationWarning = [
4+
'*scattermapbox* trace is deprecated!',
5+
'Please consider switching to the *scattermap* trace type and `map` subplots.',
6+
'Learn more at: https://plotly.com/javascript/maplibre-migration/'
7+
].join(' ');
8+
39
module.exports = {
410
attributes: require('./attributes'),
511
supplyDefaults: require('./defaults'),
@@ -25,6 +31,7 @@ module.exports = {
2531
meta: {
2632
hrName: 'scatter_mapbox',
2733
description: [
34+
deprecationWarning,
2835
'The data visualized as scatter point, lines or marker symbols',
2936
'on a Mapbox GL geographic map',
3037
'is provided by longitude/latitude pairs in `lon` and `lat`.'

test/plot-schema.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -29751,7 +29751,7 @@
2975129751
}
2975229752
},
2975329753
"subplot": {
29754-
"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.",
29754+
"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.",
2975529755
"dflt": "mapbox",
2975629756
"editType": "calc",
2975729757
"valType": "subplotid"
@@ -29865,7 +29865,7 @@
2986529865
"showLegend"
2986629866
],
2986729867
"meta": {
29868-
"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`.",
29868+
"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`.",
2986929869
"hr_name": "choropleth_mapbox"
2987029870
},
2987129871
"type": "choroplethmapbox"
@@ -37184,7 +37184,7 @@
3718437184
}
3718537185
},
3718637186
"subplot": {
37187-
"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.",
37187+
"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.",
3718837188
"dflt": "mapbox",
3718937189
"editType": "calc",
3719037190
"valType": "subplotid"
@@ -37282,7 +37282,7 @@
3728237282
"showLegend"
3728337283
],
3728437284
"meta": {
37285-
"description": "Draws a bivariate kernel density estimation with a Gaussian kernel from `lon` and `lat` coordinates and optional `z` values using a colorscale.",
37285+
"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.",
3728637286
"hr_name": "density_mapbox"
3728737287
},
3728837288
"type": "densitymapbox"
@@ -80422,7 +80422,7 @@
8042280422
}
8042380423
},
8042480424
"subplot": {
80425-
"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.",
80425+
"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.",
8042680426
"dflt": "mapbox",
8042780427
"editType": "calc",
8042880428
"valType": "subplotid"
@@ -80580,7 +80580,7 @@
8058080580
"scatter-like"
8058180581
],
8058280582
"meta": {
80583-
"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`.",
80583+
"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`.",
8058480584
"hrName": "scatter_mapbox"
8058580585
},
8058680586
"type": "scattermapbox"

0 commit comments

Comments
 (0)