@@ -554,33 +554,38 @@ def _panel_refresh(self):
554554 self .y_range .start = zoom_bounds [2 ]
555555 self .y_range .end = zoom_bounds [3 ]
556556
557- # Defer to avoid nested Bokeh callbacks
558- # pn.state.execute(_do_update, schedule=True)
559557
560558 def _panel_compute_unit_glyph_patches (self ):
561559 """Compute glyph patches without modifying Bokeh models."""
562560 current_alphas = self .glyphs_data_source .data ['alpha' ]
563561 current_sizes = self .glyphs_data_source .data ['size' ]
564562 current_line_colors = self .glyphs_data_source .data ['line_color' ]
563+ current_colors = self .glyphs_data_source .data ['color' ]
565564
566565 alpha_patches = []
567566 size_patches = []
568567 line_color_patches = []
568+ color_patches = []
569+
570+ if self .controller .main_settings ['color_mode' ] in ('color_by_visibility' , 'color_only_visible' ):
571+ self .controller .refresh_colors ()
569572
570573 for idx , unit_id in enumerate (self .controller .unit_ids ):
571- color = self .get_unit_color (unit_id )
574+ new_color = self .get_unit_color (unit_id )
572575 is_visible = self .controller .get_unit_visibility (unit_id )
573576
574577 new_alpha = self .alpha_selected if is_visible else self .alpha_unselected
575578 new_size = self .unit_marker_size_selected if is_visible else self .unit_marker_size_unselected
576- new_line_color = "black" if is_visible else color
579+ new_line_color = "black" if is_visible else new_color
577580
578581 if current_alphas [idx ] != new_alpha :
579582 alpha_patches .append ((idx , new_alpha ))
580583 if current_sizes [idx ] != new_size :
581584 size_patches .append ((idx , new_size ))
582585 if current_line_colors [idx ] != new_line_color :
583586 line_color_patches .append ((idx , new_line_color ))
587+ if current_colors [idx ] != new_color :
588+ color_patches .append ((idx , new_color ))
584589
585590 patch_dict = {}
586591 if alpha_patches :
@@ -589,6 +594,8 @@ def _panel_compute_unit_glyph_patches(self):
589594 patch_dict ['size' ] = size_patches
590595 if line_color_patches :
591596 patch_dict ['line_color' ] = line_color_patches
597+ if color_patches :
598+ patch_dict ['color' ] = color_patches
592599
593600 return patch_dict
594601
0 commit comments