Skip to content

CategoryAxis

Base classes

Name Children Inherits
ValueAxisMixin
prettyqt.charts.valueaxis
QCategoryAxis
PySide6.QtCharts
QCategoryAxis(self, /, parent: PySide6.QtCore.QObject | None \= None, *, startValue: float | None \= None, count: int | None \= None, categoriesLabels: collections.abc.Sequence[str] | None \= None, labelsPosition: PySide6.QtCharts.QCategoryAxis.AxisLabelsPosition | None \= None) -> None

⋔ Inheritance diagram

graph TD
  2145403523["charts.CategoryAxis"]
  3516352003["charts.ValueAxisMixin"]
  1234850145["charts.AbstractAxisMixin"]
  3227531497["core.ObjectMixin"]
  2751680898["builtins.object"]
  1095004961["QtCharts.QCategoryAxis"]
  3302172864["QtCharts.QValueAxis"]
  964990825["QtCharts.QAbstractAxis"]
  3984060476["QtCore.QObject"]
  37984305["Shiboken.Object"]
  3516352003 --> 2145403523
  1234850145 --> 3516352003
  3227531497 --> 1234850145
  2751680898 --> 3227531497
  2751680898 --> 1234850145
  2751680898 --> 3516352003
  1095004961 --> 2145403523
  3302172864 --> 1095004961
  964990825 --> 3302172864
  3984060476 --> 964990825
  37984305 --> 3984060476
  2751680898 --> 37984305

🛈 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))

:fa-brands-github: Show source on GitHub