Class: QgsDiagramLayerSettings

class qgis.core.QgsDiagramLayerSettings

Bases: sip.wrapper

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.

QgsDiagramLayerSettings() Constructor for QgsDiagramLayerSettings.

QgsDiagramLayerSettings(rh: QgsDiagramLayerSettings) Copy constructor

Enums

Property

Bases: enum.IntEnum

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.

Attributes

AboveLine

AroundPoint

BelowLine

Curved

Free

Horizontal

Line

MapOrientation

OnLine

OverPoint

AboveLine = 2
AroundPoint = 0
BelowLine = 4
Curved = 3
Free = 5
Horizontal = 4
Line = 2
class LinePlacementFlag

Bases: int

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

Bases: sip.wrapper

MapOrientation = 16
OnLine = 1
OverPoint = 1
class Placement

Bases: int

class Property(value)

Bases: enum.IntEnum

Data definable properties.

  • BackgroundColor: Diagram background color

  • StrokeColor: Stroke color

  • StrokeWidth: Stroke width

  • PositionX: X-coordinate data defined diagram position

  • PositionY: Y-coordinate data defined diagram position

  • Distance: Distance to diagram from feature

  • Priority: Diagram priority (between 0 and 10)

  • ZIndex: Z-index for diagram ordering

  • IsObstacle: Whether diagram features act as obstacles for other diagrams/labels

  • Show: Whether to show the diagram

  • AlwaysShow: Whether the diagram should always be shown, even if it overlaps other diagrams/labels

  • StartAngle: Angle offset for pie diagram

coordinateTransform(self) QgsCoordinateTransform

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

Return type:

QgsCoordinateTransform

dataDefinedProperties(self) QgsPropertyCollection

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

Return type:

QgsPropertyCollection

distance(self) float

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

See also

setDistance()

Return type:

float

isObstacle(self) bool

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

See also

setIsObstacle()

Return type:

bool

linePlacementFlags(self) QgsDiagramLayerSettings.LinePlacementFlags

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

Return type:

QgsDiagramLayerSettings.LinePlacementFlags

placement(self) QgsDiagramLayerSettings.Placement

Returns the diagram placement.

See also

setPlacement()

Return type:

QgsDiagramLayerSettings.Placement

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.

Parameters:

context (QgsExpressionContext = QgsExpressionContext())

Return type:

bool

priority(self) int

Returns the diagram priority.

Return type:

int

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()

propertyDefinitions() Dict[int, QgsPropertyDefinition]

Returns the diagram property definitions.

Return type:

Dict[int, QgsPropertyDefinition]

readXml(self, elem: QDomElement)

Reads the diagram settings from a DOM element.

See also

writeXml()

Parameters:

elem (QDomElement)

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

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

Parameters:

context (QgsExpressionContext = QgsExpressionContext()) – expression context the diagrams will be drawn using

Return type:

Set[str]

renderer(self) QgsDiagramRenderer

Returns the diagram renderer associated with the layer.

See also

setRenderer()

Return type:

QgsDiagramRenderer

setCoordinateTransform(self, transform: QgsCoordinateTransform)

Sets the coordinate transform associated with the layer.

Parameters:

transform (QgsCoordinateTransform) – coordinate transform. Ownership is transferred to the object.

setDataDefinedProperties(self, collection: QgsPropertyCollection)

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

Parameters:

collection (QgsPropertyCollection) – property collection. Existing properties will be replaced.

See also

Property

setDistance(self, distance: float)

Sets the distance between the diagram and the feature.

Parameters:

distance (float) – distance in mm

See also

distance()

setIsObstacle(self, isObstacle: bool)

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

Parameters:

isObstacle (bool) – set to True for feature to act as obstacle

See also

isObstacle()

setLinePlacementFlags(self, flags: 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 (Union[QgsDiagramLayerSettings.LinePlacementFlags) – placement value

setPlacement(self, value: QgsDiagramLayerSettings.Placement)

Sets the diagram placement.

Parameters:

value (QgsDiagramLayerSettings.Placement) – placement value

See also

placement()

setPriority(self, value: int)

Sets the diagram priority.

Parameters:

value (int) – priority, where 0 = low and 10 = high

See also

priority()

setRenderer(self, diagramRenderer: QgsDiagramRenderer)

Sets the diagram renderer associated with the layer.

Parameters:

diagramRenderer (QgsDiagramRenderer) – diagram renderer. Ownership is transferred to the object.

See also

renderer()

setShowAllDiagrams(self, showAllDiagrams: bool)

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

Parameters:

showAllDiagrams (bool) – set to True to show all diagrams

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 (float) – diagram z-index

See also

zIndex()

showAllDiagrams(self) bool

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

Return type:

bool

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

Writes the diagram settings to a DOM element.

See also

readXml()

Parameters:
  • layerElem (QDomElement)

  • doc (QDomDocument)

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()

Return type:

float