PieChart

#include <PieChart.h>

Inheritance diagram for PieChart:

Properties

QColor backgroundColor
 
bool filled
 
qreal fromAngle
 
RangeGroup range
 
bool smoothEnds
 
qreal spacing
 
qreal thickness
 
qreal toAngle
 
- Properties inherited from Chart
ChartDataSource colorSource
 
IndexingMode indexingMode
 
ChartDataSource nameSource
 
ChartDataSource shortNameSource
 
QQmlListProperty< ChartDataSourcevalueSources
 
- Properties inherited from QQuickItem
 activeFocus
 
 activeFocusOnTab
 
 antialiasing
 
 baselineOffset
 
 childrenRect
 
 clip
 
 enabled
 
 focus
 
 height
 
 implicitHeight
 
 implicitWidth
 
 opacity
 
 parent
 
 rotation
 
 scale
 
 smooth
 
 state
 
 transformOrigin
 
 visible
 
 width
 
 x
 
 y
 
 z
 
- Properties inherited from QObject
 objectName
 

Public Member Functions

 PieChart (QQuickItem *parent=nullptr)
 
QColor backgroundColor () const
 
Q_SIGNAL void backgroundColorChanged ()
 
bool filled () const
 
Q_SIGNAL void filledChanged ()
 
qreal fromAngle () const
 
Q_SIGNAL void fromAngleChanged ()
 
RangeGrouprange () const
 
void setBackgroundColor (const QColor &color)
 
void setFilled (bool newFilled)
 
void setFromAngle (qreal newFromAngle)
 
void setSmoothEnds (bool newSmoothEnds)
 
void setSpacing (qreal newSpacing)
 
void setThickness (qreal newThickness)
 
void setToAngle (qreal newToAngle)
 
bool smoothEnds () const
 
Q_SIGNAL void smoothEndsChanged ()
 
qreal spacing () const
 
Q_SIGNAL void spacingChanged ()
 
qreal thickness () const
 
Q_SIGNAL void thicknessChanged ()
 
qreal toAngle () const
 
Q_SIGNAL void toAngleChanged ()
 
- Public Member Functions inherited from Chart
 Chart (QQuickItem *parent=nullptr)
 
ChartDataSourcecolorSource () const
 
Q_SIGNAL void colorSourceChanged ()
 
IndexingMode indexingMode () const
 
Q_SIGNAL void indexingModeChanged ()
 
Q_INVOKABLE void insertValueSource (int index, ChartDataSource *source)
 
ChartDataSourcenameSource () const
 
Q_SIGNAL void nameSourceChanged ()
 
Q_INVOKABLE void removeValueSource (int index)
 
Q_INVOKABLE void removeValueSource (QObject *source)
 
void setColorSource (ChartDataSource *colorSource)
 
void setIndexingMode (IndexingMode newIndexingMode)
 
void setNameSource (ChartDataSource *nameSource)
 
void setShortNameSource (ChartDataSource *shortNameSource)
 
ChartDataSourceshortNameSource () const
 
Q_SIGNAL void shortNameSourceChanged ()
 
QVector< ChartDataSource * > valueSources () const
 
Q_SIGNAL void valueSourcesChanged ()
 
DataSourcesProperty valueSourcesProperty ()
 
- Public Member Functions inherited from QQuickItem
 QQuickItem (QQuickItem *parent)
 
Qt::MouseButtons acceptedMouseButtons () const const
 
bool acceptHoverEvents () const const
 
bool acceptTouchEvents () const const
 
void activeFocusChanged (bool)
 
bool activeFocusOnTab () const const
 
void activeFocusOnTabChanged (bool)
 
bool antialiasing () const const
 
void antialiasingChanged (bool)
 
qreal baselineOffset () const const
 
void baselineOffsetChanged (qreal)
 
QQuickItemchildAt (qreal x, qreal y) const const
 
QList< QQuickItem * > childItems () const const
 
QRectF childrenRect ()
 
void childrenRectChanged (const QRectF &)
 
bool clip () const const
 
void clipChanged (bool)
 
QObjectcontainmentMask () const const
 
void containmentMaskChanged ()
 
virtual bool contains (const QPointF &point) const const
 
QCursor cursor () const const
 
void enabledChanged ()
 
bool filtersChildMouseEvents () const const
 
QQuickItem::Flags flags () const const
 
void focusChanged (bool)
 
void forceActiveFocus ()
 
void forceActiveFocus (Qt::FocusReason reason)
 
void grabMouse ()
 
QSharedPointer< QQuickItemGrabResultgrabToImage (const QSize &targetSize)
 
void grabTouchPoints (const QVector< int > &ids)
 
bool hasActiveFocus () const const
 
bool hasFocus () const const
 
qreal height () const const
 
void heightChanged ()
 
qreal implicitHeight () const const
 
void implicitHeightChanged ()
 
qreal implicitWidth () const const
 
void implicitWidthChanged ()
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const const
 
bool isAncestorOf (const QQuickItem *child) const const
 
bool isEnabled () const const
 
bool isFocusScope () const const
 
virtual bool isTextureProvider () const const
 
bool isVisible () const const
 
bool keepMouseGrab () const const
 
bool keepTouchGrab () const const
 
QPointF mapFromGlobal (const QPointF &point) const const
 
QPointF mapFromItem (const QQuickItem *item, const QPointF &point) const const
 
QPointF mapFromScene (const QPointF &point) const const
 
QRectF mapRectFromItem (const QQuickItem *item, const QRectF &rect) const const
 
QRectF mapRectFromScene (const QRectF &rect) const const
 
QRectF mapRectToItem (const QQuickItem *item, const QRectF &rect) const const
 
QRectF mapRectToScene (const QRectF &rect) const const
 
QPointF mapToGlobal (const QPointF &point) const const
 
QPointF mapToItem (const QQuickItem *item, const QPointF &point) const const
 
QPointF mapToScene (const QPointF &point) const const
 
QQuickItemnextItemInFocusChain (bool forward)
 
qreal opacity () const const
 
void opacityChanged ()
 
void parentChanged (QQuickItem *)
 
QQuickItemparentItem () const const
 
void polish ()
 
void resetAntialiasing ()
 
void resetHeight ()
 
void resetWidth ()
 
qreal rotation () const const
 
void rotationChanged ()
 
qreal scale () const const
 
void scaleChanged ()
 
QQuickItemscopedFocusItem () const const
 
void setAcceptedMouseButtons (Qt::MouseButtons buttons)
 
void setAcceptHoverEvents (bool enabled)
 
void setAcceptTouchEvents (bool enabled)
 
void setActiveFocusOnTab (bool)
 
void setAntialiasing (bool)
 
void setBaselineOffset (qreal)
 
void setClip (bool)
 
void setContainmentMask (QObject *mask)
 
void setCursor (const QCursor &cursor)
 
void setEnabled (bool)
 
void setFiltersChildMouseEvents (bool filter)
 
void setFlag (QQuickItem::Flag flag, bool enabled)
 
void setFlags (QQuickItem::Flags flags)
 
void setFocus (bool)
 
void setFocus (bool focus, Qt::FocusReason reason)
 
void setHeight (qreal)
 
void setImplicitHeight (qreal)
 
void setImplicitWidth (qreal)
 
void setKeepMouseGrab (bool keep)
 
void setKeepTouchGrab (bool keep)
 
void setOpacity (qreal)
 
void setParentItem (QQuickItem *parent)
 
void setRotation (qreal)
 
void setScale (qreal)
 
void setSize (const QSizeF &size)
 
void setSmooth (bool)
 
void setState (const QString &)
 
void setTransformOrigin (QQuickItem::TransformOrigin)
 
void setVisible (bool)
 
void setWidth (qreal)
 
void setX (qreal)
 
void setY (qreal)
 
void setZ (qreal)
 
QSizeF size () const const
 
bool smooth () const const
 
void smoothChanged (bool)
 
void stackAfter (const QQuickItem *sibling)
 
void stackBefore (const QQuickItem *sibling)
 
QString state () const const
 
void stateChanged (const QString &)
 
virtual QSGTextureProvidertextureProvider () const const
 
QQuickItem::TransformOrigin transformOrigin () const const
 
void transformOriginChanged (QQuickItem::TransformOrigin)
 
void ungrabMouse ()
 
void ungrabTouchPoints ()
 
void unsetCursor ()
 
void update ()
 
void visibleChanged ()
 
qreal width () const const
 
void widthChanged ()
 
QQuickWindowwindow () const const
 
void windowChanged (QQuickWindow *window)
 
qreal x () const const
 
void xChanged ()
 
qreal y () const const
 
void yChanged ()
 
qreal z () const const
 
void zChanged ()
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Protected Member Functions

void onDataChanged () override
 
QSGNodeupdatePaintNode (QSGNode *node, UpdatePaintNodeData *data) override
 
- Protected Member Functions inherited from Chart
void componentComplete () override
 
- Protected Member Functions inherited from QQuickItem
virtual bool childMouseEventFilter (QQuickItem *item, QEvent *event)
 
virtual void classBegin () override
 
virtual void dragEnterEvent (QDragEnterEvent *event)
 
virtual void dragLeaveEvent (QDragLeaveEvent *event)
 
virtual void dragMoveEvent (QDragMoveEvent *event)
 
virtual void dropEvent (QDropEvent *event)
 
virtual bool event (QEvent *ev) override
 
virtual void focusInEvent (QFocusEvent *)
 
virtual void focusOutEvent (QFocusEvent *)
 
virtual void geometryChanged (const QRectF &newGeometry, const QRectF &oldGeometry)
 
bool heightValid () const const
 
virtual void hoverEnterEvent (QHoverEvent *event)
 
virtual void hoverLeaveEvent (QHoverEvent *event)
 
virtual void hoverMoveEvent (QHoverEvent *event)
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 
bool isComponentComplete () const const
 
virtual void itemChange (QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value)
 
virtual void keyPressEvent (QKeyEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 
virtual void mouseMoveEvent (QMouseEvent *event)
 
virtual void mousePressEvent (QMouseEvent *event)
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 
virtual void mouseUngrabEvent ()
 
virtual void releaseResources ()
 
virtual void touchEvent (QTouchEvent *event)
 
virtual void touchUngrabEvent ()
 
void updateInputMethod (Qt::InputMethodQueries queries)
 
virtual QSGNodeupdatePaintNode (QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *updatePaintNodeData)
 
virtual void updatePolish ()
 
virtual void wheelEvent (QWheelEvent *event)
 
bool widthValid () const const
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Public Types inherited from Chart
using DataSourcesProperty = QQmlListProperty< ChartDataSource >
 
enum  IndexingMode { IndexSourceValues = 1, IndexEachSource, IndexAllValues }
 
- Public Types inherited from QQuickItem
enum  Flag
 
enum  ItemChange
 
enum  TransformOrigin
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from QQuickItem
 Bottom
 
 BottomLeft
 
 BottomRight
 
 Center
 
typedef Flags
 
 ItemAcceptsDrops
 
 ItemAcceptsInputMethod
 
 ItemActiveFocusHasChanged
 
 ItemAntialiasingHasChanged
 
 ItemChildAddedChange
 
 ItemChildRemovedChange
 
 ItemClipsChildrenToShape
 
 ItemDevicePixelRatioHasChanged
 
 ItemEnabledHasChanged
 
 ItemHasContents
 
 ItemIsFocusScope
 
 ItemOpacityHasChanged
 
 ItemParentHasChanged
 
 ItemRotationHasChanged
 
 ItemSceneChange
 
 ItemVisibleHasChanged
 
 Left
 
 Right
 
 Top
 
 TopLeft
 
 TopRight
 
- Public Attributes inherited from QObject
typedef QObjectList
 

Detailed Description

An item to render a pie chart.

This item will render a Pie chart based on the valueSources supplied to it. By default it will set indexingMode to IndexSourceValues, meaning that it will use the individual values of the valueSources to render sections of the chart.

Usage example

import QtQuick 2.11
import QtQuick.Controls 2.11
import org.kde.quickcharts 1.0 as Charts
Charts.PieChart {
width: 400
height: 300
valueSources: Charts.ModelSource {
roleName: "data";
model: ListModel {
id: listModel
ListElement { data: 12 }
ListElement { data: 19 }
ListElement { data: 10 }
ListElement { data: 13 }
ListElement { data: 13 }
}
}
colorSource: Charts.ArraySource { array: ["red", "green", "blue", "yellow", "cyan"] }
nameSource: Charts.ArraySource { array: ["Red", "Green", "Blue", "Yellow", "Cyan"] }
}
piechart.png
The resulting pie chart.

Multiple Value Sources

Multiple valueSources are rendered as consecutive pie charts in the same item. The first valueSource will become the outermost circle and consecutive valueSources will be rendered as continuously smaller circles. When rendering multiple value sources, filled will only affect the last value source. All other value sources will be rendered according to thickness, with spacing amount of space between them.

Definition at line 50 of file PieChart.h.

Property Documentation

QColor PieChart::backgroundColor
readwrite

Sets a colour to use to fill remaining space on the pie.

The default is transparent.

Definition at line 87 of file PieChart.h.

bool PieChart::filled
readwrite

Whether to use a filled pie or not.

If true, the last pie rendered will be rendered as a filled circle. The default is false.

Definition at line 69 of file PieChart.h.

qreal PieChart::fromAngle
readwrite

The starting angle of the arc used for the entire pie.

When set, instead of rendering a full circle, the pie will be rendered as an arc. The default is 0.

Definition at line 94 of file PieChart.h.

RangeGroup * PieChart::range
read

The range of values to display in this PieChart.

When set to "automatic", the values will be divided across the entire chart.

See also
RangeGroup

Definition at line 62 of file PieChart.h.

bool PieChart::smoothEnds
readwrite

Smooth the ends of pie sections.

When true, this will try to smooth the ends of sections. This works best when filled is false. The default is false.

Definition at line 109 of file PieChart.h.

qreal PieChart::spacing
readwrite

The amount of spacing between pies when rendering multiple value sources.

The default is 0.

Definition at line 81 of file PieChart.h.

qreal PieChart::thickness
readwrite

The thickness of an individual pie, in pixels.

If filled is set, this is ignored for the last pie. The default is 10px.

Definition at line 75 of file PieChart.h.

qreal PieChart::toAngle
readwrite

The end angle of the arc used for the entire pie.

When set, instead of rendering a full circle, the pie will be rendered as an arc. The default is 360.

Definition at line 100 of file PieChart.h.

Member Function Documentation

void PieChart::onDataChanged ( )
overrideprotectedvirtual

Reimplemented from Chart.

Implements Chart.

Definition at line 187 of file PieChart.cpp.

QSGNode * PieChart::updatePaintNode ( QSGNode node,
UpdatePaintNodeData *  data 
)
overrideprotected

Reimplemented from QQuickItem.

Definition at line 141 of file PieChart.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Jan 27 2021 22:48:10 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.