17.2.5. L’Oggetto Legenda

L’oggetto Legenda è una casella o una tabella che spiega il significato dei simboli usati sulla mappa. Una legenda è quindi legata ad un elemento della mappa. È possibile aggiungere una legenda con lo strumento addLegend Aggiungi una nuova legenda al Layout seguendo items creation instructions e manipolarla come esposto in Interagire con gli oggetti del layout.

Per impostazione predefinita, l’elemento legenda visualizza tutti i layer disponibili e può essere raffinato utilizzando il pannello Proprietà dell’oggetto. A parte le items common properties, questo pannello ha le seguenti funzionalità (vedi figure_layout_legend):

../../../../_images/legend_properties.png

Fig. 17.24 Pannello Proprietà Oggetto Legenda

17.2.5.1. Proprietà principali

La finestra di dialogo Proprietà principali del pannello legenda Proprietà dell’oggetto fornisce le seguenti opzioni (vedi figure_layout_legend_ppt):

../../../../_images/legend_mainproperties.png

Fig. 17.25 Legenda gruppo Proprietà principali

Nelle proprietà principali puoi:

  • Change the Title of the legend. It can be made dynamic using the data-defined override setting, useful for example when generating an atlas;

  • Choose which Map item the current legend will refer to. By default, the map over which the legend item is drawn is picked. If none, then it falls back to the reference map.

    Nota

    Variables of the linked map item (@map_id, @map_scale, @map_extent…) are also accessible from data-defined properties of the legend.

  • Wrap the text of the legend on a given character: each time the character appears, it’s replaced with a line break;

  • Set the symbols and text placement in the legend: the Arrangement can be Symbols on left or Symbols on right. The default value depends on the locale in use (right-to-left based or not).

  • Use checkbox Resize to fit contents to control whether or not a legend should be automatically resized to fit its contents. If unchecked, then the legend will never resize and instead just stick to whatever size the user has set. Any content which doesn’t fit the size is cropped out.

17.2.5.2. Oggetti della Legenda

Il gruppo Oggetti della Legenda del pannello Legenda di Proprietà dell’oggetto fornisce le seguenti funzionalità (vedi figure_layout_legend_items):

../../../../_images/legend_items.png

Fig. 17.26 Gruppo Oggetti della Legenda

  • The legend will be updated automatically if checkbox Auto-update is checked. When Auto-update is unchecked this will give you more control over the legend items. All the icons below the legend items list will be activated.

  • La finestra degli oggetti legenda elenca tutte gli oggetti legenda e consente di modificare l’ordine degli oggetti, raggruppare i layer, rimuovere e ripristinare gli oggetti nell’elenco, modificare i nomi dei layer e aggiungere un filtro.

    • L’ordine degli oggetti può essere modificato utilizzando i pulsanti arrowUp e arrowDown, oppure con la funzionalità “drag-and-drop”. L’ordine non può essere modificato per le legende WMS.

    • Utilizza il pulsante addGroup per aggiungere un gruppo legenda.

    • Utilizza il pulsante signPlus per aggiungere layer e il pulsante signMinus per rimuovere gruppi, layer o classi di simboli.

    • Il pulsante projectProperties viene utilizzato per modificare il nome del layer, del gruppo o del titolo. In primo luogo devi selezionare l’oggetto della legenda. Facendo doppio click sull’oggetto si apre anche la casella di testo per rinominarlo.

    • expression allows you to add expressions to each symbol label of a given layer. New variables (@symbol_label, @symbol_id and @symbol_count) help you interact with the legend entry.

      For example, given a categorized layer, you can append to each class in the legend their number of features, ie class (number):

      1. Select the layer entry in the legend tree

      2. Press the expression button, opening the Expression String Builder dialog

      3. Enter the following expression:

        concat( @symbol_label, ' (', @symbol_count, ')' )
        
      4. Premi OK

    • Il pulsante sum aggiunge il conteggio delle ricorrenze per ogni tipo di layer vettoriale.

    • Il pulsante expressionFilter Filtra legenda tramite espressione ti aiuta a filtrare quali delle voci della legenda di un layer saranno visualizzate per un layer che ha oggetti diversificati (ad esempio, da una simbologia basata su regole o categorizzata) si può specificare un’espressione booleana per rimuovere dall’albero della legenda, stili che non hanno alcun elemento soddisfacente una condizione. Tieni presente che gli elementi sono comunque conservati e mostrati nell’oggetto della mappa del layout.

    While the default behavior of the legend item is to mimic the Layers panel tree, displaying the same groups, layers and classes of symbology, right-click any item offers you options to hide layer’s name or raise it as a group or subgroup. In case you have made some changes to a layer, you can revert them by choosing Reset to defaults from the contextual menu of the legend entry.

    Dopo aver modificato la simbologia nella finestra principale di QGIS, puoi fare click su Aggiorna tutto per adottare le modifiche nell’oggetto legenda del layout di stampa.

  • With the checkbox Only show items inside linked map, only the legend items visible in the linked map will be listed in the legend. This tool remains available when checkbox Auto-update is active

  • Durante la generazione di un atlante con layers poligonali, è possibile filtrare gli oggetti di legenda che si trovano al di fuori della scelta fatta per l’atlante corrente. Per farlo, seleziona l’opzione checkbox Mostra solamente elementi all’interno della geometria dell’atlante.

17.2.5.3. Fonts

The Fonts group of the legend Item Properties panel provides the following functionalities:

../../../../_images/legend_fonts.png

Fig. 17.27 Legend Fonts properties

  • You can change the font of the legend title, group, subgroup and item (feature) in the legend item using the font selector widget

  • For each of these levels you can set the text Alignment: it can be Left (default for left-to-right based locales), Center or Right (default for right-to-left based locales).

  • You set the Color of the labels using the color selector widget. The selected color will apply to all the font items in the legend.

17.2.5.4. Columns

Under the Columns group of the legend Item Properties panel, legend items can be arranged over several columns:

  • Set the number of columns in the Count selectNumber field. This value can be made dynamic e.g., following atlas features, legend contents, the frame size…

  • checkbox Uguale larghezza delle colonne imposta la stessa larghezza fra le colonne affiancate.

  • L’opzione checkbox Dividi i layer consente di dividere le colonne della legenda per layer categorizzati o graduati.

../../../../_images/legend_columns.png

Fig. 17.28 Legend Columns settings

17.2.5.5. Symbol

The Symbol group of the legend Item Properties panel configures the size of symbols displayed next to the legend labels. You can:

  • Set the Symbol width and Symbol height

  • checkbox Draw stroke for raster symbols: this adds an outline to the symbol representing the band color of the raster layer; you can set both the Stroke color and Tickness.

../../../../_images/legend_symbol.png

Fig. 17.29 Legend Symbol configuration

17.2.5.6. Legenda WMS e Spaziatura

Il pannello Legenda WMS e Spaziatura gruppi della leggenda Proprietà dell’oggetto forniscono le seguenti opzioni (vedi figure_layout_legend_wms):

../../../../_images/legend_wms.png

Fig. 17.30 Legenda WMS e Spaziatura gruppi

Quando hai aggiunto un layer WMS e inserisci un oggetto legenda, viene inviata una richiesta al server WMS per fornire una legenda WMS. Questa legenda verrà mostrata solo se il server WMS fornisce la funzionalità GetLegendGraphic. Il contenuto della legenda WMS sarà fornito come immagine raster.

Legenda WMS consente di regolare la Larghezza legenda e la Altezza legenda dell’immagine raster della legenda WMS.

Spacing around title, groups, subgroups, symbols, labels, boxes, columns and lines can be customized through this dialog.