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

Method _handler_js2py_pointsCallback

plotly/basewidget.py:635–717  ·  view source on GitHub ↗

Process points callback message from the frontend

(self, change)

Source from the content-addressed store, hash-verified

633
634 @observe("_js2py_pointsCallback")
635 def _handler_js2py_pointsCallback(self, change):
636 """
637 Process points callback message from the frontend
638 """
639
640 # Receive message
641 # ---------------
642 callback_data = change["new"]
643
644 if not callback_data:
645 self._js2py_pointsCallback = None
646 return
647
648 # Get event type
649 # --------------
650 event_type = callback_data["event_type"]
651
652 # Build Selector Object
653 # ---------------------
654 if callback_data.get("selector", None):
655 selector_data = callback_data["selector"]
656 selector_type = selector_data["type"]
657 selector_state = selector_data["selector_state"]
658 if selector_type == "box":
659 selector = BoxSelector(**selector_state)
660 elif selector_type == "lasso":
661 selector = LassoSelector(**selector_state)
662 else:
663 raise ValueError("Unsupported selector type: %s" % selector_type)
664 else:
665 selector = None
666
667 # Build Input Device State Object
668 # -------------------------------
669 if callback_data.get("device_state", None):
670 device_state_data = callback_data["device_state"]
671 state = InputDeviceState(**device_state_data)
672 else:
673 state = None
674
675 # Build Trace Points Dictionary
676 # -----------------------------
677 points_data = callback_data["points"]
678 trace_points = {
679 trace_ind: {
680 "point_inds": [],
681 "xs": [],
682 "ys": [],
683 "trace_name": self._data_objs[trace_ind].name,
684 "trace_index": trace_ind,
685 }
686 for trace_ind in range(len(self._data_objs))
687 }
688
689 for x, y, point_ind, trace_ind in zip(
690 points_data["xs"],
691 points_data["ys"],
692 points_data["point_indexes"],

Callers

nothing calls this directly

Calls 11

BoxSelectorClass · 0.85
LassoSelectorClass · 0.85
InputDeviceStateClass · 0.85
PointsClass · 0.85
_dispatch_on_clickMethod · 0.80
_dispatch_on_hoverMethod · 0.80
_dispatch_on_unhoverMethod · 0.80
_dispatch_on_deselectMethod · 0.80
getMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected