Debian Codegraph @

examples/charts/qmlchartsgallery/qml/Donut.qml

raw
1 // Copyright (C) 2023 The Qt Company Ltd.
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4 import QtQuick
5 import QtCharts
6
7 //![1]
8 ChartView {
9 id: chart
10 title: "Production Costs"
11 anchors.fill: parent
12 legend.visible: false
13 antialiasing: true
14
15 PieSeries {
16 id: pieOuter
17 size: 0.96
18 holeSize: 0.7
19 PieSlice { id: slice; label: "Alpha"; value: 19511; color: "#99CA53" }
20 PieSlice { label: "Epsilon"; value: 11105; color: "#209FDF" }
21 PieSlice { label: "Psi"; value: 9352; color: "#F6A625" }
22 }
23
24 PieSeries {
25 size: 0.7
26 id: pieInner
27 holeSize: 0.25
28
29 PieSlice { label: "Materials"; value: 10334; color: "#B9DB8A" }
30 PieSlice { label: "Employee"; value: 3066; color: "#DCEDC4" }
31 PieSlice { label: "Logistics"; value: 6111; color: "#F3F9EB" }
32
33 PieSlice { label: "Materials"; value: 7371; color: "#63BCE9" }
34 PieSlice { label: "Employee"; value: 2443; color: "#A6D9F2" }
35 PieSlice { label: "Logistics"; value: 1291; color: "#E9F5FC" }
36
37 PieSlice { label: "Materials"; value: 4022; color: "#F9C36C" }
38 PieSlice { label: "Employee"; value: 3998; color: "#FCE1B6" }
39 PieSlice { label: "Logistics"; value: 1332; color: "#FEF5E7" }
40 }
41
42 Component.onCompleted: {
43 // Set the common slice properties dynamically for convenience
44 for (var i = 0; i < pieOuter.count; i++) {
45 pieOuter.at(i).labelPosition = PieSlice.LabelOutside;
46 pieOuter.at(i).labelVisible = true;
47 pieOuter.at(i).borderWidth = 3;
48 }
49 for (var i = 0; i < pieInner.count; i++) {
50 pieInner.at(i).labelPosition = PieSlice.LabelInsideNormal;
51 pieInner.at(i).labelVisible = true;
52 pieInner.at(i).borderWidth = 2;
53 }
54 }
55 }
56
57 //![1]