class QPieSlice#

The QPieSlice class represents a single slice in a pie series. More

Inheritance diagram of PySide6.QtCharts.QPieSlice

Synopsis#

Properties#

  • angleSpanᅟ - Span of the slice in degrees. A full pie is 360 degrees, where 0 degrees is at 12 a’clock. Updated automatically once the slice is added to the series

  • borderColorᅟ - Color used to draw the slice border. This is a convenience property for modifying the slice pen

  • borderWidthᅟ - Width of the slice border. This is a convenience property for modifying the slice pen

  • brushᅟ - Used to fill the slice

  • colorᅟ - Fill (brush) color of the slice. This is a convenience property for modifying the slice brush

  • explodeDistanceFactorᅟ - Determines how far away from the pie the slice is exploded

  • explodedᅟ - Whether the slice is separated from the pie

  • labelᅟ - Of the slice

  • labelArmLengthFactorᅟ - Length of the label arm. The factor is relative to the pie radius. For example:

  • labelBrushᅟ - Brush used to draw the label and label arm of the slice

  • labelColorᅟ - Color used to draw the slice label. This is a convenience property for modifying the slice label brush

  • labelFontᅟ - Font used for drawing the label text

  • labelPositionᅟ - Position of the slice label

  • labelVisibleᅟ - Visibility of the slice label. By default, the label is not visible

  • penᅟ - Used to draw the slice border

  • percentageᅟ - Of the slice compared to the sum of all slices in the series. The actual value ranges from 0.0 to 1.0. Updated automatically once the slice is added to the series

  • startAngleᅟ - Starting angle of this slice in the series it belongs to. A full pie is 360 degrees, where 0 degrees is at 12 a’clock. Updated automatically once the slice is added to the series

  • valueᅟ - Of the slice

Methods#

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#

A pie slice has a value and a label. When the slice is added to a pie series, the QPieSeries object calculates the percentage of the slice compared with the sum of all slices in the series to determine the actual size of the slice in the chart.

By default, the label is hidden. If it is visible, it can be either located outside the slice and connected to it with an arm or centered inside the slice either horizontally or in parallel with the tangential or normal of the slice’s arc.

By default, the visual appearance of the slice is set by a theme, but the theme can be overridden by specifying slice properties. However, if the theme is changed after the slices are customized, all customization will be lost.

To enable user interaction with the pie chart, some basic signals are emitted when users click pie slices or hover the mouse over them.

See also

QPieSeries

class LabelPosition#

This enum describes the position of the slice label.

Constant

Description

QPieSlice.LabelOutside

The label is located outside the slice connected to it with an arm. This is the default value.

QPieSlice.LabelInsideHorizontal

The label is centered within the slice and laid out horizontally.

QPieSlice.LabelInsideTangential

The label is centered within the slice and rotated to be parallel with the tangential of the slice’s arc.

QPieSlice.LabelInsideNormal

The label is centered within the slice and rotated to be parallel with the normal of the slice’s arc.

Note

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

property angleSpanᅟ: float#

This property holds The span of the slice in degrees. A full pie is 360 degrees, where 0 degrees is at 12 a’clock. Updated automatically once the slice is added to the series..

Access functions:
property borderColorᅟ: QColor#

This property holds The color used to draw the slice border. This is a convenience property for modifying the slice pen..

See also

pen borderWidth

Access functions:
property borderWidthᅟ: int#

This property holds The width of the slice border. This is a convenience property for modifying the slice pen..

See also

pen borderColor

Access functions:
property brushᅟ: QBrush#

This property holds The brush used to fill the slice..

Access functions:
property colorᅟ: QColor#

This property holds The fill (brush) color of the slice. This is a convenience property for modifying the slice brush..

See also

brush

Access functions:
property explodeDistanceFactorᅟ: float#

This property Determines how far away from the pie the slice is exploded..

  • 1.0 means that the distance is the same as the radius.

  • 0.5 means that the distance is half of the radius.

By default, the distance is 0.15

See also

exploded

Access functions:
property explodedᅟ: bool#

This property holds Whether the slice is separated from the pie..

Access functions:
property labelᅟ: str#

This property holds The label of the slice..

Note

The string can be HTML formatted.

See also

labelVisible labelBrush labelFont labelArmLengthFactor

Access functions:
property labelArmLengthFactorᅟ: float#

This property holds The length of the label arm. The factor is relative to the pie radius. For example:.

  • 1.0 means that the length is the same as the radius.

  • 0.5 means that the length is half of the radius.

By default, the arm length is 0.15

See also

label labelVisible labelBrush labelFont

Access functions:
property labelBrushᅟ: QBrush#

This property holds The brush used to draw the label and label arm of the slice..

See also

label labelVisible labelFont labelArmLengthFactor

Access functions:
property labelColorᅟ: QColor#

This property holds The color used to draw the slice label. This is a convenience property for modifying the slice label brush..

See also

labelBrush

Access functions:
property labelFontᅟ: QFont#

This property holds The font used for drawing the label text..

See also

label labelVisible labelArmLengthFactor

Access functions:
property labelPositionᅟ: QPieSlice.LabelPosition#

This property holds The position of the slice label..

See also

label labelVisible

Access functions:
property labelVisibleᅟ: bool#

This property holds The visibility of the slice label. By default, the label is not visible..

Access functions:
property penᅟ: QPen#

This property holds The pen used to draw the slice border..

Access functions:
property percentageᅟ: float#

This property holds The percentage of the slice compared to the sum of all slices in the series. The actual value ranges from 0.0 to 1.0. Updated automatically once the slice is added to the series..

See also

value sum

Access functions:
property startAngleᅟ: float#

This property holds The starting angle of this slice in the series it belongs to. A full pie is 360 degrees, where 0 degrees is at 12 a’clock. Updated automatically once the slice is added to the series..

Access functions:
property valueᅟ: float#

This property holds The value of the slice..

Note

A negative value is converted to a positive value.

See also

percentage() sum()

Access functions:
__init__(label, value[, parent=None])#
Parameters:
  • label – str

  • value – float

  • parentQObject

Constructs an empty slice with the specified value, label, and parent.

See also

append() insert()

__init__([parent=None])
Parameters:

parentQObject

Constructs an empty slice with the parent parent.

See also

append() insert()

angleSpan()#
Return type:

float

Getter of property angleSpanᅟ .

angleSpanChanged()#

This signal is emitted when the angle span of the slice changes.

See also

angleSpan

Notification signal of property angleSpanᅟ .

borderColor()#
Return type:

QColor

See also

setBorderColor()

Getter of property borderColorᅟ .

borderColorChanged()#

This signal is emitted when the slice border color changes.

See also

pen borderColor

Notification signal of property borderColorᅟ .

borderWidth()#
Return type:

int

See also

setBorderWidth()

Getter of property borderWidthᅟ .

borderWidthChanged()#

This signal is emitted when the slice border width changes.

See also

pen borderWidth

Notification signal of property borderWidthᅟ .

brush()#
Return type:

QBrush

See also

setBrush()

Getter of property brushᅟ .

brushChanged()#

This signal is emitted when the brush used to fill the slice changes.

See also

brush

Notification signal of property brushᅟ .

clicked()#

This signal is emitted when the slice is clicked.

See also

clicked()

color()#
Return type:

QColor

See also

setColor()

Getter of property colorᅟ .

colorChanged()#

This signal is emitted when the slice color changes.

See also

brush

Notification signal of property colorᅟ .

doubleClicked()#

This signal is emitted when user double-clicks the slice.

See also

doubleClicked()

explodeDistanceFactor()#
Return type:

float

Getter of property explodeDistanceFactorᅟ .

hovered(state)#
Parameters:

state – bool

This signal is emitted when a mouse is hovered over the slice. When the mouse moves over the slice, state turns true, and when the mouse moves away again, it turns false.

See also

hovered()

isExploded()#
Return type:

bool

Getter of property explodedᅟ .

isLabelVisible()#
Return type:

bool

Getter of property labelVisibleᅟ .

label()#
Return type:

str

See also

setLabel()

Getter of property labelᅟ .

labelArmLengthFactor()#
Return type:

float

Getter of property labelArmLengthFactorᅟ .

labelBrush()#
Return type:

QBrush

See also

setLabelBrush()

Getter of property labelBrushᅟ .

labelBrushChanged()#

This signal is emitted when the label brush of the slice changes.

See also

labelBrush

Notification signal of property labelBrushᅟ .

labelChanged()#

This signal is emitted when the slice label changes.

See also

label

Notification signal of property labelᅟ .

labelColor()#
Return type:

QColor

See also

setLabelColor()

Getter of property labelColorᅟ .

labelColorChanged()#

This signal is emitted when the slice label color changes.

See also

labelColor

Notification signal of property labelColorᅟ .

labelFont()#
Return type:

QFont

See also

setLabelFont()

Getter of property labelFontᅟ .

labelFontChanged()#

This signal is emitted when the label font of the slice changes.

See also

labelFont

Notification signal of property labelFontᅟ .

labelPosition()#
Return type:

LabelPosition

Getter of property labelPositionᅟ .

labelVisibleChanged()#

This signal is emitted when the visibility of the slice label changes.

See also

labelVisible

Notification signal of property labelVisibleᅟ .

pen()#
Return type:

QPen

See also

setPen()

Getter of property penᅟ .

penChanged()#

This signal is emitted when the pen used to draw the slice border changes.

See also

pen

Notification signal of property penᅟ .

percentage()#
Return type:

float

Getter of property percentageᅟ .

percentageChanged()#

This signal is emitted when the percentage of the slice changes.

See also

percentage

Notification signal of property percentageᅟ .

pressed()#

This signal is emitted when the user clicks the slice and holds down the mouse button.

See also

pressed()

released()#

This signal is emitted when the user releases the mouse press on the slice.

See also

released()

series()#
Return type:

QPieSeries

Returns the series that this slice belongs to.

See also

append()

setBorderColor(color)#
Parameters:

colorQColor

See also

borderColor()

Setter of property borderColorᅟ .

setBorderWidth(width)#
Parameters:

width – int

See also

borderWidth()

Setter of property borderWidthᅟ .

setBrush(brush)#
Parameters:

brushQBrush

See also

brush()

Setter of property brushᅟ .

setColor(color)#
Parameters:

colorQColor

See also

color()

Setter of property colorᅟ .

setExplodeDistanceFactor(factor)#
Parameters:

factor – float

Setter of property explodeDistanceFactorᅟ .

setExploded([exploded=true])#
Parameters:

exploded – bool

See also

isExploded()

Setter of property explodedᅟ .

setLabel(label)#
Parameters:

label – str

See also

label()

Setter of property labelᅟ .

setLabelArmLengthFactor(factor)#
Parameters:

factor – float

Setter of property labelArmLengthFactorᅟ .

setLabelBrush(brush)#
Parameters:

brushQBrush

See also

labelBrush()

Setter of property labelBrushᅟ .

setLabelColor(color)#
Parameters:

colorQColor

See also

labelColor()

Setter of property labelColorᅟ .

setLabelFont(font)#
Parameters:

fontQFont

See also

labelFont()

Setter of property labelFontᅟ .

setLabelPosition(position)#
Parameters:

positionLabelPosition

See also

labelPosition()

Setter of property labelPositionᅟ .

setLabelVisible([visible=true])#
Parameters:

visible – bool

See also

isLabelVisible()

Setter of property labelVisibleᅟ .

setPen(pen)#
Parameters:

penQPen

See also

pen()

Setter of property penᅟ .

setValue(value)#
Parameters:

value – float

See also

value()

Setter of property valueᅟ .

startAngle()#
Return type:

float

Getter of property startAngleᅟ .

startAngleChanged()#

This signal is emitted when the starting angle of the slice changes.

See also

startAngle

Notification signal of property startAngleᅟ .

value()#
Return type:

float

See also

setValue()

Getter of property valueᅟ .

valueChanged()#

This signal is emitted when the slice value changes.

See also

value

Notification signal of property valueᅟ .