@@ -0,0 +1,41 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | import QtQuick 1.0 | |
|
22 | import QtCommercial.Chart 1.0 | |
|
23 | ||
|
24 | ChartView { | |
|
25 | title: "Grouped bar series" | |
|
26 | anchors.fill: parent | |
|
27 | theme: ChartView.ChartThemeLight | |
|
28 | legend: ChartView.LegendBottom | |
|
29 | // TODO: labels defined by x-axis, not by bar series | |
|
30 | axisXLabels: ["0", "2008", "1", "2009", "2", "2010", "3", "2012"] | |
|
31 | ||
|
32 | property variant series: daSeries | |
|
33 | ||
|
34 | GroupedBarSeries { | |
|
35 | id: daSeries | |
|
36 | barCategories: [ "2008", "2009", "2010", "2011", "2012" ] | |
|
37 | BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
|
38 | BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
|
39 | BarSet { name: "James"; values: [3, 5, 8, 13, 5, 8] } | |
|
40 | } | |
|
41 | } |
@@ -0,0 +1,40 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | import QtQuick 1.0 | |
|
22 | import QtCommercial.Chart 1.0 | |
|
23 | ||
|
24 | ChartView { | |
|
25 | title: "Percent bar series" | |
|
26 | anchors.fill: parent | |
|
27 | theme: ChartView.ChartThemeLight | |
|
28 | legend: ChartView.LegendBottom | |
|
29 | // TODO: labels defined by x-axis, not by bar series | |
|
30 | axisXLabels: ["0", "2008", "1", "2009", "2", "2010", "3", "2012"] | |
|
31 | ||
|
32 | property variant series: daSeries | |
|
33 | ||
|
34 | PercentBarSeries { | |
|
35 | id: daSeries | |
|
36 | BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
|
37 | BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
|
38 | BarSet { name: "James"; values: [3, 5, 8, 13, 5, 8] } | |
|
39 | } | |
|
40 | } |
@@ -0,0 +1,39 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | import QtQuick 1.0 | |
|
22 | import QtCommercial.Chart 1.0 | |
|
23 | ||
|
24 | ChartView { | |
|
25 | title: "Stacked bar series" | |
|
26 | anchors.fill: parent | |
|
27 | theme: ChartView.ChartThemeLight | |
|
28 | legend: ChartView.LegendBottom | |
|
29 | axisXLabels: ["0", "2008", "1", "2009", "2", "2010", "3", "2012"] | |
|
30 | ||
|
31 | property variant series: daSeries | |
|
32 | ||
|
33 | StackedBarSeries { | |
|
34 | id: daSeries | |
|
35 | BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
|
36 | BarSet { name: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
|
37 | BarSet { name: "James"; values: [3, 5, 8, 13, 5, 8] } | |
|
38 | } | |
|
39 | } |
@@ -196,6 +196,96 DeclarativeBarSet *DeclarativeGroupedBarSeries::at(int index) | |||
|
196 | 196 | return 0; |
|
197 | 197 | } |
|
198 | 198 | |
|
199 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) : | |
|
200 | QStackedBarSeries(parent) | |
|
201 | { | |
|
202 | } | |
|
203 | ||
|
204 | void DeclarativeStackedBarSeries::classBegin() | |
|
205 | { | |
|
206 | } | |
|
207 | ||
|
208 | void DeclarativeStackedBarSeries::componentComplete() | |
|
209 | { | |
|
210 | foreach(QObject *child, children()) { | |
|
211 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
|
212 | QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
|
213 | } else if(qobject_cast<QVBarModelMapper *>(child)) { | |
|
214 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
|
215 | mapper->setSeries(this); | |
|
216 | } else if(qobject_cast<QHBarModelMapper *>(child)) { | |
|
217 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
|
218 | mapper->setSeries(this); | |
|
219 | } | |
|
220 | } | |
|
221 | } | |
|
222 | ||
|
223 | QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren() | |
|
224 | { | |
|
225 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); | |
|
226 | } | |
|
227 | ||
|
228 | void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
|
229 | { | |
|
230 | // Empty implementation; the children are parsed in componentComplete instead | |
|
231 | Q_UNUSED(list); | |
|
232 | Q_UNUSED(element); | |
|
233 | } | |
|
234 | ||
|
235 | DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index) | |
|
236 | { | |
|
237 | QList<QBarSet*> setList = barSets(); | |
|
238 | if (index < setList.count()) | |
|
239 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
|
240 | ||
|
241 | return 0; | |
|
242 | } | |
|
243 | ||
|
244 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) : | |
|
245 | QPercentBarSeries(parent) | |
|
246 | { | |
|
247 | } | |
|
248 | ||
|
249 | void DeclarativePercentBarSeries::classBegin() | |
|
250 | { | |
|
251 | } | |
|
252 | ||
|
253 | void DeclarativePercentBarSeries::componentComplete() | |
|
254 | { | |
|
255 | foreach(QObject *child, children()) { | |
|
256 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
|
257 | QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
|
258 | } else if(qobject_cast<QVBarModelMapper *>(child)) { | |
|
259 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
|
260 | mapper->setSeries(this); | |
|
261 | } else if(qobject_cast<QHBarModelMapper *>(child)) { | |
|
262 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
|
263 | mapper->setSeries(this); | |
|
264 | } | |
|
265 | } | |
|
266 | } | |
|
267 | ||
|
268 | QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren() | |
|
269 | { | |
|
270 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); | |
|
271 | } | |
|
272 | ||
|
273 | void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
|
274 | { | |
|
275 | // Empty implementation; the children are parsed in componentComplete instead | |
|
276 | Q_UNUSED(list); | |
|
277 | Q_UNUSED(element); | |
|
278 | } | |
|
279 | ||
|
280 | DeclarativeBarSet *DeclarativePercentBarSeries::at(int index) | |
|
281 | { | |
|
282 | QList<QBarSet*> setList = barSets(); | |
|
283 | if (index < setList.count()) | |
|
284 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
|
285 | ||
|
286 | return 0; | |
|
287 | } | |
|
288 | ||
|
199 | 289 | #include "moc_declarativebarseries.cpp" |
|
200 | 290 | |
|
201 | 291 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -22,10 +22,12 | |||
|
22 | 22 | #define DECLARATIVEBARSERIES_H |
|
23 | 23 | |
|
24 | 24 | #include "qchartglobal.h" |
|
25 | #include <QDeclarativeItem> | |
|
26 | #include <QDeclarativeParserStatus> | |
|
27 | 25 | #include <QGroupedBarSeries> |
|
26 | #include <QStackedBarSeries> | |
|
27 | #include <QPercentBarSeries> | |
|
28 | 28 | #include <QBarSet> |
|
29 | #include <QDeclarativeItem> | |
|
30 | #include <QDeclarativeParserStatus> | |
|
29 | 31 | |
|
30 | 32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | 33 | |
@@ -105,6 +107,46 public Q_SLOTS: | |||
|
105 | 107 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
106 | 108 | }; |
|
107 | 109 | |
|
110 | class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus | |
|
111 | { | |
|
112 | Q_OBJECT | |
|
113 | Q_INTERFACES(QDeclarativeParserStatus) | |
|
114 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
|
115 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
|
116 | ||
|
117 | public: | |
|
118 | explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0); | |
|
119 | QDeclarativeListProperty<QObject> seriesChildren(); | |
|
120 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
|
121 | ||
|
122 | public: // from QDeclarativeParserStatus | |
|
123 | void classBegin(); | |
|
124 | void componentComplete(); | |
|
125 | ||
|
126 | public Q_SLOTS: | |
|
127 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
|
128 | }; | |
|
129 | ||
|
130 | class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus | |
|
131 | { | |
|
132 | Q_OBJECT | |
|
133 | Q_INTERFACES(QDeclarativeParserStatus) | |
|
134 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
|
135 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
|
136 | ||
|
137 | public: | |
|
138 | explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0); | |
|
139 | QDeclarativeListProperty<QObject> seriesChildren(); | |
|
140 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
|
141 | ||
|
142 | public: // from QDeclarativeParserStatus | |
|
143 | void classBegin(); | |
|
144 | void componentComplete(); | |
|
145 | ||
|
146 | public Q_SLOTS: | |
|
147 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
|
148 | }; | |
|
149 | ||
|
108 | 150 | QTCOMMERCIALCHART_END_NAMESPACE |
|
109 | 151 | |
|
110 | 152 | #endif // DECLARATIVEBARSERIES_H |
@@ -55,6 +55,8 public: | |||
|
55 | 55 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); |
|
56 | 56 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); |
|
57 | 57 | qmlRegisterType<DeclarativeGroupedBarSeries>(uri, 1, 0, "GroupedBarSeries"); |
|
58 | qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries"); | |
|
59 | qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries"); | |
|
58 | 60 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); |
|
59 | 61 | qmlRegisterType<DeclarativePieSlice>(uri, 1, 0, "PieSlice"); |
|
60 | 62 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); |
@@ -31,7 +31,7 ChartView { | |||
|
31 | 31 | |
|
32 | 32 | property variant series: daSeries |
|
33 | 33 | |
|
34 |
|
|
|
34 | BarSeries { | |
|
35 | 35 | id: daSeries |
|
36 | 36 | barCategories: [ "2008", "2009", "2010", "2011", "2012" ] |
|
37 | 37 | BarSet { name: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
@@ -23,7 +23,7 import QtQuick 1.0 | |||
|
23 | 23 | Rectangle { |
|
24 | 24 | id: button |
|
25 | 25 | height: 25 |
|
26 |
width: 1 |
|
|
26 | width: 140 | |
|
27 | 27 | color: "#afafaf" |
|
28 | 28 | radius: 5 |
|
29 | 29 |
@@ -26,7 +26,7 Rectangle { | |||
|
26 | 26 | width: parent.width |
|
27 | 27 | height: parent.height |
|
28 | 28 | property int viewNumber: 0 |
|
29 |
property int viewCount: |
|
|
29 | property int viewCount: 9 | |
|
30 | 30 | property variant colors: ["#637D74", "#403D3A", "#8C3B3B", "#AB6937", "#D4A960"] |
|
31 | 31 | property int colorIndex: 0 |
|
32 | 32 | |
@@ -55,6 +55,15 Rectangle { | |||
|
55 | 55 | } else if (viewNumber == 5) { |
|
56 | 56 | chartLoader.source = "BarChart.qml"; |
|
57 | 57 | editorLoader.source = "BarEditor.qml"; |
|
58 | } else if (viewNumber == 6) { | |
|
59 | chartLoader.source = "GroupedBarChart.qml"; | |
|
60 | editorLoader.source = "BarEditor.qml"; | |
|
61 | } else if (viewNumber == 7) { | |
|
62 | chartLoader.source = "StackedBarChart.qml"; | |
|
63 | editorLoader.source = "BarEditor.qml"; | |
|
64 | } else if (viewNumber == 8) { | |
|
65 | chartLoader.source = "PercentBarChart.qml"; | |
|
66 | editorLoader.source = "BarEditor.qml"; | |
|
58 | 67 | } else { |
|
59 | 68 | console.log("Illegal view number"); |
|
60 | 69 | } |
@@ -63,6 +72,7 Rectangle { | |||
|
63 | 72 | Row { |
|
64 | 73 | anchors.top: parent.top |
|
65 | 74 | anchors.bottom: buttonRow.top |
|
75 | anchors.bottomMargin: 10 | |
|
66 | 76 | anchors.left: parent.left |
|
67 | 77 | anchors.right: parent.right |
|
68 | 78 | |
@@ -80,7 +90,7 Rectangle { | |||
|
80 | 90 | |
|
81 | 91 | Loader { |
|
82 | 92 | id: editorLoader |
|
83 |
width: 2 |
|
|
93 | width: 280 | |
|
84 | 94 | height: parent.height |
|
85 | 95 | source: "PieEditor.qml" |
|
86 | 96 | onStatusChanged: { |
@@ -93,44 +103,23 Rectangle { | |||
|
93 | 103 | |
|
94 | 104 | Row { |
|
95 | 105 | id: buttonRow |
|
96 |
height: |
|
|
106 | height: 40 | |
|
97 | 107 | anchors.bottom: parent.bottom |
|
98 | anchors.bottomMargin: 10 | |
|
99 | 108 | anchors.horizontalCenter: parent.horizontalCenter |
|
100 | 109 | spacing: 10 |
|
101 | 110 | |
|
102 |
|
|
|
103 | height: buttonRow.height | |
|
104 | width: 100 | |
|
105 | color: "#afafaf" | |
|
106 | radius: 5 | |
|
107 | Text { | |
|
108 | anchors.centerIn: parent | |
|
111 | Button { | |
|
109 | 112 |
|
|
110 | } | |
|
111 | MouseArea { | |
|
112 | anchors.fill: parent | |
|
113 | 113 |
|
|
114 | 114 |
|
|
115 | 115 |
|
|
116 | 116 |
|
|
117 | } | |
|
118 | 117 | |
|
119 |
|
|
|
120 | height: buttonRow.height | |
|
121 | width: 100 | |
|
122 | color: "#afafaf" | |
|
123 | radius: 5 | |
|
124 | Text { | |
|
125 | anchors.centerIn: parent | |
|
118 | Button { | |
|
126 | 119 |
|
|
127 | } | |
|
128 | MouseArea { | |
|
129 | anchors.fill: parent | |
|
130 | 120 |
|
|
131 | 121 |
|
|
132 | 122 |
|
|
133 | 123 |
|
|
134 | 124 |
|
|
135 | 125 | } |
|
136 | } |
@@ -14,5 +14,8 | |||
|
14 | 14 | <file>qml/qmlchartproperties/BarEditor.qml</file> |
|
15 | 15 | <file>qml/qmlchartproperties/ScatterEditor.qml</file> |
|
16 | 16 | <file>qml/qmlchartproperties/AreaEditor.qml</file> |
|
17 | <file>qml/qmlchartproperties/GroupedBarChart.qml</file> | |
|
18 | <file>qml/qmlchartproperties/StackedBarChart.qml</file> | |
|
19 | <file>qml/qmlchartproperties/PercentBarChart.qml</file> | |
|
17 | 20 | </qresource> |
|
18 | 21 | </RCC> |
General Comments 0
You need to be logged in to leave comments.
Login now