本页内容

HorizontalPercentBarSeries QML Type

将一系列分类数据以各类别所占百分比的形式呈现。更多...

Import Statement: import QtCharts 2.12
In C++: QHorizontalPercentBarSeries
Inherits:

AbstractBarSeries

Status: Deprecated

此类型已弃用。我们强烈建议不要在新代码中使用它。

详细说明

数据以一系列大小均匀的水平堆叠条形图形式绘制,每个类别对应一个条形。添加到该系列中的每个条形集都会为每个堆叠条形图贡献一个分段。分段的大小对应于该分段值占堆叠中所有分段总值的百分比。值为零的条形不会被绘制。

以下 QML 代码片段演示了如何创建一个简单的水平百分比条形图:

ChartView {
    title: "Horizontal Percent Bar Chart"
    anchors.fill: parent
    legend.alignment: Qt.AlignBottom
    antialiasing: true

    HorizontalPercentBarSeries {
        axisY: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
        BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] }
        BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] }
        BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] }
    }
}

水平百分比条形图,其中 Bob、Susan 和 James 每年的条形均填满 100%


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