- class 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
Methods#
def
__init__()
def
backgroundPen()
def
chartType()
def
isZoomed()
def
legend()
def
locale()
def
mapToPosition()
def
mapToValue()
def
margins()
def
plotArea()
def
scroll()
def
setLocale()
def
setMargins()
def
setPlotArea()
def
setTheme()
def
setTitle()
def
setTitleBrush()
def
setTitleFont()
def
theme()
def
title()
def
titleBrush()
def
titleFont()
def
zoom()
def
zoomIn()
def
zoomOut()
def
zoomReset()
Signals#
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 classQChartView
can be used instead ofQChart
. In addition, line, spline, area, and scatter series can be presented as polar charts by using theQPolarChart
class.See also
- class 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.
- class 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 Charts with Widgets Gallery 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.
- class 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.
Note
Properties can be used directly when
from __feature__ import true_property
is used or via accessor functions otherwise.- property animationDurationᅟ: int#
This property holds The duration of the animation for the chart..
- Access functions:
- property animationEasingCurveᅟ: QEasingCurve#
This property holds The easing curve of the animation for the chart..
- Access functions:
- property animationOptionsᅟ: Combination of QChart.AnimationOption#
This property holds The animation options for the chart..
Animations are enabled or disabled based on this setting.
- Access functions:
- property backgroundRoundnessᅟ: float#
This property holds The diameter of the rounding circle at the corners of the chart background..
- Access functions:
- property backgroundVisibleᅟ: bool#
This property holds Whether the chart background is visible..
See also
setBackgroundBrush()
setBackgroundPen()
plotAreaBackgroundVisible
- Access functions:
- property chartTypeᅟ: QChart.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:
- property 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 tofalse
, 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:
This property holds The locale used to format various chart labels..
Labels are localized only when
localizeNumbers
istrue
, except forQDateTimeAxis
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
- Access functions:
- property 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 thelocale
property. Whenfalse
, the C locale is always used. Defaults tofalse
.Note
This property does not affect
QDateTimeAxis
labels, which always use the QLocale set with the locale property.See also
- Access functions:
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:
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 callingsetPlotArea(QRectF());
will achieve this.- Access functions:
- property 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:
- property themeᅟ: QChart.ChartTheme#
This property holds The theme used for the chart..
- Access functions:
- property 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.
- Access functions:
- __init__([parent=None[, wFlags=Qt.WindowFlags()]])#
- Parameters:
parent –
QGraphicsItem
wFlags – Combination of
WindowType
Constructs a chart object that is a child of
parent
. The properties specified bywFlags
are passed to the QGraphicsWidget constructor.- __init__(type, parent, wFlags)
- Parameters:
type –
ChartType
parent –
QGraphicsItem
wFlags – Combination of
WindowType
- animationDuration()#
- Return type:
int
See also
Getter of property
animationDurationᅟ
.- animationEasingCurve()#
- Return type:
See also
Getter of property
animationEasingCurveᅟ
.- animationOptions()#
- Return type:
Combination of
AnimationOption
See also
Getter of property
animationOptionsᅟ
.Gets the brush that is used for painting the background of the chart area.
See also
Gets the pen that is used for painting the background of the chart area.
See also
- backgroundRoundness()#
- Return type:
float
See also
Getter of property
backgroundRoundnessᅟ
.Getter of property
chartTypeᅟ
.- 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
axes()
attachAxis()
- isBackgroundVisible()#
- Return type:
bool
Getter of property
backgroundVisibleᅟ
.- isDropShadowEnabled()#
- Return type:
bool
Getter of property
dropShadowEnabledᅟ
.- isPlotAreaBackgroundVisible()#
- Return type:
bool
Getter of property
plotAreaBackgroundVisibleᅟ
.- isZoomed()#
- Return type:
bool
Returns
true
if any series has a zoomed domain.Returns the legend object of the chart. Ownership stays with the chart.
- locale()#
- Return type:
See also
Getter of property
localeᅟ
.- localizeNumbers()#
- Return type:
bool
See also
Getter of property
localizeNumbersᅟ
.- margins()#
- Return type:
See also
Getter of property
marginsᅟ
.- plotArea()#
- Return type:
See also
Getter of property
plotAreaᅟ
.Returns the brush used to fill the background of the plot area of the chart.
See also
plotArea()
plotAreaBackgroundVisible
plotAreaBackgroundPen()
setPlotAreaBackgroundBrush()
Returns the pen used to draw the background of the plot area of the chart.
See also
plotArea()
plotAreaBackgroundVisible
plotAreaBackgroundBrush()
setPlotAreaBackgroundPen()
Notification signal of property
plotAreaᅟ
.- removeAllSeries()#
Removes and deletes all series objects that have been added to the chart.
See also
addSeries()
removeSeries()
- scroll(dx, dy)#
- Parameters:
dx – float
dy – float
Scrolls the visible area of the chart by the distance specified by
dx
anddy
.For polar charts,
dx
indicates the angle along the angular axis instead of distance.- setAnimationDuration(msecs)#
- Parameters:
msecs – int
See also
Setter of property
animationDurationᅟ
.- setAnimationEasingCurve(curve)#
- Parameters:
curve –
QEasingCurve
See also
Setter of property
animationEasingCurveᅟ
.- setAnimationOptions(options)#
- Parameters:
options – Combination of
AnimationOption
See also
Setter of property
animationOptionsᅟ
.Sets the brush that is used for painting the background of the chart area to
brush
.See also
Sets the pen that is used for painting the background of the chart area to
pen
.See also
- setBackgroundRoundness(diameter)#
- Parameters:
diameter – float
See also
Setter of property
backgroundRoundnessᅟ
.- setBackgroundVisible([visible=true])#
- Parameters:
visible – bool
See also
Setter of property
backgroundVisibleᅟ
.- setDropShadowEnabled([enabled=true])#
- Parameters:
enabled – bool
See also
Setter of property
dropShadowEnabledᅟ
.Setter of property
localeᅟ
.- setLocalizeNumbers(localize)#
- Parameters:
localize – bool
See also
Setter of property
localizeNumbersᅟ
.Setter of property
marginsᅟ
.Setter of property
plotAreaᅟ
.Sets the brush used to fill the background of the plot area of the chart to
brush
.See also
plotArea()
plotAreaBackgroundVisible
setPlotAreaBackgroundPen()
plotAreaBackgroundBrush()
Sets the pen used to draw the background of the plot area of the chart to
pen
.See also
plotArea()
plotAreaBackgroundVisible
setPlotAreaBackgroundBrush()
plotAreaBackgroundPen()
- setPlotAreaBackgroundVisible([visible=true])#
- Parameters:
visible – bool
See also
Setter of property
plotAreaBackgroundVisibleᅟ
.- setTheme(theme)#
- Parameters:
theme –
ChartTheme
See also
Setter of property
themeᅟ
.Setter of property
titleᅟ
.Sets the brush used for drawing the title text to
brush
.See also
Sets the font that is used for drawing the chart title to
font
.See also
- theme()#
- Return type:
See also
Getter of property
themeᅟ
.- title()#
- Return type:
str
See also
Getter of property
titleᅟ
.Returns the brush used for drawing the title text.
See also
Gets the font that is used for drawing the chart title.
See also
- 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.
- zoomIn()#
Zooms into the view by a factor of two.
- zoomIn(rect)
- Parameters:
rect –
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.
- 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.
- 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.