QCategoryAxis Class▲
-
Header: QCategoryAxis
-
Inherited By:
-
Instantiated By: qml-qtcharts-categoryaxis.xml
-
Inherits: QValueAxis
-
Inherited By:
Detailed Description▲
This class can be used to explain the underlying data by adding labeled categories. Unlike QBarCategoryAxis, QCategoryAxis allows the widths of the category ranges to be specified freely.
Example code on how to use QCategoryAxis:
QChartView *
chartView =
new
QChartView;
QLineSeries *
series =
new
QLineSeries;
// ...
chartView-&
gt;chart()-&
gt;addSeries(series);
QCategoryAxis *
axisY =
new
QCategoryAxis;
axisY-&
gt;setMin(0
);
axisY-&
gt;setMax(52
);
axisY-&
gt;setStartValue(15
);
axisY-&
gt;append("First"
, 20
);
axisY-&
gt;append("Second"
, 37
);
axisY-&
gt;append("Third"
, 52
);
chartView-&
gt;chart()-&
gt;setAxisY(axisY, series);
Member Type Documentation▲
enum QCategoryAxis::AxisLabelsPosition▲
This enum describes the position of the category labels.
Constant |
Value |
Description |
---|---|---|
QCategoryAxis::AxisLabelsPositionCenter |
0x0 |
Labels are centered to category. |
QCategoryAxis::AxisLabelsPositionOnValue |
0x1 |
Labels are positioned to the high end limit of the category. |
Property Documentation▲
[read-only] categoriesLabels : const QStringList▲
[read-only] count : const int▲
labelsPosition : AxisLabelsPosition▲
This property holds the position of the category labels. The labels in the beginning and in the end of the axes may overlap other axes' labels when positioned on value.
Access functions:
-
labelsPosition() const
-
void setLabelsPosition( position)
Notifier signal:
-
void labelsPositionChanged( position)
startValue : qreal▲
This property holds the low end of the first category on the axis.
Access functions:
-
qreal startValue(const &categoryLabel = QString()) const
-
void setStartValue(qreal min)
Member Function Documentation▲
[explicit] QCategoryAxis::QCategoryAxis(QObject *parent = nullptr)▲
Constructs an axis object that is a child of parent.
[virtual] QCategoryAxis::~QCategoryAxis()▲
Destroys the object.
void QCategoryAxis::append(const QString &categoryLabel, qreal categoryEndValue)▲
Appends a new category to the axis with the label categoryLabel. A category label has to be unique. categoryEndValue specifies the high end limit of the category. It has to be greater than the high end limit of the previous category. Otherwise the method returns without adding a new category.
void QCategoryAxis::categoriesChanged()▲
This signal is emitted when the categories of the axis change.
QStringList QCategoryAxis::categoriesLabels()▲
Returns the list of the categories' labels.
Getter function for property categoriesLabels.
int QCategoryAxis::count() const▲
Returns the number of categories.
Getter function for property count.
qreal QCategoryAxis::endValue(const QString &categoryLabel) const▲
Returns the high end limit of the category specified by categoryLabel.
void QCategoryAxis::remove(const QString &categoryLabel)▲
Removes a category specified by the label categoryLabel from the axis.
void QCategoryAxis::replaceLabel(const QString &oldLabel, const QString &newLabel)▲
Replaces an existing category label specified by oldLabel with newLabel. If the old label does not exist, the method returns without making any changes.
void QCategoryAxis::setStartValue(qreal min)▲
Sets min to be the low end limit of the first category on the axis. If categories have already been added to the axis, the passed value must be less than the high end value of the already defined first category range. Otherwise nothing is done.
Setter function for property startValue.
See Also▲
See also startValue()
qreal QCategoryAxis::startValue(const QString &categoryLabel = QString()) const▲
Returns the low end limit of the category specified by categoryLabel.
Getter function for property startValue.
See Also▲
See also setStartValue()
[override virtual] QAbstractAxis::AxisType QCategoryAxis::type() const▲
Reimplements: QValueAxis::type() const.
Returns the type of the axis.