QAbstractBarSeries Class▲
-
Header: QAbstractBarSeries
-
Inherited By: QBarSeries, QHorizontalBarSeries, QHorizontalPercentBarSeries, QHorizontalStackedBarSeries, QPercentBarSeries, and QStackedBarSeries
-
Instantiated By: qml-qtcharts-abstractbarseries.xml
-
Inherits: QAbstractSeries
-
Inherited By: QBarSeries, QHorizontalBarSeries, QHorizontalPercentBarSeries, QHorizontalStackedBarSeries, QPercentBarSeries, and QStackedBarSeries
Detailed Description▲
In bar charts, bars are defined as bar sets that contain one data value for each category. The position of a bar is specified by the category and its height by the data value. Bar series that contain multiple bar sets group together bars that belong to the same category. The way the bars are displayed is determined by the subclass of this class chosen to create the bar chart.
If a QValueAxis is used instead of QBarCategoryAxis for the main bar axis, the bars are grouped around the index value of the category.
See the bar chart example to learn how to use the QBarSeries class to create a simple bar chart.
See Also▲
Member Type Documentation▲
enum QAbstractBarSeries::LabelsPosition▲
This enum value describes the position of the data value labels:
Constant |
Value |
Description |
---|---|---|
QAbstractBarSeries::LabelsCenter |
0 |
Label is located in the center of the bar. |
QAbstractBarSeries::LabelsInsideEnd |
1 |
Label is located inside the bar at the top. |
QAbstractBarSeries::LabelsInsideBase |
2 |
Label is located inside the bar at the bottom. |
QAbstractBarSeries::LabelsOutsideEnd |
3 |
Label is located outside the bar at the top. |
Property Documentation▲
barWidth : qreal▲
This property holds the width of the bars of the series.
The unit of width is the unit of the x-axis. The minimum width for bars is zero, and negative values are treated as zero. Setting the width to zero means that the width of the bar on the screen is one pixel regardless of the scale of the x-axis. Bars wider than zero are scaled using the x-axis scale.
When used with QBarSeries, this value specifies the width of a group of bars instead of that of a single bar.
Access functions:
-
qreal barWidth() const
-
void setBarWidth(qreal width)
See Also▲
See also QBarSeries
[read-only] count : const int▲
This property holds the number of bar sets in a bar series.
Access functions:
-
int count() const
Notifier signal:
-
void countChanged()
labelsAngle : qreal▲
This property holds the angle of the value labels in degrees.
Access functions:
-
qreal labelsAngle() const
-
void setLabelsAngle(qreal angle)
Notifier signal:
-
void labelsAngleChanged(qreal angle)
labelsFormat : QString▲
This property holds the format used for showing labels in a bar series.
QAbstractBarSeries supports the following format tag:
@value |
The value of the bar |
For example, the following usage of the format tags would produce labels that show the value followed by the unit (u):
series-&
gt;setLabelsFormat("@value u"
);
By default, the labels show the value of the bar. For the percent bar series, % is added after the value. The labels are shown on the plot area, if the bars are close to each other, the labels may overlap.
Access functions:
-
labelsFormat() const
-
void setLabelsFormat(const &format)
Notifier signal:
-
void labelsFormatChanged(const &format)
See Also▲
See also labelsVisible, labelsPosition, labelsPrecision
labelsPosition : LabelsPosition▲
This property holds the position of value labels.
Access functions:
-
labelsPosition() const
-
void setLabelsPosition( position)
Notifier signal:
-
void labelsPositionChanged( position)
See Also▲
See also labelsVisible, labelsFormat
labelsPrecision : int▲
This property holds the maximum amount of significant digits shown in value labels.
Default value is 6.
Access functions:
-
int labelsPrecision() const
-
void setLabelsPrecision(int precision)
Notifier signal:
-
void labelsPrecisionChanged(int precision)
labelsVisible : bool▲
This property holds the visibility of the labels in a bar series.
Access functions:
-
bool isLabelsVisible() const
-
void setLabelsVisible(bool visible = true)
Notifier signal:
-
void labelsVisibleChanged()
Member Function Documentation▲
[virtual] QAbstractBarSeries::~QAbstractBarSeries()▲
Removes the abstract bar series and the bar sets owned by it.
bool QAbstractBarSeries::append(QBarSet *set)▲
Adds a set of bars specified by set to the bar series and takes ownership of it. If the set is null or it already belongs to the series, it will not be appended. Returns true if appending succeeded.
bool QAbstractBarSeries::append(const QList<QBarSet *> &sets)▲
Adds a list of bar sets specified by sets to a bar series and takes ownership of the sets. Returns true if all sets were appended successfully. If any of the sets is null or was previously appended to the series, nothing is appended and this function returns false. If any of the sets appears in the list more than once, nothing is appended and this function returns false.
QList<QBarSet *> QAbstractBarSeries::barSets() const▲
Returns a list of bar sets in a bar series. Keeps the ownership of the bar sets.
qreal QAbstractBarSeries::barWidth() const▲
Returns the width of the bars of the series.
Getter function for property barWidth.
See Also▲
See also setBarWidth()
void QAbstractBarSeries::barsetsAdded(const QList<QBarSet *> &sets)▲
This signal is emitted when the bar sets specified by sets are added to the series.
See Also▲
void QAbstractBarSeries::barsetsRemoved(const QList<QBarSet *> &sets)▲
This signal is emitted when the bar sets specified by sets are removed from the series.
See Also▲
See also remove()
void QAbstractBarSeries::clear()▲
Removes all bar sets from the series and permanently deletes them.
void QAbstractBarSeries::clicked(int index, QBarSet *barset)▲
This signal is emitted when the user clicks the bar specified by index in the bar set specified by barset.
int QAbstractBarSeries::count() const▲
Returns the number of bar sets in a bar series.
Getter function for property count.
void QAbstractBarSeries::countChanged()▲
This signal is emitted when the number of bar sets is changed, for example by append() or remove().
Notifier signal for property count.
void QAbstractBarSeries::doubleClicked(int index, QBarSet *barset)▲
This signal is emitted when the user double-clicks the bar specified by index in the bar set specified by barset.
void QAbstractBarSeries::hovered(bool status, int index, QBarSet *barset)▲
This signal is emitted when a mouse is hovered over the bar specified by index in the bar set specified by barset. When the mouse moves over the bar, status turns true, and when the mouse moves away again, it turns false.
bool QAbstractBarSeries::insert(int index, QBarSet *set)▲
Inserts a bar set specified by set to a series at the position specified by index and takes ownership of the set. If the set is null or already belongs to the series, it will not be appended. Returns true if inserting succeeds.
bool QAbstractBarSeries::isLabelsVisible() const▲
Returns the visibility of labels.
Getter function for property labelsVisible.
void QAbstractBarSeries::labelsAngleChanged(qreal angle)▲
This signal is emitted when the angle of the value labels changes.
Notifier signal for property labelsAngle.
void QAbstractBarSeries::labelsFormatChanged(const QString &format)▲
This signal is emitted when the format of data value labels changes.
Notifier signal for property labelsFormat.
void QAbstractBarSeries::labelsPositionChanged(QAbstractBarSeries::LabelsPosition position)▲
This signal is emitted when the position of value labels changes.
Notifier signal for property labelsPosition.
void QAbstractBarSeries::labelsPrecisionChanged(int precision)▲
This signal is emitted when the precision of the value labels changes.
Notifier signal for property labelsPrecision.
void QAbstractBarSeries::labelsVisibleChanged()▲
This signal is emitted when the labels' visibility changes.
Notifier signal for property labelsVisible.
See Also▲
See also isLabelsVisible(), setLabelsVisible()
void QAbstractBarSeries::pressed(int index, QBarSet *barset)▲
This signal is emitted when the user clicks the bar specified by index in the bar set specified by barset and holds down the mouse button.
void QAbstractBarSeries::released(int index, QBarSet *barset)▲
This signal is emitted when the user releases the mouse press on the bar specified by index in the bar set specified by barset.
bool QAbstractBarSeries::remove(QBarSet *set)▲
Removes the bar set specified by set from the series and permanently deletes it if the removal succeeds. Returns true if the set was removed.
void QAbstractBarSeries::setBarWidth(qreal width)▲
Sets the width of the bars of the series to width.
Setter function for property barWidth.
See Also▲
See also barWidth()
void QAbstractBarSeries::setLabelsVisible(bool visible = true)▲
Sets the visibility of labels in a bar series to visible.
Setter function for property labelsVisible.
See Also▲
See also isLabelsVisible()
bool QAbstractBarSeries::take(QBarSet *set)▲
Takes a single set from the series. Does not delete the bar set object.
The series remains the barset's parent object. You must set the parent object to take full ownership.
Returns true if the take operation succeeds.