Skip to content

To align mark and the label vertically in a Legend#3206

Merged
j9ac9k merged 1 commit intopyqtgraph:masterfrom
jiban:master
Jan 25, 2025
Merged

To align mark and the label vertically in a Legend#3206
j9ac9k merged 1 commit intopyqtgraph:masterfrom
jiban:master

Conversation

@jiban
Copy link
Copy Markdown
Contributor

@jiban jiban commented Dec 20, 2024

This will solve #3199

ItemSample had zero width and height.
This change sets width and height according to the boundingRect and adjusts horizontal spacing accordingly.
Besides, vertical alignment option has been given.

Fixes #3199
Fixes #3027

Copy link
Copy Markdown
Member

@ixjlyons ixjlyons left a comment

Choose a reason for hiding this comment

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

This seems reasonable enough to me.

I'll point out that making the label text really small gives the opposite issue where the sample dictates the row size and the text appears aligned to the top of the row, but setting AlignVCenter on the label doesn't fix it. I think this is fairly unlikely unless/until we make the sample size modifiable in some way rather than hard-coding 20 (i.e. it's not really noticeable until you get down to labelTextSize="6pt" or so).

image

Note this should also close #3027

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Jan 25, 2025

Thanks for the PR @jiban and thanks for the review @ixjlyons

I updated the original post so the relevant issues are automatically closed. Diff LGTM, merging.

@j9ac9k j9ac9k merged commit 41c2470 into pyqtgraph:master Jan 25, 2025
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.

Vertical mis-alignment in LegendItem between ItemSample and Label Increasing Legend text generate a vertical misalignment with the sample.

3 participants