QCharts類管理一個可以顯示圖表系列的圖片,座標軸,和曲線
文章目錄
- 詳細描述
- 枚舉變量
- 參數文檔
- animationDuration:int
- animationEasingCurve:QEasingCurve
- animationOptions:QChart::AnimationOptions
- backgroundRoundness:qreal
- backgroundVisble:bool
- charType:const QChart::chartType
- dropShadowEnabled:bool
- locale:QLocale
- localizeNumbers:bool
- margins:QMargins
- plotArea:QRectF
- plotAreaBackgroundVisable:bool
- theme:Qchart::chartTheme
- title:QString
- 成員函數描述
詳細描述
QCharts是一個QGraphicsWidget,你可以展示圖片它管理了一個有不同線和其他的比如標題欄或者座標軸的對象,爲了在一個列表中展示一個圖表,一個名爲QChartView的類可以用代替QChart,除此之外,線,虛線,空間,極座標等可以使用QPolarChart類來使用
枚舉變量
枚舉變量描述了chart的主題,設定這些主題以後將會改變所有的系列
參數文檔
animationDuration:int
這個參數來控制圖形的動畫時間
訪問方法:
int animationDuration() const
void setAnimationDuration(int msecs)
animationEasingCurve:QEasingCurve
此屬性保存圖表動畫的緩動曲線
訪問方法:
QEasingCurve animationEasingCurve() const
void setAnimationEasingCurve(const QEasingVurve &curve)
animationOptions:QChart::AnimationOptions
這個參數決定圖表的動畫選項
動畫是否使能取決於這個設置
訪問方法:
QChart::AnimationOptions animationOptions() const
void setAnimationOptions(QChart::AnimationOptions options)
backgroundRoundness:qreal
此屬性保存圖表背景角處的圓的直徑。
訪問方法:
qreal backgroundness() const
void setBackgroundRoundness(qreal diameter)
backgroundVisble:bool
這個屬性決定是否圖表的背景是有效的
訪問方式:
bool isBackgroundVisble() const
void setBackgroundVisible(bool visible = true)
charType:const QChart::chartType
這個參數決定是否是迪卡爾座標系還是一個直角座標系
這個參數是在內部實現的,在外面是僅僅可讀的
訪問方式:
QChart::ChartType charType() const
dropShadowEnabled:bool
這個參數決定背景消除陰影是否是有效的,如果是有效的,背景消除陰影就會使能,反之會結束,
**注意:**背景消除陰影取決於主題,如果主題變了,這個效果也會變化
訪問方式:
bool isDropShadowEnabled() const
void setDropShadowEnabled(bool enabled = true)
locale:QLocale
此屬性保存用於格式化各種圖表標籤的區域設置。
只有當locailzeNumbers爲真的時候,除了QDateTimeAxis標籤之外,通常使用QLocale來設置這個屬性,默認的應用將會在這個圖表創建的時候構建
訪問方式:
QLocale locale() const
void setLocale(const QLocale & locale)
localizeNumbers:bool
這個參數決定了是否這個數據是局部的
當爲真的時候,所有,意思就是是否允許標籤固定
**注意:**這個參數不會影響QDataTimeAxis標籤,這個標籤經常使用QLocale設置locale屬性
訪問方式:
bool localizeNumbers() const
void setLocalizeNumbers(bool localize)
margins:QMargins
這個參數保證了在繪圖區域和圖表區域的最小的邊緣
這個參數用來繪製標題,座標軸和網格
訪問方式:
QMargins margins() const
void setMargins(const QMargins &margins)
plotArea:QRectF
這個參數決定了圖表在繪製的矩形的區域
繪製區域不包括邊框的區域,默認情況下他們將會在QChartView中重新繪製大小,如果一個明確的繪製尺寸設定了,就會遵守,調用函數setPlotArea(QRectF())使之恢復到默認表現
訪問方式:
QRectF plotArea() const
void setPlotArea(const QRectF &rect)
通知信號:
void plotAreaChaged(const QRectF &plotArea)
plotAreaBackgroundVisable:bool
這個參數決定了圖表的繪製區域的背景是否是有效的
訪問方法:
bool isPlotAreaBackgroundVisible() const
void setPlotAreaBackgroundVisable(bool visible = true)
theme:Qchart::chartTheme
這個參數決定了是否主題可以用在圖表中
訪問方法:
QChart::ChartTheme theme() const
void setTheme(QChart::ChartTheme theme)
title:QString
這個參數決定了圖表的標題
這個標題將會在圖表的上方出現,標題支持HTML格式
訪問方法:
QString title() const
void setTitle(const QString &title)
成員函數描述
QChart::QChart(QGraphicsitem *parant = nullptr, Qt::WindowFlags wFlags = Qt::WindowFlags())
構造一個圖表對象,是其父類的子對象,這個參數通過wFlags來指定,還會調用 QGraphicsWidget 的構造函數
QChart::~QChart() [virtual]
刪除這個圖表對象以及它的子對象,比如裏面的一系列的系列對象
void QChart::addAxis(QAbstractAxis *axis, Qt::Alignemnt alignment)
向圖表中插入指定的系列的曲線,這個圖表擁有這些對象
與此相關的還有removeAxis(), reateDefaultAxes(), 和 QAbstractSeries::attchAxis()
void QChart::addSeries(QAbstractSeries *series)
向圖表中添加新的系列
新添加的數據系列在默認情況下不會依附於任何的座標軸,所以我們可能需要在系列添加早圖表之前使用函數createDefaultAxes()來設置默認的額座標軸,如果沒有將新添加的系列依附在一個座標軸上,如果圖表中已經有座標軸的話,這個系列將會附着在現有的座標軸上,這樣可能導致圖表的混亂,所以儘量在添加數據系列之前調用函數createDefaultAxes()函數
QList<QAbstractAxis *> QChart::axes(Qt::Qrientations orientation = Qt::Horizontal|Qt::Vertical, QAbstractSeries *series = nullptr) const
根據方向返回座標軸上的系列
QBrush QChart::backgroundBrush() const
得到圖表區域的繪製背景的刷子
QPen QChart::backgroundPen() const
得到繪製圖表區域的背景
void QChart::createDefaultAxes()
創在圖表的基本的格式,任何之前加載圖表中的系列都將被刪除
**注意:**這個函數需要在數據系列添加到圖表之前調用
bool QChart::isZoomed()
如果有任何的縮放域,就返回true
QLegend *QChart::legend() const
返回圖表中的圖例,以QLegend的形式來返回
QPointF QChart::mapToPosition(const QPointF &value, QAbstractSeries *series = nullptr)
返回返回指定值在圖表中的位置
QPointF QChart::mapToValue(const QPointF &position, QAbstractSeries *series = nullptr)
返回指定值在圖表中的指定位置的值
QBrush QChart::plotAreaBackgroundBrush() const
返回填充背景的刷子QBrush
QPen QChart::plotAreaBackgroundPen() sonst
返回繪製圖表背景的QPen
void QChart::removeAllSeries()
移除所有的添加到圖表中的系列
void QChart::removeAxis(QAbstractAxis *axis)
從圖表中移除座標軸,圖表釋放指定的座標軸對象的所有權
void QChart::removeSeries(QAbstractSeries *series)
從圖表中移除一系列的系列,圖表釋放對這些系列的所有權
void QChart::scroll(qreal dx, qreal dy)
滾動圖表的有效位置,按照dx,dy的長度來滾動
QList<QAbstractSeries *> QChart::series() const
返回所有添加到圖表中的數據系列
void QChart::setBackgroundBrush(const QBrush &brush)
設置一個用來繪製該圖表的刷子
void QChart::setPlotAreaBackgroundPen(const QPen &pen)
設置一個用來繪製圖表區域背景的一個QPen
void QChart::setTitleBrush(const QBrush &brush)
設置一個繪製圖表標題的刷子QBrush
void QChart::setTiitleFont(const QFont &font)
設置圖表標題的字體
void QChart::titleBrush() const
返回用來繪製圖表標題的刷子
void QChart::titleBrush() const
返回用來繪製圖表標題的刷子
void QChart::titleFont() const
得到用來繪製圖表標題的字體
void QChart::zoom(qreal factor)
通過定製的factor來縮放圖標是視圖
void QChart::zoomIn()
將圖表視圖放大兩倍
void QChart::zoomIn(const QRect &rect)
方法這個圖表視圖
void QChart::zoomOut()
縮小視圖
void QChart::zoomReset()
復位視圖