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
Instantiated By: XYSeries
Inherits: QAbstractSeries
Inherited By:

QLineSeries, QScatterSeries, and QSplineSeries

Properties

Public Functions

void append(const QList<QPointF> &points)
void append(const QPointF &point)
void append(qreal x, qreal y)
const 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)
bool draggable() const
int find(const QPointF &point) const
void insert(qsizetype index, const QPointF &point)
bool isPointSelected(qsizetype index)
QQmlComponent *pointMarker() const
QList<QPointF> points() const
void remove(const 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(const QPointF &oldPoint, const QPointF &newPoint)
void replace(qsizetype index, const 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(const QColor &newColor)
void setDraggable(bool newDraggable)
void setPointMarker(QQmlComponent *newPointMarker)
void setPointSelected(qsizetype index, bool selected)
void setSelectedColor(const QColor &color)
bool take(const QPointF &point)
void toggleSelection(const QList<qsizetype> &indexes)

Signals

void colorChanged(QColor color)
void draggableChanged()
void pointMarkerChanged()
void pointReplaced(qsizetype index)
void selectedColorChanged(const 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(const QColor &newColor)

Notifier signal:

void colorChanged(QColor color)

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 draggable() const
void setDraggable(bool newDraggable)

Notifier signal:

void draggableChanged()

pointMarker : 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.
QColorpointSelectedColorThe selected color of the series. This value comes either from the QGraphsTheme or from QXYSeries::selectedColor if the QXYSeries overrides the color.
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 *pointMarker() const
void setPointMarker(QQmlComponent *newPointMarker)

Notifier signal:

void pointMarkerChanged()

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(const QColor &color)

Notifier signal:

void selectedColorChanged(const 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(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(const 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(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] const 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] qsizetype QXYSeries::count() const

Returns the number of data points in a 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] int QXYSeries::find(const 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, const 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)

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.

[invokable] void QXYSeries::remove(const 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 pointReplaced 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(const QPointF &oldPoint, const 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, const 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(const 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.