BarCategoryAxis QML Type | Qt Graphs | Qt 6.11.1
Description: Adds categories to a graph's axes.

- Qt 6.11
- Qt Graphs
- QML Types
- QtGraphs
- BarCategoryAxis
- Qt Graphs | Commercial or GPLv3

# BarCategoryAxis QML Type

Adds categories to a graph's axes. More...

Import Statement: | `import QtGraphs`
In C++: | QBarCategoryAxis
Inherits: | AbstractAxis

- List of all members, including inherited members
- BarCategoryAxis is part of Qt Graphs QML Types for 2D.

## Properties

- categories : list
- count : int
- labelPosition : enumeration `(since 6.11)`
- max : string
- min : string

## Signals

- categoriesChanged()
- categoryRangeChanged(string min, string max)
- countChanged()
- maxChanged(string max)
- minChanged(string min)

## Methods

- void append(list categories)
- void append(string category)
- string at(int index)
- void clear()
- void insert(int index, string category)
- void remove(int index)
- void remove(string category)
- void replace(string oldCategory, string newCategory)

## Detailed Description

The BarCategoryAxis type can be set up to show an axis line with tick marks, grid lines, and shades. Categories are drawn between the ticks.

The following QML snippet illustrates how to use BarCategoryAxis:

     GraphsView {
         anchors.fill: parent
         axisX: BarCategoryAxis {
             categories: ["2023", "2024", "2025"]
             lineVisible: false
         }
         axisY: ValueAxis { }
         BarSeries {
             BarSet {
                 values: [7, 6, 9]
             }
         }
     }

## Property Documentation

### categories : list

The categories of an axis.

### count : int `[read-only]`

The number of categories of an axis.

### labelPosition : enumeration `[since 6.11]`

Constant | Description
--- | ---
`BarCategoryAxis.Center` | Labels are centered to category.
`BarCategoryAxis.OnValue` | Labels are positioned to the high end limit of the category.

This property was introduced in Qt 6.11.

### max : string

The maximum value on the axis. The given value should be contained in `categories`.

### min : string

The minimum value on the axis. The given value should be contained in `categories`.

## Signal Documentation

### categoriesChanged()

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

Note: The corresponding handler is `onCategoriesChanged`.

### categoryRangeChanged(string min, string max)

This signal is emitted when the range of categories of the axis changes. min and max are the min and max of the new range.

Note: The corresponding handler is `onCategoryRangeChanged`.

### countChanged()

This signal is emitted when the number of categories of an axis changes.

Note: The corresponding handler is `onCountChanged`.

### maxChanged(string max)

This signal is emitted when the axis maximum value changes to max.

Note: The corresponding handler is `onMaxChanged`.

### minChanged(string min)

This signal is emitted when the axis minimum value changes to min.

Note: The corresponding handler is `onMinChanged`.

## Method Documentation

### void append(list categories)

Appends categories to an axis. The maximum value on the axis will be changed to match the last category in categories. If no categories were previously defined, the minimum value on the axis will also be changed to match the first category in categories.

A category has to be a valid QString and it cannot be duplicated. Duplicated categories will not be appended.

### void append(string category)

Appends category to an axis. The maximum value on the axis will be changed to match the last category. If no categories were previously defined, the minimum value on the axis will also be changed to match category.

A category has to be a valid QString and it cannot be duplicated. Duplicated categories will not be appended.

### string at(int index)

Returns the category at index.

### void clear()

Removes all categories. Sets the maximum and minimum values of the axis range to QString::null.

### void insert(int index, string category)

Inserts category to the axis at index. category has to be a valid QString and it cannot be duplicated. If category is prepended or appended to other categories, the minimum and maximum values on the axis are updated accordingly.

### void remove(int index)

Removes a category at index from the axis. Removing a category that currently sets the maximum or minimum value on the axis will affect the axis range.

### void remove(string category)

Removes category from the axis. Removing a category that currently sets the maximum or minimum value on the axis will affect the axis range.

### void replace(string oldCategory, string newCategory)

Replaces oldCategory with newCategory. If oldCategory does not exist on the axis, nothing is done. newCategory has to be a valid QString and it cannot be duplicated. If the minimum or maximum category is replaced, the minimum and maximum values on the axis are updated accordingly.