Skip to content

Correct layout and functionalities#493

Merged
tschaume merged 9 commits intomaterialsproject:mainfrom
minhsueh:pourbaix2
Nov 4, 2025
Merged

Correct layout and functionalities#493
tschaume merged 9 commits intomaterialsproject:mainfrom
minhsueh:pourbaix2

Conversation

@minhsueh
Copy link
Copy Markdown
Collaborator

@minhsueh minhsueh commented Oct 29, 2025

Original error:
The concentration/composition inputs appear after heatmap entries are provided, but they should appear immediately after Pourbaix entries are entered.

Root cause:
Several callbacks have interdependent triggers, and their execution order isn’t controlled correctly.

TODO:

  • Display concentration and composition inputs after Pourbaix entries are provided.
  • Remove annotations from the heatmap, as suggested by Kristin.
  • Format composition input and invalid input windows.
  • Adjust concentration range limits from 1e-8 to 5, take care of invalid input.
  • Verify that changing concentration affects the calculated energy. Preliminary results show a change, but it appears too small to notice.
  • Implement a concentration input for support heatmap generation (or at least display what concentration is being used)
  • Correct heatmap entries when filtering solids
  • Include instructions on how to zoom in and out for the Pourbaix diagram (as suggested by Mackinzie).
  • Error handling if composition is invalid

Takeaway:

  1. Trigger discipline:
    Avoid using MPComponent.get_all_kwargs_id() as an Input in multiple callbacks—typing or minor changes in any child will fire callbacks unexpectedly. Use it only for a single, dedicated callback when sub-components are generated dynamically, and you can’t explicitly list triggers. Otherwise, prefer explicit Inputs (or dict/pattern IDs) and use State for values that shouldn’t trigger. (mpc limits the ID format—so for this repo, keeping MPComponent.get_all_kwargs_id())
  2. Static shell, dynamic children:
    Don’t create your main components inside callbacks. Put stable containers in the initial layout and add dynamic sub-components to their children. This avoids common errors like “component id not found” and “duplicate id.”

@minhsueh minhsueh marked this pull request as draft October 29, 2025 01:11
@minhsueh
Copy link
Copy Markdown
Collaborator Author

minhsueh commented Nov 1, 2025

The previous design for adjusting composition was counterintuitive and failed to render properly on the web due to incorrect callback references.

Before:
Screenshot 2025-10-31 at 5 55 45 PM

After:
Screenshot 2025-10-31 at 5 56 59 PM

@minhsueh
Copy link
Copy Markdown
Collaborator Author

minhsueh commented Nov 4, 2025

After resetting the axes (e.g., zooming in/out), the updated axes may not match the original ones.

Screenshot 2025-11-03 at 5 01 22 PM

This behavior appears to be a long-standing issue in Dash.

This might also occur in other components we have.

Reference:
https://community.plotly.com/t/dash-reset-axes-range-not-updating-if-ranges-specified-in-layout/25839/3

Fix:
Intentionally update the graph by wrapping it in an html.Div instead of directly modifying go.Figure or dcc.Graph.

@minhsueh minhsueh marked this pull request as ready for review November 4, 2025 21:52
@minhsueh minhsueh requested a review from tschaume November 4, 2025 21:53
@tschaume tschaume merged commit bd75b78 into materialsproject:main Nov 4, 2025
6 checks passed
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.

2 participants