CategoryAxis QML Type

CategoryAxis places named ranges on the axis. More...

Import Statement: import QtCharts 2.14
Instantiates: QCategoryAxis
Inherits:

AbstractAxis

Properties

Methods

Detailed Description

This type can be used to explain the underlying data by adding labeled categories. The widths of the category ranges can be specified freely.

For example:

ChartView {
    title: "Numerical Data for Dummies"
    anchors.fill: parent
    legend.visible: false
    antialiasing: true

    LineSeries {
        axisY: CategoryAxis {
            min: 0
            max: 30
            CategoryRange {
                label: "critical"
                endValue: 2
            }
            CategoryRange {
                label: "low"
                endValue: 4
            }
            CategoryRange {
                label: "normal"
                endValue: 7
            }
            CategoryRange {
                label: "high"
                endValue: 15
            }
            CategoryRange {
                label: "extremely high"
                endValue: 30
            }
        }

        XYPoint { x: 0; y: 4.3 }
        XYPoint { x: 1; y: 4.1 }
        XYPoint { x: 2; y: 4.7 }
        XYPoint { x: 3; y: 3.9 }
        XYPoint { x: 4; y: 5.2 }
    }
}

Property Documentation

categoriesLabels : StringList

The category labels as a list of strings.

count : int

The number of categories.

labelsPosition : enumeration

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.

Constant Description
CategoryAxis.AxisLabelsPositionCenter Labels are centered to category.
CategoryAxis.AxisLabelsPositionOnValue Labels are positioned to the high end limit of the category.

startValue : int

The low end of the first category on the axis.

Method Documentation

append(label, real endValue)

Appends a new category to the axis with the label label. A category label has to be unique. endValue 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.

remove(label)

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

replace(oldLabel, string newLabel)

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

© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-5.14/qml-qtcharts-categoryaxis.html