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

attributeLegend Returns True if renderer will show legend items for diagram attributes.
clone Returns new instance that is equivalent to this one
convertSizeToMapUnits Converts size from mm to map units
diagram
diagramAttributes Returns attribute indices needed for diagram rendering
diagramSettings Returns list with all diagram settings in the renderer
diagramSize Returns size of the diagram (in painter units) or an invalid size in case of error
dpiPaintDevice Returns the paint device dpi (or -1 in case of error
legendItems Returns list of legend nodes for the diagram
readXml Reads diagram state from a DOM element.
referencedFields Returns the set of any fields required for diagram rendering
renderDiagram Renders the diagram for a specified feature at a specific position in the passed render context.
rendererName
setAttributeLegend Sets whether the renderer will show legend items for diagram attributes.
setDiagram
sizeMapUnits Returns size of the diagram for a feature in map units.
writeXml Writes diagram state to a DOM element.

Signals

Attributes

attributeLegend(self) → bool

Returns True if renderer will show legend items for diagram attributes.

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) → object

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

writeXml()

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

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

writeXml(self, layerElem: QDomElement, doc: QDomDocument, context: QgsReadWriteContext)

Writes diagram state to a DOM element. Subclasses should ensure that _writeXml() is called by their writeXml implementation to save the general QgsDiagramRenderer settings.

See also

readXml()