Skip to content

Only show locationmode warning if locationmode is 'country names' #7520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions src/traces/choropleth/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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');
}
Expand Down
11 changes: 0 additions & 11 deletions src/traces/choropleth/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 10 additions & 0 deletions src/traces/scattergeo/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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');
}
Expand Down
11 changes: 0 additions & 11 deletions src/traces/scattergeo/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down