BarCategoryAxis QML Type

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

Import Statement: import QtGraphs
In C++: QBarCategoryAxis
Inherits:

AbstractAxis

Properties

Signals

Methods

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.


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

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.


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.


clear()

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


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.


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.


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.


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.


© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.