Skip to content

Remove axis padding from equal-aspect image plot#226

Merged
JamesDoingStuff merged 1 commit into
mainfrom
jg/fix-image-plot-expansion
Mar 25, 2026
Merged

Remove axis padding from equal-aspect image plot#226
JamesDoingStuff merged 1 commit into
mainfrom
jg/fix-image-plot-expansion

Conversation

@JamesDoingStuff

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread client/component/src/ImagePlot.tsx Outdated
Comment thread client/component/src/ImagePlot.tsx Outdated
Comment thread client/component/src/ImagePlot.tsx Outdated

@PeterC-DLS PeterC-DLS 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.

Looks fine apart from my comments

@VictoriaBeilsten-Edmands VictoriaBeilsten-Edmands left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would you add an example of a plot in different sized containers to a tab in client/example/src/App.tsx

@JamesDoingStuff JamesDoingStuff force-pushed the jg/fix-image-plot-expansion branch 2 times, most recently from 67b2db8 to 0886a8b Compare February 13, 2026 15:13
@JamesDoingStuff JamesDoingStuff marked this pull request as ready for review February 13, 2026 15:20

@PeterC-DLS PeterC-DLS 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.

Please add the new attribute to ImagePlot.stories

Comment thread client/component/src/ImagePlot.tsx
@JamesDoingStuff JamesDoingStuff force-pushed the jg/fix-image-plot-expansion branch from 0886a8b to aa50b65 Compare March 4, 2026 14:00
@JamesDoingStuff

Copy link
Copy Markdown
Collaborator Author

Updated to add story. I wasn't able to get the useMeasure hook to work without causing infinite re-renders - the ref from that hook seems to behave slightly differently to the one from useRef in a straight swap.

@PeterC-DLS

Copy link
Copy Markdown
Contributor

Does setting tightAxes=true always mean that the axes are drawn wholly to the image extent?

In the screenshot, I squeezed the browser window horizontally. The left plot has space visible at the bottom, and the top right plot has space on the left and right side:.
tight-axes

@JamesDoingStuff JamesDoingStuff force-pushed the jg/fix-image-plot-expansion branch from aa50b65 to e9f2204 Compare March 5, 2026 10:17
@JamesDoingStuff

Copy link
Copy Markdown
Collaborator Author

Sorry about that, I hadn't noticed - it seemed to revert back to the correct aspect when expanding the window at all, so not sure what exactly wasn't triggering when shrinking it. I've changed it so that instead of re-triggering the effect, it uses a resize observer callback. I think it's fixed now and the animation seems smoother as a bonus

@PeterC-DLS

Copy link
Copy Markdown
Contributor

I think there is still an issue when reducing the window height. The bottom right plot has space on the left and right:
Screenshot from 2026-03-05 11-58-43

@JamesDoingStuff

Copy link
Copy Markdown
Collaborator Author

Damn, back to the drawing board... Thanks for letting me know

@JamesDoingStuff

Copy link
Copy Markdown
Collaborator Author

Actually I think that that might be a result of the plot's toolbar reaching it's minimum size - the space only starts appearing once the toolbar hits the left boundary of the plot. This is what happens if you turn it off:
image
I could get the plot to shrink smaller than the toolbar if you'd like, but at that point the title formatting is going to be messed up anyway and there's not much I can do about that

@PeterC-DLS

Copy link
Copy Markdown
Contributor

How easy is it to move the title to its own box so it isn't constrained by the plot size?

@JamesDoingStuff

Copy link
Copy Markdown
Collaborator Author

The title (as it currently exists) gets handled way down in the h5web VisCanvas component, so I wouldn't want to mess with that. Adding in a new title box would be possible I suppose, but would probably add more complexity to this feature

@PeterC-DLS

Copy link
Copy Markdown
Contributor

Ok, if you allow the plot to be smaller than the toolbar width, does the items on the toolbar flow into the drop-down menu?

@JamesDoingStuff JamesDoingStuff force-pushed the jg/fix-image-plot-expansion branch from e9f2204 to a038c8f Compare March 13, 2026 15:04
@JamesDoingStuff JamesDoingStuff force-pushed the jg/fix-image-plot-expansion branch from a038c8f to 60bd19a Compare March 23, 2026 09:08
@JamesDoingStuff

Copy link
Copy Markdown
Collaborator Author

Apologies for not getting this finished before going on leave. The issue was that I'd put the toolbar it its own div - setting minWidth: 0 for that div lets the toolbar shrink again

@PeterC-DLS

Copy link
Copy Markdown
Contributor

The example app behaves fine when I squeeze the window horizontally: plots seem to have minimum widths and the toolbar narrows and items overflow to dropdown menu properly.

@PeterC-DLS PeterC-DLS 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.

LGTM

@JamesDoingStuff JamesDoingStuff added this pull request to the merge queue Mar 25, 2026
Merged via the queue into main with commit c40adf7 Mar 25, 2026
2 checks passed
@JamesDoingStuff JamesDoingStuff deleted the jg/fix-image-plot-expansion branch March 25, 2026 10:37
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.

3 participants