Class: QgsDiagram¶
Base class for all diagram types.
Class Hierarchy¶
Subclasses¶
A histogram style diagram.  | 
|
A pie chart diagram.  | 
|
A stacked bar chart diagram.  | 
|
A diagram composed of several subdiagrams, located side by side.  | 
|
A text based diagram.  | 
Methods
Returns an instance that is equivalent to this one  | 
|
Gets a descriptive name for this diagram type.  | 
|
Returns the size in map units the diagram will use to render.  | 
|
Returns a prepared expression for the specified context.  | 
|
Returns the size of the legend item for the diagram corresponding to a specified value.  | 
|
Draws the diagram at the given position (in pixel coordinates)  | 
|
Calculates a size to match the current settings and rendering context  | 
|
Changes the pen width to match the current settings and rendering context  | 
|
Returns the scaled size of a diagram for a value, respecting the specified diagram interpolation settings.  | 
|
Calculates a size to match the current settings and rendering context  | 
- class qgis.core.QgsDiagram[source]¶
 Bases:
object- clone(self) QgsDiagram | None[source]¶
 Returns an instance that is equivalent to this one
- Return type:
 Optional[QgsDiagram]
- diagramSize(self, attributes: Any, c: QgsRenderContext, s: QgsDiagramSettings) QSizeF[source]¶
 Returns the size in map units the diagram will use to render.
- Parameters:
 attributes (Any)
c (
QgsRenderContext)
- Return type:
 QSizeF
- diagramSize(self, feature: QgsFeature, c: QgsRenderContext, s: QgsDiagramSettings, interpolationSettings: QgsDiagramInterpolationSettings) QSizeF[source]
 Returns the size in map units the diagram will use to render. Interpolate size
- Parameters:
 feature (
QgsFeature)c (
QgsRenderContext)interpolationSettings (
QgsDiagramInterpolationSettings)
- Return type:
 QSizeF
- getExpression(self, expression: str | None, context: QgsExpressionContext) QgsExpression | None[source]¶
 Returns a prepared expression for the specified context.
- Parameters:
 expression (Optional[str]) – expression string
context (QgsExpressionContext) – expression context
- Return type:
 Optional[QgsExpression]
- legendSize(self, value: float, s: QgsDiagramSettings, interpolationSettings: QgsDiagramInterpolationSettings) float[source]¶
 Returns the size of the legend item for the diagram corresponding to a specified value.
- Parameters:
 value (float) – value to return legend item size for
s (QgsDiagramSettings) – diagram settings
interpolationSettings (QgsDiagramInterpolationSettings) – interpolation settings
- Return type:
 float
- renderDiagram(self, feature: QgsFeature, c: QgsRenderContext, s: QgsDiagramSettings, position: QPointF | QPoint)[source]¶
 Draws the diagram at the given position (in pixel coordinates)
- Parameters:
 feature (QgsFeature)
c (QgsRenderContext)
position (Union[QPointF, QPoint])
- scaledFont(self, s: QgsDiagramSettings, c: QgsRenderContext) QFont[source]¶
 Calculates a size to match the current settings and rendering context
- Parameters:
 s (QgsDiagramSettings) – The settings that contain the font size and size type
c (QgsRenderContext) – The rendering specifying the proper scale units for pixel conversion
- Return type:
 QFont
- Returns:
 The properly scaled font for rendering
- setPenWidth(self, pen: QPen | QColor | Qt.GlobalColor, s: QgsDiagramSettings, c: QgsRenderContext)[source]¶
 Changes the pen width to match the current settings and rendering context
- Parameters:
 pen (Union[QPen, Union[QColor, Qt.GlobalColor]]) – The pen to modify
s (QgsDiagramSettings) – The settings that specify the pen width
c (QgsRenderContext) – The rendering specifying the proper scale units for pixel conversion
- sizeForValue(self, value: float, s: QgsDiagramSettings, interpolationSettings: QgsDiagramInterpolationSettings) QSizeF[source]¶
 Returns the scaled size of a diagram for a value, respecting the specified diagram interpolation settings.
- Parameters:
 value (float) – value to calculate corresponding circular size for
s (QgsDiagramSettings) – diagram settings
interpolationSettings (QgsDiagramInterpolationSettings) – interpolation settings
- Return type:
 QSizeF
- sizePainterUnits(self, size: QSizeF, s: QgsDiagramSettings, c: QgsRenderContext) QSizeF[source]¶
 Calculates a size to match the current settings and rendering context
- Parameters:
 size (QSizeF) – The size to convert
s (
QgsDiagramSettings) – The settings that specify the size typec (
QgsRenderContext) – The rendering specifying the proper scale units for pixel conversion
- Return type:
 QSizeF
- Returns:
 The converted size for rendering
- sizePainterUnits(self, l: float, s: QgsDiagramSettings, c: QgsRenderContext) float[source]
 Calculates a length to match the current settings and rendering context
- Parameters:
 l (float) – The length to convert
s (
QgsDiagramSettings) – The settings that specify the size typec (
QgsRenderContext) – The rendering specifying the proper scale units for pixel conversion
- Return type:
 float
- Returns:
 The converted length for rendering