Class: QgsDiagramRenderer¶
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
Note
This is an abstract class, with methods which must be implemented by a subclass.
The following methods must be implemented: clone()
, diagramAttributes()
, diagramSettings()
, diagramSize()
, readXml()
, rendererName()
, writeXml()
Class Hierarchy¶
Subclasses¶
Alters the size of rendered diagrams using linear scaling. |
|
Renders the diagrams for all features with the same settings. |
|
Renders diagrams using mixed diagram render types. |
Abstract Methods
Returns new instance that is equivalent to this one |
|
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 |
|
Reads diagram state from a DOM element. |
|
Writes diagram state to a DOM element. |
Methods
Returns |
|
Converts size from mm to map units |
|
Sets whether the renderer will show legend items for diagram attributes. |
|
Virtual Methods
In PyQGIS, only methods marked as virtual
can be safely overridden in a Python subclass of QgsDiagramRenderer. See the FAQ for more details.
Returns list of legend nodes for the diagram |
|
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. |
|
Returns size of the diagram for a feature in map units. |
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
True
if renderer will show legend items for diagram attributes.See also
- Return type:
bool
- abstract 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]
- abstract diagramAttributes(self) List[str] ¶
Returns attribute indices needed for diagram rendering
- Return type:
List[str]
- abstract diagramSettings(self) List[QgsDiagramSettings] [source]¶
Returns list with all diagram settings in the renderer
- Return type:
List[QgsDiagramSettings]
- abstract diagramSettings(self, feature: QgsFeature, c: QgsRenderContext, s: QgsDiagramSettings) bool [source]
Returns diagram settings for a feature (or
False
if 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
- abstract 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
- virtual 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:
- abstract 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
QgsDiagramRenderer
settings.See also
- Parameters:
elem (QDomElement)
context (QgsReadWriteContext)
- virtual 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]
- virtual 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
True
to show diagram attribute legend
See also
- setDiagram(self, d: QgsDiagram | None)[source]¶
- Parameters:
d (Optional[QgsDiagram])
- virtual 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
- abstract 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
QgsDiagramRenderer
settings.See also
- Parameters:
layerElem (QDomElement)
doc (QDomDocument)
context (QgsReadWriteContext)