diff --git a/src/traces/choropleth/defaults.js b/src/traces/choropleth/defaults.js index b6b1a82e418..af94097d5a0 100644 --- a/src/traces/choropleth/defaults.js +++ b/src/traces/choropleth/defaults.js @@ -4,6 +4,12 @@ var Lib = require('../../lib'); var colorscaleDefaults = require('../../components/colorscale/defaults'); var attributes = require('./attributes'); +const locationmodeBreakingChangeWarning = [ + 'The library used by the *country names* `locationmode` option is changing in the next major version.', + 'Some country names in existing plots may not work in the new version.', + 'To ensure consistent behavior, consider setting `locationmode` to *ISO-3*.', +].join(' '); + module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) { function coerce(attr, dflt) { return Lib.coerce(traceIn, traceOut, attributes, attr, dflt); @@ -28,6 +34,10 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout var locationMode = coerce('locationmode', locationmodeDflt); + if(locationMode === 'country names') { + Lib.warn(locationmodeBreakingChangeWarning); + } + if(locationMode === 'geojson-id') { coerce('featureidkey'); } diff --git a/src/traces/choropleth/plot.js b/src/traces/choropleth/plot.js index bf99852986c..da27bf17d78 100644 --- a/src/traces/choropleth/plot.js +++ b/src/traces/choropleth/plot.js @@ -9,18 +9,7 @@ var findExtremes = require('../../plots/cartesian/autorange').findExtremes; var style = require('./style').style; -const breakingChangeWarning = [ - 'The library used by the *country names* `locationmode` option is changing in an upcoming version.', - 'Country names in existing plots may not work in the new version.' -].join(' '); -let firstPlot = true; - function plot(gd, geo, calcData) { - if(firstPlot) { - firstPlot = false; - Lib.warn(breakingChangeWarning); - } - var choroplethLayer = geo.layers.backplot.select('.choroplethlayer'); Lib.makeTraceGroups(choroplethLayer, calcData, 'trace choropleth').each(function(calcTrace) { diff --git a/src/traces/scattergeo/defaults.js b/src/traces/scattergeo/defaults.js index 6f8adb11d98..f2a1ad9b9d8 100644 --- a/src/traces/scattergeo/defaults.js +++ b/src/traces/scattergeo/defaults.js @@ -10,6 +10,12 @@ var handleFillColorDefaults = require('../scatter/fillcolor_defaults'); var attributes = require('./attributes'); +const locationmodeBreakingChangeWarning = [ + 'The library used by the *country names* `locationmode` option is changing in the next major version.', + 'Some country names in existing plots may not work in the new version.', + 'To ensure consistent behavior, consider setting `locationmode` to *ISO-3*.', +].join(' '); + module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) { function coerce(attr, dflt) { return Lib.coerce(traceIn, traceOut, attributes, attr, dflt); @@ -27,6 +33,10 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout var locationMode = coerce('locationmode', locationmodeDflt); + if(locationMode === 'country names') { + Lib.warn(locationmodeBreakingChangeWarning); + } + if(locationMode === 'geojson-id') { coerce('featureidkey'); } diff --git a/src/traces/scattergeo/plot.js b/src/traces/scattergeo/plot.js index 284bb0093d1..9124900e8b3 100644 --- a/src/traces/scattergeo/plot.js +++ b/src/traces/scattergeo/plot.js @@ -13,18 +13,7 @@ var calcMarkerSize = require('../scatter/calc').calcMarkerSize; var subTypes = require('../scatter/subtypes'); var style = require('./style'); -const breakingChangeWarning = [ - 'The library used by the *country names* `locationmode` option is changing in an upcoming version.', - 'Country names in existing plots may not work in the new version.' -].join(' '); -let firstPlot = true; - function plot(gd, geo, calcData) { - if(firstPlot) { - firstPlot = false; - Lib.warn(breakingChangeWarning); - } - var scatterLayer = geo.layers.frontplot.select('.scatterlayer'); var gTraces = Lib.makeTraceGroups(scatterLayer, calcData, 'trace scattergeo');