Force scale ratio if x and y axis have same unit for 1D and 2D plots#80
Force scale ratio if x and y axis have same unit for 1D and 2D plots#80mfiaudrin-epsyl wants to merge 1 commit into
Conversation
Documentation build overview
48 files changed ·
|
There was a problem hiding this comment.
Pull request overview
Adds automatic 1:1 axis scaling for 1D and 2D plots when the relevant axes share the same unit, improving visual comparability for same-unit data.
Changes:
- SimplePlotly: compute a
shouldForceRatiorule and apply Plotlyxaxis.scaleanchor/scaleratioaccordingly. - Heatmap2D: compute a similar
shouldForceRatiorule from coordinate units and apply the same Plotly layout constraint.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| frontend/src/renderer/components/plot/SimplePlotly.tsx | Adds a same-unit detection rule and conditionally anchors x/y scaling via Plotly layout. |
| frontend/src/renderer/components/plot/Heatmap2D.tsx | Adds a coordinate-unit equality rule and conditionally anchors x/y scaling via Plotly layout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| useEffect(() => { | ||
| const coordinateUnit = itemDataGrid.coordinates.find( | ||
| (c) => c.axeIndex === 0, | ||
| )?.unit; | ||
| const allPlotsHaveSameUnit = itemDataGrid.plot.every( | ||
| (plot) => plot.unit === itemDataGrid.plot[0]?.unit, | ||
| ); | ||
| setShouldForceRatio( | ||
| allPlotsHaveSameUnit && coordinateUnit === itemDataGrid.plot[0]?.unit, | ||
| ); | ||
| }, [itemDataGrid.coordinates]); |
| /** | ||
| * Update layout to force ratio are not | ||
| */ |
| useEffect(() => { | ||
| const firstCoordinateUnit = itemDataGrid.coordinates.find( | ||
| (c) => c.axeIndex === 0, | ||
| )?.unit; | ||
| const secondCoordinateUnit = itemDataGrid.coordinates.find( | ||
| (c) => c.axeIndex === 1, | ||
| )?.unit; | ||
| setShouldForceRatio(firstCoordinateUnit === secondCoordinateUnit); | ||
| }, [itemDataGrid.coordinates]); |
| /** | ||
| * Update layout to force ratio are not | ||
| */ |
|
Errors encountered when testing this PR are described in #84 (it also affects the Otherwise the square ratio feature works as expected. From our last discussion with the group and @imbeauf, we mentioned that ideally there would be a customization option to allow the user to disable the fixed ratio (fix ratio is good as the default behavior), as well as to enable fixed ratio even if units are not the same in x and y. |
This feature add a rule to display the plots with the the same ratio between x & y axis if they have the same unit.