Class: QgsDataDefinedSizeLegend¶
Object that keeps configuration of appearance of marker symbol’s data-defined size in legend.
For example: the list of classes (size values), whether the classes should appear in separate legend nodes or whether to collapse them into one legend node.
List of all members, including inherited members
Classes
Definition of one class for the legend |
|
Methods
Returns list of classes: each class is a pair of symbol size (in units used by the symbol) and label |
|
Returns output image that would be shown in the legend. |
|
Draw the legend if using LegendOneNodeForAll and optionally output size of the legend and x offset of labels (in painter units). |
|
Returns font used for rendering of labels - only valid for collapsed legend |
|
Generates legend symbol items according to the configuration |
|
Returns how the legend should be rendered |
|
Returns the line symbol that will be used to draw callout lines in legend. |
|
Sets list of classes: each class is a pair of symbol size (in units used by the symbol) and label |
|
Sets font used for rendering of labels - only valid for collapsed legend |
|
Sets how the legend should be rendered |
|
Sets the line symbol that will be used to draw callout lines in legend. |
|
Sets transformer for scaling of symbol sizes. |
|
Sets marker symbol that will be used to draw markers in legend |
|
Sets horizontal text alignment for rendering of labels - only valid for collapsed legend |
|
Sets text color for rendering of labels - only valid for collapsed legend |
|
Sets title label for data-defined size legend |
|
Sets vertical alignment of symbols - only valid for collapsed legend |
|
Returns transformer for scaling of symbol sizes. |
|
Returns marker symbol that will be used to draw markers in legend |
|
Returns horizontal text alignment for rendering of labels - only valid for collapsed legend |
|
Returns text color for rendering of labels - only valid for collapsed legend |
|
Returns title label for data-defined size legend |
|
Updates the list of classes, source symbol and title label from given symbol and property |
|
Returns vertical alignment of symbols - only valid for collapsed legend |
|
Writes configuration to the given XML element. |
Static Methods
Creates instance from given element and returns it (caller takes ownership). |
Attributes
- class qgis.core.QgsDataDefinedSizeLegend[source]¶
Bases:
object- __init__()
Constructor for QgsDataDefinedSizeLegend.
- __init__(other: QgsDataDefinedSizeLegend)
- Parameters:
other (QgsDataDefinedSizeLegend)
- AlignBottom = 1¶
- AlignCenter = 0¶
- LegendCollapsed = 1¶
- LegendSeparated = 0¶
- class LegendType¶
Bases:
int
- class VerticalAlignment¶
Bases:
int
- classes(self) list[QgsDataDefinedSizeLegend.SizeClass]¶
Returns list of classes: each class is a pair of symbol size (in units used by the symbol) and label
- Return type:
- collapsedLegendImage(self, context: QgsRenderContext, backgroundColor: QColor | Qt.GlobalColor = Qt.transparent, paddingMM: float = 1) QImage[source]¶
Returns output image that would be shown in the legend. Returns invalid image if legend is not configured as collapsed.
- Parameters:
context (QgsRenderContext)
backgroundColor (Union[QColor, Qt.GlobalColor] = Qt.transparent)
paddingMM (float = 1)
- Return type:
QImage
- drawCollapsedLegend(self, context: QgsRenderContext)[source]¶
Draw the legend if using LegendOneNodeForAll and optionally output size of the legend and x offset of labels (in painter units). If the painter in context is
None, it only does size calculation without actual rendering. Does nothing if legend is not configured as collapsed.- Parameters:
context (QgsRenderContext)
- Return type:
(Optional[QSizeF], Optional[float])
- font(self) QFont[source]¶
Returns font used for rendering of labels - only valid for collapsed legend
- Return type:
QFont
- legendSymbolList(self) list[QgsLegendSymbolItem][source]¶
Generates legend symbol items according to the configuration
- Return type:
list[QgsLegendSymbolItem]
- legendType(self) QgsDataDefinedSizeLegend.LegendType[source]¶
Returns how the legend should be rendered
- Return type:
- lineSymbol(self) QgsLineSymbol | None[source]¶
Returns the line symbol that will be used to draw callout lines in legend.
See also
Added in version 3.14.
- Return type:
Optional[QgsLineSymbol]
- static readXml(elem: QDomElement, context: QgsReadWriteContext) QgsDataDefinedSizeLegend | None[source]¶
Creates instance from given element and returns it (caller takes ownership). Returns
Noneon error.- Parameters:
elem (QDomElement)
context (QgsReadWriteContext)
- Return type:
Optional[QgsDataDefinedSizeLegend]
- setClasses(self, classes: Iterable[QgsDataDefinedSizeLegend.SizeClass])[source]¶
Sets list of classes: each class is a pair of symbol size (in units used by the symbol) and label
- Parameters:
classes (Iterable[QgsDataDefinedSizeLegend.SizeClass])
- setFont(self, font: QFont)[source]¶
Sets font used for rendering of labels - only valid for collapsed legend
- Parameters:
font (QFont)
- setLegendType(self, type: QgsDataDefinedSizeLegend.LegendType)[source]¶
Sets how the legend should be rendered
- Parameters:
- setLineSymbol(self, symbol: QgsLineSymbol | None)[source]¶
Sets the line
symbolthat will be used to draw callout lines in legend.Ownership of
symbolis transferred.See also
Added in version 3.14.
- Parameters:
symbol (Optional[QgsLineSymbol])
- setSizeScaleTransformer(self, transformer: QgsSizeScaleTransformer | None)[source]¶
Sets transformer for scaling of symbol sizes. Takes ownership of the object. Accepts
Noneto set no transformer.- Parameters:
transformer (Optional[QgsSizeScaleTransformer])
- setSymbol(self, symbol: QgsMarkerSymbol | None)[source]¶
Sets marker symbol that will be used to draw markers in legend
- Parameters:
symbol (Optional[QgsMarkerSymbol])
- setTextAlignment(self, flag: Qt.AlignmentFlag)[source]¶
Sets horizontal text alignment for rendering of labels - only valid for collapsed legend
- Parameters:
flag (Qt.AlignmentFlag)
- setTextColor(self, color: QColor | Qt.GlobalColor)[source]¶
Sets text color for rendering of labels - only valid for collapsed legend
- Parameters:
color (Union[QColor, Qt.GlobalColor])
- setTitle(self, title: str | None)[source]¶
Sets title label for data-defined size legend
- Parameters:
title (Optional[str])
- setVerticalAlignment(self, vAlign: QgsDataDefinedSizeLegend.VerticalAlignment)[source]¶
Sets vertical alignment of symbols - only valid for collapsed legend
- Parameters:
- sizeScaleTransformer(self) QgsSizeScaleTransformer | None[source]¶
Returns transformer for scaling of symbol sizes. Returns
Noneif no transformer is defined.- Return type:
Optional[QgsSizeScaleTransformer]
- symbol(self) QgsMarkerSymbol | None[source]¶
Returns marker symbol that will be used to draw markers in legend
- Return type:
Optional[QgsMarkerSymbol]
- textAlignment(self) Qt.AlignmentFlag[source]¶
Returns horizontal text alignment for rendering of labels - only valid for collapsed legend
- Return type:
Qt.AlignmentFlag
- textColor(self) QColor[source]¶
Returns text color for rendering of labels - only valid for collapsed legend
- Return type:
QColor
- updateFromSymbolAndProperty(self, symbol: QgsMarkerSymbol | None, ddSize: QgsProperty)[source]¶
Updates the list of classes, source symbol and title label from given symbol and property
- Parameters:
symbol (Optional[QgsMarkerSymbol])
ddSize (QgsProperty)
- verticalAlignment(self) QgsDataDefinedSizeLegend.VerticalAlignment[source]¶
Returns vertical alignment of symbols - only valid for collapsed legend
- Return type:
- writeXml(self, elem: QDomElement, context: QgsReadWriteContext)[source]¶
Writes configuration to the given XML element.
- Parameters:
elem (QDomElement)
context (QgsReadWriteContext)