PySide6.QtGraphs.QBarSeries

class QBarSeries

The QBarSeries class presents data in bar graphs. More

Inheritance diagram of PySide6.QtGraphs.QBarSeries

Synopsis

Properties

  • barDelegateᅟ - A custom QML component used for visualizing each of the bars. Instance of this component is created for each of the bar. When this is not defined, a default rectangle visualization for bars is used

  • barSetsᅟ - A list of sets added to the series

  • barWidthᅟ - Width of the bars of the series

  • barsTypeᅟ - Type of the bar series

  • borderColorsᅟ - List of border colors to be used for all the objects in the series

  • countᅟ - Number of bar sets in a bar series

  • labelsAngleᅟ - Angle of the value labels in degrees

  • labelsFormatᅟ - Format used for showing labels in a bar series

  • labelsMarginᅟ - Margin of the value labels in pixels

  • labelsPositionᅟ - Position of value labels

  • labelsPrecisionᅟ - Maximum amount of significant digits shown in value labels

  • labelsVisibleᅟ - Visibility of the labels in a bar series. The default label visibility is false

  • seriesColorsᅟ - List of base colors to be used for all the objects in the series

Methods

Slots

Signals

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description

This class 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.

A bar series needs the GraphsView x-axis to be set to a BarCategoryAxis and the y-axis set to ValueAxis .

class LabelsPosition

This enum value describes the position of the data value labels:

Constant

Description

QBarSeries.LabelsPosition.LabelsPosition.Center

Label is located in the center of the bar.

QBarSeries.LabelsPosition.LabelsPosition.InsideEnd

Label is located inside the bar at the top.

QBarSeries.LabelsPosition.LabelsPosition.InsideBase

Label is located inside the bar at the bottom.

QBarSeries.LabelsPosition.LabelsPosition.OutsideEnd

Label is located outside the bar at the top.

class BarsType

This enum value describes the type of the bar series:

Constant

Description

QBarSeries.BarsType.BarsType.Groups

Bar sets are grouped by category.

QBarSeries.BarsType.BarsType.Stacked

Bar sets are stacked after each other by category.

QBarSeries.BarsType.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.

Added in version 6.8.

Note

Properties can be used directly when from __feature__ import true_property is used or via accessor functions otherwise.

property barDelegateᅟ: QQmlComponent

This property holds A custom QML component used for visualizing each of the bars. Instance of this component is created for each of the bar. When this is not defined, a default rectangle visualization for bars is used..

The dynamic properties available for this component are:

Type

Name

Description

QColor

barColor

The fill color of the bar. This value comes either from the QGraphsTheme or from color if the QBarSet overrides the color.

QColor

barBorderColor

The border color of the bar. This value comes either from the QGraphsTheme or from borderColor if the QBarSet overrides the color.

qreal

barBorderWidth

The width of the bar border. This value comes either from the QGraphsTheme or from borderWidth if the QBarSet overrides the width.

qreal

barValue

The value of the bar. This value comes from the values .

QString

barLabel

The label of the bar. This value comes from the label .

bool

barSelected

This value is true when the bar is selected, meaning that the bar index is in selectedBars .

int

barIndex

Index of the bar, from 0 to the amount of bars - 1. [since 6.9]

To use any of these, add property with the defined name into your custom component. For example "property color barColor" and "property real barValue".

Access functions:
property barSetsᅟ: list of QBarSet

This property holds A list of sets added to the series..

Access functions:
property barWidthᅟ: float

This property holds The width of the bars of the series..

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 QBarSeries , this value specifies the width of a group of bars instead of that of a single bar.

See also

QBarSeries

Access functions:
property barsTypeᅟ: QBarSeries.BarsType

This property holds The type of the bar series..

Access functions:
property borderColorsᅟ: list of QColor

This property holds The list of border colors to be used for all the objects in the series..

If there are more series than colors, the color list wraps and starts again with the first color in the list. If this is not set (default), colors from the borderColors will be used.

Access functions:
property countᅟ: int

This property holds The number of bar sets in a bar series..

Access functions:
property labelsAngleᅟ: float

This property holds The angle of the value labels in degrees..

Access functions:
property labelsFormatᅟ: str

This property holds The format used for showing labels in a bar series..

QBarSeries supports the following format tag:

@value

The value of the bar

For example, the following usage of the format tags would produce labels that show the value followed by the unit (u):

series->setLabelsFormat("@value u");

By default, the labels show the value of the bar. For the percent bar series, % is added after the value. The labels are shown on the plot area, if the bars are close to each other, the labels may overlap.

Access functions:
property labelsMarginᅟ: float

This property holds 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.

Access functions:
property labelsPositionᅟ: QBarSeries.LabelsPosition

This property holds The position of value labels..

Access functions:
property labelsPrecisionᅟ: int

This property holds The maximum amount of significant digits shown in value labels..

Default value is 6.

Access functions:
property labelsVisibleᅟ: bool

This property holds The visibility of the labels in a bar series. The default label visibility is false..

Access functions:
property seriesColorsᅟ: list of QColor

This property holds The list of base colors to be used for all the objects in the series..

If there are more series than colors, the color list wraps and starts again with the first color in the list. If this is not set (default), colors from the seriesColors will be used.

Access functions:
__init__([parent=None])
Parameters:

parentQObject

Constructs an empty bar series that is a QObject and a child of parent.

append(set)
Parameters:

setQBarSet

Return type:

bool

Adds a set of bars specified by set to the bar series and takes ownership of it. If the set is null or it already belongs to the series, it will not be appended. Returns true if appending succeeded.

append(sets)
Parameters:

sets – .list of QBarSet

Return type:

bool

Adds a list of bar sets specified by sets to a bar series and takes ownership of the sets. Returns true if all sets were appended successfully. If any of the sets is null or was previously appended to the series, nothing is appended and this function returns false. If any of the sets appears in the list more than once, nothing is appended and this function returns false.

at(index)
Parameters:

index – int

Return type:

QBarSet

Retrieves the BarSet specified at the location index. Returns null if no BarSet was found.

barDelegate()
Return type:

QQmlComponent

See also

setBarDelegate()

Getter of property barDelegateᅟ .

barDelegateChanged()

Notification signal of property barDelegateᅟ .

barSets()
Return type:

.list of QBarSet

Returns a list of bar sets in a bar series. Keeps the ownership of the bar sets.

Getter of property barSetsᅟ .

barSetsChanged()

Notification signal of property barSetsᅟ .

barWidth()
Return type:

float

Returns the width of the bars of the series.

See also

setBarWidth()

Getter of property barWidthᅟ .

barWidthChanged()

Notification signal of property barWidthᅟ .

barsType()
Return type:

BarsType

See also

setBarsType()

Getter of property barsTypeᅟ .

barsTypeChanged(type)
Parameters:

typeBarsType

Notification signal of property barsTypeᅟ .

barsetsAdded(sets)
Parameters:

sets – .list of QBarSet

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

See also

append() insert()

barsetsRemoved(sets)
Parameters:

sets – .list of QBarSet

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

See also

remove()

barsetsReplaced(sets)
Parameters:

sets – .list of QBarSet

borderColors()
Return type:

.list of QColor

Getter of property borderColorsᅟ .

borderColorsChanged()

Notification signal of property borderColorsᅟ .

clear()

Removes all bar sets from the series and permanently deletes them.

clicked(index, barset)
Parameters:
count()
Return type:

int

Returns the number of bar sets in a bar series.

Getter of property countᅟ .

countChanged()

Notification signal of property countᅟ .

deselectAll()
doubleClicked(index, barset)
Parameters:
find(set)
Parameters:

setQBarSet

Return type:

int

Returns the index of the first BarSet found as defined by set. Returns -1 if no BarSet was found.

insert(index, set)
Parameters:
Return type:

bool

Inserts a bar set specified by set to a series at the position specified by index and takes ownership of the set. If the set is null or already belongs to the series, it will not be appended. Returns true if inserting succeeds.

labelsAngle()
Return type:

float

See also

setLabelsAngle()

Getter of property labelsAngleᅟ .

labelsAngleChanged(angle)
Parameters:

angle – float

Notification signal of property labelsAngleᅟ .

labelsFormat()
Return type:

str

Getter of property labelsFormatᅟ .

labelsFormatChanged(format)
Parameters:

format – str

Notification signal of property labelsFormatᅟ .

labelsMargin()
Return type:

float

Getter of property labelsMarginᅟ .

labelsMarginChanged(margin)
Parameters:

margin – float

Notification signal of property labelsMarginᅟ .

labelsPosition()
Return type:

LabelsPosition

Getter of property labelsPositionᅟ .

labelsPositionChanged(position)
Parameters:

positionLabelsPosition

Notification signal of property labelsPositionᅟ .

labelsPrecision()
Return type:

int

Getter of property labelsPrecisionᅟ .

labelsPrecisionChanged(precision)
Parameters:

precision – int

Notification signal of property labelsPrecisionᅟ .

labelsVisible()
Return type:

bool

Returns the visibility of labels.

Getter of property labelsVisibleᅟ .

labelsVisibleChanged(visible)
Parameters:

visible – bool

This signal is emitted when the labels’ visibility changes to visible.

Notification signal of property labelsVisibleᅟ .

pressed(index, barset)
Parameters:
released(index, barset)
Parameters:
remove(set)
Parameters:

setQBarSet

Return type:

bool

Removes the bar set specified by set from the series and permanently deletes it if the removal succeeds. Returns true if the set was removed.

remove(index)
Parameters:

index – int

Return type:

bool

Removes the BarSet at the location index. The BarSet will be permanently deleted.

removeMultiple(index, count)
Parameters:
  • index – int

  • count – int

Removes multiple BarSets from the series starting from index to a number of count. The BarSets will be permanently deleted.

replace(sets)
Parameters:

sets – .list of QBarSet

Return type:

bool

Replaces the entire BarSet list inside of this BarSeries with the BarSets specified by sets. All of the original BarSets will be permanently deleted. Returns true if all BarSets are replaced.

replace(oldValue, newValue)
Parameters:
Return type:

bool

Replaces the BarSet specified by oldValue with the one in newValue. The BarSet in oldValue will be permanently deleted if found inside the series. Returns true if the replace is successful.

replace(index, set)
Parameters:

Replaces the BarSet which is present at index with set. The original BarSet will be permanently deleted.

selectAll()
seriesColors()
Return type:

.list of QColor

Getter of property seriesColorsᅟ .

seriesColorsChanged()

Notification signal of property seriesColorsᅟ .

setBarDelegate(newBarDelegate)
Parameters:

newBarDelegateQQmlComponent

See also

barDelegate()

Setter of property barDelegateᅟ .

setBarWidth(width)
Parameters:

width – float

Sets the width of the bars of the series to width.

See also

barWidth()

Setter of property barWidthᅟ .

setBarsType(type)
Parameters:

typeBarsType

See also

barsType()

Setter of property barsTypeᅟ .

setBorderColors(newBorderColors)
Parameters:

newBorderColors – .list of QColor

See also

borderColors()

Setter of property borderColorsᅟ .

setLabelsAngle(angle)
Parameters:

angle – float

See also

labelsAngle()

Setter of property labelsAngleᅟ .

setLabelsFormat(format)
Parameters:

format – str

See also

labelsFormat()

Setter of property labelsFormatᅟ .

setLabelsMargin(margin)
Parameters:

margin – float

See also

labelsMargin()

Setter of property labelsMarginᅟ .

setLabelsPosition(position)
Parameters:

positionLabelsPosition

See also

labelsPosition()

Setter of property labelsPositionᅟ .

setLabelsPrecision(precision)
Parameters:

precision – int

Setter of property labelsPrecisionᅟ .

setLabelsVisible([visible=true])
Parameters:

visible – bool

Sets the visibility of labels in a bar series to visible.

See also

labelsVisible()

Setter of property labelsVisibleᅟ .

setSeriesColors(newSeriesColors)
Parameters:

newSeriesColors – .list of QColor

See also

seriesColors()

Setter of property seriesColorsᅟ .

setValueAdded(index, count, barset)
Parameters:
  • index – int

  • count – int

  • barsetQBarSet

This signal is emitted when a barset’s value is changed. index is the index of the barset in the series. The number of the added values is indicated count. The barset is a pointer to the changed set.

setValueChanged(index, barset)
Parameters:

This signal is emitted when a barset’s value is changed. index is the index of the barset in the series. The barset is a pointer to the changed set.

setValueRemoved(index, count, barset)
Parameters:
  • index – int

  • count – int

  • barsetQBarSet

This signal is emitted when a barset’s value is changed. index is the index of the barset in the series. The number of the removed values is indicated count. The barset is a pointer to the changed set.

take(set)
Parameters:

setQBarSet

Return type:

bool

Takes a single set from the series. Does not delete the bar set object.

Note

The series remains the barset’s parent object. You must set the parent object to take full ownership.

Returns true if the take operation succeeds.

updatedBars()

This signal is emitted when bars are updated.