Skip to content

CategoryAxis

Qt Base Class: QCategoryAxis

Signature: QCategoryAxis(self, parent: Optional[PySide6.QtCore.QObject] = None) -> None

Base classes

Name Children Inherits
ValueAxisMixin
prettyqt.charts.valueaxis
QCategoryAxis
PySide6.QtCharts
QCategoryAxis(self, parent: Optional[PySide6.QtCore.QObject] \= None) -> None

⋔ Inheritance diagram

graph TD
  1473367678096["charts.CategoryAxis"]
  1473367659552["charts.ValueAxisMixin"]
  1473367646864["charts.AbstractAxisMixin"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473367636128["QtCharts.QCategoryAxis"]
  1473367648816["QtCharts.QValueAxis"]
  1473367634176["QtCharts.QAbstractAxis"]
  1473288842240["QtCore.QObject"]
  1473291690208["Shiboken.Object"]
  1473367659552 --> 1473367678096
  1473367646864 --> 1473367659552
  1473299815024 --> 1473367646864
  140713234304496 --> 1473299815024
  1473367636128 --> 1473367678096
  1473367648816 --> 1473367636128
  1473367634176 --> 1473367648816
  1473288842240 --> 1473367634176
  1473291690208 --> 1473288842240
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: ValueAxisMixin, QCategoryAxis

Source code in prettyqt\charts\categoryaxis.py
class CategoryAxis(charts.ValueAxisMixin, charts.QCategoryAxis):
    def __delitem__(self, index: str):
        """Remove category label."""
        self.remove(index)

    def __getitem__(self, label: int | slice) -> str | list[str]:
        """Get category label from given index."""
        return self.categoriesLabels()[label]

    def __setitem__(self, index: str, value: str):
        """Set label at given index to value."""
        self.replaceLabel(index, value)

    def __iter__(self) -> Iterator[str]:
        """Iterate through all category labels."""
        return iter(self.categoriesLabels())

    def __add__(self, other: tuple[str, int]) -> CategoryAxis:
        """Append another category."""
        self.append(*other)
        return self

    def __len__(self):
        """Return category label count from axis."""
        return self.count()

    def set_labels_position(
        self, position: LabelsPositionStr | charts.QCategoryAxis.AxisLabelsPosition
    ):
        """Set the labels position.

        Args:
            position: labels position
        """
        self.setLabelsPosition(LABELS_POSITIONS.get_enum_value(position))

    def get_labels_position(self) -> LabelsPositionStr:
        """Return current labels position.

        Returns:
            labels position
        """
        return LABELS_POSITIONS.inverse[self.labelsPosition()]

__add__(other: tuple[str, int]) -> CategoryAxis

Append another category.

Source code in prettyqt\charts\categoryaxis.py
def __add__(self, other: tuple[str, int]) -> CategoryAxis:
    """Append another category."""
    self.append(*other)
    return self

__delitem__(index: str)

Remove category label.

Source code in prettyqt\charts\categoryaxis.py
def __delitem__(self, index: str):
    """Remove category label."""
    self.remove(index)

__getitem__(label: int | slice) -> str | list[str]

Get category label from given index.

Source code in prettyqt\charts\categoryaxis.py
def __getitem__(self, label: int | slice) -> str | list[str]:
    """Get category label from given index."""
    return self.categoriesLabels()[label]

__iter__() -> Iterator[str]

Iterate through all category labels.

Source code in prettyqt\charts\categoryaxis.py
def __iter__(self) -> Iterator[str]:
    """Iterate through all category labels."""
    return iter(self.categoriesLabels())

__len__()

Return category label count from axis.

Source code in prettyqt\charts\categoryaxis.py
def __len__(self):
    """Return category label count from axis."""
    return self.count()

__setitem__(index: str, value: str)

Set label at given index to value.

Source code in prettyqt\charts\categoryaxis.py
def __setitem__(self, index: str, value: str):
    """Set label at given index to value."""
    self.replaceLabel(index, value)

get_labels_position() -> LabelsPositionStr

Return current labels position.

Source code in prettyqt\charts\categoryaxis.py
def get_labels_position(self) -> LabelsPositionStr:
    """Return current labels position.

    Returns:
        labels position
    """
    return LABELS_POSITIONS.inverse[self.labelsPosition()]

set_labels_position(position: LabelsPositionStr | charts.QCategoryAxis.AxisLabelsPosition)

Set the labels position.

Parameters:

Name Type Description Default
position LabelsPositionStr | AxisLabelsPosition

labels position

required
Source code in prettyqt\charts\categoryaxis.py
def set_labels_position(
    self, position: LabelsPositionStr | charts.QCategoryAxis.AxisLabelsPosition
):
    """Set the labels position.

    Args:
        position: labels position
    """
    self.setLabelsPosition(LABELS_POSITIONS.get_enum_value(position))

⌗ Property table

Qt Property Type Doc
objectName QString
visible bool
lineVisible bool
linePen QPen
color QColor
labelsVisible bool
labelsBrush QBrush
labelsAngle int
labelsFont QFont
labelsColor QColor
labelsTruncated bool
truncateLabels bool
gridVisible bool
gridLinePen QPen
minorGridVisible bool
minorGridLinePen QPen
gridLineColor QColor
minorGridLineColor QColor
shadesVisible bool
shadesColor QColor
shadesBorderColor QColor
shadesPen QPen
shadesBrush QBrush
titleText QString
titleBrush QBrush
titleVisible bool
titleFont QFont
orientation Qt::Orientation
alignment QFlags
reverse bool
tickCount int
min double
max double
labelFormat QString
minorTickCount int
tickAnchor double
tickInterval double
tickType QValueAxis::TickType
startValue double
count int
categoriesLabels QStringList
labelsPosition QCategoryAxis::AxisLabelsPosition