QAreaSeries Class
The QAreaSeries class fills the area between two lines, or below one. More…
| Header | #include <QAreaSeries> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Charts) |
| Module | Nt Charts C++ Classes |
| Inherits | QAbstractSeries |
List of all members, including inherited members
Public Functions
| QAreaSeries(QObject *parent = nullptr) | |
| QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = nullptr) | |
| ~QAreaSeries() | |
| void | setUpperSeries(QLineSeries *series) |
| QLineSeries * | upperSeries() const |
| void | setLowerSeries(QLineSeries *series) |
| QLineSeries * | lowerSeries() const |
| void | setPen(const QPen &pen) |
| QPen | pen() const |
| void | setBrush(const QBrush &brush) |
| QBrush | brush() const |
| void | setColor(const QColor &color) |
| QColor | color() const |
| void | setBorderColor(const QColor &color) |
| QColor | borderColor() const |
| void | setPointsVisible(bool visible = true) |
| bool | pointsVisible() const |
| void | setPointLabelsFormat(const QString &format) |
| QString | pointLabelsFormat() const |
| void | setPointLabelsVisible(bool visible = true) |
| bool | pointLabelsVisible() const |
Reimplemented Public Functions
| QAbstractSeries::SeriesType | type() const |
Signals
| void | clicked(const QPointF &point) |
| void | hovered(const QPointF &point, bool state) |
| void | pressed(const QPointF &point) |
| void | released(const QPointF &point) |
| void | doubleClicked(const QPointF &point) |
| void | colorChanged(QColor color) |
| void | borderColorChanged(QColor color) |
| void | pointLabelsFormatChanged(const QString &format) |
| void | pointLabelsVisibilityChanged(bool visible) |
Detailed Description

The area is bounded by the points of an upper QLineSeries and of a lower one. Without a lower series it reaches down to zero, or to the edge of the plot area if zero is not shown.
auto *upper = new QLineSeries;
for (int t = 0; t < 24; ++t)
upper->append(t, 2.0 + std::sin(t / 4.0));
auto *series = new QAreaSeries(upper);
series->setName("Memory");
auto *chart = new QChart;
chart->addSeries(series);
chart->createDefaultAxes();
The line series are not added to the chart themselves. The area series watches them: changing their points redraws it. A line series without a parent becomes a child of the area series.
See also QLineSeries.
Differences from Qt
There is no best-fit line, and the point labels are drawn for the upper series only.
Member Function Documentation
QAreaSeries::QAreaSeries(QObject *parent = nullptr)
Constructs an area series without line series, with the given parent.
QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = nullptr)
Constructs an area series between upperSeries and lowerSeries, which may be nullptr.
QAreaSeries::~QAreaSeries()
Destroys the series.
QColor QAreaSeries::borderColor() const
Returns the color of the border.
void QAreaSeries::borderColorChanged(QColor color)
This signal is emitted when the border color changes to color.
QBrush QAreaSeries::brush() const
Returns the brush that fills the area.
void QAreaSeries::clicked(const QPointF &point)
This signal is emitted when the user clicks the area at point, in the coordinates of the series.
QColor QAreaSeries::color() const
Returns the fill color.
void QAreaSeries::colorChanged(QColor color)
This signal is emitted when the fill color changes to color.
void QAreaSeries::doubleClicked(const QPointF &point)
This signal is emitted when the user double-clicks the area at point.
void QAreaSeries::hovered(const QPointF &point, bool state)
This signal is emitted when the mouse enters or leaves the area at point; state is true when it enters.
QLineSeries * QAreaSeries::lowerSeries() const
Returns the series that bounds the area from below, or nullptr.
QPen QAreaSeries::pen() const
Returns the pen of the border of the area.
QString QAreaSeries::pointLabelsFormat() const
Returns the format of the point labels.
void QAreaSeries::pointLabelsFormatChanged(const QString &format)
This signal is emitted when the format of the point labels changes to format.
void QAreaSeries::pointLabelsVisibilityChanged(bool visible)
This signal is emitted when the point labels are shown or hidden; visible is the new state.
bool QAreaSeries::pointLabelsVisible() const
Returns true if the point labels are drawn; otherwise returns false.
bool QAreaSeries::pointsVisible() const
Returns true if markers are drawn at the points; otherwise returns false.
void QAreaSeries::pressed(const QPointF &point)
This signal is emitted when the user presses a mouse button on the area at point.
void QAreaSeries::released(const QPointF &point)
This signal is emitted when the user releases a mouse button on the area at point.
void QAreaSeries::setBorderColor(const QColor &color)
Sets the color of the border to color.
void QAreaSeries::setBrush(const QBrush &brush)
Sets the brush that fills the area to brush.
void QAreaSeries::setColor(const QColor &color)
Sets the fill color to color.
void QAreaSeries::setLowerSeries(QLineSeries *series)
Sets the series that bounds the area from below to series, or to nullptr for zero.
void QAreaSeries::setPen(const QPen &pen)
Sets the pen of the border of the area to pen.
void QAreaSeries::setPointLabelsFormat(const QString &format)
Sets the format of the point labels to format, as QXYSeries::setPointLabelsFormat() does.
void QAreaSeries::setPointLabelsVisible(bool visible = true)
Draws a label above each point of the upper series if visible is true.
void QAreaSeries::setPointsVisible(bool visible = true)
Draws a marker at each point of the bounding series if visible is true.
void QAreaSeries::setUpperSeries(QLineSeries *series)
Sets the series that bounds the area from above to series.
QAbstractSeries::SeriesType QAreaSeries::type() const
Reimplements QAbstractSeries::type().
Returns QAbstractSeries::SeriesTypeArea.
QLineSeries * QAreaSeries::upperSeries() const
Returns the series that bounds the area from above.