- Qt 6.8
- Qt Graphs
- QML Types
- QtGraphs
- PieSeries
- Qt Graphs | Commercial or GPLv3

# PieSeries QML Type

Presents data in pie graphs. More...

Import Statement: | import QtGraphs
Instantiates: | QPieSeries
Inherits: | AbstractSeries

- List of all members, including inherited members
- PieSeries is part of Qt Graphs QML Types for 2D.

## Properties

- count : int
- endAngle : real
- horizontalPosition : real
- size : real
- startAngle : real
- sum : real
- verticalPosition : real

## Signals

- added(list<PieSlice> slices)
- countChanged()
- endAngleChanged()
- horizontalPositionChanged()
- removed(list<PieSlice> slices)
- sizeChanged()
- startAngleChanged()
- sumChanged()
- verticalPositionChanged()

## Methods

- PieSlice append(string label, real value)
- PieSlice at(int index)
- clear()
- PieSlice find(string label)
- bool remove(PieSlice slice)

## Detailed Description

A pie series consists of slices that are defined using the PieSlice type. The slices can have any values as the PieSeries type calculates the percentage of a slice compared with the sum of all slices in the series to determine the actual size of the slice in the graph.

Pie size and position on the graph are controlled by using relative values that range from 0.0 to 1.0. These relate to the actual graph rectangle.

By default, the pie is defined as a full pie. A partial pie can be created by setting a starting angle and angle span for the series. A full pie is 360 degrees, where 0 is at 12 o'clock.

The following QML example shows how to create a simple pie graph.

See also PieSlice and GraphsView.

## Property Documentation

count : int `[read-only]`

The number of slices in the series.

endAngle : real

The ending angle of the pie.

A full pie is 360 degrees, where 0 degrees is at 12 o'clock.

The default value is 360.

horizontalPosition : real

The horizontal position of the pie.

The value is relative to the graph rectangle, so that:

- 0.0 is the absolute left.
- 1.0 is the absolute right.

The default value is 0.5 (center).

See also verticalPosition.

size : real

The pie size.

The value is relative to the graph rectangle, so that:

- 0.0 is the minimum size (pie not drawn).
- 1.0 is the maximum size that can fit the graph.

When setting this property, the holeSize property is adjusted if necessary, to ensure that the hole size is not greater than the pie size.

The default value is 0.7.

startAngle : real

The starting angle of the pie.

A full pie is 360 degrees, where 0 degrees is at 12 o'clock.

The default value is 0.

sum : real `[read-only]`

The sum of all slices.

The series keeps track of the sum of all the slices it holds.

verticalPosition : real

The vertical position of the pie.

The value is relative to the graph rectangle, so that:

- 0.0 is the absolute top.
- 1.0 is the absolute bottom.

The default value is 0.5 (center).

See also horizontalPosition.

## Signal Documentation

added(list<PieSlice> slices)

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

Note: The corresponding handler is `onAdded`.

countChanged()

This signal is emitted when the slice count changes.

Note: The corresponding handler is `onCountChanged`.

See also count.

endAngleChanged()

This signal is emitted when the end angle changes.

Note: The corresponding handler is `onEndAngleChanged`.

See also endAngle.

horizontalPositionChanged()

This signal is emitted when the horizontal position changes.

Note: The corresponding handler is `onHorizontalPositionChanged`.

See also horizontalPosition.

removed(list<PieSlice> slices)

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

Note: The corresponding handler is `onRemoved`.

sizeChanged()

This signal is emitted when the size changes.

Note: The corresponding handler is `onSizeChanged`.

See also size.

startAngleChanged()

This signal is emitted when the start angle changes.

Note: The corresponding handler is `onStartAngleChanged`.

See also startAngle.

sumChanged()

This signal is emitted when the sum of all slices changes.

Note: The corresponding handler is `onSumChanged`.

See also sum.

verticalPositionChanged()

This signal is emitted when the vertical position changes.

Note: The corresponding handler is `onVerticalPositionChanged`.

See also verticalPosition.

## Method Documentation

PieSlice append(string label, real value)

Adds a new slice with the label label and the value value to the pie.

PieSlice at(int index)

Returns the slice at the position specified by index. Returns null if the index is not valid.

clear()

Removes all slices from the pie.

PieSlice find(string label)

Returns the first slice that has the label label. Returns null if the label is not found.

bool remove(PieSlice slice)

Removes the slice specified by slice from the pie. Returns `true` if the removal was successful, `false` otherwise.