PySide6.QtGraphs.QBarSeries¶
- class QBarSeries¶
The
QBarSeries
class presents data in bar graphs. More…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 usedbarSetsᅟ
- A list of sets added to the seriesbarWidthᅟ
- Width of the bars of the seriesbarsTypeᅟ
- Type of the bar seriesborderColorsᅟ
- List of border colors to be used for all the objects in the seriescountᅟ
- Number of bar sets in a bar serieslabelsAngleᅟ
- Angle of the value labels in degreeslabelsFormatᅟ
- Format used for showing labels in a bar serieslabelsMarginᅟ
- Margin of the value labels in pixelslabelsPositionᅟ
- Position of value labelslabelsPrecisionᅟ
- Maximum amount of significant digits shown in value labelslabelsVisibleᅟ
- Visibility of the labels in a bar series. The default label visibility is falseseriesColorsᅟ
- List of base colors to be used for all the objects in the series
Methods¶
def
__init__()
def
append()
def
at()
def
barDelegate()
def
barSets()
def
barWidth()
def
barsType()
def
borderColors()
def
clear()
def
count()
def
find()
def
insert()
def
labelsAngle()
def
labelsFormat()
def
labelsMargin()
def
labelsPosition()
def
labelsVisible()
def
remove()
def
removeMultiple()
def
replace()
def
seriesColors()
def
setBarDelegate()
def
setBarWidth()
def
setBarsType()
def
setLabelsAngle()
def
take()
Slots¶
def
deselectAll()
def
selectAll()
Signals¶
def
barSetsChanged()
def
barsetsAdded()
def
barsetsRemoved()
def
clicked()
def
countChanged()
def
doubleClicked()
def
pressed()
def
released()
def
setValueAdded()
def
updatedBars()
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 .
See also
- 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 fromcolor
if theQBarSet
overrides the color.QColor
barBorderColor
The border color of the bar. This value comes either from the
QGraphsTheme
or fromborderColor
if theQBarSet
overrides the color.qreal
barBorderWidth
The width of the bar border. This value comes either from the
QGraphsTheme
or fromborderWidth
if theQBarSet
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:
Signal
barSetsChanged()
- 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
- 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:
Signal
countChanged()
- 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.
See also
- 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 thanLabelsPosition.Center
. The default value is0
.- Access functions:
- property labelsPositionᅟ: QBarSeries.LabelsPosition¶
This property holds The position of value labels..
See also
- 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:
Constructs an empty bar series that is a QObject and a child of
parent
.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. Returnstrue
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. Returnstrue
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 returnsfalse
. If any of the sets appears in the list more than once, nothing is appended and this function returnsfalse
.Retrieves the BarSet specified at the location
index
. Returns null if no BarSet was found.- barDelegate()¶
- Return type:
See also
Getter of property
barDelegateᅟ
.- barDelegateChanged()¶
Notification signal of property
barDelegateᅟ
.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
Getter of property
barWidthᅟ
.- barWidthChanged()¶
Notification signal of property
barWidthᅟ
.- barsType()¶
- Return type:
See also
Getter of property
barsTypeᅟ
.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.- 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
- barsetsReplaced(sets)¶
- Parameters:
sets – .list of QBarSet
Getter of property
borderColorsᅟ
.- borderColorsChanged()¶
Notification signal of property
borderColorsᅟ
.- clear()¶
Removes all bar sets from the series and permanently deletes them.
- 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()¶
Returns the index of the first BarSet found as defined by
set
. Returns -1 if no BarSet was found.Inserts a bar set specified by
set
to a series at the position specified byindex
and takes ownership of the set. If the set is null or already belongs to the series, it will not be appended. Returnstrue
if inserting succeeds.- labelsAngle()¶
- Return type:
float
See also
Getter of property
labelsAngleᅟ
.- labelsAngleChanged(angle)¶
- Parameters:
angle – float
Notification signal of property
labelsAngleᅟ
.- labelsFormat()¶
- Return type:
str
See also
Getter of property
labelsFormatᅟ
.- labelsFormatChanged(format)¶
- Parameters:
format – str
Notification signal of property
labelsFormatᅟ
.- labelsMargin()¶
- Return type:
float
See also
Getter of property
labelsMarginᅟ
.- labelsMarginChanged(margin)¶
- Parameters:
margin – float
Notification signal of property
labelsMarginᅟ
.- labelsPosition()¶
- Return type:
See also
Getter of property
labelsPositionᅟ
.- labelsPositionChanged(position)¶
- Parameters:
position –
LabelsPosition
Notification signal of property
labelsPositionᅟ
.- labelsPrecision()¶
- Return type:
int
See also
Getter of property
labelsPrecisionᅟ
.- labelsPrecisionChanged(precision)¶
- Parameters:
precision – int
Notification signal of property
labelsPrecisionᅟ
.- labelsVisible()¶
- Return type:
bool
Returns the visibility of labels.
See also
Getter of property
labelsVisibleᅟ
.- labelsVisibleChanged(visible)¶
- Parameters:
visible – bool
This signal is emitted when the labels’ visibility changes to
visible
.See also
Notification signal of property
labelsVisibleᅟ
.Removes the bar set specified by
set
from the series and permanently deletes it if the removal succeeds. Returnstrue
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 ofcount
. 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. Returnstrue
if all BarSets are replaced.Replaces the BarSet specified by
oldValue
with the one innewValue
. The BarSet inoldValue
will be permanently deleted if found inside the series. Returnstrue
if the replace is successful.- replace(index, set)
- Parameters:
index – int
set –
QBarSet
Replaces the BarSet which is present at
index
withset
. The original BarSet will be permanently deleted.- selectAll()¶
Getter of property
seriesColorsᅟ
.- seriesColorsChanged()¶
Notification signal of property
seriesColorsᅟ
.- setBarDelegate(newBarDelegate)¶
- Parameters:
newBarDelegate –
QQmlComponent
See also
Setter of property
barDelegateᅟ
.- setBarWidth(width)¶
- Parameters:
width – float
Sets the width of the bars of the series to
width
.See also
Setter of property
barWidthᅟ
.Setter of property
barsTypeᅟ
.- setBorderColors(newBorderColors)¶
- Parameters:
newBorderColors – .list of QColor
See also
Setter of property
borderColorsᅟ
.- setLabelsAngle(angle)¶
- Parameters:
angle – float
See also
Setter of property
labelsAngleᅟ
.- setLabelsFormat(format)¶
- Parameters:
format – str
See also
Setter of property
labelsFormatᅟ
.- setLabelsMargin(margin)¶
- Parameters:
margin – float
See also
Setter of property
labelsMarginᅟ
.- setLabelsPosition(position)¶
- Parameters:
position –
LabelsPosition
See also
Setter of property
labelsPositionᅟ
.- setLabelsPrecision(precision)¶
- Parameters:
precision – int
See also
Setter of property
labelsPrecisionᅟ
.- setLabelsVisible([visible=true])¶
- Parameters:
visible – bool
Sets the visibility of labels in a bar series to
visible
.See also
Setter of property
labelsVisibleᅟ
.- setSeriesColors(newSeriesColors)¶
- Parameters:
newSeriesColors – .list of QColor
See also
Setter of property
seriesColorsᅟ
.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 indicatedcount
. Thebarset
is a pointer to the changed set.This signal is emitted when a barset’s value is changed.
index
is the index of the barset in the series. Thebarset
is a pointer to the changed set.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 indicatedcount
. Thebarset
is a pointer to the changed set.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.