The QChart 類管理圖錶的係列、圖例和軸的圖形錶示。 更多...
| 頭: | #include <QChart> |
| 繼承: | QGraphicsWidget |
| 繼承者: | QPolarChart |
| enum | AnimationOption { NoAnimation, GridAxisAnimations, SeriesAnimations, AllAnimations } |
| flags | AnimationOptions |
| enum | ChartTheme { ChartThemeLight, ChartThemeBlueCerulean, ChartThemeDark, ChartThemeBrownSand, ..., ChartThemeQt } |
| enum | ChartType { ChartTypeUndefined, ChartTypeCartesian, ChartTypePolar } |
|
|
| QChart (QGraphicsItem * parent = nullptr, Qt::WindowFlags wFlags = Qt::WindowFlags()) | |
| virtual | ~QChart () |
| void | addAxis (QAbstractAxis * axis , Qt::Alignment alignment ) |
| void | addSeries (QAbstractSeries * series ) |
| int | animationDuration () const |
| QEasingCurve | animationEasingCurve () const |
| QChart::AnimationOptions | animationOptions () const |
| QList<QAbstractAxis *> | axes (Qt::Orientations orientation = Qt::Horizontal|Qt::Vertical, QAbstractSeries * series = nullptr) const |
| QBrush | backgroundBrush () const |
| QPen | backgroundPen () const |
| qreal | backgroundRoundness () const |
| QChart::ChartType | chartType () const |
| void | createDefaultAxes () |
| bool | isBackgroundVisible () const |
| bool | isDropShadowEnabled () const |
| bool | isPlotAreaBackgroundVisible () const |
| bool | isZoomed () |
| QLegend * | legend () const |
| QLocale | locale () const |
| bool | localizeNumbers () const |
| QPointF | mapToPosition (const QPointF & value , QAbstractSeries * series = nullptr) |
| QPointF | mapToValue (const QPointF & position , QAbstractSeries * series = nullptr) |
| QMargins | margins () const |
| QRectF | plotArea () const |
| QBrush | plotAreaBackgroundBrush () const |
| QPen | plotAreaBackgroundPen () const |
| void | removeAllSeries () |
| void | removeAxis (QAbstractAxis * axis ) |
| void | removeSeries (QAbstractSeries * series ) |
| void | scroll (qreal dx , qreal dy ) |
| QList<QAbstractSeries *> | series () const |
| void | setAnimationDuration (int msecs ) |
| void | setAnimationEasingCurve (const QEasingCurve & curve ) |
| void | setAnimationOptions (QChart::AnimationOptions options ) |
| void | setBackgroundBrush (const QBrush & brush ) |
| void | setBackgroundPen (const QPen & pen ) |
| 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 | setPlotAreaBackgroundBrush (const QBrush & brush ) |
| void | setPlotAreaBackgroundPen (const QPen & pen ) |
| void | setPlotAreaBackgroundVisible (bool visible = true) |
| void | setTheme (QChart::ChartTheme theme ) |
| void | setTitle (const QString & title ) |
| void | setTitleBrush (const QBrush & brush ) |
| void | setTitleFont (const QFont & font ) |
| QChart::ChartTheme | theme () const |
| QString | title () const |
| QBrush | titleBrush () const |
| QFont | titleFont () const |
| void | zoom (qreal factor ) |
| void | zoomIn () |
| void | zoomIn (const QRectF & rect ) |
| void | zoomOut () |
| void | zoomReset () |
| void | plotAreaChanged (const QRectF & plotArea ) |
| const QMetaObject | staticMetaObject |
| QScopedPointer<QChartPrivate> | d_ptr |
The QChart 類管理圖錶的係列、圖例和軸的圖形錶示。
QChart 是 QGraphicsWidget 可以展示在 QGraphicsScene 。它管理不同係列類型及其它圖錶相關對象 (像圖例和軸) 的圖形錶示。為在布局中簡單展示圖錶,方便類 QChartView 可以用來代替 QChart 。此外,綫、樣條綫、區域和散點係列可以呈現為極坐標圖錶通過使用 QPolarChart 類。
另請參閱 QChartView and QPolarChart .
此枚舉描述圖錶中啓用的動畫。
| 常量 | 值 | 描述 |
|---|---|---|
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. |
AnimationOptions 類型是 typedef 對於 QFlags <AnimationOption>. It stores an OR combination of AnimationOption values.
此枚舉描述用於圖錶的主題。
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 圖錶主題範例 illustrates how to use themes.
注意: Changing the theme will overwrite all customizations previously applied to the series.
| 常量 | 值 | 描述 |
|---|---|---|
QChart::ChartThemeLight
|
0
|
The light theme, which is the default theme. |
QChart::ChartThemeBlueCerulean
|
1
|
鈷天藍主題。 |
QChart::ChartThemeDark
|
2
|
暗黑主題。 |
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
|
Qt 主題。 |
此枚舉描述圖錶類型。
| 常量 | 值 | 描述 |
|---|---|---|
QChart::ChartTypeUndefined
|
0
|
圖錶類型未定義。 |
QChart::ChartTypeCartesian
|
1
|
笛卡爾圖錶。 |
QChart::ChartTypePolar
|
2
|
極坐標圖錶。 |
This property holds the duration of the animation for the chart.
訪問函數:
| int | animationDuration () const |
| void | setAnimationDuration (int msecs ) |
This property holds the easing curve of the animation for the chart.
訪問函數:
| QEasingCurve | animationEasingCurve () const |
| void | setAnimationEasingCurve (const QEasingCurve & curve ) |
This property holds the animation options for the chart.
Animations are enabled or disabled based on this setting.
訪問函數:
| QChart::AnimationOptions | animationOptions () const |
| void | setAnimationOptions (QChart::AnimationOptions options ) |
This property holds the diameter of the rounding circle at the corners of the chart background.
訪問函數:
| qreal | backgroundRoundness () const |
| void | setBackgroundRoundness (qreal diameter ) |
此特性保持圖錶背景是否可見。
訪問函數:
| bool | isBackgroundVisible () const |
| void | setBackgroundVisible (bool visible = true) |
另請參閱 setBackgroundBrush (), setBackgroundPen (),和 plotAreaBackgroundVisible .
This property holds whether the chart is a cartesian chart or a polar chart.
This property is set internally and it is read only.
訪問函數:
| QChart::ChartType | chartType () const |
另請參閱 QPolarChart .
This property holds whether the background drop shadow effect is enabled.
若設為
true
, the background drop shadow effect is enabled. If set to
false
, it is disabled.
注意: The drop shadow effect depends on the theme, and therefore the setting may change if the theme is changed.
訪問函數:
| bool | isDropShadowEnabled () const |
| void | setDropShadowEnabled (bool enabled = true) |
此特性保持用於格式各種圖錶標簽的區域設置。
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.
訪問函數:
| QLocale | locale () const |
| void | setLocale (const QLocale & locale ) |
另請參閱 localizeNumbers .
This property holds whether numbers are localized.
當
true
, all generated numbers appearing in various series and axis labels will be localized using the
QLocale
set with the
locale
property. When
false
,
C
locale is always used. Defaults to
false
.
注意: This property does not affect QDateTimeAxis labels, which always use the QLocale set with the locale property.
訪問函數:
| bool | localizeNumbers () const |
| void | setLocalizeNumbers (bool localize ) |
另請參閱 locale .
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.
訪問函數:
| QMargins | margins () const |
| void | setMargins (const QMargins & margins ) |
此特性保持繪製圖錶內的矩形。
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.
訪問函數:
| QRectF | plotArea () const |
| void | setPlotArea (const QRectF & rect ) |
通知程序信號:
| void | plotAreaChanged (const QRectF & plotArea ) |
此特性保持圖錶繪圖區域背景是否可見。
注意: 默認情況下,繪圖區域背景是不可見的且繪圖區域使用一般圖錶背景。
訪問函數:
| bool | isPlotAreaBackgroundVisible () const |
| void | setPlotAreaBackgroundVisible (bool visible = true) |
另請參閱 setPlotAreaBackgroundBrush (), setPlotAreaBackgroundPen (),和 backgroundVisible .
此特性保持用於圖錶的主題。
訪問函數:
| QChart::ChartTheme | theme () const |
| void | setTheme (QChart::ChartTheme theme ) |
此特性保持圖錶的標題。
標題是展示在圖錶頂部的標題行。圖錶標題支持 HTML 格式。
訪問函數:
| QString | title () const |
| void | setTitle (const QString & title ) |
構造子級圖錶對象為 parent 。特性指定通過 wFlags 被傳遞給 QGraphicsWidget 構造函數。
[虛擬]
QChart::
~QChart
()
刪除圖錶對象及其子級,譬如:添加到它的係列和軸對象。
添加軸 axis 到圖錶對齊的指定通過 alignment 。圖錶擁有軸的所有權。
另請參閱 removeAxis (), createDefaultAxes (),和 QAbstractSeries::attachAxis ().
添加係列 series 到圖錶並擁有其所有權。
注意: 默認情況下,不會將新近添加的係列附加到任何軸,甚至圖錶可能已創建那些軸使用 createDefaultAxes () 在將係列添加到圖錶之前。若展示圖錶之前沒有將軸附加到新近添加的係列,係列將被繪製,就好像它擁有會將係列範圍準確擬閤到圖錶繪圖區域的軸。這會令人睏惑,若同一圖錶還顯示擁有正確附加軸的其它係列,因此始終確保調用 createDefaultAxes () 在添加係列後或為係列明確附加軸。
另請參閱 removeSeries (), removeAllSeries (), createDefaultAxes (),和 QAbstractSeries::attachAxis ().
返迴軸已附加到係列 series 采用取嚮指定通過 orientation 。若未指定係列,按指定取嚮返迴添加到圖錶的所有軸。
另請參閱 addAxis () 和 createDefaultAxes ().
Gets the brush that is used for painting the background of the chart area.
另請參閱 setBackgroundBrush ().
Gets the pen that is used for painting the background of the chart area.
另請參閱 setBackgroundPen ().
基於已添加到圖錶的係列為圖錶創建軸。先前添加到圖錶的任何軸都會被刪除。
注意: 此函數必須被調用,在將所有係列添加到圖錶後。由此函數創建的軸不會自動附加到 (已添加到圖錶的) 任何係列,在此函數被調用後。默認情況下,將比例縮放沒有附加軸的係列以利用圖錶的整個繪圖區域,這會令人睏惑,若還存在其它帶有正確附加軸的係列。
| 係列類型 | 水平軸 (X) | 垂直軸 (Y) |
|---|---|---|
| QXYSeries | QValueAxis | QValueAxis |
| QBarSeries | QBarCategoryAxis | QValueAxis |
| QPieSeries | None | None |
若有幾個 QXYSeries 派生係列被添加到圖錶且未添加其它類型的係列,則僅創建一對軸。若錶有添加幾個不同類型的係列,那麼每個係列都有自己的軸對。
稍後可以從圖錶獲得係列的特定軸,通過將係列提供作為參數對於 axes () 函數調用。 QPieSeries 不創建任何軸。
另請參閱 axes () 和 QAbstractSeries::attachAxis ().
返迴
true
if any series has a zoomed domain.
返迴圖錶的圖例對象。所有權停留在圖錶。
Returns the position on the chart that corresponds to the value value in the series specified by series .
Returns the value in the series specified by series at the position specified by position in a chart.
Returns the brush used to fill the background of the plot area of the chart.
另請參閱 plotArea (), plotAreaBackgroundVisible , plotAreaBackgroundPen (),和 setPlotAreaBackgroundBrush ().
Returns the pen used to draw the background of the plot area of the chart.
另請參閱 plotArea (), plotAreaBackgroundVisible , plotAreaBackgroundBrush (),和 setPlotAreaBackgroundPen ().
Removes and deletes all series objects that have been added to the chart.
另請參閱 addSeries () 和 removeSeries ().
Removes the axis axis from the chart. The chart releases the ownership of the specified axis 對象。
另請參閱 addAxis (), createDefaultAxes (),和 QAbstractSeries::detachAxis ().
Removes the series series from the chart. The chart releases the ownership of the specified series 對象。
另請參閱 addSeries () 和 removeAllSeries ().
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.
Returns all series that are added to the chart.
另請參閱 addSeries (), removeSeries (),和 removeAllSeries ().
Sets the brush that is used for painting the background of the chart area to brush .
另請參閱 backgroundBrush ().
Sets the pen that is used for painting the background of the chart area to pen .
另請參閱 backgroundPen ().
Sets the brush used to fill the background of the plot area of the chart to brush .
另請參閱 plotArea (), plotAreaBackgroundVisible , setPlotAreaBackgroundPen (),和 plotAreaBackgroundBrush ().
Sets the pen used to draw the background of the plot area of the chart to pen .
另請參閱 plotArea (), plotAreaBackgroundVisible , setPlotAreaBackgroundBrush (),和 plotAreaBackgroundPen ().
Sets the brush used for drawing the title text to brush .
另請參閱 titleBrush ().
Sets the font that is used for drawing the chart title to font .
另請參閱 titleFont ().
Returns the brush used for drawing the title text.
另請參閱 setTitleBrush ().
Gets the font that is used for drawing the chart title.
另請參閱 setTitleFont ().
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.
Zooms into the view by a factor of two.
Zooms into the view to a maximum level at which the rectangle rect is still fully visible.
注意: Applying a zoom may modify properties of attached axes, for instance QAbstractAxis::min and QAbstractAxis::max.
注意: 這不支持極坐標圖錶。
Zooms out of the view by a factor of two.
Resets the series domains to what they were before any zoom method was called.
注意: 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.