- Qt 6.12
- Qt Graphs
- QML Types
- QtGraphs
- XYSeries
- Qt Graphs | Commercial or GPLv3

# XYSeries QML Type (Uncreatable)

A parent type for all x & y series types. More...

Import Statement: | `import QtGraphs`
In C++: | QXYSeries
Inherits: | AbstractSeries
Inherited By: | LineSeries, ScatterSeries, and SplineSeries

Note: This is an uncreatable type. It cannot be instantiated in QML.

- List of all members, including inherited members
- XYSeries is part of Qt Graphs QML Types for 2D.

## Properties

- color : color
- count : int
- declarativePoints : list<variant> `(since 6.12)`
- draggable : bool
- pointDelegate : Component
- selectedColor : color
- selectedPoints : list<int>

## Signals

- clicked(point point)
- colorChanged(color color)
- doubleClicked(point point)
- draggableChanged()
- pointMarkerChanged()
- pointReplaced(int index)
- pointsAdded(int start, int end) `(since 6.9)`
- pointsReplaced()
- pressed(point point)
- released(point point)
- selectedColorChanged(color color)
- selectedPointsChanged()

## Methods

- void append(list<point> points)
- void append(point point)
- void append(real x, real y)
- point at(int index)
- void clear()
- void deselectAllPoints()
- void deselectPoint(int index)
- void deselectPoints(list<int> indexes)
- int find(point point)
- void insert(int index, point point)
- bool isPointSelected(int index)
- void remove(int index)
- void remove(point point)
- void remove(real x, real y)
- void removeMultiple(int index, int count)
- void replace(list<point> points)
- void replace(int index, point newPoint)
- void replace(point oldPoint, point newPoint)
- void replace(int index, real newX, real newY)
- void replace(real oldX, real oldY, real newX, real newY)
- void selectAllPoints()
- void selectPoint(int index)
- void selectPoints(list<int> indexes)
- void setPointSelected(int index, bool selected)
- bool take(point point)
- void toggleSelection(list<int> indexes)

## Detailed Description

In XYSeries, data points are defined as a list of point types, defining X and Y positions.

## Property Documentation

### color : color

The main color of the series. For LineSeries this means the line color and for ScatterSeries the color of the point

### count : int `[read-only]`

Returns the number of data points in a series.

### declarativePoints : list<variant> `[since 6.12]`

This property can be used to set points declaratively for a XYSeries. The variant list can be either points or numbers. If numbers are given, the declarativePointHint can be used to indicate whether the number is interpreted as the X or Y component of a point.

This property was introduced in Qt 6.12.

### draggable : bool

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

### pointDelegate : Component

A custom QML Component used as a marker for data points.

The dynamic properties available for this component are:

Type | Name | Description
--- | --- | ---
bool | pointSelected | This value is true when the point is selected.
Color | pointColor | The color of the series. This value comes either from the GraphsTheme or from XYSeries::color if the XYSeries overrides the color.
Color | pointBorderColor | The border color of the series. This value comes from the GraphsTheme.
Color | pointSelectedColor | The selected color of the series. This value comes either from the GraphsTheme or from XYSeries::selectedColor if the XYSeries overrides the color.
real | pointBorderWidth | The border width of the series. This value comes from the GraphsTheme.
real | pointValueX | The value of the XYPoint::x at this position.
real | pointValueY | The value of the XYPoint::y at this position.
int | pointIndex | The index of the point, from 0 to the amount of points - 1. [since 6.9]

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

### selectedColor : color

The color of selected points.

### selectedPoints : list<int> `[read-only]`

The indexes of the points which are currently selected.

## Signal Documentation

### clicked(point point)

This signal is emitted when the user clicks or taps the point in the graph.

Note: The corresponding handler is `onClicked`.

### colorChanged(color color)

This signal is emitted when the line color changes to color.

Note: The corresponding handler is `onColorChanged`.

### doubleClicked(point point)

This signal is emitted when the user double-clicks or double-taps the data point in the graph. The point is the point where the first press was triggered. This signal always occurs after clicked.

Note: The corresponding handler is `onDoubleClicked`.

### draggableChanged()

This signal is emitted when a series becomes draggable by a mouse/touch or becomes fixed.

Note: The corresponding handler is `onDraggableChanged`.

### pointMarkerChanged()

This signal is emitted when a point is changed.

Note: The corresponding handler is `onPointMarkerChanged`.

### pointReplaced(int index)

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

Note: The corresponding handler is `onPointReplaced`.

### `[since 6.9]` pointsAdded(int start, int end)

This signal is emitted when a list of points is appended. The indexes of the new added points are between start and end.

Note: The corresponding handler is `onPointsAdded`.

This signal was introduced in Qt 6.9.

### pointsReplaced()

This signal is emitted when all points are replaced.

Note: The corresponding handler is `onPointsReplaced`.

### pressed(point point)

This signal is emitted when the user presses the data point in the graph and holds down the mouse button or gesture.

Note: The corresponding handler is `onPressed`.

### released(point point)

This signal is emitted when the user releases the previously pressed mouse button or gesture on the data point.

Note: The corresponding handler is `onReleased`.

### selectedColorChanged(color color)

This signal is emitted when the color of selected series changes to color.

Note: The corresponding handler is `onSelectedColorChanged`.

### selectedPointsChanged()

This signal is emitted when the set of selected points changes.

Note: The corresponding handler is `onSelectedPointsChanged`.

## Method Documentation

### void append(list<point> points)

Appends points with the coordinates points to the series.

Note: This is much faster than appending data points one by one. Emits pointsAdded when the points have been added.

### void append(point point)

Appends a point with the coordinates point to the series.

### void append(real x, real y)

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

### point at(int index)

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

### void clear()

Removes all points from the series.

### void deselectAllPoints()

Deselects all points in the series.

Note: Emits QXYSeries::selectedPointsChanged

See also setPointSelected().

### void deselectPoint(int index)

Deselects point at given index.

Note: Emits QXYSeries::selectedPointsChanged

See also setPointSelected().

### void deselectPoints(list<int> indexes)

Marks multiple points passed in a indexes list as deselected.

Note: Emits QXYSeries::selectedPointsChanged

See also setPointSelected().

### int find(point point)

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

### void insert(int index, point 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 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 selectedColor.

### void remove(int index)

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

### void remove(point point)

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

### void remove(real x, real y)

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

### void removeMultiple(int index, int count)

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

### void replace(list<point> 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.

### void replace(int index, point newPoint)

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

### void replace(point oldPoint, point 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 replace(int index, real newX, real newY)

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

### void replace(real oldX, real oldY, real newX, real 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 selectAllPoints()

Marks all points in the series as selected,

Note: Emits QXYSeries::selectedPointsChanged

See also setPointSelected().

### void selectPoint(int index)

Marks point at index as selected.

Note: Emits QXYSeries::selectedPointsChanged

See also setPointSelected().

### void selectPoints(list<int> indexes)

Marks multiple points passed in a indexes list as selected.

Note: Emits QXYSeries::selectedPointsChanged

See also setPointSelected().

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

### bool take(point point)

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

### void toggleSelection(list<int> indexes)

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

Note: Emits QXYSeries::selectedPointsChanged

See also setPointSelected().