Subgroup: Diagram

Class: QgsDiagramLayerSettings

class qgis.core.QgsDiagramLayerSettings

Bases: sip.wrapper

Constructor for QgsDiagramLayerSettings.

QgsDiagramLayerSettings(rh: QgsDiagramLayerSettings) Copy constructor

Stores the settings for rendering of all diagrams for a layer.

QgsDiagramSettings stores the settings related to rendering the individual diagrams themselves, while QgsDiagramLayerSettings stores settings which control how ALL diagrams within a layer are rendered.

Methods

coordinateTransform Returns the coordinate transform associated with the layer, or an invalid transform if no transformation is required.
dataDefinedProperties Returns a reference to the diagram’s property collection, used for data defined overrides.
distance Returns the distance between the diagram and the feature (in mm).
isObstacle Returns whether the feature associated with a diagram acts as an obstacle for other labels or diagrams.
linePlacementFlags Returns the diagram placement flags.
placement Returns the diagram placement.
prepare Prepares the diagrams for a specified expression context.
priority Returns the diagram priority.
propertyDefinitions Returns the diagram property definitions.
readXml Reads the diagram settings from a DOM element.
referencedFields Returns the set of any fields referenced by the layer’s diagrams.
renderer Returns the diagram renderer associated with the layer.
setCoordinateTransform Sets the coordinate transform associated with the layer.
setDataDefinedProperties Sets the diagram’s property collection, used for data defined overrides.
setDistance Sets the distance between the diagram and the feature.
setIsObstacle Sets whether the feature associated with a diagram acts as an obstacle for other labels or diagrams.
setLinePlacementFlags Sets the the diagram placement flags.
setPlacement Sets the diagram placement.
setPriority Sets the diagram priority.
setRenderer Sets the diagram renderer associated with the layer.
setShowAllDiagrams Sets whether the layer should show all diagrams, including overlapping diagrams
setZIndex Sets the diagram z-index.
showAllDiagrams Returns whether the layer should show all diagrams, including overlapping diagrams
writeXml Writes the diagram settings to a DOM element.
zIndex Returns the diagram z-index.

Signals

Attributes

AboveLine
AlwaysShow
AroundPoint
BackgroundColor
BelowLine
Curved
Distance
Free
Horizontal
IsObstacle
Line
MapOrientation
OnLine
OverPoint
PositionX
PositionY
Priority
Show
StartAngle
StrokeColor
StrokeWidth
ZIndex
AboveLine = 2
AlwaysShow = 10
AroundPoint = 0
BackgroundColor = 0
BelowLine = 4
Curved = 3
Distance = 5
Free = 5
Horizontal = 4
IsObstacle = 8
Line = 2
class LinePlacementFlag

Bases: int

class LinePlacementFlags

Bases: sip.wrapper

QgsDiagramLayerSettings.LinePlacementFlags(Union[QgsDiagramLayerSettings.LinePlacementFlags, QgsDiagramLayerSettings.LinePlacementFlag]) QgsDiagramLayerSettings.LinePlacementFlags(QgsDiagramLayerSettings.LinePlacementFlags)

MapOrientation = 16
OnLine = 1
OverPoint = 1
class Placement

Bases: int

PositionX = 3
PositionY = 4
Priority = 6
class Property

Bases: int

Show = 9
StartAngle = 11
StrokeColor = 1
StrokeWidth = 2
ZIndex = 7
coordinateTransform(self) → QgsCoordinateTransform

Returns the coordinate transform associated with the layer, or an invalid transform if no transformation is required.

New in version 2.16.

dataDefinedProperties(self) → QgsPropertyCollection

Returns a reference to the diagram’s property collection, used for data defined overrides.

New in version 3.0.

distance(self) → float

Returns the distance between the diagram and the feature (in mm).

See also

setDistance()

New in version 2.16.

isObstacle(self) → bool

Returns whether the feature associated with a diagram acts as an obstacle for other labels or diagrams.

See also

setIsObstacle()

New in version 2.16.

linePlacementFlags(self) → QgsDiagramLayerSettings.LinePlacementFlags

Returns the diagram placement flags. These are only used if the diagram placement is set to a line type.

New in version 2.16.

placement(self) → QgsDiagramLayerSettings.Placement

Returns the diagram placement.

See also

setPlacement()

New in version 2.16.

prepare(self, context: QgsExpressionContext = QgsExpressionContext()) → bool

Prepares the diagrams for a specified expression context. Calling prepare before rendering multiple diagrams allows precalculation of expensive setup tasks such as parsing expressions. Returns true if preparation was successful.

New in version 3.0.

priority(self) → int

Returns the diagram priority.

Returns:diagram priority, where 0 = low and 10 = high

Note

placement priority is shared with labeling, so diagrams with a high priority may displace labels and vice-versa

See also

setPriority()

New in version 2.16.

propertyDefinitions() → object

Returns the diagram property definitions.

New in version 3.0.

readXml(self, elem: QDomElement)

Reads the diagram settings from a DOM element.

See also

writeXml()

referencedFields(self, context: QgsExpressionContext = QgsExpressionContext()) → Set[str]

Returns the set of any fields referenced by the layer’s diagrams.

Parameters:context – expression context the diagrams will be drawn using

New in version 2.16.

renderer(self) → QgsDiagramRenderer

Returns the diagram renderer associated with the layer.

See also

setRenderer()

New in version 2.16.

setCoordinateTransform(self, transform: QgsCoordinateTransform)

Sets the coordinate transform associated with the layer.

Parameters:transform – coordinate transform. Ownership is transferred to the object.

New in version 2.16.

setDataDefinedProperties(self, collection: QgsPropertyCollection)

Sets the diagram’s property collection, used for data defined overrides.

Parameters:collection – property collection. Existing properties will be replaced.

New in version 3.0.

setDistance(self, distance: float)

Sets the distance between the diagram and the feature.

Parameters:distance – distance in mm

See also

distance()

New in version 2.16.

setIsObstacle(self, isObstacle: bool)

Sets whether the feature associated with a diagram acts as an obstacle for other labels or diagrams.

Parameters:isObstacle – set to true for feature to act as obstacle

See also

isObstacle()

New in version 2.16.

setLinePlacementFlags(self, flags: Union[QgsDiagramLayerSettings.LinePlacementFlags, QgsDiagramLayerSettings.LinePlacementFlag])

Sets the the diagram placement flags. These are only used if the diagram placement is set to a line type.

Parameters:flags – placement value

New in version 2.16.

setPlacement(self, value: QgsDiagramLayerSettings.Placement)

Sets the diagram placement.

Parameters:value – placement value

See also

placement()

New in version 2.16.

setPriority(self, value: int)

Sets the diagram priority.

Parameters:value – priority, where 0 = low and 10 = high

See also

priority()

New in version 2.16.

setRenderer(self, diagramRenderer: QgsDiagramRenderer)

Sets the diagram renderer associated with the layer.

Parameters:diagramRenderer – diagram renderer. Ownership is transferred to the object.

See also

renderer()

New in version 2.16.

setShowAllDiagrams(self, showAllDiagrams: bool)

Sets whether the layer should show all diagrams, including overlapping diagrams

Parameters:showAllDiagrams – set to true to show all diagrams

New in version 2.16.

setZIndex(self, index: float)

Sets the diagram z-index. Diagrams (or labels) with a higher z-index are drawn over diagrams with a lower z-index.

Parameters:index – diagram z-index

See also

zIndex()

New in version 2.16.

showAllDiagrams(self) → bool

Returns whether the layer should show all diagrams, including overlapping diagrams

New in version 2.16.

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

Writes the diagram settings to a DOM element.

See also

readXml()

zIndex(self) → float

Returns the diagram z-index. Diagrams (or labels) with a higher z-index are drawn over diagrams with a lower z-index.

Note

z-index ordering is shared with labeling, so diagrams with a high z-index may be drawn over labels with a low z-index and vice-versa

See also

setZIndex()

New in version 2.16.