Skip to content

Commit 61b76b8

Browse files
authored
fix: DH-18653: migrate to plotly >= 6.0.0 (#1179)
Fixes #946 1. Bump plotly.py to 6.0.0 2. Bump plotly.js to 3.0.0 3. Deprecate any mapbox reference 4. Remove `alignmentgroup` and `offsetgroup` in tests where they now do not need to be set 5. Generally replaced NULL_INT and NULL_DOUBLE with a binary data form plotly is now converting those values to in tests 6. Replaced all `title=<str>` with `title_text=<str>` as the former is deprecated 7. Fixed some minor inconsistencies 8. Added a few e2e tests where I could to make sure migration did not break the charts. Those images were generated on main originally.
1 parent e42bb98 commit 61b76b8

52 files changed

Lines changed: 3075 additions & 3781 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package-lock.json

Lines changed: 2455 additions & 3270 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/auth-keycloak/src/js/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"update-dh-packages": "node ../../../../tools/update-dh-packages.mjs"
2828
},
2929
"devDependencies": {
30-
"@types/plotly.js": "^2.12.18",
3130
"@types/react": "^17.0.2",
3231
"react": "^17.0.2",
3332
"typescript": "^4.5.4"

plugins/plotly-express/setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ packages=find_namespace:
2727
install_requires =
2828
deephaven-core>=0.37.6
2929
deephaven-plugin>=0.6.0
30-
plotly>=5.15.0,<6.0.0
30+
plotly>=6.0.0,<7.0.0
3131
deephaven-plugin-utilities>=0.0.2
3232
typing_extensions;python_version<'3.11'
3333
jpy

plugins/plotly-express/src/deephaven/plot/express/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
line_mapbox,
4444
density_heatmap,
4545
indicator,
46+
scatter_map,
47+
density_map,
48+
line_map,
4649
)
4750

4851
from .data import data_generators

plugins/plotly-express/src/deephaven/plot/express/deephaven_figure/custom_draw.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pandas import DataFrame
77
import plotly.graph_objects as go
88
from plotly.graph_objects import Figure
9-
from plotly.validators.heatmap import ColorscaleValidator
9+
from plotly.validator_cache import ValidatorCache
1010

1111
# attach a prefix to the number format so that we can identify it as the GWT Java NumberFormat syntax
1212
# https://www.gwtproject.org/javadoc/latest/com/google/gwt/i18n/client/NumberFormat.html
@@ -57,10 +57,10 @@ def draw_finance(
5757
data.append(
5858
go_func(
5959
x=data_frame[x_f],
60-
open=data_frame[open],
61-
high=data_frame[high],
62-
low=data_frame[low],
63-
close=data_frame[close],
60+
open=data_frame[o],
61+
high=data_frame[h],
62+
low=data_frame[l],
63+
close=data_frame[c],
6464
)
6565
)
6666

@@ -185,7 +185,7 @@ def draw_density_heatmap(
185185

186186
range_color_list = range_color or [None, None]
187187

188-
colorscale_validator = ColorscaleValidator("colorscale", "draw_density_heatmap")
188+
colorscale_validator = ValidatorCache.get_validator("heatmap", "colorscale")
189189

190190
coloraxis_layout = dict(
191191
colorscale=colorscale_validator.validate_coerce(color_continuous_scale),
@@ -200,7 +200,7 @@ def draw_density_heatmap(
200200

201201
heatmap.update_layout(
202202
coloraxis1=coloraxis_layout,
203-
title=title,
203+
title_text=title,
204204
template=template,
205205
xaxis_title=x,
206206
yaxis_title=y,
@@ -276,7 +276,7 @@ def draw_indicator(
276276
fig.update_traces(delta_reference=data_frame[reference][0])
277277

278278
if layout_title:
279-
fig.update_layout(title=layout_title)
279+
fig.update_layout(title_text=layout_title)
280280

281281
if title:
282282
# This is the title on the indicator trace. This is where it should go by default.

plugins/plotly-express/src/deephaven/plot/express/plots/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
from .pie import pie
99
from ._layer import layer
1010
from .subplots import make_subplots
11-
from .maps import scatter_geo, scatter_mapbox, density_mapbox, line_geo, line_mapbox
11+
from .maps import (
12+
scatter_geo,
13+
scatter_mapbox,
14+
density_mapbox,
15+
line_geo,
16+
line_mapbox,
17+
scatter_map,
18+
density_map,
19+
line_map,
20+
)
1221
from .heatmap import density_heatmap
1322
from .indicator import indicator

plugins/plotly-express/src/deephaven/plot/express/plots/maps.py

Lines changed: 67 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
from typing import Callable
4+
import warnings
45

56
from plotly import express as px
67

@@ -159,7 +160,55 @@ def scatter_geo(
159160
return process_args(args, {"scatter"}, px_func=px.scatter_geo)
160161

161162

162-
def scatter_mapbox(
163+
def scatter_mapbox(*args, **kwargs) -> DeephavenFigure:
164+
"""
165+
c
166+
"""
167+
warnings.warn(
168+
"scatter_mapbox is deprecated and will be removed in a future release. Use scatter_map instead.",
169+
DeprecationWarning,
170+
stacklevel=2,
171+
)
172+
173+
if "style_mapbox" in kwargs:
174+
kwargs["map_style"] = kwargs.pop("style_mapbox")
175+
176+
return scatter_map(*args, **kwargs)
177+
178+
179+
def line_mapbox(*args, **kwargs) -> DeephavenFigure:
180+
"""
181+
Deprecated function. Use line_map instead.
182+
"""
183+
warnings.warn(
184+
"line_mapbox is deprecated and will be removed in a future release. Use line_map instead.",
185+
DeprecationWarning,
186+
stacklevel=2,
187+
)
188+
189+
if "style_mapbox" in kwargs:
190+
kwargs["map_style"] = kwargs.pop("style_mapbox")
191+
192+
return line_map(*args, **kwargs)
193+
194+
195+
def density_mapbox(*args, **kwargs) -> DeephavenFigure:
196+
"""
197+
Deprecated function. Use density_map instead.
198+
"""
199+
warnings.warn(
200+
"density_mapbox is deprecated and will be removed in a future release. Use density_map instead.",
201+
DeprecationWarning,
202+
stacklevel=2,
203+
)
204+
205+
if "style_mapbox" in kwargs:
206+
kwargs["map_style"] = kwargs.pop("style_mapbox")
207+
208+
return density_map(*args, **kwargs)
209+
210+
211+
def scatter_map(
163212
table: PartitionableTableLike,
164213
lat: str | None = None,
165214
lon: str | None = None,
@@ -191,13 +240,13 @@ def scatter_mapbox(
191240
opacity: float | None = None,
192241
zoom: float | None = None,
193242
center: dict[str, float] | None = None,
194-
mapbox_style: str = "open-street-map",
243+
map_style: str = "open-street-map",
195244
title: str | None = None,
196245
template: str | None = None,
197246
unsafe_update_figure: Callable = default_callback,
198247
) -> DeephavenFigure:
199248
"""
200-
Create a scatter_mapbox plot
249+
Create a scatter_map plot
201250
202251
Args:
203252
table: A table to pull data from.
@@ -263,7 +312,7 @@ def scatter_mapbox(
263312
center: A dictionary of center coordinates.
264313
The keys should be 'lat' and 'lon' and the values should be floats
265314
that represent the lat and lon of the center of the map.
266-
mapbox_style: The style of the map.
315+
map_style: The style of the map.
267316
One of 'open-street-map', 'white-bg', 'carto-positron', 'carto-darkmatter',
268317
and 'stamen-terrain', 'stamen-toner', 'stamen-watercolor'
269318
title: The title of the chart
@@ -277,11 +326,11 @@ def scatter_mapbox(
277326
mappings.
278327
279328
Returns:
280-
DeephavenFigure: A DeephavenFigure that contains the scatter_mapbox figure
329+
DeephavenFigure: A DeephavenFigure that contains the scatter_map figure
281330
"""
282331
args = locals()
283332

284-
return process_args(args, {"scatter"}, px_func=px.scatter_mapbox)
333+
return process_args(args, {"scatter"}, px_func=px.scatter_map)
285334

286335

287336
def line_geo(
@@ -441,7 +490,7 @@ def line_geo(
441490
return process_args(args, {"line"}, px_func=px.line_geo)
442491

443492

444-
def line_mapbox(
493+
def line_map(
445494
table: PartitionableTableLike,
446495
lat: str | None = None,
447496
lon: str | None = None,
@@ -468,14 +517,14 @@ def line_mapbox(
468517
width_sequence: list[int] | None = None,
469518
width_map: dict[str | tuple[str], str] | None = None,
470519
zoom: float | None = None,
471-
mapbox_style: str = "open-street-map",
520+
map_style: str = "open-street-map",
472521
center: dict[str, float] | None = None,
473522
title: str | None = None,
474523
template: str | None = None,
475524
unsafe_update_figure: Callable = default_callback,
476525
) -> DeephavenFigure:
477526
"""
478-
Create a line_mapbox plot
527+
Create a line_map plot
479528
480529
Args:
481530
table: A table to pull data from.
@@ -550,7 +599,7 @@ def line_mapbox(
550599
center: A dictionary of center coordinates.
551600
The keys should be 'lat' and 'lon' and the values should be floats
552601
that represent the lat and lon of the center of the map.
553-
mapbox_style: The style of the map.
602+
map_style: The style of the map.
554603
One of 'open-street-map', 'white-bg', 'carto-positron', 'carto-darkmatter',
555604
and 'stamen-terrain', 'stamen-toner', 'stamen-watercolor'
556605
title: The title of the chart
@@ -564,15 +613,15 @@ def line_mapbox(
564613
mappings.
565614
566615
Returns:
567-
DeephavenFigure: A DeephavenFigure that contains the line_mapbox figure
616+
DeephavenFigure: A DeephavenFigure that contains the line_map figure
568617
569618
"""
570619
args = locals()
571620

572-
return process_args(args, {"line"}, px_func=px.line_mapbox)
621+
return process_args(args, {"line"}, px_func=px.line_map)
573622

574623

575-
def density_mapbox(
624+
def density_map(
576625
table: TableLike,
577626
lat: str | None = None,
578627
lon: str | None = None,
@@ -586,13 +635,13 @@ def density_mapbox(
586635
opacity: float | None = None,
587636
zoom: float | None = None,
588637
center: dict[str, float] | None = None,
589-
mapbox_style: str = "open-street-map",
638+
map_style: str = "open-street-map",
590639
title: str | None = None,
591640
template: str | None = None,
592641
unsafe_update_figure: Callable = default_callback,
593642
) -> DeephavenFigure:
594643
"""
595-
Create a density_mapbox plot
644+
Create a density_map plot
596645
597646
Args:
598647
table: A table to pull data from.
@@ -611,7 +660,7 @@ def density_mapbox(
611660
center: A dictionary of center coordinates.
612661
The keys should be 'lat' and 'lon' and the values should be floats
613662
that represent the lat and lon of the center of the map.
614-
mapbox_style: The style of the map.
663+
map_style: The style of the map.
615664
One of 'open-street-map', 'white-bg', 'carto-positron', 'carto-darkmatter',
616665
and 'stamen-terrain', 'stamen-toner', 'stamen-watercolor'
617666
title: The title of the chart
@@ -625,8 +674,8 @@ def density_mapbox(
625674
mappings.
626675
627676
Returns:
628-
DeephavenFigure: A DeephavenFigure that contains the density_mapbox figure
677+
DeephavenFigure: A DeephavenFigure that contains the density_map figure
629678
"""
630679
args = locals()
631680

632-
return process_args(args, set(), px_func=px.density_mapbox)
681+
return process_args(args, set(), px_func=px.density_map)

plugins/plotly-express/src/js/package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
"update-dh-packages": "node ../../../../tools/update-dh-packages.mjs"
3939
},
4040
"devDependencies": {
41-
"@deephaven/jsapi-types": "1.0.0-dev0.38.0",
41+
"@deephaven/jsapi-types": "^1.0.0-dev0.39.5",
4242
"@deephaven/test-utils": "0.105.0",
4343
"@types/deep-equal": "^1.0.1",
44-
"@types/plotly.js": "^2.12.18",
44+
"@types/plotly.js": "^3.0.0",
4545
"@types/plotly.js-dist-min": "^2.3.1",
4646
"@types/react": "^17.0.2",
4747
"@types/react-plotly.js": "^2.6.0",
@@ -54,22 +54,22 @@
5454
"react-dom": "^17.0.2"
5555
},
5656
"dependencies": {
57-
"@deephaven/chart": "0.105.0",
58-
"@deephaven/components": "0.105.0",
59-
"@deephaven/dashboard": "0.105.0",
60-
"@deephaven/dashboard-core-plugins": "0.105.0",
61-
"@deephaven/icons": "0.105.0",
62-
"@deephaven/jsapi-bootstrap": "0.105.0",
63-
"@deephaven/jsapi-utils": "0.105.0",
64-
"@deephaven/log": "0.105.0",
65-
"@deephaven/plugin": "0.105.0",
66-
"@deephaven/redux": "0.105.0",
67-
"@deephaven/utils": "0.105.0",
57+
"@deephaven/chart": "^1.2.0",
58+
"@deephaven/components": "^1.2.0",
59+
"@deephaven/dashboard": "^1.2.0",
60+
"@deephaven/dashboard-core-plugins": "^1.2.0",
61+
"@deephaven/icons": "^1.2.0",
62+
"@deephaven/jsapi-bootstrap": "1.2.0",
63+
"@deephaven/jsapi-utils": "1.1.1",
64+
"@deephaven/log": "1.1.0",
65+
"@deephaven/plugin": "^1.2.0",
66+
"@deephaven/redux": "^1.2.0",
67+
"@deephaven/utils": "^1.1.0",
6868
"deep-equal": "^2.2.1",
6969
"memoizee": "^0.4.17",
7070
"nanoid": "^5.0.7",
71-
"plotly.js": "^2.29.1",
72-
"plotly.js-dist-min": "^2.29.1",
71+
"plotly.js": "^3.0.0",
72+
"plotly.js-dist-min": "^3.0.0",
7373
"react-plotly.js": "^2.4.0",
7474
"react-redux": "^7.2.9"
7575
},

plugins/plotly-express/src/js/src/PlotlyExpressChart.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export function PlotlyExpressChart(
4646
containerRef={containerRef}
4747
model={model}
4848
settings={settings}
49+
// @ts-expect-error https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/72099
4950
Plotly={Plotly}
5051
/>
5152
) : null;

0 commit comments

Comments
 (0)