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 .

特性文档编制

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 .

countChanged ()

This signal is emitted when the slice count changes.

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

另请参阅 count .

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 .

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 若成功。