<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qpieseries.cpp --> <title>PieSeries QML Type | Qt Charts 5.9</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css"); // loading style sheet breaks anchors that were jumped to before // so force jumping to anchor again setTimeout(function() { var anchor = location.hash; // need to jump to different anchor first (e.g. none) location.hash = "#"; setTimeout(function() { location.hash = anchor; }, 0); }, 0); </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td >Qt 5.9</td><td ><a href="qtcharts-index.html">Qt Charts</a></td><td ><a href="qtcharts-qmlmodule.html">QML Types</a></td><td >PieSeries QML Type</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <div class="sidebar"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#properties">Properties</a></li> <li class="level1"><a href="#signals">Signals</a></li> <li class="level1"><a href="#methods">Methods</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">PieSeries QML Type</h1> <span class="subtitle"></span> <!-- $$$PieSeries-brief --> <p>Presents data in pie charts. <a href="#details">More...</a></p> <!-- @@@PieSeries --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Import Statement:</td><td class="memItemRight bottomAlign"> import QtCharts 2.2</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Instantiates:</td><td class="memItemRight bottomAlign"> <a href="qml-qtcharts-pieseries.html"><a href="qpieseries.html">QPieSeries</a></td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <p><a href="qml-qtcharts-abstractseries.html">AbstractSeries</a></p> </td></tr></table></div><ul> <li><a href="qml-qtcharts-pieseries-members.html">List of all members, including inherited members</a></li> </ul> <a name="properties"></a> <h2 id="properties">Properties</h2> <ul> <li class="fn"><b><b><a href="qml-qtcharts-pieseries.html#count-prop">count</a></b></b> : int</li> <li class="fn"><b><b><a href="qml-qtcharts-pieseries.html#endAngle-prop">endAngle</a></b></b> : real</li> <li class="fn"><b><b><a href="qml-qtcharts-pieseries.html#holeSize-prop">holeSize</a></b></b> : real</li> <li class="fn"><b><b><a href="qml-qtcharts-pieseries.html#horizontalPosition-prop">horizontalPosition</a></b></b> : real</li> <li class="fn"><b><b><a href="qml-qtcharts-pieseries.html#size-prop">size</a></b></b> : real</li> <li class="fn"><b><b><a href="qml-qtcharts-pieseries.html#startAngle-prop">startAngle</a></b></b> : real</li> <li class="fn"><b><b><a href="qml-qtcharts-pieseries.html#sum-prop">sum</a></b></b> : real</li> <li class="fn"><b><b><a href="qml-qtcharts-pieseries.html#verticalPosition-prop">verticalPosition</a></b></b> : real</li> </ul> <a name="signals"></a> <h2 id="signals">Signals</h2> <ul> <li class="fn"><b><b><a href="qml-qtcharts-pieseries.html#added-signal">added</a></b></b>(list<PieSlice> <i>slices</i>)</li> <li class="fn"><b><b><a href="qml-qtcharts-pieseries.html#clicked-signal">clicked</a></b></b>(PieSlice <i>slice</i>)</li> <li class="fn"><b><b><a href="qml-qtcharts-pieseries.html#doubleClicked-signal">doubleClicked</a></b></b>(PieSlice <i>slice</i>)</li> <li class="fn"><b><b><a href="qml-qtcharts-pieseries.html#hovered-signal">hovered</a></b></b>(PieSlice <i>slice</i>, bool <i>state</i>)</li> <li class="fn"><b><b><a href="qml-qtcharts-pieseries.html#pressed-signal">pressed</a></b></b>(PieSlice <i>slice</i>)</li> <li class="fn"><b><b><a href="qml-qtcharts-pieseries.html#released-signal">released</a></b></b>(PieSlice <i>slice</i>)</li> <li class="fn"><b><b><a href="qml-qtcharts-pieseries.html#removed-signal">removed</a></b></b>(list<PieSlice> <i>slices</i>)</li> <li class="fn"><b><b><a href="qml-qtcharts-pieseries.html#sliceAdded-signal">sliceAdded</a></b></b>(PieSlice <i>slice</i>)</li> <li class="fn"><b><b><a href="qml-qtcharts-pieseries.html#sliceRemoved-signal">sliceRemoved</a></b></b>(PieSlice <i>slice</i>)</li> </ul> <a name="methods"></a> <h2 id="methods">Methods</h2> <ul> <li class="fn">PieSlice <b><b><a href="qml-qtcharts-pieseries.html#append-method">append</a></b></b>(string <i>label</i>, real <i>value</i>)</li> <li class="fn">PieSlice <b><b><a href="qml-qtcharts-pieseries.html#at-method">at</a></b></b>(int <i>index</i>)</li> <li class="fn"><b><b><a href="qml-qtcharts-pieseries.html#clear-method">clear</a></b></b>()</li> <li class="fn">PieSlice <b><b><a href="qml-qtcharts-pieseries.html#find-method">find</a></b></b>(string <i>label</i>)</li> <li class="fn">bool <b><b><a href="qml-qtcharts-pieseries.html#remove-method">remove</a></b></b>(PieSlice <i>slice</i>)</li> </ul> <!-- $$$PieSeries-description --> <a name="details"></a> <h2 id="details">Detailed Description</h2> <p>A pie series consists of slices that are defined using the <a href="qml-qtcharts-pieslice.html">PieSlice</a> type. The slices can have any values as the <a href="qml-qtcharts-pieseries.html">PieSeries</a> 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 chart.</p> <p>Pie size and position on the chart are controlled by using relative values that range from 0.0 to 1.0. These relate to the actual chart rectangle.</p> <p>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 a'clock.</p> <p>The following QML example shows how to create a simple pie chart.</p> <pre class="qml"> <span class="type"><a href="qml-qtcharts-chartview.html">ChartView</a></span> { <span class="name">id</span>: <span class="name">chart</span> <span class="name">title</span>: <span class="string">"Top-5 car brand shares in Finland"</span> <span class="name">anchors</span>.fill: <span class="name">parent</span> <span class="name">legend</span>.alignment: <span class="name">Qt</span>.<span class="name">AlignBottom</span> <span class="name">antialiasing</span>: <span class="number">true</span> <span class="type"><a href="qml-qtcharts-pieseries.html">PieSeries</a></span> { <span class="name">id</span>: <span class="name">pieSeries</span> <span class="type"><a href="qml-qtcharts-pieslice.html">PieSlice</a></span> { <span class="name">label</span>: <span class="string">"Volkswagen"</span>; <span class="name">value</span>: <span class="number">13.5</span> } <span class="type"><a href="qml-qtcharts-pieslice.html">PieSlice</a></span> { <span class="name">label</span>: <span class="string">"Toyota"</span>; <span class="name">value</span>: <span class="number">10.9</span> } <span class="type"><a href="qml-qtcharts-pieslice.html">PieSlice</a></span> { <span class="name">label</span>: <span class="string">"Ford"</span>; <span class="name">value</span>: <span class="number">8.6</span> } <span class="type"><a href="qml-qtcharts-pieslice.html">PieSlice</a></span> { <span class="name">label</span>: <span class="string">"Skoda"</span>; <span class="name">value</span>: <span class="number">8.2</span> } <span class="type"><a href="qml-qtcharts-pieslice.html">PieSlice</a></span> { <span class="name">label</span>: <span class="string">"Volvo"</span>; <span class="name">value</span>: <span class="number">6.8</span> } } } <span class="name">Component</span>.onCompleted: { <span class="comment">// You can also manipulate slices dynamically</span> <span class="name">othersSlice</span> <span class="operator">=</span> <span class="name">pieSeries</span>.<span class="name">append</span>(<span class="string">"Others"</span>, <span class="number">52.0</span>); <span class="name">pieSeries</span>.<span class="name">find</span>(<span class="string">"Volkswagen"</span>).<span class="name">exploded</span> <span class="operator">=</span> <span class="number">true</span>; } </pre> <div style="float: left; margin-right: 2em"><p class="centerAlign"><img src="images/examples_qmlchart1.png" alt="" /></p></div><br style="clear: both" /><p><b>See also </b><a href="qml-qtcharts-pieslice.html">PieSlice</a> and <a href="qml-qtcharts-chartview.html">ChartView</a>.</p> <!-- @@@PieSeries --> <h2>Property Documentation</h2> <!-- $$$count --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="count-prop"> <td class="tblQmlPropNode"><p> <a name="count-prop"></a><span class="name">count</span> : <span class="type">int</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>The number of slices in the series.</p> </div></div><!-- @@@count --> <br/> <!-- $$$endAngle --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="endAngle-prop"> <td class="tblQmlPropNode"><p> <a name="endAngle-prop"></a><span class="name">endAngle</span> : <span class="type">real</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>The ending angle of the pie.</p> <p>A full pie is 360 degrees, where 0 degrees is at 12 a'clock.</p> <p>The default value is 360.</p> </div></div><!-- @@@endAngle --> <br/> <!-- $$$holeSize --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="holeSize-prop"> <td class="tblQmlPropNode"><p> <a name="holeSize-prop"></a><span class="name">holeSize</span> : <span class="type">real</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>The donut hole size.</p> <p>The value is relative to the chart rectangle, so that:</p> <ul> <li>0.0 is the minimum size (full pie drawn without a hole).</li> <li>1.0 is the maximum size that can fit the chart (the donut has no width).</li> </ul> <p>When setting this property, the <a href="qml-qtcharts-pieseries.html#size-prop">size</a> property is adjusted if necessary, to ensure that the hole size is not greater than the pie size.</p> <p>The default value is 0.0.</p> </div></div><!-- @@@holeSize --> <br/> <!-- $$$horizontalPosition --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="horizontalPosition-prop"> <td class="tblQmlPropNode"><p> <a name="horizontalPosition-prop"></a><span class="name">horizontalPosition</span> : <span class="type">real</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>The horizontal position of the pie.</p> <p>The value is relative to the chart rectangle, so that:</p> <ul> <li>0.0 is the absolute left.</li> <li>1.0 is the absolute right.</li> </ul> <p>The default value is 0.5 (center).</p> <p><b>See also </b><a href="qml-qtcharts-pieseries.html#verticalPosition-prop">verticalPosition</a>.</p> </div></div><!-- @@@horizontalPosition --> <br/> <!-- $$$size --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="size-prop"> <td class="tblQmlPropNode"><p> <a name="size-prop"></a><span class="name">size</span> : <span class="type">real</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>The pie size.</p> <p>The value is relative to the chart rectangle, so that:</p> <ul> <li>0.0 is the minimum size (pie not drawn).</li> <li>1.0 is the maximum size that can fit the chart.</li> </ul> <p>When setting this property, the <a href="qml-qtcharts-pieseries.html#holeSize-prop">holeSize</a> property is adjusted if necessary, to ensure that the hole size is not greater than the pie size.</p> <p>The default value is 0.7.</p> </div></div><!-- @@@size --> <br/> <!-- $$$startAngle --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="startAngle-prop"> <td class="tblQmlPropNode"><p> <a name="startAngle-prop"></a><span class="name">startAngle</span> : <span class="type">real</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>The starting angle of the pie.</p> <p>A full pie is 360 degrees, where 0 degrees is at 12 a'clock.</p> <p>The default value is 0.</p> </div></div><!-- @@@startAngle --> <br/> <!-- $$$sum --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="sum-prop"> <td class="tblQmlPropNode"><p> <a name="sum-prop"></a><span class="name">sum</span> : <span class="type">real</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>The sum of all slices.</p> <p>The series keeps track of the sum of all the slices it holds.</p> </div></div><!-- @@@sum --> <br/> <!-- $$$verticalPosition --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="verticalPosition-prop"> <td class="tblQmlPropNode"><p> <a name="verticalPosition-prop"></a><span class="name">verticalPosition</span> : <span class="type">real</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>The vertical position of the pie.</p> <p>The value is relative to the chart rectangle, so that:</p> <ul> <li>0.0 is the absolute top.</li> <li>1.0 is the absolute bottom.</li> </ul> <p>The default value is 0.5 (center).</p> <p><b>See also </b><a href="qml-qtcharts-pieseries.html#horizontalPosition-prop">horizontalPosition</a>.</p> </div></div><!-- @@@verticalPosition --> <br/> <h2>Signal Documentation</h2> <!-- $$$added --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="added-signal"> <td class="tblQmlFuncNode"><p> <a name="added-signal"></a><span class="name">added</span>(<span class="type">list</span><<span class="type"><a href="qml-qtcharts-pieslice.html">PieSlice</a></span>> <i>slices</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>This signal is emitted when the slices specified by <i>slices</i> are added to the series.</p> <p>The corresponding signal handler is <code>onAdded</code>.</p> </div></div><!-- @@@added --> <br/> <!-- $$$clicked --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="clicked-signal"> <td class="tblQmlFuncNode"><p> <a name="clicked-signal"></a><span class="name">clicked</span>(<span class="type"><a href="qml-qtcharts-pieslice.html">PieSlice</a></span> <i>slice</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>This signal is emitted when the slice specified by <i>slice</i> is clicked.</p> <p>The corresponding signal handler is <code>onClicked</code>.</p> </div></div><!-- @@@clicked --> <br/> <!-- $$$doubleClicked --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="doubleClicked-signal"> <td class="tblQmlFuncNode"><p> <a name="doubleClicked-signal"></a><span class="name">doubleClicked</span>(<span class="type"><a href="qml-qtcharts-pieslice.html">PieSlice</a></span> <i>slice</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>This signal is emitted when the slice specified by <i>slice</i> is double-clicked.</p> <p>The corresponding signal handler is <code>onDoubleClicked</code>.</p> </div></div><!-- @@@doubleClicked --> <br/> <!-- $$$hovered --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="hovered-signal"> <td class="tblQmlFuncNode"><p> <a name="hovered-signal"></a><span class="name">hovered</span>(<span class="type"><a href="qml-qtcharts-pieslice.html">PieSlice</a></span> <i>slice</i>, <span class="type">bool</span> <i>state</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>This signal is emitted when a mouse is hovered over the slice specified by <i>slice</i>. When the mouse moves over the slice, <i>state</i> turns <code>true</code>, and when the mouse moves away again, it turns <code>false</code>.</p> <p>The corresponding signal handler is <code>onHovered</code>.</p> </div></div><!-- @@@hovered --> <br/> <!-- $$$pressed --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="pressed-signal"> <td class="tblQmlFuncNode"><p> <a name="pressed-signal"></a><span class="name">pressed</span>(<span class="type"><a href="qml-qtcharts-pieslice.html">PieSlice</a></span> <i>slice</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>This signal is emitted when the user clicks the slice specified by <i>slice</i> and holds down the mouse button.</p> <p>The corresponding signal handler is <code>onPressed</code>.</p> </div></div><!-- @@@pressed --> <br/> <!-- $$$released --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="released-signal"> <td class="tblQmlFuncNode"><p> <a name="released-signal"></a><span class="name">released</span>(<span class="type"><a href="qml-qtcharts-pieslice.html">PieSlice</a></span> <i>slice</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>This signal is emitted when the user releases the mouse press on the slice specified by <i>slice</i>.</p> <p>The corresponding signal handler is <code>onReleased</code>.</p> </div></div><!-- @@@released --> <br/> <!-- $$$removed --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="removed-signal"> <td class="tblQmlFuncNode"><p> <a name="removed-signal"></a><span class="name">removed</span>(<span class="type">list</span><<span class="type"><a href="qml-qtcharts-pieslice.html">PieSlice</a></span>> <i>slices</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>This signal is emitted when the slices specified by <i>slices</i> are removed from the series.</p> <p>The corresponding signal handler is <code>onRemoved</code>.</p> </div></div><!-- @@@removed --> <br/> <!-- $$$sliceAdded --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="sliceAdded-signal"> <td class="tblQmlFuncNode"><p> <a name="sliceAdded-signal"></a><span class="name">sliceAdded</span>(<span class="type"><a href="qml-qtcharts-pieslice.html">PieSlice</a></span> <i>slice</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>This signal is emitted when the slice specified by <i>slice</i> is added to the series.</p> <p>The corresponding signal handler is <code>onSliceAdded</code>.</p> </div></div><!-- @@@sliceAdded --> <br/> <!-- $$$sliceRemoved --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="sliceRemoved-signal"> <td class="tblQmlFuncNode"><p> <a name="sliceRemoved-signal"></a><span class="name">sliceRemoved</span>(<span class="type"><a href="qml-qtcharts-pieslice.html">PieSlice</a></span> <i>slice</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>This signal is emitted when the slice specified by <i>slice</i> is removed from the series.</p> <p>The corresponding signal handler is <code>onSliceRemoved</code>.</p> </div></div><!-- @@@sliceRemoved --> <br/> <h2>Method Documentation</h2> <!-- $$$append --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="append-method"> <td class="tblQmlFuncNode"><p> <a name="append-method"></a><span class="type"><a href="qml-qtcharts-pieslice.html">PieSlice</a></span> <span class="name">append</span>(<span class="type">string</span> <i>label</i>, <span class="type">real</span> <i>value</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>Adds a new slice with the label <i>label</i> and the value <i>value</i> to the pie.</p> </div></div><!-- @@@append --> <br/> <!-- $$$at --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="at-method"> <td class="tblQmlFuncNode"><p> <a name="at-method"></a><span class="type"><a href="qml-qtcharts-pieslice.html">PieSlice</a></span> <span class="name">at</span>(<span class="type">int</span> <i>index</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>Returns the slice at the position specified by <i>index</i>. Returns null if the index is not valid.</p> </div></div><!-- @@@at --> <br/> <!-- $$$clear --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="clear-method"> <td class="tblQmlFuncNode"><p> <a name="clear-method"></a><span class="name">clear</span>()</p></td></tr> </table></div> </div><div class="qmldoc"><p>Removes all slices from the pie.</p> </div></div><!-- @@@clear --> <br/> <!-- $$$find --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="find-method"> <td class="tblQmlFuncNode"><p> <a name="find-method"></a><span class="type"><a href="qml-qtcharts-pieslice.html">PieSlice</a></span> <span class="name">find</span>(<span class="type">string</span> <i>label</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>Returns the first slice that has the label <i>label</i>. Returns null if the label is not found.</p> </div></div><!-- @@@find --> <br/> <!-- $$$remove --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="remove-method"> <td class="tblQmlFuncNode"><p> <a name="remove-method"></a><span class="type">bool</span> <span class="name">remove</span>(<span class="type"><a href="qml-qtcharts-pieslice.html">PieSlice</a></span> <i>slice</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>Removes the slice specified by <i>slice</i> from the pie. Returns <code>true</code> if the removal was successful, <code>false</code> otherwise.</p> </div></div><!-- @@@remove --> <br/> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2017 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.<br> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br> 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. </p> </div> </body> </html>