- Qt 6.8
- Qt Graphs
- QML Types
- QtGraphs
- BarSeries
- Qt Graphs | Commercial or GPLv3

# BarSeries QML Type

Presents data in bar graphs. More...

Import Statement: | import QtGraphs
Instantiates: | QBarSeries
Inherits: | AbstractSeries

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

## Properties

- axisX : AbstractAxis
- axisY : AbstractAxis
- barComponent : Component
- barWidth : real
- barsOrientation : enumeration
- barsType : enumeration
- count : int
- labelsAngle : real
- labelsFormat : string
- labelsMargin : real
- labelsPosition : enumeration
- labelsPrecision : real
- labelsVisible : bool

## Signals

- barsetsAdded()
- barsetsRemoved()
- clicked(int index, BarSet barset)
- doubleClicked(int index, BarSet barset)
- hovered(bool status, int index, BarSet barset)
- pressed(int index, BarSet barset)
- released(int index, BarSet barset)

## Methods

- BarSet append(string label, VariantList values)
- BarSet at(int index)
- clear()
- BarSet insert(int index, string label, VariantList values)
- bool remove(BarSet barset)

## Detailed Description

Draws data by default as a series of bars grouped by category, with one bar per category from each bar set added to the series. It also supports horizontal bars and grouping bars as stacked.

## Property Documentation

axisX : AbstractAxis

The x-axis used for the series. This should be BarCategoryAxis.

See also axisY.

axisY : AbstractAxis

The y-axis used for the series. This should be ValueAxis.

See also axisX.

barComponent : Component

A custom QML component used for visualizing each of the bars. Instance of this component is created for each of the bar. To get access into bars properties, use BarComponent. When this is not defined, a default rectangle visualization for bars is used.

barWidth : real

The unit of width is the unit of the x-axis. The minimum width for bars is zero, and negative values are treated as zero. Setting the width to zero means that the width of the bar on the screen is one pixel regardless of the scale of the x-axis. Bars wider than zero are scaled using the x-axis scale.

By default, the barWidth is 0.5 (bars will take 50% of the available width). The valid values range from 0.0 (0%) to 1.0 (100%).

Note: When used with the BarSeries type, this value specifies the width of a group of bars instead of that of a single bar.

barsOrientation : enumeration

The orientation of the bar series:

Constant | Description
--- | ---
`BarSeries.BarsOrientation.Vertical` | Bars appear vertically. This is the default value.
`BarSeries.BarsOrientation.Horizontal` | Bars appear horizontally.

barsType : enumeration

The type of the bar series:

Constant | Description
--- | ---
`BarSeries.BarsType.Groups` | Bar sets are grouped by category. This is the default value.
`BarSeries.BarsType.Stacked` | Bar sets are stacked after each other by category.
`BarSeries.BarsType.StackedPercent` | Bar sets are stacked after each other by category. The segment size corresponds to the percentage of the segment value compared with the total value of all segments in the stack.

count : int `[read-only]`

The number of bar sets in a bar series.

labelsAngle : real

The angle of the value labels in degrees.

labelsFormat : string

The format used for showing labels in a bar series.

See also QBarSeries::labelsFormat, labelsVisible, and labelsPosition.

labelsMargin : real

The margin of the value labels in pixels.

This margin from side is used when labelsPosition is set to something else than `LabelsPosition.Center`. The default value is `0`.

labelsPosition : enumeration

The position of the data value labels:

Constant | Description
--- | ---
`BarSeries.LabelsPosition.Center` | Label is located in the center of the bar.
`BarSeries.LabelsPosition.InsideEnd` | Label is located inside the bar at the top.
`BarSeries.LabelsPosition.InsideBase` | Label is located inside the bar at the bottom.
`BarSeries.LabelsPosition.OutsideEnd` | Label is located outside the bar at the top.

See also labelsVisible and labelsFormat.

labelsPrecision : real

The maximum amount of significant digits shown in value labels.

Default value is 6.

labelsVisible : bool

The visibility of the labels in a bar series. The default label visibility is `false`.

## Signal Documentation

barsetsAdded()

This signal is emitted when bar sets are added to the series.

The corresponding signal handler is `onBarsetsAdded`.

Note: The corresponding handler is `onBarsetsAdded`.

barsetsRemoved()

This signal is emitted when bar sets are removed from the series.

The corresponding signal handler is `onBarsetsRemoved`.

Note: The corresponding handler is `onBarsetsRemoved`.

clicked(int index, BarSet barset)

This signal is emitted when the user clicks the bar specified by index in the bar set specified by barset.

The corresponding signal handler is `onClicked`.

Note: The corresponding handler is `onClicked`.

doubleClicked(int index, BarSet barset)

This signal is emitted when the user double-clicks the bar specified by index in the bar set specified by barset.

The corresponding signal handler is `onDoubleClicked`.

Note: The corresponding handler is `onDoubleClicked`.

hovered(bool status, int index, BarSet barset)

This signal is emitted when a mouse is hovered over the bar specified by index in the bar set specified by barset. When the mouse moves over the bar, status turns `true`, and when the mouse moves away again, it turns `false`.

The corresponding signal handler is `onHovered`.

Note: The corresponding handler is `onHovered`.

pressed(int index, BarSet barset)

This signal is emitted when the user clicks the bar specified by index in the bar set specified by barset and holds down the mouse button.

The corresponding signal handler is `onPressed`.

Note: The corresponding handler is `onPressed`.

released(int index, BarSet barset)

This signal is emitted when the user releases the mouse press on the bar specified by index in the bar set specified by barset.

The corresponding signal handler is `onReleased`.

Note: The corresponding handler is `onReleased`.

## Method Documentation

BarSet append(string label, VariantList values)

Adds a new bar set with label and values to the index. values is a list of real values.

For example:

     myBarSeries.append("set 1", [0, 0.2, 0.2, 0.5, 0.4, 1.5, 0.9]);

BarSet at(int index)

Returns the bar set at index. Returns null if the index is not valid.

clear()

Removes all bar sets from the series.

BarSet insert(int index, string label, VariantList values)

Adds a new bar set with label and values to index. values can be a list of real values or a list of XYPoint types.

If the index value is equal to or less than zero, the new bar set is prepended to the bar series. If the index value is equal to or greater than the number of bar sets in the bar series, the new bar set is appended to the bar series.

See also append().

bool remove(BarSet barset)

Removes the bar set specified by barset from the series. Returns `true` if successful, `false` otherwise.