@@ -1,306 +1,308 | |||||
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 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 | DeclarativeBarSet::DeclarativeBarSet(QObject *parent) : |
|
29 | DeclarativeBarSet::DeclarativeBarSet(QObject *parent) : | |
30 | QBarSet("", parent) |
|
30 | QBarSet("", parent) | |
31 | { |
|
31 | { | |
32 | connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int, int))); |
|
32 | connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int, int))); | |
33 | connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int, int))); |
|
33 | connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int, int))); | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | void DeclarativeBarSet::handleCountChanged(int index, int count) |
|
36 | void DeclarativeBarSet::handleCountChanged(int index, int count) | |
37 | { |
|
37 | { | |
38 | Q_UNUSED(index) |
|
38 | Q_UNUSED(index) | |
39 | Q_UNUSED(count) |
|
39 | Q_UNUSED(count) | |
40 | emit countChanged(QBarSet::count()); |
|
40 | emit countChanged(QBarSet::count()); | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | QVariantList DeclarativeBarSet::values() |
|
43 | QVariantList DeclarativeBarSet::values() | |
44 | { |
|
44 | { | |
45 | QVariantList values; |
|
45 | QVariantList values; | |
46 | for (int i(0); i < count(); i++) |
|
46 | for (int i(0); i < count(); i++) | |
47 | values.append(QVariant(at(i))); |
|
47 | values.append(QVariant(QBarSet::at(i))); | |
48 | return values; |
|
48 | return values; | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 | void DeclarativeBarSet::setValues(QVariantList values) |
|
51 | void DeclarativeBarSet::setValues(QVariantList values) | |
52 | { |
|
52 | { | |
53 | while (count()) |
|
53 | while (count()) | |
54 | remove(count() - 1); |
|
54 | remove(count() - 1); | |
55 |
|
55 | |||
56 | for (int i(0); i < values.count(); i++) { |
|
56 | for (int i(0); i < values.count(); i++) { | |
57 | if (values.at(i).canConvert(QVariant::Double)) |
|
57 | if (values.at(i).canConvert(QVariant::Double)) | |
58 | append(values[i].toDouble()); |
|
58 | QBarSet::append(values[i].toDouble()); | |
|
59 | else if (values.at(i).canConvert(QVariant::PointF)) | |||
|
60 | QBarSet::append(values[i].toPointF()); | |||
59 | } |
|
61 | } | |
60 | } |
|
62 | } | |
61 |
|
63 | |||
62 | DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : |
|
64 | DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : | |
63 | QBarSeries(parent) |
|
65 | QBarSeries(parent) | |
64 | { |
|
66 | { | |
65 | connect(this, SIGNAL(barsetsAdded(QList<QBarSet*>)), this, SLOT(handleAdded(QList<QBarSet*>))); |
|
67 | connect(this, SIGNAL(barsetsAdded(QList<QBarSet*>)), this, SLOT(handleAdded(QList<QBarSet*>))); | |
66 | connect(this, SIGNAL(barsetsRemoved(QList<QBarSet*>)), this, SLOT(handleRemoved(QList<QBarSet*>))); |
|
68 | connect(this, SIGNAL(barsetsRemoved(QList<QBarSet*>)), this, SLOT(handleRemoved(QList<QBarSet*>))); | |
67 | } |
|
69 | } | |
68 |
|
70 | |||
69 | void DeclarativeBarSeries::handleAdded(QList<QBarSet* > barsets) |
|
71 | void DeclarativeBarSeries::handleAdded(QList<QBarSet* > barsets) | |
70 | { |
|
72 | { | |
71 | foreach(QBarSet *b, barsets) { |
|
73 | foreach(QBarSet *b, barsets) { | |
72 | DeclarativeBarSet *barset = qobject_cast<DeclarativeBarSet *>(b); |
|
74 | DeclarativeBarSet *barset = qobject_cast<DeclarativeBarSet *>(b); | |
73 | emit added(barset); |
|
75 | emit added(barset); | |
74 | } |
|
76 | } | |
75 | } |
|
77 | } | |
76 |
|
78 | |||
77 | void DeclarativeBarSeries::handleRemoved(QList<QBarSet* > barsets) |
|
79 | void DeclarativeBarSeries::handleRemoved(QList<QBarSet* > barsets) | |
78 | { |
|
80 | { | |
79 | foreach(QBarSet *b, barsets) { |
|
81 | foreach(QBarSet *b, barsets) { | |
80 | DeclarativeBarSet *barset = qobject_cast<DeclarativeBarSet *>(b); |
|
82 | DeclarativeBarSet *barset = qobject_cast<DeclarativeBarSet *>(b); | |
81 | emit removed(barset); |
|
83 | emit removed(barset); | |
82 | } |
|
84 | } | |
83 | } |
|
85 | } | |
84 |
|
86 | |||
85 | void DeclarativeBarSeries::classBegin() |
|
87 | void DeclarativeBarSeries::classBegin() | |
86 | { |
|
88 | { | |
87 | } |
|
89 | } | |
88 |
|
90 | |||
89 | void DeclarativeBarSeries::componentComplete() |
|
91 | void DeclarativeBarSeries::componentComplete() | |
90 | { |
|
92 | { | |
91 | foreach(QObject *child, children()) { |
|
93 | foreach(QObject *child, children()) { | |
92 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
94 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
93 | QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
95 | QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
94 | } else if(qobject_cast<QVBarModelMapper *>(child)) { |
|
96 | } else if(qobject_cast<QVBarModelMapper *>(child)) { | |
95 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
97 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
96 | mapper->setSeries(this); |
|
98 | mapper->setSeries(this); | |
97 | } else if(qobject_cast<QHBarModelMapper *>(child)) { |
|
99 | } else if(qobject_cast<QHBarModelMapper *>(child)) { | |
98 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
100 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
99 | mapper->setSeries(this); |
|
101 | mapper->setSeries(this); | |
100 | } |
|
102 | } | |
101 | } |
|
103 | } | |
102 | } |
|
104 | } | |
103 |
|
105 | |||
104 | QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren() |
|
106 | QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren() | |
105 | { |
|
107 | { | |
106 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); |
|
108 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); | |
107 | } |
|
109 | } | |
108 |
|
110 | |||
109 | void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
111 | void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
110 | { |
|
112 | { | |
111 | // Empty implementation; the children are parsed in componentComplete instead |
|
113 | // Empty implementation; the children are parsed in componentComplete instead | |
112 | Q_UNUSED(list); |
|
114 | Q_UNUSED(list); | |
113 | Q_UNUSED(element); |
|
115 | Q_UNUSED(element); | |
114 | } |
|
116 | } | |
115 |
|
117 | |||
116 | DeclarativeBarSet *DeclarativeBarSeries::at(int index) |
|
118 | DeclarativeBarSet *DeclarativeBarSeries::at(int index) | |
117 | { |
|
119 | { | |
118 | QList<QBarSet*> setList = barSets(); |
|
120 | QList<QBarSet*> setList = barSets(); | |
119 | if (index >= 0 && index < setList.count()) |
|
121 | if (index >= 0 && index < setList.count()) | |
120 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
122 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
121 |
|
123 | |||
122 | return 0; |
|
124 | return 0; | |
123 | } |
|
125 | } | |
124 |
|
126 | |||
125 | DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values) |
|
127 | DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values) | |
126 | { |
|
128 | { | |
127 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
129 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
128 | barset->setLabel(label); |
|
130 | barset->setLabel(label); | |
129 | barset->setValues(values); |
|
131 | barset->setValues(values); | |
130 | if (QBarSeries::insert(index, barset)) |
|
132 | if (QBarSeries::insert(index, barset)) | |
131 | return barset; |
|
133 | return barset; | |
132 | delete barset; |
|
134 | delete barset; | |
133 | return 0; |
|
135 | return 0; | |
134 | } |
|
136 | } | |
135 |
|
137 | |||
136 | DeclarativeGroupedBarSeries::DeclarativeGroupedBarSeries(QDeclarativeItem *parent) : |
|
138 | DeclarativeGroupedBarSeries::DeclarativeGroupedBarSeries(QDeclarativeItem *parent) : | |
137 | QGroupedBarSeries(parent) |
|
139 | QGroupedBarSeries(parent) | |
138 | { |
|
140 | { | |
139 | } |
|
141 | } | |
140 |
|
142 | |||
141 | void DeclarativeGroupedBarSeries::classBegin() |
|
143 | void DeclarativeGroupedBarSeries::classBegin() | |
142 | { |
|
144 | { | |
143 | } |
|
145 | } | |
144 |
|
146 | |||
145 | void DeclarativeGroupedBarSeries::componentComplete() |
|
147 | void DeclarativeGroupedBarSeries::componentComplete() | |
146 | { |
|
148 | { | |
147 | foreach(QObject *child, children()) { |
|
149 | foreach(QObject *child, children()) { | |
148 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
150 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
149 | QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
151 | QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
150 | } else if(qobject_cast<QVBarModelMapper *>(child)) { |
|
152 | } else if(qobject_cast<QVBarModelMapper *>(child)) { | |
151 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
153 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
152 | mapper->setSeries(this); |
|
154 | mapper->setSeries(this); | |
153 | } else if(qobject_cast<QHBarModelMapper *>(child)) { |
|
155 | } else if(qobject_cast<QHBarModelMapper *>(child)) { | |
154 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
156 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
155 | mapper->setSeries(this); |
|
157 | mapper->setSeries(this); | |
156 | } |
|
158 | } | |
157 | } |
|
159 | } | |
158 | } |
|
160 | } | |
159 |
|
161 | |||
160 | QDeclarativeListProperty<QObject> DeclarativeGroupedBarSeries::seriesChildren() |
|
162 | QDeclarativeListProperty<QObject> DeclarativeGroupedBarSeries::seriesChildren() | |
161 | { |
|
163 | { | |
162 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); |
|
164 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); | |
163 | } |
|
165 | } | |
164 |
|
166 | |||
165 | void DeclarativeGroupedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
167 | void DeclarativeGroupedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
166 | { |
|
168 | { | |
167 | // Empty implementation; the children are parsed in componentComplete instead |
|
169 | // Empty implementation; the children are parsed in componentComplete instead | |
168 | Q_UNUSED(list); |
|
170 | Q_UNUSED(list); | |
169 | Q_UNUSED(element); |
|
171 | Q_UNUSED(element); | |
170 | } |
|
172 | } | |
171 |
|
173 | |||
172 | DeclarativeBarSet *DeclarativeGroupedBarSeries::at(int index) |
|
174 | DeclarativeBarSet *DeclarativeGroupedBarSeries::at(int index) | |
173 | { |
|
175 | { | |
174 | QList<QBarSet*> setList = barSets(); |
|
176 | QList<QBarSet*> setList = barSets(); | |
175 | if (index >= 0 && index < setList.count()) |
|
177 | if (index >= 0 && index < setList.count()) | |
176 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
178 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
177 |
|
179 | |||
178 | return 0; |
|
180 | return 0; | |
179 | } |
|
181 | } | |
180 |
|
182 | |||
181 | DeclarativeBarSet *DeclarativeGroupedBarSeries::insert(int index, QString label, QVariantList values) |
|
183 | DeclarativeBarSet *DeclarativeGroupedBarSeries::insert(int index, QString label, QVariantList values) | |
182 | { |
|
184 | { | |
183 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
185 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
184 | barset->setLabel(label); |
|
186 | barset->setLabel(label); | |
185 | barset->setValues(values); |
|
187 | barset->setValues(values); | |
186 | if (QGroupedBarSeries::insert(index, barset)) |
|
188 | if (QGroupedBarSeries::insert(index, barset)) | |
187 | return barset; |
|
189 | return barset; | |
188 | delete barset; |
|
190 | delete barset; | |
189 | return 0; |
|
191 | return 0; | |
190 | } |
|
192 | } | |
191 |
|
193 | |||
192 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) : |
|
194 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) : | |
193 | QStackedBarSeries(parent) |
|
195 | QStackedBarSeries(parent) | |
194 | { |
|
196 | { | |
195 | } |
|
197 | } | |
196 |
|
198 | |||
197 | void DeclarativeStackedBarSeries::classBegin() |
|
199 | void DeclarativeStackedBarSeries::classBegin() | |
198 | { |
|
200 | { | |
199 | } |
|
201 | } | |
200 |
|
202 | |||
201 | void DeclarativeStackedBarSeries::componentComplete() |
|
203 | void DeclarativeStackedBarSeries::componentComplete() | |
202 | { |
|
204 | { | |
203 | foreach(QObject *child, children()) { |
|
205 | foreach(QObject *child, children()) { | |
204 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
206 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
205 | QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
207 | QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
206 | } else if(qobject_cast<QVBarModelMapper *>(child)) { |
|
208 | } else if(qobject_cast<QVBarModelMapper *>(child)) { | |
207 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
209 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
208 | mapper->setSeries(this); |
|
210 | mapper->setSeries(this); | |
209 | } else if(qobject_cast<QHBarModelMapper *>(child)) { |
|
211 | } else if(qobject_cast<QHBarModelMapper *>(child)) { | |
210 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
212 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
211 | mapper->setSeries(this); |
|
213 | mapper->setSeries(this); | |
212 | } |
|
214 | } | |
213 | } |
|
215 | } | |
214 | } |
|
216 | } | |
215 |
|
217 | |||
216 | QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren() |
|
218 | QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren() | |
217 | { |
|
219 | { | |
218 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); |
|
220 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); | |
219 | } |
|
221 | } | |
220 |
|
222 | |||
221 | void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
223 | void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
222 | { |
|
224 | { | |
223 | // Empty implementation; the children are parsed in componentComplete instead |
|
225 | // Empty implementation; the children are parsed in componentComplete instead | |
224 | Q_UNUSED(list); |
|
226 | Q_UNUSED(list); | |
225 | Q_UNUSED(element); |
|
227 | Q_UNUSED(element); | |
226 | } |
|
228 | } | |
227 |
|
229 | |||
228 | DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index) |
|
230 | DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index) | |
229 | { |
|
231 | { | |
230 | QList<QBarSet*> setList = barSets(); |
|
232 | QList<QBarSet*> setList = barSets(); | |
231 | if (index >= 0 && index < setList.count()) |
|
233 | if (index >= 0 && index < setList.count()) | |
232 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
234 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
233 |
|
235 | |||
234 | return 0; |
|
236 | return 0; | |
235 | } |
|
237 | } | |
236 |
|
238 | |||
237 | DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, QVariantList values) |
|
239 | DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, QVariantList values) | |
238 | { |
|
240 | { | |
239 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
241 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
240 | barset->setLabel(label); |
|
242 | barset->setLabel(label); | |
241 | barset->setValues(values); |
|
243 | barset->setValues(values); | |
242 | if (QStackedBarSeries::insert(index, barset)) |
|
244 | if (QStackedBarSeries::insert(index, barset)) | |
243 | return barset; |
|
245 | return barset; | |
244 | delete barset; |
|
246 | delete barset; | |
245 | return 0; |
|
247 | return 0; | |
246 | } |
|
248 | } | |
247 |
|
249 | |||
248 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) : |
|
250 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) : | |
249 | QPercentBarSeries(parent) |
|
251 | QPercentBarSeries(parent) | |
250 | { |
|
252 | { | |
251 | } |
|
253 | } | |
252 |
|
254 | |||
253 | void DeclarativePercentBarSeries::classBegin() |
|
255 | void DeclarativePercentBarSeries::classBegin() | |
254 | { |
|
256 | { | |
255 | } |
|
257 | } | |
256 |
|
258 | |||
257 | void DeclarativePercentBarSeries::componentComplete() |
|
259 | void DeclarativePercentBarSeries::componentComplete() | |
258 | { |
|
260 | { | |
259 | foreach(QObject *child, children()) { |
|
261 | foreach(QObject *child, children()) { | |
260 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
262 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
261 | QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
263 | QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
262 | } else if(qobject_cast<QVBarModelMapper *>(child)) { |
|
264 | } else if(qobject_cast<QVBarModelMapper *>(child)) { | |
263 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
265 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
264 | mapper->setSeries(this); |
|
266 | mapper->setSeries(this); | |
265 | } else if(qobject_cast<QHBarModelMapper *>(child)) { |
|
267 | } else if(qobject_cast<QHBarModelMapper *>(child)) { | |
266 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
268 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
267 | mapper->setSeries(this); |
|
269 | mapper->setSeries(this); | |
268 | } |
|
270 | } | |
269 | } |
|
271 | } | |
270 | } |
|
272 | } | |
271 |
|
273 | |||
272 | QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren() |
|
274 | QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren() | |
273 | { |
|
275 | { | |
274 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); |
|
276 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); | |
275 | } |
|
277 | } | |
276 |
|
278 | |||
277 | void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
279 | void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
278 | { |
|
280 | { | |
279 | // Empty implementation; the children are parsed in componentComplete instead |
|
281 | // Empty implementation; the children are parsed in componentComplete instead | |
280 | Q_UNUSED(list); |
|
282 | Q_UNUSED(list); | |
281 | Q_UNUSED(element); |
|
283 | Q_UNUSED(element); | |
282 | } |
|
284 | } | |
283 |
|
285 | |||
284 | DeclarativeBarSet *DeclarativePercentBarSeries::at(int index) |
|
286 | DeclarativeBarSet *DeclarativePercentBarSeries::at(int index) | |
285 | { |
|
287 | { | |
286 | QList<QBarSet*> setList = barSets(); |
|
288 | QList<QBarSet*> setList = barSets(); | |
287 | if (index >= 0 && index < setList.count()) |
|
289 | if (index >= 0 && index < setList.count()) | |
288 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
290 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
289 |
|
291 | |||
290 | return 0; |
|
292 | return 0; | |
291 | } |
|
293 | } | |
292 |
|
294 | |||
293 | DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, QVariantList values) |
|
295 | DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, QVariantList values) | |
294 | { |
|
296 | { | |
295 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
297 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
296 | barset->setLabel(label); |
|
298 | barset->setLabel(label); | |
297 | barset->setValues(values); |
|
299 | barset->setValues(values); | |
298 | if (QPercentBarSeries::insert(index, barset)) |
|
300 | if (QPercentBarSeries::insert(index, barset)) | |
299 | return barset; |
|
301 | return barset; | |
300 | delete barset; |
|
302 | delete barset; | |
301 | return 0; |
|
303 | return 0; | |
302 | } |
|
304 | } | |
303 |
|
305 | |||
304 | #include "moc_declarativebarseries.cpp" |
|
306 | #include "moc_declarativebarseries.cpp" | |
305 |
|
307 | |||
306 | QTCOMMERCIALCHART_END_NAMESPACE |
|
308 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,162 +1,166 | |||||
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 <QGroupedBarSeries> |
|
25 | #include <QGroupedBarSeries> | |
26 | #include <QStackedBarSeries> |
|
26 | #include <QStackedBarSeries> | |
27 | #include <QPercentBarSeries> |
|
27 | #include <QPercentBarSeries> | |
28 | #include <QBarSet> |
|
28 | #include <QBarSet> | |
29 | #include <QDeclarativeItem> |
|
29 | #include <QDeclarativeItem> | |
30 | #include <QDeclarativeParserStatus> |
|
30 | #include <QDeclarativeParserStatus> | |
31 |
|
31 | |||
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
33 |
|
33 | |||
34 | class QChart; |
|
34 | class QChart; | |
35 |
|
35 | |||
36 | class DeclarativeBarSet : public QBarSet |
|
36 | class DeclarativeBarSet : public QBarSet | |
37 | { |
|
37 | { | |
38 | Q_OBJECT |
|
38 | Q_OBJECT | |
39 | Q_PROPERTY(QVariantList values READ values WRITE setValues) |
|
39 | Q_PROPERTY(QVariantList values READ values WRITE setValues) | |
40 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
40 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
41 |
|
41 | |||
42 | public: |
|
42 | public: | |
43 | explicit DeclarativeBarSet(QObject *parent = 0); |
|
43 | explicit DeclarativeBarSet(QObject *parent = 0); | |
44 | QVariantList values(); |
|
44 | QVariantList values(); | |
45 | void setValues(QVariantList values); |
|
45 | void setValues(QVariantList values); | |
46 |
|
46 | |||
47 | public: // From QBarSet |
|
47 | public: // From QBarSet | |
48 | Q_INVOKABLE void append(qreal value) { QBarSet::append(value); } |
|
48 | Q_INVOKABLE void append(qreal value) { QBarSet::append(value); } | |
49 | Q_INVOKABLE void append(qreal x, qreal y) { QBarSet::append(QPointF(x, y)); } |
|
49 | Q_INVOKABLE void append(qreal x, qreal y) { QBarSet::append(QPointF(x, y)); } | |
|
50 | Q_INVOKABLE bool remove(const int index, const int count = 1) { return QBarSet::remove(index, count); } | |||
|
51 | Q_INVOKABLE void replace(int index, qreal value) { QBarSet::replace(index, value); } | |||
|
52 | Q_INVOKABLE void replace(int index, qreal x, qreal y) { QBarSet::replace(index, QPointF(x, y)); } | |||
|
53 | Q_INVOKABLE QPointF at(int index) { return QBarSet::at(index); } | |||
50 |
|
54 | |||
51 | Q_SIGNALS: |
|
55 | Q_SIGNALS: | |
52 | void countChanged(int count); |
|
56 | void countChanged(int count); | |
53 |
|
57 | |||
54 | private Q_SLOTS: |
|
58 | private Q_SLOTS: | |
55 | void handleCountChanged(int index, int count); |
|
59 | void handleCountChanged(int index, int count); | |
56 | }; |
|
60 | }; | |
57 |
|
61 | |||
58 | class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus |
|
62 | class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus | |
59 | { |
|
63 | { | |
60 | Q_OBJECT |
|
64 | Q_OBJECT | |
61 | Q_INTERFACES(QDeclarativeParserStatus) |
|
65 | Q_INTERFACES(QDeclarativeParserStatus) | |
62 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
66 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
63 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
67 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
64 |
|
68 | |||
65 | public: |
|
69 | public: | |
66 | explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0); |
|
70 | explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0); | |
67 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
71 | QDeclarativeListProperty<QObject> seriesChildren(); | |
68 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
72 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
69 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
73 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
70 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
74 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
71 | Q_INVOKABLE bool remove(QBarSet *barset) { return QBarSeries::remove(barset); } |
|
75 | Q_INVOKABLE bool remove(QBarSet *barset) { return QBarSeries::remove(barset); } | |
72 | Q_INVOKABLE void clear() { return QBarSeries::clear(); } |
|
76 | Q_INVOKABLE void clear() { return QBarSeries::clear(); } | |
73 |
|
77 | |||
74 | public: // from QDeclarativeParserStatus |
|
78 | public: // from QDeclarativeParserStatus | |
75 | void classBegin(); |
|
79 | void classBegin(); | |
76 | void componentComplete(); |
|
80 | void componentComplete(); | |
77 |
|
81 | |||
78 | Q_SIGNALS: |
|
82 | Q_SIGNALS: | |
79 | void added(DeclarativeBarSet *barset); |
|
83 | void added(DeclarativeBarSet *barset); | |
80 | void removed(DeclarativeBarSet *barset); |
|
84 | void removed(DeclarativeBarSet *barset); | |
81 |
|
85 | |||
82 | public Q_SLOTS: |
|
86 | public Q_SLOTS: | |
83 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
87 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
84 | void handleAdded(QList<QBarSet* > barsets); |
|
88 | void handleAdded(QList<QBarSet* > barsets); | |
85 | void handleRemoved(QList<QBarSet* > barsets); |
|
89 | void handleRemoved(QList<QBarSet* > barsets); | |
86 | }; |
|
90 | }; | |
87 |
|
91 | |||
88 | class DeclarativeGroupedBarSeries : public QGroupedBarSeries, public QDeclarativeParserStatus |
|
92 | class DeclarativeGroupedBarSeries : public QGroupedBarSeries, public QDeclarativeParserStatus | |
89 | { |
|
93 | { | |
90 | Q_OBJECT |
|
94 | Q_OBJECT | |
91 | Q_INTERFACES(QDeclarativeParserStatus) |
|
95 | Q_INTERFACES(QDeclarativeParserStatus) | |
92 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
96 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
93 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
97 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
94 |
|
98 | |||
95 | public: |
|
99 | public: | |
96 | explicit DeclarativeGroupedBarSeries(QDeclarativeItem *parent = 0); |
|
100 | explicit DeclarativeGroupedBarSeries(QDeclarativeItem *parent = 0); | |
97 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
101 | QDeclarativeListProperty<QObject> seriesChildren(); | |
98 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
102 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
99 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
103 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
100 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
104 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
101 | Q_INVOKABLE bool remove(QBarSet *barset) { return QGroupedBarSeries::remove(barset); } |
|
105 | Q_INVOKABLE bool remove(QBarSet *barset) { return QGroupedBarSeries::remove(barset); } | |
102 | Q_INVOKABLE void clear() { return QGroupedBarSeries::clear(); } |
|
106 | Q_INVOKABLE void clear() { return QGroupedBarSeries::clear(); } | |
103 |
|
107 | |||
104 | public: // from QDeclarativeParserStatus |
|
108 | public: // from QDeclarativeParserStatus | |
105 | void classBegin(); |
|
109 | void classBegin(); | |
106 | void componentComplete(); |
|
110 | void componentComplete(); | |
107 |
|
111 | |||
108 | public Q_SLOTS: |
|
112 | public Q_SLOTS: | |
109 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
113 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
110 | }; |
|
114 | }; | |
111 |
|
115 | |||
112 | class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus |
|
116 | class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus | |
113 | { |
|
117 | { | |
114 | Q_OBJECT |
|
118 | Q_OBJECT | |
115 | Q_INTERFACES(QDeclarativeParserStatus) |
|
119 | Q_INTERFACES(QDeclarativeParserStatus) | |
116 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
120 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
117 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
121 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
118 |
|
122 | |||
119 | public: |
|
123 | public: | |
120 | explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0); |
|
124 | explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0); | |
121 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
125 | QDeclarativeListProperty<QObject> seriesChildren(); | |
122 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
126 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
123 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
127 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
124 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
128 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
125 | Q_INVOKABLE bool remove(QBarSet *barset) { return QStackedBarSeries::remove(barset); } |
|
129 | Q_INVOKABLE bool remove(QBarSet *barset) { return QStackedBarSeries::remove(barset); } | |
126 | Q_INVOKABLE void clear() { return QStackedBarSeries::clear(); } |
|
130 | Q_INVOKABLE void clear() { return QStackedBarSeries::clear(); } | |
127 |
|
131 | |||
128 | public: // from QDeclarativeParserStatus |
|
132 | public: // from QDeclarativeParserStatus | |
129 | void classBegin(); |
|
133 | void classBegin(); | |
130 | void componentComplete(); |
|
134 | void componentComplete(); | |
131 |
|
135 | |||
132 | public Q_SLOTS: |
|
136 | public Q_SLOTS: | |
133 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
137 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
134 | }; |
|
138 | }; | |
135 |
|
139 | |||
136 | class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus |
|
140 | class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus | |
137 | { |
|
141 | { | |
138 | Q_OBJECT |
|
142 | Q_OBJECT | |
139 | Q_INTERFACES(QDeclarativeParserStatus) |
|
143 | Q_INTERFACES(QDeclarativeParserStatus) | |
140 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
144 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
141 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
145 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
142 |
|
146 | |||
143 | public: |
|
147 | public: | |
144 | explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0); |
|
148 | explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0); | |
145 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
149 | QDeclarativeListProperty<QObject> seriesChildren(); | |
146 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
150 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
147 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
151 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
148 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
152 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
149 | Q_INVOKABLE bool remove(QBarSet *barset) { return QPercentBarSeries::remove(barset); } |
|
153 | Q_INVOKABLE bool remove(QBarSet *barset) { return QPercentBarSeries::remove(barset); } | |
150 | Q_INVOKABLE void clear() { return QPercentBarSeries::clear(); } |
|
154 | Q_INVOKABLE void clear() { return QPercentBarSeries::clear(); } | |
151 |
|
155 | |||
152 | public: // from QDeclarativeParserStatus |
|
156 | public: // from QDeclarativeParserStatus | |
153 | void classBegin(); |
|
157 | void classBegin(); | |
154 | void componentComplete(); |
|
158 | void componentComplete(); | |
155 |
|
159 | |||
156 | public Q_SLOTS: |
|
160 | public Q_SLOTS: | |
157 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
161 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
158 | }; |
|
162 | }; | |
159 |
|
163 | |||
160 | QTCOMMERCIALCHART_END_NAMESPACE |
|
164 | QTCOMMERCIALCHART_END_NAMESPACE | |
161 |
|
165 | |||
162 | #endif // DECLARATIVEBARSERIES_H |
|
166 | #endif // DECLARATIVEBARSERIES_H |
@@ -1,58 +1,66 | |||||
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 | ChartView { |
|
24 | ChartView { | |
25 | title: "Bar series" |
|
25 | title: "Bar series" | |
26 | anchors.fill: parent |
|
26 | anchors.fill: parent | |
27 | theme: ChartView.ChartThemeLight |
|
27 | theme: ChartView.ChartThemeLight | |
28 | legend.alignment: Qt.AlignBottom |
|
28 | legend.alignment: Qt.AlignBottom | |
29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] |
|
29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] | |
30 |
|
30 | |||
31 | property variant series: barSeries |
|
31 | property variant series: barSeries | |
32 |
|
32 | |||
33 | BarSeries { |
|
33 | BarSeries { | |
34 | id: barSeries |
|
34 | id: barSeries | |
35 | name: "bar" |
|
35 | name: "bar" | |
36 | BarSet { label: "Bob"; values: [4, 7, 3, 10, 5, 6] |
|
36 | BarSet { label: "Bob"; values: [4, 7, 3, 10, 5, 6] | |
37 | onClicked: console.log("barset.onClicked: " + index); |
|
37 | onClicked: console.log("barset.onClicked: " + index); | |
38 | onHovered: console.log("barset.onHovered: " + status); |
|
38 | onHovered: console.log("barset.onHovered: " + status); | |
|
39 | onPenChanged: console.log("barset.onPenChanged: " + pen); | |||
|
40 | onBrushChanged: console.log("barset.onBrushChanged: " + brush); | |||
|
41 | onLabelChanged: console.log("barset.onLabelChanged: " + label); | |||
|
42 | onLabelBrushChanged: console.log("barset.onLabelBrushChanged: " + labelBrush); | |||
|
43 | onLabelFontChanged: console.log("barset.onLabelFontChanged: " + labelFont); | |||
39 | onColorChanged: console.log("barset.onColorChanged: " + color); |
|
44 | onColorChanged: console.log("barset.onColorChanged: " + color); | |
40 | onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); |
|
45 | onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); | |
41 | onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); |
|
46 | onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); | |
42 | onCountChanged: console.log("barset.onCountChanged: " + count); |
|
47 | onCountChanged: console.log("barset.onCountChanged: " + count); | |
|
48 | onValuesAdded: console.log("barset.onValuesAdded: " + index + ", " + count); | |||
|
49 | onValuesRemoved: console.log("barset.onValuesRemoved: " + index + ", " + count); | |||
|
50 | onValueChanged: console.log("barset.onValuesChanged: " + index); | |||
43 | } |
|
51 | } | |
44 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 8] } |
|
52 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 8] } | |
45 | BarSet { label: "James"; values: [3, 5, 8, 5, 4, 7] } |
|
53 | BarSet { label: "James"; values: [3, 5, 8, 5, 4, 7] } | |
46 |
|
54 | |||
47 | onNameChanged: console.log("barSeries.onNameChanged: " + series.name); |
|
55 | onNameChanged: console.log("barSeries.onNameChanged: " + series.name); | |
48 | onVisibleChanged: console.log("barSeries.onVisibleChanged: " + series.visible); |
|
56 | onVisibleChanged: console.log("barSeries.onVisibleChanged: " + series.visible); | |
49 | onClicked: console.log("barSeries.onClicked: " + barset + " " + index); |
|
57 | onClicked: console.log("barSeries.onClicked: " + barset + " " + index); | |
50 | onHovered: console.log("barSeries.onHovered: " + barset + " " + status); |
|
58 | onHovered: console.log("barSeries.onHovered: " + barset + " " + status); | |
51 | onLabelsVisibleChanged: console.log("barSeries.onLabelsVisibleChanged: " + series.labelsVisible); |
|
59 | onLabelsVisibleChanged: console.log("barSeries.onLabelsVisibleChanged: " + series.labelsVisible); | |
52 | onCountChanged: console.log("barSeries.onCountChanged: " + count); |
|
60 | onCountChanged: console.log("barSeries.onCountChanged: " + count); | |
53 | onBarsetsAdded: console.log("barSeries.onBarsetsAdded: " + sets); // There is no point in this signal on QML side |
|
61 | onBarsetsAdded: console.log("barSeries.onBarsetsAdded: " + sets); // There is no point in this signal on QML side | |
54 | onAdded: console.log("barSeries.onBarsetAdded: " + barset); |
|
62 | onAdded: console.log("barSeries.onBarsetAdded: " + barset); | |
55 | onBarsetsRemoved: console.log("barSeries.onBarsetsRemoved: " + sets); // There is no point in this signal on QML side |
|
63 | onBarsetsRemoved: console.log("barSeries.onBarsetsRemoved: " + sets); // There is no point in this signal on QML side | |
56 | onRemoved: console.log("barSeries.onBarsetRemoved: " + barset); |
|
64 | onRemoved: console.log("barSeries.onBarsetRemoved: " + barset); | |
57 | } |
|
65 | } | |
58 | } |
|
66 | } |
@@ -1,88 +1,102 | |||||
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 | Flow { |
|
24 | Flow { | |
25 | id: flow |
|
25 | id: flow | |
26 | spacing: 5 |
|
26 | spacing: 5 | |
27 | flow: Flow.TopToBottom |
|
27 | flow: Flow.TopToBottom | |
28 | property variant series |
|
28 | property variant series | |
29 |
|
29 | |||
30 | Button { |
|
30 | Button { | |
31 | text: "visible" |
|
31 | text: "visible" | |
32 | onClicked: series.visible = !series.visible; |
|
32 | onClicked: series.visible = !series.visible; | |
33 | } |
|
33 | } | |
34 | Button { |
|
34 | Button { | |
35 | text: "labels visible" |
|
35 | text: "labels visible" | |
36 | onClicked: series.labelsVisible = !series.labelsVisible; |
|
36 | onClicked: series.labelsVisible = !series.labelsVisible; | |
37 | } |
|
37 | } | |
38 | Button { |
|
38 | Button { | |
39 | text: "bar width +" |
|
39 | text: "bar width +" | |
40 | onClicked: series.barWidth += 0.1; |
|
40 | onClicked: series.barWidth += 0.1; | |
41 | } |
|
41 | } | |
42 | Button { |
|
42 | Button { | |
43 | text: "bar width -" |
|
43 | text: "bar width -" | |
44 | onClicked: series.barWidth -= 0.1; |
|
44 | onClicked: series.barWidth -= 0.1; | |
45 | } |
|
45 | } | |
46 | Button { |
|
46 | Button { | |
47 | text: "append set" |
|
47 | text: "append set" | |
48 | onClicked: { |
|
48 | onClicked: { | |
49 | var count = series.count; |
|
49 | var count = series.count; | |
50 | series.append("set" + count, [0, 0.1 * count, 0.2 * count, 0.3 * count, 0.4 * count, 0.5 * count, 0.6 * count]); |
|
50 | series.append("set" + count, [0, 0.1 * count, 0.2 * count, 0.3 * count, 0.4 * count, 0.5 * count, 0.6 * count]); | |
51 | } |
|
51 | } | |
52 | } |
|
52 | } | |
53 | Button { |
|
53 | Button { | |
54 | text: "insert set" |
|
54 | text: "insert set" | |
55 | onClicked: { |
|
55 | onClicked: { | |
56 | var count = series.count; |
|
56 | var count = series.count; | |
57 | series.insert(count - 1, "set" + count, [0, 0.1 * count, 0.2 * count, 0.3 * count, 0.4 * count, 0.5 * count, 0.6 * count]); |
|
57 | series.insert(count - 1, "set" + count, [0, 0.1 * count, 0.2 * count, 0.3 * count, 0.4 * count, 0.5 * count, 0.6 * count]); | |
58 | } |
|
58 | } | |
59 | } |
|
59 | } | |
60 | Button { |
|
60 | Button { | |
61 | text: "remove set" |
|
61 | text: "remove set" | |
62 | onClicked: series.remove(series.at(series.count - 1)); |
|
62 | onClicked: series.remove(series.at(series.count - 1)); | |
63 | } |
|
63 | } | |
64 | Button { |
|
64 | Button { | |
65 | text: "clear sets" |
|
65 | text: "clear sets" | |
66 | onClicked: series.clear(); |
|
66 | onClicked: series.clear(); | |
67 | } |
|
67 | } | |
|
68 | ||||
|
69 | Button { | |||
|
70 | text: "set 1 append" | |||
|
71 | onClicked: series.at(0).append(series.at(0).count + 1); | |||
|
72 | } | |||
|
73 | Button { | |||
|
74 | text: "set 1 replace" | |||
|
75 | onClicked: series.at(0).replace(series.at(0).count - 1, series.at(0).at(series.at(0).count - 1).y + 0.5); | |||
|
76 | } | |||
|
77 | Button { | |||
|
78 | text: "set 1 remove" | |||
|
79 | onClicked: series.at(0).remove(series.at(0).count - 1); | |||
|
80 | } | |||
|
81 | ||||
68 | Button { |
|
82 | Button { | |
69 | text: "set 1 color" |
|
83 | text: "set 1 color" | |
70 | onClicked: series.at(0).color = main.nextColor(); |
|
84 | onClicked: series.at(0).color = main.nextColor(); | |
71 | } |
|
85 | } | |
72 | Button { |
|
86 | Button { | |
73 | text: "set 1 border color" |
|
87 | text: "set 1 border color" | |
74 | onClicked: series.at(0).borderColor = main.nextColor(); |
|
88 | onClicked: series.at(0).borderColor = main.nextColor(); | |
75 | } |
|
89 | } | |
76 | Button { |
|
90 | Button { | |
77 | text: "set 1 label color" |
|
91 | text: "set 1 label color" | |
78 | onClicked: series.at(0).labelColor = main.nextColor(); |
|
92 | onClicked: series.at(0).labelColor = main.nextColor(); | |
79 | } |
|
93 | } | |
80 | Button { |
|
94 | Button { | |
81 | text: "set 1 font size +" |
|
95 | text: "set 1 font size +" | |
82 | onClicked: series.at(0).labelFont.pixelSize += 1; |
|
96 | onClicked: series.at(0).labelFont.pixelSize += 1; | |
83 | } |
|
97 | } | |
84 | Button { |
|
98 | Button { | |
85 | text: "set 1 font size -" |
|
99 | text: "set 1 font size -" | |
86 | onClicked: series.at(0).labelFont.pixelSize -= 1; |
|
100 | onClicked: series.at(0).labelFont.pixelSize -= 1; | |
87 | } |
|
101 | } | |
88 | } |
|
102 | } |
@@ -1,54 +1,62 | |||||
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 | ChartView { |
|
24 | ChartView { | |
25 | title: "Grouped bar series" |
|
25 | title: "Grouped bar series" | |
26 | anchors.fill: parent |
|
26 | anchors.fill: parent | |
27 | theme: ChartView.ChartThemeLight |
|
27 | theme: ChartView.ChartThemeLight | |
28 | legend.alignment: Qt.AlignBottom |
|
28 | legend.alignment: Qt.AlignBottom | |
29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] |
|
29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] | |
30 |
|
30 | |||
31 | property variant series: barSeries |
|
31 | property variant series: barSeries | |
32 |
|
32 | |||
33 | GroupedBarSeries { |
|
33 | GroupedBarSeries { | |
34 | id: barSeries |
|
34 | id: barSeries | |
35 | name: "bar" |
|
35 | name: "bar" | |
36 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] |
|
36 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] | |
37 | onClicked: console.log("barset.onClicked: " + index); |
|
37 | onClicked: console.log("barset.onClicked: " + index); | |
38 | onHovered: console.log("barset.onHovered: " + status); |
|
38 | onHovered: console.log("barset.onHovered: " + status); | |
|
39 | onPenChanged: console.log("barset.onPenChanged: " + pen); | |||
|
40 | onBrushChanged: console.log("barset.onBrushChanged: " + brush); | |||
|
41 | onLabelChanged: console.log("barset.onLabelChanged: " + label); | |||
|
42 | onLabelBrushChanged: console.log("barset.onLabelBrushChanged: " + labelBrush); | |||
|
43 | onLabelFontChanged: console.log("barset.onLabelFontChanged: " + labelFont); | |||
39 | onColorChanged: console.log("barset.onColorChanged: " + color); |
|
44 | onColorChanged: console.log("barset.onColorChanged: " + color); | |
40 | onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); |
|
45 | onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); | |
41 | onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); |
|
46 | onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); | |
42 | onCountChanged: console.log("barset.onCountChanged: " + count); |
|
47 | onCountChanged: console.log("barset.onCountChanged: " + count); | |
|
48 | onValuesAdded: console.log("barset.onValuesAdded: " + index + ", " + count); | |||
|
49 | onValuesRemoved: console.log("barset.onValuesRemoved: " + index + ", " + count); | |||
|
50 | onValueChanged: console.log("barset.onValuesChanged: " + index); | |||
43 | } |
|
51 | } | |
44 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
52 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
45 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
53 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
46 |
|
54 | |||
47 | onNameChanged: console.log("groupedBarSeries.onNameChanged: " + series.name); |
|
55 | onNameChanged: console.log("groupedBarSeries.onNameChanged: " + series.name); | |
48 | onVisibleChanged: console.log("groupedBarSeries.onVisibleChanged: " + series.visible); |
|
56 | onVisibleChanged: console.log("groupedBarSeries.onVisibleChanged: " + series.visible); | |
49 | onClicked: console.log("groupedBarSeries.onClicked: " + barset + " " + index); |
|
57 | onClicked: console.log("groupedBarSeries.onClicked: " + barset + " " + index); | |
50 | onHovered: console.log("groupedBarSeries.onHovered: " + barset + " " + status); |
|
58 | onHovered: console.log("groupedBarSeries.onHovered: " + barset + " " + status); | |
51 | onLabelsVisibleChanged: console.log("groupedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); |
|
59 | onLabelsVisibleChanged: console.log("groupedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); | |
52 | onCountChanged: console.log("groupedBarSeries.onCountChanged: " + count); |
|
60 | onCountChanged: console.log("groupedBarSeries.onCountChanged: " + count); | |
53 | } |
|
61 | } | |
54 | } |
|
62 | } |
@@ -1,54 +1,62 | |||||
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 | ChartView { |
|
24 | ChartView { | |
25 | title: "Percent bar series" |
|
25 | title: "Percent bar series" | |
26 | anchors.fill: parent |
|
26 | anchors.fill: parent | |
27 | theme: ChartView.ChartThemeLight |
|
27 | theme: ChartView.ChartThemeLight | |
28 | legend.alignment: Qt.AlignBottom |
|
28 | legend.alignment: Qt.AlignBottom | |
29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] |
|
29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] | |
30 |
|
30 | |||
31 | property variant series: barSeries |
|
31 | property variant series: barSeries | |
32 |
|
32 | |||
33 | PercentBarSeries { |
|
33 | PercentBarSeries { | |
34 | id: barSeries |
|
34 | id: barSeries | |
35 | name: "bar" |
|
35 | name: "bar" | |
36 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] |
|
36 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] | |
37 | onClicked: console.log("barset.onClicked: " + index); |
|
37 | onClicked: console.log("barset.onClicked: " + index); | |
38 | onHovered: console.log("barset.onHovered: " + status); |
|
38 | onHovered: console.log("barset.onHovered: " + status); | |
|
39 | onPenChanged: console.log("barset.onPenChanged: " + pen); | |||
|
40 | onBrushChanged: console.log("barset.onBrushChanged: " + brush); | |||
|
41 | onLabelChanged: console.log("barset.onLabelChanged: " + label); | |||
|
42 | onLabelBrushChanged: console.log("barset.onLabelBrushChanged: " + labelBrush); | |||
|
43 | onLabelFontChanged: console.log("barset.onLabelFontChanged: " + labelFont); | |||
39 | onColorChanged: console.log("barset.onColorChanged: " + color); |
|
44 | onColorChanged: console.log("barset.onColorChanged: " + color); | |
40 | onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); |
|
45 | onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); | |
41 | onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); |
|
46 | onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); | |
42 | onCountChanged: console.log("barset.onCountChanged: " + count); |
|
47 | onCountChanged: console.log("barset.onCountChanged: " + count); | |
|
48 | onValuesAdded: console.log("barset.onValuesAdded: " + index + ", " + count); | |||
|
49 | onValuesRemoved: console.log("barset.onValuesRemoved: " + index + ", " + count); | |||
|
50 | onValueChanged: console.log("barset.onValuesChanged: " + index); | |||
43 | } |
|
51 | } | |
44 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
52 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
45 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
53 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
46 |
|
54 | |||
47 | onNameChanged: console.log("percentBarSeries.onNameChanged: " + series.name); |
|
55 | onNameChanged: console.log("percentBarSeries.onNameChanged: " + series.name); | |
48 | onVisibleChanged: console.log("percentBarSeries.onVisibleChanged: " + series.visible); |
|
56 | onVisibleChanged: console.log("percentBarSeries.onVisibleChanged: " + series.visible); | |
49 | onClicked: console.log("percentBarSeries.onClicked: " + barset + " " + index); |
|
57 | onClicked: console.log("percentBarSeries.onClicked: " + barset + " " + index); | |
50 | onHovered: console.log("percentBarSeries.onHovered: " + barset + " " + status); |
|
58 | onHovered: console.log("percentBarSeries.onHovered: " + barset + " " + status); | |
51 | onLabelsVisibleChanged: console.log("percentBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); |
|
59 | onLabelsVisibleChanged: console.log("percentBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); | |
52 | onCountChanged: console.log("percentBarSeries.onCountChanged: " + count); |
|
60 | onCountChanged: console.log("percentBarSeries.onCountChanged: " + count); | |
53 | } |
|
61 | } | |
54 | } |
|
62 | } |
@@ -1,54 +1,62 | |||||
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 | ChartView { |
|
24 | ChartView { | |
25 | title: "Stacked bar series" |
|
25 | title: "Stacked bar series" | |
26 | anchors.fill: parent |
|
26 | anchors.fill: parent | |
27 | theme: ChartView.ChartThemeLight |
|
27 | theme: ChartView.ChartThemeLight | |
28 | legend.alignment: Qt.AlignBottom |
|
28 | legend.alignment: Qt.AlignBottom | |
29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] |
|
29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] | |
30 |
|
30 | |||
31 | property variant series: barSeries |
|
31 | property variant series: barSeries | |
32 |
|
32 | |||
33 | StackedBarSeries { |
|
33 | StackedBarSeries { | |
34 | id: barSeries |
|
34 | id: barSeries | |
35 | name: "bar" |
|
35 | name: "bar" | |
36 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] |
|
36 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] | |
37 | onClicked: console.log("barset.onClicked: " + index); |
|
37 | onClicked: console.log("barset.onClicked: " + index); | |
38 | onHovered: console.log("barset.onHovered: " + status); |
|
38 | onHovered: console.log("barset.onHovered: " + status); | |
|
39 | onPenChanged: console.log("barset.onPenChanged: " + pen); | |||
|
40 | onBrushChanged: console.log("barset.onBrushChanged: " + brush); | |||
|
41 | onLabelChanged: console.log("barset.onLabelChanged: " + label); | |||
|
42 | onLabelBrushChanged: console.log("barset.onLabelBrushChanged: " + labelBrush); | |||
|
43 | onLabelFontChanged: console.log("barset.onLabelFontChanged: " + labelFont); | |||
39 | onColorChanged: console.log("barset.onColorChanged: " + color); |
|
44 | onColorChanged: console.log("barset.onColorChanged: " + color); | |
40 | onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); |
|
45 | onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); | |
41 | onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); |
|
46 | onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); | |
42 | onCountChanged: console.log("barset.onCountChanged: " + count); |
|
47 | onCountChanged: console.log("barset.onCountChanged: " + count); | |
|
48 | onValuesAdded: console.log("barset.onValuesAdded: " + index + ", " + count); | |||
|
49 | onValuesRemoved: console.log("barset.onValuesRemoved: " + index + ", " + count); | |||
|
50 | onValueChanged: console.log("barset.onValuesChanged: " + index); | |||
43 | } |
|
51 | } | |
44 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
52 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
45 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
53 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
46 |
|
54 | |||
47 | onNameChanged: console.log("stackedBarSeries.onNameChanged: " + series.name); |
|
55 | onNameChanged: console.log("stackedBarSeries.onNameChanged: " + series.name); | |
48 | onVisibleChanged: console.log("stackedBarSeries.onVisibleChanged: " + series.visible); |
|
56 | onVisibleChanged: console.log("stackedBarSeries.onVisibleChanged: " + series.visible); | |
49 | onClicked: console.log("stackedBarSeries.onClicked: " + barset + " " + index); |
|
57 | onClicked: console.log("stackedBarSeries.onClicked: " + barset + " " + index); | |
50 | onHovered: console.log("stackedBarSeries.onHovered: " + barset + " " + status); |
|
58 | onHovered: console.log("stackedBarSeries.onHovered: " + barset + " " + status); | |
51 | onLabelsVisibleChanged: console.log("stackedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); |
|
59 | onLabelsVisibleChanged: console.log("stackedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); | |
52 | onCountChanged: console.log("stackedBarSeries.onCountChanged: " + count); |
|
60 | onCountChanged: console.log("stackedBarSeries.onCountChanged: " + count); | |
53 | } |
|
61 | } | |
54 | } |
|
62 | } |
General Comments 0
You need to be logged in to leave comments.
Login now