Class: QgsLayoutItemChart¶
A layout item subclass that renders chart plots.
Added in version 4.0.
Class Hierarchy¶
Base classes¶
Base class for graphical items within a |
|
A base class for objects which belong to a layout. |
|
Abstract interface for generating an expression context. |
|
Interface for layout objects which support undo/redo commands. |
Methods
Returns the plot used to render the chart. |
|
Returns the plot series details used to generate the plot data. |
|
Sets the plot used to render the chart. |
|
Sets the plot series details used to generate the plot data. |
|
Sets whether features should be sorted in an ascending order when iterating through the vector layer from which the plot data wil be gathered from. |
|
Sets the expression used to sort features when iterating through the vector layer from which the plot data wil be gathered from. |
|
Sets whether features should be sorted when iterating through the vector layer from which the plot data wil be gathered from. |
|
Sets the source vector layer from which the plot data wil be gathered from. |
|
Returns |
|
Returns the expression used to sort features when iterating through the vector layer from which the plot data wil be gathered from. |
|
Returns |
|
Returns the source vector layer from which the plot data will be gathered from. |
Static Methods
Returns a new chart item for the specified layout. |
- class qgis.core.QgsLayoutItemChart[source]¶
Bases:
QgsLayoutItem
- __init__(layout: QgsLayout | None)
Constructor for QgsLayoutItemChart, with the specified parent
layout
.- Parameters:
layout (Optional[QgsLayout])
- class SeriesDetails[source]¶
Bases:
object
Chart series details covering all supported series types.
Note
this class is experimental and therefore is not considered as stable API, it may change in the future as more chart plot types are implemented.
Added in version 4.0.
QgsLayoutItemChart.SeriesDetails(name: Optional[str] = ‘’) Constructor for SeriesDetails with an optional
name
parameter to provide a name string to the series.QgsLayoutItemChart.SeriesDetails(a0: QgsLayoutItemChart.SeriesDetails)
- filterExpression(self) str [source]¶
Returns the filter expression used to generate a series against a subset of the source layer.
- Return type:
str
- setFilterExpression(self, filterExpression: str | None)[source]¶
Sets the filter expression used to generate a series against a subset of the source layer.
- Parameters:
filterExpression (Optional[str])
- setXExpression(self, xExpression: str | None)[source]¶
Sets the expression used to generate X-axis values. If the associated chart X axis type is set to
Qgis
.PlotAxisType.Categorical, the generated values will be converted to strings. ForQgis
.PlotAxisType.Interval, the generated values will be converted to double.- Parameters:
xExpression (Optional[str])
- setYExpression(self, yExpression: str | None)[source]¶
Sets the expression used to generate Y-axis values. The generated values will be converted to double.
- Parameters:
yExpression (Optional[str])
- xExpression(self) str [source]¶
Returns the expression used to generate X-axis values. If the associated chart X axis type is set to
Qgis
.PlotAxisType.Categorical, the generated values will be converted to strings. ForQgis
.PlotAxisType.Interval, the generated values will be converted to double.- Return type:
str
- static create(layout: QgsLayout | None) QgsLayoutItemChart | None [source]¶
Returns a new chart item for the specified
layout
.The caller takes responsibility for deleting the returned object.
- Parameters:
layout (Optional[QgsLayout])
- Return type:
Optional[QgsLayoutItemChart]
- plot(self) QgsPlot | None [source]¶
Returns the plot used to render the chart.
- Return type:
Optional[QgsPlot]
- seriesList(self) List[QgsLayoutItemChart.SeriesDetails] ¶
Returns the plot series details used to generate the plot data.
See also
- Return type:
- setPlot(self, plot: QgsPlot | None)[source]¶
Sets the
plot
used to render the chart.Ownership is transferred to the item.
- Parameters:
plot (Optional[QgsPlot])
- setSeriesList(self, seriesList: Iterable[QgsLayoutItemChart.SeriesDetails])[source]¶
Sets the plot series details used to generate the plot data.
See also
- Parameters:
seriesList (Iterable[QgsLayoutItemChart.SeriesDetails])
- setSortAscending(self, ascending: bool)[source]¶
Sets whether features should be sorted in an
ascending
order when iterating through the vector layer from which the plot data wil be gathered from.This property has no effect is
sortFeatures()
isFalse
.See also
See also
See also
- Parameters:
ascending (bool)
- setSortExpression(self, expression: str | None)[source]¶
Sets the
expression
used to sort features when iterating through the vector layer from which the plot data wil be gathered from.See also
See also
See also
- Parameters:
expression (Optional[str])
- setSortFeatures(self, sorted: bool)[source]¶
Sets whether features should be
sorted
when iterating through the vector layer from which the plot data wil be gathered from.See also
See also
See also
- Parameters:
sorted (bool)
- setSourceLayer(self, layer: QgsVectorLayer | None)[source]¶
Sets the source vector
layer
from which the plot data wil be gathered from.See also
- Parameters:
layer (Optional[QgsVectorLayer])
- sortAscending(self) bool [source]¶
Returns
True
if features should be sorted in an ascending order when iterating through the vector layer from which the plot data wil be gathered from.This property has no effect is
sortFeatures()
isFalse
.See also
See also
See also
- Return type:
bool
- sortExpression(self) str [source]¶
Returns the expression used to sort features when iterating through the vector layer from which the plot data wil be gathered from.
See also
See also
See also
- Return type:
str
- sortFeatures(self) bool [source]¶
Returns
True
if features should be sorted when iterating through the vector layer from which the plot data wil be gathered from.See also
See also
See also
- Return type:
bool
- sourceLayer(self) QgsVectorLayer | None [source]¶
Returns the source vector layer from which the plot data will be gathered from.
See also
- Return type:
Optional[QgsVectorLayer]