Class: QgsDiagram¶
Base class for all diagram types.
Note
This is an abstract class, with methods which must be implemented by a subclass.
The following methods must be implemented: clone(), diagramName(), diagramSize(), legendSize(), renderDiagram()
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. |
- class qgis.core.QgsDiagram[source]¶
Bases:
object- abstract clone(self) QgsDiagram | None[source]¶
Returns an instance that is equivalent to this one
- Return type:
Optional[QgsDiagram]
- abstract diagramName(self) str[source]¶
Gets a descriptive name for this diagram type.
- Return type:
str
- abstract diagramSize(self, attributes: Any, c: QgsRenderContext, s: QgsDiagramSettings) QSizeF[source]¶
Returns the size in map units the diagram will use to render.
diagramSize(self, feature:
QgsFeature, c:QgsRenderContext, s:QgsDiagramSettings, interpolationSettings:QgsDiagramInterpolationSettings) -> QSizeF Returns the size in map units the diagram will use to render. Interpolate size- Parameters:
attributes (Any)
c (QgsRenderContext)
- 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]
- abstract 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
- abstract 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 type
c (QgsRenderContext) – The rendering specifying the proper scale units for pixel conversion
- Returns:
The converted size for rendering
sizePainterUnits(self, l: float, s:
QgsDiagramSettings, c:QgsRenderContext) -> float Calculates a length to match the current settings and rendering context- Parameters:
l – The length to convert
s – The settings that specify the size type
c – The rendering specifying the proper scale units for pixel conversion
- Return type:
QSizeF
- Returns:
The converted length for rendering