Bug report #16795
[Composer Legend] Symbology of layer always follows the map canvas and breaks the composer legend
|Affected QGIS version:||3.5(master)||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||24694|
Create two different styles for a single layer.
Now in print composer, do a layout and add the layer to a composer legend.
Go to the map canvas and activate the other style of the layer. In your composer legend, you'll notice that the layer legend has changed and follows what is shown in the map canvas and not the style you have set at the beginning (which should be in line with your map).
Note that if you switch the map canvas to a preset visibility that contains the layer with the first style, the style is well rendered in the legend.
If you had switched to a preset visibility that doesn't use the layer, no change is done in the legend either.
This state can easily corrupt the legend of the layout unless you check each print composer (actually update map canvas with correct preset visibility) before exporting (to ensure the legend shown is in line with the maps in composer) --> time consuming, prone to error (and discourages to use multiple styles for a single layer).
I think that legend of the layer should be bound to the style it has been added with to the composer, and follow the changes in that style. But it shouldn't switch between styles, according to what's enabled or not in the map canvas.
Ouch! I'm rewording given that the description above is just ununderstandable. Sorry, devs. Let's do it simple :-)
In few words, the symbol shown in a legend item follows the style of the layer in the map canvas and not the styled used in the map item: it uses the style applied to the layer the last time it was visible.
In a project where multiple styles are used for a single layer, this becomes problematic.
Still applies to 2.18 and master 3.1
#3 Updated by Pieter Brusselman about 4 years ago
I have a similar issue using visibility-presets/themes. In the printcomposer you can assign a certain preset/theme to a map. However, the legend does not follow the assigned preset/theme, even if auto update is unchecked. The legend that shows up is the one that is active in the projectwindow.