QChart¶
The QChart
class manages the graphical representation of the chart’s series, legends, and axes. More…
Inherited by: QPolarChart
Synopsis¶
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)
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.
- 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¶
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
This property holds The duration of the animation for the chart..
- PySide6.QtCharts.QChart.animationEasingCurve()¶
- Return type
This property holds The easing curve of the animation for the chart..
- PySide6.QtCharts.QChart.animationOptions()¶
- Return type
AnimationOptions
This property holds The animation options for the chart..
Animations are enabled or disabled based on this setting.
- PySide6.QtCharts.QChart.axes([orientation=Qt.Horizontal|Qt.Vertical[, series=None]])¶
- Parameters
orientation –
Orientations
series –
PySide6.QtCharts.QAbstractSeries
- Return type
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
This property holds The diameter of the rounding circle at the corners of the chart background..
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
- 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
This property holds Whether the chart background is visible..
See also
setBackgroundBrush()
setBackgroundPen()
plotAreaBackgroundVisible
- PySide6.QtCharts.QChart.isDropShadowEnabled()¶
- Return type
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.
- PySide6.QtCharts.QChart.isPlotAreaBackgroundVisible()¶
- Return type
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
- 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
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
- PySide6.QtCharts.QChart.localizeNumbers()¶
- Return type
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
- 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
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.
- PySide6.QtCharts.QChart.plotArea()¶
- Return type
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.
- 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
- 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()¶
- Return type
Returns all series that are added to the chart.
See also
- PySide6.QtCharts.QChart.setAnimationDuration(msecs)¶
- Parameters
msecs – int
This property holds The duration of the animation for the chart..
- PySide6.QtCharts.QChart.setAnimationEasingCurve(curve)¶
- Parameters
curve –
PySide6.QtCore.QEasingCurve
This property holds The easing curve of the animation for the chart..
- PySide6.QtCharts.QChart.setAnimationOptions(options)¶
- Parameters
options –
AnimationOptions
This property holds The animation options for the chart..
Animations are enabled or disabled based on this setting.
- 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
This property holds The diameter of the rounding circle at the corners of the chart background..
- PySide6.QtCharts.QChart.setBackgroundVisible([visible=true])¶
- Parameters
visible – bool
This property holds Whether the chart background is visible..
See also
setBackgroundBrush()
setBackgroundPen()
plotAreaBackgroundVisible
- PySide6.QtCharts.QChart.setDropShadowEnabled([enabled=true])¶
- Parameters
enabled – 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.
- PySide6.QtCharts.QChart.setLocale(locale)¶
- Parameters
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
- PySide6.QtCharts.QChart.setLocalizeNumbers(localize)¶
- Parameters
localize – 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
- PySide6.QtCharts.QChart.setMargins(margins)¶
- Parameters
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.
- PySide6.QtCharts.QChart.setPlotArea(rect)¶
- Parameters
rect –
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.
- 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
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
- PySide6.QtCharts.QChart.setTheme(theme)¶
- Parameters
theme –
ChartTheme
This property holds The theme used for the chart..
- PySide6.QtCharts.QChart.setTitle(title)¶
- Parameters
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.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
This property holds The theme used for the chart..
- PySide6.QtCharts.QChart.title()¶
- Return type
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.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.
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.