- Qt 6.11
- Qt Charts
- QML Types
- BarSet
- Qt Charts | Commercial or GPLv3

# BarSet QML Type

Represents one set of bars in a bar chart. More...

Import Statement: | `import QtCharts 2.11`
In C++: | QBarSet

- List of all members, including inherited members

## Properties

- borderColor : color
- borderWidth : real
- brushFilename : string
- color : color
- count : int
- label : string
- labelColor : color
- labelFont : font
- values : list<var>

## Signals

- clicked(int index)
- doubleClicked(int index)
- pressed(int index)
- released(int index)
- valueChanged(int index)
- valuesAdded(int index, int count)
- valuesRemoved(int index, int count)

## Methods

- void append(real value)
- real at(int index)
- void remove(int index, int count)
- void replace(int index, real value)

## Detailed Description

A bar set contains one data value for each category. The first value of a set is assumed to belong to the first category, the second one to the second category, and so on. If the set has fewer values than there are categories, the missing values are assumed to be located at the end of the set. For missing values in the middle of a set, the numerical value of zero is used. Labels for zero value sets are not shown.

See also AbstractBarSeries, BarSeries, StackedBarSeries, PercentBarSeries, HorizontalBarSeries, HorizontalStackedBarSeries, and HorizontalPercentBarSeries.

## Property Documentation

### borderColor : color

The line (pen) color of the bar set.

### borderWidth : real

The width of the border line. By default, the width is 2.0.

### brushFilename : string

The name of the file used as a brush for the set.

### color : color

The fill (brush) color of the bar set.

### count : int

The number of values in the bar set.

### label : string

The label of the bar set.

### labelColor : color

The text (label) color of the bar set.

### labelFont : font

The font used to draw the bar set's label.

For more information, see font.

### values : list<var>

The values of the bar set. You can set a list of either real or point types as values.

If you set a list of real types as values, they directly define the bar set values.

If you set a list of point types as values, the x-coordinate of the point specifies its zero-based index in the bar set. The size of the bar set is the highest x-coordinate value + 1. If a point is missing for any x-coordinate between zero and the highest value, it gets the value zero.

For example, the following bar sets have equal values:

     myBarSet1.values = [5, 0, 1, 5];
     myBarSet2.values = [Qt.point(0, 5), Qt.point(2, 1), Qt.point(3, 5)];

## Signal Documentation

### clicked(int index)

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

The corresponding signal handler is `onClicked`.

Note: The corresponding handler is `onClicked`.

### doubleClicked(int index)

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

The corresponding signal handler is `onDoubleClicked`.

Note: The corresponding handler is `onDoubleClicked`.

### pressed(int index)

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

The corresponding signal handler is `onPressed`.

Note: The corresponding handler is `onPressed`.

### released(int index)

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

The corresponding signal handler is `onReleased`.

Note: The corresponding handler is `onReleased`.

### valueChanged(int index)

This signal is emitted when the value at the position specified by index is modified.

The corresponding signal handler is `onValueChanged`.

Note: The corresponding handler is `onValueChanged`.

### valuesAdded(int index, int count)

This signal is emitted when new values are added to the bar set. index indicates the position of the first inserted value, and count is the number of inserted values.

The corresponding signal handler is `onValuesAdded`.

Note: The corresponding handler is `onValuesAdded`.

### valuesRemoved(int index, int count)

This signal is emitted when values are removed from the bar set. index indicates the position of the first removed value, and count is the number of removed values.

The corresponding signal handler is `onValuesRemoved`.

Note: The corresponding handler is `onValuesRemoved`.

## Method Documentation

### void append(real value)

Appends the new value specified by value to the end of the bar set.

### real at(int index)

Returns the value specified by index from the bar set. If the index is out of bounds, 0.0 is returned.

### void remove(int index, int count)

Removes the number of values specified by count from the bar set starting with the value specified by index.

If you leave out count, only the value specified by index is removed.

### void replace(int index, real value)

Adds the value specified by value to the bar set at the position specified by index.