##// END OF EJS Templates
Fix multiline axis label positioning....
Fix multiline axis label positioning. Refactored axis label/title handling to not use QFontMetrics but a dummy graphics text item instead. Task-number: QTRD-2056 Change-Id: Ib24f26d214046f97f4fd2d3b2dd720e866561dbd Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>

File last commit:

r1985:86ffb652e423
r2534:ec1756baf233
Show More
demos-nesteddonuts.qdoc
50 lines | 2.6 KiB | text/plain | TextLexer
/ doc / src / demos-nesteddonuts.qdoc
Marek Rosa
Documented the donut example
r1713 /*!
Jani Honkonen
Fixed nesteddonuts docs
r1886 \example demos/nesteddonuts
\title Nested donuts demo
Marek Rosa
Documented the donut example
r1713 \subtitle
This example shows how to use create a nested donuts chart using QPieSeries API.
Tero Ahola
Updated screenshots in donut and bar examples
r1956 \image demos_nesteddonuts.png
Marek Rosa
Documented the donut example
r1713
Marek Rosa
Nesteddonuts chart docs updated
r1985 Let's start by creating a QChartView instance and enabling the Antialiasing on it. QChart object is then obtained from the QChartView instance.
The legend is disabled and the title of the chart is set. Last line enables the animations of the chart.
Marek Rosa
Documented the donut example
r1713
Jani Honkonen
Fixed nesteddonuts docs
r1886 \snippet ../demos/nesteddonuts/widget.cpp 1
Marek Rosa
Documented the donut example
r1713
Three variables are defined that will be used to define the donut chart. Min and max size define the relative size of the whole donut.
minSize is the relative inner size of the smallest donut. maxSize is the relative outer size of the biggest donut.
Jani Honkonen
Fixed nesteddonuts docs
r1886 \snippet ../demos/nesteddonuts/widget.cpp 2
Marek Rosa
Documented the donut example
r1713
Following block of code defines the individual donuts and their slices. First new QPieSeries object is created.
Marek Rosa
Nesteddonuts chart docs updated
r1985 The number of slices in each donut is randomized.
Marek Rosa
Documented the donut example
r1713 The internal for loop creates the slices with a random value and label same as the value.
Next the label of the slice is set to be visible and its color is set to white.
To make the example more interesting the hovered signal of the slice is connected to widget's slot which inner workings are explained later.
Jani Honkonen
Fix spelling errors
r1940 Finally the slice is added to the donut. The donut's size is adjusted to achieve the nesting of the donuts.
Marek Rosa
Documented the donut example
r1713 Then the donut is added to the widget's list of donuts and to the chart.
Jani Honkonen
Fixed nesteddonuts docs
r1886 \snippet ../demos/nesteddonuts/widget.cpp 3
Marek Rosa
Documented the donut example
r1713
Finally the widget is placed in a layout used by the application.
Jani Honkonen
Fixed nesteddonuts docs
r1886 \snippet ../demos/nesteddonuts/widget.cpp 4
Marek Rosa
Documented the donut example
r1713
To make the example more interesting the donuts are rotated randomly every 1.25 sec.
Jani Honkonen
Fixed nesteddonuts docs
r1886 \snippet ../demos/nesteddonuts/widget.cpp 5
Marek Rosa
Documented the donut example
r1713
The widget's updatedRotation slot is defined below.
It goes through all of the donuts and modifies thier current rotation by a random value.
Jani Honkonen
Fixed nesteddonuts docs
r1886 \snippet ../demos/nesteddonuts/widget.cpp 6
Marek Rosa
Documented the donut example
r1713
The earlier mentioned explodeSlice slot code is provided below.
If the slice is set to exploded then stop the timer that controls the donuts rotation.
Marek Rosa
Nesteddonuts chart docs updated
r1985 Then the slice's start and end angles are obtained from the slice.
Marek Rosa
Documented the donut example
r1713 To highlight the selected slice all the other donuts that lie outward from the one that contains the selected slice
have their start and end angles modified so that they wouldn't "block" the way for the hightlighted slice.
If the slice is no longer selected return to the original state.
Jani Honkonen
Fixed nesteddonuts docs
r1886 \snippet ../demos/nesteddonuts/widget.cpp 7
Marek Rosa
Documented the donut example
r1713 */