Process trace deltas message from the frontend
(self, change)
| 420 | # ----------------------------- |
| 421 | @observe("_js2py_traceDeltas") |
| 422 | def _handler_js2py_traceDeltas(self, change): |
| 423 | """ |
| 424 | Process trace deltas message from the frontend |
| 425 | """ |
| 426 | |
| 427 | # Receive message |
| 428 | # --------------- |
| 429 | msg_data = change["new"] |
| 430 | if not msg_data: |
| 431 | self._js2py_traceDeltas = None |
| 432 | return |
| 433 | |
| 434 | trace_deltas = msg_data["trace_deltas"] |
| 435 | trace_edit_id = msg_data["trace_edit_id"] |
| 436 | |
| 437 | # Apply deltas |
| 438 | # ------------ |
| 439 | # We only apply the deltas if this message corresponds to the most |
| 440 | # recent trace edit operation |
| 441 | if trace_edit_id == self._last_trace_edit_id: |
| 442 | # ### Loop over deltas ### |
| 443 | for delta in trace_deltas: |
| 444 | # #### Find existing trace for uid ### |
| 445 | trace_uid = delta["uid"] |
| 446 | trace_uids = [trace.uid for trace in self.data] |
| 447 | trace_index = trace_uids.index(trace_uid) |
| 448 | uid_trace = self.data[trace_index] |
| 449 | |
| 450 | # #### Transform defaults to delta #### |
| 451 | delta_transform = BaseFigureWidget._transform_data( |
| 452 | uid_trace._prop_defaults, delta |
| 453 | ) |
| 454 | |
| 455 | # #### Remove overlapping properties #### |
| 456 | # If a property is present in both _props and _prop_defaults |
| 457 | # then we remove the copy from _props |
| 458 | remove_props = self._remove_overlapping_props( |
| 459 | uid_trace._props, uid_trace._prop_defaults |
| 460 | ) |
| 461 | |
| 462 | # #### Notify frontend model of property removal #### |
| 463 | if remove_props: |
| 464 | remove_trace_props_msg = { |
| 465 | "remove_trace": trace_index, |
| 466 | "remove_props": remove_props, |
| 467 | } |
| 468 | self._py2js_removeTraceProps = remove_trace_props_msg |
| 469 | self._py2js_removeTraceProps = None |
| 470 | |
| 471 | # #### Dispatch change callbacks #### |
| 472 | self._dispatch_trace_change_callbacks(delta_transform, [trace_index]) |
| 473 | |
| 474 | # ### Trace edits no longer in process ### |
| 475 | self._trace_edit_in_process = False |
| 476 | |
| 477 | # ### Call any waiting trace edit callbacks ### |
| 478 | if not self._layout_edit_in_process: |
| 479 | while self._waiting_edit_callbacks: |
nothing calls this directly
no test coverage detected