Skip to content

Upgrade plotly.js to 3.1.0 #5318

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

Merged
merged 3 commits into from
Aug 12, 2025
Merged
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
26 changes: 26 additions & 0 deletions codegen/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"choroplethmapbox",
"densitymapbox",
]
locationmode_traces = [
"choropleth",
"scattergeo",
]


def get_typing_type(plotly_type, array_ok=False):
Expand Down Expand Up @@ -100,6 +104,7 @@ def build_datatype_py(node):

if (
node.name_property in deprecated_mapbox_traces
or node.name_property in locationmode_traces
or node.name_property == "template"
):
buffer.write("import warnings\n")
Expand Down Expand Up @@ -341,6 +346,27 @@ def __init__(self"""
constructor must be a dict or
an instance of :class:`{class_name}`\"\"\")
"""
)

# Add warning for 'country names' locationmode
if node.name_property in locationmode_traces:
buffer.write(
f"""
if locationmode == "country names" and kwargs.get("_validate"):
warnings.warn(
"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. "
"To ensure consistent behavior, consider setting `locationmode` to *ISO-3*.",
DeprecationWarning,
stacklevel=5,
)
"""
)

buffer.write(
f"""
self._skip_invalid = kwargs.pop("skip_invalid", False)
self._validate = kwargs.pop("_validate", True)
"""
Expand Down
703 changes: 601 additions & 102 deletions codegen/resources/plot-schema.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"dependencies": {
"lodash-es": "^4.17.21",
"plotly.js": "3.0.3",
"plotly.js": "3.1.0",
"@lumino/widgets": "~2.4.0"
},
"devDependencies": {
Expand Down
20 changes: 20 additions & 0 deletions plotly/express/_chart_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,16 @@ def choropleth(
In a choropleth map, each row of `data_frame` is represented by a
colored region mark on a map.
"""

if locationmode == "country names":
warn(
"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. "
"To ensure consistent behavior, consider setting `locationmode` to *ISO-3*.",
DeprecationWarning,
stacklevel=2,
)

return make_figure(
args=locals(),
constructor=go.Choropleth,
Expand Down Expand Up @@ -1168,6 +1178,16 @@ def scatter_geo(
In a geographic scatter plot, each row of `data_frame` is represented
by a symbol mark on a map.
"""

if locationmode == "country names":
warn(
"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. "
"To ensure consistent behavior, consider setting `locationmode` to *ISO-3*.",
DeprecationWarning,
stacklevel=2,
)

return make_figure(
args=locals(),
constructor=go.Scattergeo,
Expand Down
8 changes: 4 additions & 4 deletions plotly/graph_objs/_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ def hovertemplate(self):
(the ones that are `arrayOk: true`) are available. Finally, the
template string has access to variables `value` and `label`.
Anything contained in tag `<extra>` is displayed in the
secondary box, for example "<extra>{fullData.name}</extra>". To
hide the secondary box completely, use an empty tag
secondary box, for example `<extra>%{fullData.name}</extra>`.
To hide the secondary box completely, use an empty tag
`<extra></extra>`.

The 'hovertemplate' property is a string and must be specified as:
Expand Down Expand Up @@ -1731,7 +1731,7 @@ def _prop_descriptions(self):
are available. Finally, the template string has access
to variables `value` and `label`. Anything contained in
tag `<extra>` is displayed in the secondary box, for
example "<extra>{fullData.name}</extra>". To hide the
example `<extra>%{fullData.name}</extra>`. To hide the
secondary box completely, use an empty tag
`<extra></extra>`.
hovertemplatesrc
Expand Down Expand Up @@ -2197,7 +2197,7 @@ def __init__(
are available. Finally, the template string has access
to variables `value` and `label`. Anything contained in
tag `<extra>` is displayed in the secondary box, for
example "<extra>{fullData.name}</extra>". To hide the
example `<extra>%{fullData.name}</extra>`. To hide the
secondary box completely, use an empty tag
`<extra></extra>`.
hovertemplatesrc
Expand Down
12 changes: 7 additions & 5 deletions plotly/graph_objs/_barpolar.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def hovertemplate(self):
Additionally, every attributes that can be specified per-point
(the ones that are `arrayOk: true`) are available. Anything
contained in tag `<extra>` is displayed in the secondary box,
for example "<extra>{fullData.name}</extra>". To hide the
for example `<extra>%{fullData.name}</extra>`. To hide the
secondary box completely, use an empty tag `<extra></extra>`.

The 'hovertemplate' property is a string and must be specified as:
Expand Down Expand Up @@ -1086,8 +1086,9 @@ def _prop_descriptions(self):
specified per-point (the ones that are `arrayOk: true`)
are available. Anything contained in tag `<extra>` is
displayed in the secondary box, for example
"<extra>{fullData.name}</extra>". To hide the secondary
box completely, use an empty tag `<extra></extra>`.
`<extra>%{fullData.name}</extra>`. To hide the
secondary box completely, use an empty tag
`<extra></extra>`.
hovertemplatesrc
Sets the source reference on Chart Studio Cloud for
`hovertemplate`.
Expand Down Expand Up @@ -1368,8 +1369,9 @@ def __init__(
specified per-point (the ones that are `arrayOk: true`)
are available. Anything contained in tag `<extra>` is
displayed in the secondary box, for example
"<extra>{fullData.name}</extra>". To hide the secondary
box completely, use an empty tag `<extra></extra>`.
`<extra>%{fullData.name}</extra>`. To hide the
secondary box completely, use an empty tag
`<extra></extra>`.
hovertemplatesrc
Sets the source reference on Chart Studio Cloud for
`hovertemplate`.
Expand Down
12 changes: 7 additions & 5 deletions plotly/graph_objs/_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def hovertemplate(self):
Additionally, every attributes that can be specified per-point
(the ones that are `arrayOk: true`) are available. Anything
contained in tag `<extra>` is displayed in the secondary box,
for example "<extra>{fullData.name}</extra>". To hide the
for example `<extra>%{fullData.name}</extra>`. To hide the
secondary box completely, use an empty tag `<extra></extra>`.
The 'hovertemplate' property is a string and must be specified as:
Expand Down Expand Up @@ -1996,8 +1996,9 @@ def _prop_descriptions(self):
specified per-point (the ones that are `arrayOk: true`)
are available. Anything contained in tag `<extra>` is
displayed in the secondary box, for example
"<extra>{fullData.name}</extra>". To hide the secondary
box completely, use an empty tag `<extra></extra>`.
`<extra>%{fullData.name}</extra>`. To hide the
secondary box completely, use an empty tag
`<extra></extra>`.
hovertemplatesrc
Sets the source reference on Chart Studio Cloud for
`hovertemplate`.
Expand Down Expand Up @@ -2567,8 +2568,9 @@ def __init__(
specified per-point (the ones that are `arrayOk: true`)
are available. Anything contained in tag `<extra>` is
displayed in the secondary box, for example
"<extra>{fullData.name}</extra>". To hide the secondary
box completely, use an empty tag `<extra></extra>`.
`<extra>%{fullData.name}</extra>`. To hide the
secondary box completely, use an empty tag
`<extra></extra>`.
hovertemplatesrc
Sets the source reference on Chart Studio Cloud for
`hovertemplate`.
Expand Down
65 changes: 43 additions & 22 deletions plotly/graph_objs/_choropleth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from plotly.basedatatypes import BaseTraceType as _BaseTraceType
import copy as _copy
import warnings


class Choropleth(_BaseTraceType):
Expand Down Expand Up @@ -370,7 +371,7 @@ def hovertemplate(self):
Additionally, every attributes that can be specified per-point
(the ones that are `arrayOk: true`) are available. Anything
contained in tag `<extra>` is displayed in the secondary box,
for example "<extra>{fullData.name}</extra>". To hide the
for example `<extra>%{fullData.name}</extra>`. To hide the
secondary box completely, use an empty tag `<extra></extra>`.

The 'hovertemplate' property is a string and must be specified as:
Expand Down Expand Up @@ -594,11 +595,14 @@ def legendwidth(self, val):
@property
def locationmode(self):
"""
Determines the set of locations used to match entries in
`locations` to regions on the map. Values "ISO-3", "USA-
states", *country names* correspond to features on the base map
and value "geojson-id" corresponds to features from a custom
GeoJSON linked to the `geojson` attribute.
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. Determines the set of
locations used to match entries in `locations` to regions on
the map. Values "ISO-3", "USA-states", *country names*
correspond to features on the base map and value "geojson-id"
corresponds to features from a custom GeoJSON linked to the
`geojson` attribute.

The 'locationmode' property is an enumeration that may be specified as:
- One of the following enumeration values:
Expand Down Expand Up @@ -1196,8 +1200,9 @@ def _prop_descriptions(self):
specified per-point (the ones that are `arrayOk: true`)
are available. Anything contained in tag `<extra>` is
displayed in the secondary box, for example
"<extra>{fullData.name}</extra>". To hide the secondary
box completely, use an empty tag `<extra></extra>`.
`<extra>%{fullData.name}</extra>`. To hide the
secondary box completely, use an empty tag
`<extra></extra>`.
hovertemplatesrc
Sets the source reference on Chart Studio Cloud for
`hovertemplate`.
Expand Down Expand Up @@ -1241,12 +1246,15 @@ def _prop_descriptions(self):
Sets the width (in px or fraction) of the legend for
this trace.
locationmode
Determines the set of locations used to match entries
in `locations` to regions on the map. Values "ISO-3",
"USA-states", *country names* correspond to features on
the base map and value "geojson-id" corresponds to
features from a custom GeoJSON linked to the `geojson`
attribute.
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. Determines the set of locations used to match
entries in `locations` to regions on the map. Values
"ISO-3", "USA-states", *country names* correspond to
features on the base map and value "geojson-id"
corresponds to features from a custom GeoJSON linked to
the `geojson` attribute.
locations
Sets the coordinates via location IDs or names. See
`locationmode` for more info.
Expand Down Expand Up @@ -1515,8 +1523,9 @@ def __init__(
specified per-point (the ones that are `arrayOk: true`)
are available. Anything contained in tag `<extra>` is
displayed in the secondary box, for example
"<extra>{fullData.name}</extra>". To hide the secondary
box completely, use an empty tag `<extra></extra>`.
`<extra>%{fullData.name}</extra>`. To hide the
secondary box completely, use an empty tag
`<extra></extra>`.
hovertemplatesrc
Sets the source reference on Chart Studio Cloud for
`hovertemplate`.
Expand Down Expand Up @@ -1560,12 +1569,15 @@ def __init__(
Sets the width (in px or fraction) of the legend for
this trace.
locationmode
Determines the set of locations used to match entries
in `locations` to regions on the map. Values "ISO-3",
"USA-states", *country names* correspond to features on
the base map and value "geojson-id" corresponds to
features from a custom GeoJSON linked to the `geojson`
attribute.
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. Determines the set of locations used to match
entries in `locations` to regions on the map. Values
"ISO-3", "USA-states", *country names* correspond to
features on the base map and value "geojson-id"
corresponds to features from a custom GeoJSON linked to
the `geojson` attribute.
locations
Sets the coordinates via location IDs or names. See
`locationmode` for more info.
Expand Down Expand Up @@ -1697,6 +1709,15 @@ def __init__(
constructor must be a dict or
an instance of :class:`plotly.graph_objs.Choropleth`""")

if locationmode == "country names" and kwargs.get("_validate"):
warnings.warn(
"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. "
"To ensure consistent behavior, consider setting `locationmode` to *ISO-3*.",
DeprecationWarning,
stacklevel=5,
)

self._skip_invalid = kwargs.pop("skip_invalid", False)
self._validate = kwargs.pop("_validate", True)

Expand Down
6 changes: 3 additions & 3 deletions plotly/graph_objs/_choroplethmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def hovertemplate(self):
(the ones that are `arrayOk: true`) are available. Finally, the
template string has access to variable `properties` Anything
contained in tag `<extra>` is displayed in the secondary box,
for example "<extra>{fullData.name}</extra>". To hide the
for example `<extra>%{fullData.name}</extra>`. To hide the
secondary box completely, use an empty tag `<extra></extra>`.
The 'hovertemplate' property is a string and must be specified as:
Expand Down Expand Up @@ -1193,7 +1193,7 @@ def _prop_descriptions(self):
are available. Finally, the template string has access
to variable `properties` Anything contained in tag
`<extra>` is displayed in the secondary box, for
example "<extra>{fullData.name}</extra>". To hide the
example `<extra>%{fullData.name}</extra>`. To hide the
secondary box completely, use an empty tag
`<extra></extra>`.
hovertemplatesrc
Expand Down Expand Up @@ -1510,7 +1510,7 @@ def __init__(
are available. Finally, the template string has access
to variable `properties` Anything contained in tag
`<extra>` is displayed in the secondary box, for
example "<extra>{fullData.name}</extra>". To hide the
example `<extra>%{fullData.name}</extra>`. To hide the
secondary box completely, use an empty tag
`<extra></extra>`.
hovertemplatesrc
Expand Down
6 changes: 3 additions & 3 deletions plotly/graph_objs/_choroplethmapbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def hovertemplate(self):
(the ones that are `arrayOk: true`) are available. Finally, the
template string has access to variable `properties` Anything
contained in tag `<extra>` is displayed in the secondary box,
for example "<extra>{fullData.name}</extra>". To hide the
for example `<extra>%{fullData.name}</extra>`. To hide the
secondary box completely, use an empty tag `<extra></extra>`.
The 'hovertemplate' property is a string and must be specified as:
Expand Down Expand Up @@ -1198,7 +1198,7 @@ def _prop_descriptions(self):
are available. Finally, the template string has access
to variable `properties` Anything contained in tag
`<extra>` is displayed in the secondary box, for
example "<extra>{fullData.name}</extra>". To hide the
example `<extra>%{fullData.name}</extra>`. To hide the
secondary box completely, use an empty tag
`<extra></extra>`.
hovertemplatesrc
Expand Down Expand Up @@ -1525,7 +1525,7 @@ def __init__(
are available. Finally, the template string has access
to variable `properties` Anything contained in tag
`<extra>` is displayed in the secondary box, for
example "<extra>{fullData.name}</extra>". To hide the
example `<extra>%{fullData.name}</extra>`. To hide the
secondary box completely, use an empty tag
`<extra></extra>`.
hovertemplatesrc
Expand Down
Loading