##// END OF EJS Templates
Added donut to QML chart demo app
Tero Ahola -
r1832:a53d18bba921
parent child
Show More
@@ -0,0 +1,74
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
23
24 Rectangle {
25 anchors.fill: parent
26
27 //![1]
28 ChartView {
29 id: chart
30 title: "Production costs"
31 anchors.fill: parent
32 legend.visible: false
33
34 PieSeries {
35 id: pieOuter
36 size: 0.96
37 PieSlice { id: slice; label: "Alpha"; value: 19511; color: "#2D6960"; borderColor: "#163430" }
38 PieSlice { label: "Epsilon"; value: 11105; color: "#EFE672"; borderColor: "#3B391C" }
39 PieSlice { label: "Psi"; value: 9352; color: "#4C1B33"; borderColor: "#13060C" }
40 }
41
42 PieSeries {
43 size: 0.7
44 id: pieInner
45
46 PieSlice { label: "Materials"; value: 10334; color: "#618E87"; borderColor: "#163430" }
47 PieSlice { label: "Employee"; value: 3066; color: "#2D6960"; borderColor: "#163430"; borderWidth: 2 }
48 PieSlice { label: "Logistics"; value: 6111; color: "#214E48"; borderColor: "#163430"; borderWidth: 2 }
49
50 PieSlice { label: "Materials"; value: 7371; color: "#F7F28B"; borderColor: "#3B391C"; borderWidth: 2 }
51 PieSlice { label: "Employee"; value: 2443; color: "#EFE672"; borderColor: "#3B391C"; borderWidth: 2 }
52 PieSlice { label: "Logistics"; value: 1291; color: "#777339"; borderColor: "#3B391C"; borderWidth: 2 }
53
54 PieSlice { label: "Materials"; value: 4022; color: "#785466"; borderColor: "#13060C"; borderWidth: 2 }
55 PieSlice { label: "Employee"; value: 3998; color: "#4C1B33"; borderColor: "#13060C"; borderWidth: 2 }
56 PieSlice { label: "Logistics"; value: 1332; color: "#260D19"; borderColor: "#13060C"; borderWidth: 2 }
57 }
58 }
59 //![1]
60
61 Component.onCompleted: {
62 // Set the common slice properties dynamically for convenience
63 for (var i = 0; i < pieOuter.count; i++) {
64 pieOuter.at(i).labelPosition = PieSlice.LabelOutside;
65 pieOuter.at(i).labelVisible = true;
66 pieOuter.at(i).borderWidth = 2;
67 }
68 for (var i = 0; i < pieInner.count; i++) {
69 pieInner.at(i).labelPosition = PieSlice.LabelInsideNormal;
70 pieInner.at(i).labelVisible = true;
71 pieInner.at(i).borderWidth = 2;
72 }
73 }
74 }
@@ -1,52 +1,51
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 Rectangle {
24 Rectangle {
25 anchors.fill: parent
25 anchors.fill: parent
26 property int __explodedIndex: -1
26 property variant othersSlice: 0
27 property variant otherSlice: 0
28
27
29 //![1]
28 //![1]
30 ChartView {
29 ChartView {
31 id: chart
30 id: chart
32 title: "Top-5 car brand shares in Finland"
31 title: "Top-5 car brand shares in Finland"
33 anchors.fill: parent
32 anchors.fill: parent
34 legend.alignment: Qt.AlignBottom
33 legend.alignment: Qt.AlignBottom
35
34
36 PieSeries {
35 PieSeries {
37 id: pieSeries
36 id: pieSeries
38 PieSlice { label: "Volkswagen"; value: 13.5 }
37 PieSlice { label: "Volkswagen"; value: 13.5 }
39 PieSlice { label: "Toyota"; value: 10.9 }
38 PieSlice { label: "Toyota"; value: 10.9 }
40 PieSlice { label: "Ford"; value: 8.6 }
39 PieSlice { label: "Ford"; value: 8.6 }
41 PieSlice { label: "Skoda"; value: 8.2 }
40 PieSlice { label: "Skoda"; value: 8.2 }
42 PieSlice { label: "Volvo"; value: 6.8 }
41 PieSlice { label: "Volvo"; value: 6.8 }
43 }
42 }
44 }
43 }
45
44
46 Component.onCompleted: {
45 Component.onCompleted: {
47 // You can also manipulate slices dynamically
46 // You can also manipulate slices dynamically
48 otherSlice = pieSeries.append("Others", 52.0);
47 othersSlice = pieSeries.append("Others", 52.0);
49 pieSeries.find("Volkswagen").exploded = true;
48 pieSeries.find("Volkswagen").exploded = true;
50 }
49 }
51 //![1]
50 //![1]
52 }
51 }
@@ -1,90 +1,90
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 Rectangle {
24 Rectangle {
25 width: parent.width
25 width: parent.width
26 height: parent.height
26 height: parent.height
27 property int viewNumber: 1
27 property int viewNumber: 12
28
28
29 Loader {
29 Loader {
30 id: loader
30 id: loader
31 anchors.fill: parent
31 anchors.fill: parent
32 source: "View" + viewNumber + ".qml";
32 source: "View" + viewNumber + ".qml";
33 }
33 }
34
34
35 Rectangle {
35 Rectangle {
36 id: infoText
36 id: infoText
37 anchors.centerIn: parent
37 anchors.centerIn: parent
38 width: parent.width
38 width: parent.width
39 height: 40
39 height: 40
40 color: "black"
40 color: "black"
41 Text {
41 Text {
42 color: "white"
42 color: "white"
43 anchors.centerIn: parent
43 anchors.centerIn: parent
44 text: "Use left and right arrow keys to navigate between chart types"
44 text: "Use left and right arrow keys to navigate between chart types"
45 }
45 }
46
46
47 Behavior on opacity {
47 Behavior on opacity {
48 NumberAnimation { duration: 400 }
48 NumberAnimation { duration: 400 }
49 }
49 }
50 }
50 }
51
51
52 MouseArea {
52 MouseArea {
53 focus: true
53 focus: true
54 anchors.fill: parent
54 anchors.fill: parent
55 onClicked: {
55 onClicked: {
56 if (infoText.opacity > 0) {
56 if (infoText.opacity > 0) {
57 infoText.opacity = 0.0;
57 infoText.opacity = 0.0;
58 } else {
58 } else {
59 nextView();
59 nextView();
60 }
60 }
61 }
61 }
62 Keys.onPressed: {
62 Keys.onPressed: {
63 if (infoText.opacity > 0) {
63 if (infoText.opacity > 0) {
64 infoText.opacity = 0.0;
64 infoText.opacity = 0.0;
65 } else {
65 } else {
66 if (event.key == Qt.Key_Left) {
66 if (event.key == Qt.Key_Left) {
67 previousView();
67 previousView();
68 } else {
68 } else {
69 nextView();
69 nextView();
70 }
70 }
71 }
71 }
72 }
72 }
73 }
73 }
74
74
75 function nextView() {
75 function nextView() {
76 var i = viewNumber + 1;
76 var i = viewNumber + 1;
77 if (i > 11)
77 if (i > 12)
78 viewNumber = 1;
78 viewNumber = 1;
79 else
79 else
80 viewNumber = i;
80 viewNumber = i;
81 }
81 }
82
82
83 function previousView() {
83 function previousView() {
84 var i = viewNumber - 1;
84 var i = viewNumber - 1;
85 if (i <= 0)
85 if (i <= 0)
86 viewNumber = 11;
86 viewNumber = 12;
87 else
87 else
88 viewNumber = i;
88 viewNumber = i;
89 }
89 }
90 }
90 }
@@ -1,17 +1,18
1 <RCC>
1 <RCC>
2 <qresource prefix="/">
2 <qresource prefix="/">
3 <file>qml/qmlchart/loader.qml</file>
3 <file>qml/qmlchart/loader.qml</file>
4 <file>qml/qmlchart/main.qml</file>
4 <file>qml/qmlchart/main.qml</file>
5 <file>qml/qmlchart/View1.qml</file>
5 <file>qml/qmlchart/View1.qml</file>
6 <file>qml/qmlchart/View2.qml</file>
6 <file>qml/qmlchart/View2.qml</file>
7 <file>qml/qmlchart/View3.qml</file>
7 <file>qml/qmlchart/View3.qml</file>
8 <file>qml/qmlchart/View4.qml</file>
8 <file>qml/qmlchart/View4.qml</file>
9 <file>qml/qmlchart/View5.qml</file>
9 <file>qml/qmlchart/View5.qml</file>
10 <file>qml/qmlchart/View6.qml</file>
10 <file>qml/qmlchart/View6.qml</file>
11 <file>qml/qmlchart/View7.qml</file>
11 <file>qml/qmlchart/View7.qml</file>
12 <file>qml/qmlchart/View8.qml</file>
12 <file>qml/qmlchart/View8.qml</file>
13 <file>qml/qmlchart/View9.qml</file>
13 <file>qml/qmlchart/View9.qml</file>
14 <file>qml/qmlchart/View10.qml</file>
14 <file>qml/qmlchart/View10.qml</file>
15 <file>qml/qmlchart/View11.qml</file>
15 <file>qml/qmlchart/View11.qml</file>
16 <file>qml/qmlchart/View12.qml</file>
16 </qresource>
17 </qresource>
17 </RCC>
18 </RCC>
General Comments 0
You need to be logged in to leave comments. Login now