QPieSlice

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

Inheritance diagram of PySide6.QtCharts.QPieSlice

Synopsis

Functions

Signals

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 PySide6.QtCharts.QPieSlice([parent=None])

PySide6.QtCharts.QPieSlice(label, value[, parent=None])

Parameters

Constructs an empty slice with the parent parent.

See also

append() insert()

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

See also

append() insert()

PySide6.QtCharts.QPieSlice.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.

PySide6.QtCharts.QPieSlice.angleSpan()
Return type

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

PySide6.QtCharts.QPieSlice.angleSpanChanged()
PySide6.QtCharts.QPieSlice.borderColor()
Return type

PySide6.QtGui.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

PySide6.QtCharts.QPieSlice.borderColorChanged()
PySide6.QtCharts.QPieSlice.borderWidth()
Return type

int

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

See also

pen borderColor

PySide6.QtCharts.QPieSlice.borderWidthChanged()
PySide6.QtCharts.QPieSlice.brush()
Return type

PySide6.QtGui.QBrush

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

PySide6.QtCharts.QPieSlice.brushChanged()
PySide6.QtCharts.QPieSlice.clicked()
PySide6.QtCharts.QPieSlice.color()
Return type

PySide6.QtGui.QColor

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

See also

brush

PySide6.QtCharts.QPieSlice.colorChanged()
PySide6.QtCharts.QPieSlice.doubleClicked()
PySide6.QtCharts.QPieSlice.explodeDistanceFactor()
Return type

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

PySide6.QtCharts.QPieSlice.hovered(state)
Parameters

state – bool

PySide6.QtCharts.QPieSlice.isExploded()
Return type

bool

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

PySide6.QtCharts.QPieSlice.isLabelVisible()
Return type

bool

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

PySide6.QtCharts.QPieSlice.label()
Return type

str

This property holds The label of the slice..

See also

labelVisible labelBrush labelFont labelArmLengthFactor

PySide6.QtCharts.QPieSlice.labelArmLengthFactor()
Return type

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

PySide6.QtCharts.QPieSlice.labelBrush()
Return type

PySide6.QtGui.QBrush

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

See also

label labelVisible labelFont labelArmLengthFactor

PySide6.QtCharts.QPieSlice.labelBrushChanged()
PySide6.QtCharts.QPieSlice.labelChanged()
PySide6.QtCharts.QPieSlice.labelColor()
Return type

PySide6.QtGui.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

PySide6.QtCharts.QPieSlice.labelColorChanged()
PySide6.QtCharts.QPieSlice.labelFont()
Return type

PySide6.QtGui.QFont

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

See also

label labelVisible labelArmLengthFactor

PySide6.QtCharts.QPieSlice.labelFontChanged()
PySide6.QtCharts.QPieSlice.labelPosition()
Return type

LabelPosition

This property holds The position of the slice label..

See also

label labelVisible

PySide6.QtCharts.QPieSlice.labelVisibleChanged()
PySide6.QtCharts.QPieSlice.pen()
Return type

PySide6.QtGui.QPen

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

PySide6.QtCharts.QPieSlice.penChanged()
PySide6.QtCharts.QPieSlice.percentage()
Return type

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

PySide6.QtCharts.QPieSlice.percentageChanged()
PySide6.QtCharts.QPieSlice.pressed()
PySide6.QtCharts.QPieSlice.released()
PySide6.QtCharts.QPieSlice.series()
Return type

PySide6.QtCharts.QPieSeries

Returns the series that this slice belongs to.

See also

append()

PySide6.QtCharts.QPieSlice.setBorderColor(color)
Parameters

colorPySide6.QtGui.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

PySide6.QtCharts.QPieSlice.setBorderWidth(width)
Parameters

width – int

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

See also

pen borderColor

PySide6.QtCharts.QPieSlice.setBrush(brush)
Parameters

brushPySide6.QtGui.QBrush

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

PySide6.QtCharts.QPieSlice.setColor(color)
Parameters

colorPySide6.QtGui.QColor

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

See also

brush

PySide6.QtCharts.QPieSlice.setExplodeDistanceFactor(factor)
Parameters

factor – 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

PySide6.QtCharts.QPieSlice.setExploded([exploded=true])
Parameters

exploded – bool

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

PySide6.QtCharts.QPieSlice.setLabel(label)
Parameters

label – str

This property holds The label of the slice..

See also

labelVisible labelBrush labelFont labelArmLengthFactor

PySide6.QtCharts.QPieSlice.setLabelArmLengthFactor(factor)
Parameters

factor – 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

PySide6.QtCharts.QPieSlice.setLabelBrush(brush)
Parameters

brushPySide6.QtGui.QBrush

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

See also

label labelVisible labelFont labelArmLengthFactor

PySide6.QtCharts.QPieSlice.setLabelColor(color)
Parameters

colorPySide6.QtGui.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

PySide6.QtCharts.QPieSlice.setLabelFont(font)
Parameters

fontPySide6.QtGui.QFont

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

See also

label labelVisible labelArmLengthFactor

PySide6.QtCharts.QPieSlice.setLabelPosition(position)
Parameters

positionLabelPosition

This property holds The position of the slice label..

See also

label labelVisible

PySide6.QtCharts.QPieSlice.setLabelVisible([visible=true])
Parameters

visible – bool

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

PySide6.QtCharts.QPieSlice.setPen(pen)
Parameters

penPySide6.QtGui.QPen

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

PySide6.QtCharts.QPieSlice.setValue(value)
Parameters

value – float

This property holds The value of the slice..

Note

A negative value is converted to a positive value.

See also

percentage() sum()

PySide6.QtCharts.QPieSlice.startAngle()
Return type

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

PySide6.QtCharts.QPieSlice.startAngleChanged()
PySide6.QtCharts.QPieSlice.value()
Return type

float

This property holds The value of the slice..

Note

A negative value is converted to a positive value.

See also

percentage() sum()

PySide6.QtCharts.QPieSlice.valueChanged()