- Qt 6.7
- Qt Graphs
- QML Types
- QtGraphs (Technical Preview)
- AbstractGraph3D
- Qt Graphs | Commercial or GPLv3

# AbstractGraph3D QML Type

Base type for 3D graphs. More...

Import Statement: | import QtGraphs
Inherited By: | Bars3D, Scatter3D, and Surface3D
Status: | Technical Preview

- List of all members, including inherited members
- AbstractGraph3D is part of Qt Graphs QML Types for 3D.

## Properties

- aspectRatio : real
- cameraPreset : AbstractGraph3D.CameraPreset
- cameraTargetPosition : vector3d
- cameraXRotation : float
- cameraYRotation : float
- cameraZoomLevel : float
- currentFps : int
- customItemList : list<Custom3DItem>
- horizontalAspectRatio : real
- inputHandler : AbstractInputHandler3D
- locale : locale
- margin : real
- maxCameraZoomLevel : float
- measureFps : bool
- minCameraZoomLevel : float
- msaaSamples : int
- optimizationHint : AbstractGraph3D.OptimizationHint
- orthoProjection : bool
- polar : bool
- queriedGraphPosition : vector3d
- radialLabelOffset : real
- renderingMode : AbstractGraph3D.RenderingMode
- scene : Scene3D
- selectedElement : AbstractGraph3D.ElementType
- selectionMode : AbstractGraph3D.SelectionMode
- shadowQuality : AbstractGraph3D.ShadowQuality
- theme : Theme3D
- wrapCameraXRotation : bool
- wrapCameraYRotation : bool

## Methods

- int addCustomItem(Custom3DItem item)
- void clearSelection()
- bool hasSeries(Abstract3DSeries series)
- void releaseCustomItem(Custom3DItem item)
- void removeCustomItem(Custom3DItem item)
- void removeCustomItemAt(vector3d position)
- void removeCustomItems()
- Abstract3DAxis selectedAxis()
- Custom3DItem selectedCustomItem()
- int selectedCustomItemIndex()
- int selectedLabelIndex()

## Detailed Description

The base type for all 3D graphs in QtGraphs.

This type is uncreatable, but it contains properties that are shared between the 3D graphs types.

See also Bars3D, Scatter3D, Surface3D, and Qt Graphs C++ Classes for 3D.

## Property Documentation

aspectRatio : real

The ratio of the graph scaling between the longest axis on the horizontal plane and the y-axis. Defaults to `2.0`.

Note: Has no effect on Bars3D.

See also horizontalAspectRatio.

cameraPreset : AbstractGraph3D.CameraPreset

The currently active camera preset, which is one of AbstractGraph3D.CameraPreset. If no preset is active, the value is `AbstractGraph3D.CameraPreset.None`.

cameraTargetPosition : vector3d

The camera target as a vector3d. Defaults to `vector3d(0.0, 0.0, 0.0)`.

Valid coordinate values are between `-1.0...1.0`, where the edge values indicate the edges of the corresponding axis range. Any values outside this range are clamped to the edge.

Note: For bar graphs, the Y-coordinate is ignored and camera always targets a point on the horizontal background.

cameraXRotation : float

The X-rotation angle of the camera around the target point in degrees starting from the current base position.

cameraYRotation : float

The Y-rotation angle of the camera around the target point in degrees starting from the current base position.

cameraZoomLevel : float

The camera zoom level in percentage. The default value of `100.0` means there is no zoom in or out set in the camera. The value is limited by the minCameraZoomLevel and maxCameraZoomLevel properties.

See also minCameraZoomLevel and maxCameraZoomLevel.

currentFps : int

When FPS measuring is enabled, the results for the last second are stored in this read-only property. It takes at least a second before this value updates after measuring is activated.

See also measureFps.

customItemList : list<Custom3DItem>

The list of Custom3DItem items added to the graph. The graph takes ownership of the added items.

horizontalAspectRatio : real

The ratio of the graph scaling between the x-axis and z-axis. The value of `0.0` indicates automatic scaling according to axis ranges. Defaults to `0.0`.

Note: Has no effect on Bars3D, which handles scaling on the horizontal plane via the barThickness and barSpacing properties. Polar graphs also ignore this property.

See also aspectRatio, polar, Bars3D::barThickness, and Bars3D::barSpacing.

inputHandler : AbstractInputHandler3D

The active input handler used in the graph. You can disable default input handlers by setting this property to null.

locale : locale

Sets the locale used for formatting various numeric labels. Defaults to the `"C"` locale.

See also ValueAxis3D::labelFormat.

margin : real

The absolute value used for the space left between the edge of the plottable graph area and the edge of the graph background.

If the margin value is negative, the margins are determined automatically and can vary according to the size of the items in the series and the type of the graph. The value is interpreted as a fraction of the y-axis range if the graph aspect ratios have not beed changed from the default values. Defaults to `-1.0`.

Note: Setting a smaller margin for a scatter graph than the automatically determined margin can cause the scatter items at the edges of the graph to overlap with the graph background.

Note: On scatter and surface graphs, if the margin is small in comparison to the axis label size, the positions of the edge labels of the axes are adjusted to avoid overlap with the edge labels of the neighboring axes.

maxCameraZoomLevel : float

Sets the maximum allowed camera zoom level. If the new maximum level is lower than the existing minimum level, the minimum level is adjusted to the new maximum as well. If the current cameraZoomLevel is outside the new bounds, it is adjusted as well. Defaults to `500.0f`.

See also cameraZoomLevel and minCameraZoomLevel.

measureFps : bool

If `true`, the rendering is done continuously instead of on demand, and the value of the currentFps property is updated. Defaults to `false`.

See also currentFps.

minCameraZoomLevel : float

Sets the minimum allowed camera zoom level. If the new minimum level is higher than the existing maximum level, the maximum level is adjusted to the new minimum as well. If the current cameraZoomLevel is outside the new bounds, it is adjusted as well. The minCameraZoomLevel cannot be set below `1.0`. Defaults to `10.0`.

See also cameraZoomLevel and maxCameraZoomLevel.

msaaSamples : int

The number of samples used in multisample antialiasing when renderingMode is `Indirect`. When renderingMode is `DirectToBackground`, this property value is read-only and returns the number of samples specified by the window surface format. Defaults to `4`.

See also renderingMode.

optimizationHint : AbstractGraph3D.OptimizationHint

Whether the default, static, or legacy mode is used for rendering optimization.

The default mode uses instanced rendering, and provides the full feature set at the best level of performance on most systems. The static mode optimizes graph rendering and is ideal for large non-changing data sets. It is slower with dynamic data changes and item rotations. Selection is not optimized, so using the static mode with massive data sets is not advisable. Legacy mode renders all items in th graph individually, without instancing. It should be used only if default mode does not work, i.e. if the target system does not support instancing. Defaults to Default.

Note: On some environments, large graphs using static optimization may not render, because all of the items are rendered using a single draw call, and different graphics drivers support different maximum vertice counts per call. This is mostly an issue on 32bit and OpenGL ES2 platforms. To work around this issue, choose an item mesh with a low vertex count or use the point mesh.

See also Abstract3DSeries::mesh and QAbstract3DGraph::OptimizationHint.

orthoProjection : bool

If `true`, orthographic projection will be used for displaying the graph. Defaults to `false`.

Note: Shadows will be disabled when set to `true`.

polar : bool

If `true`, the horizontal axes are changed into polar axes. The x-axis becomes the angular axis and the z-axis becomes the radial axis. Polar mode is not available for bar graphs.

Defaults to `false`.

See also orthoProjection and radialLabelOffset.

queriedGraphPosition : vector3d

This read-only property contains the latest graph position values along each axis queried using Scene3D::graphPositionQuery. The values are normalized to range `[-1, 1]`. If the queried position was outside the graph bounds, the values will not reflect the real position, but will instead be some undefined position outside the range `[-1, 1]`. The value will be undefined until a query is made.

There is no single correct 3D coordinate to match a particular screen position, so to be consistent, the queries are always done against the inner sides of an invisible box surrounding the graph.

Note: Bar graphs only allow querying graph position at the graph floor level, so the y-value is always zero for bar graphs and valid queries can be only made at screen positions that contain the floor of the graph.

See also Scene3D::graphPositionQuery.

radialLabelOffset : real

This property specifies the normalized horizontal offset for the axis labels of the radial polar axis. The value `0.0` indicates that the labels should be drawn next to the 0-angle angular axis grid line. The value `1.0` indicates that the labels are drawn in their usual place at the edge of the graph background. This property is ignored if the polar property value is `false`. Defaults to `1.0`.

See also polar.

renderingMode : AbstractGraph3D.RenderingMode

How the graph will be rendered. Defaults to `Indirect`.

Constant | Description
--- | ---

`DirectToBackground`

Indicates that the graph will be rendered directly on the window background and QML items are rendered on top of it. Using non-transparent QML item as a background will hide the graph. Clears the whole window before rendering the graph, including the areas outside the graph. If the surface format of the window supports antialiasing, it will be used (see `QtGraphs::qDefaultSurfaceFormat()`). This rendering mode offers the best performance at the expense of non-standard QML behavior. For example, the graphs do not obey the z ordering of QML items and the opacity value has no effect on them.

`Indirect` | Indicates the graph will be first rendered to an offscreen surface that is then drawn during normal QML item rendering. The rendered image is antialiased using the multisampling method if it is supported in the current environment and the msaaSamples property value is greater than zero. This rendering mode offers good quality and normal QML item behavior at the expense of performance.

Note: Antialiasing is not supported in OpenGL ES2 environments in any rendering mode.

Note: Setting the `antialiasing` property of the graph does not do anything. However, it is set by the graph itself if the current rendering mode uses antialiasing.

See also msaaSamples.

scene : Scene3D

The Scene3D pointer that can be used to manipulate the scene and access the scene elements.

This property is read-only.

selectedElement : AbstractGraph3D.ElementType

The element selected in the graph.

This property can be used to query the selected element type. The type is valid until a new selection is made in the graph and the `selectedElementChanged` signal is emitted.

The signal can be used for example for implementing customized input handling, as demonstrated by the Axis Handling example.

See also selectedLabelIndex(), selectedAxis(), selectedCustomItemIndex(), selectedCustomItem(), Bars3D::selectedSeries, Scatter3D::selectedSeries, Scene3D::selectionQueryPosition, and QAbstract3DGraph::ElementType.

selectionMode : AbstractGraph3D.SelectionMode

The active selection mode in the graph. One of the QAbstract3DGraph::SelectionFlag enum values.

See also QAbstract3DGraph::SelectionFlag.

shadowQuality : AbstractGraph3D.ShadowQuality

The quality of shadows. One of the QAbstract3DGraph::ShadowQuality enum values.

See also QAbstract3DGraph::ShadowQuality.

theme : Theme3D

The active theme of the graph.

See also Theme3D.

wrapCameraXRotation : bool

The behavior of the minimum and maximum limits in the X-rotation. By default, the X-rotation wraps from minimum value to maximum and from maximum to minimum.

If set to `true`, the X-rotation of the camera is wrapped from minimum to maximum and from maximum to minimum. If set to `false`, the X-rotation of the camera is limited to the sector determined by the minimum and maximum values.

wrapCameraYRotation : bool

The behavior of the minimum and maximum limits in the Y-rotation. By default, the Y-rotation is limited between the minimum and maximum values without any wrapping.

If `true`, the Y-rotation of the camera is wrapped from minimum to maximum and from maximum to minimum. If `false`, the Y-rotation of the camera is limited to the sector determined by the minimum and maximum values.

## Method Documentation

int addCustomItem(Custom3DItem item)

Adds a Custom3DItem item to the graph. Graph takes ownership of the added item.

Returns index to the added item if add was successful, -1 if trying to add a null item, and index of the item if trying to add an already added item.

See also removeCustomItems(), removeCustomItem(), and removeCustomItemAt().

void clearSelection()

Clears selection from all attached series.

bool hasSeries(Abstract3DSeries series)

Returns whether the series has already been added to the graph.

void releaseCustomItem(Custom3DItem item)

Gets ownership of item back and removes the item from the graph.

Note: If the same item is added back to the graph, the texture file needs to be re-set.

See also Custom3DItem::textureFile.

void removeCustomItem(Custom3DItem item)

Removes the custom item. Deletes the resources allocated to it.

void removeCustomItemAt(vector3d position)

Removes all custom items at position. Deletes the resources allocated to them.

void removeCustomItems()

Removes all custom items. Deletes the resources allocated to them.

Abstract3DAxis selectedAxis()

Can be used to get the selected axis after receiving `selectedElementChanged` signal with any label type. Selection is valid until the next `selectedElementChanged` signal.

Returns the selected axis, or null.

See also selectedElement.

Custom3DItem selectedCustomItem()

Can be used to get the selected custom item after receiving `selectedElementChanged` signal with ElementType.CustomItem type. Ownership of the item remains with the graph. Selection is valid until the next `selectedElementChanged` signal.

Returns the selected custom item, or null.

See also selectedElement.

int selectedCustomItemIndex()

Can be used to query the index of the selected custom item after receiving `selectedElementChanged` signal with ElementType.CustomItem type. Selection is valid until the next `selectedElementChanged` signal.

Returns index of the selected custom item, or -1.

See also selectedElement.

int selectedLabelIndex()

Can be used to query the index of the selected label after receiving `selectedElementChanged` signal with any label type. Selection is valid until the next `selectedElementChanged` signal.

Returns index of the selected label, or -1.

See also selectedElement.