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