Skip to content

Commit

Permalink
plot options support for line in scatter viewer (spacetelescope#2449)
Browse files Browse the repository at this point in the history
* enable plot options for line in a scatter viewer
* improved visibility/ordering - line_visible for scatters doesn't toggle the entire layer, but marker_scatter does, so instead the switch is moved to the line section (but for profile viewers, it is left in the "layers" section)
  • Loading branch information
kecnry authored Oct 23, 2023
1 parent d9cacaf commit 4603356
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ Other Changes and Additions

- Add swatches to color picker. [#2494]

- Plot options now includes better support for scatter viewers, including toggling line visibility. [#2449]

3.7.1 (unreleased)
==================

Expand Down
4 changes: 2 additions & 2 deletions jdaviz/configs/default/plugins/plot_options/plot_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,9 @@ def state_attr_for_line_visible(state):
return 'visible'

# Profile/line viewer/layer options:
# TODO: once lines are supported in ScatterViewer, update state_filter to supports_line
self.line_visible = PlotOptionsSyncState(self, self.viewer, self.layer, state_attr_for_line_visible, # noqa
'line_visible_value', 'line_visible_sync',
state_filter=is_profile)
state_filter=supports_line)
self.collapse_function = PlotOptionsSyncState(self, self.viewer, self.layer, 'function',
'collapse_func_value', 'collapse_func_sync')
self.line_color = PlotOptionsSyncState(self, self.viewer, self.layer, 'color',
Expand All @@ -333,6 +332,7 @@ def state_attr_for_line_visible(state):
'uncertainty_visible_value', 'uncertainty_visible_sync') # noqa

# Scatter/marker options:
# NOTE: marker_visible hides the entire layer (including the line)
self.marker_visible = PlotOptionsSyncState(self, self.viewer, self.layer, 'visible',
'marker_visible_value', 'marker_visible_sync',
state_filter=is_scatter)
Expand Down
27 changes: 18 additions & 9 deletions jdaviz/configs/default/plugins/plot_options/plot_options.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@
<v-btn icon @click.stop="marker_visible_value = !marker_visible_value">
<v-icon>mdi-eye{{ marker_visible_value ? '' : '-off' }}</v-icon>
</v-btn>
Show Marker
Show Scatter Layer
</span>
</glue-state-sync-wrapper>

<glue-state-sync-wrapper :sync="line_visible_sync" :multiselect="multiselect" @unmix-state="unmix_state('line_visible')">
<glue-state-sync-wrapper v-if="!marker_visible_sync.in_subscribed_states" :sync="line_visible_sync" :multiselect="multiselect" @unmix-state="unmix_state('line_visible')">
<span>
<v-btn icon @click.stop="line_visible_value = !line_visible_value">
<v-icon>mdi-eye{{ line_visible_value ? '' : '-off' }}</v-icon>
Expand Down Expand Up @@ -108,7 +108,16 @@


<!-- PROFILE/LINE -->
<j-plugin-section-header v-if="(line_visible_sync.in_subscribed_states && line_visible_value) || collapse_func_sync.in_subscribed_states">Line</j-plugin-section-header>
<j-plugin-section-header v-if="(line_visible_sync.in_subscribed_states && ((!marker_visible_sync.in_subscribed_states && line_visible_value) || (marker_visible_sync.in_subscribed_states && marker_visible_value))) || collapse_func_sync.in_subscribed_states">Line</j-plugin-section-header>
<glue-state-sync-wrapper v-if="marker_visible_sync.in_subscribed_states && marker_visible_value" :sync="line_visible_sync" :multiselect="multiselect" @unmix-state="unmix_state('line_visible')">
<span>
<v-btn icon @click.stop="line_visible_value = !line_visible_value">
<v-icon>mdi-eye{{ line_visible_value ? '' : '-off' }}</v-icon>
</v-btn>
Show Line
</span>
</glue-state-sync-wrapper>

<glue-state-sync-wrapper v-if="config === 'cubeviz'" :sync="collapse_func_sync" :multiselect="multiselect" @unmix-state="unmix_state('function')">
<v-select
:menu-props="{ left: true }"
Expand All @@ -121,7 +130,7 @@
></v-select>
</glue-state-sync-wrapper>

<glue-state-sync-wrapper v-if="line_visible_value" :sync="line_color_sync" :multiselect="multiselect" @unmix-state="unmix_state('line_color')">
<glue-state-sync-wrapper v-if="line_visible_value && (!marker_visible_sync.in_subscribed_states || marker_visible_value)" :sync="line_color_sync" :multiselect="multiselect" @unmix-state="unmix_state('line_color')">
<div>
<v-subheader class="pl-0 slider-label" style="height: 12px">Line Color</v-subheader>
<v-menu>
Expand All @@ -139,33 +148,33 @@
</div>
</glue-state-sync-wrapper>

<glue-state-sync-wrapper v-if="line_visible_value" :sync="line_width_sync" :multiselect="multiselect" @unmix-state="unmix_state('line_width')">
<glue-state-sync-wrapper v-if="line_visible_value && (!marker_visible_sync.in_subscribed_states || marker_visible_value)" :sync="line_width_sync" :multiselect="multiselect" @unmix-state="unmix_state('line_width')">
<glue-float-field label="Line Width" :value.sync="line_width_value" />
</glue-state-sync-wrapper>

<glue-state-sync-wrapper v-if="line_visible_value" :sync="line_opacity_sync" :multiselect="multiselect" @unmix-state="unmix_state('line_opacity')">
<glue-state-sync-wrapper v-if="line_visible_value && (!marker_visible_sync.in_subscribed_states || marker_visible_value)" :sync="line_opacity_sync" :multiselect="multiselect" @unmix-state="unmix_state('line_opacity')">
<div>
<v-subheader class="pl-0 slider-label" style="height: 12px">Line Opacity</v-subheader>
<glue-throttled-slider wait="300" max="1" step="0.01" :value.sync="line_opacity_value" hide-details class="no-hint" />
</div>
</glue-state-sync-wrapper>

<glue-state-sync-wrapper v-if="line_visible_value" :sync="line_as_steps_sync" :multiselect="multiselect" @unmix-state="unmix_state('line_as_steps')">
<glue-state-sync-wrapper v-if="line_visible_value && (!marker_visible_sync.in_subscribed_states || marker_visible_value)" :sync="line_as_steps_sync" :multiselect="multiselect" @unmix-state="unmix_state('line_as_steps')">
<v-switch
v-model="line_as_steps_value"
label="Plot profile as steps"
/>
</glue-state-sync-wrapper>

<glue-state-sync-wrapper v-if="line_visible_value" :sync="uncertainty_visible_sync" :multiselect="multiselect" @unmix-state="unmix_state('uncertainty_visible')">
<glue-state-sync-wrapper v-if="line_visible_value && (!marker_visible_sync.in_subscribed_states || marker_visible_value)" :sync="uncertainty_visible_sync" :multiselect="multiselect" @unmix-state="unmix_state('uncertainty_visible')">
<v-switch
v-model="uncertainty_visible_value"
label="Plot uncertainties"
/>
</glue-state-sync-wrapper>

<!-- MARKER/SCATTER -->
<div v-if="marker_visible_sync.in_subscribed_states">
<div v-if="marker_visible_sync.in_subscribed_states && (!marker_visible_sync.in_subscribed_states || marker_visible_value)">
<j-plugin-section-header>Marker</j-plugin-section-header>
<glue-state-sync-wrapper v-if="marker_visible_value" :sync="marker_fill_sync" :multiselect="multiselect" @unmix-state="unmix_state('marker_fill')">
<v-switch
Expand Down

0 comments on commit 4603356

Please sign in to comment.