QChart#
The QChart
class manages the graphical representation of the chart’s series, legends, and axes. More…
Inherited by: QPolarChart
Synopsis#
Properties#
animationDuration
- Duration of the animation for the chartanimationEasingCurve
- Easing curve of the animation for the chartanimationOptions
- Animation options for the chartbackgroundRoundness
- Diameter of the rounding circle at the corners of the chart backgroundbackgroundVisible
- Whether the chart background is visiblechartType
- Whether the chart is a cartesian chart or a polar chartdropShadowEnabled
- Whether the background drop shadow effect is enabledlocale
- Used to format various chart labelslocalizeNumbers
- Whether numbers are localizedmargins
- Minimum margins allowed between the edge of the chart rectangle and the plot areaplotArea
- Rectangle within which the chart is drawnplotAreaBackgroundVisible
- Whether the chart plot area background is visibletheme
- Used for the charttitle
- Of the chart
Functions#
def
addAxis
(axis, alignment)def
addSeries
(series)def
animationDuration
()def
animationEasingCurve
()def
animationOptions
()def
axes
([orientation=Qt.Horizontal|Qt.Vertical[, series=None]])def
axisX
([series=None])def
axisY
([series=None])def
backgroundBrush
()def
backgroundPen
()def
backgroundRoundness
()def
chartType
()def
createDefaultAxes
()def
isBackgroundVisible
()def
isDropShadowEnabled
()def
isPlotAreaBackgroundVisible
()def
isZoomed
()def
legend
()def
locale
()def
localizeNumbers
()def
mapToPosition
(value[, series=None])def
mapToValue
(position[, series=None])def
margins
()def
plotArea
()def
plotAreaBackgroundBrush
()def
plotAreaBackgroundPen
()def
removeAllSeries
()def
removeAxis
(axis)def
removeSeries
(series)def
scroll
(dx, dy)def
series
()def
setAnimationDuration
(msecs)def
setAnimationEasingCurve
(curve)def
setAnimationOptions
(options)def
setAxisX
(axis[, series=None])def
setAxisY
(axis[, series=None])def
setBackgroundBrush
(brush)def
setBackgroundPen
(pen)def
setBackgroundRoundness
(diameter)def
setBackgroundVisible
([visible=true])def
setDropShadowEnabled
([enabled=true])def
setLocale
(locale)def
setLocalizeNumbers
(localize)def
setMargins
(margins)def
setPlotArea
(rect)def
setPlotAreaBackgroundBrush
(brush)def
setPlotAreaBackgroundPen
(pen)def
setPlotAreaBackgroundVisible
([visible=true])def
setTheme
(theme)def
setTitle
(title)def
setTitleBrush
(brush)def
setTitleFont
(font)def
theme
()def
title
()def
titleBrush
()def
titleFont
()def
zoom
(factor)def
zoomIn
()def
zoomIn
(rect)def
zoomOut
()def
zoomReset
()
Signals#
def
plotAreaChanged
(plotArea)
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description#
QChart
is a QGraphicsWidget
that you can show in a QGraphicsScene
. It manages the graphical representation of different types of series and other chart related objects like legend and axes. To simply show a chart in a layout, the convenience class QChartView
can be used instead of QChart
. In addition, line, spline, area, and scatter series can be presented as polar charts by using the QPolarChart
class.
See also
- class PySide6.QtCharts.QChart(type, parent, wFlags)#
PySide6.QtCharts.QChart([parent=None[, wFlags=Qt.WindowFlags()]])
- Parameters:
wFlags –
WindowFlags
type –
ChartType
parent –
PySide6.QtWidgets.QGraphicsItem
Constructs a chart object that is a child of parent
. The properties specified by wFlags
are passed to the QGraphicsWidget
constructor.
Note
Properties can be used directly when from __feature__ import true_property
is used or via accessor functions otherwise.
- property PᅟySide6.QtCharts.QChart.animationDuration: int#
This property holds The duration of the animation for the chart..
- Access functions:
setAnimationDuration
(msecs)
- property PᅟySide6.QtCharts.QChart.animationEasingCurve: PySide6.QtCore.QEasingCurve#
This property holds The easing curve of the animation for the chart..
- Access functions:
setAnimationEasingCurve
(curve)
- property PᅟySide6.QtCharts.QChart.animationOptions: AnimationOptions#
This property holds The animation options for the chart..
Animations are enabled or disabled based on this setting.
- Access functions:
setAnimationOptions
(options)
- property PᅟySide6.QtCharts.QChart.backgroundRoundness: float#
This property holds The diameter of the rounding circle at the corners of the chart background..
- Access functions:
setBackgroundRoundness
(diameter)
- property PᅟySide6.QtCharts.QChart.backgroundVisible: bool#
This property holds Whether the chart background is visible..
See also
setBackgroundBrush()
setBackgroundPen()
plotAreaBackgroundVisible
- Access functions:
setBackgroundVisible
([visible=true])
- property PᅟySide6.QtCharts.QChart.chartType: ChartType#
This property holds Whether the chart is a cartesian chart or a polar chart..
This property is set internally and it is read only.
See also
- Access functions:
chartType
()
- property PᅟySide6.QtCharts.QChart.dropShadowEnabled: bool#
This property holds Whether the background drop shadow effect is enabled..
If set to true
, the background drop shadow effect is enabled. If set to false
, it is disabled.
Note
The drop shadow effect depends on the theme, and therefore the setting may change if the theme is changed.
- Access functions:
setDropShadowEnabled
([enabled=true])
- property PᅟySide6.QtCharts.QChart.locale: PySide6.QtCore.QLocale#
This property holds The locale used to format various chart labels..
Labels are localized only when localizeNumbers
is true
, except for QDateTimeAxis
labels, which always use the QLocale
set with this property.
Defaults to the application default locale at the time when the chart is constructed.
See also
- property PᅟySide6.QtCharts.QChart.localizeNumbers: bool#
This property holds Whether numbers are localized..
When true
, all generated numbers appearing in various series and axis labels will be localized using the QLocale
set with the locale
property. When false
, the C locale is always used. Defaults to false
.
Note
This property does not affect QDateTimeAxis
labels, which always use the QLocale
set with the locale property.
See also
- Access functions:
setLocalizeNumbers
(localize)
- property PᅟySide6.QtCharts.QChart.margins: PySide6.QtCore.QMargins#
This property holds The minimum margins allowed between the edge of the chart rectangle and the plot area..
The margins are used for drawing the title, axes, and legend.
- Access functions:
margins
()setMargins
(margins)
- property PᅟySide6.QtCharts.QChart.plotArea: PySide6.QtCore.QRectF#
This property holds The rectangle within which the chart is drawn..
The plot area does not include the area defined by margins. By default this will resize if inside a QChartView
. If an explicit size is set for the plot area then it will respect this, to revert back to the default behavior, then calling setPlotArea(QRectF());
will achieve this.
- Access functions:
plotArea
()setPlotArea
(rect)Signal
plotAreaChanged
(plotArea)
- property PᅟySide6.QtCharts.QChart.plotAreaBackgroundVisible: bool#
This property holds Whether the chart plot area background is visible..
Note
By default, the plot area background is invisible and the plot area uses the general chart background.
See also
setPlotAreaBackgroundBrush()
setPlotAreaBackgroundPen()
backgroundVisible
- Access functions:
setPlotAreaBackgroundVisible
([visible=true])
- property PᅟySide6.QtCharts.QChart.theme: ChartTheme#
This property holds The theme used for the chart..
- property PᅟySide6.QtCharts.QChart.title: str#
This property holds The title of the chart..
The title is shown as a headline on top of the chart. Chart titles support HTML formatting.
- PySide6.QtCharts.QChart.ChartType#
This enum describes the chart type.
Constant
Description
QChart.ChartTypeUndefined
The chart type is not defined.
QChart.ChartTypeCartesian
A cartesian chart.
QChart.ChartTypePolar
A polar chart.
- PySide6.QtCharts.QChart.ChartTheme#
This enum describes the theme used by the chart.
A theme is a built-in collection of UI style related settings applied to all the visual elements of a chart, such as colors, pens, brushes, and fonts of series, as well as axes, title, and legend. The Chart themes example illustrates how to use themes.
Note
Changing the theme will overwrite all customizations previously applied to the series.
Constant |
Description |
---|---|
QChart.ChartThemeLight |
The light theme, which is the default theme. |
QChart.ChartThemeBlueCerulean |
The cerulean blue theme. |
QChart.ChartThemeDark |
The dark theme. |
QChart.ChartThemeBrownSand |
The sand brown theme. |
QChart.ChartThemeBlueNcs |
The natural color system (NCS) blue theme. |
QChart.ChartThemeHighContrast |
The high contrast theme. |
QChart.ChartThemeBlueIcy |
The icy blue theme. |
QChart.ChartThemeQt |
The Qt theme. |
- PySide6.QtCharts.QChart.AnimationOption#
(inherits enum.Flag
) This enum describes the animations enabled in the chart.
Constant
Description
QChart.NoAnimation
Animation is disabled in the chart. This is the default value.
QChart.GridAxisAnimations
Grid axis animation is enabled in the chart.
QChart.SeriesAnimations
Series animation is enabled in the chart.
QChart.AllAnimations
All animation types are enabled in the chart.
- PySide6.QtCharts.QChart.addAxis(axis, alignment)#
- Parameters:
alignment –
Alignment
Adds the axis axis
to the chart aligned as specified by alignment
. The chart takes the ownership of the axis.
See also
- PySide6.QtCharts.QChart.addSeries(series)#
- Parameters:
series –
PySide6.QtCharts.QAbstractSeries
Adds the series series
to the chart and takes ownership of it.
Note
A newly added series is not attached to any axes by default, not even those that might have been created for the chart using createDefaultAxes()
before the series was added to the chart. If no axes are attached to the newly added series before the chart is shown, the series will get drawn as if it had axes with ranges that exactly fit the series to the plot area of the chart. This can be confusing if the same chart also displays other series that have properly attached axes, so always make sure you either call createDefaultAxes()
after a series has been added or explicitly attach axes for the series.
- PySide6.QtCharts.QChart.animationDuration()#
- Return type:
int
See also
Getter of property animationDuration
.
- PySide6.QtCharts.QChart.animationEasingCurve()#
- Return type:
See also
Getter of property animationEasingCurve
.
- PySide6.QtCharts.QChart.animationOptions()#
- Return type:
AnimationOptions
See also
Getter of property animationOptions
.
- PySide6.QtCharts.QChart.axes([orientation=Qt.Horizontal|Qt.Vertical[, series=None]])#
- Parameters:
orientation –
Orientations
series –
PySide6.QtCharts.QAbstractSeries
Returns the axes attached to the series series
with the orientation specified by orientation
. If no series is specified, all axes added to the chart with the specified orientation are returned.
See also
- PySide6.QtCharts.QChart.axisX([series=None])#
- Parameters:
series –
PySide6.QtCharts.QAbstractSeries
- Return type:
Note
This function is deprecated.
Use axes()
instead.
Returns a pointer to the horizontal axis attached to the specified series
. If no series is specified, the first horizontal axis added to the chart is returned.
See also
- PySide6.QtCharts.QChart.axisY([series=None])#
- Parameters:
series –
PySide6.QtCharts.QAbstractSeries
- Return type:
Note
This function is deprecated.
Use axes()
instead.
Returns a pointer to the vertical axis attached to the specified series
. If no series is specified, the first vertical axis added to the chart is returned.
See also
- PySide6.QtCharts.QChart.backgroundBrush()#
- Return type:
Gets the brush that is used for painting the background of the chart area.
See also
- PySide6.QtCharts.QChart.backgroundPen()#
- Return type:
Gets the pen that is used for painting the background of the chart area.
See also
- PySide6.QtCharts.QChart.backgroundRoundness()#
- Return type:
float
See also
Getter of property backgroundRoundness
.
Getter of property chartType
.
- PySide6.QtCharts.QChart.createDefaultAxes()#
Creates axes for the chart based on the series that have already been added to the chart. Any axes previously added to the chart will be deleted.
Note
This function has to be called after all series have been added to the chart. The axes created by this function will NOT get automatically attached to any series added to the chart after this function has been called. A series with no axes attached will by default scale to utilize the entire plot area of the chart, which can be confusing if there are other series with properly attached axes also present.
Series type |
Horizontal axis (X) |
Vertical axis (Y) |
---|---|---|
None |
None |
If there are several QXYSeries
derived series added to the chart and no series of other types have been added, then only one pair of axes is created. If there are several series of different types added to the chart, then each series gets its own axes pair.
The axes specific to the series can be later obtained from the chart by providing the series as the parameter for the axes()
function call. QPieSeries
does not create any axes.
See also
- PySide6.QtCharts.QChart.isBackgroundVisible()#
- Return type:
bool
Getter of property backgroundVisible
.
- PySide6.QtCharts.QChart.isDropShadowEnabled()#
- Return type:
bool
Getter of property dropShadowEnabled
.
- PySide6.QtCharts.QChart.isPlotAreaBackgroundVisible()#
- Return type:
bool
Getter of property plotAreaBackgroundVisible
.
- PySide6.QtCharts.QChart.isZoomed()#
- Return type:
bool
Returns true
if any series has a zoomed domain.
- PySide6.QtCharts.QChart.legend()#
- Return type:
Returns the legend object of the chart. Ownership stays with the chart.
- PySide6.QtCharts.QChart.locale()#
- Return type:
See also
Getter of property locale
.
- PySide6.QtCharts.QChart.localizeNumbers()#
- Return type:
bool
See also
Getter of property localizeNumbers
.
- PySide6.QtCharts.QChart.mapToPosition(value[, series=None])#
- Parameters:
value –
PySide6.QtCore.QPointF
series –
PySide6.QtCharts.QAbstractSeries
- Return type:
Returns the position on the chart that corresponds to the value value
in the series specified by series
.
- PySide6.QtCharts.QChart.mapToValue(position[, series=None])#
- Parameters:
position –
PySide6.QtCore.QPointF
series –
PySide6.QtCharts.QAbstractSeries
- Return type:
Returns the value in the series specified by series
at the position specified by position
in a chart.
- PySide6.QtCharts.QChart.margins()#
- Return type:
See also
Getter of property margins
.
- PySide6.QtCharts.QChart.plotArea()#
- Return type:
See also
Getter of property plotArea
.
- PySide6.QtCharts.QChart.plotAreaBackgroundBrush()#
- Return type:
Returns the brush used to fill the background of the plot area of the chart.
See also
plotArea()
plotAreaBackgroundVisible
plotAreaBackgroundPen()
setPlotAreaBackgroundBrush()
- PySide6.QtCharts.QChart.plotAreaBackgroundPen()#
- Return type:
Returns the pen used to draw the background of the plot area of the chart.
See also
plotArea()
plotAreaBackgroundVisible
plotAreaBackgroundBrush()
setPlotAreaBackgroundPen()
- PySide6.QtCharts.QChart.plotAreaChanged(plotArea)#
- Parameters:
plotArea –
PySide6.QtCore.QRectF
Notification signal of property plotArea
.
- PySide6.QtCharts.QChart.removeAllSeries()#
Removes and deletes all series objects that have been added to the chart.
See also
- PySide6.QtCharts.QChart.removeAxis(axis)#
- Parameters:
Removes the axis axis
from the chart. The chart releases the ownership of the specified axis
object.
See also
- PySide6.QtCharts.QChart.removeSeries(series)#
- Parameters:
series –
PySide6.QtCharts.QAbstractSeries
Removes the series series
from the chart. The chart releases the ownership of the specified series
object.
See also
- PySide6.QtCharts.QChart.scroll(dx, dy)#
- Parameters:
dx – float
dy – float
Scrolls the visible area of the chart by the distance specified by dx
and dy
.
For polar charts, dx
indicates the angle along the angular axis instead of distance.
- PySide6.QtCharts.QChart.series()#
Returns all series that are added to the chart.
See also
- PySide6.QtCharts.QChart.setAnimationDuration(msecs)#
- Parameters:
msecs – int
See also
Setter of property animationDuration
.
- PySide6.QtCharts.QChart.setAnimationEasingCurve(curve)#
- Parameters:
curve –
PySide6.QtCore.QEasingCurve
See also
Setter of property animationEasingCurve
.
- PySide6.QtCharts.QChart.setAnimationOptions(options)#
- Parameters:
options –
AnimationOptions
See also
Setter of property animationOptions
.
- PySide6.QtCharts.QChart.setAxisX(axis[, series=None])#
- Parameters:
series –
PySide6.QtCharts.QAbstractSeries
Note
This function is deprecated.
Use addAxis()
instead.
Adds the axis axis
to the chart and attaches it to the series series
as a bottom-aligned horizontal axis. The chart takes ownership of both the axis and the series. Any horizontal axes previously attached to the series are deleted.
- PySide6.QtCharts.QChart.setAxisY(axis[, series=None])#
- Parameters:
series –
PySide6.QtCharts.QAbstractSeries
Note
This function is deprecated.
Use addAxis()
instead.
Adds the axis axis
to the chart and attaches it to the series series
as a left-aligned vertical axis. The chart takes ownership of both the axis and the series. Any vertical axes previously attached to the series are deleted.
- PySide6.QtCharts.QChart.setBackgroundBrush(brush)#
- Parameters:
brush –
PySide6.QtGui.QBrush
Sets the brush that is used for painting the background of the chart area to brush
.
See also
- PySide6.QtCharts.QChart.setBackgroundPen(pen)#
- Parameters:
pen –
PySide6.QtGui.QPen
Sets the pen that is used for painting the background of the chart area to pen
.
See also
- PySide6.QtCharts.QChart.setBackgroundRoundness(diameter)#
- Parameters:
diameter – float
See also
Setter of property backgroundRoundness
.
- PySide6.QtCharts.QChart.setBackgroundVisible([visible=true])#
- Parameters:
visible – bool
See also
Setter of property backgroundVisible
.
- PySide6.QtCharts.QChart.setDropShadowEnabled([enabled=true])#
- Parameters:
enabled – bool
See also
Setter of property dropShadowEnabled
.
- PySide6.QtCharts.QChart.setLocale(locale)#
- Parameters:
locale –
PySide6.QtCore.QLocale
See also
Setter of property locale
.
- PySide6.QtCharts.QChart.setLocalizeNumbers(localize)#
- Parameters:
localize – bool
See also
Setter of property localizeNumbers
.
- PySide6.QtCharts.QChart.setMargins(margins)#
- Parameters:
margins –
PySide6.QtCore.QMargins
See also
Setter of property margins
.
- PySide6.QtCharts.QChart.setPlotArea(rect)#
- Parameters:
rect –
PySide6.QtCore.QRectF
See also
Setter of property plotArea
.
- PySide6.QtCharts.QChart.setPlotAreaBackgroundBrush(brush)#
- Parameters:
brush –
PySide6.QtGui.QBrush
Sets the brush used to fill the background of the plot area of the chart to brush
.
See also
plotArea()
plotAreaBackgroundVisible
setPlotAreaBackgroundPen()
plotAreaBackgroundBrush()
- PySide6.QtCharts.QChart.setPlotAreaBackgroundPen(pen)#
- Parameters:
pen –
PySide6.QtGui.QPen
Sets the pen used to draw the background of the plot area of the chart to pen
.
See also
plotArea()
plotAreaBackgroundVisible
setPlotAreaBackgroundBrush()
plotAreaBackgroundPen()
- PySide6.QtCharts.QChart.setPlotAreaBackgroundVisible([visible=true])#
- Parameters:
visible – bool
See also
Setter of property plotAreaBackgroundVisible
.
- PySide6.QtCharts.QChart.setTheme(theme)#
- Parameters:
theme –
ChartTheme
See also
Setter of property theme
.
Setter of property title
.
- PySide6.QtCharts.QChart.setTitleBrush(brush)#
- Parameters:
brush –
PySide6.QtGui.QBrush
Sets the brush used for drawing the title text to brush
.
See also
- PySide6.QtCharts.QChart.setTitleFont(font)#
- Parameters:
font –
PySide6.QtGui.QFont
Sets the font that is used for drawing the chart title to font
.
See also
- PySide6.QtCharts.QChart.theme()#
- Return type:
See also
Getter of property theme
.
- PySide6.QtCharts.QChart.title()#
- Return type:
str
See also
Getter of property title
.
- PySide6.QtCharts.QChart.titleBrush()#
- Return type:
Returns the brush used for drawing the title text.
See also
- PySide6.QtCharts.QChart.titleFont()#
- Return type:
Gets the font that is used for drawing the chart title.
See also
- PySide6.QtCharts.QChart.zoom(factor)#
- Parameters:
factor – float
Zooms into the view by the custom factor factor
.
A factor over 1.0 zooms into the view and a factor between 0.0 and 1.0 zooms out of it.
- PySide6.QtCharts.QChart.zoomIn()#
Zooms into the view by a factor of two.
- PySide6.QtCharts.QChart.zoomIn(rect)
- Parameters:
rect –
PySide6.QtCore.QRectF
Zooms into the view to a maximum level at which the rectangle rect
is still fully visible.
Note
Applying a zoom may modify properties of attached axes, for instance QAbstractAxis::min and QAbstractAxis::max.
Note
This is not supported for polar charts.
- PySide6.QtCharts.QChart.zoomOut()#
Zooms out of the view by a factor of two.
Note
This will do nothing if the result would contain an invalid logarithmic axis range.
- PySide6.QtCharts.QChart.zoomReset()#
Resets the series domains to what they were before any zoom method was called.
Note
This will also reset scrolling and explicit axis range settings specified between the first zoom operation and calling this method. If no zoom operation has been performed, this method does nothing.