QXYSeries Class

The QXYSeries class is a parent class for all x & y series classes. More...

Header: #include <QXYSeries>
CMake: find_package(Qt6 REQUIRED COMPONENTS Graphs)
target_link_libraries(mytarget PRIVATE Qt6::Graphs)
qmake: QT += graphs
In QML: XYSeries
Inherits: QAbstractSeries
Inherited By:

QLineSeries, QScatterSeries, and QSplineSeries

Properties

Public Functions

void append(QPointF point)
void append(const QList<QPointF> &points)
void append(qreal x, qreal y)
QPointF at(qsizetype index) const
void clear()
QColor color() const
qsizetype count() const
void deselectAllPoints()
void deselectPoint(qsizetype index)
void deselectPoints(const QList<qsizetype> &indexes)
qsizetype find(QPointF point) const
void insert(qsizetype index, QPointF point)
bool isDraggable() const
bool isPointSelected(qsizetype index) const
QQmlComponent *pointDelegate() const
QList<QPointF> points() const
void remove(QPointF point)
void remove(qsizetype index)
void remove(qreal x, qreal y)
void removeMultiple(qsizetype index, qsizetype count)
void replace(const QList<QPointF> &points)
void replace(QPointF oldPoint, QPointF newPoint)
void replace(qsizetype index, QPointF newPoint)
void replace(qsizetype index, qreal newX, qreal newY)
void replace(qreal oldX, qreal oldY, qreal newX, qreal newY)
void selectAllPoints()
void selectPoint(qsizetype index)
void selectPoints(const QList<qsizetype> &indexes)
QColor selectedColor() const
QList<qsizetype> selectedPoints() const
void setColor(QColor newColor)
void setDraggable(bool newDraggable)
void setPointDelegate(QQmlComponent *newPointDelegate)
void setPointSelected(qsizetype index, bool selected)
void setSelectedColor(QColor color)
bool take(QPointF point)
void toggleSelection(const QList<qsizetype> &indexes)

Signals

void colorChanged(QColor color)
void countChanged()
void draggableChanged()
void pointDelegateChanged()
void pointReplaced(qsizetype index)
void pointsReplaced()
void selectedColorChanged(QColor color)
void selectedPointsChanged()

Detailed Description

In QXYSeries, data points are defined as a list of QPointF, defining X and Y positions.

See also QLineSeries and QScatterSeries.

Property Documentation

color : QColor

This property holds the main color of the series. For QLineSeries this means the line color and for QScatterSeries the color of the point.

Access functions:

QColor color() const
void setColor(QColor newColor)

Notifier signal:

void colorChanged(QColor color)

[read-only] count : const qsizetype

Returns the number of data points in a series.

Access functions:

qsizetype count() const

Notifier signal:

void countChanged()

draggable : bool

Controls if the series is draggable.

Controls if the series can be dragged with mouse/touch. By default, draggable is set to false.

Access functions:

bool isDraggable() const
void setDraggable(bool newDraggable)

Notifier signal:

void draggableChanged()

pointDelegate : QQmlComponent*

This property holds a custom QML Component used as a marker for data points.

The dynamic properties available for this component are:

TypeNameDescription
boolpointSelectedThis value is true when the point is selected, meaning that the point index is in QXYSeries::selectedPoints.
QColorpointColorThe color of the series. This value comes either from the QGraphsTheme or from QXYSeries::color if the QXYSeries overrides the color.
QColorpointBorderColorThe border color of the series. This value comes from the QGraphsTheme.
QColorpointSelectedColorThe selected color of the series. This value comes either from the QGraphsTheme or from QXYSeries::selectedColor if the QXYSeries overrides the color.
qrealpointBorderWidthThe border width of the series. This value comes from the QGraphsTheme.
qrealpointValueXThe value of the QXYPoint::x at this position.
qrealpointValueYThe value of the QXYPoint::y at this position.

To use any of these, add property with the defined name into your custom component. For example "property color pointColor" and "property real pointValueX".

Access functions:

QQmlComponent *pointDelegate() const
void setPointDelegate(QQmlComponent *newPointDelegate)

Notifier signal:

void pointDelegateChanged()

selectedColor : QColor

This property holds the main color of the selected series. For QLineSeries this means the line color and for QScatterSeries the color of the point.

Access functions:

QColor selectedColor() const
void setSelectedColor(QColor color)

Notifier signal:

void selectedColorChanged(QColor color)

[read-only] selectedPoints : const QList<qsizetype>

This property holds the indexes of the points which are currently selected.

Access functions:

QList<qsizetype> selectedPoints() const

Notifier signal:

void selectedPointsChanged()

Member Function Documentation

[invokable] void QXYSeries::append(QPointF point)

Appends a point with the coordinates point to the series.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] void QXYSeries::append(const QList<QPointF> &points)

Appends points with the coordinates points to the series.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] void QXYSeries::append(qreal x, qreal y)

Appends a point with the coordinates x and y to the series.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] QPointF QXYSeries::at(qsizetype index) const

Returns the point at the position specified by index. Returns (0, 0) if the index is not valid.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] void QXYSeries::clear()

Removes all points from the series.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] void QXYSeries::deselectAllPoints()

Deselects all points in the series.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also setPointSelected().

[invokable] void QXYSeries::deselectPoint(qsizetype index)

Deselects point at given index.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also setPointSelected().

[invokable] void QXYSeries::deselectPoints(const QList<qsizetype> &indexes)

Marks multiple points passed in a indexes list as deselected.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also setPointSelected().

[invokable] qsizetype QXYSeries::find(QPointF point) const

Finds and returns the index of the first matching point found as defined by point. Returns -1 if the point is not found.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] void QXYSeries::insert(qsizetype index, QPointF point)

Inserts a point with the coordinates point to the position specified by index in the series. If the index is 0 or less than 0, the point is prepended to the list of points. If the index is equal to or greater than than the number of points in the series, the point is appended to the list of points.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] bool QXYSeries::isPointSelected(qsizetype index) const

Returns true if point at given index is among selected points and false otherwise.

Note: Selected points are drawn using the selected color if it was specified.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also selectedPoints, setPointSelected(), and setSelectedColor().

[signal] void QXYSeries::pointReplaced(qsizetype index)

This signal is emitted when a point is replaced at the position specified by index.

See also replace().

QList<QPointF> QXYSeries::points() const

Returns the points in the series.

[signal] void QXYSeries::pointsReplaced()

This signal is emitted when all points are replaced.

[invokable] void QXYSeries::remove(QPointF point)

Removes the point with the coordinates point from the series. Does nothing if the point does not exist.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] void QXYSeries::remove(qsizetype index)

Removes the point at the position specified by index from the series.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] void QXYSeries::remove(qreal x, qreal y)

Removes the point with the coordinates x and y from the series. Does nothing if the point does not exist.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] void QXYSeries::removeMultiple(qsizetype index, qsizetype count)

Removes the number of points specified by count from the series starting at the position specified by index.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] void QXYSeries::replace(const QList<QPointF> &points)

Replaces the current points with the points specified by points

Note: This is much faster than replacing data points one by one, or first clearing all data, and then appending the new data. Emits pointsReplaced when the points have been replaced.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] void QXYSeries::replace(QPointF oldPoint, QPointF newPoint)

Replaces the point with the coordinates oldPoint with the point with the coordinates newPoint. Does nothing if the old point does not exist.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] void QXYSeries::replace(qsizetype index, QPointF newPoint)

Replaces the point at the position specified by index with the point that has the coordinates newPoint.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] void QXYSeries::replace(qsizetype index, qreal newX, qreal newY)

Replaces the point at the position specified by index with the point that has the coordinates newX and newY.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] void QXYSeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY)

Replaces the point with the coordinates oldX and oldY with the point with the coordinates newX and newY. Does nothing if the old point does not exist.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] void QXYSeries::selectAllPoints()

Marks all points in the series as selected,

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also setPointSelected().

[invokable] void QXYSeries::selectPoint(qsizetype index)

Marks point at index as selected.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also setPointSelected().

[invokable] void QXYSeries::selectPoints(const QList<qsizetype> &indexes)

Marks multiple points passed in a indexes list as selected.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also setPointSelected().

QList<qsizetype> QXYSeries::selectedPoints() const

Returns a list of points indexes marked as selected. Selected points are visible regardless of points visibility.

Note: Getter function for property selectedPoints.

See also setPointSelected().

[invokable] void QXYSeries::setPointSelected(qsizetype index, bool selected)

Marks point at given index as either selected or deselected as specified by selected.

Note: Selected points are drawn using the selected color if it was specified. Emits QXYSeries::selectedPointsChanged

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also isPointSelected(), selectAllPoints(), and setSelectedColor().

[invokable] bool QXYSeries::take(QPointF point)

Takes a point, specified by point, out of the series if found. Returns true if the operation is successful.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] void QXYSeries::toggleSelection(const QList<qsizetype> &indexes)

Changes selection state of points at given indexes to the opposite one.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also setPointSelected().

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.