- Qt 6.7
- Qt Graphs
- C++ Classes
- QtGraphs (Technical Preview)
- QXYSeries
- Qt Graphs | Commercial or GPLv3

# 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 and QScatterSeries
Status: | Technical Preview

- List of all members, including inherited members
- QXYSeries is part of Qt Graphs C++ Classes for 2D.

## Properties

axisX : QAbstractAxis* axisY : QAbstractAxis* color : QColor | markerSize : qreal pointMarker : QQmlComponent* selectedColor : QColor

## Public Functions

void | append(qreal x, qreal y)
void | append(const QPointF &point)
void | append(const QList<QPointF> &points)
const QPointF & | at(int index) const
QAbstractAxis * | axisX() const
QAbstractAxis * | axisY() const
void | clear()
virtual QColor | color() const
int | count() const
void | deselectAllPoints()
void | deselectPoint(int index)
void | deselectPoints(const QList<int> &indexes)
void | insert(int index, const QPointF &point)
bool | isPointSelected(int index)
qreal | markerSize() const
QQmlComponent * | pointMarker() const
QList<QPointF> | points() const
void | remove(qreal x, qreal y)
void | remove(const QPointF &point)
void | remove(int index)
void | removePoints(int index, int count)
void | replace(qreal oldX, qreal oldY, qreal newX, qreal newY)
void | replace(const QPointF &oldPoint, const QPointF &newPoint)
void | replace(int index, qreal newX, qreal newY)
void | replace(int index, const QPointF &newPoint)
void | replace(const QList<QPointF> &points)
void | selectAllPoints()
void | selectPoint(int index)
void | selectPoints(const QList<int> &indexes)
QColor | selectedColor() const
QList<int> | selectedPoints() const
void | setAxisX(QAbstractAxis *axis)
void | setAxisY(QAbstractAxis *axis)
virtual void | setColor(const QColor &newColor)
void | setMarkerSize(qreal size)
void | setPointMarker(QQmlComponent *newPointMarker)
void | setPointSelected(int index, bool selected)
void | setSelectedColor(const QColor &color)
void | toggleSelection(const QList<int> &indexes)

## Signals

void | axisXChanged()
void | axisYChanged()
void | colorChanged(QColor color)
void | markerSizeChanged(qreal size)
void | pointMarkerChanged()
void | pointReplaced(int index)
void | selectedColorChanged(const QColor &color)

## 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

### axisX : QAbstractAxis*

X-axis of the series.

The x-axis used for the series. This should be QValueAxis.

Access functions:

QAbstractAxis * | axisX() const
void | setAxisX(QAbstractAxis *axis)

Notifier signal:

void | axisXChanged()

### axisY : QAbstractAxis*

Y-axis of the series.

The y-axis used for the series. This should be QValueAxis.

Access functions:

QAbstractAxis * | axisY() const
void | setAxisY(QAbstractAxis *axis)

Notifier signal:

void | axisYChanged()

### 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:

virtual QColor | color() const
virtual void | setColor(const QColor &newColor)

Notifier signal:

void | colorChanged(QColor color)

### markerSize : qreal

This property holds the size of the point marker in pixels when using a default circle as a marker. When using pointMarker, the size is defined by the pointMarker conponent.

Access functions:

qreal | markerSize() const
void | setMarkerSize(qreal size)

Notifier signal:

void | markerSizeChanged(qreal size)

### pointMarker : QQmlComponent*

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

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)

## Member Function Documentation

### void QXYSeries::append(qreal x, qreal y)

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

### void QXYSeries::append(const QPointF &point)

Appends a point with the coordinates point to the series.

### void QXYSeries::append(const QList<QPointF> &points)

Appends points with the coordinates points to the series.

### const QPointF &QXYSeries::at(int index) const

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

### void QXYSeries::clear()

Removes all points from the series.

### int QXYSeries::count() const

Returns the number of data points in a series.

### void QXYSeries::deselectAllPoints()

Deselects all points in the series.

Note: Emits QXYSeries::selectedPointsChanged

See also setPointSelected().

### void QXYSeries::deselectPoint(int index)

Deselects point at given index.

Note: Emits QXYSeries::selectedPointsChanged

See also setPointSelected().

### void QXYSeries::deselectPoints(const QList<int> &indexes)

Marks multiple points passed in a indexes list as deselected.

Note: Emits QXYSeries::selectedPointsChanged

See also setPointSelected().

### void QXYSeries::insert(int 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.

### bool QXYSeries::isPointSelected(int 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.

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

### `[signal]` void QXYSeries::pointReplaced(int 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.

### 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.

### void QXYSeries::remove(const QPointF &point)

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

### void QXYSeries::remove(int index)

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

### void QXYSeries::removePoints(int index, int count)

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

### 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.

### 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.

### void QXYSeries::replace(int index, qreal newX, qreal newY)

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

### void QXYSeries::replace(int index, const QPointF &newPoint)

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

### 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.

### void QXYSeries::selectAllPoints()

Marks all points in the series as selected,

Note: Emits QXYSeries::selectedPointsChanged

See also setPointSelected().

### void QXYSeries::selectPoint(int index)

Marks point at index as selected.

Note: Emits QXYSeries::selectedPointsChanged

See also setPointSelected().

### void QXYSeries::selectPoints(const QList<int> &indexes)

Marks multiple points passed in a indexes list as selected.

Note: Emits QXYSeries::selectedPointsChanged

See also setPointSelected().

### QList<int> QXYSeries::selectedPoints() const

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

See also setPointSelected().

### void QXYSeries::setPointSelected(int 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

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

### void QXYSeries::toggleSelection(const QList<int> &indexes)

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

Note: Emits QXYSeries::selectedPointsChanged

See also setPointSelected().