Skip to content

Remember result dimension selections between variables#329

Merged
Femkemilene merged 2 commits into
mainfrom
issue-324-remember-results-selections
Jul 2, 2026
Merged

Remember result dimension selections between variables#329
Femkemilene merged 2 commits into
mainfrom
issue-324-remember-results-selections

Conversation

@Sanatparida01

Copy link
Copy Markdown
Collaborator

Fixes #324.

  • This PR updates the Results page so that dimension selections are remembered by classification when switching between variables. For example, if two variables both use Region or the same FTT:P technology classification, the selected values are kept instead of resetting to the first available option.

  • I tested this locally with FTT-P results. Switching between MEWG and MEWS preserved the selected regions and FTT:P technologies. I also tested the All/Sum options for matching classifications, and these were preserved when switching between variables with the same dimension setup.

  • I additionally checked a variable with a different dimension setup, PRSCX. In that case, the selected regions were preserved, but the FTT:P technology selector was not shown, which is expected because PRSCX does not use that technology dimension.

  • I also tried a few other variable switches to check that selections are only carried over when the underlying classifications match.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Results page variable/dimension selector logic so that dimension selections (including “All” and “Sum”) persist when switching between variables that share the same underlying classification (e.g., RTI regions, T2TI technologies), addressing issue #324.

Changes:

  • Introduces per-classification caches for selected dimension values and aggregate (“Sum”) flags.
  • Initializes dimension selectors from the cached selections when the same classification is encountered again.
  • Updates caches when users change dimension selections or aggregation options.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread GUI/page_results.py Outdated
Comment on lines +321 to +324
if not hasattr(state, 'dim_selection_cache'):
state.dim_selection_cache = {}
if not hasattr(state, 'dim_aggregate_cache'):
state.dim_aggregate_cache = {}
Comment thread GUI/page_results.py
Comment on lines +392 to 398
if dim_name in state.dim_selection_cache:
dim_select.value = [
value for value in state.dim_selection_cache[dim_name]
if value in dim_values
]
elif dim_values:
dim_select.value = [dim_values[0]]
Comment thread GUI/page_results.py
Comment on lines 402 to 406
def handler(e):
state.dim_selections[idx][f'dim{idx}_values'] = e.sender.value
selected_values = list(e.sender.value or [])
state.dim_selections[idx][f'dim{idx}_values'] = selected_values
state.dim_selection_cache[dim_key] = selected_values
update_plot()
Comment thread GUI/page_results.py Outdated
Comment on lines +418 to +422
selected_values = list(vals) if e.value else []
if e.value:
selector.value = vals
selector.value = selected_values
else:
selector.value = []
selector.value = selected_values
@Femkemilene

Copy link
Copy Markdown
Contributor

@copilot: question only, do not make code changes. When I go to settings and come back to the graph, the line disappears. I only have to reselect one dimension for it to reappear, but what can I do to make that more sticky?

@Sanatparida01: I've tested it, and it's a great improvement. This is going to save users a lot of headaches. Thanks so much! Of the copilot suggestions, the first, third and last seem valid. Could you implement those (or ask copilot to implement if you're able to click on those too).

Copilot AI commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

@copilot: question only, do not make code changes. When I go to settings and come back to the graph, the line disappears. I only have to reselect one dimension for it to reappear, but what can I do to...

This behavior is currently due to the Results view being reconstructed when you return from Settings, while the chart redraw only happens after a selector change event. For now, the practical workaround is exactly what you found: toggle/reselect one dimension to trigger a redraw.

To make it sticky long-term, the fix is to persist the active dimension selections in page state and trigger a plot refresh when the Results page is shown (not only on selector-change handlers).

@Femkemilene Femkemilene left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

@Sanatparida01

Sanatparida01 commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator Author

@Femkemilene Thanks for the review. I’ve implemented the first, third, and last Copilot suggestions:
---moved the dimension selection caches into GUIState,
---updated the All checkbox so it stays in sync with the selected values,
---simplified the repeated assignment in the All handler.

@Femkemilene Femkemilene left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes done

@Femkemilene
Femkemilene merged commit 8f4d326 into main Jul 2, 2026
1 check passed
@Femkemilene
Femkemilene deleted the issue-324-remember-results-selections branch July 2, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remember selection of region/technologies when switching variable

4 participants