Feature request #6960

Possibility to set item label when using single symbol

Added by Victor Axbom almost 12 years ago. Updated about 7 years ago.

Status:Open
Priority:Normal
Assignee:-
Category:Unknown
Pull Request or Patch supplied:No Resolution:
Easy fix?:No Copied to github as #:16070

Description

As it is right now you have the possibility to set an item label different from the item value when using the categorized or the other symbology-styles. It would be great if you could also set an item label when using the single symbol as symbology. This would make it easier when creating your legend in the composer. I often want the layername right next to the symbol in the legend and now I have to cut and paste the names in the legend items properties if using single symbol.

One alternative would be to have som different legend styles to choose from in the composer where the layernames, item names etc. is placed at different positions.

example.JPG (6.34 KB) Victor Axbom, 2013-01-08 01:34 AM

History

#1 Updated by Regis Haubourg almost 12 years ago

+1 for single symbols, it is annoying to manually clean composer legend for each layer.

#2 Updated by Radim Blazek over 11 years ago

Instead of setting item label (which is additional work) I would suggest to represent single symbol layers in composer as single line with layer title used as symbol label.

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

That would definitively be an improvement from current situation.

#4 Updated by Victor Axbom over 11 years ago

Yes, that would be even better!

Radim Blazek wrote:

Instead of setting item label (which is additional work) I would suggest to represent single symbol layers in composer as single line with layer title used as symbol label.

#5 Updated by Radim Blazek over 11 years ago

Changed in 4e29b6a529 so that single symbol layers are drawn on single line with layer title as symbol label if symbol text is not defined.

The space above such item is still layer space, so that single symbol layer may be visually separated from symbols of a layer above.

OTOH, the font of such item is symbol font. So it is not quite consistent.

This is implemented in QgsComposerLegend and it is not reflected in legend item properties tree widget so it may be a bit confusing. Unfortunately that is not as easy as it seems to be.

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

Radim, fantastic! The current implementation could however be IMHO improved. As it now stands, single symbol layers are always drawn on a single line, even when the user has set a layer string and a string for its single symbol.

I think the best behavior should be to drawn the layer on a single line when a single symbol layer has no string attached to its symbol in the legend.

#7 Updated by Victor Axbom over 11 years ago

Great work! Maybe a bit confusing with the symbol font for the layer name but that can be solved later

#8 Updated by Radim Blazek over 11 years ago

nirvn - wrote:

Radim, fantastic! The current implementation could however be IMHO improved. As it now stands, single symbol layers are always drawn on a single line, even when the user has set a layer string and a string for its single symbol.

I think the best behavior should be to drawn the layer on a single line when a single symbol layer has no string attached to its symbol in the legend.

It could be probably done but:

1) It is becoming a bit tricky, too many "if" behind the scene to explain to users.

2) Both cases (single symbol layer displayed with or without title) may be required. For example, if there is a layer transport with a single rule based symbol labeled railways it seems to me natural to add it in the legend as a single line only with railways label instead of to levels transport - railways.

However, I am not sure about it. There are more ways to do it and it is not clear which should be preferred. If there should be supported both possibilities, it should be done in more transparent way for the user, with an explicit option in GUI, in my opinion.

#9 Updated by Radim Blazek over 11 years ago

Victor Axbom wrote:

Great work! Maybe a bit confusing with the symbol font for the layer name but that can be solved later

Well, it is not really "layer name", it is still symbol font but layer title is omitted and its text is used as symbol label. It could be probably cleared up by calling the layer font "layer title font".

Another problem is, that because group and layer font may be different, it is problematic to simulate layers using groups (the example of mixing roads and railways from two layers into single "layer" group in legend requested by Mathieu Pellerin).

#10 Updated by Victor Axbom over 11 years ago

Radim Blazek wrote:

Well, it is not really "layer name", it is still symbol font but layer title is omitted and its text is used as symbol label. It could be probably cleared up by calling the layer font "layer title font".

Okay, I get it. That might be better, but I still think it's a little confusing as I think users will still see the symbol label as a layer title even if it's now placed besides the symbol and then try to change the "layer title font" to change the text which will not work. The best solution would be if the text could still use the layer font but be placed as a symbol label. But its just a minor issue, IMO the legend behaves much better now then before your changes.

#11 Updated by Radim Blazek over 11 years ago

Victor Axbom wrote:

Okay, I get it. That might be better, but I still think it's a little confusing as I think users will still see the symbol label as a layer title even if it's now placed besides the symbol and then try to change the "layer title font" to change the text which will not work. The best solution would be if the text could still use the layer font but be placed as a symbol label.

Would not it look strange if symbols had different fonts? Se my next comment.

#12 Updated by Radim Blazek over 11 years ago

As I am thinking about it more and more, it seems to me that we bind QGIS data layers to composer "layers" (groups of symbols) to tightly. In reality, there is only a weak relation. May be the term "layer" for a cluster of symbols in the composer context is misleading and it would be better to call it something like "subgroup" (also bad, I know, it would be better to have groups and supergroups, but we have already groups).

Symbols in a printed map maybe organized in multiple levels of grouping but all symbols are on the same (lowest) level regardless where they come from (single or multi symbol layer). While usually a layer is mapped to a subgroup, it may be that symbols of multiple layers have to be grouped into a single subgroup (as requested by Mathieu). In both cases, the subgroup title font should be the same (the first level of grouping from bottom even if we grouped symbols from multiple layers).

Feature freeze is coming, so we don't have time to implement new features but I would like to keep door open in the 2.x line for all reasonable functionality requirements. We have to get idea how it should ideally work and make QGIS compatible with such ideal future implementation before 2.0 release.

First I would like to collect all requirements. Here is a table of required QGIS data to composer legend mapping I know about (using subgroup term for former layer):

QGIS data Mapping type Composer legend
+ layer 1
  + symbol 1
  + symbol2
standard
 (subgroup space )
subgroup title (layer 1)
 (symbol space)
symbol 1
 (symbol space)
symbol2
+ layer 1
  + symbol 1
standard
 (symbol or subgroups space???)
symbol 1
grouped
 (subgroup space )
subgroup title (layer 1)
 (symbol space)
symbol 1
+ group 1
  + layer 1
    + symbol 1
    + symbol2
  + layer 2
    + symbol 1
    + symbol2
standard
 (group space)
group title (group 1)
 (subgroup space )
subgroup title (layer 1)
 (symbol space)
layer 1 - symbol 1
 (symbol space)
layer 1 - symbol2
 (subgroup space )
subgroup title (layer 2)
 (symbol space)
layer 2 - symbol 1
 (symbol space)
layer 2 - symbol2
flattened
 (subgroup space )
subgroup title (group 1)
 (symbol space)
layer 1 - symbol 1
 (symbol space)
layer 1 - symbol2
 (symbol space)
layer 2 - symbol 1
 (symbol space)
layer 2 - symbol2

Are there others? Let me know.

#13 Updated by Regis Haubourg over 11 years ago

Hi Radim,
I'm not sure to see all use cases. I tested your revision and I must say it's close to perfection to me.
yet, I found 1 bug and 1 missing small feature:
- bug: when activating feature count for single symbol layers, title is lost and it goes back to a 2 line representation. 1 line + [count] would be better. Title must stay.

- feature: I miss a parameter to indent symbol and layers in groups. Did I miss it?

Thanks for your work.
régis

#14 Updated by Victor Axbom over 11 years ago

You are probably right about not to focus too much on the connection to the data layers and skip the layer term. Then there will be less confuse about what's the layer label and symbol label. One idea could be to skip the difference between group/subgroup in your proposal, call all groups just group and let the user create group types with individual settings for font and spacing. One group type could be auto-created when creating the legend if you have multi symbol layers.

#15 Updated by Mathieu Pellerin - nIRV over 11 years ago

IMO, a "natural" behavior for users would be: if both layer title and single symbol have a string, show both. If only layer title or single symbol has a string, then display on a single line.

That said, I don't feel strongly either way. It'll probably be a minuscule irritant for people opening 1.8 projects and expecting the print composers to be identical, but shouldn't be too much of a problem if the new behavior is explained in the release notes.

Radim Blazek wrote:

It could be probably done but:

1) It is becoming a bit tricky, too many "if" behind the scene to explain to users.

2) Both cases (single symbol layer displayed with or without title) may be required. For example, if there is a layer transport with a single rule based symbol labeled railways it seems to me natural to add it in the legend as a single line only with railways label instead of to levels transport - railways.

However, I am not sure about it. There are more ways to do it and it is not clear which should be preferred. If there should be supported both possibilities, it should be done in more transparent way for the user, with an explicit option in GUI, in my opinion.

#16 Updated by Radim Blazek over 11 years ago

nirvn - wrote:

IMO, a "natural" behavior for users would be: if both layer title and single symbol have a string, show both. If only layer title or single symbol has a string, then display on a single line.

You are probably right. It may also depend on purpose of the printed map, if it is just a working draft for internal use, it may be better to have layer title + symbol to see the data structure, if it is final output, it is little probable that single symbol layer would be presented with layer title (but still possible).

In any case, if there are both layer title and symbol label non empty, we don't which one to use as symbol label. But in that case, it should be possible for the user to switch to the single line representation easily. Deleting text of one or other is possible, but a bit ugly and especially not obvious for user. Deleting the layer title text also makes work in the tree widget harder.

It may also be that the user wants to hide layer title of a layer with multiple symbols. Instead of the "flatten" group a solution for both could be "hide layer title" checkbox.

#17 Updated by Radim Blazek over 11 years ago

regis Haubourg wrote:

Hi Radim,
I'm not sure to see all use cases. I tested your revision and I must say it's close to perfection to me.
yet, I found 1 bug and 1 missing small feature:
- bug: when activating feature count for single symbol layers, title is lost and it goes back to a 2 line representation. 1 line + [count] would be better. Title must stay.

Fixed in 7008cd4 feature counts are appended to symbol labels only for multi symbol layers or non empty single symbol labels. Well, hack over hack, exactly what I wanted to avoid.

- feature: I miss a parameter to indent symbol and layers in groups. Did I miss it?

There is no such option. If implemented, it should also allow to indent group titles as other users may want to indent group and layer titles keeping symbols leftmost.

#18 Updated by Radim Blazek over 11 years ago

Victor Axbom wrote:

One idea could be to skip the difference between group/subgroup in your proposal, call all groups just group and let the user create group types with individual settings for font and spacing. One group type could be auto-created when creating the legend if you have multi symbol layers.

So you want a possibility to define styles like in a word processor and assign them to group titles. Not minimalistic at all, but in the end it could simplify things. I have to evaluate if it is feasible, but I worry that it is not before 2.0 and it will impossible to introduce it in 2.x. The indentation would go to the style.

#19 Updated by Radim Blazek over 11 years ago

I have partially implemented Victor's idea with styles. It should solve most (all?) problems we found until now. Current implementation features:

  • Groups and layers have styles which may be changed by user in the tree.
  • Currently there are 3 styles available: group, subgroup (layer) and hidden (title is not drawn at all)
  • The styles include also margins (spaces) internally but it is not yet reflected by GUI
  • Single symbol layers with empty symbol label are by default added with style hidden
  • Layer title is used to label symbol if symbol label is empty

It should be mostly backward compatible, fonts and spaces are loaded from 1.8 project files.

I am not sure if it is better to add top margin also to first item in column (current implementation) which seems to be more consistent (margin always used) but items in multiple columns may not be aligned to the top if different styles are used. Or there should be no space added above first item in column.

It would be nice to find some funding to finish the work (in 2.1) especially the GUI: style dialog including font and margins, that would also allow to add left margin which means requested "indentation".

Please verify ASAP, we have last 3 days.

#20 Updated by Victor Axbom over 11 years ago

Great work, looks good to me! I think the current implementation now covers the most cases. Might be a bit confusing to name the non-title as hidden as you get the impression that the whole item will be hidden. But this might be more clear if the gui-column "2" gets the name "Title style" or something similar.
Found a bug, if you activate the feature count, any custom symbol label will be replaced by layer name.

About the top margin, IMO there should be some possibility to align the columns to the top. Maybe a optional checkbox under "Columns" to align columns, which removes the first items top margin?

#21 Updated by Radim Blazek over 11 years ago

Victor Axbom wrote:

Great work, looks good to me! I think the current implementation now covers the most cases. Might be a bit confusing to name the non-title as hidden as you get the impression that the whole item will be hidden. But this might be more clear if the gui-column "2" gets the name "Title style" or something similar.

Done.

Found a bug, if you activate the feature count, any custom symbol label will be replaced by layer name.

I am not able to reproduce, can you specify exactly:
  • which renderer (single symbol, categorized, ...)?
  • how many classes (symbols)?
  • do classes have labels?

About the top margin, IMO there should be some possibility to align the columns to the top. Maybe a optional checkbox under "Columns" to align columns, which removes the first items top margin?

I'll keep margins for now and the suggested option may be added later.

#22 Updated by Victor Axbom over 11 years ago

Radim Blazek wrote:

Victor Axbom wrote:

Found a bug, if you activate the feature count, any custom symbol label will be replaced by layer name.

I am not able to reproduce, can you specify exactly:
  • which renderer (single symbol, categorized, ...)?
  • how many classes (symbols)?
  • do classes have labels?

Single symbol renderer and only one class. I set a new label to the symbol, press the feature count button and then the old label is back again with the feature count.

#23 Updated by Radim Blazek over 11 years ago

Victor Axbom wrote:

Single symbol renderer and only one class. I set a new label to the symbol, press the feature count button and then the old label is back again with the feature count.

Confirmed. It takes original layer title + feature count and overwrites the label set by user.

Until I fix this, I would like to clarify what should happen if the user set a different item label in composer and legend update (update button) is called? Should it keep the labels entered by the user or should it overwrite all labels entered by the user in composer by current values (from layer properties)? Most probably there should be two actions: "Soft" update which keeps user labels and "hard" update which resets all labels.

At this moment (after feature freeze) we can only choose one, and make it work consistently. I think that the "soft" update is probably more often desired.

Another question is, how to maintain user labels (entered in composer) together with feature counts. Usually the counts should be updated even if the label was overwritten by the user. OTOH, it may be, that the user wants to modify how feature counts are presented, for example overwrite "[123]" by "(123 features)" or even set manually the counts for certain classes. The best (most flexible solution) would probably be to use some special character or string to represent the count in the label. The label edited by user would look like "Roads [#]" and # would represent feature count.

#24 Updated by Victor Axbom over 11 years ago

Radim Blazek wrote:

Victor Axbom wrote:

Single symbol renderer and only one class. I set a new label to the symbol, press the feature count button and then the old label is back again with the feature count.

Confirmed. It takes original layer title + feature count and overwrites the label set by user.

Until I fix this, I would like to clarify what should happen if the user set a different item label in composer and legend update (update button) is called? Should it keep the labels entered by the user or should it overwrite all labels entered by the user in composer by current values (from layer properties)? Most probably there should be two actions: "Soft" update which keeps user labels and "hard" update which resets all labels.

At this moment (after feature freeze) we can only choose one, and make it work consistently. I think that the "soft" update is probably more often desired.

Another question is, how to maintain user labels (entered in composer) together with feature counts. Usually the counts should be updated even if the label was overwritten by the user. OTOH, it may be, that the user wants to modify how feature counts are presented, for example overwrite "[123]" by "(123 features)" or even set manually the counts for certain classes. The best (most flexible solution) would probably be to use some special character or string to represent the count in the label. The label edited by user would look like "Roads [#]" and # would represent feature count.

IMO the "soft" update would be the most desired. But as you say, there could also be a hard update avaible but with a warning message that all custom labels will be removed. The proposal with the custom sign for feature count looks nice, could be useful!
By the way, the name of the gui-columns is still "1" and "2", or am I missing something there?

#25 Updated by Radim Blazek over 11 years ago

Victor Axbom wrote:

Found a bug, if you activate the feature count, any custom symbol label will be replaced by layer name.

Fixed in 4c7f51e. User defined labels are now stored separately.

There are two update buttons
  • Update item - Update legend. User defined labels are preserved.
  • Update all - Update whole legend. Layers are added/removed according to main application legend. User defined labels will be deleted.
There are still little imperfections:
  • If feature count is activated and edit item text dialog is opened, the text contains also the feature count, but user has to enter the text without feature count. Feature count will be appended automatically.
  • Special character for the count is not yet supported (it would be simple, just decide the character, it is necessary to look around what is used in such situations in QGIS - $,%...?).
  • Classes labels are preserved based on classes order. If classes order changed in the layer, the user labels will be wrong. There is no unique layer class identifier which could be used.

BTW, some code should be probably moved from QgsLegendModel to QgsComposerLegendItem children.

#26 Updated by Adam Szieberth about 8 years ago

As a workaround, just switch to rule based symbol layer with a single rule = true. You can set custom legend text then.

#27 Updated by Giovanni Manghi over 7 years ago

  • Easy fix? set to No

#28 Updated by Jürgen Fischer about 7 years ago

  • Category set to Unknown

Also available in: Atom PDF