QAbstractSeries Class | Qt Charts 5.7

Qt 5.7 | Qt Charts | C++ Classes | QAbstractSeries

Qt 5.7.0 Reference Documentation

# QAbstractSeries Class

Base class for all Qt Chart series. More...

Header: | #include <QAbstractSeries>
Instantiated By: | AbstractSeries
Inherits: | QObject
Inherited By: | QAbstractBarSeries, QAreaSeries, QBoxPlotSeries, QPieSeries, and QXYSeries

- List of all members, including inherited members

## Public Types

enum | SeriesType { SeriesTypeLine, SeriesTypeArea, SeriesTypeBar, SeriesTypeStackedBar, ..., SeriesTypeBoxPlot }

## Properties

- name : QString
- opacity : qreal
- type : const SeriesType

- useOpenGL : bool
- visible : bool

- 1 property inherited from QObject

## Public Functions

| ~QAbstractSeries()
bool | attachAxis(QAbstractAxis *axis)
QList<QAbstractAxis *> | attachedAxes()
QChart * | chart() const
bool | detachAxis(QAbstractAxis *axis)
void | hide()
bool | isVisible() const
QString | name() const
qreal | opacity() const
void | setName(const QString &name)
void | setOpacity(qreal opacity)
void | setUseOpenGL(bool enable = true)
void | setVisible(bool visible = true)
void | show()
virtual SeriesType | type() const = 0
bool | useOpenGL() const

- 31 public functions inherited from QObject

## Signals

void | nameChanged()
void | opacityChanged()
void | useOpenGLChanged()
void | visibleChanged()

- 2 signals inherited from QObject

### Additional Inherited Members

- 1 public slot inherited from QObject
- 1 public variable inherited from QObject
- 10 static public members inherited from QObject
- 9 protected functions inherited from QObject
- 2 protected variables inherited from QObject

## Detailed Description

Base class for all Qt Chart series.

Usually you use the series type specific inherited classes instead of the base class.

See also QXYSeries, QLineSeries, QSplineSeries, QScatterSeries, QAreaSeries, QAbstractBarSeries, QStackedBarSeries, QPercentBarSeries, and QPieSeries.

## Member Type Documentation

### enum QAbstractSeries::SeriesType

The type of the series object.

Constant | Value
--- | ---
`QAbstractSeries::SeriesTypeLine` | `0`
`QAbstractSeries::SeriesTypeArea` | `1`
`QAbstractSeries::SeriesTypeBar` | `2`
`QAbstractSeries::SeriesTypeStackedBar` | `3`
`QAbstractSeries::SeriesTypePercentBar` | `4`
`QAbstractSeries::SeriesTypePie` | `5`
`QAbstractSeries::SeriesTypeScatter` | `6`
`QAbstractSeries::SeriesTypeSpline` | `7`
`QAbstractSeries::SeriesTypeHorizontalBar` | `8`
`QAbstractSeries::SeriesTypeHorizontalStackedBar` | `9`
`QAbstractSeries::SeriesTypeHorizontalPercentBar` | `10`
`QAbstractSeries::SeriesTypeBoxPlot` | `11`

## Property Documentation

### name : QString

This property holds name of the series property. The name is shown in legend for series and supports html formatting.

Access functions:

QString | name() const
void | setName(const QString &name)

Notifier signal:

void | nameChanged()

### opacity : qreal

This property holds the opacity of the series.

By default the opacity is 1.0. The valid values range from 0.0 (transparent) to 1.0 (opaque).

Access functions:

qreal | opacity() const
void | setOpacity(qreal opacity)

Notifier signal:

void | opacityChanged()

### type : const SeriesType

The type of the series.

Access functions:

virtual SeriesType | type() const = 0

### useOpenGL : bool

This property specifies whether or not the series drawing is accelerated with OpenGL.

Drawing series with OpenGL is supported only for QLineSeries and QScatterSeries. Line series used as edge series for a QAreaSeries cannot use OpenGL acceleration. When a chart contains any series that are drawn with OpenGL, a transparent QOpenGLWidget is created on top of the chart plot area. The accelerated series are not drawn on the underlying QGraphicsView, but are instead drawn on the created QOpenGLWidget.

Performance gained from using OpenGL to accelerate series drawing depends on the underlying hardware, but in most cases it is significant. For example, on a standard desktop computer, enabling OpenGL acceleration for a series typically allows rendering at least hundred times more points without reduction on the frame rate. Chart size also has less effect on the frame rate.

The OpenGL acceleration of series drawing is meant for use cases that need fast drawing of large numbers of points. It is optimized for efficiency, and therefore the series using it lack support for many features available to non-accelerated series:

- Series animations are not supported for accelerated series.
- Antialiasing is not supported for accelerated series.
- Point labels are not supported for accelerated series.
- Pen styles and marker shapes are ignored for accelerated series. Only solid lines and plain scatter dots are supported. The scatter dots may be circular or rectangular, depending on the underlying graphics hardware and drivers.
- Polar charts do not support accelerated series.
- Mouse events are not supported for accelerated series.
- Enabling chart drop shadow or using transparent chart background color is not recommended when using accelerated series, as that can slow the frame rate down significantly.

These additional restrictions stem from the fact that the accelerated series is drawn on a separate widget on top of the chart:

- If you draw any graphics items on top of a chart containing an accelerated series, the accelerated series is drawn over those items.
- To enable QOpenGLWidget to be partially transparent, it needs to be stacked on top of all other widgets. This means you cannot have other widgets partially covering the chart when using accelerated series.
- Accelerated series are not supported for use cases where the graphics scene has more than one graphics view attached to it.
- Accelerated series are not supported for use cases where the chart doesn't fill the entire graphics view or has non-default geometry. For example, scrolling the view with scroll bars or adding transformations to the graphics view cause the accelerated series to be drawn in incorrect position related to the chart.

The default value is `false`.

Access functions:

bool | useOpenGL() const
void | setUseOpenGL(bool enable = true)

Notifier signal:

void | useOpenGLChanged()

### visible : bool

This property holds whether the series is visible or not; true by default.

Access functions:

bool | isVisible() const
void | setVisible(bool visible = true)

Notifier signal:

void | visibleChanged()

## Member Function Documentation

### QAbstractSeries::~QAbstractSeries()

Virtual destructor for the chart series.

### bool QAbstractSeries::attachAxis(QAbstractAxis *axis)

Attach axis to the series. Returns true if the axis was attached successfully, false otherwise.

Note: If multiple axes of same orientation are attached to same series, they will have same min/max ranges.

See also QChart::addAxis() and QChart::createDefaultAxes().

### QList<QAbstractAxis *> QAbstractSeries::attachedAxes()

Returns the list of axes attached to the series. Usually there is an x-axis and a y-axis attached to a series, except in case of a QPieSeries, which does not have any axes attached.

See also attachAxis() and detachAxis().

### QChart *QAbstractSeries::chart() const

Returns the chart where series belongs to.

Set automatically when the series is added to the chart and unset when the series is removed from the chart.

### bool QAbstractSeries::detachAxis(QAbstractAxis *axis)

Detach axis from the series. Returns true if the axis was detached successfully, false otherwise.

See also QChart::removeAxis().

### void QAbstractSeries::hide()

Sets the visibility of the series to false.

See also setVisible() and isVisible().

### `[signal]` void QAbstractSeries::nameChanged()

This signal is emitted when the series name changes.

Note: Notifier signal for property name.

### `[signal]` void QAbstractSeries::opacityChanged()

Emitted when the opacity of the series changes.

Note: Notifier signal for property opacity.

### void QAbstractSeries::show()

Sets the visibility of the series to true.

See also setVisible() and isVisible().

### `[signal]` void QAbstractSeries::useOpenGLChanged()

Emitted when the useOpenGL property value changes.

Note: Notifier signal for property useOpenGL.

### `[signal]` void QAbstractSeries::visibleChanged()

Emitted when the series visibility changes.

Note: Notifier signal for property visible.