PieSeries QML Type

The PieSeries type is used for making pie charts. More...

Import Statement: import QtCharts 2.2
Instantiates: QPieSeries
Inherits:

AbstractSeries

Properties

Signals

Methods

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

Detailed Description

The following QML shows how to create a simple pie chart.

ChartView {
    id: chart
    title: "Top-5 car brand shares in Finland"
    anchors.fill: parent
    legend.alignment: Qt.AlignBottom
    antialiasing: true

    PieSeries {
        id: pieSeries
        PieSlice { label: "Volkswagen"; value: 13.5 }
        PieSlice { label: "Toyota"; value: 10.9 }
        PieSlice { label: "Ford"; value: 8.6 }
        PieSlice { label: "Skoda"; value: 8.2 }
        PieSlice { label: "Volvo"; value: 6.8 }
    }
}

Component.onCompleted: {
    // You can also manipulate slices dynamically
    othersSlice = pieSeries.append("Others", 52.0);
    pieSeries.find("Volkswagen").exploded = true;
}


Property Documentation

count : int

Number of slices in the series.


endAngle : real

Defines the ending angle of the pie.

Full pie is 360 degrees where 0 degrees is at 12 a'clock.

Default is value is 360.


holeSize : real

Defines the donut hole size.

The value is a relative value to the chart rectangle where:

  • 0.0 is the minimum size (full pie drawn, without any hole inside).
  • 1.0 is the maximum size that can fit the chart. (donut has no width)

When setting this property the size property is adjusted if necessary, to ensure that the inner size is not greater than the outer size.

Default value is 0.0.


horizontalPosition : real

Defines the horizontal position of the pie.

The value is a relative value to the chart rectangle where:

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

Default value is 0.5 (center).

See also verticalPosition.


size : real

Defines the pie size.

The value is a relative value to the chart rectangle where:

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

Default value is 0.7.


startAngle : real

Defines the starting angle of the pie.

Full pie is 360 degrees where 0 degrees is at 12 a'clock.

Default is value is 0.


sum : real

Sum of all slices.

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


verticalPosition : real

Defines the vertical position of the pie.

The value is a relative value to the chart rectangle where:

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

Default value is 0.5 (center).

See also horizontalPosition.


Signal Documentation

onAdded(list<PieSlice> slices)

Emitted when slices have been added to the series.


onClicked(PieSlice slice)

This signal is emitted when a slice has been clicked.


onCountChanged()

Emitted when the slice count has changed.


onDoubleClicked(PieSlice slice)

This signal is emitted when a slice has been doubleClicked.


onHovered(PieSlice slice, bool state)

This signal is emitted when user has hovered over or away from the slice. state is true when user has hovered over the slice and false when hover has moved away from the slice.


onPressed(PieSlice slice)

This signal is emitted when a slice has been pressed.


onReleased(PieSlice slice)

This signal is emitted when a slice has been released.


onRemoved(list<PieSlice> slices)

Emitted when slices have been removed from the series.


onSliceAdded(PieSlice slice)

Emitted when slice has been added to the series.


onSliceRemoved(PieSlice slice)

Emitted when slice has been removed from the series.


onSumChanged()

Emitted when the sum of all slices has changed. This may happen for example if you add or remove slices, or if you change value of a slice.


Method Documentation

PieSlice append(string label, real value)

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


PieSlice at(int index)

Returns slice at index. Returns null if the index is not valid.


clear()

Removes all slices from the pie.


PieSlice find(string label)

Returns the first slice with label. Returns null if the index is not valid.


bool remove(PieSlice slice)

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


© 2017 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.