Skip to content

Commit 581cbda

Browse files
authored
Handle relayout and restyle callbacks on Plotly pane (#7662)
1 parent 29714f2 commit 581cbda

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

panel/pane/plotly.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,11 @@ def _get_sources_for_trace(json, data, parent_path=''):
156156
def _update_figure(self):
157157
import plotly.graph_objs as go
158158

159-
if (self.object is None or type(self.object) is not go.Figure or
159+
if (self.object is None or type(self.object) not in (go.Figure, go.FigureWidget) or
160160
self.object is self._figure or not self.link_figure):
161161
return
162162

163163
# Monkey patch the message stubs used by FigureWidget.
164-
# We only patch `Figure` objects (not subclasses like FigureWidget) so
165-
# we don't interfere with subclasses that override these methods.
166164
fig = self.object
167165
fig._send_addTraces_msg = lambda *_, **__: self._update_from_figure('add')
168166
fig._send_deleteTraces_msg = lambda *_, **__: self._update_from_figure('delete')
@@ -335,6 +333,7 @@ def _process_event(self, event):
335333
self.param.trigger(pname)
336334
else:
337335
self.param.update(**{pname: data})
336+
338337
if data is None or not hasattr(self.object, '_handler_js2py_pointsCallback'):
339338
return
340339

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

395-
self.object._handler_js2py_pointsCallback(
394+
self._figure._handler_js2py_pointsCallback(
396395
{
397396
"new": dict(
398397
event_type=f'plotly_{etype}',

0 commit comments

Comments
 (0)