Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow change in cmap_att on change in data components #2567

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions jdaviz/core/template_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2899,16 +2899,23 @@ def _on_viewer_layer_changed(self, msg=None):
if glue_name in ['contour_visible', 'bitmap_visible']:
state.add_callback('visible', self._on_glue_layer_visible_changed)

if self.sync.get('choices') is None and \
(hasattr(getattr(type(state), glue_name), 'get_display_func')
or glue_name == 'cmap'):
# then we can access and populate the choices. We are assuming here
# that each state-instance with this same name will have the same
# choices and that those will not change. If we ever hookup options
# with changing choices, we'll need additional logic to sync to those
# and handle mixed state in the choices...
if (
# We are assuming here that each state-instance with this same name
# will have the same choices and that those will not change. If we
# ever hookup options with changing choices, we'll need additional
# logic to sync to those and handle mixed state in the choices...
self.sync.get('choices') is None and
(
hasattr(getattr(type(state), glue_name), 'get_display_func') or
glue_name == 'cmap'
)
) or (
# update choices in `sync` if glue state choices are updated
# during glue Component add/rename/delete:
glue_name == 'cmap_att'
):
# then we can access and populate/update the choices.
self.sync = {**self.sync, 'choices': self._get_glue_choices(state)}

self.sync = {**self.sync,
'in_subscribed_states': in_subscribed_states,
'icons': icons,
Expand Down