QgsDiagramLayerSettings class

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.

Public types

enum LinePlacementFlag { OnLine = 1, AboveLine = 1 << 1, BelowLine = 1 << 2, MapOrientation = 1 << 4 }
Line placement flags for controlling line based placements.
enum Property { BackgroundColor, StrokeColor, StrokeWidth, PositionX, PositionY, Distance, Priority, ZIndex, IsObstacle, Show, AlwaysShow, StartAngle }
Data definable properties.

Public static functions

static auto propertyDefinitions() -> const QgsPropertiesDefinition&
Returns the diagram property definitions.

Constructors, destructors, conversion operators

QgsDiagramLayerSettings()
Constructor for QgsDiagramLayerSettings.
QgsDiagramLayerSettings(const QgsDiagramLayerSettings& rh)
Copy constructor.

Public functions

auto coordinateTransform() const -> QgsCoordinateTransform
Returns the coordinate transform associated with the layer, or an invalid transform if no transformation is required.
auto dataDefinedProperties() -> QgsPropertyCollection&
Returns a reference to the diagram's property collection, used for data defined overrides.
auto dataDefinedProperties() const -> const QgsPropertyCollection&
Returns a reference to the diagram's property collection, used for data defined overrides.
auto distance() const -> double
Returns the distance between the diagram and the feature (in mm).
auto isObstacle() const -> bool
Returns whether the feature associated with a diagram acts as an obstacle for other labels or diagrams.
auto linePlacementFlags() const -> LinePlacementFlags
Returns the diagram placement flags.
auto placement() const -> Placement
Returns the diagram placement.
auto prepare(const QgsExpressionContext& context = QgsExpressionContext()) const -> bool
Prepares the diagrams for a specified expression context.
auto priority() const -> int
Returns the diagram priority.
void readXml(const QDomElement& elem)
Reads the diagram settings from a DOM element.
auto referencedFields(const QgsExpressionContext& context = QgsExpressionContext()) const -> QSet<QString>
Returns the set of any fields referenced by the layer's diagrams.
auto renderer() -> QgsDiagramRenderer*
Returns the diagram renderer associated with the layer.
auto renderer() const -> const QgsDiagramRenderer*
Returns the diagram renderer associated with the layer.
void setCoordinateTransform(const QgsCoordinateTransform& transform)
Sets the coordinate transform associated with the layer.
void setDataDefinedProperties(const QgsPropertyCollection& collection)
Sets the diagram's property collection, used for data defined overrides.
void setDistance(double distance)
Sets the distance between the diagram and the feature.
void setIsObstacle(bool isObstacle)
Sets whether the feature associated with a diagram acts as an obstacle for other labels or diagrams.
void setLinePlacementFlags(LinePlacementFlags flags)
Sets the the diagram placement flags.
void setPlacement(Placement value)
Sets the diagram placement.
void setPriority(int value)
Sets the diagram priority.
void setRenderer(QgsDiagramRenderer* diagramRenderer)
Sets the diagram renderer associated with the layer.
void setShowAllDiagrams(bool showAllDiagrams)
Sets whether the layer should show all diagrams, including overlapping diagrams.
void setZIndex(double index)
Sets the diagram z-index.
auto showAllDiagrams() const -> bool
Returns whether the layer should show all diagrams, including overlapping diagrams.
void writeXml(QDomElement& layerElem, QDomDocument& doc) const
Writes the diagram settings to a DOM element.
auto zIndex() const -> double
Returns the diagram z-index.

Enum documentation

enum QgsDiagramLayerSettings::Property

Data definable properties.

Enumerators
BackgroundColor

Diagram background color.

StrokeColor

Stroke color.

StrokeWidth

Stroke width.

PositionX
PositionY

x-coordinate data defined diagram position

Distance

y-coordinate data defined diagram position

Priority

Distance to diagram from feature.

ZIndex

Diagram priority (between 0 and 10)

IsObstacle

Z-index for diagram ordering.

Show

Whether diagram features act as obstacles for other diagrams/labels.

AlwaysShow

Whether to show the diagram.

StartAngle

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

Function documentation

static const QgsPropertiesDefinition& QgsDiagramLayerSettings::propertyDefinitions()

Returns the diagram property definitions.

QgsCoordinateTransform QgsDiagramLayerSettings::coordinateTransform() const

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

QgsPropertyCollection& QgsDiagramLayerSettings::dataDefinedProperties()

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

const QgsPropertyCollection& QgsDiagramLayerSettings::dataDefinedProperties() const

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

double QgsDiagramLayerSettings::distance() const

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

bool QgsDiagramLayerSettings::isObstacle() const

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

LinePlacementFlags QgsDiagramLayerSettings::linePlacementFlags() const

Returns the diagram placement flags.

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

Placement QgsDiagramLayerSettings::placement() const

Returns the diagram placement.

bool QgsDiagramLayerSettings::prepare(const QgsExpressionContext& context = QgsExpressionContext()) const

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.

int QgsDiagramLayerSettings::priority() const

Returns the diagram priority.

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

void QgsDiagramLayerSettings::readXml(const QDomElement& elem)

Reads the diagram settings from a DOM element.

QSet<QString> QgsDiagramLayerSettings::referencedFields(const QgsExpressionContext& context = QgsExpressionContext()) const

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

Parameters
context expression context the diagrams will be drawn using

QgsDiagramRenderer* QgsDiagramLayerSettings::renderer()

Returns the diagram renderer associated with the layer.

const QgsDiagramRenderer* QgsDiagramLayerSettings::renderer() const

Returns the diagram renderer associated with the layer.

void QgsDiagramLayerSettings::setCoordinateTransform(const QgsCoordinateTransform& transform)

Sets the coordinate transform associated with the layer.

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

void QgsDiagramLayerSettings::setDataDefinedProperties(const QgsPropertyCollection& collection)

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

Parameters
collection property collection. Existing properties will be replaced.

void QgsDiagramLayerSettings::setDistance(double distance)

Sets the distance between the diagram and the feature.

Parameters
distance distance in mm

void QgsDiagramLayerSettings::setIsObstacle(bool isObstacle)

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

void QgsDiagramLayerSettings::setLinePlacementFlags(LinePlacementFlags flags)

Sets the the diagram placement flags.

Parameters
flags placement value

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

void QgsDiagramLayerSettings::setPlacement(Placement value)

Sets the diagram placement.

Parameters
value placement value

void QgsDiagramLayerSettings::setPriority(int value)

Sets the diagram priority.

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

void QgsDiagramLayerSettings::setRenderer(QgsDiagramRenderer* diagramRenderer)

Sets the diagram renderer associated with the layer.

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

void QgsDiagramLayerSettings::setShowAllDiagrams(bool showAllDiagrams)

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

Parameters
showAllDiagrams set to true to show all diagrams

void QgsDiagramLayerSettings::setZIndex(double index)

Sets the diagram z-index.

Parameters
index diagram z-index

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

bool QgsDiagramLayerSettings::showAllDiagrams() const

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

void QgsDiagramLayerSettings::writeXml(QDomElement& layerElem, QDomDocument& doc) const

Writes the diagram settings to a DOM element.

double QgsDiagramLayerSettings::zIndex() const

Returns the diagram z-index.

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