CategoryAxis QML Type

CategoryAxis 将命名的范围放置在坐标轴上。更多

Import Statement: import QtCharts 2.9
In C++: QCategoryAxis
Inherits:

AbstractAxis

属性

方法

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

详细描述

该类型可通过添加标注类别来解释基础数据。类别范围的宽度可以自由指定。

例如

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 }
    }
}

属性文档

categoriesLabels : StringList [read-only]

作为字符串列表的类别标签。


count : int [read-only]

类别数量。


labelsPosition : enumeration

类别标签的位置。在值上定位时,坐标轴开头和结尾的标签可能会与其他坐标轴的标签重叠。

常数说明
CategoryAxis.AxisLabelsPositionCenter标签以类别为中心。
CategoryAxis.AxisLabelsPositionOnValue标签定位到类别的上限。

startValue : int

坐标轴上第一个类别的低端。


方法文档

append(string label, real endValue)

在轴上添加一个新类别,标签为label 。类别标签必须是唯一的。endValue 指定类别的上限。它必须大于前一个类别的上限。否则,该方法将返回,但不会添加新的类别。


remove(string label)

从坐标轴中删除标签label 指定的类别。


replace(string oldLabel, string newLabel)

newLabel 替换oldLabel 指定的现有类别标签。如果旧标签不存在,则方法返回,不做任何更改。


© 2025 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.