CategoryAxis QML Type | Qt Charts 5.7

Qt 5.7 | Qt Charts | QML Types | CategoryAxis QML Type

Qt 5.7.0 Reference Documentation

# CategoryAxis QML Type

CategoryAxis allows putting a named ranges on the axis. More...

Import Statement: | import QtCharts 2.1
Instantiates: | QCategoryAxis
Inherits: | AbstractAxis

- List of all members, including inherited members

## Properties

- categoriesLabels : StringList
- count : int
- labelsPosition : AxisLabelsPosition
- startValue : int

## Methods

- append(string label, real endValue)
- remove(string label)
- replace(string oldLabel, string newLabel)

## Detailed Description

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 count of categories.

labelsPosition : AxisLabelsPosition

Defines 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.

startValue : int

Defines the low end of the first category on the axis.

## Method Documentation

append(string label, real endValue)

Appends new category to the axis with an label. Category label has to be unique. Parameter 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(string label)

Removes a category specified by the label from the axis

replace(string oldLabel, string newLabel)

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