Bars3DNode QML Type
三维条形图节点。更多
Import Statement: | import QtGraphs |
Inherits: |
- 所有成员(包括继承成员)的列表
- Bars3DNode 是Qt Graphs QML Types for 3D 的一部分。
属性
- aspectRatio : real
- barSeriesMargin : size
- barSpacing : size
- barSpacingRelative : bool
- barThickness : real
- columnAxis : Category3DAxis
- customItemList : list<Custom3DItem>
- floorLevel : real
- gridLineType : Graphs3D.GridLineType
- horizontalAspectRatio : real
- labelMargin : real
- locale : locale
- margin : real
- multiSeriesUniform : bool
- optimizationHint : Graphs3D.OptimizationHint
- polar : bool
- primarySeries : Bar3DSeries
- queriedGraphPosition : vector3d
- radialLabelOffset : real
- rowAxis : Category3DAxis
- selectedElement : Graphs3D.ElementType
- selectedSeries : Bar3DSeries
- selectionMode : Graphs3D.SelectionMode
- seriesList : list<Bar3DSeries>
- theme : GraphsTheme
- valueAxis : ValueAxis3D
信号
- barSeriesMarginChanged(size margin)
- barSpacingChanged(size spacing)
- barSpacingRelativeChanged(bool relative)
- barThicknessChanged(real thicknessRatio)
- columnAxisChanged(Category3DAxis axis)
- floorLevelChanged(real level)
- multiSeriesUniformChanged(bool uniform)
- primarySeriesChanged(Bar3DSeries series)
- rowAxisChanged(Category3DAxis axis)
- selectedSeriesChanged(Bar3DSeries series)
- valueAxisChanged(ValueAxis3D axis)
方法
- qsizetype addCustomItem(Custom3DItem item)
- void addSeries(Bar3DSeries series)
- void clearSelection()
- void doPicking(QPoint point)
- void doRayPicking(QVector3D origin, QVector3D direction)
- bool hasSeries(Abstract3DSeries series)
- void insertSeries(int index, Bar3DSeries series)
- void releaseCustomItem(Custom3DItem item)
- void removeCustomItem(Custom3DItem item)
- void removeCustomItemAt(vector3d position)
- void removeCustomItems()
- void removeSeries(Bar3DSeries series)
- Abstract3DAxis selectedAxis()
- Custom3DItem selectedCustomItem()
- qsizetype selectedCustomItemIndex()
- int selectedLabelIndex()
详细说明
开发人员可以使用该类型通过Qt Quick 渲染三维条形图节点。
您需要导入Qt Graphs 模块才能使用该类型:
import QtGraphs
之后,您就可以在 qml 文件中使用 Bars3DNode:
import QtQuick import QtGraphs View3D { width: 640 height: 480 Bars3DNode { width: parent.width height: parent.height Bar3DSeries { itemLabelFormat: "@colLabel, @rowLabel: @valueLabel" ItemModelBarDataProxy { itemModel: dataModel // Mapping model roles to bar series rows, columns, and values. rowRole: "year" columnRole: "city" valueRole: "expenses" } } } ListModel { id: dataModel ListElement{ year: "2022"; city: "Oulu"; expenses: "4200"; } ListElement{ year: "2022"; city: "Rauma"; expenses: "2100"; } ListElement{ year: "2022"; city: "Helsinki"; expenses: "7040"; } ListElement{ year: "2022"; city: "Tampere"; expenses: "4330"; } ListElement{ year: "2023"; city: "Oulu"; expenses: "3960"; } ListElement{ year: "2023"; city: "Rauma"; expenses: "1990"; } ListElement{ year: "2023"; city: "Helsinki"; expenses: "7230"; } ListElement{ year: "2023"; city: "Tampere"; expenses: "4650"; } } }
另请参阅 Bar3DSeries,ItemModelBarDataProxy,Scatter3DNode,Surface3DNode, 和Qt Graphs C++ 3D 类。
属性文档
aspectRatio : real |
barSeriesMargin : size |
X 和 Z 维度系列列之间的边距。默认设置为(0.0, 0.0)
。合理值范围为 [0,1)。
barSpacing : size |
X 和 Z 尺寸的条间距。
默认设置为(1.0, 1.0)
。间距受barSpacingRelative 属性影响。
barSpacingRelative : bool |
间距是绝对间距还是相对于条形图厚度的间距。
如果true
,0.0
的值表示条形图横向排列,1.0
表示在条形图之间留出与一个条形图厚度等宽的空间,依此类推。预设为true
。
barThickness : real |
X 和 Z 尺寸之间的条形厚度比。1.0
表示条形图的宽度与深度相同,而0.5
则表示条形图的深度是宽度的两倍。
columnAxis : Category3DAxis |
活动列轴。
如果没有给出坐标轴,则会创建一个没有标签的临时默认坐标轴。如果另一个轴被明确设置为相同的方向,这个临时轴将被销毁。
customItemList : list<Custom3DItem> |
添加到图表中的Custom3DItem 项目列表。图形拥有添加项的所有权。
floorLevel : real |
以 Y 轴数据坐标表示的条形图底层水平。
实际底层水平将受 Y 轴最小值和最大值的限制。默认为零。
gridLineType : Graphs3D.GridLineType |
定义网格线类型是Graphs3D.GridLineType.Shader
还是Graphs3D.GridLineType.Geometry
。
该值会影响所有网格线。
另请参阅 Graphs3D.GridLineType 。
horizontalAspectRatio : real |
X 轴和 Z 轴之间的图形缩放比例。0.0
表示根据坐标轴范围自动缩放。默认值为0.0
。
注: 对Bars3DNode 没有影响,它通过barThickness 和barSpacing 属性处理水平面的缩放。极坐标图也忽略此属性。
另请参阅 aspectRatio,polar,Bars3DNode::barThickness, 和Bars3DNode::barSpacing 。
labelMargin : real |
该属性指定了轴标签放置的边距。
负值用于将标签置于绘图区域内,正值用于将标签置于绘图区域外。当值为负数时,将禁用标签自动旋转功能。默认值为0.1
locale : locale |
设置用于格式化各种数字标签的本地语言。默认为"C"
locale。
另请参阅 Value3DAxis::labelFormat 。
margin : real |
可绘图区域边缘与图形背景边缘之间留出空间的绝对值。
如果边距值为负数,边距将自动确定,并根据系列中项目的大小和图形类型而变化。如果图形纵横比未从默认值中更改,则该值将被解释为 Y 轴范围的一部分。默认值为-1.0
。
注意: 如果为散点图设置的边距小于自动确定的边距,可能会导致图形边缘的散点项与图 形背景重叠。
注: 在散点图和曲面图中,如果边距小于坐标轴标签尺寸,则会调整坐标轴边缘标签的位置,以避免与相邻坐标轴的边缘标签重叠。
multiSeriesUniform : bool |
定义条形图是否按比例缩放,即使显示多个系列条形图也是如此。如果设置为true
,bar spacing 将仅正确应用于 X 轴。默认设置为false
。
optimizationHint : Graphs3D.OptimizationHint |
指定使用默认模式还是传统模式进行渲染优化。
默认模式使用实例渲染,可在大多数系统上以最佳性能提供完整的功能集。静态模式可优化图形渲染,是大型非变化数据集的理想选择。但在动态数据变化和项目旋转的情况下,该模式的运行速度较慢。选择模式未进行优化,因此不建议在海量数据集上使用静态模式。传统模式会单独渲染图形中的所有项目,而不会实例化。只有在默认模式不工作时,即目标系统不支持实例化时,才应使用该模式。默认值为Default 。
注意: 在某些环境下,使用静态优化的大型图形可能无法渲染,因为所有项目都是通过单次绘制调用渲染的,而不同的图形驱动程序支持不同的每次调用最大顶点数。这个问题主要出现在 32 位和 OpenGL ES2 平台上。要解决这个问题,可以选择顶点数较少的项目网格或使用点网格。
polar : bool |
primarySeries : Bar3DSeries |
图形的主系列。如果没有明确设置行、列坐标轴标签,则用它来确定行、列坐标轴标签。
如果指定的序列尚未添加到图形中,将其设置为主序列也会将其隐式添加到图形中。
如果从图形中删除了主系列,该属性将重置为默认值。
如果序列为空,该属性将重置为默认值。默认值为第一个添加的序列,如果没有序列添加到图表中,则默认值为 0。
queriedGraphPosition : vector3d |
此只读属性包含使用Scene3D::graphPositionQuery 查询到的每个轴的最新图形位置值。这些值已归一化,范围为[-1, 1]
。如果所查询的位置超出了图形边界,则该值将不会反映真实位置,而会是[-1, 1]
范围外的某个未定义位置。在进行查询之前,该值都是未定义的。
没有一个正确的三维坐标与特定的屏幕位置相匹配,因此为了保持一致,查询总是针对图形周围的一个不可见方框的内侧进行。
注意: 条形图只允许在图形底层查询图形位置,因此条形图的 y 值始终为零,只能在包含图形底层的屏幕位置进行有效查询。
另请参阅 Scene3D::graphPositionQuery 。
radialLabelOffset : real |
该属性指定径向极轴标签的归一化水平偏移。0.0
表示标签应绘制在 0 角度角轴网格线旁边。1.0
表示标签绘制在图形背景边缘的常规位置。如果极坐标属性值为false
,该属性将被忽略。默认值为1.0
。
另请参阅 polar 。
rowAxis : Category3DAxis |
活动行轴。
如果没有给出坐标轴,则会创建一个没有标签的临时默认坐标轴。如果另一个轴被明确设置为相同的方向,则该临时轴将被销毁。
selectedElement : Graphs3D.ElementType |
图形中选择的元素。
该属性可用于查询所选元素的类型。该类型一直有效,直到在图形中做出新的选择并发出selectedElementChanged
信号。
例如,该信号可用于实现自定义输入处理,如轴处理示例所示。
另请参阅 selectedLabelIndex(),selectedAxis(),selectedCustomItemIndex(),selectedCustomItem(),Bars3DNode::selectedSeries,Scatter3DNode::selectedSeries,Scene3D::selectionQueryPosition, 和Graphs3D.ElementType 。
selectedSeries : Bar3DSeries |
选定的系列或null
。如果selectionMode 已设置SelectionMultiSeries
标志,则该属性将保留拥有选定条形图的系列。
selectionMode : Graphs3D.SelectionMode |
图表中的活动选择模式。graphs3d.selectionflag 枚举值之一。
seriesList : list<Bar3DSeries> |
图形的系列。默认情况下,该属性包含一个空列表。要设置序列,可使用addSeries() 函数或将其定义为图形的子序列。
theme : GraphsTheme |
图表的活动主题。
另请参阅 GraphsTheme 。
valueAxis : ValueAxis3D |
活动值轴。
如果没有给出坐标轴,则会创建一个没有标签和自动调整范围的临时默认坐标轴。如果另一个轴被明确设置为相同方向,则该临时轴将被销毁。
信号文档
barSeriesMarginChanged(size margin) |
当barSeriesMargin 更改为margin 时会发出该信号。
注: 相应的处理程序是onBarSeriesMarginChanged
。
barSpacingChanged(size spacing) |
当barSpacing 更改为spacing 时会发出此信号。
注: 相应的处理程序是onBarSpacingChanged
。
barSpacingRelativeChanged(bool relative) |
当barSpacingRelative 变更为relative 时,发出该信号。
注: 相应的处理程序是onBarSpacingRelativeChanged
。
barThicknessChanged(real thicknessRatio) |
当barThickness 变更为thicknessRatio 时,发出此信号。
注: 相应的处理程序是onBarThicknessChanged
。
columnAxisChanged(Category3DAxis axis) |
当columnAxis 变更为axis 时,发出此信号。
注: 相应的处理程序是onColumnAxisChanged
。
floorLevelChanged(real level) |
当floorLevel 变更为level 时,发出此信号。
注: 相应的处理程序是onFloorLevelChanged
。
multiSeriesUniformChanged(bool uniform) |
当multiSeriesUniform 变更为uniform 时,发出此信号。
注: 相应的处理程序是onMultiSeriesUniformChanged
。
primarySeriesChanged(Bar3DSeries series) |
当primarySeries 变更为series 时,发出此信号。
注: 相应的处理程序是onPrimarySeriesChanged
。
rowAxisChanged(Category3DAxis轴) |
当rowAxis 更改为axis 时会发出该信号。
注: 相应的处理程序是onRowAxisChanged
。
selectedSeriesChanged(Bar3DSeries series) |
当selectedSeries 变更为series 时发出此信号。
注: 相应的处理程序是onSelectedSeriesChanged
。
valueAxisChanged(ValueAxis3D axis) |
当valueAxis 变更为axis 时,发出此信号。
注: 相应的处理程序是onValueAxisChanged
。
方法文档
qsizetype addCustomItem(Custom3DItem item) |
将Custom3DItem item 添加到图。图形拥有添加项的所有权。
如果添加成功,则返回已添加项的索引;如果试图添加一个空项,则返回-1;如果试图添加一个已添加项,则返回该项的索引。
另请参阅 removeCustomItems()、removeCustomItem() 和removeCustomItemAt()。
void addSeries(Bar3DSeries series) |
将series 添加到图表中。图表可以包含多个序列,但只有一组坐标轴,因此所有序列的行和列必须匹配,这样可视化数据才有意义。如果图形有多个可见序列,在未明确设置坐标轴标签的情况下,只有第一个添加的序列才会在坐标轴上生成行或列标签。如果新添加的序列已指定了一个选定的柱形图,则该柱形图将突出显示,并且任何现有的选 择都将被清除。只有一个添加的序列可以有活动选区。
另请参阅 GraphsNode::hasSeries().
void clearSelection() |
清除所有附加系列的选区。
void doPicking(QPoint point) |
使用point 中的视图坐标对图形元素执行选取,选择第一个命中的项目。默认输入处理会在接收到 onTapped 事件时执行此操作。
另请参阅 selectedElement 。
void doRayPicking(QVector3D origin, QVector3D direction) |
从origin 开始,在direction 中对图形元素执行拾取,选择第一个命中的项目。
另请参阅 selectedElement 。
bool hasSeries(Abstract3DSeries series) |
返回series 是否已添加到图形中。
void insertSeries(int index, Bar3DSeries series) |
将series 插入系列列表中的index 位置。如果series 已添加到列表中,则将其移动到新的index 中。
注: 将序列移动到其旧索引之后的新index 时,列表中的新位置将按照序列仍在其旧索引中的情况计算,因此最终索引实际上是index 减一。
另请参阅 GraphsNode::hasSeries() 。
void releaseCustomItem(Custom3DItem item) |
void removeCustomItem(Custom3DItem item) |
删除自定义item 。删除分配给它的资源。
void removeCustomItemAt(vector3d position) |
删除position 上的所有自定义项目。删除分配给它们的资源。
void removeCustomItems() |
删除所有自定义项目。删除为其分配的资源。
void removeSeries(Bar3DSeries series) |
从图形中删除series 。
另请参阅 GraphsNode::hasSeries() 。
Abstract3DAxis selectedAxis() |
在收到selectedElementChanged
信号后,可使用任何标签类型获取所选坐标轴。在下一个selectedElementChanged
信号发出之前,选择有效。
返回选中的轴或空值。
另请参阅 selectedElement 。
Custom3DItem selectedCustomItem() |
在收到selectedElementChanged
信号后,可使用ElementType.CustomItem 类型获取选定的自定义项。项目的所有权仍归图形所有。在下一个selectedElementChanged
信号发出之前,选择有效。
返回选中的自定义项目或 null。
另请参阅 selectedElement 。
qsizetype selectedCustomItemIndex() |
在收到selectedElementChanged
信号(类型为ElementType.CustomItem )后,可用于查询所选自定义项的索引。选择有效期至下一个selectedElementChanged
信号发出为止。
返回所选自定义项的索引或-1。
另请参阅 selectedElement 。
int selectedLabelIndex() |
在收到selectedElementChanged
信号后,可使用任何标签类型查询所选标签的索引。选择在下一个selectedElementChanged
信号发出前有效。
返回所选标签的索引或-1。
另请参阅 selectedElement 。
© 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.