MCPcopy Index your code
hub / github.com/plotly/plotly.py / _handler_js2py_layoutDelta

Method _handler_js2py_layoutDelta

plotly/basewidget.py:485–545  ·  view source on GitHub ↗

Process layout delta message from the frontend

(self, change)

Source from the content-addressed store, hash-verified

483
484 @observe("_js2py_layoutDelta")
485 def _handler_js2py_layoutDelta(self, change):
486 """
487 Process layout delta message from the frontend
488 """
489
490 # Receive message
491 # ---------------
492 msg_data = change["new"]
493 if not msg_data:
494 self._js2py_layoutDelta = None
495 return
496
497 layout_delta = msg_data["layout_delta"]
498 layout_edit_id = msg_data["layout_edit_id"]
499
500 # Apply delta
501 # -----------
502 # We only apply the delta if this message corresponds to the most
503 # recent layout edit operation
504 if layout_edit_id == self._last_layout_edit_id:
505 # ### Transform defaults to delta ###
506 delta_transform = BaseFigureWidget._transform_data(
507 self._layout_defaults, layout_delta
508 )
509
510 # ### Remove overlapping properties ###
511 # If a property is present in both _layout and _layout_defaults
512 # then we remove the copy from _layout
513 removed_props = self._remove_overlapping_props(
514 self._widget_layout, self._layout_defaults
515 )
516
517 # ### Notify frontend model of property removal ###
518 if removed_props:
519 remove_props_msg = {"remove_props": removed_props}
520
521 self._py2js_removeLayoutProps = remove_props_msg
522 self._py2js_removeLayoutProps = None
523
524 # ### Create axis objects ###
525 # For example, when a SPLOM trace is created the layout defaults
526 # may include axes that weren't explicitly defined by the user.
527 for proppath in delta_transform:
528 prop = proppath[0]
529 match = self.layout._subplot_re_match(prop)
530 if match and prop not in self.layout:
531 # We need to create a subplotid object
532 self.layout[prop] = {}
533
534 # ### Dispatch change callbacks ###
535 self._dispatch_layout_change_callbacks(delta_transform)
536
537 # ### Layout edits no longer in process ###
538 self._layout_edit_in_process = False
539
540 # ### Call any waiting layout edit callbacks ###
541 if not self._trace_edit_in_process:
542 while self._waiting_edit_callbacks:

Callers

nothing calls this directly

Calls 5

_transform_dataMethod · 0.80
_subplot_re_matchMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected