QCategoryAxis#

The QCategoryAxis class places named ranges on the axis. More

Inheritance diagram of PySide6.QtCharts.QCategoryAxis

Synopsis#

Properties#

  • categoriesLabels - Category labels as a string list

  • count - Number of categories

  • labelsPosition - 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

  • startValue - Low end of the first category on the axis

Functions#

Signals#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

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 :

../../_images/api_category_axis.png
QChartView *chartView = new QChartView;
QLineSeries *series = new QLineSeries;
// ...
chartView->chart()->addSeries(series);

QCategoryAxis *axisY = new QCategoryAxis;
axisY->setMin(0);
axisY->setMax(52);
axisY->setStartValue(15);
axisY->append("First", 20);
axisY->append("Second", 37);
axisY->append("Third", 52);
chartView->chart()->setAxisY(axisY, series);
class PySide6.QtCharts.QCategoryAxis([parent=None])#
Parameters:

parentPySide6.QtCore.QObject

Constructs an axis object that is a child of parent.

Note

Properties can be used directly when from __feature__ import true_property is used or via accessor functions otherwise.

property PᅟySide6.QtCharts.QCategoryAxis.categoriesLabels: list of strings#

This property holds The category labels as a string list..

Access functions:
property PᅟySide6.QtCharts.QCategoryAxis.count: int#

This property holds The number of categories..

Access functions:
property PᅟySide6.QtCharts.QCategoryAxis.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:
property PᅟySide6.QtCharts.QCategoryAxis.startValue: float#

This property holds The low end of the first category on the axis..

Access functions:
PySide6.QtCharts.QCategoryAxis.AxisLabelsPosition#

This enum describes the position of the category labels.

Constant

Description

QCategoryAxis.AxisLabelsPositionCenter

Labels are centered to category.

QCategoryAxis.AxisLabelsPositionOnValue

Labels are positioned to the high end limit of the category.

PySide6.QtCharts.QCategoryAxis.append(label, categoryEndValue)#
Parameters:
  • label – str

  • categoryEndValue – float

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.

PySide6.QtCharts.QCategoryAxis.categoriesChanged()#

This signal is emitted when the categories of the axis change.

PySide6.QtCharts.QCategoryAxis.categoriesLabels()#
Return type:

list of strings

Returns the list of the categories’ labels.

Getter of property categoriesLabels .

PySide6.QtCharts.QCategoryAxis.count()#
Return type:

int

Returns the number of categories.

Getter of property count .

PySide6.QtCharts.QCategoryAxis.endValue(categoryLabel)#
Parameters:

categoryLabel – str

Return type:

float

Returns the high end limit of the category specified by categoryLabel.

PySide6.QtCharts.QCategoryAxis.labelsPosition()#
Return type:

AxisLabelsPosition

Getter of property labelsPosition .

PySide6.QtCharts.QCategoryAxis.labelsPositionChanged(position)#
Parameters:

positionAxisLabelsPosition

Notification signal of property labelsPosition .

PySide6.QtCharts.QCategoryAxis.remove(label)#
Parameters:

label – str

Removes a category specified by the label categoryLabel from the axis.

PySide6.QtCharts.QCategoryAxis.replaceLabel(oldLabel, newLabel)#
Parameters:
  • oldLabel – str

  • newLabel – str

Replaces an existing category label specified by oldLabel with newLabel. If the old label does not exist, the method returns without making any changes.

PySide6.QtCharts.QCategoryAxis.setLabelsPosition(position)#
Parameters:

positionAxisLabelsPosition

See also

labelsPosition()

Setter of property labelsPosition .

PySide6.QtCharts.QCategoryAxis.setStartValue(min)#
Parameters:

min – float

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.

See also

startValue()

Setter of property startValue .

PySide6.QtCharts.QCategoryAxis.startValue([categoryLabel=""])#
Parameters:

categoryLabel – str

Return type:

float

Returns the low end limit of the category specified by categoryLabel.

See also

setStartValue()