##// END OF EJS Templates
Property notifications: axis minmax, bar properties, xyseries p-visibl and count
Tero Ahola -
r1465:7735835ca38c
parent child
Show More
@@ -1,271 +1,244
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)));
33 connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int, int)));
34 }
35
36 void DeclarativeBarSet::handleCountChanged(int index, int count)
37 {
38 Q_UNUSED(index)
39 Q_UNUSED(count)
40 emit countChanged(QBarSet::count());
32 }
41 }
33
42
34 QVariantList DeclarativeBarSet::values()
43 QVariantList DeclarativeBarSet::values()
35 {
44 {
36 QVariantList values;
45 QVariantList values;
37 for (int i(0); i < count(); i++)
46 for (int i(0); i < count(); i++)
38 values.append(QVariant(at(i)));
47 values.append(QVariant(at(i)));
39 return values;
48 return values;
40 }
49 }
41
50
42 void DeclarativeBarSet::setValues(QVariantList values)
51 void DeclarativeBarSet::setValues(QVariantList values)
43 {
52 {
44 while (count())
53 while (count())
45 remove(count() - 1);
54 remove(count() - 1);
46
55
47 for (int i(0); i < values.count(); i++) {
56 for (int i(0); i < values.count(); i++) {
48 if (values.at(i).canConvert(QVariant::Double))
57 if (values.at(i).canConvert(QVariant::Double))
49 append(values[i].toDouble());
58 append(values[i].toDouble());
50 }
59 }
51 }
60 }
52
61
53 QColor DeclarativeBarSet::color()
54 {
55 return brush().color();
56 }
57
58 void DeclarativeBarSet::setColor(QColor color)
59 {
60 QBrush b = brush();
61 b.setColor(color);
62 setBrush(b);
63 }
64
65 QColor DeclarativeBarSet::borderColor()
66 {
67 return pen().color();
68 }
69
70 void DeclarativeBarSet::setBorderColor(QColor color)
71 {
72 QPen p = pen();
73 p.setColor(color);
74 setPen(p);
75 }
76
77 QColor DeclarativeBarSet::labelColor()
78 {
79 return labelBrush().color();
80 }
81
82 void DeclarativeBarSet::setLabelColor(QColor color)
83 {
84 QBrush b = labelBrush();
85 b.setColor(color);
86 setLabelBrush(b);
87 }
88
89 DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) :
62 DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) :
90 QBarSeries(parent)
63 QBarSeries(parent)
91 {
64 {
92 }
65 }
93
66
94 void DeclarativeBarSeries::classBegin()
67 void DeclarativeBarSeries::classBegin()
95 {
68 {
96 }
69 }
97
70
98 void DeclarativeBarSeries::componentComplete()
71 void DeclarativeBarSeries::componentComplete()
99 {
72 {
100 foreach(QObject *child, children()) {
73 foreach(QObject *child, children()) {
101 if (qobject_cast<DeclarativeBarSet *>(child)) {
74 if (qobject_cast<DeclarativeBarSet *>(child)) {
102 QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
75 QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
103 } else if(qobject_cast<QVBarModelMapper *>(child)) {
76 } else if(qobject_cast<QVBarModelMapper *>(child)) {
104 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
77 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
105 mapper->setSeries(this);
78 mapper->setSeries(this);
106 } else if(qobject_cast<QHBarModelMapper *>(child)) {
79 } else if(qobject_cast<QHBarModelMapper *>(child)) {
107 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
80 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
108 mapper->setSeries(this);
81 mapper->setSeries(this);
109 }
82 }
110 }
83 }
111 }
84 }
112
85
113 QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren()
86 QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren()
114 {
87 {
115 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
88 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
116 }
89 }
117
90
118 void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
91 void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
119 {
92 {
120 // Empty implementation; the children are parsed in componentComplete instead
93 // Empty implementation; the children are parsed in componentComplete instead
121 Q_UNUSED(list);
94 Q_UNUSED(list);
122 Q_UNUSED(element);
95 Q_UNUSED(element);
123 }
96 }
124
97
125 DeclarativeBarSet *DeclarativeBarSeries::at(int index)
98 DeclarativeBarSet *DeclarativeBarSeries::at(int index)
126 {
99 {
127 QList<QBarSet*> setList = barSets();
100 QList<QBarSet*> setList = barSets();
128 if (index < setList.count())
101 if (index < setList.count())
129 return qobject_cast<DeclarativeBarSet *>(setList[index]);
102 return qobject_cast<DeclarativeBarSet *>(setList[index]);
130
103
131 return 0;
104 return 0;
132 }
105 }
133
106
134 DeclarativeGroupedBarSeries::DeclarativeGroupedBarSeries(QDeclarativeItem *parent) :
107 DeclarativeGroupedBarSeries::DeclarativeGroupedBarSeries(QDeclarativeItem *parent) :
135 QGroupedBarSeries(parent)
108 QGroupedBarSeries(parent)
136 {
109 {
137 }
110 }
138
111
139 void DeclarativeGroupedBarSeries::classBegin()
112 void DeclarativeGroupedBarSeries::classBegin()
140 {
113 {
141 }
114 }
142
115
143 void DeclarativeGroupedBarSeries::componentComplete()
116 void DeclarativeGroupedBarSeries::componentComplete()
144 {
117 {
145 foreach(QObject *child, children()) {
118 foreach(QObject *child, children()) {
146 if (qobject_cast<DeclarativeBarSet *>(child)) {
119 if (qobject_cast<DeclarativeBarSet *>(child)) {
147 QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
120 QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
148 } else if(qobject_cast<QVBarModelMapper *>(child)) {
121 } else if(qobject_cast<QVBarModelMapper *>(child)) {
149 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
122 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
150 mapper->setSeries(this);
123 mapper->setSeries(this);
151 } else if(qobject_cast<QHBarModelMapper *>(child)) {
124 } else if(qobject_cast<QHBarModelMapper *>(child)) {
152 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
125 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
153 mapper->setSeries(this);
126 mapper->setSeries(this);
154 }
127 }
155 }
128 }
156 }
129 }
157
130
158 QDeclarativeListProperty<QObject> DeclarativeGroupedBarSeries::seriesChildren()
131 QDeclarativeListProperty<QObject> DeclarativeGroupedBarSeries::seriesChildren()
159 {
132 {
160 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
133 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
161 }
134 }
162
135
163 void DeclarativeGroupedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
136 void DeclarativeGroupedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
164 {
137 {
165 // Empty implementation; the children are parsed in componentComplete instead
138 // Empty implementation; the children are parsed in componentComplete instead
166 Q_UNUSED(list);
139 Q_UNUSED(list);
167 Q_UNUSED(element);
140 Q_UNUSED(element);
168 }
141 }
169
142
170 DeclarativeBarSet *DeclarativeGroupedBarSeries::at(int index)
143 DeclarativeBarSet *DeclarativeGroupedBarSeries::at(int index)
171 {
144 {
172 QList<QBarSet*> setList = barSets();
145 QList<QBarSet*> setList = barSets();
173 if (index < setList.count())
146 if (index < setList.count())
174 return qobject_cast<DeclarativeBarSet *>(setList[index]);
147 return qobject_cast<DeclarativeBarSet *>(setList[index]);
175
148
176 return 0;
149 return 0;
177 }
150 }
178
151
179 DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) :
152 DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) :
180 QStackedBarSeries(parent)
153 QStackedBarSeries(parent)
181 {
154 {
182 }
155 }
183
156
184 void DeclarativeStackedBarSeries::classBegin()
157 void DeclarativeStackedBarSeries::classBegin()
185 {
158 {
186 }
159 }
187
160
188 void DeclarativeStackedBarSeries::componentComplete()
161 void DeclarativeStackedBarSeries::componentComplete()
189 {
162 {
190 foreach(QObject *child, children()) {
163 foreach(QObject *child, children()) {
191 if (qobject_cast<DeclarativeBarSet *>(child)) {
164 if (qobject_cast<DeclarativeBarSet *>(child)) {
192 QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
165 QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
193 } else if(qobject_cast<QVBarModelMapper *>(child)) {
166 } else if(qobject_cast<QVBarModelMapper *>(child)) {
194 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
167 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
195 mapper->setSeries(this);
168 mapper->setSeries(this);
196 } else if(qobject_cast<QHBarModelMapper *>(child)) {
169 } else if(qobject_cast<QHBarModelMapper *>(child)) {
197 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
170 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
198 mapper->setSeries(this);
171 mapper->setSeries(this);
199 }
172 }
200 }
173 }
201 }
174 }
202
175
203 QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren()
176 QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren()
204 {
177 {
205 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
178 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
206 }
179 }
207
180
208 void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
181 void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
209 {
182 {
210 // Empty implementation; the children are parsed in componentComplete instead
183 // Empty implementation; the children are parsed in componentComplete instead
211 Q_UNUSED(list);
184 Q_UNUSED(list);
212 Q_UNUSED(element);
185 Q_UNUSED(element);
213 }
186 }
214
187
215 DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index)
188 DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index)
216 {
189 {
217 QList<QBarSet*> setList = barSets();
190 QList<QBarSet*> setList = barSets();
218 if (index < setList.count())
191 if (index < setList.count())
219 return qobject_cast<DeclarativeBarSet *>(setList[index]);
192 return qobject_cast<DeclarativeBarSet *>(setList[index]);
220
193
221 return 0;
194 return 0;
222 }
195 }
223
196
224 DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) :
197 DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) :
225 QPercentBarSeries(parent)
198 QPercentBarSeries(parent)
226 {
199 {
227 }
200 }
228
201
229 void DeclarativePercentBarSeries::classBegin()
202 void DeclarativePercentBarSeries::classBegin()
230 {
203 {
231 }
204 }
232
205
233 void DeclarativePercentBarSeries::componentComplete()
206 void DeclarativePercentBarSeries::componentComplete()
234 {
207 {
235 foreach(QObject *child, children()) {
208 foreach(QObject *child, children()) {
236 if (qobject_cast<DeclarativeBarSet *>(child)) {
209 if (qobject_cast<DeclarativeBarSet *>(child)) {
237 QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
210 QBarSeries::append(qobject_cast<DeclarativeBarSet *>(child));
238 } else if(qobject_cast<QVBarModelMapper *>(child)) {
211 } else if(qobject_cast<QVBarModelMapper *>(child)) {
239 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
212 QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child);
240 mapper->setSeries(this);
213 mapper->setSeries(this);
241 } else if(qobject_cast<QHBarModelMapper *>(child)) {
214 } else if(qobject_cast<QHBarModelMapper *>(child)) {
242 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
215 QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child);
243 mapper->setSeries(this);
216 mapper->setSeries(this);
244 }
217 }
245 }
218 }
246 }
219 }
247
220
248 QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren()
221 QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren()
249 {
222 {
250 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
223 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren);
251 }
224 }
252
225
253 void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
226 void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
254 {
227 {
255 // Empty implementation; the children are parsed in componentComplete instead
228 // Empty implementation; the children are parsed in componentComplete instead
256 Q_UNUSED(list);
229 Q_UNUSED(list);
257 Q_UNUSED(element);
230 Q_UNUSED(element);
258 }
231 }
259
232
260 DeclarativeBarSet *DeclarativePercentBarSeries::at(int index)
233 DeclarativeBarSet *DeclarativePercentBarSeries::at(int index)
261 {
234 {
262 QList<QBarSet*> setList = barSets();
235 QList<QBarSet*> setList = barSets();
263 if (index < setList.count())
236 if (index < setList.count())
264 return qobject_cast<DeclarativeBarSet *>(setList[index]);
237 return qobject_cast<DeclarativeBarSet *>(setList[index]);
265
238
266 return 0;
239 return 0;
267 }
240 }
268
241
269 #include "moc_declarativebarseries.cpp"
242 #include "moc_declarativebarseries.cpp"
270
243
271 QTCOMMERCIALCHART_END_NAMESPACE
244 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,142 +1,140
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(QColor color READ color WRITE setColor)
40 Q_PROPERTY(int count READ count NOTIFY countChanged)
41 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor)
42 Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor)
43
41
44 public:
42 public:
45 explicit DeclarativeBarSet(QObject *parent = 0);
43 explicit DeclarativeBarSet(QObject *parent = 0);
46 QVariantList values();
44 QVariantList values();
47 void setValues(QVariantList values);
45 void setValues(QVariantList values);
48 QColor color();
49 void setColor(QColor color);
50 QColor borderColor();
51 void setBorderColor(QColor color);
52 QColor labelColor();
53 void setLabelColor(QColor color);
54
46
55 public: // From QBarSet
47 public: // From QBarSet
56 Q_INVOKABLE void append(qreal value) { QBarSet::append(value); }
48 Q_INVOKABLE void append(qreal value) { QBarSet::append(value); }
57 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
51 Q_SIGNALS:
52 void countChanged(int count);
53
54 private Q_SLOTS:
55 void handleCountChanged(int index, int count);
58 };
56 };
59
57
60 class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus
58 class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus
61 {
59 {
62 Q_OBJECT
60 Q_OBJECT
63 Q_INTERFACES(QDeclarativeParserStatus)
61 Q_INTERFACES(QDeclarativeParserStatus)
64 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
62 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
65 Q_CLASSINFO("DefaultProperty", "seriesChildren")
63 Q_CLASSINFO("DefaultProperty", "seriesChildren")
66
64
67 public:
65 public:
68 explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0);
66 explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0);
69 QDeclarativeListProperty<QObject> seriesChildren();
67 QDeclarativeListProperty<QObject> seriesChildren();
70 Q_INVOKABLE DeclarativeBarSet *at(int index);
68 Q_INVOKABLE DeclarativeBarSet *at(int index);
71
69
72 public: // from QDeclarativeParserStatus
70 public: // from QDeclarativeParserStatus
73 void classBegin();
71 void classBegin();
74 void componentComplete();
72 void componentComplete();
75
73
76 public Q_SLOTS:
74 public Q_SLOTS:
77 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
75 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
78 };
76 };
79
77
80 class DeclarativeGroupedBarSeries : public QGroupedBarSeries, public QDeclarativeParserStatus
78 class DeclarativeGroupedBarSeries : public QGroupedBarSeries, public QDeclarativeParserStatus
81 {
79 {
82 Q_OBJECT
80 Q_OBJECT
83 Q_INTERFACES(QDeclarativeParserStatus)
81 Q_INTERFACES(QDeclarativeParserStatus)
84 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
82 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
85 Q_CLASSINFO("DefaultProperty", "seriesChildren")
83 Q_CLASSINFO("DefaultProperty", "seriesChildren")
86
84
87 public:
85 public:
88 explicit DeclarativeGroupedBarSeries(QDeclarativeItem *parent = 0);
86 explicit DeclarativeGroupedBarSeries(QDeclarativeItem *parent = 0);
89 QDeclarativeListProperty<QObject> seriesChildren();
87 QDeclarativeListProperty<QObject> seriesChildren();
90 Q_INVOKABLE DeclarativeBarSet *at(int index);
88 Q_INVOKABLE DeclarativeBarSet *at(int index);
91
89
92 public: // from QDeclarativeParserStatus
90 public: // from QDeclarativeParserStatus
93 void classBegin();
91 void classBegin();
94 void componentComplete();
92 void componentComplete();
95
93
96 public Q_SLOTS:
94 public Q_SLOTS:
97 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
95 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
98 };
96 };
99
97
100 class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus
98 class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus
101 {
99 {
102 Q_OBJECT
100 Q_OBJECT
103 Q_INTERFACES(QDeclarativeParserStatus)
101 Q_INTERFACES(QDeclarativeParserStatus)
104 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
102 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
105 Q_CLASSINFO("DefaultProperty", "seriesChildren")
103 Q_CLASSINFO("DefaultProperty", "seriesChildren")
106
104
107 public:
105 public:
108 explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0);
106 explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0);
109 QDeclarativeListProperty<QObject> seriesChildren();
107 QDeclarativeListProperty<QObject> seriesChildren();
110 Q_INVOKABLE DeclarativeBarSet *at(int index);
108 Q_INVOKABLE DeclarativeBarSet *at(int index);
111
109
112 public: // from QDeclarativeParserStatus
110 public: // from QDeclarativeParserStatus
113 void classBegin();
111 void classBegin();
114 void componentComplete();
112 void componentComplete();
115
113
116 public Q_SLOTS:
114 public Q_SLOTS:
117 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
115 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
118 };
116 };
119
117
120 class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus
118 class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus
121 {
119 {
122 Q_OBJECT
120 Q_OBJECT
123 Q_INTERFACES(QDeclarativeParserStatus)
121 Q_INTERFACES(QDeclarativeParserStatus)
124 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
122 Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren)
125 Q_CLASSINFO("DefaultProperty", "seriesChildren")
123 Q_CLASSINFO("DefaultProperty", "seriesChildren")
126
124
127 public:
125 public:
128 explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0);
126 explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0);
129 QDeclarativeListProperty<QObject> seriesChildren();
127 QDeclarativeListProperty<QObject> seriesChildren();
130 Q_INVOKABLE DeclarativeBarSet *at(int index);
128 Q_INVOKABLE DeclarativeBarSet *at(int index);
131
129
132 public: // from QDeclarativeParserStatus
130 public: // from QDeclarativeParserStatus
133 void classBegin();
131 void classBegin();
134 void componentComplete();
132 void componentComplete();
135
133
136 public Q_SLOTS:
134 public Q_SLOTS:
137 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
135 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
138 };
136 };
139
137
140 QTCOMMERCIALCHART_END_NAMESPACE
138 QTCOMMERCIALCHART_END_NAMESPACE
141
139
142 #endif // DECLARATIVEBARSERIES_H
140 #endif // DECLARATIVEBARSERIES_H
@@ -1,53 +1,60
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 "declarativelineseries.h"
21 #include "declarativelineseries.h"
22 #include "declarativechart.h"
22 #include "declarativechart.h"
23 #include "qchart.h"
23 #include "qchart.h"
24 #include "qlineseries.h"
24 #include "qlineseries.h"
25
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) :
28 DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) :
29 QLineSeries(parent)
29 QLineSeries(parent)
30 {
30 {
31 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
32 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
31 }
33 }
32
34
33 QXYSeries *DeclarativeLineSeries::xySeries()
35 QXYSeries *DeclarativeLineSeries::xySeries()
34 {
36 {
35 return this;
37 return this;
36 }
38 }
37
39
40 void DeclarativeLineSeries::handleCountChanged(int index)
41 {
42 Q_UNUSED(index)
43 emit countChanged(points().count());
44 }
45
38 QDeclarativeListProperty<QObject> DeclarativeLineSeries::declarativeChildren()
46 QDeclarativeListProperty<QObject> DeclarativeLineSeries::declarativeChildren()
39 {
47 {
40 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
48 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
41 }
49 }
42
50
43 void DeclarativeLineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
51 void DeclarativeLineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
44 {
52 {
45 QXYSeries *series = qobject_cast<QXYSeries*>(list->object);
53 Q_UNUSED(list)
46 DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element);
54 Q_UNUSED(element)
47 if (series && point)
55 // Empty implementation, childs are parsed in componentComplete
48 series->append(*point);
49 }
56 }
50
57
51 #include "moc_declarativelineseries.cpp"
58 #include "moc_declarativelineseries.cpp"
52
59
53 QTCOMMERCIALCHART_END_NAMESPACE
60 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,62 +1,67
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 DECLARATIVELINESERIES_H
21 #ifndef DECLARATIVELINESERIES_H
22 #define DECLARATIVELINESERIES_H
22 #define DECLARATIVELINESERIES_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include "qlineseries.h"
25 #include "qlineseries.h"
26 #include "declarativexyseries.h"
26 #include "declarativexyseries.h"
27 #include <QDeclarativeParserStatus>
27 #include <QDeclarativeParserStatus>
28 #include <QDeclarativeListProperty>
28 #include <QDeclarativeListProperty>
29 #include <QDeclarativeParserStatus>
29 #include <QDeclarativeParserStatus>
30
30
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32
32
33 class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus
33 class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus
34 {
34 {
35 Q_OBJECT
35 Q_OBJECT
36 Q_INTERFACES(QDeclarativeParserStatus)
36 Q_INTERFACES(QDeclarativeParserStatus)
37 Q_PROPERTY(QColor color READ penColor WRITE setPenColor)
37 Q_PROPERTY(QColor color READ penColor WRITE setPenColor)
38 Q_PROPERTY(int count READ count NOTIFY countChanged)
38 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
39 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
39 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
40 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
40
41
41 public:
42 public:
42 explicit DeclarativeLineSeries(QObject *parent = 0);
43 explicit DeclarativeLineSeries(QObject *parent = 0);
43 QXYSeries *xySeries();
44 QXYSeries *xySeries();
44 QDeclarativeListProperty<QObject> declarativeChildren();
45 QDeclarativeListProperty<QObject> declarativeChildren();
45
46
46 public: // from QDeclarativeParserStatus
47 public: // from QDeclarativeParserStatus
47 void classBegin() { DeclarativeXySeries::classBegin(); }
48 void classBegin() { DeclarativeXySeries::classBegin(); }
48 void componentComplete() { DeclarativeXySeries::componentComplete(); }
49 void componentComplete() { DeclarativeXySeries::componentComplete(); }
49
50
50 public: // from QLineSeries
51 public: // from QLineSeries
51 Q_INVOKABLE void append(qreal x, qreal y) { QLineSeries::append(x, y); }
52 Q_INVOKABLE void append(qreal x, qreal y) { QLineSeries::append(x, y); }
52 Q_INVOKABLE void remove(qreal x, qreal y) { QLineSeries::remove(x, y); }
53 Q_INVOKABLE void remove(qreal x, qreal y) { QLineSeries::remove(x, y); }
53 Q_INVOKABLE void clear() { QLineSeries::clear(); }
54 Q_INVOKABLE void clear() { QLineSeries::clear(); }
54 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
55 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
55
56
57 Q_SIGNALS:
58 void countChanged(int count);
59
56 public Q_SLOTS:
60 public Q_SLOTS:
57 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
61 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
62 void handleCountChanged(int index);
58 };
63 };
59
64
60 QTCOMMERCIALCHART_END_NAMESPACE
65 QTCOMMERCIALCHART_END_NAMESPACE
61
66
62 #endif // DECLARATIVELINESERIES_H
67 #endif // DECLARATIVELINESERIES_H
@@ -1,65 +1,72
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 "declarativescatterseries.h"
21 #include "declarativescatterseries.h"
22 #include "declarativechart.h"
22 #include "declarativechart.h"
23 #include "qchart.h"
23 #include "qchart.h"
24 #include "qscatterseries.h"
24 #include "qscatterseries.h"
25
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) :
28 DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) :
29 QScatterSeries(parent)
29 QScatterSeries(parent)
30 {
30 {
31 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
32 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
31 }
33 }
32
34
33 QXYSeries *DeclarativeScatterSeries::xySeries()
35 QXYSeries *DeclarativeScatterSeries::xySeries()
34 {
36 {
35 return this;
37 return this;
36 }
38 }
37
39
40 void DeclarativeScatterSeries::handleCountChanged(int index)
41 {
42 Q_UNUSED(index)
43 emit countChanged(QScatterSeries::count());
44 }
45
38 QDeclarativeListProperty<QObject> DeclarativeScatterSeries::declarativeChildren()
46 QDeclarativeListProperty<QObject> DeclarativeScatterSeries::declarativeChildren()
39 {
47 {
40 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
48 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
41 }
49 }
42
50
43 void DeclarativeScatterSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
51 void DeclarativeScatterSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
44 {
52 {
45 QXYSeries *series = qobject_cast<QXYSeries*>(list->object);
53 Q_UNUSED(list)
46 DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element);
54 Q_UNUSED(element)
47 if (series && point)
55 // Empty implementation, childs are parsed in componentComplete
48 series->append(*point);
49 }
56 }
50
57
51 QColor DeclarativeScatterSeries::brushColor()
58 QColor DeclarativeScatterSeries::brushColor()
52 {
59 {
53 return brush().color();
60 return brush().color();
54 }
61 }
55
62
56 void DeclarativeScatterSeries::setBrushColor(QColor color)
63 void DeclarativeScatterSeries::setBrushColor(QColor color)
57 {
64 {
58 QBrush b = brush();
65 QBrush b = brush();
59 b.setColor(color);
66 b.setColor(color);
60 setBrush(b);
67 setBrush(b);
61 }
68 }
62
69
63 #include "moc_declarativescatterseries.cpp"
70 #include "moc_declarativescatterseries.cpp"
64
71
65 QTCOMMERCIALCHART_END_NAMESPACE
72 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,64 +1,69
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 DECLARATIVESCATTERSERIES_H
21 #ifndef DECLARATIVESCATTERSERIES_H
22 #define DECLARATIVESCATTERSERIES_H
22 #define DECLARATIVESCATTERSERIES_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include "qscatterseries.h"
25 #include "qscatterseries.h"
26 #include "declarativexyseries.h"
26 #include "declarativexyseries.h"
27 #include <QDeclarativeListProperty>
27 #include <QDeclarativeListProperty>
28 #include <QDeclarativeParserStatus>
28 #include <QDeclarativeParserStatus>
29
29
30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31
31
32 class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries, public QDeclarativeParserStatus
32 class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries, public QDeclarativeParserStatus
33 {
33 {
34 Q_OBJECT
34 Q_OBJECT
35 Q_INTERFACES(QDeclarativeParserStatus)
35 Q_INTERFACES(QDeclarativeParserStatus)
36 Q_PROPERTY(QColor color READ brushColor WRITE setBrushColor)
36 Q_PROPERTY(QColor color READ brushColor WRITE setBrushColor)
37 Q_PROPERTY(QColor borderColor READ penColor WRITE setPenColor)
37 Q_PROPERTY(QColor borderColor READ penColor WRITE setPenColor)
38 Q_PROPERTY(int count READ count NOTIFY countChanged)
38 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
39 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
39 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
40 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
40
41
41 public:
42 public:
42 explicit DeclarativeScatterSeries(QObject *parent = 0);
43 explicit DeclarativeScatterSeries(QObject *parent = 0);
43 QXYSeries *xySeries();
44 QXYSeries *xySeries();
44 QDeclarativeListProperty<QObject> declarativeChildren();
45 QDeclarativeListProperty<QObject> declarativeChildren();
45 QColor brushColor();
46 QColor brushColor();
46 void setBrushColor(QColor color);
47 void setBrushColor(QColor color);
47
48
48 public: // from QDeclarativeParserStatus
49 public: // from QDeclarativeParserStatus
49 void classBegin() { DeclarativeXySeries::classBegin(); }
50 void classBegin() { DeclarativeXySeries::classBegin(); }
50 void componentComplete() { DeclarativeXySeries::componentComplete(); }
51 void componentComplete() { DeclarativeXySeries::componentComplete(); }
51
52
52 public: // from QScatterSeries
53 public: // from QScatterSeries
53 Q_INVOKABLE void append(qreal x, qreal y) { QScatterSeries::append(x, y); }
54 Q_INVOKABLE void append(qreal x, qreal y) { QScatterSeries::append(x, y); }
54 Q_INVOKABLE void remove(qreal x, qreal y) { QScatterSeries::remove(x, y); }
55 Q_INVOKABLE void remove(qreal x, qreal y) { QScatterSeries::remove(x, y); }
55 Q_INVOKABLE void clear() { QScatterSeries::clear(); }
56 Q_INVOKABLE void clear() { QScatterSeries::clear(); }
56 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
57 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
57
58
59 Q_SIGNALS:
60 void countChanged(int count);
61
58 public Q_SLOTS:
62 public Q_SLOTS:
59 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
63 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
64 void handleCountChanged(int index);
60 };
65 };
61
66
62 QTCOMMERCIALCHART_END_NAMESPACE
67 QTCOMMERCIALCHART_END_NAMESPACE
63
68
64 #endif // DECLARATIVESCATTERSERIES_H
69 #endif // DECLARATIVESCATTERSERIES_H
@@ -1,53 +1,60
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 "declarativesplineseries.h"
21 #include "declarativesplineseries.h"
22 #include "declarativechart.h"
22 #include "declarativechart.h"
23 #include <QChart>
23 #include <QChart>
24 #include "declarativexypoint.h"
24 #include "declarativexypoint.h"
25
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) :
28 DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) :
29 QSplineSeries(parent)
29 QSplineSeries(parent)
30 {
30 {
31 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
32 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
31 }
33 }
32
34
33 QXYSeries *DeclarativeSplineSeries::xySeries()
35 QXYSeries *DeclarativeSplineSeries::xySeries()
34 {
36 {
35 return this;
37 return this;
36 }
38 }
37
39
40 void DeclarativeSplineSeries::handleCountChanged(int index)
41 {
42 Q_UNUSED(index)
43 emit countChanged(points().count());
44 }
45
38 QDeclarativeListProperty<QObject> DeclarativeSplineSeries::declarativeChildren()
46 QDeclarativeListProperty<QObject> DeclarativeSplineSeries::declarativeChildren()
39 {
47 {
40 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
48 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
41 }
49 }
42
50
43 void DeclarativeSplineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
51 void DeclarativeSplineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
44 {
52 {
45 QXYSeries *series = qobject_cast<QXYSeries*>(list->object);
53 Q_UNUSED(list)
46 DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(element);
54 Q_UNUSED(element)
47 if (series && point)
55 // Empty implementation, childs are parsed in componentComplete
48 series->append(*point);
49 }
56 }
50
57
51 #include "moc_declarativesplineseries.cpp"
58 #include "moc_declarativesplineseries.cpp"
52
59
53 QTCOMMERCIALCHART_END_NAMESPACE
60 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,62 +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 #ifndef DECLARATIVESPLINESERIES_H
21 #ifndef DECLARATIVESPLINESERIES_H
22 #define DECLARATIVESPLINESERIES_H
22 #define DECLARATIVESPLINESERIES_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include "qsplineseries.h"
25 #include "qsplineseries.h"
26 #include "declarativexyseries.h"
26 #include "declarativexyseries.h"
27 #include <QDeclarativeParserStatus>
27 #include <QDeclarativeParserStatus>
28 #include <QDeclarativeListProperty>
28 #include <QDeclarativeListProperty>
29 #include <QDeclarativeParserStatus>
29 #include <QDeclarativeParserStatus>
30
30
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32
32
33 class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus
33 class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus
34 {
34 {
35 Q_OBJECT
35 Q_OBJECT
36 Q_INTERFACES(QDeclarativeParserStatus)
36 Q_INTERFACES(QDeclarativeParserStatus)
37 Q_PROPERTY(QColor color READ penColor WRITE setPenColor)
37 Q_PROPERTY(QColor color READ penColor WRITE setPenColor)
38 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
38 Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren)
39 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
39 Q_CLASSINFO("DefaultProperty", "declarativeChildren")
40
40
41 public:
41 public:
42 explicit DeclarativeSplineSeries(QObject *parent = 0);
42 explicit DeclarativeSplineSeries(QObject *parent = 0);
43 QXYSeries *xySeries();
43 QXYSeries *xySeries();
44 QDeclarativeListProperty<QObject> declarativeChildren();
44 QDeclarativeListProperty<QObject> declarativeChildren();
45
45
46 public: // from QDeclarativeParserStatus
46 public: // from QDeclarativeParserStatus
47 void classBegin() { DeclarativeXySeries::classBegin(); }
47 void classBegin() { DeclarativeXySeries::classBegin(); }
48 void componentComplete() { DeclarativeXySeries::componentComplete(); }
48 void componentComplete() { DeclarativeXySeries::componentComplete(); }
49
49
50 public: // from QSplineSeries
50 public: // from QSplineSeries
51 Q_INVOKABLE void append(qreal x, qreal y) { QSplineSeries::append(x, y); }
51 Q_INVOKABLE void append(qreal x, qreal y) { QSplineSeries::append(x, y); }
52 Q_INVOKABLE void remove(qreal x, qreal y) { QSplineSeries::remove(x, y); }
52 Q_INVOKABLE void remove(qreal x, qreal y) { QSplineSeries::remove(x, y); }
53 Q_INVOKABLE void clear() { QSplineSeries::clear(); }
53 Q_INVOKABLE void clear() { QSplineSeries::clear(); }
54 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
54 Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); }
55
55
56 Q_SIGNALS:
57 void countChanged(int count);
58
56 public Q_SLOTS:
59 public Q_SLOTS:
57 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
60 static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
61 void handleCountChanged(int index);
58 };
62 };
59
63
60 QTCOMMERCIALCHART_END_NAMESPACE
64 QTCOMMERCIALCHART_END_NAMESPACE
61
65
62 #endif // DECLARATIVESPLINESERIES_H
66 #endif // DECLARATIVESPLINESERIES_H
@@ -1,94 +1,94
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 "DeclarativeXySeries.h"
21 //#include "DeclarativeXySeries.h"
22 #include "declarativexyseries.h"
22 #include "declarativexyseries.h"
23 #include "declarativechart.h"
23 #include "declarativechart.h"
24 #include <QXYSeries>
24 #include <QXYSeries>
25 #include <QVXYModelMapper>
25 #include <QVXYModelMapper>
26 #include <QHXYModelMapper>
26 #include <QHXYModelMapper>
27 #include <QDeclarativeListProperty>
27 #include <QDeclarativeListProperty>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
30
31 DeclarativeXySeries::DeclarativeXySeries()
31 DeclarativeXySeries::DeclarativeXySeries()
32 {
32 {
33 }
33 }
34
34
35 DeclarativeXySeries::~DeclarativeXySeries()
35 DeclarativeXySeries::~DeclarativeXySeries()
36 {
36 {
37 }
37 }
38
38
39 void DeclarativeXySeries::classBegin()
39 void DeclarativeXySeries::classBegin()
40 {
40 {
41 }
41 }
42
42
43 void DeclarativeXySeries::componentComplete()
43 void DeclarativeXySeries::componentComplete()
44 {
44 {
45 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
45 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
46 Q_ASSERT(series);
46 Q_ASSERT(series);
47
47
48 foreach(QObject *child, series->children()) {
48 foreach(QObject *child, series->children()) {
49 if (qobject_cast<DeclarativeXyPoint *>(child)) {
49 if (qobject_cast<DeclarativeXyPoint *>(child)) {
50 // TODO:
50 DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(child);
51 // series->append(qobject_cast<DeclarativeXyPoint *>(child));
51 series->append(point->x(), point->y());
52 } else if(qobject_cast<QVXYModelMapper *>(child)) {
52 } else if(qobject_cast<QVXYModelMapper *>(child)) {
53 QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child);
53 QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child);
54 mapper->setSeries(series);
54 mapper->setSeries(series);
55 } else if(qobject_cast<QHXYModelMapper *>(child)) {
55 } else if(qobject_cast<QHXYModelMapper *>(child)) {
56 QHXYModelMapper *mapper = qobject_cast<QHXYModelMapper *>(child);
56 QHXYModelMapper *mapper = qobject_cast<QHXYModelMapper *>(child);
57 mapper->setSeries(series);
57 mapper->setSeries(series);
58 }
58 }
59 }
59 }
60 }
60 }
61
61
62 QColor DeclarativeXySeries::penColor()
62 QColor DeclarativeXySeries::penColor()
63 {
63 {
64 // All the inherited objects must be of type QXYSeries, so it is safe to cast
64 // All the inherited objects must be of type QXYSeries, so it is safe to cast
65 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
65 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
66 Q_ASSERT(series);
66 Q_ASSERT(series);
67 return series->pen().color();
67 return series->pen().color();
68 }
68 }
69
69
70 void DeclarativeXySeries::setPenColor(QColor color)
70 void DeclarativeXySeries::setPenColor(QColor color)
71 {
71 {
72 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
72 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
73 Q_ASSERT(series);
73 Q_ASSERT(series);
74 QPen pen = series->pen();
74 QPen pen = series->pen();
75 pen.setColor(color);
75 pen.setColor(color);
76 series->setPen(pen);
76 series->setPen(pen);
77 }
77 }
78
78
79 DeclarativeXyPoint *DeclarativeXySeries::at(int index)
79 DeclarativeXyPoint *DeclarativeXySeries::at(int index)
80 {
80 {
81 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
81 QXYSeries *series = qobject_cast<QXYSeries *>(xySeries());
82 Q_ASSERT(series);
82 Q_ASSERT(series);
83 if (index < series->count()) {
83 if (index < series->count()) {
84 QPointF point = series->points().at(index);
84 QPointF point = series->points().at(index);
85 DeclarativeXyPoint *xyPoint = new DeclarativeXyPoint(series);
85 DeclarativeXyPoint *xyPoint = new DeclarativeXyPoint(series);
86 xyPoint->setX(point.x());
86 xyPoint->setX(point.x());
87 xyPoint->setY(point.y());
87 xyPoint->setY(point.y());
88 return xyPoint;
88 return xyPoint;
89 }
89 }
90 return 0;
90 return 0;
91 }
91 }
92
92
93
93
94 QTCOMMERCIALCHART_END_NAMESPACE
94 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,101 +1,103
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 "qaxiscategories.h"
24 #include "qaxiscategories.h"
25 #include "declarativechart.h"
25 #include "declarativechart.h"
26 #include "declarativexypoint.h"
26 #include "declarativexypoint.h"
27 #include "declarativelineseries.h"
27 #include "declarativelineseries.h"
28 #include "declarativesplineseries.h"
28 #include "declarativesplineseries.h"
29 #include "declarativeareaseries.h"
29 #include "declarativeareaseries.h"
30 #include "declarativescatterseries.h"
30 #include "declarativescatterseries.h"
31 #include "declarativebarseries.h"
31 #include "declarativebarseries.h"
32 #include "declarativepieseries.h"
32 #include "declarativepieseries.h"
33 #include <QVXYModelMapper>
33 #include <QVXYModelMapper>
34 #include <QHXYModelMapper>
34 #include <QHXYModelMapper>
35 #include <QHPieModelMapper>
35 #include <QHPieModelMapper>
36 #include <QVPieModelMapper>
36 #include <QVPieModelMapper>
37 #include <QHBarModelMapper>
37 #include <QHBarModelMapper>
38 #include <QVBarModelMapper>
38 #include <QVBarModelMapper>
39
39
40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
41
41
42 class ChartQmlPlugin : public QDeclarativeExtensionPlugin
42 class ChartQmlPlugin : public QDeclarativeExtensionPlugin
43 {
43 {
44 Q_OBJECT
44 Q_OBJECT
45 public:
45 public:
46 virtual void registerTypes(const char *uri)
46 virtual void registerTypes(const char *uri)
47 {
47 {
48 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
48 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
49
49
50 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView");
50 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView");
51 qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint");
51 qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint");
52 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
52 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
53 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
53 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
54 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
54 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
55 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
55 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
56 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
56 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
57 qmlRegisterType<DeclarativeGroupedBarSeries>(uri, 1, 0, "GroupedBarSeries");
57 qmlRegisterType<DeclarativeGroupedBarSeries>(uri, 1, 0, "GroupedBarSeries");
58 qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries");
58 qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries");
59 qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries");
59 qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries");
60 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
60 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
61 qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice");
61 qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice");
62 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
62 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
63 qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper");
63 qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper");
64 qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper");
64 qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper");
65 qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper");
65 qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper");
66 qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper");
66 qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper");
67 qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper");
67 qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper");
68 qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper");
68 qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper");
69
69
70 qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend",
70 qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend",
71 QLatin1String("Trying to create uncreatable: Legend."));
71 QLatin1String("Trying to create uncreatable: Legend."));
72 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "QXYSeries",
73 QLatin1String("Trying to create uncreatable: QXYSeries."));
72 qmlRegisterUncreatableType<QScatterSeries>(uri, 1, 0, "QScatterSeries",
74 qmlRegisterUncreatableType<QScatterSeries>(uri, 1, 0, "QScatterSeries",
73 QLatin1String("Trying to create uncreatable: QScatterSeries."));
75 QLatin1String("Trying to create uncreatable: QScatterSeries."));
74 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
76 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
75 QLatin1String("Trying to create uncreatable: QPieSeries."));
77 QLatin1String("Trying to create uncreatable: QPieSeries."));
76 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
78 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
77 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
79 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
78 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
80 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
79 QLatin1String("Trying to create uncreatable: XYModelMapper."));
81 QLatin1String("Trying to create uncreatable: XYModelMapper."));
80 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
82 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
81 QLatin1String("Trying to create uncreatable: PieModelMapper."));
83 QLatin1String("Trying to create uncreatable: PieModelMapper."));
82 qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper",
84 qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper",
83 QLatin1String("Trying to create uncreatable: BarModelMapper."));
85 QLatin1String("Trying to create uncreatable: BarModelMapper."));
84 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries",
86 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries",
85 QLatin1String("Trying to create uncreatable: AbstractSeries."));
87 QLatin1String("Trying to create uncreatable: AbstractSeries."));
86 qmlRegisterUncreatableType<QAxis>(uri, 1, 0, "Axis",
88 qmlRegisterUncreatableType<QAxis>(uri, 1, 0, "Axis",
87 QLatin1String("Trying to create uncreatable: Axis."));
89 QLatin1String("Trying to create uncreatable: Axis."));
88 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
90 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
89 QLatin1String("Trying to create uncreatable: PieModelMapper."));
91 QLatin1String("Trying to create uncreatable: PieModelMapper."));
90 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
92 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
91 QLatin1String("Trying to create uncreatable: XYModelMapper."));
93 QLatin1String("Trying to create uncreatable: XYModelMapper."));
92 }
94 }
93 };
95 };
94
96
95 #include "plugin.moc"
97 #include "plugin.moc"
96
98
97 QTCOMMERCIALCHART_END_NAMESPACE
99 QTCOMMERCIALCHART_END_NAMESPACE
98
100
99 QTCOMMERCIALCHART_USE_NAMESPACE
101 QTCOMMERCIALCHART_USE_NAMESPACE
100
102
101 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
103 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
@@ -1,138 +1,138
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 QAXIS_H
21 #ifndef QAXIS_H
22 #define QAXIS_H
22 #define QAXIS_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <qaxiscategories.h>
25 #include <qaxiscategories.h>
26 #include <QPen>
26 #include <QPen>
27 #include <QFont>
27 #include <QFont>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
30
31 class QAxisPrivate;
31 class QAxisPrivate;
32
32
33 class QTCOMMERCIALCHART_EXPORT QAxis : public QObject
33 class QTCOMMERCIALCHART_EXPORT QAxis : public QObject
34 {
34 {
35 Q_OBJECT
35 Q_OBJECT
36 Q_PROPERTY(bool visible READ isAxisVisible WRITE setAxisVisible NOTIFY visibleChanged)
36 Q_PROPERTY(bool visible READ isAxisVisible WRITE setAxisVisible NOTIFY visibleChanged)
37 Q_PROPERTY(QColor color READ axisPenColor WRITE setAxisPenColor NOTIFY colorChanged)
37 Q_PROPERTY(QColor color READ axisPenColor WRITE setAxisPenColor NOTIFY colorChanged)
38 Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
38 Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
39 Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged)
39 Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged)
40 Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged)
40 Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged)
41 Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged)
41 Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged)
42 Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged)
42 Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged)
43 Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged)
43 Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged)
44 Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged)
44 Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged)
45 Q_PROPERTY(qreal min READ min WRITE setMin)
45 Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged)
46 Q_PROPERTY(qreal max READ max WRITE setMax)
46 Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged)
47 Q_PROPERTY(int ticksCount READ ticksCount WRITE setTicksCount NOTIFY ticksCountChanged)
47 Q_PROPERTY(int ticksCount READ ticksCount WRITE setTicksCount NOTIFY ticksCountChanged)
48 Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled NOTIFY niceNumbersEnabledChanged)
48 Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled NOTIFY niceNumbersEnabledChanged)
49
49
50 public:
50 public:
51
51
52 QAxis(QObject *parent =0);
52 QAxis(QObject *parent =0);
53 ~QAxis();
53 ~QAxis();
54
54
55 //axis handling
55 //axis handling
56 bool isAxisVisible() const;
56 bool isAxisVisible() const;
57 void setAxisVisible(bool visible = true);
57 void setAxisVisible(bool visible = true);
58 void setAxisPen(const QPen &pen);
58 void setAxisPen(const QPen &pen);
59 QPen axisPen() const;
59 QPen axisPen() const;
60 void setAxisPenColor(QColor color);
60 void setAxisPenColor(QColor color);
61 QColor axisPenColor() const;
61 QColor axisPenColor() const;
62
62
63 //grid handling
63 //grid handling
64 bool isGridLineVisible() const;
64 bool isGridLineVisible() const;
65 void setGridLineVisible(bool visible = true);
65 void setGridLineVisible(bool visible = true);
66 void setGridLinePen(const QPen &pen);
66 void setGridLinePen(const QPen &pen);
67 QPen gridLinePen() const;
67 QPen gridLinePen() const;
68
68
69 //labels handling
69 //labels handling
70 bool labelsVisible() const;
70 bool labelsVisible() const;
71 void setLabelsVisible(bool visible = true);
71 void setLabelsVisible(bool visible = true);
72 void setLabelsPen(const QPen &pen);
72 void setLabelsPen(const QPen &pen);
73 QPen labelsPen() const;
73 QPen labelsPen() const;
74 void setLabelsBrush(const QBrush &brush);
74 void setLabelsBrush(const QBrush &brush);
75 QBrush labelsBrush() const;
75 QBrush labelsBrush() const;
76 void setLabelsFont(const QFont &font);
76 void setLabelsFont(const QFont &font);
77 QFont labelsFont() const;
77 QFont labelsFont() const;
78 void setLabelsAngle(int angle);
78 void setLabelsAngle(int angle);
79 int labelsAngle() const;
79 int labelsAngle() const;
80 void setLabelsColor(QColor color);
80 void setLabelsColor(QColor color);
81 QColor labelsColor() const;
81 QColor labelsColor() const;
82
82
83 //shades handling
83 //shades handling
84 bool shadesVisible() const;
84 bool shadesVisible() const;
85 void setShadesVisible(bool visible = true);
85 void setShadesVisible(bool visible = true);
86 void setShadesPen(const QPen &pen);
86 void setShadesPen(const QPen &pen);
87 QPen shadesPen() const;
87 QPen shadesPen() const;
88 void setShadesBrush(const QBrush &brush);
88 void setShadesBrush(const QBrush &brush);
89 QBrush shadesBrush() const;
89 QBrush shadesBrush() const;
90 void setShadesColor(QColor color);
90 void setShadesColor(QColor color);
91 QColor shadesColor() const;
91 QColor shadesColor() const;
92 void setShadesBorderColor(QColor color);
92 void setShadesBorderColor(QColor color);
93 QColor shadesBorderColor() const;
93 QColor shadesBorderColor() const;
94
94
95 //range handling
95 //range handling
96 void setMin(qreal min);
96 void setMin(qreal min);
97 qreal min() const;
97 qreal min() const;
98 void setMax(qreal max);
98 void setMax(qreal max);
99 qreal max() const;
99 qreal max() const;
100 void setRange(qreal min, qreal max);
100 void setRange(qreal min, qreal max);
101
101
102 //ticks handling
102 //ticks handling
103 void setTicksCount(int count);
103 void setTicksCount(int count);
104 int ticksCount() const;
104 int ticksCount() const;
105
105
106 void setNiceNumbersEnabled(bool enable = true);
106 void setNiceNumbersEnabled(bool enable = true);
107 bool niceNumbersEnabled() const;
107 bool niceNumbersEnabled() const;
108
108
109 QAxisCategories* categories();
109 QAxisCategories* categories();
110
110
111 void show();
111 void show();
112 void hide();
112 void hide();
113
113
114 Q_SIGNALS:
114 Q_SIGNALS:
115 void visibleChanged(bool visible);
115 void visibleChanged(bool visible);
116 void labelsVisibleChanged(bool visible);
116 void labelsVisibleChanged(bool visible);
117 void gridVisibleChanged(bool visible);
117 void gridVisibleChanged(bool visible);
118 void minChanged(qreal min);
119 void maxChanged(qreal max);
120 void rangeChanged(qreal min, qreal max);
118 void rangeChanged(qreal min, qreal max);
121 void colorChanged(QColor color);
119 void colorChanged(QColor color);
122 void labelsColorChanged(QColor color);
120 void labelsColorChanged(QColor color);
123 void labelsAngleChanged(int angle);
121 void labelsAngleChanged(int angle);
124 void shadesVisibleChanged(bool visible);
122 void shadesVisibleChanged(bool visible);
125 void shadesColorChanged(QColor color);
123 void shadesColorChanged(QColor color);
126 void shadesBorderColorChanged(QColor color);
124 void shadesBorderColorChanged(QColor color);
125 void minChanged(qreal min);
126 void maxChanged(qreal max);
127 void ticksCountChanged(int count);
127 void ticksCountChanged(int count);
128 void niceNumbersEnabledChanged(bool enabled);
128 void niceNumbersEnabledChanged(bool enabled);
129
129
130 private:
130 private:
131 QScopedPointer<QAxisPrivate> d_ptr;
131 QScopedPointer<QAxisPrivate> d_ptr;
132 Q_DISABLE_COPY(QAxis)
132 Q_DISABLE_COPY(QAxis)
133 friend class ChartDataSet;
133 friend class ChartDataSet;
134 friend class ChartAxis;
134 friend class ChartAxis;
135 };
135 };
136
136
137 QTCOMMERCIALCHART_END_NAMESPACE
137 QTCOMMERCIALCHART_END_NAMESPACE
138 #endif /* QCHARTAXIS_H_ */
138 #endif /* QCHARTAXIS_H_ */
@@ -1,701 +1,688
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 "qbarseries.h"
21 #include "qbarseries.h"
22 #include "qbarseries_p.h"
22 #include "qbarseries_p.h"
23 #include "qbarset.h"
23 #include "qbarset.h"
24 #include "qbarset_p.h"
24 #include "qbarset_p.h"
25 #include "domain_p.h"
25 #include "domain_p.h"
26 #include "legendmarker_p.h"
26 #include "legendmarker_p.h"
27 #include "chartdataset_p.h"
27 #include "chartdataset_p.h"
28 #include "charttheme_p.h"
28 #include "charttheme_p.h"
29 #include "chartanimator_p.h"
29 #include "chartanimator_p.h"
30
30
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32
32
33 /*!
33 /*!
34 \class QBarSeries
34 \class QBarSeries
35 \brief part of QtCommercial chart API.
35 \brief part of QtCommercial chart API.
36 \mainclass
36 \mainclass
37
37
38 QBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars to
38 QBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars to
39 the position defined by data. Single bar is defined by QPointF, where x value is the x-coordinate of the bar
39 the position defined by data. Single bar is defined by QPointF, where x value is the x-coordinate of the bar
40 and y-value is the height of the bar. The category names are ignored with this series and x-axis
40 and y-value is the height of the bar. The category names are ignored with this series and x-axis
41 shows the x-values.
41 shows the x-values.
42
42
43 See the \l {BarChart Example} {bar chart example} to learn how to create a simple bar chart.
43 See the \l {BarChart Example} {bar chart example} to learn how to create a simple bar chart.
44 \image examples_barchart.png
44 \image examples_barchart.png
45
45
46 \sa QBarSet, QStackedBarSeries, QPercentBarSeries
46 \sa QBarSet, QStackedBarSeries, QPercentBarSeries
47 */
47 */
48
48
49 /*!
49 /*!
50 \property QBarSeries::barWidth
50 \property QBarSeries::barWidth
51 \brief Sets the width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars
51 \brief The width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars
52 is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen
52 is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen
53 is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis.
53 is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis.
54 Note that with QGroupedBarSeries this value means the width of one group of bars instead of just one bar. This is
54 Note that with QGroupedBarSeries this value means the width of one group of bars instead of just one bar. This is
55 because with grouped series it is more logical to set width of whole group and let the chart calculate correct
55 because with grouped series it is more logical to set width of whole group and let the chart calculate correct
56 width for bar.
56 width for bar.
57 \sa QGroupedBarSeries
57 \sa QGroupedBarSeries
58 */
58 */
59
59
60 /*!
60 /*!
61 \property QBarSeries::count
61 \property QBarSeries::count
62 \brief Holds the number of sets in series.
62 \brief Holds the number of sets in series.
63 */
63 */
64
64
65 /*!
65 /*!
66 \property QBarSeries::labelsVisible
66 \property QBarSeries::labelsVisible
67 \brief Defines the visibility of the labels in series
67 \brief Defines the visibility of the labels in series
68 */
68 */
69
69
70 /*!
70 /*!
71 \fn void QBarSeries::clicked(QBarSet *barset, int index)
71 \fn void QBarSeries::clicked(QBarSet *barset, int index)
72
72
73 The signal is emitted if the user clicks with a mouse on top of QBarSet \a barset.
73 The signal is emitted if the user clicks with a mouse on top of QBarSet \a barset.
74 Clicked bar inside set is indexed by \a index
74 Clicked bar inside set is indexed by \a index
75 */
75 */
76
76
77 /*!
77 /*!
78 \fn void QBarSeries::hovered(QBarSet* barset, bool status)
78 \fn void QBarSeries::hovered(QBarSet* barset, bool status)
79
79
80 The signal is emitted if mouse is hovered on top of series.
80 The signal is emitted if mouse is hovered on top of series.
81 Parameter \a barset is the pointer of barset, where hover happened.
81 Parameter \a barset is the pointer of barset, where hover happened.
82 Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series.
82 Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series.
83 */
83 */
84 /*!
84 /*!
85 \fn void QBarSeries::barWidthChanged()
85 \fn void QBarSeries::barWidthChanged(qreal)
86
86
87 This signal is emitted when bar width has been changed.
87 This signal is emitted when bar width has been changed to \a width.
88 */
88 */
89
89
90 /*!
90 /*!
91 \fn void QBarSeries::countChanged()
91 \fn void QBarSeries::countChanged()
92
92
93 This signal is emitted when barset count has been changed, for example by append or remove.
93 This signal is emitted when barset count has been changed, for example by append or remove.
94 */
94 */
95
95
96 /*!
96 /*!
97 \fn void QBarSeries::labelsVisibleChanged()
97 \fn void QBarSeries::labelsVisibleChanged()
98
98
99 This signal is emitted when labels visibility have changed.
99 This signal is emitted when labels visibility have changed.
100
100
101 \sa isLabelsVisible(), setLabelsVisible()
101 \sa isLabelsVisible(), setLabelsVisible()
102 */
102 */
103
103
104 /*!
104 /*!
105 \fn void QBarSeries::barsetsAdded(QList<QBarSet*> sets)
105 \fn void QBarSeries::barsetsAdded(QList<QBarSet*> sets)
106
106
107 This signal is emitted when \a sets have been added to the series.
107 This signal is emitted when \a sets have been added to the series.
108
108
109 \sa append(), insert()
109 \sa append(), insert()
110 */
110 */
111
111
112 /*!
112 /*!
113 \fn void QBarSeries::barsetsRemoved(QList<QBarSet*> sets)
113 \fn void QBarSeries::barsetsRemoved(QList<QBarSet*> sets)
114
114
115 This signal is emitted when \a sets have been removed from the series.
115 This signal is emitted when \a sets have been removed from the series.
116
116
117 \sa remove()
117 \sa remove()
118 */
118 */
119
119
120 /*!
120 /*!
121 Constructs empty QBarSeries.
121 Constructs empty QBarSeries.
122 QBarSeries is QObject which is a child of a \a parent.
122 QBarSeries is QObject which is a child of a \a parent.
123 */
123 */
124 QBarSeries::QBarSeries(QObject *parent) :
124 QBarSeries::QBarSeries(QObject *parent) :
125 QAbstractSeries(*new QBarSeriesPrivate(this),parent)
125 QAbstractSeries(*new QBarSeriesPrivate(this),parent)
126 {
126 {
127 }
127 }
128
128
129 /*!
129 /*!
130 Destructs barseries and owned barsets.
130 Destructs barseries and owned barsets.
131 */
131 */
132 QBarSeries::~QBarSeries()
132 QBarSeries::~QBarSeries()
133 {
133 {
134 Q_D(QBarSeries);
134 Q_D(QBarSeries);
135 if(d->m_dataset){
135 if(d->m_dataset){
136 d->m_dataset->removeSeries(this);
136 d->m_dataset->removeSeries(this);
137 }
137 }
138 }
138 }
139
139
140 /*!
140 /*!
141 \internal
141 \internal
142 */
142 */
143 QBarSeries::QBarSeries(QBarSeriesPrivate &d, QObject *parent) :
143 QBarSeries::QBarSeries(QBarSeriesPrivate &d, QObject *parent) :
144 QAbstractSeries(d,parent)
144 QAbstractSeries(d,parent)
145 {
145 {
146 }
146 }
147
147
148 /*!
148 /*!
149 Returns the type of series. Derived classes override this.
149 Returns the type of series. Derived classes override this.
150 */
150 */
151 QAbstractSeries::SeriesType QBarSeries::type() const
151 QAbstractSeries::SeriesType QBarSeries::type() const
152 {
152 {
153 return QAbstractSeries::SeriesTypeBar;
153 return QAbstractSeries::SeriesTypeBar;
154 }
154 }
155
155
156 /*!
157 Sets the width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars
158 is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen
159 is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis.
160 Note that with QGroupedBarSeries this value means the width of one group of bars instead of just one bar. This is
161 because with grouped series it is more logical to set widht of whole group and let the chart calculate correct
162 width for bar.
163 \sa QGroupedBarSeries
164 */
165 void QBarSeries::setBarWidth(qreal width)
156 void QBarSeries::setBarWidth(qreal width)
166 {
157 {
167 Q_D(QBarSeries);
158 Q_D(QBarSeries);
168 d->setBarWidth(width);
159 d->setBarWidth(width);
169 emit barWidthChanged();
160 emit barWidthChanged(width);
170 }
161 }
171
162
172 /*!
173 Returns the width of bars.
174 */
175 qreal QBarSeries::barWidth() const
163 qreal QBarSeries::barWidth() const
176 {
164 {
177 Q_D(const QBarSeries);
165 Q_D(const QBarSeries);
178 return d->barWidth();
166 return d->barWidth();
179 }
167 }
180
168
181 /*!
169 /*!
182 Adds a set of bars to series. Takes ownership of \a set. If the set is null or is already in series, it won't be appended.
170 Adds a set of bars to series. Takes ownership of \a set. If the set is null or is already in series, it won't be appended.
183 Returns true, if appending succeeded.
171 Returns true, if appending succeeded.
184
185 */
172 */
186 bool QBarSeries::append(QBarSet *set)
173 bool QBarSeries::append(QBarSet *set)
187 {
174 {
188 Q_D(QBarSeries);
175 Q_D(QBarSeries);
189 bool success = d->append(set);
176 bool success = d->append(set);
190 if (success) {
177 if (success) {
191 QList<QBarSet*> sets;
178 QList<QBarSet*> sets;
192 sets.append(set);
179 sets.append(set);
193 emit barsetsAdded(sets);
180 emit barsetsAdded(sets);
194 emit countChanged();
181 emit countChanged();
195 }
182 }
196 return success;
183 return success;
197 }
184 }
198
185
199 /*!
186 /*!
200 Removes a set of bars from series. Releases ownership of \a set. Doesn't delete \a set.
187 Removes a set of bars from series. Releases ownership of \a set. Doesn't delete \a set.
201 Returns true, if set was removed.
188 Returns true, if set was removed.
202 */
189 */
203 bool QBarSeries::remove(QBarSet *set)
190 bool QBarSeries::remove(QBarSet *set)
204 {
191 {
205 Q_D(QBarSeries);
192 Q_D(QBarSeries);
206 bool success = d->remove(set);
193 bool success = d->remove(set);
207 if (success) {
194 if (success) {
208 QList<QBarSet*> sets;
195 QList<QBarSet*> sets;
209 sets.append(set);
196 sets.append(set);
210 emit barsetsRemoved(sets);
197 emit barsetsRemoved(sets);
211 emit countChanged();
198 emit countChanged();
212 }
199 }
213 return success;
200 return success;
214 }
201 }
215
202
216 /*!
203 /*!
217 Adds a list of barsets to series. Takes ownership of \a sets.
204 Adds a list of barsets to series. Takes ownership of \a sets.
218 Returns true, if all sets were appended succesfully. If any of the sets is null or is already appended to series,
205 Returns true, if all sets were appended succesfully. If any of the sets is null or is already appended to series,
219 nothing is appended and function returns false. If any of the sets is in list more than once, nothing is appended
206 nothing is appended and function returns false. If any of the sets is in list more than once, nothing is appended
220 and function returns false.
207 and function returns false.
221 */
208 */
222 bool QBarSeries::append(QList<QBarSet* > sets)
209 bool QBarSeries::append(QList<QBarSet* > sets)
223 {
210 {
224 Q_D(QBarSeries);
211 Q_D(QBarSeries);
225 bool success = d->append(sets);
212 bool success = d->append(sets);
226 if (success) {
213 if (success) {
227 emit barsetsAdded(sets);
214 emit barsetsAdded(sets);
228 emit countChanged();
215 emit countChanged();
229 }
216 }
230 return success;
217 return success;
231 }
218 }
232
219
233 /*!
220 /*!
234 Insert a set of bars to series at \a index postion. Takes ownership of \a set. If the set is null or is already in series, it won't be appended.
221 Insert a set of bars to series at \a index postion. Takes ownership of \a set. If the set is null or is already in series, it won't be appended.
235 Returns true, if inserting succeeded.
222 Returns true, if inserting succeeded.
236
223
237 */
224 */
238 bool QBarSeries::insert(int index, QBarSet *set)
225 bool QBarSeries::insert(int index, QBarSet *set)
239 {
226 {
240 Q_D(QBarSeries);
227 Q_D(QBarSeries);
241 bool success = d->insert(index, set);
228 bool success = d->insert(index, set);
242 if (success) {
229 if (success) {
243 QList<QBarSet*> sets;
230 QList<QBarSet*> sets;
244 sets.append(set);
231 sets.append(set);
245 emit barsetsAdded(sets);
232 emit barsetsAdded(sets);
246 emit countChanged();
233 emit countChanged();
247 }
234 }
248 return success;
235 return success;
249 }
236 }
250
237
251 /*!
238 /*!
252 Removes all of the bar sets from the series
239 Removes all of the bar sets from the series
253 */
240 */
254 void QBarSeries::clear()
241 void QBarSeries::clear()
255 {
242 {
256 Q_D(QBarSeries);
243 Q_D(QBarSeries);
257 QList<QBarSet *> sets = barSets();
244 QList<QBarSet *> sets = barSets();
258 bool success = d->remove(sets);
245 bool success = d->remove(sets);
259 if (success) {
246 if (success) {
260 emit barsetsRemoved(sets);
247 emit barsetsRemoved(sets);
261 emit countChanged();
248 emit countChanged();
262 }
249 }
263 }
250 }
264
251
265 /*!
252 /*!
266 Returns number of sets in series.
253 Returns number of sets in series.
267 */
254 */
268 int QBarSeries::count() const
255 int QBarSeries::count() const
269 {
256 {
270 Q_D(const QBarSeries);
257 Q_D(const QBarSeries);
271 return d->m_barSets.count();
258 return d->m_barSets.count();
272 }
259 }
273
260
274 /*!
261 /*!
275 Returns a list of sets in series. Keeps ownership of sets.
262 Returns a list of sets in series. Keeps ownership of sets.
276 */
263 */
277 QList<QBarSet*> QBarSeries::barSets() const
264 QList<QBarSet*> QBarSeries::barSets() const
278 {
265 {
279 Q_D(const QBarSeries);
266 Q_D(const QBarSeries);
280 return d->m_barSets;
267 return d->m_barSets;
281 }
268 }
282
269
283 /*!
270 /*!
284 Sets the visibility of labels in series to \a visible
271 Sets the visibility of labels in series to \a visible
285 */
272 */
286 void QBarSeries::setLabelsVisible(bool visible)
273 void QBarSeries::setLabelsVisible(bool visible)
287 {
274 {
288 Q_D(QBarSeries);
275 Q_D(QBarSeries);
289 if (d->m_labelsVisible != visible) {
276 if (d->m_labelsVisible != visible) {
290 d->setLabelsVisible(visible);
277 d->setLabelsVisible(visible);
291 emit labelsVisibleChanged();
278 emit labelsVisibleChanged();
292 }
279 }
293 }
280 }
294
281
295 /*!
282 /*!
296 Returns the visibility of labels
283 Returns the visibility of labels
297 */
284 */
298 bool QBarSeries::isLabelsVisible() const
285 bool QBarSeries::isLabelsVisible() const
299 {
286 {
300 Q_D(const QBarSeries);
287 Q_D(const QBarSeries);
301 return d->m_labelsVisible;
288 return d->m_labelsVisible;
302 }
289 }
303
290
304 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
291 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
305
292
306 QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) :
293 QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) :
307 QAbstractSeriesPrivate(q),
294 QAbstractSeriesPrivate(q),
308 m_barWidth(0.5), // Default value is 50% of category width
295 m_barWidth(0.5), // Default value is 50% of category width
309 m_labelsVisible(false),
296 m_labelsVisible(false),
310 m_visible(true)
297 m_visible(true)
311 {
298 {
312 }
299 }
313
300
314 void QBarSeriesPrivate::setCategories(QStringList categories)
301 void QBarSeriesPrivate::setCategories(QStringList categories)
315 {
302 {
316 m_categories = categories;
303 m_categories = categories;
317 }
304 }
318
305
319 void QBarSeriesPrivate::insertCategory(int index, const QString category)
306 void QBarSeriesPrivate::insertCategory(int index, const QString category)
320 {
307 {
321 m_categories.insert(index, category);
308 m_categories.insert(index, category);
322 emit categoriesUpdated();
309 emit categoriesUpdated();
323 }
310 }
324
311
325 void QBarSeriesPrivate::removeCategory(int index)
312 void QBarSeriesPrivate::removeCategory(int index)
326 {
313 {
327 m_categories.removeAt(index);
314 m_categories.removeAt(index);
328 emit categoriesUpdated();
315 emit categoriesUpdated();
329 }
316 }
330
317
331 int QBarSeriesPrivate::categoryCount() const
318 int QBarSeriesPrivate::categoryCount() const
332 {
319 {
333 if (m_categories.count() > 0) {
320 if (m_categories.count() > 0) {
334 return m_categories.count();
321 return m_categories.count();
335 }
322 }
336
323
337 // No categories defined. return count of longest set.
324 // No categories defined. return count of longest set.
338 int count = 0;
325 int count = 0;
339 for (int i=0; i<m_barSets.count(); i++) {
326 for (int i=0; i<m_barSets.count(); i++) {
340 if (m_barSets.at(i)->count() > count) {
327 if (m_barSets.at(i)->count() > count) {
341 count = m_barSets.at(i)->count();
328 count = m_barSets.at(i)->count();
342 }
329 }
343 }
330 }
344
331
345 return count;
332 return count;
346 }
333 }
347
334
348 QStringList QBarSeriesPrivate::categories() const
335 QStringList QBarSeriesPrivate::categories() const
349 {
336 {
350 if (m_categories.count() > 0) {
337 if (m_categories.count() > 0) {
351 return m_categories;
338 return m_categories;
352 }
339 }
353
340
354 // No categories defined. retun list of indices.
341 // No categories defined. retun list of indices.
355 QStringList categories;
342 QStringList categories;
356
343
357 int count = categoryCount();
344 int count = categoryCount();
358 for (int i = 0; i < count; i++) {
345 for (int i = 0; i < count; i++) {
359 categories.append(QString::number(i));
346 categories.append(QString::number(i));
360 }
347 }
361 return categories;
348 return categories;
362 }
349 }
363
350
364 void QBarSeriesPrivate::setBarWidth(qreal width)
351 void QBarSeriesPrivate::setBarWidth(qreal width)
365 {
352 {
366 if (width < 0.0) {
353 if (width < 0.0) {
367 width = 0.0;
354 width = 0.0;
368 }
355 }
369 m_barWidth = width;
356 m_barWidth = width;
370 emit updatedBars();
357 emit updatedBars();
371 }
358 }
372
359
373 qreal QBarSeriesPrivate::barWidth() const
360 qreal QBarSeriesPrivate::barWidth() const
374 {
361 {
375 return m_barWidth;
362 return m_barWidth;
376 }
363 }
377
364
378 QBarSet* QBarSeriesPrivate::barsetAt(int index)
365 QBarSet* QBarSeriesPrivate::barsetAt(int index)
379 {
366 {
380 return m_barSets.at(index);
367 return m_barSets.at(index);
381 }
368 }
382
369
383 void QBarSeriesPrivate::setVisible(bool visible)
370 void QBarSeriesPrivate::setVisible(bool visible)
384 {
371 {
385 m_visible = visible;
372 m_visible = visible;
386 emit updatedBars();
373 emit updatedBars();
387 }
374 }
388
375
389 void QBarSeriesPrivate::setLabelsVisible(bool visible)
376 void QBarSeriesPrivate::setLabelsVisible(bool visible)
390 {
377 {
391 m_labelsVisible = visible;
378 m_labelsVisible = visible;
392 emit labelsVisibleChanged(visible);
379 emit labelsVisibleChanged(visible);
393 }
380 }
394
381
395 QString QBarSeriesPrivate::categoryName(int category)
382 QString QBarSeriesPrivate::categoryName(int category)
396 {
383 {
397 if ((category >= 0) && (category < m_categories.count())) {
384 if ((category >= 0) && (category < m_categories.count())) {
398 return m_categories.at(category);
385 return m_categories.at(category);
399 }
386 }
400
387
401 return QString::number(category);
388 return QString::number(category);
402 }
389 }
403
390
404 qreal QBarSeriesPrivate::min()
391 qreal QBarSeriesPrivate::min()
405 {
392 {
406 if (m_barSets.count() <= 0) {
393 if (m_barSets.count() <= 0) {
407 return 0;
394 return 0;
408 }
395 }
409 qreal min = INT_MAX;
396 qreal min = INT_MAX;
410
397
411 for (int i = 0; i < m_barSets.count(); i++) {
398 for (int i = 0; i < m_barSets.count(); i++) {
412 int categoryCount = m_barSets.at(i)->count();
399 int categoryCount = m_barSets.at(i)->count();
413 for (int j = 0; j < categoryCount; j++) {
400 for (int j = 0; j < categoryCount; j++) {
414 qreal temp = m_barSets.at(i)->at(j).y();
401 qreal temp = m_barSets.at(i)->at(j).y();
415 if (temp < min)
402 if (temp < min)
416 min = temp;
403 min = temp;
417 }
404 }
418 }
405 }
419 return min;
406 return min;
420 }
407 }
421
408
422 qreal QBarSeriesPrivate::max()
409 qreal QBarSeriesPrivate::max()
423 {
410 {
424 if (m_barSets.count() <= 0) {
411 if (m_barSets.count() <= 0) {
425 return 0;
412 return 0;
426 }
413 }
427 qreal max = INT_MIN;
414 qreal max = INT_MIN;
428
415
429 for (int i = 0; i < m_barSets.count(); i++) {
416 for (int i = 0; i < m_barSets.count(); i++) {
430 int categoryCount = m_barSets.at(i)->count();
417 int categoryCount = m_barSets.at(i)->count();
431 for (int j = 0; j < categoryCount; j++) {
418 for (int j = 0; j < categoryCount; j++) {
432 qreal temp = m_barSets.at(i)->at(j).y();
419 qreal temp = m_barSets.at(i)->at(j).y();
433 if (temp > max)
420 if (temp > max)
434 max = temp;
421 max = temp;
435 }
422 }
436 }
423 }
437
424
438 return max;
425 return max;
439 }
426 }
440
427
441 qreal QBarSeriesPrivate::valueAt(int set, int category)
428 qreal QBarSeriesPrivate::valueAt(int set, int category)
442 {
429 {
443 if ((set < 0) || (set >= m_barSets.count())) {
430 if ((set < 0) || (set >= m_barSets.count())) {
444 // No set, no value.
431 // No set, no value.
445 return 0;
432 return 0;
446 } else if ((category < 0) || (category >= m_barSets.at(set)->count())) {
433 } else if ((category < 0) || (category >= m_barSets.at(set)->count())) {
447 // No category, no value.
434 // No category, no value.
448 return 0;
435 return 0;
449 }
436 }
450
437
451 return m_barSets.at(set)->at(category).y();
438 return m_barSets.at(set)->at(category).y();
452 }
439 }
453
440
454 qreal QBarSeriesPrivate::percentageAt(int set, int category)
441 qreal QBarSeriesPrivate::percentageAt(int set, int category)
455 {
442 {
456 if ((set < 0) || (set >= m_barSets.count())) {
443 if ((set < 0) || (set >= m_barSets.count())) {
457 // No set, no value.
444 // No set, no value.
458 return 0;
445 return 0;
459 } else if ((category < 0) || (category >= m_barSets.at(set)->count())) {
446 } else if ((category < 0) || (category >= m_barSets.at(set)->count())) {
460 // No category, no value.
447 // No category, no value.
461 return 0;
448 return 0;
462 }
449 }
463
450
464 qreal value = m_barSets.at(set)->at(category).y();
451 qreal value = m_barSets.at(set)->at(category).y();
465 qreal sum = categorySum(category);
452 qreal sum = categorySum(category);
466 if ( qFuzzyIsNull(sum) ) {
453 if ( qFuzzyIsNull(sum) ) {
467 return 0;
454 return 0;
468 }
455 }
469
456
470 return value / sum;
457 return value / sum;
471 }
458 }
472
459
473 qreal QBarSeriesPrivate::categorySum(int category)
460 qreal QBarSeriesPrivate::categorySum(int category)
474 {
461 {
475 qreal sum(0);
462 qreal sum(0);
476 int count = m_barSets.count(); // Count sets
463 int count = m_barSets.count(); // Count sets
477 for (int set = 0; set < count; set++) {
464 for (int set = 0; set < count; set++) {
478 if (category < m_barSets.at(set)->count())
465 if (category < m_barSets.at(set)->count())
479 sum += m_barSets.at(set)->at(category).y();
466 sum += m_barSets.at(set)->at(category).y();
480 }
467 }
481 return sum;
468 return sum;
482 }
469 }
483
470
484 qreal QBarSeriesPrivate::absoluteCategorySum(int category)
471 qreal QBarSeriesPrivate::absoluteCategorySum(int category)
485 {
472 {
486 qreal sum(0);
473 qreal sum(0);
487 int count = m_barSets.count(); // Count sets
474 int count = m_barSets.count(); // Count sets
488 for (int set = 0; set < count; set++) {
475 for (int set = 0; set < count; set++) {
489 if (category < m_barSets.at(set)->count())
476 if (category < m_barSets.at(set)->count())
490 sum += qAbs(m_barSets.at(set)->at(category).y());
477 sum += qAbs(m_barSets.at(set)->at(category).y());
491 }
478 }
492 return sum;
479 return sum;
493 }
480 }
494
481
495 qreal QBarSeriesPrivate::maxCategorySum()
482 qreal QBarSeriesPrivate::maxCategorySum()
496 {
483 {
497 qreal max = INT_MIN;
484 qreal max = INT_MIN;
498 int count = categoryCount();
485 int count = categoryCount();
499 for (int i = 0; i < count; i++) {
486 for (int i = 0; i < count; i++) {
500 qreal sum = categorySum(i);
487 qreal sum = categorySum(i);
501 if (sum > max)
488 if (sum > max)
502 max = sum;
489 max = sum;
503 }
490 }
504 return max;
491 return max;
505 }
492 }
506
493
507 qreal QBarSeriesPrivate::minX()
494 qreal QBarSeriesPrivate::minX()
508 {
495 {
509 if (m_barSets.count() <= 0) {
496 if (m_barSets.count() <= 0) {
510 return 0;
497 return 0;
511 }
498 }
512 qreal min = INT_MAX;
499 qreal min = INT_MAX;
513
500
514 for (int i = 0; i < m_barSets.count(); i++) {
501 for (int i = 0; i < m_barSets.count(); i++) {
515 int categoryCount = m_barSets.at(i)->count();
502 int categoryCount = m_barSets.at(i)->count();
516 for (int j = 0; j < categoryCount; j++) {
503 for (int j = 0; j < categoryCount; j++) {
517 qreal temp = m_barSets.at(i)->at(j).x();
504 qreal temp = m_barSets.at(i)->at(j).x();
518 if (temp < min)
505 if (temp < min)
519 min = temp;
506 min = temp;
520 }
507 }
521 }
508 }
522 return min;
509 return min;
523 }
510 }
524
511
525 qreal QBarSeriesPrivate::maxX()
512 qreal QBarSeriesPrivate::maxX()
526 {
513 {
527 if (m_barSets.count() <= 0) {
514 if (m_barSets.count() <= 0) {
528 return 0;
515 return 0;
529 }
516 }
530 qreal max = INT_MIN;
517 qreal max = INT_MIN;
531
518
532 for (int i = 0; i < m_barSets.count(); i++) {
519 for (int i = 0; i < m_barSets.count(); i++) {
533 int categoryCount = m_barSets.at(i)->count();
520 int categoryCount = m_barSets.at(i)->count();
534 for (int j = 0; j < categoryCount; j++) {
521 for (int j = 0; j < categoryCount; j++) {
535 qreal temp = m_barSets.at(i)->at(j).x();
522 qreal temp = m_barSets.at(i)->at(j).x();
536 if (temp > max)
523 if (temp > max)
537 max = temp;
524 max = temp;
538 }
525 }
539 }
526 }
540
527
541 return max;
528 return max;
542 }
529 }
543
530
544
531
545 void QBarSeriesPrivate::scaleDomain(Domain& domain)
532 void QBarSeriesPrivate::scaleDomain(Domain& domain)
546 {
533 {
547 qreal minX(domain.minX());
534 qreal minX(domain.minX());
548 qreal minY(domain.minY());
535 qreal minY(domain.minY());
549 qreal maxX(domain.maxX());
536 qreal maxX(domain.maxX());
550 qreal maxY(domain.maxY());
537 qreal maxY(domain.maxY());
551 int tickXCount(domain.tickXCount());
538 int tickXCount(domain.tickXCount());
552 int tickYCount(domain.tickYCount());
539 int tickYCount(domain.tickYCount());
553
540
554 qreal seriesMinX = this->minX();
541 qreal seriesMinX = this->minX();
555 qreal seriesMaxX = this->maxX();
542 qreal seriesMaxX = this->maxX();
556 qreal y = max();
543 qreal y = max();
557 minX = qMin(minX, seriesMinX - 0.5);
544 minX = qMin(minX, seriesMinX - 0.5);
558 minY = qMin(minY, y);
545 minY = qMin(minY, y);
559 maxX = qMax(maxX, seriesMaxX + 0.5);
546 maxX = qMax(maxX, seriesMaxX + 0.5);
560 maxY = qMax(maxY, y);
547 maxY = qMax(maxY, y);
561 tickXCount = categoryCount()+1;
548 tickXCount = categoryCount()+1;
562
549
563 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
550 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
564 }
551 }
565
552
566 Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
553 Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
567 {
554 {
568 Q_Q(QBarSeries);
555 Q_Q(QBarSeries);
569
556
570 BarChartItem* bar = new BarChartItem(q,presenter);
557 BarChartItem* bar = new BarChartItem(q,presenter);
571 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
558 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
572 presenter->animator()->addAnimation(bar);
559 presenter->animator()->addAnimation(bar);
573 }
560 }
574 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
561 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
575 return bar;
562 return bar;
576
563
577 }
564 }
578
565
579 QList<LegendMarker*> QBarSeriesPrivate::createLegendMarker(QLegend* legend)
566 QList<LegendMarker*> QBarSeriesPrivate::createLegendMarker(QLegend* legend)
580 {
567 {
581 Q_Q(QBarSeries);
568 Q_Q(QBarSeries);
582 QList<LegendMarker*> markers;
569 QList<LegendMarker*> markers;
583 foreach(QBarSet* set, q->barSets()) {
570 foreach(QBarSet* set, q->barSets()) {
584 BarLegendMarker* marker = new BarLegendMarker(q,set,legend);
571 BarLegendMarker* marker = new BarLegendMarker(q,set,legend);
585 markers << marker;
572 markers << marker;
586 }
573 }
587
574
588 return markers;
575 return markers;
589 }
576 }
590
577
591 bool QBarSeriesPrivate::append(QBarSet *set)
578 bool QBarSeriesPrivate::append(QBarSet *set)
592 {
579 {
593 Q_Q(QBarSeries);
580 Q_Q(QBarSeries);
594 if ((m_barSets.contains(set)) || (set == 0)) {
581 if ((m_barSets.contains(set)) || (set == 0)) {
595 // Fail if set is already in list or set is null.
582 // Fail if set is already in list or set is null.
596 return false;
583 return false;
597 }
584 }
598 m_barSets.append(set);
585 m_barSets.append(set);
599 QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
586 QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
600 QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
587 QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
601 emit restructuredBars(); // this notifies barchartitem
588 emit restructuredBars(); // this notifies barchartitem
602 if (m_dataset) {
589 if (m_dataset) {
603 m_dataset->updateSeries(q); // this notifies legend
590 m_dataset->updateSeries(q); // this notifies legend
604 }
591 }
605 return true;
592 return true;
606 }
593 }
607
594
608 bool QBarSeriesPrivate::remove(QBarSet *set)
595 bool QBarSeriesPrivate::remove(QBarSet *set)
609 {
596 {
610 Q_Q(QBarSeries);
597 Q_Q(QBarSeries);
611 if (!m_barSets.contains(set)) {
598 if (!m_barSets.contains(set)) {
612 // Fail if set is not in list
599 // Fail if set is not in list
613 return false;
600 return false;
614 }
601 }
615 m_barSets.removeOne(set);
602 m_barSets.removeOne(set);
616 QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
603 QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
617 QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
604 QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
618 emit restructuredBars(); // this notifies barchartitem
605 emit restructuredBars(); // this notifies barchartitem
619 if (m_dataset) {
606 if (m_dataset) {
620 m_dataset->updateSeries(q); // this notifies legend
607 m_dataset->updateSeries(q); // this notifies legend
621 }
608 }
622 return true;
609 return true;
623 }
610 }
624
611
625 bool QBarSeriesPrivate::append(QList<QBarSet* > sets)
612 bool QBarSeriesPrivate::append(QList<QBarSet* > sets)
626 {
613 {
627 Q_Q(QBarSeries);
614 Q_Q(QBarSeries);
628 foreach (QBarSet* set, sets) {
615 foreach (QBarSet* set, sets) {
629 if ((set == 0) || (m_barSets.contains(set))) {
616 if ((set == 0) || (m_barSets.contains(set))) {
630 // Fail if any of the sets is null or is already appended.
617 // Fail if any of the sets is null or is already appended.
631 return false;
618 return false;
632 }
619 }
633 if (sets.count(set) != 1) {
620 if (sets.count(set) != 1) {
634 // Also fail if same set is more than once in given list.
621 // Also fail if same set is more than once in given list.
635 return false;
622 return false;
636 }
623 }
637 }
624 }
638
625
639 foreach (QBarSet* set, sets) {
626 foreach (QBarSet* set, sets) {
640 m_barSets.append(set);
627 m_barSets.append(set);
641 QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
628 QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
642 QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
629 QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
643 }
630 }
644 emit restructuredBars(); // this notifies barchartitem
631 emit restructuredBars(); // this notifies barchartitem
645 if (m_dataset) {
632 if (m_dataset) {
646 m_dataset->updateSeries(q); // this notifies legend
633 m_dataset->updateSeries(q); // this notifies legend
647 }
634 }
648 return true;
635 return true;
649 }
636 }
650
637
651 bool QBarSeriesPrivate::remove(QList<QBarSet* > sets)
638 bool QBarSeriesPrivate::remove(QList<QBarSet* > sets)
652 {
639 {
653 Q_Q(QBarSeries);
640 Q_Q(QBarSeries);
654 if (sets.count() == 0) {
641 if (sets.count() == 0) {
655 return false;
642 return false;
656 }
643 }
657 foreach (QBarSet* set, sets) {
644 foreach (QBarSet* set, sets) {
658 if ((set == 0) || (!m_barSets.contains(set))) {
645 if ((set == 0) || (!m_barSets.contains(set))) {
659 // Fail if any of the sets is null or is not in series
646 // Fail if any of the sets is null or is not in series
660 return false;
647 return false;
661 }
648 }
662 if (sets.count(set) != 1) {
649 if (sets.count(set) != 1) {
663 // Also fail if same set is more than once in given list.
650 // Also fail if same set is more than once in given list.
664 return false;
651 return false;
665 }
652 }
666 }
653 }
667
654
668 foreach (QBarSet* set, sets) {
655 foreach (QBarSet* set, sets) {
669 m_barSets.removeOne(set);
656 m_barSets.removeOne(set);
670 QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
657 QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
671 QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
658 QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
672 }
659 }
673
660
674 emit restructuredBars(); // this notifies barchartitem
661 emit restructuredBars(); // this notifies barchartitem
675 if (m_dataset) {
662 if (m_dataset) {
676 m_dataset->updateSeries(q); // this notifies legend
663 m_dataset->updateSeries(q); // this notifies legend
677 }
664 }
678 return true;
665 return true;
679 }
666 }
680
667
681 bool QBarSeriesPrivate::insert(int index, QBarSet *set)
668 bool QBarSeriesPrivate::insert(int index, QBarSet *set)
682 {
669 {
683 Q_Q(QBarSeries);
670 Q_Q(QBarSeries);
684 if ((m_barSets.contains(set)) || (set == 0)) {
671 if ((m_barSets.contains(set)) || (set == 0)) {
685 // Fail if set is already in list or set is null.
672 // Fail if set is already in list or set is null.
686 return false;
673 return false;
687 }
674 }
688 m_barSets.insert(index, set);
675 m_barSets.insert(index, set);
689 QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
676 QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
690 QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
677 QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
691 emit restructuredBars(); // this notifies barchartitem
678 emit restructuredBars(); // this notifies barchartitem
692 if (m_dataset) {
679 if (m_dataset) {
693 m_dataset->updateSeries(q); // this notifies legend
680 m_dataset->updateSeries(q); // this notifies legend
694 }
681 }
695 return true;
682 return true;
696 }
683 }
697
684
698 #include "moc_qbarseries.cpp"
685 #include "moc_qbarseries.cpp"
699 #include "moc_qbarseries_p.cpp"
686 #include "moc_qbarseries_p.cpp"
700
687
701 QTCOMMERCIALCHART_END_NAMESPACE
688 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,83 +1,83
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 BARSERIES_H
21 #ifndef BARSERIES_H
22 #define BARSERIES_H
22 #define BARSERIES_H
23
23
24 #include <qabstractseries.h>
24 #include <qabstractseries.h>
25 #include <QStringList>
25 #include <QStringList>
26
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
28
29 class QBarSet;
29 class QBarSet;
30 class QBarSeriesPrivate;
30 class QBarSeriesPrivate;
31
31
32 // Container for series
32 // Container for series
33 class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractSeries
33 class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractSeries
34 {
34 {
35 Q_OBJECT
35 Q_OBJECT
36 Q_PROPERTY(qreal barWidth READ barWidth WRITE setBarWidth NOTIFY barWidthChanged)
36 Q_PROPERTY(qreal barWidth READ barWidth WRITE setBarWidth NOTIFY barWidthChanged)
37 Q_PROPERTY(int count READ count NOTIFY countChanged)
37 Q_PROPERTY(int count READ count NOTIFY countChanged)
38 Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
38 Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
39
39
40 public:
40 public:
41 explicit QBarSeries(QObject *parent = 0);
41 explicit QBarSeries(QObject *parent = 0);
42 virtual ~QBarSeries();
42 virtual ~QBarSeries();
43
43
44 QAbstractSeries::SeriesType type() const;
44 QAbstractSeries::SeriesType type() const;
45
45
46 void setBarWidth(qreal width);
46 void setBarWidth(qreal width);
47 qreal barWidth() const;
47 qreal barWidth() const;
48
48
49 bool append(QBarSet *set);
49 bool append(QBarSet *set);
50 bool remove(QBarSet *set);
50 bool remove(QBarSet *set);
51 bool append(QList<QBarSet* > sets);
51 bool append(QList<QBarSet* > sets);
52 bool insert(int index, QBarSet *set);
52 bool insert(int index, QBarSet *set);
53 int count() const;
53 int count() const;
54 QList<QBarSet*> barSets() const;
54 QList<QBarSet*> barSets() const;
55 void clear();
55 void clear();
56
56
57 void setLabelsVisible(bool visible = true);
57 void setLabelsVisible(bool visible = true);
58 bool isLabelsVisible() const;
58 bool isLabelsVisible() const;
59
59
60 protected:
60 protected:
61 explicit QBarSeries(QBarSeriesPrivate &d,QObject *parent = 0);
61 explicit QBarSeries(QBarSeriesPrivate &d,QObject *parent = 0);
62
62
63 Q_SIGNALS:
63 Q_SIGNALS:
64 void clicked(QBarSet *barset, int index);
64 void clicked(QBarSet *barset, int index);
65 void hovered(QBarSet* barset, bool status);
65 void hovered(QBarSet* barset, bool status);
66 void barWidthChanged();
66 void barWidthChanged(qreal width);
67 void countChanged();
67 void countChanged();
68 void labelsVisibleChanged();
68 void labelsVisibleChanged();
69
69
70 void barsetsAdded(QList<QBarSet*> sets);
70 void barsetsAdded(QList<QBarSet*> sets);
71 void barsetsRemoved(QList<QBarSet*> sets);
71 void barsetsRemoved(QList<QBarSet*> sets);
72
72
73 protected:
73 protected:
74 Q_DECLARE_PRIVATE(QBarSeries)
74 Q_DECLARE_PRIVATE(QBarSeries)
75 friend class BarChartItem;
75 friend class BarChartItem;
76 friend class PercentBarChartItem;
76 friend class PercentBarChartItem;
77 friend class StackedBarChartItem;
77 friend class StackedBarChartItem;
78 friend class GroupedBarChartItem;
78 friend class GroupedBarChartItem;
79 };
79 };
80
80
81 QTCOMMERCIALCHART_END_NAMESPACE
81 QTCOMMERCIALCHART_END_NAMESPACE
82
82
83 #endif // BARSERIES_H
83 #endif // BARSERIES_H
@@ -1,494 +1,569
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 "qbarset.h"
21 #include "qbarset.h"
22 #include "qbarset_p.h"
22 #include "qbarset_p.h"
23
23
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25
25
26 /*!
26 /*!
27 \class QBarSet
27 \class QBarSet
28 \brief part of QtCommercial chart API.
28 \brief part of QtCommercial chart API.
29
29
30 QBarSet represents one set of bars. Set of bars contains one data value for each category.
30 QBarSet represents one set of bars. Set of bars contains one data value for each category.
31 First value of set is assumed to belong to first category, second to second category and so on.
31 First value of set is assumed to belong to first category, second to second category and so on.
32 If set has fewer values than there are categories, then the missing values are assumed to be
32 If set has fewer values than there are categories, then the missing values are assumed to be
33 at the end of set. For missing values in middle of a set, numerical value of zero is used.
33 at the end of set. For missing values in middle of a set, numerical value of zero is used.
34
34
35 \mainclass
35 \mainclass
36
36
37 \sa QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries
37 \sa QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries
38 */
38 */
39
39
40 /*!
40 /*!
41 \property QBarSet::label
41 \property QBarSet::label
42 \brief Defines the label of the barSet.
42 \brief Defines the label of the barSet.
43 */
43 */
44
44
45 /*!
45 /*!
46 \property QBarSet::pen
46 \property QBarSet::pen
47 \brief Defines the pen used by the barSet.
47 \brief Defines the pen used by the barSet.
48 */
48 */
49
49
50 /*!
50 /*!
51 \property QBarSet::brush
51 \property QBarSet::brush
52 \brief Defines the brush used by the barSet.
52 \brief Defines the brush used by the barSet.
53 */
53 */
54
54
55 /*!
55 /*!
56 \property QBarSet::labelBrush
56 \property QBarSet::labelBrush
57 \brief Defines the brush used by the barSet's label.
57 \brief Defines the brush used by the barSet's label.
58 */
58 */
59
59
60 /*!
60 /*!
61 \property QBarSet::labelFont
61 \property QBarSet::labelFont
62 \brief Defines the font used by the barSet's label.
62 \brief Defines the font used by the barSet's label.
63 */
63 */
64
64
65 /*!
65 /*!
66 \property QBarSet::color
67 \brief The fill (brush) color of the bar set.
68 */
69
70 /*!
71 \property QBarSet::borderColor
72 \brief The line (pen) color of the bar set.
73 */
74
75 /*!
76 \property QBarSet::labelColor
77 \brief The text (label) color of the bar set.
78 */
79
80 /*!
66 \fn void QBarSet::labelChanged()
81 \fn void QBarSet::labelChanged()
67
82
68 This signal is emitted when the label of the barSet has changed.
83 This signal is emitted when the label of the barSet has changed.
69
84
70 \sa label
85 \sa label
71 */
86 */
72
87
73 /*!
88 /*!
74 \fn void QBarSet::penChanged()
89 \fn void QBarSet::penChanged()
75
90
76 This signal is emitted when the pen of the barSet has changed.
91 This signal is emitted when the pen of the barSet has changed.
77
92
78 \sa pen
93 \sa pen
79 */
94 */
80
95
81 /*!
96 /*!
82 \fn void QBarSet::brushChanged()
97 \fn void QBarSet::brushChanged()
83
98
84 This signal is emitted when the brush of the barSet has changed.
99 This signal is emitted when the brush of the barSet has changed.
85
100
86 \sa brush
101 \sa brush
87 */
102 */
88
103
89 /*!
104 /*!
90 \fn void QBarSet::labelBrushChanged()
105 \fn void QBarSet::labelBrushChanged()
91
106
92 This signal is emitted when the brush of the barSet's label has changed.
107 This signal is emitted when the brush of the barSet's label has changed.
93
108
94 \sa labelBrush
109 \sa labelBrush
95 */
110 */
96
111
97 /*!
112 /*!
98 \fn void QBarSet::labelFontChanged()
113 \fn void QBarSet::labelFontChanged()
99
114
100 This signal is emitted when the font of the barSet's label has changed.
115 This signal is emitted when the font of the barSet's label has changed.
101
116
102 \sa labelBrush
117 \sa labelBrush
103 */
118 */
104
119
105 /*!
120 /*!
121 \fn void QBarSet::colorChanged(QColor)
122 This signal is emitted when the fill (brush) color of the set has changed to \a color.
123 */
124
125 /*!
126 \fn void QBarSet::borderColorChanged(QColor)
127 This signal is emitted when the line (pen) color of the set has changed to \a color.
128 */
129
130 /*!
131 \fn void QBarSet::labelColorChanged(QColor)
132 This signal is emitted when the text (label) color of the set has changed to \a color.
133 */
134
135 /*!
106 \fn void QBarSet::valuesAdded(int index, int count)
136 \fn void QBarSet::valuesAdded(int index, int count)
107
137
108 This signal is emitted when new values have been added to the set.
138 This signal is emitted when new values have been added to the set.
109 Parameter \a index indicates the position of the first inserted value.
139 Parameter \a index indicates the position of the first inserted value.
110 Parameter \a count is the number of iserted values.
140 Parameter \a count is the number of iserted values.
111
141
112 \sa append(), insert()
142 \sa append(), insert()
113 */
143 */
114
144
115 /*!
145 /*!
116 \fn void QBarSet::valuesRemoved(int index, int count)
146 \fn void QBarSet::valuesRemoved(int index, int count)
117
147
118 This signal is emitted values have been removed from the set.
148 This signal is emitted values have been removed from the set.
119 Parameter \a index indicates the position of the first removed value.
149 Parameter \a index indicates the position of the first removed value.
120 Parameter \a count is the number of removed values.
150 Parameter \a count is the number of removed values.
121
151
122 \sa remove()
152 \sa remove()
123 */
153 */
124
154
125 /*!
155 /*!
126 \fn void QBarSet::valueChanged(int index)
156 \fn void QBarSet::valueChanged(int index)
127
157
128 This signal is emitted values the value in the set has been modified.
158 This signal is emitted values the value in the set has been modified.
129 Parameter \a index indicates the position of the modified value.
159 Parameter \a index indicates the position of the modified value.
130
160
131 \sa at()
161 \sa at()
132 */
162 */
133 void valueChanged(int index);
163 void valueChanged(int index);
134
164
135 /*!
165 /*!
136 Constructs QBarSet with a label of \a label and with parent of \a parent
166 Constructs QBarSet with a label of \a label and with parent of \a parent
137 */
167 */
138 QBarSet::QBarSet(const QString label, QObject *parent)
168 QBarSet::QBarSet(const QString label, QObject *parent)
139 : QObject(parent)
169 : QObject(parent)
140 ,d_ptr(new QBarSetPrivate(label,this))
170 ,d_ptr(new QBarSetPrivate(label,this))
141 {
171 {
142 }
172 }
143
173
144 /*!
174 /*!
145 Destroys the barset
175 Destroys the barset
146 */
176 */
147 QBarSet::~QBarSet()
177 QBarSet::~QBarSet()
148 {
178 {
149 // NOTE: d_ptr destroyed by QObject
179 // NOTE: d_ptr destroyed by QObject
150 }
180 }
151
181
152 /*!
182 /*!
153 Sets new \a label for set.
183 Sets new \a label for set.
154 */
184 */
155 void QBarSet::setLabel(const QString label)
185 void QBarSet::setLabel(const QString label)
156 {
186 {
157 d_ptr->m_label = label;
187 d_ptr->m_label = label;
158 emit labelChanged();
188 emit labelChanged();
159 }
189 }
160
190
161 /*!
191 /*!
162 Returns label of the set.
192 Returns label of the set.
163 */
193 */
164 QString QBarSet::label() const
194 QString QBarSet::label() const
165 {
195 {
166 return d_ptr->m_label;
196 return d_ptr->m_label;
167 }
197 }
168
198
169 /*!
199 /*!
170 Appends a point to set. Parameter \a value x coordinate defines the
200 Appends a point to set. Parameter \a value x coordinate defines the
171 position in x-axis and y coordinate defines the height of bar.
201 position in x-axis and y coordinate defines the height of bar.
172 Depending on presentation (QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries)
202 Depending on presentation (QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries)
173 the x values are used or ignored.
203 the x values are used or ignored.
174 */
204 */
175 void QBarSet::append(const QPointF value)
205 void QBarSet::append(const QPointF value)
176 {
206 {
177 int index = d_ptr->m_values.count();
207 int index = d_ptr->m_values.count();
178 d_ptr->append(value);
208 d_ptr->append(value);
179 emit valuesAdded(index, 1);
209 emit valuesAdded(index, 1);
180 }
210 }
181
211
182 /*!
212 /*!
183 Appends a list of \a values to set. Works like append with single point.
213 Appends a list of \a values to set. Works like append with single point.
184 \sa append()
214 \sa append()
185 */
215 */
186 void QBarSet::append(const QList<QPointF> values)
216 void QBarSet::append(const QList<QPointF> values)
187 {
217 {
188 int index = d_ptr->m_values.count();
218 int index = d_ptr->m_values.count();
189 d_ptr->append(values);
219 d_ptr->append(values);
190 emit valuesAdded(index, values.count());
220 emit valuesAdded(index, values.count());
191 }
221 }
192
222
193 /*!
223 /*!
194 Appends new value \a value to the end of set. Internally the value is converted to QPointF,
224 Appends new value \a value to the end of set. Internally the value is converted to QPointF,
195 with x coordinate being the index of appended value and y coordinate is the value.
225 with x coordinate being the index of appended value and y coordinate is the value.
196 */
226 */
197 void QBarSet::append(const qreal value)
227 void QBarSet::append(const qreal value)
198 {
228 {
199 // Convert to QPointF and use other append(QPointF) method.
229 // Convert to QPointF and use other append(QPointF) method.
200 append(QPointF(d_ptr->m_values.count(), value));
230 append(QPointF(d_ptr->m_values.count(), value));
201 }
231 }
202
232
203 /*!
233 /*!
204 Appends a list of reals to set. Works like append with single real value. The \a values in list
234 Appends a list of reals to set. Works like append with single real value. The \a values in list
205 are converted to QPointF, where x coordinate is the index of point and y coordinate is the value.
235 are converted to QPointF, where x coordinate is the index of point and y coordinate is the value.
206 \sa append()
236 \sa append()
207 */
237 */
208 void QBarSet::append(const QList<qreal> values)
238 void QBarSet::append(const QList<qreal> values)
209 {
239 {
210 int index = d_ptr->m_values.count();
240 int index = d_ptr->m_values.count();
211 d_ptr->append(values);
241 d_ptr->append(values);
212 emit valuesAdded(index, values.count());
242 emit valuesAdded(index, values.count());
213 }
243 }
214
244
215 /*!
245 /*!
216 Convinience operator. Same as append, with real \a value.
246 Convinience operator. Same as append, with real \a value.
217 \sa append()
247 \sa append()
218 */
248 */
219 QBarSet& QBarSet::operator << (const qreal &value)
249 QBarSet& QBarSet::operator << (const qreal &value)
220 {
250 {
221 append(value);
251 append(value);
222 return *this;
252 return *this;
223 }
253 }
224
254
225 /*!
255 /*!
226 Convinience operator. Same as append, with QPointF \a value.
256 Convinience operator. Same as append, with QPointF \a value.
227 \sa append()
257 \sa append()
228 */
258 */
229 QBarSet& QBarSet::operator << (const QPointF &value)
259 QBarSet& QBarSet::operator << (const QPointF &value)
230 {
260 {
231 append(value);
261 append(value);
232 return *this;
262 return *this;
233 }
263 }
234
264
235 /*!
265 /*!
236 Inserts new \a value on the \a index position.
266 Inserts new \a value on the \a index position.
237 The value that is currently at this postion is moved to postion index + 1
267 The value that is currently at this postion is moved to postion index + 1
238 \sa remove()
268 \sa remove()
239 */
269 */
240 void QBarSet::insert(const int index, const qreal value)
270 void QBarSet::insert(const int index, const qreal value)
241 {
271 {
242 d_ptr->insert(index, value);
272 d_ptr->insert(index, value);
243 emit valuesAdded(index,1);
273 emit valuesAdded(index,1);
244 }
274 }
245
275
246 /*!
276 /*!
247 Inserts new \a value on the \a index position.
277 Inserts new \a value on the \a index position.
248 The value that is currently at this postion is moved to postion index + 1
278 The value that is currently at this postion is moved to postion index + 1
249 \sa remove()
279 \sa remove()
250 */
280 */
251 void QBarSet::insert(const int index, const QPointF value)
281 void QBarSet::insert(const int index, const QPointF value)
252 {
282 {
253 d_ptr->insert(index,value);
283 d_ptr->insert(index,value);
254 emit valuesAdded(index,1);
284 emit valuesAdded(index,1);
255 }
285 }
256
286
257 /*!
287 /*!
258 Removes \a count number of values from the set starting at \a index.
288 Removes \a count number of values from the set starting at \a index.
259 Returns true if remove operation was succesfull.
289 Returns true if remove operation was succesfull.
260 \sa insert()
290 \sa insert()
261 */
291 */
262 bool QBarSet::remove(const int index, const int count)
292 bool QBarSet::remove(const int index, const int count)
263 {
293 {
264 bool success = d_ptr->remove(index,count);
294 bool success = d_ptr->remove(index,count);
265 if (success) {
295 if (success) {
266 emit valuesRemoved(index,count);
296 emit valuesRemoved(index,count);
267 }
297 }
268 return success;
298 return success;
269 }
299 }
270
300
271 /*!
301 /*!
272 Sets a new value \a value to set, indexed by \a index
302 Sets a new value \a value to set, indexed by \a index
273 */
303 */
274 void QBarSet::replace(const int index, const qreal value)
304 void QBarSet::replace(const int index, const qreal value)
275 {
305 {
276 d_ptr->replace(index,value);
306 d_ptr->replace(index,value);
277 emit valueChanged(index);
307 emit valueChanged(index);
278 }
308 }
279
309
280 /*!
310 /*!
281 Sets a new value \a value to set, indexed by \a index
311 Sets a new value \a value to set, indexed by \a index
282 */
312 */
283 void QBarSet::replace(const int index, const QPointF value)
313 void QBarSet::replace(const int index, const QPointF value)
284 {
314 {
285 d_ptr->replace(index,value);
315 d_ptr->replace(index,value);
286 emit valueChanged(index);
316 emit valueChanged(index);
287 }
317 }
288
318
289 /*!
319 /*!
290 Returns value of set indexed by \a index. Note that all appended values are stored internally as QPointF.
320 Returns value of set indexed by \a index. Note that all appended values are stored internally as QPointF.
291 The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value
321 The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value
292 of the QPointF (if appended with QPointF append).
322 of the QPointF (if appended with QPointF append).
293 If the index is out of bounds QPointF(0, 0.0) is returned.
323 If the index is out of bounds QPointF(0, 0.0) is returned.
294 */
324 */
295 QPointF QBarSet::at(const int index) const
325 QPointF QBarSet::at(const int index) const
296 {
326 {
297 if (index < 0 || index >= d_ptr->m_values.count()) {
327 if (index < 0 || index >= d_ptr->m_values.count()) {
298 return QPointF(index, 0.0);
328 return QPointF(index, 0.0);
299 }
329 }
300
330
301 return d_ptr->m_values.at(index);
331 return d_ptr->m_values.at(index);
302 }
332 }
303
333
304 /*!
334 /*!
305 Returns value of set indexed by \a index. ote that all appended values are stored internally as QPointF.
335 Returns value of set indexed by \a index. ote that all appended values are stored internally as QPointF.
306 The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value
336 The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value
307 of the QPointF (if appended with QPointF append).
337 of the QPointF (if appended with QPointF append).
308 */
338 */
309 QPointF QBarSet::operator [](const int index) const
339 QPointF QBarSet::operator [](const int index) const
310 {
340 {
311 return d_ptr->m_values.at(index);
341 return d_ptr->m_values.at(index);
312 }
342 }
313
343
314 /*!
344 /*!
315 Returns count of values in set.
345 Returns count of values in set.
316 */
346 */
317 int QBarSet::count() const
347 int QBarSet::count() const
318 {
348 {
319 return d_ptr->m_values.count();
349 return d_ptr->m_values.count();
320 }
350 }
321
351
322 /*!
352 /*!
323 Returns sum of all values in barset. The sum is sum of y coordinates in the QPointF representation.
353 Returns sum of all values in barset. The sum is sum of y coordinates in the QPointF representation.
324 */
354 */
325 qreal QBarSet::sum() const
355 qreal QBarSet::sum() const
326 {
356 {
327 qreal total(0);
357 qreal total(0);
328 for (int i=0; i < d_ptr->m_values.count(); i++) {
358 for (int i=0; i < d_ptr->m_values.count(); i++) {
329 //total += d_ptr->m_values.at(i);
359 //total += d_ptr->m_values.at(i);
330 total += d_ptr->m_values.at(i).y();
360 total += d_ptr->m_values.at(i).y();
331 }
361 }
332 return total;
362 return total;
333 }
363 }
334
364
335 /*!
365 /*!
336 Sets pen for set. Bars of this set are drawn using \a pen
366 Sets pen for set. Bars of this set are drawn using \a pen
337 */
367 */
338 void QBarSet::setPen(const QPen &pen)
368 void QBarSet::setPen(const QPen &pen)
339 {
369 {
340 if(d_ptr->m_pen!=pen){
370 if(d_ptr->m_pen!=pen){
341 d_ptr->m_pen = pen;
371 d_ptr->m_pen = pen;
342 emit d_ptr->updatedBars();
372 emit d_ptr->updatedBars();
343 emit penChanged();
373 emit penChanged();
344 }
374 }
345 }
375 }
346
376
347 /*!
377 /*!
348 Returns pen of the set.
378 Returns pen of the set.
349 */
379 */
350 QPen QBarSet::pen() const
380 QPen QBarSet::pen() const
351 {
381 {
352 return d_ptr->m_pen;
382 return d_ptr->m_pen;
353 }
383 }
354
384
355 /*!
385 /*!
356 Sets brush for the set. Bars of this set are drawn using \a brush
386 Sets brush for the set. Bars of this set are drawn using \a brush
357 */
387 */
358 void QBarSet::setBrush(const QBrush &brush)
388 void QBarSet::setBrush(const QBrush &brush)
359 {
389 {
360 if(d_ptr->m_brush!=brush){
390 if(d_ptr->m_brush!=brush){
361 d_ptr->m_brush = brush;
391 d_ptr->m_brush = brush;
362 emit d_ptr->updatedBars();
392 emit d_ptr->updatedBars();
363 emit brushChanged();
393 emit brushChanged();
364 }
394 }
365 }
395 }
366
396
367 /*!
397 /*!
368 Returns brush of the set.
398 Returns brush of the set.
369 */
399 */
370 QBrush QBarSet::brush() const
400 QBrush QBarSet::brush() const
371 {
401 {
372 return d_ptr->m_brush;
402 return d_ptr->m_brush;
373 }
403 }
374
404
375 /*!
405 /*!
376 Sets \a brush of the values that are drawn on top of this barset
406 Sets \a brush of the values that are drawn on top of this barset
377 */
407 */
378 void QBarSet::setLabelBrush(const QBrush &brush)
408 void QBarSet::setLabelBrush(const QBrush &brush)
379 {
409 {
380 if(d_ptr->m_labelBrush!=brush){
410 if(d_ptr->m_labelBrush!=brush){
381 d_ptr->m_labelBrush = brush;
411 d_ptr->m_labelBrush = brush;
382 emit d_ptr->updatedBars();
412 emit d_ptr->updatedBars();
383 emit labelBrushChanged();
413 emit labelBrushChanged();
384 }
414 }
385 }
415 }
386
416
387 /*!
417 /*!
388 Returns brush of the values that are drawn on top of this barset
418 Returns brush of the values that are drawn on top of this barset
389 */
419 */
390 QBrush QBarSet::labelBrush() const
420 QBrush QBarSet::labelBrush() const
391 {
421 {
392 return d_ptr->m_labelBrush;
422 return d_ptr->m_labelBrush;
393 }
423 }
394
424
395 /*!
425 /*!
396 Sets the \a font for values that are drawn on top of this barset
426 Sets the \a font for values that are drawn on top of this barset
397 */
427 */
398 void QBarSet::setLabelFont(const QFont &font)
428 void QBarSet::setLabelFont(const QFont &font)
399 {
429 {
400 if(d_ptr->m_labelFont!=font) {
430 if(d_ptr->m_labelFont!=font) {
401 d_ptr->m_labelFont = font;
431 d_ptr->m_labelFont = font;
402 emit d_ptr->updatedBars();
432 emit d_ptr->updatedBars();
403 emit labelFontChanged();
433 emit labelFontChanged();
404 }
434 }
405
435
406 }
436 }
407
437
408 /*!
438 /*!
409 Returns the pen for values that are drawn on top of this set
439 Returns the pen for values that are drawn on top of this set
410 */
440 */
411 QFont QBarSet::labelFont() const
441 QFont QBarSet::labelFont() const
412 {
442 {
413 return d_ptr->m_labelFont;
443 return d_ptr->m_labelFont;
414 }
444 }
415
445
446 QColor QBarSet::color()
447 {
448 return brush().color();
449 }
450
451 void QBarSet::setColor(QColor color)
452 {
453 QBrush b = brush();
454 if (b.color() != color) {
455 b.setColor(color);
456 setBrush(b);
457 emit colorChanged(color);
458 }
459 }
460
461 QColor QBarSet::borderColor()
462 {
463 return pen().color();
464 }
465
466 void QBarSet::setBorderColor(QColor color)
467 {
468 QPen p = pen();
469 if (p.color() != color) {
470 p.setColor(color);
471 setPen(p);
472 emit borderColorChanged(color);
473 }
474 }
475
476 QColor QBarSet::labelColor()
477 {
478 return labelBrush().color();
479 }
480
481 void QBarSet::setLabelColor(QColor color)
482 {
483 QBrush b = labelBrush();
484 if (b.color() != color) {
485 b.setColor(color);
486 setLabelBrush(b);
487 emit labelColorChanged(color);
488 }
489 }
490
416 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
491 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
417
492
418 QBarSetPrivate::QBarSetPrivate(const QString label, QBarSet *parent) : QObject(parent),
493 QBarSetPrivate::QBarSetPrivate(const QString label, QBarSet *parent) : QObject(parent),
419 q_ptr(parent),
494 q_ptr(parent),
420 m_label(label)
495 m_label(label)
421 {
496 {
422 }
497 }
423
498
424 QBarSetPrivate::~QBarSetPrivate()
499 QBarSetPrivate::~QBarSetPrivate()
425 {
500 {
426 }
501 }
427
502
428 void QBarSetPrivate::append(QPointF value)
503 void QBarSetPrivate::append(QPointF value)
429 {
504 {
430 m_values.append(value);
505 m_values.append(value);
431 emit restructuredBars();
506 emit restructuredBars();
432 }
507 }
433
508
434 void QBarSetPrivate::append(QList<QPointF> values)
509 void QBarSetPrivate::append(QList<QPointF> values)
435 {
510 {
436 for (int i=0; i<values.count(); i++) {
511 for (int i=0; i<values.count(); i++) {
437 m_values.append(values.at(i));
512 m_values.append(values.at(i));
438 }
513 }
439 emit restructuredBars();
514 emit restructuredBars();
440 }
515 }
441
516
442 void QBarSetPrivate::append(QList<qreal> values)
517 void QBarSetPrivate::append(QList<qreal> values)
443 {
518 {
444 int index = m_values.count();
519 int index = m_values.count();
445 for (int i=0; i<values.count(); i++) {
520 for (int i=0; i<values.count(); i++) {
446 m_values.append(QPointF(index,values.at(i)));
521 m_values.append(QPointF(index,values.at(i)));
447 index++;
522 index++;
448 }
523 }
449 emit restructuredBars();
524 emit restructuredBars();
450 }
525 }
451
526
452 void QBarSetPrivate::insert(const int index, const qreal value)
527 void QBarSetPrivate::insert(const int index, const qreal value)
453 {
528 {
454 m_values.insert(index, QPointF(index, value));
529 m_values.insert(index, QPointF(index, value));
455 emit restructuredBars();
530 emit restructuredBars();
456 }
531 }
457
532
458 void QBarSetPrivate::insert(const int index, const QPointF value)
533 void QBarSetPrivate::insert(const int index, const QPointF value)
459 {
534 {
460 m_values.insert(index, value);
535 m_values.insert(index, value);
461 emit restructuredBars();
536 emit restructuredBars();
462 }
537 }
463
538
464 bool QBarSetPrivate::remove(const int index, const int count)
539 bool QBarSetPrivate::remove(const int index, const int count)
465 {
540 {
466 if ((index + count) > m_values.count()) {
541 if ((index + count) > m_values.count()) {
467 // cant remove more values than there are
542 // cant remove more values than there are
468 return false;
543 return false;
469 }
544 }
470 int c = count;
545 int c = count;
471 while (c > 0) {
546 while (c > 0) {
472 m_values.removeAt(index);
547 m_values.removeAt(index);
473 c--;
548 c--;
474 }
549 }
475 emit restructuredBars();
550 emit restructuredBars();
476 return true;
551 return true;
477 }
552 }
478
553
479 void QBarSetPrivate::replace(const int index, const qreal value)
554 void QBarSetPrivate::replace(const int index, const qreal value)
480 {
555 {
481 m_values.replace(index,QPointF(index,value));
556 m_values.replace(index,QPointF(index,value));
482 emit updatedBars();
557 emit updatedBars();
483 }
558 }
484
559
485 void QBarSetPrivate::replace(const int index, const QPointF value)
560 void QBarSetPrivate::replace(const int index, const QPointF value)
486 {
561 {
487 m_values.replace(index,value);
562 m_values.replace(index,value);
488 emit updatedBars();
563 emit updatedBars();
489 }
564 }
490
565
491 #include "moc_qbarset.cpp"
566 #include "moc_qbarset.cpp"
492 #include "moc_qbarset_p.cpp"
567 #include "moc_qbarset_p.cpp"
493
568
494 QTCOMMERCIALCHART_END_NAMESPACE
569 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,100 +1,115
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 QBARSET_H
21 #ifndef QBARSET_H
22 #define QBARSET_H
22 #define QBARSET_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <QPen>
25 #include <QPen>
26 #include <QBrush>
26 #include <QBrush>
27 #include <QFont>
27 #include <QFont>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 class QBarSetPrivate;
30 class QBarSetPrivate;
31
31
32 class QTCOMMERCIALCHART_EXPORT QBarSet : public QObject
32 class QTCOMMERCIALCHART_EXPORT QBarSet : public QObject
33 {
33 {
34 Q_OBJECT
34 Q_OBJECT
35 Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged)
35 Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged)
36 Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
36 Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
37 Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
37 Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
38 Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged)
38 Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged)
39 Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged)
39 Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged)
40 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
41 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged)
42 Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged)
40
43
41 public:
44 public:
42 explicit QBarSet(const QString label, QObject *parent = 0);
45 explicit QBarSet(const QString label, QObject *parent = 0);
43 virtual ~QBarSet();
46 virtual ~QBarSet();
44
47
45 void setLabel(const QString label);
48 void setLabel(const QString label);
46 QString label() const;
49 QString label() const;
47
50
48 void append(const QPointF value);
51 void append(const QPointF value);
49 void append(const QList<QPointF> values);
52 void append(const QList<QPointF> values);
50 void append(const qreal value);
53 void append(const qreal value);
51 void append(const QList<qreal> values);
54 void append(const QList<qreal> values);
52
55
53 QBarSet& operator << (const qreal &value);
56 QBarSet& operator << (const qreal &value);
54 QBarSet& operator << (const QPointF &value);
57 QBarSet& operator << (const QPointF &value);
55
58
56 void insert(const int index, const qreal value);
59 void insert(const int index, const qreal value);
57 void insert(const int index, const QPointF value);
60 void insert(const int index, const QPointF value);
58 bool remove(const int index, const int count = 1);
61 bool remove(const int index, const int count = 1);
59 void replace(const int index, const qreal value);
62 void replace(const int index, const qreal value);
60 void replace(const int index, const QPointF value);
63 void replace(const int index, const QPointF value);
61 QPointF at(const int index) const;
64 QPointF at(const int index) const;
62 QPointF operator [] (const int index) const;
65 QPointF operator [] (const int index) const;
63 int count() const;
66 int count() const;
64 qreal sum() const;
67 qreal sum() const;
65
68
66 void setPen(const QPen &pen);
69 void setPen(const QPen &pen);
67 QPen pen() const;
70 QPen pen() const;
68
71
69 void setBrush(const QBrush &brush);
72 void setBrush(const QBrush &brush);
70 QBrush brush() const;
73 QBrush brush() const;
71
74
72 void setLabelBrush(const QBrush &brush);
75 void setLabelBrush(const QBrush &brush);
73 QBrush labelBrush() const;
76 QBrush labelBrush() const;
74
77
75 void setLabelFont(const QFont &font);
78 void setLabelFont(const QFont &font);
76 QFont labelFont() const;
79 QFont labelFont() const;
77
80
81 QColor color();
82 void setColor(QColor color);
83
84 QColor borderColor();
85 void setBorderColor(QColor color);
86
87 QColor labelColor();
88 void setLabelColor(QColor color);
89
78 Q_SIGNALS:
90 Q_SIGNALS:
79 void penChanged();
91 void penChanged();
80 void brushChanged();
92 void brushChanged();
81 void labelChanged();
93 void labelChanged();
82 void labelBrushChanged();
94 void labelBrushChanged();
83 void labelFontChanged();
95 void labelFontChanged();
96 void colorChanged(QColor color);
97 void borderColorChanged(QColor color);
98 void labelColorChanged(QColor color);
84
99
85 void valuesAdded(int index, int count);
100 void valuesAdded(int index, int count);
86 void valuesRemoved(int index, int count);
101 void valuesRemoved(int index, int count);
87 void valueChanged(int index);
102 void valueChanged(int index);
88
103
89 private:
104 private:
90 QScopedPointer<QBarSetPrivate> d_ptr;
105 QScopedPointer<QBarSetPrivate> d_ptr;
91 Q_DISABLE_COPY(QBarSet)
106 Q_DISABLE_COPY(QBarSet)
92 friend class QBarSeries;
107 friend class QBarSeries;
93 friend class BarLegendMarker;
108 friend class BarLegendMarker;
94 friend class BarChartItem;
109 friend class BarChartItem;
95 friend class QBarSeriesPrivate;
110 friend class QBarSeriesPrivate;
96 };
111 };
97
112
98 QTCOMMERCIALCHART_END_NAMESPACE
113 QTCOMMERCIALCHART_END_NAMESPACE
99
114
100 #endif // QBARSET_H
115 #endif // QBARSET_H
@@ -1,350 +1,350
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 "qxyseries.h"
21 #include "qxyseries.h"
22 #include "qxyseries_p.h"
22 #include "qxyseries_p.h"
23 #include "domain_p.h"
23 #include "domain_p.h"
24 #include "legendmarker_p.h"
24 #include "legendmarker_p.h"
25
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 /*!
28 /*!
29 \class QXYSeries
29 \class QXYSeries
30 \brief The QXYSeries class is a base class for line, spline and scatter series.
30 \brief The QXYSeries class is a base class for line, spline and scatter series.
31 */
31 */
32
32
33 /*!
33 /*!
34 \property QXYSeries::pointsVisible
34 \property QXYSeries::pointsVisible
35
35
36 Controls if the data points are visible and should be drawn.
36 Controls if the data points are visible and should be drawn.
37 */
37 */
38
38
39 /*!
39 /*!
40 \property QXYSeries::count
41
42 Number of points in the series.
43 */
44
45 /*!
46 \fn QPen QXYSeries::pen() const
40 \fn QPen QXYSeries::pen() const
47 \brief Returns pen used to draw points for series.
41 \brief Returns pen used to draw points for series.
48 \sa setPen()
42 \sa setPen()
49 */
43 */
50
44
51 /*!
45 /*!
52 \fn QBrush QXYSeries::brush() const
46 \fn QBrush QXYSeries::brush() const
53 \brief Returns brush used to draw points for series.
47 \brief Returns brush used to draw points for series.
54 \sa setBrush()
48 \sa setBrush()
55 */
49 */
56
50
57 /*!
51 /*!
58 \fn void QXYSeries::clicked(const QPointF& point)
52 \fn void QXYSeries::clicked(const QPointF& point)
59 \brief Signal is emitted when user clicks the \a point on chart.
53 \brief Signal is emitted when user clicks the \a point on chart.
60 */
54 */
61
55
62 /*!
56 /*!
63 \fn void QXYSeries::pointReplaced(int index)
57 \fn void QXYSeries::pointReplaced(int index)
64 \brief Signal is emitted when user replaces a point at \a index.
58 \brief Signal is emitted when user replaces a point at \a index.
65 \sa replace()
59 \sa replace()
66 */
60 */
67
61
68 /*!
62 /*!
69 \fn void QXYSeries::pointAdded(int index)
63 \fn void QXYSeries::pointAdded(int index)
70 \brief Signal is emitted when user adds a point at \a index.
64 \brief Signal is emitted when user adds a point at \a index.
71 \sa append(), insert()
65 \sa append(), insert()
72 */
66 */
73
67
74 /*!
68 /*!
75 \fn void QXYSeries::pointRemoved(int index)
69 \fn void QXYSeries::pointRemoved(int index)
76 \brief Signal is emitted when user removes a point at \a index.
70 \brief Signal is emitted when user removes a point at \a index.
77 \sa remove()
71 \sa remove()
78 */
72 */
79
73
80 /*!
74 /*!
75 \fn void QXYSeries::pointsVisibleChanged(bool visible)
76 \brief Signal is emitted when the point visibility has changed to \a visible.
77 */
78
79 /*!
81 \fn void QXYSeriesPrivate::updated()
80 \fn void QXYSeriesPrivate::updated()
82 \brief \internal
81 \brief \internal
83 */
82 */
84
83
85 /*!
84 /*!
86 \internal
85 \internal
87
86
88 Constructs empty series object which is a child of \a parent.
87 Constructs empty series object which is a child of \a parent.
89 When series object is added to QChartView or QChart instance ownerships is transferred.
88 When series object is added to QChartView or QChart instance ownerships is transferred.
90 */
89 */
91 QXYSeries::QXYSeries(QXYSeriesPrivate &d,QObject *parent) : QAbstractSeries(d, parent)
90 QXYSeries::QXYSeries(QXYSeriesPrivate &d,QObject *parent) : QAbstractSeries(d, parent)
92 {
91 {
93 }
92 }
94
93
95 /*!
94 /*!
96 Destroys the object. Series added to QChartView or QChart instances are owned by those,
95 Destroys the object. Series added to QChartView or QChart instances are owned by those,
97 and are deleted when mentioned object are destroyed.
96 and are deleted when mentioned object are destroyed.
98 */
97 */
99 QXYSeries::~QXYSeries()
98 QXYSeries::~QXYSeries()
100 {
99 {
101 }
100 }
102
101
103 /*!
102 /*!
104 Adds data point \a x \a y to the series. Points are connected with lines on the chart.
103 Adds data point \a x \a y to the series. Points are connected with lines on the chart.
105 */
104 */
106 void QXYSeries::append(qreal x,qreal y)
105 void QXYSeries::append(qreal x,qreal y)
107 {
106 {
108 append(QPointF(x,y));
107 append(QPointF(x,y));
109 }
108 }
110
109
111 /*!
110 /*!
112 This is an overloaded function.
111 This is an overloaded function.
113 Adds data \a point to the series. Points are connected with lines on the chart.
112 Adds data \a point to the series. Points are connected with lines on the chart.
114 */
113 */
115 void QXYSeries::append(const QPointF &point)
114 void QXYSeries::append(const QPointF &point)
116 {
115 {
117 Q_D(QXYSeries);
116 Q_D(QXYSeries);
118 d->m_points<<point;
117 d->m_points<<point;
119 // emit d->pointAdded(d->m_points.count()-1);
118 // emit d->pointAdded(d->m_points.count()-1);
120 emit pointAdded(d->m_points.count()-1);
119 emit pointAdded(d->m_points.count()-1);
121 }
120 }
122
121
123 /*!
122 /*!
124 This is an overloaded function.
123 This is an overloaded function.
125 Adds list of data \a points to the series. Points are connected with lines on the chart.
124 Adds list of data \a points to the series. Points are connected with lines on the chart.
126 */
125 */
127 void QXYSeries::append(const QList<QPointF> &points)
126 void QXYSeries::append(const QList<QPointF> &points)
128 {
127 {
129 foreach(const QPointF& point , points) {
128 foreach(const QPointF& point , points) {
130 append(point);
129 append(point);
131 }
130 }
132 }
131 }
133
132
134 /*!
133 /*!
135 Replaces data point \a oldX \a oldY with data point \a newX \a newY.
134 Replaces data point \a oldX \a oldY with data point \a newX \a newY.
136 */
135 */
137 void QXYSeries::replace(qreal oldX,qreal oldY,qreal newX,qreal newY)
136 void QXYSeries::replace(qreal oldX,qreal oldY,qreal newX,qreal newY)
138 {
137 {
139 replace(QPointF(oldX,oldY),QPointF(newX,newY));
138 replace(QPointF(oldX,oldY),QPointF(newX,newY));
140 }
139 }
141
140
142 /*!
141 /*!
143 Replaces \a oldPoint with \a newPoint.
142 Replaces \a oldPoint with \a newPoint.
144 */
143 */
145 void QXYSeries::replace(const QPointF &oldPoint,const QPointF &newPoint)
144 void QXYSeries::replace(const QPointF &oldPoint,const QPointF &newPoint)
146 {
145 {
147 Q_D(QXYSeries);
146 Q_D(QXYSeries);
148 int index = d->m_points.indexOf(oldPoint);
147 int index = d->m_points.indexOf(oldPoint);
149 if(index==-1) return;
148 if(index==-1) return;
150 d->m_points[index] = newPoint;
149 d->m_points[index] = newPoint;
151 // emit d->pointReplaced(index);
150 // emit d->pointReplaced(index);
152 emit pointReplaced(index);
151 emit pointReplaced(index);
153 }
152 }
154
153
155 /*!
154 /*!
156 Removes current \a x and \a y value.
155 Removes current \a x and \a y value.
157 */
156 */
158 void QXYSeries::remove(qreal x,qreal y)
157 void QXYSeries::remove(qreal x,qreal y)
159 {
158 {
160 remove(QPointF(x,y));
159 remove(QPointF(x,y));
161 }
160 }
162
161
163 /*!
162 /*!
164 Removes current \a point x value.
163 Removes current \a point x value.
165
164
166 Note: point y value is ignored.
165 Note: point y value is ignored.
167 */
166 */
168 void QXYSeries::remove(const QPointF &point)
167 void QXYSeries::remove(const QPointF &point)
169 {
168 {
170 Q_D(QXYSeries);
169 Q_D(QXYSeries);
171 int index = d->m_points.indexOf(point);
170 int index = d->m_points.indexOf(point);
172 if(index==-1) return;
171 if(index==-1) return;
173 d->m_points.remove(index);
172 d->m_points.remove(index);
174 // emit d->pointRemoved(index);
173 // emit d->pointRemoved(index);
175 emit pointRemoved(index);
174 emit pointRemoved(index);
176 }
175 }
177
176
178 /*!
177 /*!
179 Inserts a \a point in the series at \a index position.
178 Inserts a \a point in the series at \a index position.
180 */
179 */
181 void QXYSeries::insert(int index, const QPointF &point)
180 void QXYSeries::insert(int index, const QPointF &point)
182 {
181 {
183 Q_D(QXYSeries);
182 Q_D(QXYSeries);
184 d->m_points.insert(index, point);
183 d->m_points.insert(index, point);
185 // emit d->pointAdded(index);
184 // emit d->pointAdded(index);
186 emit pointAdded(index);
185 emit pointAdded(index);
187 }
186 }
188
187
189 /*!
188 /*!
190 Removes all points from the series.
189 Removes all points from the series.
191 */
190 */
192 void QXYSeries::clear()
191 void QXYSeries::clear()
193 {
192 {
194 Q_D(QXYSeries);
193 Q_D(QXYSeries);
195 for (int i = d->m_points.size() - 1; i >= 0; i--)
194 for (int i = d->m_points.size() - 1; i >= 0; i--)
196 remove(d->m_points.at(i));
195 remove(d->m_points.at(i));
197 }
196 }
198
197
199 /*!
198 /*!
200 \internal \a pos
199 \internal \a pos
201 */
200 */
202 QList<QPointF> QXYSeries::points() const
201 QList<QPointF> QXYSeries::points() const
203 {
202 {
204 Q_D(const QXYSeries);
203 Q_D(const QXYSeries);
205 return d->m_points.toList();
204 return d->m_points.toList();
206 }
205 }
207
206
208 /*!
207 /*!
209 Returns number of data points within series.
208 Returns number of data points within series.
210 */
209 */
211 int QXYSeries::count() const
210 int QXYSeries::count() const
212 {
211 {
213 Q_D(const QXYSeries);
212 Q_D(const QXYSeries);
214 return d->m_points.count();
213 return d->m_points.count();
215 }
214 }
216
215
217
216
218 /*!
217 /*!
219 Sets \a pen used for drawing points on the chart. If the pen is not defined, the
218 Sets \a pen used for drawing points on the chart. If the pen is not defined, the
220 pen from chart theme is used.
219 pen from chart theme is used.
221 \sa QChart::setTheme()
220 \sa QChart::setTheme()
222 */
221 */
223 void QXYSeries::setPen(const QPen &pen)
222 void QXYSeries::setPen(const QPen &pen)
224 {
223 {
225 Q_D(QXYSeries);
224 Q_D(QXYSeries);
226 if (d->m_pen!=pen) {
225 if (d->m_pen!=pen) {
227 d->m_pen = pen;
226 d->m_pen = pen;
228 emit d->updated();
227 emit d->updated();
229 }
228 }
230 }
229 }
231
230
232 QPen QXYSeries::pen() const
231 QPen QXYSeries::pen() const
233 {
232 {
234 Q_D(const QXYSeries);
233 Q_D(const QXYSeries);
235 return d->m_pen;
234 return d->m_pen;
236 }
235 }
237
236
238 /*!
237 /*!
239 Sets \a brush used for drawing points on the chart. If the brush is not defined, brush
238 Sets \a brush used for drawing points on the chart. If the brush is not defined, brush
240 from chart theme setting is used.
239 from chart theme setting is used.
241 \sa QChart::setTheme()
240 \sa QChart::setTheme()
242 */
241 */
243 void QXYSeries::setBrush(const QBrush &brush)
242 void QXYSeries::setBrush(const QBrush &brush)
244 {
243 {
245 Q_D(QXYSeries);
244 Q_D(QXYSeries);
246 if (d->m_brush!=brush) {
245 if (d->m_brush!=brush) {
247 d->m_brush = brush;
246 d->m_brush = brush;
248 emit d->updated();
247 emit d->updated();
249 }
248 }
250 }
249 }
251
250
252 QBrush QXYSeries::brush() const
251 QBrush QXYSeries::brush() const
253 {
252 {
254 Q_D(const QXYSeries);
253 Q_D(const QXYSeries);
255 return d->m_brush;
254 return d->m_brush;
256 }
255 }
257
256
258
257
259 void QXYSeries::setPointsVisible(bool visible)
258 void QXYSeries::setPointsVisible(bool visible)
260 {
259 {
261 Q_D(QXYSeries);
260 Q_D(QXYSeries);
262 if (d->m_pointsVisible != visible){
261 if (d->m_pointsVisible != visible){
263 d->m_pointsVisible = visible;
262 d->m_pointsVisible = visible;
264 emit d->updated();
263 emit d->updated();
264 emit pointsVisibleChanged(visible);
265 }
265 }
266 }
266 }
267
267
268 bool QXYSeries::pointsVisible() const
268 bool QXYSeries::pointsVisible() const
269 {
269 {
270 Q_D(const QXYSeries);
270 Q_D(const QXYSeries);
271 return d->m_pointsVisible;
271 return d->m_pointsVisible;
272 }
272 }
273
273
274
274
275 /*!
275 /*!
276 Stream operator for adding a data \a point to the series.
276 Stream operator for adding a data \a point to the series.
277 \sa append()
277 \sa append()
278 */
278 */
279 QXYSeries& QXYSeries::operator<< (const QPointF &point)
279 QXYSeries& QXYSeries::operator<< (const QPointF &point)
280 {
280 {
281 append(point);
281 append(point);
282 return *this;
282 return *this;
283 }
283 }
284
284
285
285
286 /*!
286 /*!
287 Stream operator for adding a list of \a points to the series.
287 Stream operator for adding a list of \a points to the series.
288 \sa append()
288 \sa append()
289 */
289 */
290
290
291 QXYSeries& QXYSeries::operator<< (const QList<QPointF>& points)
291 QXYSeries& QXYSeries::operator<< (const QList<QPointF>& points)
292 {
292 {
293 append(points);
293 append(points);
294 return *this;
294 return *this;
295 }
295 }
296
296
297 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
297 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
298
298
299
299
300 QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) :
300 QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) :
301 QAbstractSeriesPrivate(q),
301 QAbstractSeriesPrivate(q),
302 m_pointsVisible(false)
302 m_pointsVisible(false)
303 {
303 {
304 }
304 }
305
305
306 void QXYSeriesPrivate::scaleDomain(Domain& domain)
306 void QXYSeriesPrivate::scaleDomain(Domain& domain)
307 {
307 {
308 qreal minX(domain.minX());
308 qreal minX(domain.minX());
309 qreal minY(domain.minY());
309 qreal minY(domain.minY());
310 qreal maxX(domain.maxX());
310 qreal maxX(domain.maxX());
311 qreal maxY(domain.maxY());
311 qreal maxY(domain.maxY());
312 int tickXCount(domain.tickXCount());
312 int tickXCount(domain.tickXCount());
313 int tickYCount(domain.tickYCount());
313 int tickYCount(domain.tickYCount());
314
314
315 Q_Q(QXYSeries);
315 Q_Q(QXYSeries);
316
316
317 const QList<QPointF>& points = q->points();
317 const QList<QPointF>& points = q->points();
318
318
319
319
320 if(points.isEmpty()){
320 if(points.isEmpty()){
321 minX=0.0;
321 minX=0.0;
322 minY=0.0;
322 minY=0.0;
323 maxX=1.0;
323 maxX=1.0;
324 maxY=1.0;
324 maxY=1.0;
325 }
325 }
326
326
327 for (int i = 0; i < points.count(); i++)
327 for (int i = 0; i < points.count(); i++)
328 {
328 {
329 qreal x = points[i].x();
329 qreal x = points[i].x();
330 qreal y = points[i].y();
330 qreal y = points[i].y();
331 minX = qMin(minX, x);
331 minX = qMin(minX, x);
332 minY = qMin(minY, y);
332 minY = qMin(minY, y);
333 maxX = qMax(maxX, x);
333 maxX = qMax(maxX, x);
334 maxY = qMax(maxY, y);
334 maxY = qMax(maxY, y);
335 }
335 }
336
336
337 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
337 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
338 }
338 }
339
339
340 QList<LegendMarker*> QXYSeriesPrivate::createLegendMarker(QLegend* legend)
340 QList<LegendMarker*> QXYSeriesPrivate::createLegendMarker(QLegend* legend)
341 {
341 {
342 Q_Q(QXYSeries);
342 Q_Q(QXYSeries);
343 QList<LegendMarker*> list;
343 QList<LegendMarker*> list;
344 return list << new XYLegendMarker(q,legend);
344 return list << new XYLegendMarker(q,legend);
345 }
345 }
346
346
347 #include "moc_qxyseries.cpp"
347 #include "moc_qxyseries.cpp"
348 #include "moc_qxyseries_p.cpp"
348 #include "moc_qxyseries_p.cpp"
349
349
350 QTCOMMERCIALCHART_END_NAMESPACE
350 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,87 +1,88
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 QXYSERIES_H
21 #ifndef QXYSERIES_H
22 #define QXYSERIES_H
22 #define QXYSERIES_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <qabstractseries.h>
25 #include <qabstractseries.h>
26 #include <QPen>
26 #include <QPen>
27 #include <QBrush>
27 #include <QBrush>
28
28
29 class QModelIndex;
29 class QModelIndex;
30
30
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32
32
33 class QXYSeriesPrivate;
33 class QXYSeriesPrivate;
34 class QXYModelMapper;
34 class QXYModelMapper;
35
35
36 class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries
36 class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries
37 {
37 {
38 Q_OBJECT
38 Q_OBJECT
39 Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible)
39 Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible NOTIFY pointsVisibleChanged)
40 Q_PROPERTY(int count READ count)
41
40
42 protected:
41 protected:
43 explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0);
42 explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0);
44
43
45 public:
44 public:
46 ~QXYSeries();
45 ~QXYSeries();
47 void append(qreal x, qreal y);
46 void append(qreal x, qreal y);
48 void append(const QPointF &point);
47 void append(const QPointF &point);
49 void append(const QList<QPointF> &points);
48 void append(const QList<QPointF> &points);
50 void replace(qreal oldX,qreal oldY,qreal newX,qreal newY);
49 void replace(qreal oldX,qreal oldY,qreal newX,qreal newY);
51 void replace(const QPointF &oldPoint,const QPointF &newPoint);
50 void replace(const QPointF &oldPoint,const QPointF &newPoint);
52 void remove(qreal x, qreal y);
51 void remove(qreal x, qreal y);
53 void remove(const QPointF &point);
52 void remove(const QPointF &point);
54 void insert(int index, const QPointF &point);
53 void insert(int index, const QPointF &point);
55 void clear();
54 void clear();
56
55
57 int count() const;
56 int count() const;
58 QList<QPointF> points() const;
57 QList<QPointF> points() const;
59
58
60 QXYSeries& operator << (const QPointF &point);
59 QXYSeries& operator << (const QPointF &point);
61 QXYSeries& operator << (const QList<QPointF> &points);
60 QXYSeries& operator << (const QList<QPointF> &points);
62
61
63 void setPen(const QPen &pen);
62 void setPen(const QPen &pen);
64 QPen pen() const;
63 QPen pen() const;
65
64
66 void setBrush(const QBrush &brush);
65 void setBrush(const QBrush &brush);
67 QBrush brush() const;
66 QBrush brush() const;
68
67
69 void setPointsVisible(bool visible = true);
68 void setPointsVisible(bool visible = true);
70 bool pointsVisible() const;
69 bool pointsVisible() const;
71
70
72 Q_SIGNALS:
71 Q_SIGNALS:
73 void clicked(const QPointF &point);
72 void clicked(const QPointF &point);
74 void pointReplaced(int index);
73 void pointReplaced(int index);
75 void pointRemoved(int index);
74 void pointRemoved(int index);
76 void pointAdded(int index);
75 void pointAdded(int index);
76 void pointsVisibleChanged(bool visible);
77
77
78
78 private:
79 private:
79 Q_DECLARE_PRIVATE(QXYSeries)
80 Q_DECLARE_PRIVATE(QXYSeries)
80 Q_DISABLE_COPY(QXYSeries)
81 Q_DISABLE_COPY(QXYSeries)
81 friend class XYLegendMarker;
82 friend class XYLegendMarker;
82 friend class XYChart;
83 friend class XYChart;
83 };
84 };
84
85
85 QTCOMMERCIALCHART_END_NAMESPACE
86 QTCOMMERCIALCHART_END_NAMESPACE
86
87
87 #endif
88 #endif
@@ -1,428 +1,435
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 <QtTest/QtTest>
21 #include <QtTest/QtTest>
22 #include <qbarset.h>
22 #include <qbarset.h>
23 #include <qgroupedbarseries.h>
23 #include <qgroupedbarseries.h>
24 #include <qchartview.h>
24 #include <qchartview.h>
25
25
26 QTCOMMERCIALCHART_USE_NAMESPACE
26 QTCOMMERCIALCHART_USE_NAMESPACE
27
27
28 class tst_QBarSet : public QObject
28 class tst_QBarSet : public QObject
29 {
29 {
30 Q_OBJECT
30 Q_OBJECT
31
31
32 public slots:
32 public slots:
33 void initTestCase();
33 void initTestCase();
34 void cleanupTestCase();
34 void cleanupTestCase();
35 void init();
35 void init();
36 void cleanup();
36 void cleanup();
37
37
38 private slots:
38 private slots:
39 void qbarset_data();
39 void qbarset_data();
40 void qbarset();
40 void qbarset();
41 void label_data();
41 void label_data();
42 void label();
42 void label();
43 void append_data();
43 void append_data();
44 void append();
44 void append();
45 void appendOperator_data();
45 void appendOperator_data();
46 void appendOperator();
46 void appendOperator();
47 void insert_data();
47 void insert_data();
48 void insert();
48 void insert();
49 void remove_data();
49 void remove_data();
50 void remove();
50 void remove();
51 void replace_data();
51 void replace_data();
52 void replace();
52 void replace();
53 void at_data();
53 void at_data();
54 void at();
54 void at();
55 void atOperator_data();
55 void atOperator_data();
56 void atOperator();
56 void atOperator();
57 void count_data();
57 void count_data();
58 void count();
58 void count();
59 void sum_data();
59 void sum_data();
60 void sum();
60 void sum();
61 void customize();
61 void customize();
62
62
63 private:
63 private:
64 QBarSet* m_barset;
64 QBarSet* m_barset;
65 };
65 };
66
66
67 void tst_QBarSet::initTestCase()
67 void tst_QBarSet::initTestCase()
68 {
68 {
69 }
69 }
70
70
71 void tst_QBarSet::cleanupTestCase()
71 void tst_QBarSet::cleanupTestCase()
72 {
72 {
73 }
73 }
74
74
75 void tst_QBarSet::init()
75 void tst_QBarSet::init()
76 {
76 {
77 m_barset = new QBarSet(QString("label"));
77 m_barset = new QBarSet(QString("label"));
78 }
78 }
79
79
80 void tst_QBarSet::cleanup()
80 void tst_QBarSet::cleanup()
81 {
81 {
82 delete m_barset;
82 delete m_barset;
83 m_barset = 0;
83 m_barset = 0;
84 }
84 }
85
85
86 void tst_QBarSet::qbarset_data()
86 void tst_QBarSet::qbarset_data()
87 {
87 {
88 }
88 }
89
89
90 void tst_QBarSet::qbarset()
90 void tst_QBarSet::qbarset()
91 {
91 {
92 QBarSet barset(QString("label"));
92 QBarSet barset(QString("label"));
93 QCOMPARE(barset.label(), QString("label"));
93 QCOMPARE(barset.label(), QString("label"));
94 QCOMPARE(barset.count(), 0);
94 QCOMPARE(barset.count(), 0);
95 QVERIFY(qFuzzyIsNull(barset.sum()));
95 QVERIFY(qFuzzyIsNull(barset.sum()));
96 }
96 }
97
97
98 void tst_QBarSet::label_data()
98 void tst_QBarSet::label_data()
99 {
99 {
100 QTest::addColumn<QString> ("label");
100 QTest::addColumn<QString> ("label");
101 QTest::addColumn<QString> ("result");
101 QTest::addColumn<QString> ("result");
102 QTest::newRow("label0") << QString("label0") << QString("label0");
102 QTest::newRow("label0") << QString("label0") << QString("label0");
103 QTest::newRow("label1") << QString("label1") << QString("label1");
103 QTest::newRow("label1") << QString("label1") << QString("label1");
104 }
104 }
105
105
106 void tst_QBarSet::label()
106 void tst_QBarSet::label()
107 {
107 {
108 QFETCH(QString, label);
108 QFETCH(QString, label);
109 QFETCH(QString, result);
109 QFETCH(QString, result);
110
110
111 QSignalSpy labelSpy(m_barset,SIGNAL(labelChanged()));
111 QSignalSpy labelSpy(m_barset,SIGNAL(labelChanged()));
112 m_barset->setLabel(label);
112 m_barset->setLabel(label);
113 QCOMPARE(m_barset->label(), result);
113 QCOMPARE(m_barset->label(), result);
114 QVERIFY(labelSpy.count() == 1);
114 QVERIFY(labelSpy.count() == 1);
115 }
115 }
116
116
117 void tst_QBarSet::append_data()
117 void tst_QBarSet::append_data()
118 {
118 {
119 QTest::addColumn<int> ("count");
119 QTest::addColumn<int> ("count");
120 QTest::newRow("0") << 0;
120 QTest::newRow("0") << 0;
121 QTest::newRow("5") << 5;
121 QTest::newRow("5") << 5;
122 QTest::newRow("100") << 100;
122 QTest::newRow("100") << 100;
123 QTest::newRow("1000") << 1000;
123 QTest::newRow("1000") << 1000;
124 }
124 }
125
125
126 void tst_QBarSet::append()
126 void tst_QBarSet::append()
127 {
127 {
128 QFETCH(int, count);
128 QFETCH(int, count);
129
129
130 QCOMPARE(m_barset->count(), 0);
130 QCOMPARE(m_barset->count(), 0);
131 QVERIFY(qFuzzyIsNull(m_barset->sum()));
131 QVERIFY(qFuzzyIsNull(m_barset->sum()));
132
132
133 QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int)));
133 QSignalSpy valueSpy(m_barset, SIGNAL(valuesAdded(int,int)));
134 QSignalSpy countSpy(m_barset, SIGNAL(countChanged(int)));
134
135
135 qreal sum(0.0);
136 qreal sum(0.0);
136 qreal value(0.0);
137 qreal value(0.0);
137
138
138 for (int i=0; i<count; i++) {
139 for (int i=0; i<count; i++) {
139 m_barset->append(value);
140 m_barset->append(value);
140 QCOMPARE(m_barset->at(i).y(), value);
141 QCOMPARE(m_barset->at(i).y(), value);
141 sum += value;
142 sum += value;
142 value += 1.0;
143 value += 1.0;
143 }
144 }
144
145
145 QCOMPARE(m_barset->count(), count);
146 QCOMPARE(m_barset->count(), count);
146 QVERIFY(qFuzzyCompare(m_barset->sum(), sum));
147 QVERIFY(qFuzzyCompare(m_barset->sum(), sum));
147
148
148 QVERIFY(valueSpy.count() == count);
149 QCOMPARE(valueSpy.count(), count);
150 QCOMPARE(countSpy.count(), count);
149 }
151 }
150
152
151 void tst_QBarSet::appendOperator_data()
153 void tst_QBarSet::appendOperator_data()
152 {
154 {
153 append_data();
155 append_data();
154 }
156 }
155
157
156 void tst_QBarSet::appendOperator()
158 void tst_QBarSet::appendOperator()
157 {
159 {
158 QFETCH(int, count);
160 QFETCH(int, count);
159
161
160 QCOMPARE(m_barset->count(), 0);
162 QCOMPARE(m_barset->count(), 0);
161 QVERIFY(qFuzzyIsNull(m_barset->sum()));
163 QVERIFY(qFuzzyIsNull(m_barset->sum()));
162
164
163 QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int)));
165 QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int)));
166 QSignalSpy countSpy(m_barset, SIGNAL(countChanged(int)));
164
167
165 qreal sum(0.0);
168 qreal sum(0.0);
166 qreal value(0.0);
169 qreal value(0.0);
167
170
168 for (int i=0; i<count; i++) {
171 for (int i=0; i<count; i++) {
169 *m_barset << value;
172 *m_barset << value;
170 QCOMPARE(m_barset->at(i).y(), value);
173 QCOMPARE(m_barset->at(i).y(), value);
171 sum += value;
174 sum += value;
172 value += 1.0;
175 value += 1.0;
173 }
176 }
174
177
175 QCOMPARE(m_barset->count(), count);
178 QCOMPARE(m_barset->count(), count);
176 QVERIFY(qFuzzyCompare(m_barset->sum(), sum));
179 QVERIFY(qFuzzyCompare(m_barset->sum(), sum));
177 QVERIFY(valueSpy.count() == count);
180 QCOMPARE(valueSpy.count(), count);
178
181 QCOMPARE(countSpy.count(), count);
179 }
182 }
180
183
181 void tst_QBarSet::insert_data()
184 void tst_QBarSet::insert_data()
182 {
185 {
183 }
186 }
184
187
185 void tst_QBarSet::insert()
188 void tst_QBarSet::insert()
186 {
189 {
187 QCOMPARE(m_barset->count(), 0);
190 QCOMPARE(m_barset->count(), 0);
188 QVERIFY(qFuzzyIsNull(m_barset->sum()));
191 QVERIFY(qFuzzyIsNull(m_barset->sum()));
189 QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int)));
192 QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int)));
193 QSignalSpy countSpy(m_barset, SIGNAL(countChanged(int)));
190
194
191 m_barset->insert(0, 1.0); // 1.0
195 m_barset->insert(0, 1.0); // 1.0
192 QCOMPARE(m_barset->at(0).y(), 1.0);
196 QCOMPARE(m_barset->at(0).y(), 1.0);
193 QCOMPARE(m_barset->count(), 1);
197 QCOMPARE(m_barset->count(), 1);
194 QVERIFY(qFuzzyCompare(m_barset->sum(), 1.0));
198 QVERIFY(qFuzzyCompare(m_barset->sum(), 1.0));
195
199
196 m_barset->insert(0, 2.0); // 2.0 1.0
200 m_barset->insert(0, 2.0); // 2.0 1.0
197 QCOMPARE(m_barset->at(0).y(), 2.0);
201 QCOMPARE(m_barset->at(0).y(), 2.0);
198 QCOMPARE(m_barset->at(1).y(), 1.0);
202 QCOMPARE(m_barset->at(1).y(), 1.0);
199 QCOMPARE(m_barset->count(), 2);
203 QCOMPARE(m_barset->count(), 2);
200 QVERIFY(qFuzzyCompare(m_barset->sum(), 3.0));
204 QVERIFY(qFuzzyCompare(m_barset->sum(), 3.0));
201
205
202 m_barset->insert(1, 3.0); // 2.0 3.0 1.0
206 m_barset->insert(1, 3.0); // 2.0 3.0 1.0
203 QCOMPARE(m_barset->at(1).y(), 3.0);
207 QCOMPARE(m_barset->at(1).y(), 3.0);
204 QCOMPARE(m_barset->at(0).y(), 2.0);
208 QCOMPARE(m_barset->at(0).y(), 2.0);
205 QCOMPARE(m_barset->at(2).y(), 1.0);
209 QCOMPARE(m_barset->at(2).y(), 1.0);
206 QCOMPARE(m_barset->count(), 3);
210 QCOMPARE(m_barset->count(), 3);
207 QVERIFY(qFuzzyCompare(m_barset->sum(), 6.0));
211 QVERIFY(qFuzzyCompare(m_barset->sum(), 6.0));
208 QVERIFY(valueSpy.count() == 3);
212 QCOMPARE(valueSpy.count(), 3);
213 QCOMPARE(countSpy.count(), 3);
209 }
214 }
210
215
211 void tst_QBarSet::remove_data()
216 void tst_QBarSet::remove_data()
212 {
217 {
213 }
218 }
214
219
215 void tst_QBarSet::remove()
220 void tst_QBarSet::remove()
216 {
221 {
217 QCOMPARE(m_barset->count(), 0);
222 QCOMPARE(m_barset->count(), 0);
218 QVERIFY(qFuzzyIsNull(m_barset->sum()));
223 QVERIFY(qFuzzyIsNull(m_barset->sum()));
219
224
220 QSignalSpy valueSpy(m_barset,SIGNAL(valuesRemoved(int,int)));
225 QSignalSpy valueSpy(m_barset,SIGNAL(valuesRemoved(int,int)));
226 QSignalSpy countSpy(m_barset, SIGNAL(countChanged(int)));
221
227
222 m_barset->append(1.0);
228 m_barset->append(1.0);
223 m_barset->append(2.0);
229 m_barset->append(2.0);
224 m_barset->append(3.0);
230 m_barset->append(3.0);
225 m_barset->append(4.0);
231 m_barset->append(4.0);
226
232
227 QCOMPARE(m_barset->count(), 4);
233 QCOMPARE(m_barset->count(), 4);
228 QCOMPARE(m_barset->sum(), 10.0);
234 QCOMPARE(m_barset->sum(), 10.0);
229
235
230 m_barset->remove(2); // 1.0 2.0 4.0
236 m_barset->remove(2); // 1.0 2.0 4.0
231 QCOMPARE(m_barset->at(0).y(), 1.0);
237 QCOMPARE(m_barset->at(0).y(), 1.0);
232 QCOMPARE(m_barset->at(1).y(), 2.0);
238 QCOMPARE(m_barset->at(1).y(), 2.0);
233 QCOMPARE(m_barset->at(2).y(), 4.0);
239 QCOMPARE(m_barset->at(2).y(), 4.0);
234 QCOMPARE(m_barset->count(), 3);
240 QCOMPARE(m_barset->count(), 3);
235 QCOMPARE(m_barset->sum(), 7.0);
241 QCOMPARE(m_barset->sum(), 7.0);
236
242
237 m_barset->remove(0); // 2.0 4.0
243 m_barset->remove(0); // 2.0 4.0
238 QCOMPARE(m_barset->at(0).y(), 2.0);
244 QCOMPARE(m_barset->at(0).y(), 2.0);
239 QCOMPARE(m_barset->at(1).y(), 4.0);
245 QCOMPARE(m_barset->at(1).y(), 4.0);
240 QCOMPARE(m_barset->count(), 2);
246 QCOMPARE(m_barset->count(), 2);
241 QCOMPARE(m_barset->sum(), 6.0);
247 QCOMPARE(m_barset->sum(), 6.0);
242
248
243 QVERIFY(valueSpy.count() == 2);
249 QCOMPARE(valueSpy.count(), 2);
250 QCOMPARE(countSpy.count(), 6);
244 }
251 }
245
252
246 void tst_QBarSet::replace_data()
253 void tst_QBarSet::replace_data()
247 {
254 {
248
255
249 }
256 }
250
257
251 void tst_QBarSet::replace()
258 void tst_QBarSet::replace()
252 {
259 {
253 QCOMPARE(m_barset->count(), 0);
260 QCOMPARE(m_barset->count(), 0);
254 QVERIFY(qFuzzyIsNull(m_barset->sum()));
261 QVERIFY(qFuzzyIsNull(m_barset->sum()));
255 QSignalSpy valueSpy(m_barset,SIGNAL(valueChanged(int)));
262 QSignalSpy valueSpy(m_barset,SIGNAL(valueChanged(int)));
256
263
257 m_barset->append(1.0);
264 m_barset->append(1.0);
258 m_barset->append(2.0);
265 m_barset->append(2.0);
259 m_barset->append(3.0);
266 m_barset->append(3.0);
260 m_barset->append(4.0);
267 m_barset->append(4.0);
261
268
262 QCOMPARE(m_barset->count(), 4);
269 QCOMPARE(m_barset->count(), 4);
263 QCOMPARE(m_barset->sum(), 10.0);
270 QCOMPARE(m_barset->sum(), 10.0);
264
271
265 m_barset->replace(0, 5.0); // 5.0 2.0 3.0 4.0
272 m_barset->replace(0, 5.0); // 5.0 2.0 3.0 4.0
266 QCOMPARE(m_barset->count(), 4);
273 QCOMPARE(m_barset->count(), 4);
267 QCOMPARE(m_barset->sum(), 14.0);
274 QCOMPARE(m_barset->sum(), 14.0);
268 QCOMPARE(m_barset->at(0).y(), 5.0);
275 QCOMPARE(m_barset->at(0).y(), 5.0);
269
276
270 m_barset->replace(3, 6.0);
277 m_barset->replace(3, 6.0);
271 QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0
278 QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0
272 QCOMPARE(m_barset->sum(), 16.0);
279 QCOMPARE(m_barset->sum(), 16.0);
273 QCOMPARE(m_barset->at(0).y(), 5.0);
280 QCOMPARE(m_barset->at(0).y(), 5.0);
274 QCOMPARE(m_barset->at(1).y(), 2.0);
281 QCOMPARE(m_barset->at(1).y(), 2.0);
275 QCOMPARE(m_barset->at(2).y(), 3.0);
282 QCOMPARE(m_barset->at(2).y(), 3.0);
276 QCOMPARE(m_barset->at(3).y(), 6.0);
283 QCOMPARE(m_barset->at(3).y(), 6.0);
277
284
278 QVERIFY(valueSpy.count() == 2);
285 QVERIFY(valueSpy.count() == 2);
279 }
286 }
280
287
281 void tst_QBarSet::at_data()
288 void tst_QBarSet::at_data()
282 {
289 {
283
290
284 }
291 }
285
292
286 void tst_QBarSet::at()
293 void tst_QBarSet::at()
287 {
294 {
288 QCOMPARE(m_barset->count(), 0);
295 QCOMPARE(m_barset->count(), 0);
289 QVERIFY(qFuzzyIsNull(m_barset->sum()));
296 QVERIFY(qFuzzyIsNull(m_barset->sum()));
290
297
291 m_barset->append(1.0);
298 m_barset->append(1.0);
292 m_barset->append(2.0);
299 m_barset->append(2.0);
293 m_barset->append(3.0);
300 m_barset->append(3.0);
294 m_barset->append(4.0);
301 m_barset->append(4.0);
295
302
296 QCOMPARE(m_barset->at(0).y(), 1.0);
303 QCOMPARE(m_barset->at(0).y(), 1.0);
297 QCOMPARE(m_barset->at(1).y(), 2.0);
304 QCOMPARE(m_barset->at(1).y(), 2.0);
298 QCOMPARE(m_barset->at(2).y(), 3.0);
305 QCOMPARE(m_barset->at(2).y(), 3.0);
299 QCOMPARE(m_barset->at(3).y(), 4.0);
306 QCOMPARE(m_barset->at(3).y(), 4.0);
300 }
307 }
301
308
302 void tst_QBarSet::atOperator_data()
309 void tst_QBarSet::atOperator_data()
303 {
310 {
304
311
305 }
312 }
306
313
307 void tst_QBarSet::atOperator()
314 void tst_QBarSet::atOperator()
308 {
315 {
309 QCOMPARE(m_barset->count(), 0);
316 QCOMPARE(m_barset->count(), 0);
310 QVERIFY(qFuzzyIsNull(m_barset->sum()));
317 QVERIFY(qFuzzyIsNull(m_barset->sum()));
311
318
312 m_barset->append(1.0);
319 m_barset->append(1.0);
313 m_barset->append(2.0);
320 m_barset->append(2.0);
314 m_barset->append(3.0);
321 m_barset->append(3.0);
315 m_barset->append(4.0);
322 m_barset->append(4.0);
316
323
317 QCOMPARE(m_barset->operator [](0).y(), 1.0);
324 QCOMPARE(m_barset->operator [](0).y(), 1.0);
318 QCOMPARE(m_barset->operator [](1).y(), 2.0);
325 QCOMPARE(m_barset->operator [](1).y(), 2.0);
319 QCOMPARE(m_barset->operator [](2).y(), 3.0);
326 QCOMPARE(m_barset->operator [](2).y(), 3.0);
320 QCOMPARE(m_barset->operator [](3).y(), 4.0);
327 QCOMPARE(m_barset->operator [](3).y(), 4.0);
321 }
328 }
322
329
323 void tst_QBarSet::count_data()
330 void tst_QBarSet::count_data()
324 {
331 {
325
332
326 }
333 }
327
334
328 void tst_QBarSet::count()
335 void tst_QBarSet::count()
329 {
336 {
330 QCOMPARE(m_barset->count(), 0);
337 QCOMPARE(m_barset->count(), 0);
331 QVERIFY(qFuzzyIsNull(m_barset->sum()));
338 QVERIFY(qFuzzyIsNull(m_barset->sum()));
332
339
333 m_barset->append(1.0);
340 m_barset->append(1.0);
334 QCOMPARE(m_barset->count(),1);
341 QCOMPARE(m_barset->count(),1);
335 m_barset->append(2.0);
342 m_barset->append(2.0);
336 QCOMPARE(m_barset->count(),2);
343 QCOMPARE(m_barset->count(),2);
337 m_barset->append(3.0);
344 m_barset->append(3.0);
338 QCOMPARE(m_barset->count(),3);
345 QCOMPARE(m_barset->count(),3);
339 m_barset->append(4.0);
346 m_barset->append(4.0);
340 QCOMPARE(m_barset->count(),4);
347 QCOMPARE(m_barset->count(),4);
341 }
348 }
342
349
343 void tst_QBarSet::sum_data()
350 void tst_QBarSet::sum_data()
344 {
351 {
345
352
346 }
353 }
347
354
348 void tst_QBarSet::sum()
355 void tst_QBarSet::sum()
349 {
356 {
350 QCOMPARE(m_barset->count(), 0);
357 QCOMPARE(m_barset->count(), 0);
351 QVERIFY(qFuzzyIsNull(m_barset->sum()));
358 QVERIFY(qFuzzyIsNull(m_barset->sum()));
352
359
353 m_barset->append(1.0);
360 m_barset->append(1.0);
354 QVERIFY(qFuzzyCompare(m_barset->sum(),1.0));
361 QVERIFY(qFuzzyCompare(m_barset->sum(),1.0));
355 m_barset->append(2.0);
362 m_barset->append(2.0);
356 QVERIFY(qFuzzyCompare(m_barset->sum(),3.0));
363 QVERIFY(qFuzzyCompare(m_barset->sum(),3.0));
357 m_barset->append(3.0);
364 m_barset->append(3.0);
358 QVERIFY(qFuzzyCompare(m_barset->sum(),6.0));
365 QVERIFY(qFuzzyCompare(m_barset->sum(),6.0));
359 m_barset->append(4.0);
366 m_barset->append(4.0);
360 QVERIFY(qFuzzyCompare(m_barset->sum(),10.0));
367 QVERIFY(qFuzzyCompare(m_barset->sum(),10.0));
361 }
368 }
362
369
363 void tst_QBarSet::customize()
370 void tst_QBarSet::customize()
364 {
371 {
365 // Create sets
372 // Create sets
366 QBarSet *set1 = new QBarSet("set1");
373 QBarSet *set1 = new QBarSet("set1");
367 QBarSet *set2 = new QBarSet("set2");
374 QBarSet *set2 = new QBarSet("set2");
368
375
369 // Append set1 to series
376 // Append set1 to series
370 QGroupedBarSeries *series = new QGroupedBarSeries();
377 QGroupedBarSeries *series = new QGroupedBarSeries();
371 bool success = series->append(set1);
378 bool success = series->append(set1);
372 QVERIFY(success);
379 QVERIFY(success);
373
380
374 // Add series to the chart
381 // Add series to the chart
375 QChartView view(new QChart());
382 QChartView view(new QChart());
376 view.resize(200, 200);
383 view.resize(200, 200);
377 view.chart()->addSeries(series);
384 view.chart()->addSeries(series);
378 view.show();
385 view.show();
379 QTest::qWaitForWindowShown(&view);
386 QTest::qWaitForWindowShown(&view);
380
387
381 // Test adding data to the sets
388 // Test adding data to the sets
382 *set1 << 1 << 2 << 1 << 3;
389 *set1 << 1 << 2 << 1 << 3;
383 *set2 << 2 << 1 << 3 << 1;
390 *set2 << 2 << 1 << 3 << 1;
384
391
385 // Test pen
392 // Test pen
386 QVERIFY(set1->pen() != QPen());
393 QVERIFY(set1->pen() != QPen());
387 QVERIFY(set2->pen() == QPen());
394 QVERIFY(set2->pen() == QPen());
388 QPen pen(QColor(128,128,128,128));
395 QPen pen(QColor(128,128,128,128));
389 set1->setPen(pen);
396 set1->setPen(pen);
390 QVERIFY(set1->pen() == pen);
397 QVERIFY(set1->pen() == pen);
391 QVERIFY(set2->pen() == QPen());
398 QVERIFY(set2->pen() == QPen());
392
399
393 // Test brush
400 // Test brush
394 QVERIFY(set1->brush() != QBrush());
401 QVERIFY(set1->brush() != QBrush());
395 QVERIFY(set2->brush() == QBrush());
402 QVERIFY(set2->brush() == QBrush());
396 QBrush brush(QColor(128,128,128,128));
403 QBrush brush(QColor(128,128,128,128));
397 set1->setBrush(brush);
404 set1->setBrush(brush);
398 QVERIFY(set1->brush() == brush);
405 QVERIFY(set1->brush() == brush);
399 QVERIFY(set2->brush() == QBrush());
406 QVERIFY(set2->brush() == QBrush());
400
407
401 // Test label brush
408 // Test label brush
402 QVERIFY(set1->labelBrush() != QBrush());
409 QVERIFY(set1->labelBrush() != QBrush());
403 QVERIFY(set2->labelBrush() == QBrush());
410 QVERIFY(set2->labelBrush() == QBrush());
404 set1->setLabelBrush(brush);
411 set1->setLabelBrush(brush);
405 QVERIFY(set1->labelBrush() == brush);
412 QVERIFY(set1->labelBrush() == brush);
406 QVERIFY(set2->labelBrush() == QBrush());
413 QVERIFY(set2->labelBrush() == QBrush());
407
414
408 // Test label font
415 // Test label font
409 // Note: QFont empty constructor creates font with application's default font, so the font may or may not be the
416 // Note: QFont empty constructor creates font with application's default font, so the font may or may not be the
410 // same for the set added to the series (depending on the QChart's theme configuration)
417 // same for the set added to the series (depending on the QChart's theme configuration)
411 QVERIFY(set1->labelFont() != QFont() || set1->labelFont() == QFont());
418 QVERIFY(set1->labelFont() != QFont() || set1->labelFont() == QFont());
412 QVERIFY(set2->labelFont() == QFont());
419 QVERIFY(set2->labelFont() == QFont());
413 QFont font;
420 QFont font;
414 font.setBold(true);
421 font.setBold(true);
415 font.setItalic(true);
422 font.setItalic(true);
416 set1->setLabelFont(font);
423 set1->setLabelFont(font);
417 QVERIFY(set1->labelFont() == font);
424 QVERIFY(set1->labelFont() == font);
418 QVERIFY(set2->labelFont() == QFont());
425 QVERIFY(set2->labelFont() == QFont());
419
426
420 // Test adding data to the sets
427 // Test adding data to the sets
421 *set1 << 1 << 2 << 1 << 3;
428 *set1 << 1 << 2 << 1 << 3;
422 *set2 << 2 << 1 << 3 << 1;
429 *set2 << 2 << 1 << 3 << 1;
423 }
430 }
424
431
425 QTEST_MAIN(tst_QBarSet)
432 QTEST_MAIN(tst_QBarSet)
426
433
427 #include "tst_qbarset.moc"
434 #include "tst_qbarset.moc"
428
435
@@ -1,89 +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 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 onSeriesChanged: {
30 onSeriesChanged: {
31 seriesConnections.target = series;
31 seriesConnections.target = series;
32 setConnections.target = series.at(0);
32 setConnections.target = series.at(0);
33 }
33 }
34
34
35 Connections {
35 Connections {
36 id: seriesConnections
36 id: seriesConnections
37 ignoreUnknownSignals: true
37 ignoreUnknownSignals: true
38 onNameChanged: console.log("series.onNameChanged: " + series.name);
38 onNameChanged: console.log("series.onNameChanged: " + series.name);
39 onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible);
39 onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible);
40 onBarWidthChanged: console.log("series.onBardWidthChanged: " + width)
40 onLabelsVisibleChanged: console.log("series.onLabelsVisibleChanged: " + series.labelsVisible);
41 onLabelsVisibleChanged: console.log("series.onLabelsVisibleChanged: " + series.labelsVisible);
41 onCountChanged: console.log("series.onCountChanged: " + series.count);
42 onCountChanged: console.log("series.onCountChanged: " + count);
42 }
43 }
43
44
44 Connections {
45 Connections {
45 id: setConnections
46 id: setConnections
46 ignoreUnknownSignals: true
47 ignoreUnknownSignals: true
47 onColorChanged: console.log("series.onColorChanged: " + series.color);
48 onColorChanged: console.log("series.onColorChanged: " + color);
48 onBorderColorChanged: console.log("series.onBorderColorChanged: " + series.borderColor);
49 onBorderColorChanged: console.log("series.onBorderColorChanged: " + color);
49 onLabelColorChanged: console.log("series.onLabelColorChanged: " + series.labelColor);
50 onLabelColorChanged: console.log("series.onLabelColorChanged: " + color);
50 onCountChanged: console.log("series.onCountChanged: " + series.count);
51 onCountChanged: console.log("series.onCountChanged: " + count);
51 }
52 }
52
53
53 Button {
54 Button {
54 text: "visible"
55 text: "visible"
55 onClicked: series.visible = !series.visible;
56 onClicked: series.visible = !series.visible;
56 }
57 }
57 Button {
58 Button {
58 text: "labels visible"
59 text: "labels visible"
59 onClicked: series.labelsVisible = !series.labelsVisible;
60 onClicked: series.labelsVisible = !series.labelsVisible;
60 }
61 }
61 Button {
62 Button {
62 text: "bar width +"
63 text: "bar width +"
63 onClicked: series.barWidth += 0.1;
64 onClicked: series.barWidth += 0.1;
64 }
65 }
65 Button {
66 Button {
66 text: "bar width -"
67 text: "bar width -"
67 onClicked: series.barWidth -= 0.1;
68 onClicked: series.barWidth -= 0.1;
68 }
69 }
69 Button {
70 Button {
70 text: "set 1 color"
71 text: "set 1 color"
71 onClicked: series.at(0).color = main.nextColor();
72 onClicked: series.at(0).color = main.nextColor();
72 }
73 }
73 Button {
74 Button {
74 text: "set 1 border color"
75 text: "set 1 border color"
75 onClicked: series.at(0).borderColor = main.nextColor();
76 onClicked: series.at(0).borderColor = main.nextColor();
76 }
77 }
77 Button {
78 Button {
78 text: "set 1 label color"
79 text: "set 1 label color"
79 onClicked: series.at(0).labelColor = main.nextColor();
80 onClicked: series.at(0).labelColor = main.nextColor();
80 }
81 }
81 Button {
82 Button {
82 text: "set 1 font size +"
83 text: "set 1 font size +"
83 onClicked: series.at(0).labelFont.pixelSize += 1;
84 onClicked: series.at(0).labelFont.pixelSize += 1;
84 }
85 }
85 Button {
86 Button {
86 text: "set 1 font size -"
87 text: "set 1 font size -"
87 onClicked: series.at(0).labelFont.pixelSize -= 1;
88 onClicked: series.at(0).labelFont.pixelSize -= 1;
88 }
89 }
89 }
90 }
@@ -1,283 +1,319
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
24
25 Flow {
25 Flow {
26 id: flow
26 id: flow
27 spacing: 5
27 spacing: 5
28 flow: Flow.TopToBottom
28 flow: Flow.TopToBottom
29 property variant series // TODO: rename to chart
29 property variant series // TODO: rename to chart
30
30
31 onSeriesChanged: {
31 onSeriesChanged: {
32 legendConnections.target = series.legend;
32 legendConnections.target = series.legend;
33 axisXConnections.target = series.axisX;
33 axisXConnections.target = series.axisX;
34 axisYConnections.target = series.axisY;
34 axisYConnections.target = series.axisY;
35 }
35 }
36
36
37 Connections {
37 Connections {
38 target: series
38 target: series
39 ignoreUnknownSignals: true
39 ignoreUnknownSignals: true
40 onVisibleChanged: console.log("chart.onVisibleChanged: " + series.visible);
40 onVisibleChanged: console.log("chart.onVisibleChanged: " + series.visible);
41 onThemeChanged: console.log("chart.onThemeChanged: " + series.theme);
41 onThemeChanged: console.log("chart.onThemeChanged: " + series.theme);
42 onLegendChanged: console.log("chart.onLegendChanged: " + series.legend);
42 onLegendChanged: console.log("chart.onLegendChanged: " + series.legend);
43 onAnimationOptionsChanged: console.log("chart.onAnimationOptionsChanged: " + series.animationOptions);
43 onAnimationOptionsChanged: console.log("chart.onAnimationOptionsChanged: " + series.animationOptions);
44 onTitleColorChanged: console.log("chart.onTitleColorChanged: " + series.titleColor);
44 onTitleColorChanged: console.log("chart.onTitleColorChanged: " + series.titleColor);
45 onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor);
45 onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor);
46 onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled);
46 onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled);
47 }
47 }
48
48
49 Connections {
49 Connections {
50 id: legendConnections
50 id: legendConnections
51 ignoreUnknownSignals: true
51 ignoreUnknownSignals: true
52 onAlignmentChanged: console.log("legend.onAlignmentChanged: " + alignment);
52 onAlignmentChanged: console.log("legend.onAlignmentChanged: " + alignment);
53 onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible);
53 onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible);
54 onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible);
54 onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible);
55 onColorChanged: console.log("legend.onColorChanged: " + color);
55 onColorChanged: console.log("legend.onColorChanged: " + color);
56 onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color);
56 onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color);
57 }
57 }
58
58
59 Connections {
59 Connections {
60 id: axisXConnections
60 id: axisXConnections
61 ignoreUnknownSignals: true
61 ignoreUnknownSignals: true
62 onColorChanged: console.log("axisX.onColorChanged: " + color);
62 onColorChanged: console.log("axisX.onColorChanged: " + color);
63 onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible);
63 onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible);
64 onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color);
64 onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color);
65 onLabelsAngleChanged: console.log("axisX.onLabelsAngleChanged: " + angle);
65 onLabelsAngleChanged: console.log("axisX.onLabelsAngleChanged: " + angle);
66 onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible);
66 onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible);
67 onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible);
67 onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible);
68 onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible);
68 onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible);
69 onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color);
69 onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color);
70 onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color);
70 onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color);
71 onNiceNumbersEnabledChanged: console.log("axisX.onNiceNumbersEnabledChanged: " + enabled);
71 onMinChanged: console.log("axisX.onMinChanged: " + min);
72 onMaxChanged: console.log("axisX.onMaxChanged: " + max);
72 onTicksCountChanged: console.log("axisX.onTicksCountChanged: " + count);
73 onTicksCountChanged: console.log("axisX.onTicksCountChanged: " + count);
74 onNiceNumbersEnabledChanged: console.log("axisX.onNiceNumbersEnabledChanged: " + enabled);
73 }
75 }
74
76
75 Connections {
77 Connections {
76 id: axisYConnections
78 id: axisYConnections
77 ignoreUnknownSignals: true
79 ignoreUnknownSignals: true
78 onColorChanged: console.log("axisY.onColorChanged: " + color);
80 onColorChanged: console.log("axisY.onColorChanged: " + color);
79 onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible);
81 onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible);
80 onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color);
82 onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color);
81 onLabelsAngleChanged: console.log("axisY.onLabelsAngleChanged: " + angle);
83 onLabelsAngleChanged: console.log("axisY.onLabelsAngleChanged: " + angle);
82 onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible);
84 onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible);
83 onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible);
85 onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible);
84 onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible);
86 onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible);
85 onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color);
87 onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color);
86 onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color);
88 onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color);
87 onNiceNumbersEnabledChanged: console.log("axisY.onNiceNumbersEnabledChanged: " + enabled);
89 onMinChanged: console.log("axisY.onMinChanged: " + min);
90 onMaxChanged: console.log("axisY.onMaxChanged: " + max);
88 onTicksCountChanged: console.log("axisY.onTicksCountChanged: " + count);
91 onTicksCountChanged: console.log("axisY.onTicksCountChanged: " + count);
92 onNiceNumbersEnabledChanged: console.log("axisY.onNiceNumbersEnabledChanged: " + enabled);
89 }
93 }
90
94
91 Button {
95 Button {
92 text: "visible"
96 text: "visible"
93 onClicked: series.visible = !series.visible;
97 onClicked: series.visible = !series.visible;
94 }
98 }
95 Button {
99 Button {
96 text: "theme +"
100 text: "theme +"
97 onClicked: series.theme++;
101 onClicked: series.theme++;
98 }
102 }
99 Button {
103 Button {
100 text: "theme -"
104 text: "theme -"
101 onClicked: series.theme--;
105 onClicked: series.theme--;
102 }
106 }
103 Button {
107 Button {
104 text: "animation opt +"
108 text: "animation opt +"
105 onClicked: series.animationOptions++;
109 onClicked: series.animationOptions++;
106 }
110 }
107 Button {
111 Button {
108 text: "animation opt -"
112 text: "animation opt -"
109 onClicked: series.animationOptions--;
113 onClicked: series.animationOptions--;
110 }
114 }
111 Button {
115 Button {
112 text: "title color"
116 text: "title color"
113 onClicked: series.titleColor = main.nextColor();
117 onClicked: series.titleColor = main.nextColor();
114 }
118 }
115 Button {
119 Button {
116 text: "background color"
120 text: "background color"
117 onClicked: series.backgroundColor = main.nextColor();
121 onClicked: series.backgroundColor = main.nextColor();
118 }
122 }
119 Button {
123 Button {
120 text: "drop shadow enabled"
124 text: "drop shadow enabled"
121 onClicked: series.dropShadowEnabled = !series.dropShadowEnabled;
125 onClicked: series.dropShadowEnabled = !series.dropShadowEnabled;
122 }
126 }
123 Button {
127 Button {
124 text: "zoom +"
128 text: "zoom +"
125 onClicked: series.zoom(2);
129 onClicked: series.zoom(2);
126 }
130 }
127 Button {
131 Button {
128 text: "zoom -"
132 text: "zoom -"
129 onClicked: series.zoom(0.5);
133 onClicked: series.zoom(0.5);
130 }
134 }
131 Button {
135 Button {
132 text: "scroll left"
136 text: "scroll left"
133 onClicked: series.scrollLeft(10);
137 onClicked: series.scrollLeft(10);
134 }
138 }
135 Button {
139 Button {
136 text: "scroll right"
140 text: "scroll right"
137 onClicked: series.scrollRight(10);
141 onClicked: series.scrollRight(10);
138 }
142 }
139 Button {
143 Button {
140 text: "scroll up"
144 text: "scroll up"
141 onClicked: series.scrollUp(10);
145 onClicked: series.scrollUp(10);
142 }
146 }
143 Button {
147 Button {
144 text: "scroll down"
148 text: "scroll down"
145 onClicked: series.scrollDown(10);
149 onClicked: series.scrollDown(10);
146 }
150 }
147 Button {
151 Button {
148 text: "legend visible"
152 text: "legend visible"
149 onClicked: series.legend.visible = !series.legend.visible;
153 onClicked: series.legend.visible = !series.legend.visible;
150 }
154 }
151 Button {
155 Button {
152 text: "legend bckgrd visible"
156 text: "legend bckgrd visible"
153 onClicked: series.legend.backgroundVisible = !series.legend.backgroundVisible;
157 onClicked: series.legend.backgroundVisible = !series.legend.backgroundVisible;
154 }
158 }
155 Button {
159 Button {
156 text: "legend color"
160 text: "legend color"
157 onClicked: series.legend.color = main.nextColor();
161 onClicked: series.legend.color = main.nextColor();
158 }
162 }
159 Button {
163 Button {
160 text: "legend border color"
164 text: "legend border color"
161 onClicked: series.legend.borderColor = main.nextColor();
165 onClicked: series.legend.borderColor = main.nextColor();
162 }
166 }
163 Button {
167 Button {
164 text: "legend top"
168 text: "legend top"
165 onClicked: series.legend.alignment ^= Qt.AlignTop;
169 onClicked: series.legend.alignment ^= Qt.AlignTop;
166 }
170 }
167 Button {
171 Button {
168 text: "legend bottom"
172 text: "legend bottom"
169 onClicked: series.legend.alignment ^= Qt.AlignBottom;
173 onClicked: series.legend.alignment ^= Qt.AlignBottom;
170 }
174 }
171 Button {
175 Button {
172 text: "legend left"
176 text: "legend left"
173 onClicked: series.legend.alignment ^= Qt.AlignLeft;
177 onClicked: series.legend.alignment ^= Qt.AlignLeft;
174 }
178 }
175 Button {
179 Button {
176 text: "legend right"
180 text: "legend right"
177 onClicked: series.legend.alignment ^= Qt.AlignRight;
181 onClicked: series.legend.alignment ^= Qt.AlignRight;
178 }
182 }
179 Button {
183 Button {
180 text: "axis X nice nmb"
181 onClicked: series.axisX.niceNumbersEnabled = !series.axisX.niceNumbersEnabled;
182 }
183 Button {
184 text: "axis X visible"
184 text: "axis X visible"
185 onClicked: series.axisX.visible = !series.axisX.visible;
185 onClicked: series.axisX.visible = !series.axisX.visible;
186 }
186 }
187 Button {
187 Button {
188 text: "axis X grid visible"
188 text: "axis X grid visible"
189 onClicked: series.axisX.gridVisible = !series.axisX.gridVisible;
189 onClicked: series.axisX.gridVisible = !series.axisX.gridVisible;
190 }
190 }
191 Button {
191 Button {
192 text: "axis X labels visible"
192 text: "axis X labels visible"
193 onClicked: series.axisX.labelsVisible = !series.axisX.labelsVisible;
193 onClicked: series.axisX.labelsVisible = !series.axisX.labelsVisible;
194 }
194 }
195 Button {
195 Button {
196 text: "axis X color"
196 text: "axis X color"
197 onClicked: series.axisX.color = main.nextColor();
197 onClicked: series.axisX.color = main.nextColor();
198 }
198 }
199 Button {
199 Button {
200 text: "axis X labels color"
200 text: "axis X labels color"
201 onClicked: series.axisX.labelsColor = main.nextColor();
201 onClicked: series.axisX.labelsColor = main.nextColor();
202 }
202 }
203 Button {
203 Button {
204 text: "axis X labels angle +"
204 text: "axis X labels angle +"
205 onClicked: series.axisX.labelsAngle += 5;
205 onClicked: series.axisX.labelsAngle += 5;
206 }
206 }
207 Button {
207 Button {
208 text: "axis X labels angle -"
208 text: "axis X labels angle -"
209 onClicked: series.axisX.labelsAngle -= 5;
209 onClicked: series.axisX.labelsAngle -= 5;
210 }
210 }
211 Button {
211 Button {
212 text: "axis X shades visible"
212 text: "axis X shades visible"
213 onClicked: series.axisX.shadesVisible = !series.axisX.shadesVisible;
213 onClicked: series.axisX.shadesVisible = !series.axisX.shadesVisible;
214 }
214 }
215 Button {
215 Button {
216 text: "axis X shades color"
216 text: "axis X shades color"
217 onClicked: series.axisX.shadesColor = main.nextColor();
217 onClicked: series.axisX.shadesColor = main.nextColor();
218 }
218 }
219 Button {
219 Button {
220 text: "axis X shades bcolor"
220 text: "axis X shades bcolor"
221 onClicked: series.axisX.shadesBorderColor = main.nextColor();
221 onClicked: series.axisX.shadesBorderColor = main.nextColor();
222 }
222 }
223 Button {
223 Button {
224 text: "axis X max +"
225 onClicked: series.axisX.max += 0.1;
226 }
227 Button {
228 text: "axis X max -"
229 onClicked: series.axisX.max -= 0.1;
230 }
231 Button {
232 text: "axis X min +"
233 onClicked: series.axisX.min += 0.1;
234 }
235 Button {
236 text: "axis X min -"
237 onClicked: series.axisX.min -= 0.1;
238 }
239 Button {
224 text: "axis X ticks count +"
240 text: "axis X ticks count +"
225 onClicked: series.axisX.ticksCount++;
241 onClicked: series.axisX.ticksCount++;
226 }
242 }
227 Button {
243 Button {
228 text: "axis X ticks count -"
244 text: "axis X ticks count -"
229 onClicked: series.axisX.ticksCount--;
245 onClicked: series.axisX.ticksCount--;
230 }
246 }
231 Button {
247 Button {
232 text: "axis Y nice nmb"
248 text: "axis X nice nmb"
233 onClicked: series.axisY.niceNumbersEnabled = !series.axisY.niceNumbersEnabled;
249 onClicked: series.axisX.niceNumbersEnabled = !series.axisX.niceNumbersEnabled;
234 }
250 }
235 Button {
251 Button {
236 text: "axis Y visible"
252 text: "axis Y visible"
237 onClicked: series.axisY.visible = !series.axisY.visible;
253 onClicked: series.axisY.visible = !series.axisY.visible;
238 }
254 }
239 Button {
255 Button {
240 text: "axis Y grid visible"
256 text: "axis Y grid visible"
241 onClicked: series.axisY.gridVisible = !series.axisY.gridVisible;
257 onClicked: series.axisY.gridVisible = !series.axisY.gridVisible;
242 }
258 }
243 Button {
259 Button {
244 text: "axis Y labels visible"
260 text: "axis Y labels visible"
245 onClicked: series.axisY.labelsVisible = !series.axisY.labelsVisible;
261 onClicked: series.axisY.labelsVisible = !series.axisY.labelsVisible;
246 }
262 }
247 Button {
263 Button {
248 text: "axis Y color"
264 text: "axis Y color"
249 onClicked: series.axisY.color = main.nextColor();
265 onClicked: series.axisY.color = main.nextColor();
250 }
266 }
251 Button {
267 Button {
252 text: "axis Y labels color"
268 text: "axis Y labels color"
253 onClicked: series.axisY.labelsColor = main.nextColor();
269 onClicked: series.axisY.labelsColor = main.nextColor();
254 }
270 }
255 Button {
271 Button {
256 text: "axis Y labels angle +"
272 text: "axis Y labels angle +"
257 onClicked: series.axisY.labelsAngle += 5;
273 onClicked: series.axisY.labelsAngle += 5;
258 }
274 }
259 Button {
275 Button {
260 text: "axis Y labels angle -"
276 text: "axis Y labels angle -"
261 onClicked: series.axisY.labelsAngle -= 5;
277 onClicked: series.axisY.labelsAngle -= 5;
262 }
278 }
263 Button {
279 Button {
264 text: "axis Y shades visible"
280 text: "axis Y shades visible"
265 onClicked: series.axisY.shadesVisible = !series.axisY.shadesVisible;
281 onClicked: series.axisY.shadesVisible = !series.axisY.shadesVisible;
266 }
282 }
267 Button {
283 Button {
268 text: "axis Y shades color"
284 text: "axis Y shades color"
269 onClicked: series.axisY.shadesColor = main.nextColor();
285 onClicked: series.axisY.shadesColor = main.nextColor();
270 }
286 }
271 Button {
287 Button {
272 text: "axis Y shades bcolor"
288 text: "axis Y shades bcolor"
273 onClicked: series.axisY.shadesBorderColor = main.nextColor();
289 onClicked: series.axisY.shadesBorderColor = main.nextColor();
274 }
290 }
275 Button {
291 Button {
292 text: "axis Y max +"
293 onClicked: series.axisY.max += 0.1;
294 }
295 Button {
296 text: "axis Y max -"
297 onClicked: series.axisY.max -= 0.1;
298 }
299 Button {
300 text: "axis Y min +"
301 onClicked: series.axisY.min += 0.1;
302 }
303 Button {
304 text: "axis Y min -"
305 onClicked: series.axisY.min -= 0.1;
306 }
307 Button {
276 text: "axis Y ticks count +"
308 text: "axis Y ticks count +"
277 onClicked: series.axisY.ticksCount++;
309 onClicked: series.axisY.ticksCount++;
278 }
310 }
279 Button {
311 Button {
280 text: "axis Y ticks count -"
312 text: "axis Y ticks count -"
281 onClicked: series.axisY.ticksCount--;
313 onClicked: series.axisY.ticksCount--;
282 }
314 }
315 Button {
316 text: "axis Y nice nmb"
317 onClicked: series.axisY.niceNumbersEnabled = !series.axisY.niceNumbersEnabled;
318 }
283 }
319 }
General Comments 0
You need to be logged in to leave comments. Login now