QChart Class
The QChart class manages the graphical representation of the chart's series, legends, and axes. More...
| Header: | #include <QChart> |
| Inherits: | QGraphicsWidget |
| Inherited By: |
Public Types
| enum | AnimationOption { NoAnimation, GridAxisAnimations, SeriesAnimations, AllAnimations } |
| enum | ChartTheme { ChartThemeLight, ChartThemeBlueCerulean, ChartThemeDark, ChartThemeBrownSand, ChartThemeBlueNcs, …, ChartThemeQt } |
| enum | ChartType { ChartTypeUndefined, ChartTypeCartesian, ChartTypePolar } |
Properties
|
|
Public Functions
| int | animationDuration() const |
| QEasingCurve | animationEasingCurve() const |
| QChart::AnimationOptions | animationOptions() const |
| qreal | backgroundRoundness() const |
| QChart::ChartType | chartType() const |
| bool | isBackgroundVisible() const |
| bool | isDropShadowEnabled() const |
| bool | isPlotAreaBackgroundVisible() const |
| QLocale | locale() const |
| bool | localizeNumbers() const |
| QMargins | margins() const |
| QRectF | plotArea() const |
| void | setAnimationDuration(int msecs) |
| void | setAnimationEasingCurve(const QEasingCurve &curve) |
| void | setAnimationOptions(QChart::AnimationOptions options) |
| void | setBackgroundRoundness(qreal diameter) |
| void | setBackgroundVisible(bool visible = true) |
| void | setDropShadowEnabled(bool enabled = true) |
| void | setLocale(const QLocale &locale) |
| void | setLocalizeNumbers(bool localize) |
| void | setMargins(const QMargins &margins) |
| void | setPlotArea(const QRectF &rect) |
| void | setPlotAreaBackgroundVisible(bool visible = true) |
| void | setTheme(QChart::ChartTheme theme) |
| void | setTitle(const QString &title) |
| QChart::ChartTheme | theme() const |
| QString | title() const |
Signals
| void | plotAreaChanged(const QRectF &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 QChartView and QPolarChart.
Member Type Documentation
enum QChart::AnimationOption
This enum describes the animations enabled in the chart.
| Constant | Value | Description |
|---|---|---|
QChart::NoAnimation | 0x0 | Animation is disabled in the chart. This is the default value. |
QChart::GridAxisAnimations | 0x1 | Grid axis animation is enabled in the chart. |
QChart::SeriesAnimations | 0x2 | Series animation is enabled in the chart. |
QChart::AllAnimations | 0x3 | All animation types are enabled in the chart. |
enum 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 | Value | Description |
|---|---|---|
QChart::ChartThemeLight | 0 | The light theme, which is the default theme. |
QChart::ChartThemeBlueCerulean | 1 | The cerulean blue theme. |
QChart::ChartThemeDark | 2 | The dark theme. |
QChart::ChartThemeBrownSand | 3 | The sand brown theme. |
QChart::ChartThemeBlueNcs | 4 | The natural color system (NCS) blue theme. |
QChart::ChartThemeHighContrast | 5 | The high contrast theme. |
QChart::ChartThemeBlueIcy | 6 | The icy blue theme. |
QChart::ChartThemeQt | 7 | The Qt theme. |
enum QChart::ChartType
This enum describes the chart type.
| Constant | Value | Description |
|---|---|---|
QChart::ChartTypeUndefined | 0 | The chart type is not defined. |
QChart::ChartTypeCartesian | 1 | A cartesian chart. |
QChart::ChartTypePolar | 2 | A polar chart. |
Property Documentation
animationDuration : int
This property holds the duration of the animation for the chart.
Access functions:
| int | animationDuration() const |
| void | setAnimationDuration(int msecs) |
animationEasingCurve : QEasingCurve
This property holds the easing curve of the animation for the chart.
Access functions:
| QEasingCurve | animationEasingCurve() const |
| void | setAnimationEasingCurve(const QEasingCurve &curve) |
animationOptions : QChart::AnimationOptions
This property holds the animation options for the chart.
Animations are enabled or disabled based on this setting.
Access functions:
| QChart::AnimationOptions | animationOptions() const |
| void | setAnimationOptions(QChart::AnimationOptions options) |
backgroundRoundness : qreal
This property holds the diameter of the rounding circle at the corners of the chart background.
Access functions:
| qreal | backgroundRoundness() const |
| void | setBackgroundRoundness(qreal diameter) |
backgroundVisible : bool
This property holds whether the chart background is visible.
Access functions:
| bool | isBackgroundVisible() const |
| void | setBackgroundVisible(bool visible = true) |
See also setBackgroundBrush(), setBackgroundPen(), and plotAreaBackgroundVisible.
chartType : const 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.
Access functions:
| QChart::ChartType | chartType() const |
See also QPolarChart.
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:
| bool | isDropShadowEnabled() const |
| void | setDropShadowEnabled(bool enabled = true) |
locale : 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.
Access functions:
| QLocale | locale() const |
| void | setLocale(const QLocale &locale) |
See also localizeNumbers.
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.
Access functions:
| bool | localizeNumbers() const |
| void | setLocalizeNumbers(bool localize) |
See also locale.
margins : 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:
| QMargins | margins() const |
| void | setMargins(const QMargins &margins) |
plotArea : 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:
| QRectF | plotArea() const |
| void | setPlotArea(const QRectF &rect) |
Notifier signal:
| void | plotAreaChanged(const QRectF &plotArea) |
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.
Access functions:
| bool | isPlotAreaBackgroundVisible() const |
| void | setPlotAreaBackgroundVisible(bool visible = true) |
See also setPlotAreaBackgroundBrush(), setPlotAreaBackgroundPen(), and backgroundVisible.
theme : QChart::ChartTheme
This property holds the theme used for the chart.
Access functions:
| QChart::ChartTheme | theme() const |
| void | setTheme(QChart::ChartTheme theme) |
title : QString
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:
| QString | title() const |
| void | setTitle(const QString &title) |