PieSeries QML Type

Presents data in pie graphs. 更多...

import 语句: import QtGraphs
在 C++: QPieSeries
继承:

AbstractSeries

特性

信号

方法

详细描述

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.

import QtQuick
import QtGraphs
Item {
    id: mainView
    width: 1280
    height: 720
    GraphsView {
        anchors.fill: parent
        theme: GraphsTheme {
             colorScheme: GraphsTheme.ColorScheme.Dark
             theme: GraphsTheme.Theme.QtGreen
        }
        PieSeries {
            id: pieSeries
            PieSlice {
                value: 1
            }
            PieSlice {
                value: 2
            }
        }
    }
}
					

另请参阅 PieSlice and GraphsView .

特性文档编制

angleSpanLabelVisibility : enumeration [since 6.10]

The mode for label visibility.

The mode which determines which labels will be hidden if they are under the angle span limit set with angleSpanVisibleLimit . Has no effect if angleSpanVisibleLimit has not been set.

常量 描述
PieSeries.LabelVisibility.None All of the labels of slices with smaller angle span than the angleSpanVisibleLimit will be hidden.
PieSeries.LabelVisibility.First All except the first label of consecutive slices with smaller angle span than the angleSpanVisibleLimit will be hidden. This is the default value.
PieSeries.LabelVisibility.Even Every other label of consecutive slices with smaller angle span than the angleSpanVisibleLimit will be hidden, starting from the second one.
PieSeries.LabelVisibility.Odd Every other label of consecutive slices with smaller angle span than the angleSpanVisibleLimit will be hidden, starting from the first one.

此特性在 Qt 6.10 引入。

另请参阅 angleSpanVisibleLimit .

angleSpanVisibleLimit : real [since 6.10]

The angle span limit for label visibility.

The angle span that will be used as the visibility limit for a slice label. A slice with angle span under this value will change its visibility based on the angleSpanLabelVisibility set to the series. The default value is 0 , which means no slices will be hidden regardless of the angleSpanLabelVisibility .

此特性在 Qt 6.10 引入。

另请参阅 angleSpanLabelVisibility .

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.

holeSize : real

The donut hole size.

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

The default value is 0.0.

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

另请参阅 verticalPosition .

pieSize : real

The pie size.

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

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

当设置此特性时, 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.

默认值为 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).

另请参阅 horizontalPosition .

信号文档编制

添加 ( list < PieSlice > slices )

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

注意: 相应处理程序是 onAdded .

[since 6.10] angleSpanLabelVisibilityChanged ( LabelVisibility visibility )

This signal is emitted when the angle span limit visible mode has been changed. The visibility parameter holds the new visible mode.

注意: 相应处理程序是 onAngleSpanLabelVisibilityChanged .

This signal was introduced in Qt 6.10.

[since 6.10] angleSpanVisibleLimitChanged ( real limit )

This signal is emitted when the angle span limit has been changed. The limit parameter holds the new limit.

注意: 相应处理程序是 onAngleSpanVisibleLimitChanged .

This signal was introduced in Qt 6.10.

clicked ( PieSlice slice )

此信号发射,当 slice is clicked or tapped.

注意: 相应处理程序是 onClicked .

countChanged ()

This signal is emitted when the slice count changes.

注意: 相应处理程序是 onCountChanged .

另请参阅 count .

doubleClicked ( PieSlice slice )

此信号发射,当 slice is double-clicked or double-tapped. This signal always occurs after clicked .

注意: 相应处理程序是 onDoubleClicked .

endAngleChanged ()

This signal is emitted when the pie end angle changes.

注意: 相应处理程序是 onEndAngleChanged .

另请参阅 endAngle .

holeSizeChanged ()

This signal is emitted when the donut hole size changes.

注意: 相应处理程序是 onHoleSizeChanged .

另请参阅 holeSize .

horizontalPositionChanged ()

This signal is emitted when the horizontal position changes.

注意: 相应处理程序是 onHorizontalPositionChanged .

另请参阅 horizontalPosition .

pieSizeChanged ()

This signal is emitted when the pie size changes.

注意: 相应处理程序是 onPieSizeChanged .

另请参阅 pieSize .

pressed ( PieSlice slice )

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

注意: 相应处理程序是 onPressed .

released ( PieSlice slice )

This signal is emitted when the user releases a previously pressed mouse button or gesture on the slice .

注意: 相应处理程序是 onReleased .

removed ( list < PieSlice > slices )

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

注意: 相应处理程序是 onRemoved .

startAngleChanged ()

This signal is emitted when the pie start angle changes.

注意: 相应处理程序是 onStartAngleChanged .

另请参阅 startAngle .

sumChanged ()

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

注意: 相应处理程序是 onSumChanged .

另请参阅 sum .

verticalPositionChanged ()

This signal is emitted when the vertical position changes.

注意: 相应处理程序是 onVerticalPositionChanged .

另请参阅 verticalPosition .

方法文档编制

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 否则。

bool remove ( int index )

Removes the slice specified by index from the pie. Returns true if the removal was successful, false 否则。

void removeMultiple ( int index , int count )

Removes a range of slices as specified by the index and count . The call traverses over all slices even if removal of one fails.

bool replace ( list < PieSlice > slices )

Completely replaces all current slices with slices . The size does not need to match. Returns false if any of the PieSlice in slices 无效。

bool replace ( PieSlice oldSlice , PieSlice newSlice )

Replaces the slice specified by oldSlice with newSlice. Returns true if the removal was successful, false 否则。 oldSlice is destroyed if this is successful.

bool replace ( int index , PieSlice slice )

Replaces the slice specified by slice from the pie at index 。返回 true if the replace was successful, false 否则。

bool take ( PieSlice slice )

Takes a single slice, specified by slice , from the series. Does not delete the slice object. Returns true 若成功。