GraphsTheme QML Type | Qt Graphs | Qt 6.10.3
Description: A visual style for graphs.

- Qt 6.10
- Qt Graphs
- QML Types
- QtGraphs
- GraphsTheme
- Qt Graphs | Commercial or GPLv3

# GraphsTheme QML Type

A visual style for graphs. More...

Import Statement: | `import QtGraphs`
In C++: | QGraphsTheme

- List of all members, including inherited members
- GraphsTheme is part of Qt Graphs QML Common Types.

## Properties

- GraphsLine.labelTextColor : color
- GraphsLine.mainColor : color
- GraphsLine.mainWidth : real
- GraphsLine.subColor : color
- GraphsLine.subWidth : real
- axisX : GraphsLine
- axisXLabelFont : font
- axisY : GraphsLine
- axisYLabelFont : font
- axisZ : GraphsLine
- axisZLabelFont : font
- backgroundColor : color
- backgroundVisible : bool
- baseColors : list<Color>
- baseGradients : list<Gradient>
- borderColors : list<color>
- colorScheme : QGraphsTheme::ColorScheme
- colorStyle : GraphsTheme.ColorStyle
- grid : GraphsLine
- gridVisible : bool
- labelBackgroundColor : color
- labelBackgroundVisible : bool
- labelBorderVisible : bool
- labelFont : font
- labelTextColor : color
- labelsVisible : bool
- multiHighlightColor : color
- multiHighlightGradient : Gradient
- plotAreaBackgroundColor : color
- plotAreaBackgroundVisible : bool
- seriesColors : list<color>
- singleHighlightColor : color
- singleHighlightGradient : Gradient
- theme : GraphsTheme.Theme

## Detailed Description

This type is used to specify visual properties that affect the whole graph. There are several built-in themes that can be used as is or modified freely.

Themes can be created from scratch by using the GraphsTheme.Theme.UserDefined enum value.

## Customizing Theme

The default theme is QtGreen, but it is possible to customize each property.

The following table lists the properties controlled by a theme and the default values for QGraphsTheme.Theme.UserDefined.

Property | Default Value
--- | ---
backgroundVisible | `true`
seriesColors | Qt::black
baseGradients | QLinearGradient. Essentially fully black.
colorStyle | Uniform
labelFont | QFont
gridVisible | `true`
labelBackgroundVisible | `true`
labelBorderVisible | `true`
labelsVisible | `true`

## Usage examples

Using a built-in theme without any modifications:

     Scatter3D {
         theme: GraphsTheme { theme: GraphsTheme.Theme.YellowSeries }
         ...

Using a built-in theme and modifying some properties:

     Bars3D {
         theme: GraphsTheme {
             theme: GraphsTheme.Theme.QtGreenNeon
             labelBorderVisible: true
             labelFont.pointSize: 35
             labelBackgroundVisible: false
         }
         ...

Using a user-defined theme:

     Surface3D {
         theme: GraphsTheme {
             theme: GraphsTheme.Theme.UserDefined
             backgroundColor: "red"
             backgroundVisible: true
             seriesColors: ["blue"]
             colorStyle: GraphsTheme.ColorStyle.Uniform
             labelFont.family: "Lucida Handwriting"
             labelFont.pointSize: 35
             gridVisible: false
             grid.mainColor: "red"
             grid.subColor: "blue"
             labelBackgroundColor: "black"
             labelBackgroundVisible: true
             labelBorderVisible: false
             labelTextColor: "white"
             multiHighlightColor: "green"
             singleHighlightColor: "darkRed"
         }
         ...

For GraphsTheme enums, see GraphsTheme::colorStyle and GraphsTheme::theme.

## Property Documentation

GraphsLine.labelTextColor : color

The color of the text used for labels. The default value depends on colorScheme.

GraphsLine.mainColor : color

The color of the main lines. The default value depends on colorScheme.

GraphsLine.mainWidth : real

The width of the main lines. The default value is `2.0`.

If it is set for grid lines, only has effect if GraphsItem3D::gridLineType is `Graphs3D.GridLineType.Shader`

See also Graphs3D.GridLineType.

GraphsLine.subColor : color

The color of the sub lines. The default value depends on colorScheme.

GraphsLine.subWidth : real

The width of the sub lines. The default value is `1.0`.

If it is set for grid lines, only has effect if GraphsItem3D::gridLineType is `Graphs3D.GridLineType.Shader`

See also Graphs3D.GridLineType.

axisX : GraphsLine

Holds the GraphsLine of the X axis.

See also GraphsLine.mainColor, GraphsLine.subColor, GraphsLine.mainWidth, GraphsLine.subWidth, and GraphsLine.labelTextColor.

axisXLabelFont : font

Sets the font to be used for labels on axisX.

axisY : GraphsLine

Holds the GraphsLine of the Y axis.

See also GraphsLine.mainColor, GraphsLine.subColor, GraphsLine.mainWidth, GraphsLine.subWidth, and GraphsLine.labelTextColor.

axisYLabelFont : font

Sets the font to be used for labels on axisY.

axisZ : GraphsLine

Holds the GraphsLine of the Z axis.

See also GraphsLine.mainColor, GraphsLine.subColor, GraphsLine.mainWidth, GraphsLine.subWidth, and GraphsLine.labelTextColor.

axisZLabelFont : font

Sets the font to be used for labels on axisZ.

backgroundColor : color

The color of the view the graph is drawn into. The default value depends on colorScheme.

backgroundVisible : bool

Defines whether the view background is drawn by using the value of backgroundColor. The default value is `true`.

baseColors : list<Color> `[read-only]`

The list of base colors of type Color to be used for all the objects in the graph, series by series. If there are more series than colors, color list wraps and starts again with the first color in the list. Has no immediate effect if colorStyle is not `GraphsTheme.ColorStyle.Uniform`.

Example usage:

     baseColors: [ Color { color: "red" } ]

This can be overridden by setting Abstract3DSeries.baseColor explicitly in the series.

baseGradients : list<Gradient> `[read-only]`

The list of base gradients to be used for all the objects in the graph, series by series. If there are more series than gradients, the gradient list wraps and starts again with the first gradient in the list.

Has no immediate effect if colorStyle is GraphsTheme.ColorStyle.Uniform.

Example usage:

     baseGradients: [ Gradient {
         GradientStop { position: 1.0; color: "#DBEB00" }
         GradientStop { position: 0.0; color: "#373F26" }
     } ]

This value can be overridden by setting Abstract3DSeries.baseGradient explicitly in the series.

borderColors : list<color>

The list of border colors to be used for all the objects in the graph, series by series.

If there are more series than colors, the color list wraps and starts again with the first color in the list.

Has no immediate effect if colorStyle is not Uniform.

colorScheme : QGraphsTheme::ColorScheme

The color scheme of the graph in use.

See also QGraphsTheme::ColorScheme.

colorStyle : GraphsTheme.ColorStyle

The style of the graph colors. One of QGraphsTheme::ColorStyle enum values.

This value can be overridden by setting Abstract3DSeries.colorStyle explicitly in the series.

Note: This property does not have an effect in Qt Graphs for 2D.

See also QGraphsTheme::ColorStyle.

grid : GraphsLine

Holds the GraphsLine of the theme.

See also GraphsLine.mainColor, GraphsLine.subColor, GraphsLine.mainWidth, GraphsLine.subWidth, and GraphsLine.labelTextColor.

gridVisible : bool

Defines whether the grid lines are drawn. This value affects all grid lines. The default value is `true`.

labelBackgroundColor : color

The color of the label backgrounds. Has no effect if labelBackgroundVisible is `false`. The default value depends on colorScheme.

labelBackgroundVisible : bool

Defines whether the label is drawn with a background that uses labelBackgroundColor (including alpha), or with a fully transparent background. Labels with a background are drawn to equal sizes per axis based on the longest label, and the text is centered in them. Labels without a background are drawn as is and are left or right aligned based on their position in the graph. The default value is `true`.

labelBorderVisible : bool

Defines whether label borders are drawn for labels that have a background. Has no effect if labelBackgroundVisible is `false`. The default value is `true`.

labelFont : font

Sets the font to be used for labels.

labelTextColor : color

The color of the font used for labels.

If an axis has specified labelTextColor explicitly, this has no effect.

The default value depends on colorScheme.

labelsVisible : bool

Defines whether labels are drawn at all. If this is `false`, all other label properties have no effect. The default value is `true`.

multiHighlightColor : color

The highlight color for selected objects. Used if selectionMode has the `Graphs3D.SelectionFlag.Row` or `Graphs3D.SelectionFlag.Column` flag set. The default value depends on colorScheme.

See also Graphs3D.SelectionFlag.

multiHighlightGradient : Gradient

The highlight gradient for selected objects. Used if selectionMode has the `Graphs3D.SelectionFlag.Row` or `Graphs3D.SelectionFlag.Column` flag set. The default value depends on colorScheme.

See also Graphs3D.SelectionFlag.

plotAreaBackgroundColor : color

The color of the graph plot area background. The default value depends on colorScheme.

plotAreaBackgroundVisible : bool

Defines whether the plot area background is drawn by using the value of plotAreaBackgroundColor. The default value is `true`.

seriesColors : list<color>

The list of colors to be used for all the objects in the graph, series by series. If there are more series than colors, color list wraps and starts again with the first color in the list. Has no immediate effect if colorStyle is not `GraphsTheme.ColorStyle.Uniform`.

Example usage:

     seriesColors: [ "red" ]

This can be overridden by setting Abstract3DSeries.baseColor explicitly in the series.

singleHighlightColor : color

The highlight color for a selected object. Used if selectionMode has the `Graphs3D.SelectionFlag.Item` flag set. The default value depends on colorScheme.

See also Graphs3D.SelectionFlag.

singleHighlightGradient : Gradient

The highlight gradient for a selected object. Used if selectionMode has the `Graphs3D.SelectionFlag.Item` flag set. The default value depends on colorScheme.

See also Graphs3D.SelectionFlag.

theme : GraphsTheme.Theme

The type of the theme. If no type is set, the type is GraphsTheme.Theme.QtGreen. Changing the theme type after the item has been constructed will change all other properties of the theme to what the predefined theme specifies. Changing the theme type of the active theme of the graph will also reset all attached series to use the new theme.