Skip to content

Commit

Permalink
Handle relayout and restyle callbacks on Plotly pane (#7662)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored Jan 23, 2025
1 parent 29714f2 commit 581cbda
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions panel/pane/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,11 @@ 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) is not go.Figure or
if (self.object is None or type(self.object) not in (go.Figure, go.FigureWidget) or
self.object is self._figure or not self.link_figure):
return

# Monkey patch the message stubs used by FigureWidget.
# We only patch `Figure` objects (not subclasses like FigureWidget) so
# we don't interfere with subclasses that override these methods.
fig = self.object
fig._send_addTraces_msg = lambda *_, **__: self._update_from_figure('add')
fig._send_deleteTraces_msg = lambda *_, **__: self._update_from_figure('delete')
Expand Down Expand Up @@ -335,6 +333,7 @@ def _process_event(self, event):
self.param.trigger(pname)
else:
self.param.update(**{pname: data})

if data is None or not hasattr(self.object, '_handler_js2py_pointsCallback'):
return

Expand Down Expand Up @@ -392,7 +391,7 @@ def _process_event(self, event):
if has_z and 'z' in point_obj:
points_object['zs'].append(point_obj['z'])

self.object._handler_js2py_pointsCallback(
self._figure._handler_js2py_pointsCallback(
{
"new": dict(
event_type=f'plotly_{etype}',
Expand Down

0 comments on commit 581cbda

Please sign in to comment.