- Qt 6.12
- Qt Graphs
- C++ Classes
- QtGraphs
- QCustomSeries
- Qt Graphs | Commercial or GPLv3

# QCustomSeries Class

The QCustomSeries class allows presenting customized graph types. More...

Header: | `#include <QCustomSeries>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS Graphs)` `target_link_libraries(mytarget PRIVATE Qt6::Graphs)`
qmake: | `QT += graphs`
Since: | Qt 6.11
In QML: | CustomSeries
Inherits: | QAbstractSeries

- List of all members, including inherited members

## Properties

- delegate : QQmlComponent*

## Public Functions

void | append()
void | append(const QVariantMap &data)
QQmlComponent * | delegate() const
void | insert(qsizetype index)
void | insert(qsizetype index, const QVariantMap &data)
qreal | mapX(qreal x)
qreal | mapY(qreal y)
void | remove(qsizetype index)
void | setCustomSeriesPainter(QCustomSeriesCanvasRenderer *painter)
void | setDelegate(QQmlComponent *newDelegate)

## Public Slots

void | clear()

## Signals

void | delegateChanged()

## Protected Functions

virtual void | updateDelegate(QQuickItem *item, qsizetype index)

## Detailed Description

Use QCustomSeries to create customized graphs. Think of it as a scatter graph that lets you access custom data for each element.

QCustomSeries defines a delegate that is used to render every item added to the graph. Each item includes user-defined data stored in a QVariantMap. Index of the item in the graph is also automatically added to the data map. The series passes this map to each element created based on the delegate. The delegate determines how to use the data.

To map data to the render coordinates defined by the `QGraphsView` axes, use the mapX and mapY functions.

Note: Currently, individual elements in a custom series do not share information with one another. For this reason, you can't implement a custom line series.

## Property Documentation

### delegate : QQmlComponent*

The delegate is used to insert elements to QML corresponding to provided custom data. Data is defined in the CustomSeries itself and given to the delegated elements through the "data" property.

Access functions:

QQmlComponent * | delegate() const
void | setDelegate(QQmlComponent *newDelegate)

Notifier signal:

void | delegateChanged()

## Member Function Documentation

### `[invokable]` void QCustomSeries::append()

Appends an empty data item to the series.

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

### `[invokable]` void QCustomSeries::append(const QVariantMap &data)

Appends a data item defined by data to the series.

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

### `[slot]` void QCustomSeries::clear()

Clear all data items.

### `[invokable]` void QCustomSeries::insert(qsizetype index)

Appends an empty data item to the series at position index.

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

### `[invokable]` void QCustomSeries::insert(qsizetype index, const QVariantMap &data)

Appends a data item defined by data to the series at position index.

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

### `[invokable]` qreal QCustomSeries::mapX(qreal x)

Returns x axis-space coordinate converted into render-space.

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

### `[invokable]` qreal QCustomSeries::mapY(qreal y)

Returns y axis-space coordinate converted into render-space.

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

### `[invokable]` void QCustomSeries::remove(qsizetype index)

Remove a data item at position index.

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

### void QCustomSeries::setCustomSeriesPainter(QCustomSeriesCanvasRenderer *painter)

Sets painter as the canvas painter renderer used to draw this series when the high-performance canvas painter backend is in use.

QCustomSeries takes ownership of painter. It is adopted by the CanvasPainter-backend renderer the next time this series is synchronized, after which it is destroyed only by the renderer, on the render thread – never by QCustomSeries directly. If painter is replaced or cleared before that first synchronization, or if this series is destroyed before it, QCustomSeries deletes it itself.

### `[virtual protected]` void QCustomSeries::updateDelegate(QQuickItem *item, qsizetype index)

Called by the graph renderer to give access to the item representing the data, and the index corresponding to the data item.

Override to implement custom property values for QQuickItem instance(s).