Skip to content
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

More compatibility fixes for plotly 6.0 #7682

Merged
merged 3 commits into from
Jan 31, 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
8 changes: 4 additions & 4 deletions panel/models/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
from bokeh.events import ModelEvent
from bokeh.models import ColumnDataSource, LayoutDOM

from ..io.resources import JS_URLS, bundled_files
from ..config import config
from ..io.resources import bundled_files
from ..util import classproperty

PLOTLY_VERSION = '2.35.3'
PLOTLY_VERSION = '3.0.0'


class PlotlyEvent(ModelEvent):
Expand All @@ -28,15 +29,14 @@ class PlotlyPlot(LayoutDOM):
a bokeh plot.
"""
__css_raw__ = [
"https://api.mapbox.com/mapbox-gl-js/v3.0.1/mapbox-gl.css",
f"{config.npm_cdn}/maplibre-gl@4.4.1/dist/maplibre-gl.css"
]

@classproperty
def __css__(cls):
return bundled_files(cls, 'css')

__javascript_raw__ = [
JS_URLS['jQuery'],
f'https://cdn.plot.ly/plotly-{PLOTLY_VERSION}.min.js'
]

Expand Down
9 changes: 6 additions & 3 deletions panel/pane/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from bokeh.models import ColumnDataSource
from pyviz_comms import JupyterComm

from ..util import lazy_load
from ..util import lazy_load, try_datetime64_to_datetime
from ..util.checks import datetime_types, isdatetime
from ..viewable import Layoutable
from .base import ModelPane
Expand Down Expand Up @@ -156,7 +156,7 @@ def _get_sources_for_trace(json, data, parent_path=''):
def _update_figure(self):
import plotly.graph_objs as go

if (self.object is None or type(self.object) not in (go.Figure, go.FigureWidget) or
if (self.object is None or not isinstance(self.object, (go.Figure, go.FigureWidget)) or
self.object is self._figure or not self.link_figure):
return

Expand Down Expand Up @@ -257,7 +257,10 @@ def _convert_trace(trace):
continue
arr = trace[key]
if isinstance(arr, np.ndarray):
arr = arr.astype(str)
if arr.dtype.kind == 'M' and arr.ndim == 2 and arr.shape[1] == 1:
arr = np.array([[str(try_datetime64_to_datetime(v[0]))] for v in arr])
else:
arr = arr.astype(str)
elif isinstance(arr, datetime_types):
arr = str(arr)
else:
Expand Down
2 changes: 1 addition & 1 deletion pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ holoviews = ">=1.16.0"
jupyterlab = "*"
matplotlib-base = "*"
pillow = "*"
plotly = ">=4.0"
plotly = ">=6.0"
# Optional dependencies - dev
watchfiles = "*"
# Test dependencies
Expand Down
Loading