Class: QgsDiagramRenderer¶
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
Class Hierarchy¶
Subclasses¶
Alters the size of rendered diagrams using a linear scaling.  | 
|
Renders the diagrams for all features with the same settings  | 
|
Renders diagrams using mixed diagram render types. The size of the rendered diagram is given by a combination of subrenderers.  | 
Methods
Returns   | 
|
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 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.  | 
Static Methods
Returns the paint device dpi (or -1 in case of error  | 
- class qgis.core.QgsDiagramRenderer[source]¶
 Bases:
object- attributeLegend(self) bool[source]¶
 Returns
Trueif renderer will show legend items for diagram attributes.See also
- Return type:
 bool
- clone(self) QgsDiagramRenderer | None[source]¶
 Returns new instance that is equivalent to this one
- Return type:
 Optional[QgsDiagramRenderer]
- convertSizeToMapUnits(self, size: QSizeF, context: QgsRenderContext)[source]¶
 Converts size from mm to map units
- Parameters:
 size (QSizeF)
context (QgsRenderContext)
- diagram(self) QgsDiagram | None[source]¶
 - Return type:
 Optional[QgsDiagram]
- diagramAttributes(self) List[str]¶
 Returns attribute indices needed for diagram rendering
- Return type:
 List[str]
- diagramSettings(self) List[QgsDiagramSettings][source]¶
 Returns list with all diagram settings in the renderer
- Return type:
 List[QgsDiagramSettings]
- diagramSettings(self, feature: QgsFeature, c: QgsRenderContext, s: QgsDiagramSettings) bool[source]
 Returns diagram settings for a feature (or
Falseif the diagram for the feature is not to be rendered). Used internally withinrenderDiagram()- Parameters:
 feature (
QgsFeature) – the featurec (
QgsRenderContext) – render contexts (
QgsDiagramSettings) – out: diagram settings for the feature
- Return type:
 bool
- diagramSize(self, feature: QgsFeature, c: QgsRenderContext) QSizeF[source]¶
 Returns size of the diagram (in painter units) or an invalid size in case of error
- Parameters:
 feature (QgsFeature) – the feature
c (QgsRenderContext) – render context
- Return type:
 QSizeF
- static dpiPaintDevice(a0: QPainter | None) int[source]¶
 Returns the paint device dpi (or -1 in case of error
- Parameters:
 a0 (Optional[QPainter])
- Return type:
 int
- legendItems(self, nodeLayer: QgsLayerTreeLayer | None) List[QgsLayerTreeModelLegendNode]¶
 Returns list of legend nodes for the diagram
Note
caller is responsible for deletion of
QgsLayerTreeModelLegendNodes- Parameters:
 nodeLayer (Optional[QgsLayerTreeLayer])
- Return type:
 
- readXml(self, elem: QDomElement, context: QgsReadWriteContext)[source]¶
 Reads diagram state from a DOM element. Subclasses should ensure that
- Parameters:
 elem (QDomElement)
context (
QgsReadWriteContext)
- QgsDiagramRenderer.readXml() is called by their readXml implementation to restore the
 readXml() is called by their readXml implementation to restore the general
QgsDiagramRenderersettings.See also
- Parameters:
 elem (QDomElement)
context (QgsReadWriteContext)
- referencedFields(self, context: QgsExpressionContext = QgsExpressionContext()) Set[str]¶
 Returns the set of any fields required for diagram rendering
- Parameters:
 context (
QgsExpressionContext= QgsExpressionContext()) – expression context the diagrams will be drawn using- Return type:
 Set[str]
- renderDiagram(self, feature: QgsFeature, c: QgsRenderContext, pos: QPointF | QPoint, properties: QgsPropertyCollection = QgsPropertyCollection())[source]¶
 Renders the diagram for a specified feature at a specific position in the passed render context.
- Parameters:
 feature (QgsFeature)
c (QgsRenderContext)
pos (Union[QPointF, QPoint])
properties (
QgsPropertyCollection= QgsPropertyCollection())
- setAttributeLegend(self, enabled: bool)[source]¶
 Sets whether the renderer will show legend items for diagram attributes.
- Parameters:
 enabled (bool) – set to
Trueto show diagram attribute legend
See also
- setDiagram(self, d: QgsDiagram | None)[source]¶
 - Parameters:
 d (Optional[QgsDiagram])
- sizeMapUnits(self, feature: QgsFeature, c: QgsRenderContext) QSizeF[source]¶
 Returns size of the diagram for a feature in map units. Returns an invalid QSizeF in case of error
- Parameters:
 feature (QgsFeature)
c (QgsRenderContext)
- Return type:
 QSizeF
- writeXml(self, layerElem: QDomElement, doc: QDomDocument, context: QgsReadWriteContext)[source]¶
 Writes diagram state to a DOM element. Subclasses should ensure that
- Parameters:
 layerElem (QDomElement)
doc (QDomDocument)
context (
QgsReadWriteContext)
- QgsDiagramRenderer.writeXml() is called by their writeXml implementation to save the
 writeXml() is called by their writeXml implementation to save the general
QgsDiagramRenderersettings.See also
- Parameters:
 layerElem (QDomElement)
doc (QDomDocument)
context (QgsReadWriteContext)