Class: QgsDiagramRenderer¶
-
class
qgis.core.
QgsDiagramRenderer
¶ Bases:
sip.wrapper
Constructor for QgsDiagramRenderer.
QgsDiagramRenderer(other: QgsDiagramRenderer)
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
Enums
Methods
Returns
True
if renderer will show legend items for diagram attributes.Returns new instance that is equivalent to this one
Converts size from mm to map units
Returns attribute indices needed for diagram rendering
Returns list with all diagram settings in the renderer
Returns size of the diagram (in painter units) or an invalid size in case of error
Returns the paint device dpi (or -1 in case of error
Returns list of legend nodes for the diagram
Reads diagram state from a DOM element.
Returns the set of any fields required for diagram rendering
Renders the diagram for a specified feature at a specific position in the passed render context.
Sets whether the renderer will show legend items for diagram attributes.
Returns size of the diagram for a feature in map units.
Writes diagram state to a DOM element.
Signals
Attributes
-
attributeLegend
(self) → bool¶ Returns
True
if renderer will show legend items for diagram attributes.See also
New in version 2.16.
-
clone
(self) → QgsDiagramRenderer¶ Returns new instance that is equivalent to this one
New in version 2.4.
-
convertSizeToMapUnits
(self, size: QSizeF, context: QgsRenderContext)¶ Converts size from mm to map units
-
diagram
(self) → QgsDiagram¶
-
diagramAttributes
(self) → List[str]¶ Returns attribute indices needed for diagram rendering
-
diagramSettings
(self) → List[QgsDiagramSettings]¶ Returns list with all diagram settings in the renderer
diagramSettings(self, feature: QgsFeature, c: QgsRenderContext, s: QgsDiagramSettings) -> bool Returns diagram settings for a feature (or
False
if the diagram for the feature is not to be rendered). Used internally within renderDiagram()- Parameters
feature – the feature
c – render context
s – out: diagram settings for the feature
-
diagramSize
(self, features: QgsFeature, c: QgsRenderContext) → QSizeF¶ Returns size of the diagram (in painter units) or an invalid size in case of error
-
dpiPaintDevice
(QPainter) → int¶ Returns the paint device dpi (or -1 in case of error
-
legendItems
(self, nodeLayer: QgsLayerTreeLayer) → List[QgsLayerTreeModelLegendNode]¶ Returns list of legend nodes for the diagram
Note
caller is responsible for deletion of
QgsLayerTreeModelLegendNodes
New in version 2.10.
-
readXml
(self, elem: QDomElement, context: QgsReadWriteContext)¶ Reads diagram state from a DOM element. Subclasses should ensure that _readXml() is called by their readXml implementation to restore the general QgsDiagramRenderer settings.
See also
-
referencedFields
(self, context: QgsExpressionContext = QgsExpressionContext()) → Set[str]¶ Returns the set of any fields required for diagram rendering
- Parameters
context – expression context the diagrams will be drawn using
New in version 2.16.
-
renderDiagram
(self, feature: QgsFeature, c: QgsRenderContext, pos: Union[QPointF, QPoint], properties: QgsPropertyCollection = QgsPropertyCollection())¶ Renders the diagram for a specified feature at a specific position in the passed render context.
-
rendererName
(self) → str¶
-
setAttributeLegend
(self, enabled: bool)¶ Sets whether the renderer will show legend items for diagram attributes.
- Parameters
enabled – set to
True
to show diagram attribute legend
See also
New in version 2.16.
-
setDiagram
(self, d: QgsDiagram)¶
-
sizeMapUnits
(self, feature: QgsFeature, c: QgsRenderContext) → QSizeF¶ Returns size of the diagram for a feature in map units. Returns an invalid QSizeF in case of error
-