Skip to content

Add auto-wrap after setting for layout legends #61361

Merged
nyalldawson merged 5 commits intoqgis:masterfrom
nyalldawson:legend_wrap
Apr 9, 2025
Merged

Add auto-wrap after setting for layout legends #61361
nyalldawson merged 5 commits intoqgis:masterfrom
nyalldawson:legend_wrap

Conversation

@nyalldawson
Copy link
Collaborator

Allows legend text to be automatically wrapped after a set line length (in millimeters).

This can prevent very wide auto-generated legends.

Sponsored by North Road, thanks to SLYR

Peek.2025-04-07.15-36.mp4
Apply font scaling workaround to avoid unpredictable font metrics
when zooming in/out of layout
@nyalldawson nyalldawson added Feature Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo. Changelog Items that are queued to appear in the visual changelog - remove after harvesting labels Apr 7, 2025
@qgis-bot
Copy link
Collaborator

qgis-bot commented Apr 7, 2025

@nyalldawson

This pull request has been tagged for the changelog.

  • The description will be harvested so please provide a "nearly-ready" text for the final changelog
  • If possible, add a nice illustration of the feature. Only the first one in the description will be harvested (GIF accepted as well)
  • If you can, it's better to give credits to your sponsor, see below for different formats.

You can edit the description.

Format available for credits
  • Funded by NAME
  • Funded by URL
  • Funded by NAME URL
  • Sponsored by NAME
  • Sponsored by URL
  • Sponsored by NAME URL

Thank you!

@qgis-bot
Copy link
Collaborator

qgis-bot commented Apr 7, 2025

@nyalldawson
This pull request has been tagged as requiring documentation.

A documentation ticket will be opened at https://github.com/qgis/QGIS-Documentation when this PR is merged.

Please update the description (not the comments) with helpful description and screenshot to help the work from documentors.
Also, any commit having [needs-doc] or [Needs Documentation] in will see its message pushed to the issue, so please be as verbose as you can.

Thank you!

@github-actions github-actions bot added this to the 3.44.0 milestone Apr 7, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Apr 7, 2025

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 7f352f6)

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit 7f352f6)

@qgis qgis deleted a comment from github-actions bot Apr 7, 2025
@qgis qgis deleted a comment from github-actions bot Apr 7, 2025
Allows legend text to be automatically wrapped after a set
line length (in millimeters).

This can prevent very wide auto-generated legends.

Sponsored by North Road, thanks to SLYR
This isn't exposed, and needs more thought before it is (should
we use RenderUnits or LayoutUnits?)
Copy link
Contributor

@nirvn nirvn left a comment

Choose a reason for hiding this comment

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

Nice, I love of these things are so easy to add now that the legend is using our text renderer classes.

@nyalldawson nyalldawson merged commit 1e1c415 into qgis:master Apr 9, 2025
32 checks passed
@nyalldawson nyalldawson deleted the legend_wrap branch April 9, 2025 03:09
@qgis-bot
Copy link
Collaborator

qgis-bot commented Apr 9, 2025

@nyalldawson
A documentation ticket has been opened at qgis/QGIS-Documentation#9772
It is your responsibility to visit this ticket and add as much detail as possible for the documentation team to correctly document this change.
Thank you!

@DelazJ
Copy link
Contributor

DelazJ commented Apr 22, 2025

@nyalldawson, Do you have an example of the use case of the data-defined "Assistant" entry, for this feature? Thanks
word_wrap_assistant

@nyalldawson
Copy link
Collaborator Author

@DelazJ this should be of use for atlases where you may want to tweak the legend appearance on different pages. Or for dynamic layouts which adjust legend sizes based on eg page orientation.

@DelazJ
Copy link
Contributor

DelazJ commented Apr 27, 2025

Thanks @nyalldawson for the reply. I see how this can be done using expression. My point refers mainly to the Assistant widget that generates values sequentially, not really foreseeable. I can't see what data it may be compatible with, in real life situations. If you have such data/case, I think it may be of great help we share in the docs. Thanks.

I saw the assistant widget on another option in the layout and got also surprised, but I'm currently away from QGIS for checking. Added to any numeric widget such as legend column number, rotation, opacity, map scale...

@nyalldawson
Copy link
Collaborator Author

@DelazJ assistant is just shown everywhere for these buttons. There's no use case I can see for it here, but it's just generic functionality from those buttons

@DelazJ
Copy link
Contributor

DelazJ commented Apr 28, 2025

Thanks @nyalldawson That clarifies.

@zacharlie zacharlie added ChangelogHarvested This PR description has been harvested in the Changelog already. and removed Changelog Items that are queued to appear in the visual changelog - remove after harvesting labels May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ChangelogHarvested This PR description has been harvested in the Changelog already. Feature Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo. Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks

5 participants