@@ -1,44 +1,48 | |||||
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 |
|
26 | |||
27 | //![1] |
|
27 | //![1] | |
28 | ChartView { |
|
28 | ChartView { | |
29 | title: "Line" |
|
29 | title: "Line" | |
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 |
|
31 | |||
32 | LineSeries { |
|
32 | LineSeries { | |
33 | name: "LineSeries" |
|
33 | name: "LineSeries" | |
34 | XYPoint { x: 0; y: 0 } |
|
34 | XYPoint { x: 0; y: 0 } | |
35 | XYPoint { x: 1.1; y: 2.1 } |
|
35 | XYPoint { x: 1.1; y: 2.1 } | |
36 | XYPoint { x: 1.9; y: 3.3 } |
|
36 | XYPoint { x: 1.9; y: 3.3 } | |
37 | XYPoint { x: 2.1; y: 2.1 } |
|
37 | XYPoint { x: 2.1; y: 2.1 } | |
38 | XYPoint { x: 2.9; y: 4.9 } |
|
38 | XYPoint { x: 2.9; y: 4.9 } | |
39 | XYPoint { x: 3.4; y: 3.0 } |
|
39 | XYPoint { x: 3.4; y: 3.0 } | |
40 | XYPoint { x: 4.1; y: 3.3 } |
|
40 | XYPoint { x: 4.1; y: 3.3 } | |
41 | } |
|
41 | } | |
|
42 | ||||
|
43 | Component.onCompleted: { | |||
|
44 | createDefaultAxes(); | |||
|
45 | } | |||
42 | } |
|
46 | } | |
43 | //![1] |
|
47 | //![1] | |
44 | } |
|
48 | } |
@@ -1,44 +1,48 | |||||
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 |
|
26 | |||
27 | //![1] |
|
27 | //![1] | |
28 | ChartView { |
|
28 | ChartView { | |
29 | title: "Spline" |
|
29 | title: "Spline" | |
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 |
|
31 | |||
32 | SplineSeries { |
|
32 | SplineSeries { | |
33 | name: "SplineSeries" |
|
33 | name: "SplineSeries" | |
34 | XYPoint { x: 0; y: 0.3 } |
|
34 | XYPoint { x: 0; y: 0.3 } | |
35 | XYPoint { x: 1.1; y: 3.2 } |
|
35 | XYPoint { x: 1.1; y: 3.2 } | |
36 | XYPoint { x: 1.9; y: 2.4 } |
|
36 | XYPoint { x: 1.9; y: 2.4 } | |
37 | XYPoint { x: 2.1; y: 2.1 } |
|
37 | XYPoint { x: 2.1; y: 2.1 } | |
38 | XYPoint { x: 2.9; y: 2.6 } |
|
38 | XYPoint { x: 2.9; y: 2.6 } | |
39 | XYPoint { x: 3.4; y: 2.3 } |
|
39 | XYPoint { x: 3.4; y: 2.3 } | |
40 | XYPoint { x: 4.1; y: 3.1 } |
|
40 | XYPoint { x: 4.1; y: 3.1 } | |
41 | } |
|
41 | } | |
|
42 | ||||
|
43 | Component.onCompleted: { | |||
|
44 | createDefaultAxes(); | |||
|
45 | } | |||
42 | } |
|
46 | } | |
43 | //![1] |
|
47 | //![1] | |
44 | } |
|
48 | } |
@@ -1,145 +1,149 | |||||
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 |
|
26 | |||
27 | //![1] |
|
27 | //![1] | |
28 | ChartView { |
|
28 | ChartView { | |
29 | title: "NHL All-Star Team Players" |
|
29 | title: "NHL All-Star Team Players" | |
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 |
|
31 | |||
32 | AreaSeries { |
|
32 | AreaSeries { | |
33 | axisX: CategoriesAxis { |
|
33 | //TODO: obsolate | |
34 |
|
|
34 | //axisX: CategoriesAxis { | |
35 | categories: ["2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", |
|
35 | // id: categoriesAxis | |
36 | "2008", "2009", "2010", "2011" ] |
|
36 | // categories: ["2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", | |
37 | } |
|
37 | // "2008", "2009", "2010", "2011" ] | |
|
38 | //} | |||
38 |
|
39 | |||
39 | name: "Russian" |
|
40 | name: "Russian" | |
40 | upperSeries: LineSeries { |
|
41 | upperSeries: LineSeries { | |
41 | XYPoint { x: 0; y: 1 } |
|
42 | XYPoint { x: 0; y: 1 } | |
42 | XYPoint { x: 1; y: 1 } |
|
43 | XYPoint { x: 1; y: 1 } | |
43 | XYPoint { x: 2; y: 1 } |
|
44 | XYPoint { x: 2; y: 1 } | |
44 | XYPoint { x: 3; y: 1 } |
|
45 | XYPoint { x: 3; y: 1 } | |
45 | XYPoint { x: 4; y: 1 } |
|
46 | XYPoint { x: 4; y: 1 } | |
46 | XYPoint { x: 5; y: 0 } |
|
47 | XYPoint { x: 5; y: 0 } | |
47 | XYPoint { x: 6; y: 1 } |
|
48 | XYPoint { x: 6; y: 1 } | |
48 | XYPoint { x: 7; y: 1 } |
|
49 | XYPoint { x: 7; y: 1 } | |
49 | XYPoint { x: 8; y: 4 } |
|
50 | XYPoint { x: 8; y: 4 } | |
50 | XYPoint { x: 9; y: 3 } |
|
51 | XYPoint { x: 9; y: 3 } | |
51 | XYPoint { x: 10; y: 2 } |
|
52 | XYPoint { x: 10; y: 2 } | |
52 | XYPoint { x: 11; y: 1 } |
|
53 | XYPoint { x: 11; y: 1 } | |
53 | } |
|
54 | } | |
54 | lowerSeries: LineSeries { |
|
55 | lowerSeries: LineSeries { | |
55 | XYPoint { x: 0; y: 0 } |
|
56 | XYPoint { x: 0; y: 0 } | |
56 | XYPoint { x: 1; y: 0 } |
|
57 | XYPoint { x: 1; y: 0 } | |
57 | XYPoint { x: 2; y: 0 } |
|
58 | XYPoint { x: 2; y: 0 } | |
58 | XYPoint { x: 3; y: 0 } |
|
59 | XYPoint { x: 3; y: 0 } | |
59 | XYPoint { x: 4; y: 0 } |
|
60 | XYPoint { x: 4; y: 0 } | |
60 | XYPoint { x: 5; y: 0 } |
|
61 | XYPoint { x: 5; y: 0 } | |
61 | XYPoint { x: 6; y: 0 } |
|
62 | XYPoint { x: 6; y: 0 } | |
62 | XYPoint { x: 7; y: 0 } |
|
63 | XYPoint { x: 7; y: 0 } | |
63 | XYPoint { x: 8; y: 0 } |
|
64 | XYPoint { x: 8; y: 0 } | |
64 | XYPoint { x: 9; y: 0 } |
|
65 | XYPoint { x: 9; y: 0 } | |
65 | XYPoint { x: 10; y: 0 } |
|
66 | XYPoint { x: 10; y: 0 } | |
66 | XYPoint { x: 11; y: 0 } |
|
67 | XYPoint { x: 11; y: 0 } | |
67 | } |
|
68 | } | |
68 | } |
|
69 | } | |
69 | // ... |
|
70 | // ... | |
70 | //![1] |
|
71 | //![1] | |
71 |
|
72 | |||
72 | AreaSeries { |
|
73 | AreaSeries { | |
73 | id: swedish |
|
74 | id: swedish | |
74 | name: "Swedish" |
|
75 | name: "Swedish" | |
75 | upperSeries: LineSeries { |
|
76 | upperSeries: LineSeries { | |
76 | XYPoint { x: 0; y: 1 } |
|
77 | XYPoint { x: 0; y: 1 } | |
77 | XYPoint { x: 1; y: 1 } |
|
78 | XYPoint { x: 1; y: 1 } | |
78 | XYPoint { x: 2; y: 3 } |
|
79 | XYPoint { x: 2; y: 3 } | |
79 | XYPoint { x: 3; y: 3 } |
|
80 | XYPoint { x: 3; y: 3 } | |
80 | XYPoint { x: 4; y: 2 } |
|
81 | XYPoint { x: 4; y: 2 } | |
81 | XYPoint { x: 5; y: 0 } |
|
82 | XYPoint { x: 5; y: 0 } | |
82 | XYPoint { x: 6; y: 2 } |
|
83 | XYPoint { x: 6; y: 2 } | |
83 | XYPoint { x: 7; y: 1 } |
|
84 | XYPoint { x: 7; y: 1 } | |
84 | XYPoint { x: 8; y: 2 } |
|
85 | XYPoint { x: 8; y: 2 } | |
85 | XYPoint { x: 9; y: 1 } |
|
86 | XYPoint { x: 9; y: 1 } | |
86 | XYPoint { x: 10; y: 3 } |
|
87 | XYPoint { x: 10; y: 3 } | |
87 | XYPoint { x: 11; y: 3 } |
|
88 | XYPoint { x: 11; y: 3 } | |
88 | } |
|
89 | } | |
89 | lowerSeries: LineSeries { |
|
90 | lowerSeries: LineSeries { | |
90 | XYPoint { x: 0; y: 0 } |
|
91 | XYPoint { x: 0; y: 0 } | |
91 | XYPoint { x: 1; y: 0 } |
|
92 | XYPoint { x: 1; y: 0 } | |
92 | XYPoint { x: 2; y: 0 } |
|
93 | XYPoint { x: 2; y: 0 } | |
93 | XYPoint { x: 3; y: 0 } |
|
94 | XYPoint { x: 3; y: 0 } | |
94 | XYPoint { x: 4; y: 0 } |
|
95 | XYPoint { x: 4; y: 0 } | |
95 | XYPoint { x: 5; y: 0 } |
|
96 | XYPoint { x: 5; y: 0 } | |
96 | XYPoint { x: 6; y: 0 } |
|
97 | XYPoint { x: 6; y: 0 } | |
97 | XYPoint { x: 7; y: 0 } |
|
98 | XYPoint { x: 7; y: 0 } | |
98 | XYPoint { x: 8; y: 0 } |
|
99 | XYPoint { x: 8; y: 0 } | |
99 | XYPoint { x: 9; y: 0 } |
|
100 | XYPoint { x: 9; y: 0 } | |
100 | XYPoint { x: 10; y: 0 } |
|
101 | XYPoint { x: 10; y: 0 } | |
101 | XYPoint { x: 11; y: 0 } |
|
102 | XYPoint { x: 11; y: 0 } | |
102 | } |
|
103 | } | |
103 | onClicked: { |
|
104 | onClicked: { | |
104 | color = "yellow"; |
|
105 | color = "yellow"; | |
105 | borderColor = "blue"; |
|
106 | borderColor = "blue"; | |
106 | } |
|
107 | } | |
107 | } |
|
108 | } | |
108 |
|
109 | |||
109 | AreaSeries { |
|
110 | AreaSeries { | |
110 | name: "Finnish" |
|
111 | name: "Finnish" | |
111 | upperSeries: LineSeries { |
|
112 | upperSeries: LineSeries { | |
112 | XYPoint { x: 0; y: 0 } |
|
113 | XYPoint { x: 0; y: 0 } | |
113 | XYPoint { x: 1; y: 0 } |
|
114 | XYPoint { x: 1; y: 0 } | |
114 | XYPoint { x: 2; y: 0 } |
|
115 | XYPoint { x: 2; y: 0 } | |
115 | XYPoint { x: 3; y: 0 } |
|
116 | XYPoint { x: 3; y: 0 } | |
116 | XYPoint { x: 4; y: 0 } |
|
117 | XYPoint { x: 4; y: 0 } | |
117 | XYPoint { x: 5; y: 0 } |
|
118 | XYPoint { x: 5; y: 0 } | |
118 | XYPoint { x: 6; y: 1 } |
|
119 | XYPoint { x: 6; y: 1 } | |
119 | XYPoint { x: 7; y: 0 } |
|
120 | XYPoint { x: 7; y: 0 } | |
120 | XYPoint { x: 8; y: 0 } |
|
121 | XYPoint { x: 8; y: 0 } | |
121 | XYPoint { x: 9; y: 0 } |
|
122 | XYPoint { x: 9; y: 0 } | |
122 | XYPoint { x: 10; y: 0 } |
|
123 | XYPoint { x: 10; y: 0 } | |
123 | XYPoint { x: 11; y: 1 } |
|
124 | XYPoint { x: 11; y: 1 } | |
124 | } |
|
125 | } | |
125 | lowerSeries: LineSeries { |
|
126 | lowerSeries: LineSeries { | |
126 | XYPoint { x: 0; y: 0 } |
|
127 | XYPoint { x: 0; y: 0 } | |
127 | XYPoint { x: 1; y: 0 } |
|
128 | XYPoint { x: 1; y: 0 } | |
128 | XYPoint { x: 2; y: 0 } |
|
129 | XYPoint { x: 2; y: 0 } | |
129 | XYPoint { x: 3; y: 0 } |
|
130 | XYPoint { x: 3; y: 0 } | |
130 | XYPoint { x: 4; y: 0 } |
|
131 | XYPoint { x: 4; y: 0 } | |
131 | XYPoint { x: 5; y: 0 } |
|
132 | XYPoint { x: 5; y: 0 } | |
132 | XYPoint { x: 6; y: 0 } |
|
133 | XYPoint { x: 6; y: 0 } | |
133 | XYPoint { x: 7; y: 0 } |
|
134 | XYPoint { x: 7; y: 0 } | |
134 | XYPoint { x: 8; y: 0 } |
|
135 | XYPoint { x: 8; y: 0 } | |
135 | XYPoint { x: 9; y: 0 } |
|
136 | XYPoint { x: 9; y: 0 } | |
136 | XYPoint { x: 10; y: 0 } |
|
137 | XYPoint { x: 10; y: 0 } | |
137 | XYPoint { x: 11; y: 0 } |
|
138 | XYPoint { x: 11; y: 0 } | |
138 | } |
|
139 | } | |
139 | onClicked: { |
|
140 | onClicked: { | |
140 | color = "white"; |
|
141 | color = "white"; | |
141 | borderColor = "blue"; |
|
142 | borderColor = "blue"; | |
142 | } |
|
143 | } | |
143 | } |
|
144 | } | |
|
145 | Component.onCompleted: { | |||
|
146 | createDefaultAxes(); | |||
|
147 | } | |||
144 | } |
|
148 | } | |
145 | } |
|
149 | } |
@@ -1,58 +1,63 | |||||
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 |
|
26 | |||
27 | //![1] |
|
27 | //![1] | |
28 | ChartView { |
|
28 | ChartView { | |
29 | title: "Scatters" |
|
29 | title: "Scatters" | |
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 |
|
31 | |||
32 | ScatterSeries { |
|
32 | ScatterSeries { | |
33 | id: scatter1 |
|
33 | id: scatter1 | |
34 | name: "Scatter1" |
|
34 | name: "Scatter1" | |
35 | XYPoint { x: 1.5; y: 1.5 } |
|
35 | XYPoint { x: 1.5; y: 1.5 } | |
36 | XYPoint { x: 1.5; y: 1.6 } |
|
36 | XYPoint { x: 1.5; y: 1.6 } | |
37 | XYPoint { x: 1.57; y: 1.55 } |
|
37 | XYPoint { x: 1.57; y: 1.55 } | |
38 | XYPoint { x: 1.8; y: 1.8 } |
|
38 | XYPoint { x: 1.8; y: 1.8 } | |
39 | XYPoint { x: 1.9; y: 1.6 } |
|
39 | XYPoint { x: 1.9; y: 1.6 } | |
40 | XYPoint { x: 2.1; y: 1.3 } |
|
40 | XYPoint { x: 2.1; y: 1.3 } | |
41 | XYPoint { x: 2.5; y: 2.1 } |
|
41 | XYPoint { x: 2.5; y: 2.1 } | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | ScatterSeries { |
|
44 | ScatterSeries { | |
45 | name: "Scatter2" |
|
45 | name: "Scatter2" | |
46 | // ... |
|
46 | // ... | |
47 | //![1] |
|
47 | //![1] | |
48 | XYPoint { x: 2.0; y: 2.0 } |
|
48 | XYPoint { x: 2.0; y: 2.0 } | |
49 | XYPoint { x: 2.0; y: 2.1 } |
|
49 | XYPoint { x: 2.0; y: 2.1 } | |
50 | XYPoint { x: 2.07; y: 2.05 } |
|
50 | XYPoint { x: 2.07; y: 2.05 } | |
51 | XYPoint { x: 2.2; y: 2.9 } |
|
51 | XYPoint { x: 2.2; y: 2.9 } | |
52 | XYPoint { x: 2.4; y: 2.7 } |
|
52 | XYPoint { x: 2.4; y: 2.7 } | |
53 | XYPoint { x: 2.67; y: 2.65 } |
|
53 | XYPoint { x: 2.67; y: 2.65 } | |
54 | //![2] |
|
54 | //![2] | |
55 | } |
|
55 | } | |
|
56 | ||||
|
57 | Component.onCompleted: { | |||
|
58 | createDefaultAxes(); | |||
|
59 | } | |||
|
60 | ||||
56 | } |
|
61 | } | |
57 | //![2] |
|
62 | //![2] | |
58 | } |
|
63 | } |
@@ -1,41 +1,48 | |||||
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 |
|
26 | |||
27 | //![1] |
|
27 | //![1] | |
28 | ChartView { |
|
28 | ChartView { | |
29 | title: "Bar series" |
|
29 | title: "Bar series" | |
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 | legend.alignment: Qt.AlignBottom |
|
31 | legend.alignment: Qt.AlignBottom | |
32 |
|
32 | CategoriesAxis { | ||
|
33 | id:myAxis | |||
|
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] | |||
|
35 | } | |||
33 | BarSeries { |
|
36 | BarSeries { | |
34 | axisX: CategoriesAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } |
|
37 | id: mySeries | |
35 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
36 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
39 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
37 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
40 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
38 | } |
|
41 | } | |
|
42 | Component.onCompleted: { | |||
|
43 | createDefaultAxes(); | |||
|
44 | setAxisX(myAxis,mySeries); | |||
|
45 | } | |||
39 | } |
|
46 | } | |
40 | //![1] |
|
47 | //![1] | |
41 | } |
|
48 | } |
@@ -1,41 +1,48 | |||||
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 |
|
26 | |||
27 | //![1] |
|
27 | //![1] | |
28 | ChartView { |
|
28 | ChartView { | |
29 |
title: " |
|
29 | title: "Stacked Bar series" | |
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 | legend.alignment: Qt.AlignBottom |
|
31 | legend.alignment: Qt.AlignBottom | |
32 |
|
32 | CategoriesAxis { | ||
33 | GroupedBarSeries { |
|
33 | id: myAxis; | |
34 |
|
|
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] | |
|
35 | } | |||
|
36 | StackedBarSeries { | |||
|
37 | id: mySeries; | |||
35 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
36 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
39 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
37 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
40 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
38 | } |
|
41 | } | |
|
42 | Component.onCompleted: { | |||
|
43 | createDefaultAxes(); | |||
|
44 | setAxisX(myAxis,mySeries); | |||
|
45 | } | |||
39 | } |
|
46 | } | |
40 | //![1] |
|
47 | //![1] | |
41 | } |
|
48 | } |
@@ -1,41 +1,49 | |||||
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 |
|
26 | |||
27 | //![1] |
|
27 | //![1] | |
28 | ChartView { |
|
28 | ChartView { | |
29 |
title: " |
|
29 | title: "Percent Bar series" | |
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 | legend.alignment: Qt.AlignBottom |
|
31 | legend.alignment: Qt.AlignBottom | |
32 |
|
32 | CategoriesAxis { | ||
33 | StackedBarSeries { |
|
33 | id: myAxis | |
34 |
|
|
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] | |
|
35 | } | |||
|
36 | PercentBarSeries { | |||
|
37 | id: mySeries | |||
35 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
36 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
39 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
37 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
40 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
38 | } |
|
41 | } | |
|
42 | Component.onCompleted: { | |||
|
43 | createDefaultAxes(); | |||
|
44 | setAxisX(myAxis,mySeries); | |||
|
45 | } | |||
39 | } |
|
46 | } | |
40 | //![1] |
|
47 | //![1] | |
41 | } |
|
48 | } | |
|
49 |
@@ -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: 1 | |
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 > |
|
77 | if (i > 8) | |
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 = |
|
86 | viewNumber = 8; | |
87 | else |
|
87 | else | |
88 | viewNumber = i; |
|
88 | viewNumber = i; | |
89 | } |
|
89 | } | |
90 | } |
|
90 | } |
@@ -1,15 +1,14 | |||||
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> |
|
|||
14 | </qresource> |
|
13 | </qresource> | |
15 | </RCC> |
|
14 | </RCC> |
@@ -1,393 +1,234 | |||||
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 | #include "declarativebarseries.h" |
|
21 | #include "declarativebarseries.h" | |
22 | #include "declarativechart.h" |
|
22 | #include "declarativechart.h" | |
23 | #include <QBarSet> |
|
23 | #include <QBarSet> | |
24 | #include <QVBarModelMapper> |
|
24 | #include <QVBarModelMapper> | |
25 | #include <QHBarModelMapper> |
|
25 | #include <QHBarModelMapper> | |
26 | #include <QAbstractAxis> |
|
26 | #include <QAbstractAxis> | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 | DeclarativeBarSet::DeclarativeBarSet(QObject *parent) : |
|
30 | DeclarativeBarSet::DeclarativeBarSet(QObject *parent) : | |
31 | QBarSet("", parent) |
|
31 | QBarSet("", parent) | |
32 | { |
|
32 | { | |
33 | connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int, int))); |
|
33 | connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int, int))); | |
34 | connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int, int))); |
|
34 | connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int, int))); | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | void DeclarativeBarSet::handleCountChanged(int index, int count) |
|
37 | void DeclarativeBarSet::handleCountChanged(int index, int count) | |
38 | { |
|
38 | { | |
39 | Q_UNUSED(index) |
|
39 | Q_UNUSED(index) | |
40 | Q_UNUSED(count) |
|
40 | Q_UNUSED(count) | |
41 | emit countChanged(QBarSet::count()); |
|
41 | emit countChanged(QBarSet::count()); | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | QVariantList DeclarativeBarSet::values() |
|
44 | QVariantList DeclarativeBarSet::values() | |
45 | { |
|
45 | { | |
46 | QVariantList values; |
|
46 | QVariantList values; | |
47 | for (int i(0); i < count(); i++) |
|
47 | for (int i(0); i < count(); i++) | |
48 | values.append(QVariant(QBarSet::at(i))); |
|
48 | values.append(QVariant(QBarSet::at(i))); | |
49 | return values; |
|
49 | return values; | |
50 | } |
|
50 | } | |
51 |
|
51 | |||
52 | void DeclarativeBarSet::setValues(QVariantList values) |
|
52 | void DeclarativeBarSet::setValues(QVariantList values) | |
53 | { |
|
53 | { | |
54 | while (count()) |
|
54 | while (count()) | |
55 | remove(count() - 1); |
|
55 | remove(count() - 1); | |
56 |
|
56 | |||
57 | for (int i(0); i < values.count(); i++) { |
|
57 | for (int i(0); i < values.count(); i++) { | |
58 | if (values.at(i).canConvert(QVariant::Double)) |
|
58 | if (values.at(i).canConvert(QVariant::Double)) | |
59 | QBarSet::append(values[i].toDouble()); |
|
59 | QBarSet::append(values[i].toDouble()); | |
60 | } |
|
60 | } | |
61 | } |
|
61 | } | |
62 |
|
62 | |||
63 | DeclarativeAbstractBarSeries::DeclarativeAbstractBarSeries(QDeclarativeItem *parent) : |
|
|||
64 | QAbstractBarSeries(parent) |
|
|||
65 | { |
|
|||
66 | connect(this, SIGNAL(barsetsAdded(QList<QBarSet*>)), this, SLOT(handleAdded(QList<QBarSet*>))); |
|
|||
67 | connect(this, SIGNAL(barsetsRemoved(QList<QBarSet*>)), this, SLOT(handleRemoved(QList<QBarSet*>))); |
|
|||
68 | } |
|
|||
69 |
|
||||
70 | void DeclarativeAbstractBarSeries::handleAdded(QList<QBarSet* > barsets) |
|
|||
71 | { |
|
|||
72 | foreach(QBarSet *b, barsets) { |
|
|||
73 | DeclarativeBarSet *barset = qobject_cast<DeclarativeBarSet *>(b); |
|
|||
74 | emit added(barset); |
|
|||
75 | } |
|
|||
76 | } |
|
|||
77 |
|
||||
78 | void DeclarativeAbstractBarSeries::handleRemoved(QList<QBarSet* > barsets) |
|
|||
79 | { |
|
|||
80 | foreach(QBarSet *b, barsets) { |
|
|||
81 | DeclarativeBarSet *barset = qobject_cast<DeclarativeBarSet *>(b); |
|
|||
82 | emit removed(barset); |
|
|||
83 | } |
|
|||
84 | } |
|
|||
85 |
|
||||
86 | void DeclarativeAbstractBarSeries::classBegin() |
|
|||
87 | { |
|
|||
88 | } |
|
|||
89 |
|
||||
90 | void DeclarativeAbstractBarSeries::componentComplete() |
|
|||
91 | { |
|
|||
92 | foreach(QObject *child, children()) { |
|
|||
93 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
|||
94 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
|||
95 | } else if (qobject_cast<QVBarModelMapper *>(child)) { |
|
|||
96 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
|||
97 | mapper->setSeries(this); |
|
|||
98 | } else if (qobject_cast<QHBarModelMapper *>(child)) { |
|
|||
99 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
|||
100 | mapper->setSeries(this); |
|
|||
101 | } |
|
|||
102 | } |
|
|||
103 | } |
|
|||
104 |
|
||||
105 | void DeclarativeAbstractBarSeries::setAxisX(QAbstractAxis *axis) |
|
|||
106 | { |
|
|||
107 | chart()->setAxisX(axis, this); |
|
|||
108 | } |
|
|||
109 |
|
||||
110 | QAbstractAxis *DeclarativeAbstractBarSeries::axisX() |
|
|||
111 | { |
|
|||
112 | return chart()->axisX(this); |
|
|||
113 | } |
|
|||
114 |
|
||||
115 | void DeclarativeAbstractBarSeries::setAxisY(QAbstractAxis *axis) |
|
|||
116 | { |
|
|||
117 | chart()->setAxisY(axis, this); |
|
|||
118 | } |
|
|||
119 |
|
||||
120 | QAbstractAxis *DeclarativeAbstractBarSeries::axisY() |
|
|||
121 | { |
|
|||
122 | return chart()->axisY(this); |
|
|||
123 | } |
|
|||
124 |
|
||||
125 | QDeclarativeListProperty<QObject> DeclarativeAbstractBarSeries::seriesChildren() |
|
|||
126 | { |
|
|||
127 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeAbstractBarSeries::appendSeriesChildren); |
|
|||
128 | } |
|
|||
129 |
|
||||
130 | void DeclarativeAbstractBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
|||
131 | { |
|
|||
132 | // Empty implementation; the children are parsed in componentComplete instead |
|
|||
133 | Q_UNUSED(list); |
|
|||
134 | Q_UNUSED(element); |
|
|||
135 | } |
|
|||
136 |
|
||||
137 | DeclarativeBarSet *DeclarativeAbstractBarSeries::at(int index) |
|
|||
138 | { |
|
|||
139 | QList<QBarSet*> setList = barSets(); |
|
|||
140 | if (index >= 0 && index < setList.count()) |
|
|||
141 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
|||
142 |
|
||||
143 | return 0; |
|
|||
144 | } |
|
|||
145 |
|
||||
146 | DeclarativeBarSet *DeclarativeAbstractBarSeries::insert(int index, QString label, QVariantList values) |
|
|||
147 | { |
|
|||
148 | int insertIndex = index; |
|
|||
149 | if (insertIndex < 0) |
|
|||
150 | insertIndex = 0; |
|
|||
151 | else if (insertIndex > count()) |
|
|||
152 | insertIndex = count(); |
|
|||
153 |
|
||||
154 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
|||
155 | barset->setLabel(label); |
|
|||
156 | barset->setValues(values); |
|
|||
157 | if (QAbstractBarSeries::insert(insertIndex, barset)) |
|
|||
158 | return barset; |
|
|||
159 | delete barset; |
|
|||
160 | return 0; |
|
|||
161 | } |
|
|||
162 |
|
||||
163 | DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : |
|
63 | DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : | |
164 | QBarSeries(parent) |
|
64 | QBarSeries(parent) | |
165 | { |
|
65 | { | |
166 | } |
|
66 | } | |
167 |
|
67 | |||
168 | void DeclarativeBarSeries::classBegin() |
|
68 | void DeclarativeBarSeries::classBegin() | |
169 | { |
|
69 | { | |
170 | } |
|
70 | } | |
171 |
|
71 | |||
172 | void DeclarativeBarSeries::componentComplete() |
|
72 | void DeclarativeBarSeries::componentComplete() | |
173 | { |
|
73 | { | |
174 | foreach(QObject *child, children()) { |
|
74 | foreach(QObject *child, children()) { | |
175 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
75 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
176 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
76 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
177 | } else if(qobject_cast<QVBarModelMapper *>(child)) { |
|
77 | } else if(qobject_cast<QVBarModelMapper *>(child)) { | |
178 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
78 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
179 | mapper->setSeries(this); |
|
79 | mapper->setSeries(this); | |
180 | } else if(qobject_cast<QHBarModelMapper *>(child)) { |
|
80 | } else if(qobject_cast<QHBarModelMapper *>(child)) { | |
181 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
81 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
182 | mapper->setSeries(this); |
|
82 | mapper->setSeries(this); | |
183 | } |
|
83 | } | |
184 | } |
|
84 | } | |
185 | } |
|
85 | } | |
186 |
|
86 | |||
187 | void DeclarativeBarSeries::setAxisX(QAbstractAxis *axis) |
|
|||
188 | { |
|
|||
189 | chart()->setAxisX(axis, this); |
|
|||
190 | } |
|
|||
191 |
|
||||
192 | QAbstractAxis *DeclarativeBarSeries::axisX() |
|
|||
193 | { |
|
|||
194 | return chart()->axisX(this); |
|
|||
195 | } |
|
|||
196 |
|
||||
197 | void DeclarativeBarSeries::setAxisY(QAbstractAxis *axis) |
|
|||
198 | { |
|
|||
199 | chart()->setAxisY(axis, this); |
|
|||
200 | } |
|
|||
201 |
|
||||
202 | QAbstractAxis *DeclarativeBarSeries::axisY() |
|
|||
203 | { |
|
|||
204 | return chart()->axisY(this); |
|
|||
205 | } |
|
|||
206 |
|
||||
207 | QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren() |
|
87 | QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren() | |
208 | { |
|
88 | { | |
209 |
return QDeclarativeListProperty<QObject>(this, 0, &Declarative |
|
89 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); | |
210 | } |
|
90 | } | |
211 |
|
91 | |||
212 | void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
92 | void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
213 | { |
|
93 | { | |
214 | // Empty implementation; the children are parsed in componentComplete instead |
|
94 | // Empty implementation; the children are parsed in componentComplete instead | |
215 | Q_UNUSED(list); |
|
95 | Q_UNUSED(list); | |
216 | Q_UNUSED(element); |
|
96 | Q_UNUSED(element); | |
217 | } |
|
97 | } | |
218 |
|
98 | |||
219 | DeclarativeBarSet *DeclarativeBarSeries::at(int index) |
|
99 | DeclarativeBarSet *DeclarativeBarSeries::at(int index) | |
220 | { |
|
100 | { | |
221 | QList<QBarSet*> setList = barSets(); |
|
101 | QList<QBarSet*> setList = barSets(); | |
222 | if (index >= 0 && index < setList.count()) |
|
102 | if (index >= 0 && index < setList.count()) | |
223 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
103 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
224 |
|
104 | |||
225 | return 0; |
|
105 | return 0; | |
226 | } |
|
106 | } | |
227 |
|
107 | |||
228 | DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values) |
|
108 | DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values) | |
229 | { |
|
109 | { | |
230 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
110 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
231 | barset->setLabel(label); |
|
111 | barset->setLabel(label); | |
232 | barset->setValues(values); |
|
112 | barset->setValues(values); | |
233 | if (QBarSeries::insert(index, barset)) |
|
113 | if (QBarSeries::insert(index, barset)) | |
234 | return barset; |
|
114 | return barset; | |
235 | delete barset; |
|
115 | delete barset; | |
236 | return 0; |
|
116 | return 0; | |
237 | } |
|
117 | } | |
238 |
|
118 | |||
239 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) : |
|
119 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) : | |
240 | QStackedBarSeries(parent) |
|
120 | QStackedBarSeries(parent) | |
241 | { |
|
121 | { | |
242 | } |
|
122 | } | |
243 |
|
123 | |||
244 | void DeclarativeStackedBarSeries::classBegin() |
|
124 | void DeclarativeStackedBarSeries::classBegin() | |
245 | { |
|
125 | { | |
246 | } |
|
126 | } | |
247 |
|
127 | |||
248 | void DeclarativeStackedBarSeries::componentComplete() |
|
128 | void DeclarativeStackedBarSeries::componentComplete() | |
249 | { |
|
129 | { | |
250 | foreach(QObject *child, children()) { |
|
130 | foreach(QObject *child, children()) { | |
251 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
131 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
252 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
132 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
253 | } else if(qobject_cast<QVBarModelMapper *>(child)) { |
|
133 | } else if(qobject_cast<QVBarModelMapper *>(child)) { | |
254 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
134 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
255 | mapper->setSeries(this); |
|
135 | mapper->setSeries(this); | |
256 | } else if(qobject_cast<QHBarModelMapper *>(child)) { |
|
136 | } else if(qobject_cast<QHBarModelMapper *>(child)) { | |
257 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
137 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
258 | mapper->setSeries(this); |
|
138 | mapper->setSeries(this); | |
259 | } |
|
139 | } | |
260 | } |
|
140 | } | |
261 | } |
|
141 | } | |
262 |
|
142 | |||
263 | void DeclarativeStackedBarSeries::setAxisX(QAbstractAxis *axis) |
|
|||
264 | { |
|
|||
265 | chart()->setAxisX(axis, this); |
|
|||
266 | } |
|
|||
267 |
|
||||
268 | QAbstractAxis *DeclarativeStackedBarSeries::axisX() |
|
|||
269 | { |
|
|||
270 | return chart()->axisX(this); |
|
|||
271 | } |
|
|||
272 |
|
||||
273 | void DeclarativeStackedBarSeries::setAxisY(QAbstractAxis *axis) |
|
|||
274 | { |
|
|||
275 | chart()->setAxisY(axis, this); |
|
|||
276 | } |
|
|||
277 |
|
||||
278 | QAbstractAxis *DeclarativeStackedBarSeries::axisY() |
|
|||
279 | { |
|
|||
280 | return chart()->axisY(this); |
|
|||
281 | } |
|
|||
282 |
|
143 | |||
283 | QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren() |
|
144 | QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren() | |
284 | { |
|
145 | { | |
285 |
return QDeclarativeListProperty<QObject>(this, 0, &Declarative |
|
146 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); | |
286 | } |
|
147 | } | |
287 |
|
148 | |||
288 | void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
149 | void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
289 | { |
|
150 | { | |
290 | // Empty implementation; the children are parsed in componentComplete instead |
|
151 | // Empty implementation; the children are parsed in componentComplete instead | |
291 | Q_UNUSED(list); |
|
152 | Q_UNUSED(list); | |
292 | Q_UNUSED(element); |
|
153 | Q_UNUSED(element); | |
293 | } |
|
154 | } | |
294 |
|
155 | |||
295 | DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index) |
|
156 | DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index) | |
296 | { |
|
157 | { | |
297 | QList<QBarSet*> setList = barSets(); |
|
158 | QList<QBarSet*> setList = barSets(); | |
298 | if (index >= 0 && index < setList.count()) |
|
159 | if (index >= 0 && index < setList.count()) | |
299 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
160 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
300 |
|
161 | |||
301 | return 0; |
|
162 | return 0; | |
302 | } |
|
163 | } | |
303 |
|
164 | |||
304 | DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, QVariantList values) |
|
165 | DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, QVariantList values) | |
305 | { |
|
166 | { | |
306 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
167 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
307 | barset->setLabel(label); |
|
168 | barset->setLabel(label); | |
308 | barset->setValues(values); |
|
169 | barset->setValues(values); | |
309 | if (QStackedBarSeries::insert(index, barset)) |
|
170 | if (QStackedBarSeries::insert(index, barset)) | |
310 | return barset; |
|
171 | return barset; | |
311 | delete barset; |
|
172 | delete barset; | |
312 | return 0; |
|
173 | return 0; | |
313 | } |
|
174 | } | |
314 |
|
175 | |||
315 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) : |
|
176 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) : | |
316 | QPercentBarSeries(parent) |
|
177 | QPercentBarSeries(parent) | |
317 | { |
|
178 | { | |
318 | } |
|
179 | } | |
319 |
|
180 | |||
320 | void DeclarativePercentBarSeries::classBegin() |
|
181 | void DeclarativePercentBarSeries::classBegin() | |
321 | { |
|
182 | { | |
322 | } |
|
183 | } | |
323 |
|
184 | |||
324 | void DeclarativePercentBarSeries::componentComplete() |
|
185 | void DeclarativePercentBarSeries::componentComplete() | |
325 | { |
|
186 | { | |
326 | foreach(QObject *child, children()) { |
|
187 | foreach(QObject *child, children()) { | |
327 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
188 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
328 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
189 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
329 | } else if(qobject_cast<QVBarModelMapper *>(child)) { |
|
190 | } else if(qobject_cast<QVBarModelMapper *>(child)) { | |
330 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
191 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
331 | mapper->setSeries(this); |
|
192 | mapper->setSeries(this); | |
332 | } else if(qobject_cast<QHBarModelMapper *>(child)) { |
|
193 | } else if(qobject_cast<QHBarModelMapper *>(child)) { | |
333 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
194 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
334 | mapper->setSeries(this); |
|
195 | mapper->setSeries(this); | |
335 | } |
|
196 | } | |
336 | } |
|
197 | } | |
337 | } |
|
198 | } | |
338 |
|
199 | |||
339 | void DeclarativePercentBarSeries::setAxisX(QAbstractAxis *axis) |
|
|||
340 | { |
|
|||
341 | chart()->setAxisX(axis, this); |
|
|||
342 | } |
|
|||
343 |
|
||||
344 | QAbstractAxis *DeclarativePercentBarSeries::axisX() |
|
|||
345 | { |
|
|||
346 | return chart()->axisX(this); |
|
|||
347 | } |
|
|||
348 |
|
||||
349 | void DeclarativePercentBarSeries::setAxisY(QAbstractAxis *axis) |
|
|||
350 | { |
|
|||
351 | chart()->setAxisY(axis, this); |
|
|||
352 | } |
|
|||
353 |
|
||||
354 | QAbstractAxis *DeclarativePercentBarSeries::axisY() |
|
|||
355 | { |
|
|||
356 | return chart()->axisY(this); |
|
|||
357 | } |
|
|||
358 |
|
||||
359 | QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren() |
|
200 | QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren() | |
360 | { |
|
201 | { | |
361 |
return QDeclarativeListProperty<QObject>(this, 0, &Declarative |
|
202 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); | |
362 | } |
|
203 | } | |
363 |
|
204 | |||
364 | void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
205 | void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
365 | { |
|
206 | { | |
366 | // Empty implementation; the children are parsed in componentComplete instead |
|
207 | // Empty implementation; the children are parsed in componentComplete instead | |
367 | Q_UNUSED(list); |
|
208 | Q_UNUSED(list); | |
368 | Q_UNUSED(element); |
|
209 | Q_UNUSED(element); | |
369 | } |
|
210 | } | |
370 |
|
211 | |||
371 | DeclarativeBarSet *DeclarativePercentBarSeries::at(int index) |
|
212 | DeclarativeBarSet *DeclarativePercentBarSeries::at(int index) | |
372 | { |
|
213 | { | |
373 | QList<QBarSet*> setList = barSets(); |
|
214 | QList<QBarSet*> setList = barSets(); | |
374 | if (index >= 0 && index < setList.count()) |
|
215 | if (index >= 0 && index < setList.count()) | |
375 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
216 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
376 |
|
217 | |||
377 | return 0; |
|
218 | return 0; | |
378 | } |
|
219 | } | |
379 |
|
220 | |||
380 | DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, QVariantList values) |
|
221 | DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, QVariantList values) | |
381 | { |
|
222 | { | |
382 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
223 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
383 | barset->setLabel(label); |
|
224 | barset->setLabel(label); | |
384 | barset->setValues(values); |
|
225 | barset->setValues(values); | |
385 | if (QPercentBarSeries::insert(index, barset)) |
|
226 | if (QPercentBarSeries::insert(index, barset)) | |
386 | return barset; |
|
227 | return barset; | |
387 | delete barset; |
|
228 | delete barset; | |
388 | return 0; |
|
229 | return 0; | |
389 | } |
|
230 | } | |
390 |
|
231 | |||
391 | #include "moc_declarativebarseries.cpp" |
|
232 | #include "moc_declarativebarseries.cpp" | |
392 |
|
233 | |||
393 | QTCOMMERCIALCHART_END_NAMESPACE |
|
234 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,190 +1,145 | |||||
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 | #ifndef DECLARATIVEBARSERIES_H |
|
21 | #ifndef DECLARATIVEBARSERIES_H | |
22 | #define DECLARATIVEBARSERIES_H |
|
22 | #define DECLARATIVEBARSERIES_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "qabstractbarseries.h" |
|
25 | #include "qabstractbarseries.h" | |
26 | #include "qbarseries.h" |
|
26 | #include "qbarseries.h" | |
27 | #include "qstackedbarseries.h" |
|
27 | #include "qstackedbarseries.h" | |
28 | #include "qpercentbarseries.h" |
|
28 | #include "qpercentbarseries.h" | |
29 | #include "qbarset.h" |
|
29 | #include "qbarset.h" | |
30 | #include "qabstractaxis.h" |
|
30 | #include "qabstractaxis.h" | |
31 | #include <QDeclarativeItem> |
|
31 | #include <QDeclarativeItem> | |
32 | #include <QDeclarativeParserStatus> |
|
32 | #include <QDeclarativeParserStatus> | |
33 |
|
33 | |||
34 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
34 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
35 |
|
35 | |||
36 | class QChart; |
|
36 | class QChart; | |
37 |
|
37 | |||
38 | class DeclarativeBarSet : public QBarSet |
|
38 | class DeclarativeBarSet : public QBarSet | |
39 | { |
|
39 | { | |
40 | Q_OBJECT |
|
40 | Q_OBJECT | |
41 | Q_PROPERTY(QVariantList values READ values WRITE setValues) |
|
41 | Q_PROPERTY(QVariantList values READ values WRITE setValues) | |
42 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
42 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
43 |
|
43 | |||
44 | public: |
|
44 | public: | |
45 | explicit DeclarativeBarSet(QObject *parent = 0); |
|
45 | explicit DeclarativeBarSet(QObject *parent = 0); | |
46 | QVariantList values(); |
|
46 | QVariantList values(); | |
47 | void setValues(QVariantList values); |
|
47 | void setValues(QVariantList values); | |
48 |
|
48 | |||
49 | public: // From QBarSet |
|
49 | public: // From QBarSet | |
50 | Q_INVOKABLE void append(qreal value) { QBarSet::append(value); } |
|
50 | Q_INVOKABLE void append(qreal value) { QBarSet::append(value); } | |
51 | Q_INVOKABLE void remove(const int index, const int count = 1) { QBarSet::remove(index, count); } |
|
51 | Q_INVOKABLE void remove(const int index, const int count = 1) { QBarSet::remove(index, count); } | |
52 | Q_INVOKABLE void replace(int index, qreal value) { QBarSet::replace(index, value); } |
|
52 | Q_INVOKABLE void replace(int index, qreal value) { QBarSet::replace(index, value); } | |
53 | Q_INVOKABLE qreal at(int index) { return QBarSet::at(index); } |
|
53 | Q_INVOKABLE qreal at(int index) { return QBarSet::at(index); } | |
54 |
|
54 | |||
55 | Q_SIGNALS: |
|
55 | Q_SIGNALS: | |
56 | void countChanged(int count); |
|
56 | void countChanged(int count); | |
57 |
|
57 | |||
58 | private Q_SLOTS: |
|
58 | private Q_SLOTS: | |
59 | void handleCountChanged(int index, int count); |
|
59 | void handleCountChanged(int index, int count); | |
60 | }; |
|
60 | }; | |
61 |
|
61 | |||
62 | class DeclarativeAbstractBarSeries : public QAbstractBarSeries, public QDeclarativeParserStatus |
|
|||
63 | { |
|
|||
64 | Q_OBJECT |
|
|||
65 | Q_INTERFACES(QDeclarativeParserStatus) |
|
|||
66 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
|||
67 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX) |
|
|||
68 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY) |
|
|||
69 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
|||
70 |
|
||||
71 | public: |
|
|||
72 | explicit DeclarativeAbstractBarSeries(QDeclarativeItem *parent = 0); |
|
|||
73 | void setAxisX(QAbstractAxis *axis); |
|
|||
74 | QAbstractAxis *axisX(); |
|
|||
75 | void setAxisY(QAbstractAxis *axis); |
|
|||
76 | QAbstractAxis *axisY(); |
|
|||
77 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
|||
78 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
|||
79 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
|||
80 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
|||
81 | Q_INVOKABLE bool remove(QBarSet *barset) { return QAbstractBarSeries::remove(barset); } |
|
|||
82 | Q_INVOKABLE void clear() { return QAbstractBarSeries::clear(); } |
|
|||
83 |
|
||||
84 | public: // from QDeclarativeParserStatus |
|
|||
85 | void classBegin(); |
|
|||
86 | void componentComplete(); |
|
|||
87 |
|
||||
88 | Q_SIGNALS: |
|
|||
89 | void added(DeclarativeBarSet *barset); |
|
|||
90 | void removed(DeclarativeBarSet *barset); |
|
|||
91 |
|
||||
92 | public Q_SLOTS: |
|
|||
93 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
|||
94 | void handleAdded(QList<QBarSet* > barsets); |
|
|||
95 | void handleRemoved(QList<QBarSet* > barsets); |
|
|||
96 | }; |
|
|||
97 |
|
||||
98 | class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus |
|
62 | class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus | |
99 | { |
|
63 | { | |
100 | Q_OBJECT |
|
64 | Q_OBJECT | |
101 | Q_INTERFACES(QDeclarativeParserStatus) |
|
65 | Q_INTERFACES(QDeclarativeParserStatus) | |
102 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX) |
|
|||
103 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY) |
|
|||
104 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
66 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
105 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
67 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
106 |
|
68 | |||
107 | public: |
|
69 | public: | |
108 | explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0); |
|
70 | explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0); | |
109 | void setAxisX(QAbstractAxis *axis); |
|
71 | void setAxisX(QAbstractAxis *axis); | |
110 | QAbstractAxis *axisX(); |
|
72 | QAbstractAxis *axisX(); | |
111 | void setAxisY(QAbstractAxis *axis); |
|
73 | void setAxisY(QAbstractAxis *axis); | |
112 | QAbstractAxis *axisY(); |
|
74 | QAbstractAxis *axisY(); | |
113 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
75 | QDeclarativeListProperty<QObject> seriesChildren(); | |
114 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
76 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
115 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
77 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
116 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
78 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
117 | Q_INVOKABLE bool remove(QBarSet *barset) { return QBarSeries::remove(barset); } |
|
79 | Q_INVOKABLE bool remove(QBarSet *barset) { return QBarSeries::remove(barset); } | |
118 | Q_INVOKABLE void clear() { return QBarSeries::clear(); } |
|
80 | Q_INVOKABLE void clear() { return QBarSeries::clear(); } | |
119 |
|
81 | |||
120 | public: // from QDeclarativeParserStatus |
|
82 | public: // from QDeclarativeParserStatus | |
121 | void classBegin(); |
|
83 | void classBegin(); | |
122 | void componentComplete(); |
|
84 | void componentComplete(); | |
123 |
|
85 | |||
124 | public Q_SLOTS: |
|
86 | public Q_SLOTS: | |
125 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
87 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
|
88 | ||||
|
89 | private: | |||
|
90 | QAbstractAxis* m_axisX; | |||
|
91 | QAbstractAxis* m_axisY; | |||
126 | }; |
|
92 | }; | |
127 |
|
93 | |||
128 | class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus |
|
94 | class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus | |
129 | { |
|
95 | { | |
130 | Q_OBJECT |
|
96 | Q_OBJECT | |
131 | Q_INTERFACES(QDeclarativeParserStatus) |
|
97 | Q_INTERFACES(QDeclarativeParserStatus) | |
132 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX) |
|
|||
133 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY) |
|
|||
134 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
98 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
135 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
99 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
136 |
|
100 | |||
137 | public: |
|
101 | public: | |
138 | explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0); |
|
102 | explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0); | |
139 | void setAxisX(QAbstractAxis *axis); |
|
|||
140 | QAbstractAxis *axisX(); |
|
|||
141 | void setAxisY(QAbstractAxis *axis); |
|
|||
142 | QAbstractAxis *axisY(); |
|
|||
143 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
103 | QDeclarativeListProperty<QObject> seriesChildren(); | |
144 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
104 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
145 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
105 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
146 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
106 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
147 | Q_INVOKABLE bool remove(QBarSet *barset) { return QStackedBarSeries::remove(barset); } |
|
107 | Q_INVOKABLE bool remove(QBarSet *barset) { return QStackedBarSeries::remove(barset); } | |
148 | Q_INVOKABLE void clear() { return QStackedBarSeries::clear(); } |
|
108 | Q_INVOKABLE void clear() { return QStackedBarSeries::clear(); } | |
149 |
|
109 | |||
150 | public: // from QDeclarativeParserStatus |
|
110 | public: // from QDeclarativeParserStatus | |
151 | void classBegin(); |
|
111 | void classBegin(); | |
152 | void componentComplete(); |
|
112 | void componentComplete(); | |
153 |
|
113 | |||
154 | public Q_SLOTS: |
|
114 | public Q_SLOTS: | |
155 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
115 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
|
116 | ||||
156 | }; |
|
117 | }; | |
157 |
|
118 | |||
158 | class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus |
|
119 | class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus | |
159 | { |
|
120 | { | |
160 | Q_OBJECT |
|
121 | Q_OBJECT | |
161 | Q_INTERFACES(QDeclarativeParserStatus) |
|
122 | Q_INTERFACES(QDeclarativeParserStatus) | |
162 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX) |
|
|||
163 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY) |
|
|||
164 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
123 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
165 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
124 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
166 |
|
125 | |||
167 | public: |
|
126 | public: | |
168 | explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0); |
|
127 | explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0); | |
169 | void setAxisX(QAbstractAxis *axis); |
|
|||
170 | QAbstractAxis *axisX(); |
|
|||
171 | void setAxisY(QAbstractAxis *axis); |
|
|||
172 | QAbstractAxis *axisY(); |
|
|||
173 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
128 | QDeclarativeListProperty<QObject> seriesChildren(); | |
174 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
129 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
175 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
130 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
176 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
131 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
177 | Q_INVOKABLE bool remove(QBarSet *barset) { return QPercentBarSeries::remove(barset); } |
|
132 | Q_INVOKABLE bool remove(QBarSet *barset) { return QPercentBarSeries::remove(barset); } | |
178 | Q_INVOKABLE void clear() { return QPercentBarSeries::clear(); } |
|
133 | Q_INVOKABLE void clear() { return QPercentBarSeries::clear(); } | |
179 |
|
134 | |||
180 | public: // from QDeclarativeParserStatus |
|
135 | public: // from QDeclarativeParserStatus | |
181 | void classBegin(); |
|
136 | void classBegin(); | |
182 | void componentComplete(); |
|
137 | void componentComplete(); | |
183 |
|
138 | |||
184 | public Q_SLOTS: |
|
139 | public Q_SLOTS: | |
185 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
140 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
186 | }; |
|
141 | }; | |
187 |
|
142 | |||
188 | QTCOMMERCIALCHART_END_NAMESPACE |
|
143 | QTCOMMERCIALCHART_END_NAMESPACE | |
189 |
|
144 | |||
190 | #endif // DECLARATIVEBARSERIES_H |
|
145 | #endif // DECLARATIVEBARSERIES_H |
@@ -1,504 +1,515 | |||||
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 | #include "declarativechart.h" |
|
21 | #include "declarativechart.h" | |
22 | #include <QPainter> |
|
22 | #include <QPainter> | |
23 | #include "declarativelineseries.h" |
|
23 | #include "declarativelineseries.h" | |
24 | #include "declarativeareaseries.h" |
|
24 | #include "declarativeareaseries.h" | |
25 | #include "declarativebarseries.h" |
|
25 | #include "declarativebarseries.h" | |
26 | #include "declarativepieseries.h" |
|
26 | #include "declarativepieseries.h" | |
27 | #include "declarativesplineseries.h" |
|
27 | #include "declarativesplineseries.h" | |
28 | #include "declarativescatterseries.h" |
|
28 | #include "declarativescatterseries.h" | |
29 | #include "qcategoriesaxis.h" |
|
29 | #include "qcategoriesaxis.h" | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | /*! |
|
33 | /*! | |
34 | \qmlclass ChartView DeclarativeChart |
|
34 | \qmlclass ChartView DeclarativeChart | |
35 |
|
35 | |||
36 | ChartView element is the parent that is responsible for showing different chart series types. |
|
36 | ChartView element is the parent that is responsible for showing different chart series types. | |
37 |
|
37 | |||
38 | The following QML shows how to create a simple chart with one pie series: |
|
38 | The following QML shows how to create a simple chart with one pie series: | |
39 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 |
|
39 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 | |
40 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 |
|
40 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 | |
41 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 |
|
41 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 | |
42 |
|
42 | |||
43 | \beginfloatleft |
|
43 | \beginfloatleft | |
44 | \image examples_qmlpiechart.png |
|
44 | \image examples_qmlpiechart.png | |
45 | \endfloat |
|
45 | \endfloat | |
46 | \clearfloat |
|
46 | \clearfloat | |
47 | */ |
|
47 | */ | |
48 |
|
48 | |||
49 | /*! |
|
49 | /*! | |
50 | \qmlproperty Theme ChartView::theme |
|
50 | \qmlproperty Theme ChartView::theme | |
51 | Theme defines the visual appearance of the chart, including for example colors, fonts, line |
|
51 | Theme defines the visual appearance of the chart, including for example colors, fonts, line | |
52 | widths and chart background. |
|
52 | widths and chart background. | |
53 | */ |
|
53 | */ | |
54 |
|
54 | |||
55 | /*! |
|
55 | /*! | |
56 | \qmlproperty Animation ChartView::animation |
|
56 | \qmlproperty Animation ChartView::animation | |
57 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, |
|
57 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, | |
58 | ChartView.SeriesAnimations or ChartView.AllAnimations. |
|
58 | ChartView.SeriesAnimations or ChartView.AllAnimations. | |
59 | */ |
|
59 | */ | |
60 |
|
60 | |||
61 | /*! |
|
61 | /*! | |
62 | \qmlproperty Font ChartView::titleFont |
|
62 | \qmlproperty Font ChartView::titleFont | |
63 | The title font of the chart |
|
63 | The title font of the chart | |
64 |
|
64 | |||
65 | See the \l {Font} {QML Font Element} for detailed documentation. |
|
65 | See the \l {Font} {QML Font Element} for detailed documentation. | |
66 | */ |
|
66 | */ | |
67 |
|
67 | |||
68 | /*! |
|
68 | /*! | |
69 | \qmlproperty string ChartView::title |
|
69 | \qmlproperty string ChartView::title | |
70 | The title of the chart, shown on top of the chart. |
|
70 | The title of the chart, shown on top of the chart. | |
71 | \sa ChartView::titleColor |
|
71 | \sa ChartView::titleColor | |
72 | */ |
|
72 | */ | |
73 |
|
73 | |||
74 | /*! |
|
74 | /*! | |
75 | \qmlproperty string ChartView::titleColor |
|
75 | \qmlproperty string ChartView::titleColor | |
76 | The color of the title text. |
|
76 | The color of the title text. | |
77 | */ |
|
77 | */ | |
78 |
|
78 | |||
79 | /*! |
|
79 | /*! | |
80 | \qmlproperty Axis ChartView::axisX |
|
80 | \qmlproperty Axis ChartView::axisX | |
81 | The x-axis of the chart. |
|
81 | The x-axis of the chart. | |
82 | */ |
|
82 | */ | |
83 |
|
83 | |||
84 | /*! |
|
84 | /*! | |
85 | \qmlproperty Axis ChartView::axisY |
|
85 | \qmlproperty Axis ChartView::axisY | |
86 | The default y-axis of the chart. |
|
86 | The default y-axis of the chart. | |
87 | */ |
|
87 | */ | |
88 |
|
88 | |||
89 | /*! |
|
89 | /*! | |
90 | \qmlproperty Legend ChartView::legend |
|
90 | \qmlproperty Legend ChartView::legend | |
91 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. |
|
91 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. | |
92 | */ |
|
92 | */ | |
93 |
|
93 | |||
94 | /*! |
|
94 | /*! | |
95 | \qmlproperty int ChartView::count |
|
95 | \qmlproperty int ChartView::count | |
96 | The count of series added to the chart. |
|
96 | The count of series added to the chart. | |
97 | */ |
|
97 | */ | |
98 |
|
98 | |||
99 | /*! |
|
99 | /*! | |
100 | \qmlproperty color ChartView::backgroundColor |
|
100 | \qmlproperty color ChartView::backgroundColor | |
101 | The color of the chart's background. By default background color is defined by chart theme. |
|
101 | The color of the chart's background. By default background color is defined by chart theme. | |
102 | \sa ChartView::theme |
|
102 | \sa ChartView::theme | |
103 | */ |
|
103 | */ | |
104 |
|
104 | |||
105 | /*! |
|
105 | /*! | |
106 | \qmlproperty bool ChartView::dropShadowEnabled |
|
106 | \qmlproperty bool ChartView::dropShadowEnabled | |
107 | The chart's border drop shadow. Set to true to enable drop shadow. |
|
107 | The chart's border drop shadow. Set to true to enable drop shadow. | |
108 | */ |
|
108 | */ | |
109 |
|
109 | |||
110 | /*! |
|
110 | /*! | |
111 | \qmlproperty real ChartView::topMargin |
|
111 | \qmlproperty real ChartView::topMargin | |
112 | The space between the top of chart view and the top of the plot area. The title (if non-empty) is drawn on top margin |
|
112 | The space between the top of chart view and the top of the plot area. The title (if non-empty) is drawn on top margin | |
113 | area of the chart view. Top margin area is also used by legend, if aligned to top. |
|
113 | area of the chart view. Top margin area is also used by legend, if aligned to top. | |
114 | */ |
|
114 | */ | |
115 |
|
115 | |||
116 | /*! |
|
116 | /*! | |
117 | \qmlproperty real ChartView::bottomMargin |
|
117 | \qmlproperty real ChartView::bottomMargin | |
118 | The space between the bottom of chart view and the bottom of the plot area. The bottom margin area may be used by |
|
118 | The space between the bottom of chart view and the bottom of the plot area. The bottom margin area may be used by | |
119 | legend (if aligned to bottom), x-axis, x-axis labels and x-axis tick marks. |
|
119 | legend (if aligned to bottom), x-axis, x-axis labels and x-axis tick marks. | |
120 | */ |
|
120 | */ | |
121 |
|
121 | |||
122 | /*! |
|
122 | /*! | |
123 | \qmlproperty real ChartView::leftMargin |
|
123 | \qmlproperty real ChartView::leftMargin | |
124 | The space between the left side of chart view and the left side of the plot area. The left margin area may be used by |
|
124 | The space between the left side of chart view and the left side of the plot area. The left margin area may be used by | |
125 | legend (if aligned to left), y-axis, y-axis labels and y-axis tick marks. |
|
125 | legend (if aligned to left), y-axis, y-axis labels and y-axis tick marks. | |
126 | */ |
|
126 | */ | |
127 |
|
127 | |||
128 | /*! |
|
128 | /*! | |
129 | \qmlproperty real ChartView::rightMargin |
|
129 | \qmlproperty real ChartView::rightMargin | |
130 | The space between the right side of chart view and the right side of the plot area. The right margin area may be used |
|
130 | The space between the right side of chart view and the right side of the plot area. The right margin area may be used | |
131 | by legend (if aligned to right). |
|
131 | by legend (if aligned to right). | |
132 | */ |
|
132 | */ | |
133 |
|
133 | |||
134 | /*! |
|
134 | /*! | |
135 | \qmlmethod AbstractSeries ChartView::series(int index) |
|
135 | \qmlmethod AbstractSeries ChartView::series(int index) | |
136 | Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with |
|
136 | Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with | |
137 | the count property of the chart. |
|
137 | the count property of the chart. | |
138 | */ |
|
138 | */ | |
139 |
|
139 | |||
140 | /*! |
|
140 | /*! | |
141 | \qmlmethod AbstractSeries ChartView::series(string name) |
|
141 | \qmlmethod AbstractSeries ChartView::series(string name) | |
142 | Returns the first series on the chart with \a name. If there is no series with that name, returns null. |
|
142 | Returns the first series on the chart with \a name. If there is no series with that name, returns null. | |
143 | */ |
|
143 | */ | |
144 |
|
144 | |||
145 | /*! |
|
145 | /*! | |
146 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name) |
|
146 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name) | |
147 | Creates a series object of \a type to the chart. For example: |
|
147 | Creates a series object of \a type to the chart. For example: | |
148 | \code |
|
148 | \code | |
149 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series"); |
|
149 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series"); | |
150 | scatter.markerSize = 22; |
|
150 | scatter.markerSize = 22; | |
151 | scatter.append(1.1, 2.0); |
|
151 | scatter.append(1.1, 2.0); | |
152 | \endcode |
|
152 | \endcode | |
153 | */ |
|
153 | */ | |
154 |
|
154 | |||
155 | /*! |
|
155 | /*! | |
156 | \qmlmethod Axis ChartView::axisY(QAbstractSeries *series) |
|
156 | \qmlmethod Axis ChartView::axisY(QAbstractSeries *series) | |
157 | The y-axis of the series. This is the same as the default y-axis of the chart as multiple y-axes are not yet supported. |
|
157 | The y-axis of the series. This is the same as the default y-axis of the chart as multiple y-axes are not yet supported. | |
158 | */ |
|
158 | */ | |
159 |
|
159 | |||
160 | /*! |
|
160 | /*! | |
161 | \qmlmethod ChartView::zoomY(real factor) |
|
161 | \qmlmethod ChartView::zoomY(real factor) | |
162 | Zooms in by \a factor on the center of the chart. |
|
162 | Zooms in by \a factor on the center of the chart. | |
163 | */ |
|
163 | */ | |
164 |
|
164 | |||
165 | /*! |
|
165 | /*! | |
166 | \qmlmethod ChartView::scrollLeft(real pixels) |
|
166 | \qmlmethod ChartView::scrollLeft(real pixels) | |
167 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. |
|
167 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. | |
168 | \sa Axis::min, Axis::max |
|
168 | \sa Axis::min, Axis::max | |
169 | */ |
|
169 | */ | |
170 |
|
170 | |||
171 | /*! |
|
171 | /*! | |
172 | \qmlmethod ChartView::scrollRight(real pixels) |
|
172 | \qmlmethod ChartView::scrollRight(real pixels) | |
173 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. |
|
173 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. | |
174 | \sa Axis::min, Axis::max |
|
174 | \sa Axis::min, Axis::max | |
175 | */ |
|
175 | */ | |
176 |
|
176 | |||
177 | /*! |
|
177 | /*! | |
178 | \qmlmethod ChartView::scrollUp(real pixels) |
|
178 | \qmlmethod ChartView::scrollUp(real pixels) | |
179 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. |
|
179 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. | |
180 | \sa Axis::min, Axis::max |
|
180 | \sa Axis::min, Axis::max | |
181 | */ |
|
181 | */ | |
182 |
|
182 | |||
183 | /*! |
|
183 | /*! | |
184 | \qmlmethod ChartView::scrollDown(real pixels) |
|
184 | \qmlmethod ChartView::scrollDown(real pixels) | |
185 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. |
|
185 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. | |
186 | \sa Axis::min, Axis::max |
|
186 | \sa Axis::min, Axis::max | |
187 | */ |
|
187 | */ | |
188 |
|
188 | |||
189 | /*! |
|
189 | /*! | |
190 | \qmlsignal ChartView::onTopMarginChanged(real margin) |
|
190 | \qmlsignal ChartView::onTopMarginChanged(real margin) | |
191 | The top margin of the chart view has changed to \a margin. This may happen for example if you modify font size |
|
191 | The top margin of the chart view has changed to \a margin. This may happen for example if you modify font size | |
192 | related properties of the legend or chart title. |
|
192 | related properties of the legend or chart title. | |
193 | */ |
|
193 | */ | |
194 |
|
194 | |||
195 | /*! |
|
195 | /*! | |
196 | \qmlsignal ChartView::onBottomMarginChanged(real margin) |
|
196 | \qmlsignal ChartView::onBottomMarginChanged(real margin) | |
197 | The bottom margin of the chart view has changed to \a margin. This may happen for example if you modify font size |
|
197 | The bottom margin of the chart view has changed to \a margin. This may happen for example if you modify font size | |
198 | related properties of the legend or chart title. |
|
198 | related properties of the legend or chart title. | |
199 | */ |
|
199 | */ | |
200 |
|
200 | |||
201 | /*! |
|
201 | /*! | |
202 | \qmlsignal ChartView::onLeftMarginChanged(real margin) |
|
202 | \qmlsignal ChartView::onLeftMarginChanged(real margin) | |
203 | The left margin of the chart view has changed to \a margin. This may happen for example if you modify font size |
|
203 | The left margin of the chart view has changed to \a margin. This may happen for example if you modify font size | |
204 | related properties of the legend or chart title. |
|
204 | related properties of the legend or chart title. | |
205 | */ |
|
205 | */ | |
206 |
|
206 | |||
207 | /*! |
|
207 | /*! | |
208 | \qmlsignal ChartView::onRightMarginChanged(real margin) |
|
208 | \qmlsignal ChartView::onRightMarginChanged(real margin) | |
209 | The right margin of the chart view has changed to \a margin. This may happen for example if you modify font size |
|
209 | The right margin of the chart view has changed to \a margin. This may happen for example if you modify font size | |
210 | related properties of the legend or chart title. |
|
210 | related properties of the legend or chart title. | |
211 | */ |
|
211 | */ | |
212 |
|
212 | |||
213 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) |
|
213 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) | |
214 | : QDeclarativeItem(parent), |
|
214 | : QDeclarativeItem(parent), | |
215 | m_chart(new QChart(this)) |
|
215 | m_chart(new QChart(this)) | |
216 | { |
|
216 | { | |
217 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
217 | setFlag(QGraphicsItem::ItemHasNoContents, false); | |
218 | // m_chart->axisX()->setNiceNumbersEnabled(false); |
|
218 | // m_chart->axisX()->setNiceNumbersEnabled(false); | |
219 | m_chartMargins = m_chart->margins(); |
|
219 | m_chartMargins = m_chart->margins(); | |
220 | connect(m_chart, SIGNAL(marginsChanged(QRectF)), this, SLOT(handleMarginsChanged(QRectF))); |
|
220 | connect(m_chart, SIGNAL(marginsChanged(QRectF)), this, SLOT(handleMarginsChanged(QRectF))); | |
221 | } |
|
221 | } | |
222 |
|
222 | |||
223 | void DeclarativeChart::handleMarginsChanged(QRectF newMargins) |
|
223 | void DeclarativeChart::handleMarginsChanged(QRectF newMargins) | |
224 | { |
|
224 | { | |
225 | if (m_chartMargins.top() != newMargins.top()) |
|
225 | if (m_chartMargins.top() != newMargins.top()) | |
226 | topMarginChanged(m_chart->margins().top()); |
|
226 | topMarginChanged(m_chart->margins().top()); | |
227 | if (m_chartMargins.bottom() != newMargins.bottom()) |
|
227 | if (m_chartMargins.bottom() != newMargins.bottom()) | |
228 | bottomMarginChanged(m_chart->margins().bottom()); |
|
228 | bottomMarginChanged(m_chart->margins().bottom()); | |
229 | if (m_chartMargins.left() != newMargins.left()) |
|
229 | if (m_chartMargins.left() != newMargins.left()) | |
230 | leftMarginChanged(m_chart->margins().left()); |
|
230 | leftMarginChanged(m_chart->margins().left()); | |
231 | if (m_chartMargins.right() != newMargins.right()) |
|
231 | if (m_chartMargins.right() != newMargins.right()) | |
232 | rightMarginChanged(m_chart->margins().right()); |
|
232 | rightMarginChanged(m_chart->margins().right()); | |
233 |
|
233 | |||
234 | m_chartMargins = m_chart->margins(); |
|
234 | m_chartMargins = m_chart->margins(); | |
235 | } |
|
235 | } | |
236 |
|
236 | |||
237 | DeclarativeChart::~DeclarativeChart() |
|
237 | DeclarativeChart::~DeclarativeChart() | |
238 | { |
|
238 | { | |
239 | delete m_chart; |
|
239 | delete m_chart; | |
240 | } |
|
240 | } | |
241 |
|
241 | |||
242 | void DeclarativeChart::childEvent(QChildEvent *event) |
|
242 | void DeclarativeChart::childEvent(QChildEvent *event) | |
243 | { |
|
243 | { | |
244 | if (event->type() == QEvent::ChildAdded) { |
|
244 | if (event->type() == QEvent::ChildAdded) { | |
245 | if (qobject_cast<QAbstractSeries *>(event->child())) { |
|
245 | if (qobject_cast<QAbstractSeries *>(event->child())) { | |
246 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); |
|
246 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); | |
247 | } |
|
247 | } | |
248 | } |
|
248 | } | |
249 | } |
|
249 | } | |
250 |
|
250 | |||
251 | void DeclarativeChart::componentComplete() |
|
251 | void DeclarativeChart::componentComplete() | |
252 | { |
|
252 | { | |
253 | bool createAxis = true; |
|
|||
254 | foreach(QObject *child, children()) { |
|
253 | foreach(QObject *child, children()) { | |
255 | if (qobject_cast<QAbstractSeries *>(child)) { |
|
254 | if (qobject_cast<QAbstractSeries *>(child)) { | |
256 | // qDebug() << "DeclarativeChart::componentComplete(), add: " << child; |
|
255 | // qDebug() << "DeclarativeChart::componentComplete(), add: " << child; | |
257 | // TODO: how about optional y-axis? |
|
256 | // TODO: how about optional y-axis? | |
258 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); |
|
257 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); | |
259 | }else if(qobject_cast<QAbstractAxis *>(child)){ |
|
258 | }else if(qobject_cast<QAbstractAxis *>(child)){ | |
260 | createAxis = false; |
|
259 | ||
261 | } |
|
260 | } | |
262 | } |
|
261 | } | |
263 |
|
||||
264 | if(createAxis) m_chart->createDefaultAxes(); |
|
|||
265 |
|
||||
266 | QDeclarativeItem::componentComplete(); |
|
262 | QDeclarativeItem::componentComplete(); | |
267 | } |
|
263 | } | |
268 |
|
264 | |||
269 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
265 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | |
270 | { |
|
266 | { | |
271 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); |
|
267 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); | |
272 | if (newGeometry.isValid()) { |
|
268 | if (newGeometry.isValid()) { | |
273 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { |
|
269 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { | |
274 | m_chart->resize(newGeometry.width(), newGeometry.height()); |
|
270 | m_chart->resize(newGeometry.width(), newGeometry.height()); | |
275 | } |
|
271 | } | |
276 | } |
|
272 | } | |
277 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); |
|
273 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); | |
278 | } |
|
274 | } | |
279 |
|
275 | |||
280 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
276 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
281 | { |
|
277 | { | |
282 | Q_UNUSED(option) |
|
278 | Q_UNUSED(option) | |
283 | Q_UNUSED(widget) |
|
279 | Q_UNUSED(widget) | |
284 |
|
280 | |||
285 | // TODO: optimized? |
|
281 | // TODO: optimized? | |
286 | painter->setRenderHint(QPainter::Antialiasing, true); |
|
282 | painter->setRenderHint(QPainter::Antialiasing, true); | |
287 | } |
|
283 | } | |
288 |
|
284 | |||
289 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) |
|
285 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) | |
290 | { |
|
286 | { | |
291 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; |
|
287 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; | |
292 | if (chartTheme != m_chart->theme()) |
|
288 | if (chartTheme != m_chart->theme()) | |
293 | m_chart->setTheme(chartTheme); |
|
289 | m_chart->setTheme(chartTheme); | |
294 | } |
|
290 | } | |
295 |
|
291 | |||
296 | DeclarativeChart::Theme DeclarativeChart::theme() |
|
292 | DeclarativeChart::Theme DeclarativeChart::theme() | |
297 | { |
|
293 | { | |
298 | return (DeclarativeChart::Theme) m_chart->theme(); |
|
294 | return (DeclarativeChart::Theme) m_chart->theme(); | |
299 | } |
|
295 | } | |
300 |
|
296 | |||
301 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) |
|
297 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) | |
302 | { |
|
298 | { | |
303 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; |
|
299 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; | |
304 | if (animationOptions != m_chart->animationOptions()) |
|
300 | if (animationOptions != m_chart->animationOptions()) | |
305 | m_chart->setAnimationOptions(animationOptions); |
|
301 | m_chart->setAnimationOptions(animationOptions); | |
306 | } |
|
302 | } | |
307 |
|
303 | |||
308 | DeclarativeChart::Animation DeclarativeChart::animationOptions() |
|
304 | DeclarativeChart::Animation DeclarativeChart::animationOptions() | |
309 | { |
|
305 | { | |
310 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) |
|
306 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) | |
311 | return DeclarativeChart::AllAnimations; |
|
307 | return DeclarativeChart::AllAnimations; | |
312 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) |
|
308 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) | |
313 | return DeclarativeChart::GridAxisAnimations; |
|
309 | return DeclarativeChart::GridAxisAnimations; | |
314 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
310 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) | |
315 | return DeclarativeChart::SeriesAnimations; |
|
311 | return DeclarativeChart::SeriesAnimations; | |
316 | else |
|
312 | else | |
317 | return DeclarativeChart::NoAnimation; |
|
313 | return DeclarativeChart::NoAnimation; | |
318 | } |
|
314 | } | |
319 |
|
315 | |||
320 | void DeclarativeChart::setTitle(QString title) |
|
316 | void DeclarativeChart::setTitle(QString title) | |
321 | { |
|
317 | { | |
322 | if (title != m_chart->title()) |
|
318 | if (title != m_chart->title()) | |
323 | m_chart->setTitle(title); |
|
319 | m_chart->setTitle(title); | |
324 | } |
|
320 | } | |
325 | QString DeclarativeChart::title() |
|
321 | QString DeclarativeChart::title() | |
326 | { |
|
322 | { | |
327 | return m_chart->title(); |
|
323 | return m_chart->title(); | |
328 | } |
|
324 | } | |
329 |
|
325 | |||
330 | QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) |
|
326 | QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) | |
331 | { |
|
327 | { | |
332 | return m_chart->axisX(series); |
|
328 | return m_chart->axisX(series); | |
333 | } |
|
329 | } | |
334 |
|
330 | |||
335 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) |
|
331 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) | |
336 | { |
|
332 | { | |
337 | return m_chart->axisY(series); |
|
333 | return m_chart->axisY(series); | |
338 | } |
|
334 | } | |
339 |
|
335 | |||
340 | QLegend *DeclarativeChart::legend() |
|
336 | QLegend *DeclarativeChart::legend() | |
341 | { |
|
337 | { | |
342 | return m_chart->legend(); |
|
338 | return m_chart->legend(); | |
343 | } |
|
339 | } | |
344 |
|
340 | |||
345 | void DeclarativeChart::setTitleColor(QColor color) |
|
341 | void DeclarativeChart::setTitleColor(QColor color) | |
346 | { |
|
342 | { | |
347 | QBrush b = m_chart->titleBrush(); |
|
343 | QBrush b = m_chart->titleBrush(); | |
348 | if (color != b.color()) { |
|
344 | if (color != b.color()) { | |
349 | b.setColor(color); |
|
345 | b.setColor(color); | |
350 | m_chart->setTitleBrush(b); |
|
346 | m_chart->setTitleBrush(b); | |
351 | emit titleColorChanged(color); |
|
347 | emit titleColorChanged(color); | |
352 | } |
|
348 | } | |
353 | } |
|
349 | } | |
354 |
|
350 | |||
355 | QFont DeclarativeChart::titleFont() const |
|
351 | QFont DeclarativeChart::titleFont() const | |
356 | { |
|
352 | { | |
357 | return m_chart->titleFont(); |
|
353 | return m_chart->titleFont(); | |
358 | } |
|
354 | } | |
359 |
|
355 | |||
360 | void DeclarativeChart::setTitleFont(const QFont& font) |
|
356 | void DeclarativeChart::setTitleFont(const QFont& font) | |
361 | { |
|
357 | { | |
362 | m_chart->setTitleFont(font); |
|
358 | m_chart->setTitleFont(font); | |
363 | } |
|
359 | } | |
364 |
|
360 | |||
365 | QColor DeclarativeChart::titleColor() |
|
361 | QColor DeclarativeChart::titleColor() | |
366 | { |
|
362 | { | |
367 | return m_chart->titleBrush().color(); |
|
363 | return m_chart->titleBrush().color(); | |
368 | } |
|
364 | } | |
369 |
|
365 | |||
370 | void DeclarativeChart::setBackgroundColor(QColor color) |
|
366 | void DeclarativeChart::setBackgroundColor(QColor color) | |
371 | { |
|
367 | { | |
372 | QBrush b = m_chart->backgroundBrush(); |
|
368 | QBrush b = m_chart->backgroundBrush(); | |
373 | if (b.style() != Qt::SolidPattern || color != b.color()) { |
|
369 | if (b.style() != Qt::SolidPattern || color != b.color()) { | |
374 | b.setStyle(Qt::SolidPattern); |
|
370 | b.setStyle(Qt::SolidPattern); | |
375 | b.setColor(color); |
|
371 | b.setColor(color); | |
376 | m_chart->setBackgroundBrush(b); |
|
372 | m_chart->setBackgroundBrush(b); | |
377 | emit backgroundColorChanged(); |
|
373 | emit backgroundColorChanged(); | |
378 | } |
|
374 | } | |
379 | } |
|
375 | } | |
380 |
|
376 | |||
381 | QColor DeclarativeChart::backgroundColor() |
|
377 | QColor DeclarativeChart::backgroundColor() | |
382 | { |
|
378 | { | |
383 | return m_chart->backgroundBrush().color(); |
|
379 | return m_chart->backgroundBrush().color(); | |
384 | } |
|
380 | } | |
385 |
|
381 | |||
386 | int DeclarativeChart::count() |
|
382 | int DeclarativeChart::count() | |
387 | { |
|
383 | { | |
388 | return m_chart->series().count(); |
|
384 | return m_chart->series().count(); | |
389 | } |
|
385 | } | |
390 |
|
386 | |||
391 | void DeclarativeChart::setDropShadowEnabled(bool enabled) |
|
387 | void DeclarativeChart::setDropShadowEnabled(bool enabled) | |
392 | { |
|
388 | { | |
393 | if (enabled != m_chart->isDropShadowEnabled()) { |
|
389 | if (enabled != m_chart->isDropShadowEnabled()) { | |
394 | m_chart->setDropShadowEnabled(enabled); |
|
390 | m_chart->setDropShadowEnabled(enabled); | |
395 | dropShadowEnabledChanged(enabled); |
|
391 | dropShadowEnabledChanged(enabled); | |
396 | } |
|
392 | } | |
397 | } |
|
393 | } | |
398 |
|
394 | |||
399 | bool DeclarativeChart::dropShadowEnabled() |
|
395 | bool DeclarativeChart::dropShadowEnabled() | |
400 | { |
|
396 | { | |
401 | return m_chart->isDropShadowEnabled(); |
|
397 | return m_chart->isDropShadowEnabled(); | |
402 | } |
|
398 | } | |
403 |
|
399 | |||
404 | qreal DeclarativeChart::topMargin() |
|
400 | qreal DeclarativeChart::topMargin() | |
405 | { |
|
401 | { | |
406 | return m_chart->margins().top(); |
|
402 | return m_chart->margins().top(); | |
407 | } |
|
403 | } | |
408 |
|
404 | |||
409 | qreal DeclarativeChart::bottomMargin() |
|
405 | qreal DeclarativeChart::bottomMargin() | |
410 | { |
|
406 | { | |
411 | return m_chart->margins().bottom(); |
|
407 | return m_chart->margins().bottom(); | |
412 | } |
|
408 | } | |
413 |
|
409 | |||
414 | qreal DeclarativeChart::leftMargin() |
|
410 | qreal DeclarativeChart::leftMargin() | |
415 | { |
|
411 | { | |
416 | return m_chart->margins().left(); |
|
412 | return m_chart->margins().left(); | |
417 | } |
|
413 | } | |
418 |
|
414 | |||
419 | qreal DeclarativeChart::rightMargin() |
|
415 | qreal DeclarativeChart::rightMargin() | |
420 | { |
|
416 | { | |
421 | return m_chart->margins().right(); |
|
417 | return m_chart->margins().right(); | |
422 | } |
|
418 | } | |
423 |
|
419 | |||
424 | void DeclarativeChart::zoom(qreal factor) |
|
420 | void DeclarativeChart::zoom(qreal factor) | |
425 | { |
|
421 | { | |
426 | m_chart->zoom(factor); |
|
422 | m_chart->zoom(factor); | |
427 | } |
|
423 | } | |
428 |
|
424 | |||
429 | void DeclarativeChart::scrollLeft(qreal pixels) |
|
425 | void DeclarativeChart::scrollLeft(qreal pixels) | |
430 | { |
|
426 | { | |
431 | m_chart->scroll(pixels, 0); |
|
427 | m_chart->scroll(pixels, 0); | |
432 | } |
|
428 | } | |
433 |
|
429 | |||
434 | void DeclarativeChart::scrollRight(qreal pixels) |
|
430 | void DeclarativeChart::scrollRight(qreal pixels) | |
435 | { |
|
431 | { | |
436 | m_chart->scroll(-pixels, 0); |
|
432 | m_chart->scroll(-pixels, 0); | |
437 | } |
|
433 | } | |
438 |
|
434 | |||
439 | void DeclarativeChart::scrollUp(qreal pixels) |
|
435 | void DeclarativeChart::scrollUp(qreal pixels) | |
440 | { |
|
436 | { | |
441 | m_chart->scroll(0, pixels); |
|
437 | m_chart->scroll(0, pixels); | |
442 | } |
|
438 | } | |
443 |
|
439 | |||
444 | void DeclarativeChart::scrollDown(qreal pixels) |
|
440 | void DeclarativeChart::scrollDown(qreal pixels) | |
445 | { |
|
441 | { | |
446 | m_chart->scroll(0, -pixels); |
|
442 | m_chart->scroll(0, -pixels); | |
447 | } |
|
443 | } | |
448 |
|
444 | |||
449 | QAbstractSeries *DeclarativeChart::series(int index) |
|
445 | QAbstractSeries *DeclarativeChart::series(int index) | |
450 | { |
|
446 | { | |
451 | if (index < m_chart->series().count()) { |
|
447 | if (index < m_chart->series().count()) { | |
452 | return m_chart->series().at(index); |
|
448 | return m_chart->series().at(index); | |
453 | } |
|
449 | } | |
454 | return 0; |
|
450 | return 0; | |
455 | } |
|
451 | } | |
456 |
|
452 | |||
457 | QAbstractSeries *DeclarativeChart::series(QString seriesName) |
|
453 | QAbstractSeries *DeclarativeChart::series(QString seriesName) | |
458 | { |
|
454 | { | |
459 | foreach(QAbstractSeries *series, m_chart->series()) { |
|
455 | foreach(QAbstractSeries *series, m_chart->series()) { | |
460 | if (series->name() == seriesName) |
|
456 | if (series->name() == seriesName) | |
461 | return series; |
|
457 | return series; | |
462 | } |
|
458 | } | |
463 | return 0; |
|
459 | return 0; | |
464 | } |
|
460 | } | |
465 |
|
461 | |||
466 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) |
|
462 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) | |
467 | { |
|
463 | { | |
468 | QAbstractSeries *series = 0; |
|
464 | QAbstractSeries *series = 0; | |
469 | switch (type) { |
|
465 | switch (type) { | |
470 | case DeclarativeChart::SeriesTypeLine: |
|
466 | case DeclarativeChart::SeriesTypeLine: | |
471 | series = new DeclarativeLineSeries(); |
|
467 | series = new DeclarativeLineSeries(); | |
472 | break; |
|
468 | break; | |
473 | case DeclarativeChart::SeriesTypeArea: |
|
469 | case DeclarativeChart::SeriesTypeArea: | |
474 | series = new DeclarativeAreaSeries(); |
|
470 | series = new DeclarativeAreaSeries(); | |
475 | break; |
|
471 | break; | |
476 | case DeclarativeChart::SeriesTypeStackedBar: |
|
472 | case DeclarativeChart::SeriesTypeStackedBar: | |
477 | // TODO |
|
473 | // TODO | |
478 | break; |
|
474 | break; | |
479 | case DeclarativeChart::SeriesTypePercentBar: |
|
475 | case DeclarativeChart::SeriesTypePercentBar: | |
480 | // TODO |
|
476 | // TODO | |
481 | break; |
|
477 | break; | |
482 | case DeclarativeChart::SeriesTypeBar: |
|
478 | case DeclarativeChart::SeriesTypeBar: | |
483 | series = new DeclarativeBarSeries(); |
|
479 | series = new DeclarativeBarSeries(); | |
484 | break; |
|
480 | break; | |
485 | case DeclarativeChart::SeriesTypePie: |
|
481 | case DeclarativeChart::SeriesTypePie: | |
486 | series = new DeclarativePieSeries(); |
|
482 | series = new DeclarativePieSeries(); | |
487 | break; |
|
483 | break; | |
488 | case DeclarativeChart::SeriesTypeScatter: |
|
484 | case DeclarativeChart::SeriesTypeScatter: | |
489 | series = new DeclarativeScatterSeries(); |
|
485 | series = new DeclarativeScatterSeries(); | |
490 | break; |
|
486 | break; | |
491 | case DeclarativeChart::SeriesTypeSpline: |
|
487 | case DeclarativeChart::SeriesTypeSpline: | |
492 | series = new DeclarativeSplineSeries(); |
|
488 | series = new DeclarativeSplineSeries(); | |
493 | break; |
|
489 | break; | |
494 | default: |
|
490 | default: | |
495 | qWarning() << "Illegal series type"; |
|
491 | qWarning() << "Illegal series type"; | |
496 | } |
|
492 | } | |
497 | series->setName(name); |
|
493 | series->setName(name); | |
498 | m_chart->addSeries(series); |
|
494 | m_chart->addSeries(series); | |
499 | return series; |
|
495 | return series; | |
500 | } |
|
496 | } | |
501 |
|
497 | |||
|
498 | void DeclarativeChart::setAxisX(QAbstractAxis* axis, QAbstractSeries *series) | |||
|
499 | { | |||
|
500 | m_chart->setAxisX(axis,series); | |||
|
501 | } | |||
|
502 | ||||
|
503 | void DeclarativeChart::setAxisY(QAbstractAxis* axis, QAbstractSeries *series) | |||
|
504 | { | |||
|
505 | m_chart->setAxisY(axis,series); | |||
|
506 | } | |||
|
507 | ||||
|
508 | void DeclarativeChart::createDefaultAxes() | |||
|
509 | { | |||
|
510 | m_chart->createDefaultAxes(); | |||
|
511 | } | |||
|
512 | ||||
502 | #include "moc_declarativechart.cpp" |
|
513 | #include "moc_declarativechart.cpp" | |
503 |
|
514 | |||
504 | QTCOMMERCIALCHART_END_NAMESPACE |
|
515 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,151 +1,156 | |||||
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 | #ifndef DECLARATIVECHART_H |
|
21 | #ifndef DECLARATIVECHART_H | |
22 | #define DECLARATIVECHART_H |
|
22 | #define DECLARATIVECHART_H | |
23 |
|
23 | |||
24 | #include <QtCore/QtGlobal> |
|
24 | #include <QtCore/QtGlobal> | |
25 | #include <QDeclarativeItem> |
|
25 | #include <QDeclarativeItem> | |
26 | #include <qchart.h> |
|
26 | #include <qchart.h> | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 | // TODO: Derive from QChart for easier definition of properties? |
|
30 | // TODO: Derive from QChart for easier definition of properties? | |
31 | class DeclarativeChart : public QDeclarativeItem |
|
31 | class DeclarativeChart : public QDeclarativeItem | |
32 | // TODO: for QTQUICK2: extend QQuickPainterItem instead |
|
32 | // TODO: for QTQUICK2: extend QQuickPainterItem instead | |
33 | //class DeclarativeChart : public QQuickPaintedItem, public Chart |
|
33 | //class DeclarativeChart : public QQuickPaintedItem, public Chart | |
34 | { |
|
34 | { | |
35 | Q_OBJECT |
|
35 | Q_OBJECT | |
36 | Q_PROPERTY(Theme theme READ theme WRITE setTheme) |
|
36 | Q_PROPERTY(Theme theme READ theme WRITE setTheme) | |
37 | Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions) |
|
37 | Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions) | |
38 | Q_PROPERTY(QString title READ title WRITE setTitle) |
|
38 | Q_PROPERTY(QString title READ title WRITE setTitle) | |
39 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) |
|
39 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) | |
40 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) |
|
40 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) | |
41 | Q_PROPERTY(QAbstractAxis *axisX READ axisX) |
|
41 | Q_PROPERTY(QAbstractAxis *axisX READ axisX) | |
42 | Q_PROPERTY(QAbstractAxis *axisY READ axisY) |
|
42 | Q_PROPERTY(QAbstractAxis *axisY READ axisY) | |
43 | Q_PROPERTY(QLegend *legend READ legend) |
|
43 | Q_PROPERTY(QLegend *legend READ legend) | |
44 | Q_PROPERTY(int count READ count) |
|
44 | Q_PROPERTY(int count READ count) | |
45 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) |
|
45 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) | |
46 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) |
|
46 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) | |
47 | Q_PROPERTY(qreal topMargin READ topMargin NOTIFY topMarginChanged) |
|
47 | Q_PROPERTY(qreal topMargin READ topMargin NOTIFY topMarginChanged) | |
48 | Q_PROPERTY(qreal bottomMargin READ bottomMargin NOTIFY bottomMarginChanged) |
|
48 | Q_PROPERTY(qreal bottomMargin READ bottomMargin NOTIFY bottomMarginChanged) | |
49 | Q_PROPERTY(qreal leftMargin READ leftMargin NOTIFY leftMarginChanged) |
|
49 | Q_PROPERTY(qreal leftMargin READ leftMargin NOTIFY leftMarginChanged) | |
50 | Q_PROPERTY(qreal rightMargin READ rightMargin NOTIFY rightMarginChanged) |
|
50 | Q_PROPERTY(qreal rightMargin READ rightMargin NOTIFY rightMarginChanged) | |
51 | Q_ENUMS(Animation) |
|
51 | Q_ENUMS(Animation) | |
52 | Q_ENUMS(Theme) |
|
52 | Q_ENUMS(Theme) | |
53 | Q_ENUMS(SeriesType) |
|
53 | Q_ENUMS(SeriesType) | |
54 |
|
54 | |||
55 | public: |
|
55 | public: | |
56 | // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api |
|
56 | // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api | |
57 | enum Theme { |
|
57 | enum Theme { | |
58 | ChartThemeLight = 0, |
|
58 | ChartThemeLight = 0, | |
59 | ChartThemeBlueCerulean, |
|
59 | ChartThemeBlueCerulean, | |
60 | ChartThemeDark, |
|
60 | ChartThemeDark, | |
61 | ChartThemeBrownSand, |
|
61 | ChartThemeBrownSand, | |
62 | ChartThemeBlueNcs, |
|
62 | ChartThemeBlueNcs, | |
63 | ChartThemeHighContrast, |
|
63 | ChartThemeHighContrast, | |
64 | ChartThemeBlueIcy |
|
64 | ChartThemeBlueIcy | |
65 | }; |
|
65 | }; | |
66 |
|
66 | |||
67 | enum Animation { |
|
67 | enum Animation { | |
68 | NoAnimation = 0x0, |
|
68 | NoAnimation = 0x0, | |
69 | GridAxisAnimations = 0x1, |
|
69 | GridAxisAnimations = 0x1, | |
70 | SeriesAnimations =0x2, |
|
70 | SeriesAnimations =0x2, | |
71 | AllAnimations = 0x3 |
|
71 | AllAnimations = 0x3 | |
72 | }; |
|
72 | }; | |
73 |
|
73 | |||
74 | enum SeriesType { |
|
74 | enum SeriesType { | |
75 | SeriesTypeLine, |
|
75 | SeriesTypeLine, | |
76 | SeriesTypeArea, |
|
76 | SeriesTypeArea, | |
77 | SeriesTypeBar, |
|
77 | SeriesTypeBar, | |
78 | SeriesTypeStackedBar, |
|
78 | SeriesTypeStackedBar, | |
79 | SeriesTypePercentBar, |
|
79 | SeriesTypePercentBar, | |
80 | SeriesTypePie, |
|
80 | SeriesTypePie, | |
81 | SeriesTypeScatter, |
|
81 | SeriesTypeScatter, | |
82 | SeriesTypeSpline |
|
82 | SeriesTypeSpline | |
83 | }; |
|
83 | }; | |
84 |
|
84 | |||
85 | public: |
|
85 | public: | |
86 | DeclarativeChart(QDeclarativeItem *parent = 0); |
|
86 | DeclarativeChart(QDeclarativeItem *parent = 0); | |
87 | ~DeclarativeChart(); |
|
87 | ~DeclarativeChart(); | |
88 |
|
88 | |||
89 | public: // From QDeclarativeItem/QGraphicsItem |
|
89 | public: // From QDeclarativeItem/QGraphicsItem | |
90 | void childEvent(QChildEvent *event); |
|
90 | void childEvent(QChildEvent *event); | |
91 | void componentComplete(); |
|
91 | void componentComplete(); | |
92 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); |
|
92 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); | |
93 | void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
93 | void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | |
94 |
|
94 | |||
95 | public: |
|
95 | public: | |
96 | void setTheme(DeclarativeChart::Theme theme); |
|
96 | void setTheme(DeclarativeChart::Theme theme); | |
97 | DeclarativeChart::Theme theme(); |
|
97 | DeclarativeChart::Theme theme(); | |
98 | void setAnimationOptions(DeclarativeChart::Animation animations); |
|
98 | void setAnimationOptions(DeclarativeChart::Animation animations); | |
99 | DeclarativeChart::Animation animationOptions(); |
|
99 | DeclarativeChart::Animation animationOptions(); | |
100 | void setTitle(QString title); |
|
100 | void setTitle(QString title); | |
101 | QString title(); |
|
101 | QString title(); | |
102 | QLegend *legend(); |
|
102 | QLegend *legend(); | |
103 | QFont titleFont() const; |
|
103 | QFont titleFont() const; | |
104 | void setTitleFont(const QFont& font); |
|
104 | void setTitleFont(const QFont& font); | |
105 | void setTitleColor(QColor color); |
|
105 | void setTitleColor(QColor color); | |
106 | QColor titleColor(); |
|
106 | QColor titleColor(); | |
107 | void setBackgroundColor(QColor color); |
|
107 | void setBackgroundColor(QColor color); | |
108 | QColor backgroundColor(); |
|
108 | QColor backgroundColor(); | |
109 | int count(); |
|
109 | int count(); | |
110 | void setDropShadowEnabled(bool enabled); |
|
110 | void setDropShadowEnabled(bool enabled); | |
111 | bool dropShadowEnabled(); |
|
111 | bool dropShadowEnabled(); | |
112 | qreal topMargin(); |
|
112 | qreal topMargin(); | |
113 | qreal bottomMargin(); |
|
113 | qreal bottomMargin(); | |
114 | qreal leftMargin(); |
|
114 | qreal leftMargin(); | |
115 | qreal rightMargin(); |
|
115 | qreal rightMargin(); | |
116 |
|
116 | |||
|
117 | QAbstractAxis *axisX(QAbstractSeries *series = 0); | |||
|
118 | QAbstractAxis *axisY(QAbstractSeries *series = 0); | |||
|
119 | ||||
117 | public: |
|
120 | public: | |
118 | Q_INVOKABLE QAbstractSeries *series(int index); |
|
121 | Q_INVOKABLE QAbstractSeries *series(int index); | |
119 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); |
|
122 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); | |
120 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); |
|
123 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); | |
121 |
Q_INVOKABLE QAbstractAxis |
|
124 | Q_INVOKABLE void setAxisX(QAbstractAxis* axis, QAbstractSeries *series = 0); | |
122 |
Q_INVOKABLE QAbstractAxis |
|
125 | Q_INVOKABLE void setAxisY(QAbstractAxis* axis, QAbstractSeries *series = 0); | |
|
126 | Q_INVOKABLE void createDefaultAxes(); | |||
|
127 | ||||
123 | Q_INVOKABLE void zoom(qreal factor); |
|
128 | Q_INVOKABLE void zoom(qreal factor); | |
124 | Q_INVOKABLE void scrollLeft(qreal pixels); |
|
129 | Q_INVOKABLE void scrollLeft(qreal pixels); | |
125 | Q_INVOKABLE void scrollRight(qreal pixels); |
|
130 | Q_INVOKABLE void scrollRight(qreal pixels); | |
126 | Q_INVOKABLE void scrollUp(qreal pixels); |
|
131 | Q_INVOKABLE void scrollUp(qreal pixels); | |
127 | Q_INVOKABLE void scrollDown(qreal pixels); |
|
132 | Q_INVOKABLE void scrollDown(qreal pixels); | |
128 |
|
133 | |||
129 | Q_SIGNALS: |
|
134 | Q_SIGNALS: | |
130 | void axisLabelsChanged(); |
|
135 | void axisLabelsChanged(); | |
131 | void titleColorChanged(QColor color); |
|
136 | void titleColorChanged(QColor color); | |
132 | void backgroundColorChanged(); |
|
137 | void backgroundColorChanged(); | |
133 | void dropShadowEnabledChanged(bool enabled); |
|
138 | void dropShadowEnabledChanged(bool enabled); | |
134 | void topMarginChanged(qreal margin); |
|
139 | void topMarginChanged(qreal margin); | |
135 | void bottomMarginChanged(qreal margin); |
|
140 | void bottomMarginChanged(qreal margin); | |
136 | void leftMarginChanged(qreal margin); |
|
141 | void leftMarginChanged(qreal margin); | |
137 | void rightMarginChanged(qreal margin); |
|
142 | void rightMarginChanged(qreal margin); | |
138 |
|
143 | |||
139 | public Q_SLOTS: |
|
144 | public Q_SLOTS: | |
140 | void handleMarginsChanged(QRectF newMargins); |
|
145 | void handleMarginsChanged(QRectF newMargins); | |
141 |
|
146 | |||
142 | private: |
|
147 | private: | |
143 | // Extending QChart with DeclarativeChart is not possible because QObject does not support |
|
148 | // Extending QChart with DeclarativeChart is not possible because QObject does not support | |
144 | // multi inheritance, so we now have a QChart as a member instead |
|
149 | // multi inheritance, so we now have a QChart as a member instead | |
145 | QChart *m_chart; |
|
150 | QChart *m_chart; | |
146 | QRectF m_chartMargins; |
|
151 | QRectF m_chartMargins; | |
147 | }; |
|
152 | }; | |
148 |
|
153 | |||
149 | QTCOMMERCIALCHART_END_NAMESPACE |
|
154 | QTCOMMERCIALCHART_END_NAMESPACE | |
150 |
|
155 | |||
151 | #endif // DECLARATIVECHART_H |
|
156 | #endif // DECLARATIVECHART_H |
@@ -1,108 +1,104 | |||||
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 | #include <QtDeclarative/qdeclarativeextensionplugin.h> |
|
21 | #include <QtDeclarative/qdeclarativeextensionplugin.h> | |
22 | #include <QtDeclarative/qdeclarative.h> |
|
22 | #include <QtDeclarative/qdeclarative.h> | |
23 | #include "qchart.h" |
|
23 | #include "qchart.h" | |
24 | #include "qabstractaxis.h" |
|
24 | #include "qabstractaxis.h" | |
25 | #include "qvaluesaxis.h" |
|
25 | #include "qvaluesaxis.h" | |
26 | #include "qcategoriesaxis.h" |
|
26 | #include "qcategoriesaxis.h" | |
27 | #include "declarativechart.h" |
|
27 | #include "declarativechart.h" | |
28 | #include "declarativexypoint.h" |
|
28 | #include "declarativexypoint.h" | |
29 | #include "declarativelineseries.h" |
|
29 | #include "declarativelineseries.h" | |
30 | #include "declarativesplineseries.h" |
|
30 | #include "declarativesplineseries.h" | |
31 | #include "declarativeareaseries.h" |
|
31 | #include "declarativeareaseries.h" | |
32 | #include "declarativescatterseries.h" |
|
32 | #include "declarativescatterseries.h" | |
33 | #include "declarativebarseries.h" |
|
33 | #include "declarativebarseries.h" | |
34 | #include "declarativepieseries.h" |
|
34 | #include "declarativepieseries.h" | |
35 | #include <QVXYModelMapper> |
|
35 | #include <QVXYModelMapper> | |
36 | #include <QHXYModelMapper> |
|
36 | #include <QHXYModelMapper> | |
37 | #include <QHPieModelMapper> |
|
37 | #include <QHPieModelMapper> | |
38 | #include <QVPieModelMapper> |
|
38 | #include <QVPieModelMapper> | |
39 | #include <QHBarModelMapper> |
|
39 | #include <QHBarModelMapper> | |
40 | #include <QVBarModelMapper> |
|
40 | #include <QVBarModelMapper> | |
41 |
|
41 | |||
42 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
42 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
43 |
|
43 | |||
44 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin |
|
44 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin | |
45 | { |
|
45 | { | |
46 | Q_OBJECT |
|
46 | Q_OBJECT | |
47 | public: |
|
47 | public: | |
48 | virtual void registerTypes(const char *uri) |
|
48 | virtual void registerTypes(const char *uri) | |
49 | { |
|
49 | { | |
50 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); |
|
50 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); | |
51 |
|
51 | |||
52 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); |
|
52 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); | |
53 | qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint"); |
|
53 | qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint"); | |
54 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); |
|
54 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); | |
55 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); |
|
55 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); | |
56 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); |
|
56 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); | |
57 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); |
|
57 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); | |
58 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); |
|
58 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); | |
59 | qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries"); |
|
59 | qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries"); | |
60 | qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries"); |
|
60 | qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries"); | |
61 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); |
|
61 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); | |
62 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); |
|
62 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); | |
63 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); |
|
63 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); | |
64 | qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper"); |
|
64 | qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper"); | |
65 | qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper"); |
|
65 | qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper"); | |
66 | qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper"); |
|
66 | qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper"); | |
67 | qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper"); |
|
67 | qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper"); | |
68 | qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper"); |
|
68 | qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper"); | |
69 | qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper"); |
|
69 | qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper"); | |
70 | qmlRegisterType<QValuesAxis>(uri, 1, 0, "ValuesAxis"); |
|
70 | qmlRegisterType<QValuesAxis>(uri, 1, 0, "ValuesAxis"); | |
71 | qmlRegisterType<QCategoriesAxis>(uri, 1, 0, "CategoriesAxis"); |
|
71 | qmlRegisterType<QCategoriesAxis>(uri, 1, 0, "CategoriesAxis"); | |
72 |
|
72 | |||
73 | qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend", |
|
73 | qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend", | |
74 | QLatin1String("Trying to create uncreatable: Legend.")); |
|
74 | QLatin1String("Trying to create uncreatable: Legend.")); | |
75 | qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries", |
|
75 | qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries", | |
76 | QLatin1String("Trying to create uncreatable: XYSeries.")); |
|
76 | QLatin1String("Trying to create uncreatable: XYSeries.")); | |
77 | qmlRegisterUncreatableType<QScatterSeries>(uri, 1, 0, "QScatterSeries", |
|
|||
78 | QLatin1String("Trying to create uncreatable: QScatterSeries.")); |
|
|||
79 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", |
|
|||
80 | QLatin1String("Trying to create uncreatable: QPieSeries.")); |
|
|||
81 | qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "QBarSet", |
|
|||
82 | QLatin1String("Trying to create uncreatable: QBarSet.")); |
|
|||
83 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", |
|
77 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", | |
84 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); |
|
78 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); | |
85 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", |
|
79 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", | |
86 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); |
|
80 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); | |
87 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
|
81 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", | |
88 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
82 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); | |
89 | qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper", |
|
83 | qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper", | |
90 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); |
|
84 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); | |
91 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", |
|
85 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", | |
92 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); |
|
86 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); | |
|
87 | qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries", | |||
|
88 | QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); | |||
93 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", |
|
89 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", | |
94 | QLatin1String("Trying to create uncreatable: AbstractAxis.")); |
|
90 | QLatin1String("Trying to create uncreatable: AbstractAxis.")); | |
95 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
|
91 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", | |
96 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
92 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); | |
97 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", |
|
93 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", | |
98 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); |
|
94 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); | |
99 | } |
|
95 | } | |
100 | }; |
|
96 | }; | |
101 |
|
97 | |||
102 | #include "plugin.moc" |
|
98 | #include "plugin.moc" | |
103 |
|
99 | |||
104 | QTCOMMERCIALCHART_END_NAMESPACE |
|
100 | QTCOMMERCIALCHART_END_NAMESPACE | |
105 |
|
101 | |||
106 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
102 | QTCOMMERCIALCHART_USE_NAMESPACE | |
107 |
|
103 | |||
108 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
|
104 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now