Bug report #3605

on trunk, legend items vertical spacing inconsistent, worked fine with 1.6

Added by Mathieu Pellerin - nIRV over 9 years ago. Updated over 9 years ago.

Status:Closed
Priority:Low
Assignee:Marco Hugentobler
Category:Map Legend
Affected QGIS version: Regression?:No
Operating System:All Easy fix?:No
Pull Request or Patch supplied: Resolution:fixed
Crashes QGIS or corrupts data: Copied to github as #:13664

Description

This problem started few weeks ago (sorry, can't be more precise than this).

Map legend items' vertical spacing is inconsistent when rendering layer item with one child (i.e. one rule) versus layer item with many children (i.e. rule-based children, classified symbology children, etc.). It's hard to explain with words, hopefully the screenshots attached will make it clear enough.

Problem results in visually unappealing legend boxes.

bug-vertical-spacing-legendcanvas.jpg (108 KB) Mathieu Pellerin - nIRV, 2011-03-13 07:46 PM

bug-vertical-spacing-item-list.jpg (56.7 KB) Mathieu Pellerin - nIRV, 2011-03-13 07:46 PM

legend-simple-scenario.jpg (74.4 KB) Mathieu Pellerin - nIRV, 2011-03-24 10:27 PM

History

#1 Updated by Mathieu Pellerin - nIRV over 9 years ago

http://trac.osgeo.org/qgis/changeset/15242/trunk/qgis/src/core/composer/qgscomposerlegend.cpp

I pretty sure the changeset above is causing the unwanted extra space. The changeset should be reverted as it doesn't make sense to add extra vertical space for empty title string layers.

#2 Updated by Marco Hugentobler over 9 years ago

From the screenshots it seems to me that Roads & Rivers / River are coming from two different maplayers. Is that correct?

As you know, the legend has the feature of omiting the layer title line if it is empty and there is only one class. Now a user complained that the layer space in the legend is not considered in this case, which was fixed in changeset 15242. The vertical spacing is a feature that facilitates recognizing the layer grouping by the user. If you don't like it, it is probably better to adjust the layer space in the legend settings.

#3 Updated by Mathieu Pellerin - nIRV over 9 years ago

Yep, the roads & rivers is basically a road layer + a river layer with empty layer name.

I don't understand the logic behind inserting vertical layer space in the flow when a user leaves the layer name empty (a declaration the user wants to skip the layer name and group its symbol with symbol(s) above it).

Look at the new file attached (legend-simple-scenario.jpg). This is, IMO, a typical legend case scenario, and it looks pretty bad with the added vertical spacing on empty layer names. Setting the layer spacing to 0 in favor of adjusting symbol space doesn't work well as it leaves no space between the legend title and the legend symbols. Setting layer spacing to 0 also removes all spacing for group (which could have been another alternative)

Re the "if I don't like it" argument, I actually don't think this is about me liking the situation or not as much as considering this change a visual regression (again, see latest attachment). If the user that complained about lack of layer space, he/she should name the layer, or even put a few empty spaces in the layer name to indicate to qgis he/she wants a space.

The changeset also reverse a consistent behavior of qgis since at least qgis 1.2. This is bound to affect more than one user :)

#4 Updated by Mathieu Pellerin - nIRV over 9 years ago

The user who complained should probably file a ticket and have a discussion surrounding his specific needs and possibilities to enhance the legend. But again, at the risk of repeating myself, I don't see this user's corner case as a valid reason to break away from qgis' long time established behavior :)

Maybe the solution for that user is to add a spacer element to the legend.

#5 Updated by Marco Hugentobler over 9 years ago

I think we can support both use-cases. Try 08c88575 (SVN r15605), I hope you can achieve the homogenous spacing by setting the same value for 'layer space' and 'item space'. Does it work?

#6 Updated by Mathieu Pellerin - nIRV over 9 years ago

mhugent, will check as soon as the qgis trunk PPA gets updated.

Thanks for working on this issue. I see what you're trying to achieve with this latest revision. It's a good workaround. However, it forces/restrains users to keep a layer space == item space.

Meditating on this yesterday night, IMO the best solution is to add a "[x] keep vertical margin on hidden layer titles" option in the General tab of a legend object. That way, you introduce this user-case as a new feature and insure legends created in qgis projects prior to 1.7 don't visually regress. It also allows for users to not have undesired vertical spacing while still having flexibility to independently set layer space and item space.

What do you think?

#7 Updated by Mathieu Pellerin - nIRV over 9 years ago

mhugent, I've tried with latest PPA and confirm workaround is working.

Since there was an agreement among developers to slightly delay the release of qgis 1.7, it might be a good occasion to implement the most flexible solution for this issue, that is the implementation of a "[x] keep vertical margin on hidden layer titles" option.

I'm no expert in qgis source code but from what I can understand, it'd wouldn't that much work (i.e. one additional line in legend's readXML, writeXML, and it's constructor).

Cheers, thanks for considering this :)

#8 Updated by Marco Hugentobler over 9 years ago

  • Resolution set to fixed
  • Status changed from Open to Closed

In my opinion, it does not make sense to introduce a new gui element just to have more convenient way to enable old behaviour.

I've set the layer space and the item space equal per default, so default behaviour is same as for versions < 1.6

Also available in: Atom PDF