##// END OF EJS Templates
Various docs fixes
Marek Rosa -
r1638:039a92a11dcb
parent child
Show More
@@ -1,367 +1,373
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 "qbarcategoriesaxis.h"
22 22 #include "qbarcategoriesaxis_p.h"
23 23 #include "chartcategoriesaxisx_p.h"
24 24 #include "chartcategoriesaxisy_p.h"
25 25 #include <qmath.h>
26 26 #include <QDebug>
27 27
28 28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 29 /*!
30 30 \class QBarCategoriesAxis
31 31 \brief The QBarCategoriesAxis class is used for manipulating chart's axis.
32 32 \mainclass
33 33
34 34 Axis can be setup to show axis line with tick marks, grid lines and shades.
35 35 */
36 36
37 37 /*!
38 38 \qmlclass Axis QBarCategoriesAxis
39 39 \brief The Axis element is used for manipulating chart's axes.
40 40
41 41 Axis can be setup to show axis line with tick marks, grid lines and shades.
42 42
43 43 To access Axes you can use ChartView API. For example:
44 44 \code
45 45 ChartView {
46 46 axisX.min: "Feb"
47 47 axisX.max: "Jun"
48 48 // Add a few series...
49 49 }
50 50 \endcode
51 51 */
52 52
53 53 /*!
54 54 \property QBarCategoriesAxis::categories
55 55 Defines the categories of axis
56 56 */
57 57 /*!
58 58 \qmlproperty QStringList Axis::categories
59 59 Defines the categories of axis
60 60 */
61 61
62 62 /*!
63 63 \property QBarCategoriesAxis::min
64 64 Defines the minimum value on the axis.
65 65 */
66 66 /*!
67 67 \qmlproperty real Axis::min
68 68 Defines the minimum value on the axis.
69 69 */
70 70
71 71 /*!
72 72 \property QBarCategoriesAxis::max
73 73 Defines the maximum value on the axis.
74 74 */
75 75 /*!
76 76 \qmlproperty real Axis::max
77 77 Defines the maximum value on the axis.
78 78 */
79 79
80 80 /*!
81 81 \fn void QBarCategoriesAxis::minChanged(const QString &min)
82 82 Axis emits signal when \a min of axis has changed.
83 83 */
84 84
85 85 /*!
86 86 \fn void QBarCategoriesAxis::maxChanged(const QString &max)
87 87 Axis emits signal when \a max of axis has changed.
88 88 */
89 89
90 90 /*!
91 91 \fn void QBarCategoriesAxis::rangeChanged(const QString &min, const QString &max)
92 92 Axis emits signal when \a min or \a max of axis has changed.
93 93 */
94 94
95 95 /*!
96 96 Constructs an axis object which is a child of \a parent.
97 97 */
98 98 QBarCategoriesAxis::QBarCategoriesAxis(QObject *parent):
99 99 QAbstractAxis(*new QBarCategoriesAxisPrivate(this),parent)
100 100 {
101 101 }
102 102
103 /*!
104 Destroys the object
105 */
103 106 QBarCategoriesAxis::~QBarCategoriesAxis()
104 107 {
105 108 }
106 109
110 /*!
111 \internal
112 */
107 113 QBarCategoriesAxis::QBarCategoriesAxis(QBarCategoriesAxisPrivate &d,QObject *parent):QAbstractAxis(d,parent)
108 114 {
109 115
110 116 }
111 117
112 118 /*!
113 119 Appends \a categories to axis
114 120 */
115 121 void QBarCategoriesAxis::append(const QStringList &categories)
116 122 {
117 123 Q_D(QBarCategoriesAxis);
118 124 if (d->m_categories.isEmpty()) {
119 125 d->m_categories.append(categories);
120 126 setRange(categories.first(),categories.last());
121 127 }else{
122 128 d->m_categories.append(categories);
123 129 }
124 130
125 131 emit categoriesChanged();
126 132 }
127 133
128 134 /*!
129 135 Appends \a category to axis
130 136 */
131 137 void QBarCategoriesAxis::append(const QString &category)
132 138 {
133 139 Q_D(QBarCategoriesAxis);
134 140 if (d->m_categories.isEmpty()) {
135 141 d->m_categories.append(category);
136 142 setRange(category,category);
137 143 }else{
138 144 d->m_categories.append(category);
139 145 }
140 146 emit categoriesChanged();
141 147 }
142 148
143 149 /*!
144 150 Removes \a category from axis
145 151 */
146 152 void QBarCategoriesAxis::remove(const QString &category)
147 153 {
148 154 Q_D(QBarCategoriesAxis);
149 155 if (d->m_categories.contains(category)) {
150 156 d->m_categories.removeAt(d->m_categories.indexOf(category));
151 157 setRange(d->m_categories.first(),d->m_categories.last());
152 158 emit categoriesChanged();
153 159 }
154 160 }
155 161
156 162 /*!
157 163 Inserts \a category to axis at \a index
158 164 */
159 165 void QBarCategoriesAxis::insert(int index, const QString &category)
160 166 {
161 167 Q_D(QBarCategoriesAxis);
162 168 if (d->m_categories.isEmpty()) {
163 169 d->m_categories.insert(index,category);
164 170 setRange(category,category);
165 171 }else{
166 172
167 173 }
168 174 emit categoriesChanged();
169 175 }
170 176
171 177 /*!
172 178 Removes all categories.
173 179 */
174 180 void QBarCategoriesAxis::clear()
175 181 {
176 182 Q_D(QBarCategoriesAxis);
177 183 d->m_categories.clear();
178 184 setRange(QString::null,QString::null);
179 185 emit categoriesChanged();
180 186 }
181 187
182 188 void QBarCategoriesAxis::setCategories(const QStringList &categories)
183 189 {
184 190 Q_D(QBarCategoriesAxis);
185 191 if(d->m_categories!=categories){
186 192 d->m_categories = categories;
187 193 setRange(categories.first(),categories.last());
188 194 emit categoriesChanged();
189 195 }
190 196 }
191 197
192 198 QStringList QBarCategoriesAxis::categories()
193 199 {
194 200 Q_D(QBarCategoriesAxis);
195 201 return d->m_categories;
196 202 }
197 203
198 204 /*!
199 205 Returns number of categories.
200 206 */
201 207 int QBarCategoriesAxis::count() const
202 208 {
203 209 Q_D(const QBarCategoriesAxis);
204 210 return d->m_categories.count();
205 211 }
206 212
207 213 /*!
208 214 Returns category at \a index. Index must be valid.
209 215 */
210 216 QString QBarCategoriesAxis::at(int index) const
211 217 {
212 218 Q_D(const QBarCategoriesAxis);
213 219 return d->m_categories.at(index);
214 220 }
215 221
216 222 /*!
217 223 Sets minimum category to \a min.
218 224 */
219 225 void QBarCategoriesAxis::setMin(const QString& min)
220 226 {
221 227 Q_D(QBarCategoriesAxis);
222 228 setRange(min,d->m_maxCategory);
223 229 }
224 230
225 231 /*!
226 232 Returns minimum category.
227 233 */
228 234 QString QBarCategoriesAxis::min() const
229 235 {
230 236 Q_D(const QBarCategoriesAxis);
231 237 return d->m_minCategory;
232 238 }
233 239
234 240 /*!
235 241 Sets maximum category to \a max.
236 242 */
237 243 void QBarCategoriesAxis::setMax(const QString& max)
238 244 {
239 245 Q_D(QBarCategoriesAxis);
240 246 setRange(d->m_minCategory,max);
241 247 }
242 248
243 249 /*!
244 250 Returns maximum category
245 251 */
246 252 QString QBarCategoriesAxis::max() const
247 253 {
248 254 Q_D(const QBarCategoriesAxis);
249 255 return d->m_maxCategory;
250 256 }
251 257
252 258 /*!
253 259 Sets range from \a minCategory to \a maxCategory
254 260 */
255 261 void QBarCategoriesAxis::setRange(const QString& minCategory, const QString& maxCategory)
256 262 {
257 263 Q_D(QBarCategoriesAxis);
258 264
259 265 int minIndex = d->m_categories.indexOf(minCategory);
260 266 if (minIndex == -1) {
261 267 return;
262 268 }
263 269 int maxIndex = d->m_categories.indexOf(maxCategory);
264 270 if (maxIndex == -1) {
265 271 return;
266 272 }
267 273
268 274 if (maxIndex <= minIndex) {
269 275 // max must be greater than min
270 276 return;
271 277 }
272 278
273 279 bool changed = false;
274 280 if (!qFuzzyIsNull(d->m_min - (minIndex))) {
275 281 d->m_minCategory = minCategory;
276 282 d->m_min = minIndex;
277 283 emit minChanged(minCategory);
278 284 changed = true;
279 285 }
280 286
281 287 if (!qFuzzyIsNull(d->m_max - (maxIndex))) {
282 288 d->m_max = maxIndex;
283 289 d->m_maxCategory = maxCategory;
284 290 emit maxChanged(maxCategory);
285 291 changed = true;
286 292 }
287 293
288 294 if ((changed)) {
289 295 d->emitRange();
290 296 emit categoriesChanged();
291 297 }
292 298 }
293 299
294 300 /*!
295 301 Returns the type of the axis
296 302 */
297 303 QAbstractAxis::AxisType QBarCategoriesAxis::type() const
298 304 {
299 305 return AxisTypeCategories;
300 306 }
301 307
302 308 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
303 309
304 310 QBarCategoriesAxisPrivate::QBarCategoriesAxisPrivate(QBarCategoriesAxis* q):
305 311 QAbstractAxisPrivate(q)
306 312 {
307 313
308 314 }
309 315
310 316 QBarCategoriesAxisPrivate::~QBarCategoriesAxisPrivate()
311 317 {
312 318
313 319 }
314 320
315 321 void QBarCategoriesAxisPrivate::setMin(const QVariant &min)
316 322 {
317 323 setRange(min,m_maxCategory);
318 324 }
319 325
320 326 void QBarCategoriesAxisPrivate::setMax(const QVariant &max)
321 327 {
322 328 setRange(m_minCategory,max);
323 329 }
324 330
325 331 void QBarCategoriesAxisPrivate::setRange(const QVariant &min, const QVariant &max)
326 332 {
327 333 Q_Q(QBarCategoriesAxis);
328 334 QString value1 = min.toString();
329 335 QString value2 = max.toString();
330 336 q->setRange(value1,value2);
331 337 }
332 338
333 339 int QBarCategoriesAxisPrivate::ticksCount() const
334 340 {
335 341 return m_categories.count()+1;
336 342 }
337 343
338 344 void QBarCategoriesAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count)
339 345 {
340 346 m_min = min;
341 347 m_max = max;
342 348 m_ticksCount = count;
343 349 }
344 350
345 351 ChartAxis* QBarCategoriesAxisPrivate::createGraphics(ChartPresenter* presenter)
346 352 {
347 353 Q_Q( QBarCategoriesAxis);
348 354 if(m_orientation == Qt::Vertical){
349 355 return new ChartCategoriesAxisY(q,presenter);
350 356 }else{
351 357 return new ChartCategoriesAxisX(q,presenter);
352 358 }
353 359 }
354 360
355 361 void QBarCategoriesAxisPrivate::emitRange()
356 362 {
357 363 Q_Q( QBarCategoriesAxis);
358 364 if(!q->signalsBlocked()) {
359 365 emit changed(m_min -0.5, m_max +0.5, qCeil(m_max + 0.5) -qCeil(m_min - 0.5) +1, false);
360 366 }
361 367 }
362 368
363 369
364 370 #include "moc_qbarcategoriesaxis.cpp"
365 371 #include "moc_qbarcategoriesaxis_p.cpp"
366 372
367 373 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,171 +1,177
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 "qintervalaxis.h"
22 22 #include "qintervalaxis_p.h"
23 23 #include "chartcategoriesaxisx_p.h"
24 24 #include "chartcategoriesaxisy_p.h"
25 25 #include <qmath.h>
26 26 #include <QDebug>
27 27
28 28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 29 /*!
30 30 \class QIntervalAxis
31 31 \brief The QIntervalAxis class is used for manipulating chart's axis.
32 32 \mainclass
33 33
34 34 Axis can be setup to show axis line with tick marks, grid lines and shades.
35 35 */
36 36
37 37 /*!
38 38 \qmlclass Axis QIntervalAxis
39 39 \brief The Axis element is used for manipulating chart's axes.
40 40
41 41 Axis can be setup to show axis line with tick marks, grid lines and shades.
42 42
43 43 To access Axes you can use ChartView API. For example:
44 44 \code
45 45 // TODO :)
46 46 \endcode
47 47 */
48 48
49 49 /*!
50 50 Constructs an axis object which is a child of \a parent.
51 51 */
52 52 QIntervalAxis::QIntervalAxis(QObject *parent):
53 53 QValuesAxis(*new QIntervalAxisPrivate(this),parent)
54 54 {
55 55 }
56 56
57 /*!
58 Destroys the object
59 */
57 60 QIntervalAxis::~QIntervalAxis()
58 61 {
59 62 }
60 63
64 /*!
65 \internal
66 */
61 67 QIntervalAxis::QIntervalAxis(QIntervalAxisPrivate &d,QObject *parent):QValuesAxis(d,parent)
62 68 {
63 69
64 70 }
65 71
66 72 /*!
67 73 Appends \a categories to axis
68 74 */
69 75 void QIntervalAxis::append(const QString& category, qreal x)
70 76 {
71 77 Q_D(QIntervalAxis);
72 78 if (!d->m_categories.contains(category))
73 79 {
74 80 if(d->m_categories.isEmpty()){
75 81 Range range(d->m_categoryMinimum,x);
76 82 d->m_categoriesMap.insert(category,range);
77 83 d->m_categories.append(category);
78 84 }else{
79 85 Range range = d->m_categoriesMap.value(d->m_categories.last());
80 86 d->m_categoriesMap.insert(category,Range(range.first,x));
81 87 d->m_categories.append(category);
82 88 }
83 89 setRange(d->m_min,x);
84 90 }
85 91 }
86 92
87 93 void QIntervalAxis::setFisrtCategoryMinimum(qreal x)
88 94 {
89 95 Q_D(QIntervalAxis);
90 96 if(d->m_categories.isEmpty()){
91 97 d->m_categoryMinimum=x;
92 98 }else{
93 99 Range range = d->m_categoriesMap.value(d->m_categories.first());
94 100 d->m_categoriesMap.insert(d->m_categories.first(),Range(x,range.second));
95 101 setRange(x,d->m_min);
96 102 }
97 103 }
98 104
99 105 /*!
100 106 Removes \a category from axis
101 107 */
102 108 void QIntervalAxis::remove(const QString &category)
103 109 {
104 110 Q_UNUSED(category);
105 111 //TODO
106 112 }
107 113
108 114 QStringList QIntervalAxis::categories()
109 115 {
110 116 Q_D(QIntervalAxis);
111 117 return d->m_categories;
112 118 }
113 119
114 120 /*!
115 121 Returns number of categories.
116 122 */
117 123 int QIntervalAxis::count() const
118 124 {
119 125 Q_D(const QIntervalAxis);
120 126 return d->m_categories.count();
121 127 }
122 128
123 129 /*!
124 130 Returns the type of the axis
125 131 */
126 132 QAbstractAxis::AxisType QIntervalAxis::type() const
127 133 {
128 134 return AxisTypeCategories;
129 135 }
130 136
131 137 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
132 138
133 139 QIntervalAxisPrivate::QIntervalAxisPrivate(QIntervalAxis* q):
134 140 QValuesAxisPrivate(q),
135 141 m_categoryMinimum(0)
136 142 {
137 143
138 144 }
139 145
140 146 QIntervalAxisPrivate::~QIntervalAxisPrivate()
141 147 {
142 148
143 149 }
144 150
145 151 int QIntervalAxisPrivate::ticksCount() const
146 152 {
147 153 return m_categories.count()+1;
148 154 }
149 155
150 156 void QIntervalAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count)
151 157 {
152 158 m_min = min;
153 159 m_max = max;
154 160 m_ticksCount = count;
155 161 }
156 162
157 163 ChartAxis* QIntervalAxisPrivate::createGraphics(ChartPresenter* presenter)
158 164 {
159 165 Q_UNUSED(presenter);
160 166 // Q_Q( QCategoriesAxis);
161 167 if(m_orientation == Qt::Vertical){
162 168 return 0;
163 169 }else{
164 170 return 0;
165 171 }
166 172 }
167 173
168 174 #include "moc_qintervalaxis.cpp"
169 175 #include "moc_qintervalaxis_p.cpp"
170 176
171 177 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,296 +1,302
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 "qvaluesaxis.h"
22 22 #include "qvaluesaxis_p.h"
23 23 #include "chartvaluesaxisx_p.h"
24 24 #include "chartvaluesaxisy_p.h"
25 25 #include <QDebug>
26 26
27 27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 28 /*!
29 29 \class QValuesAxis
30 30 \brief The QValuesAxis class is used for manipulating chart's axis.
31 31 \mainclass
32 32
33 33 Axis can be setup to show axis line with tick marks, grid lines and shades.
34 34 */
35 35
36 36 /*!
37 37 \qmlclass Axis QValuesAxis
38 38 \brief The Axis element is used for manipulating chart's axes
39 39
40 40 Axis can be setup to show axis line with tick marks, grid lines and shades.
41 41
42 42 To access Axes you can use ChartView API. For example:
43 43 \code
44 44 ChartView {
45 45 axisX.min: 0
46 46 axisX.max: 3
47 47 axisX.ticksCount: 4
48 48 axisY.min: 0
49 49 axisY.max: 4
50 50 // Add a few series...
51 51 }
52 52 \endcode
53 53 */
54 54
55 55 /*!
56 56 \property QValuesAxis::min
57 57 Defines the minimum value on the axis.
58 58 */
59 59 /*!
60 60 \qmlproperty real Axis::min
61 61 Defines the minimum value on the axis.
62 62 */
63 63
64 64 /*!
65 65 \property QValuesAxis::max
66 66 Defines the maximum value on the axis.
67 67 */
68 68 /*!
69 69 \qmlproperty real Axis::max
70 70 Defines the maximum value on the axis.
71 71 */
72 72
73 73 /*!
74 74 \fn void QValuesAxis::minChanged(qreal min)
75 75 Axis emits signal when \a min of axis has changed.
76 76 */
77 77
78 78 /*!
79 79 \fn void QValuesAxis::maxChanged(qreal max)
80 80 Axis emits signal when \a max of axis has changed.
81 81 */
82 82
83 83 /*!
84 84 \fn void QValuesAxis::rangeChanged(qreal min, qreal max)
85 85 Axis emits signal when \a min or \a max of axis has changed.
86 86 */
87 87
88 88 /*!
89 89 \property QValuesAxis::ticksCount
90 90 The number of tick marks for the axis.
91 91 */
92 92
93 93 /*!
94 94 \qmlproperty int Axis::ticksCount
95 95 The number of tick marks for the axis.
96 96 */
97 97
98 98 /*!
99 99 \property QValuesAxis::niceNumbersEnabled
100 100 Whether the nice numbers algorithm is enabled or not for the axis.
101 101 */
102 102
103 103 /*!
104 104 \qmlproperty bool Axis::niceNumbersEnabled
105 105 Whether the nice numbers algorithm is enabled or not for the axis.
106 106 */
107 107
108 108 /*!
109 109 Constructs an axis object which is a child of \a parent.
110 110 */
111 111 QValuesAxis::QValuesAxis(QObject *parent) :
112 112 QAbstractAxis(*new QValuesAxisPrivate(this),parent)
113 113 {
114 114
115 115 }
116 116
117 /*!
118 \internal
119 */
117 120 QValuesAxis::QValuesAxis(QValuesAxisPrivate &d,QObject *parent) : QAbstractAxis(d,parent)
118 121 {
119 122
120 123 }
121 124
125 /*!
126 Destroys the object
127 */
122 128 QValuesAxis::~QValuesAxis()
123 129 {
124 130
125 131 }
126 132
127 133 void QValuesAxis::setMin(qreal min)
128 134 {
129 135 Q_D(QValuesAxis);
130 136 setRange(min,d->m_max);
131 137 }
132 138
133 139 qreal QValuesAxis::min() const
134 140 {
135 141 Q_D(const QValuesAxis);
136 142 return d->m_min;
137 143 }
138 144
139 145 void QValuesAxis::setMax(qreal max)
140 146 {
141 147 Q_D(QValuesAxis);
142 148 setRange(d->m_min,max);
143 149 }
144 150
145 151 qreal QValuesAxis::max() const
146 152 {
147 153 Q_D(const QValuesAxis);
148 154 return d->m_max;
149 155 }
150 156
151 157 /*!
152 158 Sets range from \a min to \a max on the axis.
153 159 */
154 160 void QValuesAxis::setRange(qreal min, qreal max)
155 161 {
156 162 Q_D(QValuesAxis);
157 163 bool changed = false;
158 164 if (!qFuzzyIsNull(d->m_min - min)) {
159 165 d->m_min = min;
160 166 changed = true;
161 167 emit minChanged(min);
162 168 }
163 169
164 170 if (!qFuzzyIsNull(d->m_max - max)) {
165 171 d->m_max = max;
166 172 changed = true;
167 173 emit maxChanged(max);
168 174 }
169 175
170 176 if (changed) {
171 177 d->emitRange();
172 178 emit rangeChanged(d->m_min,d->m_max);
173 179 }
174 180 }
175 181
176 182 /*!
177 183 Sets \a count for ticks on the axis.
178 184 */
179 185 void QValuesAxis::setTicksCount(int count)
180 186 {
181 187 Q_D(QValuesAxis);
182 188 if (d->m_ticksCount != count) {
183 189 d->m_ticksCount = count;
184 190 emit d->changed(d->m_min, d->m_max, d->m_ticksCount, d->m_niceNumbers);
185 191 }
186 192 }
187 193
188 194 /*!
189 195 \fn int QValuesAxis::ticksCount() const
190 196 Return number of ticks on the axis
191 197 */
192 198 int QValuesAxis::ticksCount() const
193 199 {
194 200 Q_D(const QValuesAxis);
195 201 return d->m_ticksCount;
196 202 }
197 203
198 204 void QValuesAxis::setNiceNumbersEnabled(bool enable)
199 205 {
200 206 Q_D(QValuesAxis);
201 207 if (d->m_niceNumbers != enable){
202 208 d->m_niceNumbers = enable;
203 209 emit d->changed(d->m_min, d->m_max, d->m_ticksCount, d->m_niceNumbers);
204 210 }
205 211 }
206 212
207 213 bool QValuesAxis::niceNumbersEnabled() const
208 214 {
209 215 Q_D(const QValuesAxis);
210 216 return d->m_niceNumbers;
211 217 }
212 218
213 219 /*!
214 220 Returns the type of the axis
215 221 */
216 222 QAbstractAxis::AxisType QValuesAxis::type() const
217 223 {
218 224 return AxisTypeValues;
219 225 }
220 226
221 227 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
222 228
223 229 QValuesAxisPrivate::QValuesAxisPrivate(QValuesAxis* q):
224 230 QAbstractAxisPrivate(q),
225 231 m_niceNumbers(false)
226 232 {
227 233
228 234 }
229 235
230 236 QValuesAxisPrivate::~QValuesAxisPrivate()
231 237 {
232 238
233 239 }
234 240
235 241 void QValuesAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count)
236 242 {
237 243 Q_Q(QValuesAxis);
238 244 q->setRange(min,max);
239 245 q->setTicksCount(count);
240 246 }
241 247
242 248
243 249 void QValuesAxisPrivate::setMin(const QVariant &min)
244 250 {
245 251 Q_Q(QValuesAxis);
246 252 bool ok;
247 253 qreal value = min.toReal(&ok);
248 254 if(ok) q->setMin(value);
249 255 }
250 256
251 257 void QValuesAxisPrivate::setMax(const QVariant &max)
252 258 {
253 259 Q_Q(QValuesAxis);
254 260 bool ok;
255 261 qreal value = max.toReal(&ok);
256 262 if(ok) q->setMax(value);
257 263 }
258 264
259 265 void QValuesAxisPrivate::setRange(const QVariant &min, const QVariant &max)
260 266 {
261 267 Q_Q(QValuesAxis);
262 268 bool ok1;
263 269 bool ok2;
264 270 qreal value1 = min.toReal(&ok1);
265 271 qreal value2 = max.toReal(&ok2);
266 272 if(ok1&&ok2) q->setRange(value1,value2);
267 273 }
268 274
269 275 int QValuesAxisPrivate::ticksCount() const
270 276 {
271 277 return m_ticksCount;
272 278 }
273 279
274 280 ChartAxis* QValuesAxisPrivate::createGraphics(ChartPresenter* presenter)
275 281 {
276 282 Q_Q(QValuesAxis);
277 283 if(m_orientation == Qt::Vertical){
278 284 return new ChartValuesAxisY(q,presenter);
279 285 }else{
280 286 return new ChartValuesAxisX(q,presenter);
281 287 }
282 288
283 289 }
284 290
285 291 void QValuesAxisPrivate::emitRange()
286 292 {
287 293 Q_Q(QValuesAxis);
288 294 if(!q->signalsBlocked()) {
289 295 emit changed(m_min, m_max, m_ticksCount, m_niceNumbers);
290 296 }
291 297 }
292 298
293 299 #include "moc_qvaluesaxis.cpp"
294 300 #include "moc_qvaluesaxis_p.cpp"
295 301
296 302 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,84 +1,84
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 ABSTRACTBARSERIES_H
22 22 #define ABSTRACTBARSERIES_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 QAbstractBarSeriesPrivate;
31 31
32 32 // Container for series
33 33 class QTCOMMERCIALCHART_EXPORT QAbstractBarSeries : public QAbstractSeries
34 34 {
35 35 Q_OBJECT
36 36 Q_PROPERTY(qreal barWidth READ barWidth WRITE setBarWidth)
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 protected:
41 41 explicit QAbstractBarSeries(QObject *parent = 0);
42 42
43 43 public:
44 44 virtual ~QAbstractBarSeries();
45 45
46 virtual QAbstractSeries::SeriesType type() const = 0;
46 // virtual QAbstractSeries::SeriesType type() const = 0;
47 47
48 48 void setBarWidth(qreal width);
49 49 qreal barWidth() const;
50 50
51 51 bool append(QBarSet *set);
52 52 bool remove(QBarSet *set);
53 53 bool append(QList<QBarSet* > sets);
54 54 bool insert(int index, QBarSet *set);
55 55 int count() const;
56 56 QList<QBarSet*> barSets() const;
57 57 void clear();
58 58
59 59 void setLabelsVisible(bool visible = true);
60 60 bool isLabelsVisible() const;
61 61
62 62 protected:
63 63 explicit QAbstractBarSeries(QAbstractBarSeriesPrivate &d,QObject *parent = 0);
64 64
65 65 Q_SIGNALS:
66 66 void clicked(int index, QBarSet *barset);
67 67 void hovered(bool status, QBarSet *barset);
68 68 void countChanged();
69 69 void labelsVisibleChanged();
70 70
71 71 void barsetsAdded(QList<QBarSet*> sets);
72 72 void barsetsRemoved(QList<QBarSet*> sets);
73 73
74 74 protected:
75 75 Q_DECLARE_PRIVATE(QAbstractBarSeries)
76 76 friend class BarChartItem;
77 77 friend class PercentBarChartItem;
78 78 friend class StackedBarChartItem;
79 79 friend class GroupedBarChartItem;
80 80 };
81 81
82 82 QTCOMMERCIALCHART_END_NAMESPACE
83 83
84 84 #endif // ABSTRACTBARSERIES_H
@@ -1,189 +1,199
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 "qabstractseries.h"
22 22 #include "qabstractseries_p.h"
23 23 #include "chartdataset_p.h"
24 24
25 25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 26
27 27 /*!
28 28 \class QAbstractSeries
29 29 \brief Base class for all QtCommercial Chart series.
30 30 \mainclass
31 31
32 32 Usually you use the series type specific inherited classes instead of the base class.
33 33 \sa QXYSeries, QLineSeries, QSplineSeries, QScatterSeries, QAreaSeries, QAbstractBarSeries, QStackedBarSeries,
34 34 QPercentBarSeries, QPieSeries
35 35 */
36 36 /*!
37 37 \qmlclass AbstractSeries
38 38 AbstractSeries is the base class for all series.
39 39 The class cannot be instantiated by the user.
40 40 */
41 41
42 42 /*!
43 43 \enum QAbstractSeries::SeriesType
44 44
45 45 The type of the series object.
46 46
47 47 \value SeriesTypeLine
48 48 \value SeriesTypeArea
49 49 \value SeriesTypeBar
50 50 \value SeriesTypeStackedBar
51 51 \value SeriesTypePercentBar
52 52 \value SeriesTypePie
53 53 \value SeriesTypeScatter
54 54 \value SeriesTypeSpline
55 55 */
56 56
57 57 /*!
58 58 \property QAbstractSeries::type
59 59 The type of the series.
60 60 */
61 61 /*!
62 62 \qmlproperty ChartView.SeriesType AbstractSeries::type
63 63 The type of the series.
64 64 */
65 65
66 66 /*!
67 67 \property QAbstractSeries::name
68 68 \brief name of the series property. The name is shown in legend for QXYSeries.
69 69 */
70 70 /*!
71 71 \qmlproperty string AbstractSeries::name
72 72 Name of the series. The name is shown in legend for QXYSeries.
73 73 */
74 74
75 75 /*!
76 76 \fn void QAbstractSeries::nameChanged()
77 77 This signal is emitted when the series name changes.
78 78 */
79 79 /*!
80 80 \qmlsignal AbstractSeries::nameChanged()
81 81 This signal is emitted when the series name changes.
82 82 */
83 83
84 84 /*!
85 85 \property QAbstractSeries::visible
86 86 \brief whether the series is visible or not; true by default.
87 87 */
88 88
89 89 /*!
90 90 \fn void QAbstractSeries::visibleChanged()
91 91 Emitted when the series visibility changes.
92 92 */
93 93
94 94 /*!
95 95 \internal
96 96 \brief Constructs ChartSeries object with \a parent.
97 97 */
98 98 QAbstractSeries::QAbstractSeries(QAbstractSeriesPrivate &d, QObject *parent) :
99 99 QObject(parent),
100 100 d_ptr(&d)
101 101 {
102 102 }
103 103
104 104 /*!
105 105 \brief Virtual destructor for the chart series.
106 106 */
107 107 QAbstractSeries::~QAbstractSeries()
108 108 {
109 109 if(d_ptr->m_dataset) qFatal("Still binded series detected !");
110 110 }
111 111
112 112 void QAbstractSeries::setName(const QString& name)
113 113 {
114 114 if (name != d_ptr->m_name) {
115 115 d_ptr->m_name = name;
116 116 emit nameChanged();
117 117 }
118 118 }
119 119
120 120 QString QAbstractSeries::name() const
121 121 {
122 122 return d_ptr->m_name;
123 123 }
124 124
125 125 /*!
126 126 Sets the visibility of series to \a visible
127 127 */
128 128 void QAbstractSeries::setVisible(bool visible)
129 129 {
130 130 if (visible != d_ptr->m_visible) {
131 131 d_ptr->m_visible = visible;
132 132 emit visibleChanged();
133 133 }
134 134 }
135 135
136 136 /*!
137 137 Returns the visibility of series
138 138 */
139 139 bool QAbstractSeries::isVisible() const
140 140 {
141 141 return d_ptr->m_visible;
142 142 }
143 143
144 144 /*!
145 145 \brief Returns the chart where series belongs to.
146 146
147 147 Set automatically when the series is added to the chart
148 148 and unset when the series is removed from the chart.
149 149 */
150 150 QChart* QAbstractSeries::chart() const
151 151 {
152 152 return d_ptr->m_chart;
153 153 }
154 154
155 155 void QAbstractSeries::adjustView()
156 156 {
157 157 //TODO:
158 158 }
159 159
160 /*!
161 \brief Sets the visibility of the series to true
162
163 \sa setVisible(), isVisible()
164 */
160 165 void QAbstractSeries::show()
161 166 {
162 167 setVisible(true);
163 168 }
164 169
170 /*!
171 \brief Sets the visibility of the series to false
172
173 \sa setVisible(), isVisible()
174 */
165 175 void QAbstractSeries::hide()
166 176 {
167 177 setVisible(false);
168 178 }
169 179
170 180 ///////////////////////////////////////////////////////////////////////////////////////////////////
171 181
172 182 QAbstractSeriesPrivate::QAbstractSeriesPrivate(QAbstractSeries* q):
173 183 q_ptr(q),
174 184 m_chart(0),
175 185 m_dataset(0),
176 186 m_visible(true)
177 187 {
178 188 }
179 189
180 190 QAbstractSeriesPrivate::~QAbstractSeriesPrivate()
181 191 {
182 192 }
183 193
184 194 #include "moc_qabstractseries.cpp"
185 195 #include "moc_qabstractseries_p.cpp"
186 196
187 197 QTCOMMERCIALCHART_END_NAMESPACE
188 198
189 199
@@ -1,465 +1,485
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 "qchart.h"
22 22 #include "qchart_p.h"
23 23 #include "legendscroller_p.h"
24 24 #include "qlegend_p.h"
25 25 #include "chartbackground_p.h"
26 26 #include "qabstractaxis.h"
27 27 #include <QGraphicsScene>
28 28 #include <QGraphicsSceneResizeEvent>
29 29 #include <QGraphicsLayout>
30 30
31 31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32 32
33 33 /*!
34 34 \enum QChart::ChartTheme
35 35
36 36 This enum describes the theme used by the chart.
37 37
38 38 \value ChartThemeLight The default theme
39 39 \value ChartThemeBlueCerulean
40 40 \value ChartThemeDark
41 41 \value ChartThemeBrownSand
42 42 \value ChartThemeBlueNcs
43 43 \value ChartThemeHighContrast
44 44 \value ChartThemeBlueIcy
45 45 */
46 46
47 47 /*!
48 48 \enum QChart::AnimationOption
49 49
50 50 For enabling/disabling animations. Defaults to NoAnimation.
51 51
52 52 \value NoAnimation
53 53 \value GridAxisAnimations
54 54 \value SeriesAnimations
55 55 \value AllAnimations
56 56 */
57 57
58 58 /*!
59 59 \class QChart
60 60 \brief QtCommercial chart API.
61 61
62 62 QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical
63 63 representation of different types of series and other chart related objects like
64 64 QAxis and QLegend. If you simply want to show a chart in a layout, you can use the
65 65 convenience class QChartView instead of QChart.
66 66 \sa QChartView
67 67 */
68 68
69 69 /*!
70 70 \property QChart::animationOptions
71 71 The animation \a options for the chart. Animations are enabled/disabled based on this setting.
72 72 */
73 73
74 74 /*!
75 75 \property QChart::backgroundVisible
76 76 Whether the chart background is visible or not.
77 77 \sa setBackgroundBrush(), setBackgroundPen()
78 78 */
79 79
80 80 /*!
81 81 \property QChart::dropShadowEnabled
82 82 If set to true, the background drop shadow effect is enabled. If set to false, it is disabled. Note that the drop
83 83 shadow effect depends on theme, which means the setting may be changed if you switch to another theme.
84 84 */
85 85
86 86 /*!
87 87 \property QChart::margins
88 88 Margins around the plot area. Note that the margin area is used for drawing chart title, legend and axes.
89 89 */
90 90
91 91 /*!
92 92 \property QChart::theme
93 93 Theme is a built-in collection of UI style related settings applied for all visual elements of a chart, like colors,
94 94 pens, brushes and fonts of series, axes, title and legend. \l {Chart themes demo} shows an example with a few
95 95 different themes.
96 96 Note: changing the theme will overwrite all customizations previously applied to the series.
97 97 */
98 98
99 99 /*!
100 100 \property QChart::title
101 101 Title is the name (label) of a chart. It is shown as a headline on top of the chart.
102 102 */
103 103
104 104 /*!
105 105 \fn void QChart::marginsChanged(QRectF newMargins)
106 106 The margins around plot area have changed to \a newMargins. This may happen for example if you change title font size,
107 107 modify axes or hide/show legend.
108 108 */
109 109
110 110 /*!
111 111 Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor.
112 112 */
113 113 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
114 114 d_ptr(new QChartPrivate())
115 115 {
116 116 d_ptr->m_dataset = new ChartDataSet(this);
117 117 d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset);
118 118 d_ptr->createConnections();
119 119 d_ptr->m_legend = new LegendScroller(this);
120 120 d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false);
121 121 //connect(d_ptr->m_presenter, SIGNAL(marginsChanged(QRectF)), this, SIGNAL(marginsChanged(QRectF)));
122 122 setLayout(d_ptr->m_presenter->layout());
123 123 }
124 124
125 125 /*!
126 126 Destroys the object and it's children, like series and axis objects added to it.
127 127 */
128 128 QChart::~QChart()
129 129 {
130 130 //delete first presenter , since this is a root of all the graphical items
131 131 setLayout(0);
132 132 delete d_ptr->m_presenter;
133 133 d_ptr->m_presenter=0;
134 134 }
135 135
136 136 /*!
137 137 Adds the \a series onto the chart and takes the ownership of the object.
138 138 If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and
139 139 the y axis).
140 140
141 141 \sa removeSeries(), removeAllSeries()
142 142 */
143 143 void QChart::addSeries(QAbstractSeries *series)
144 144 {
145 145 Q_ASSERT(series);
146 146 d_ptr->m_dataset->addSeries(series);
147 147 }
148 148
149 149 /*!
150 150 Removes the \a series specified in a perameter from the QChartView.
151 151 It releses its ownership of the specified QChartSeries object.
152 152 It does not delete the pointed QChartSeries data object
153 153 \sa addSeries(), removeAllSeries()
154 154 */
155 155 void QChart::removeSeries(QAbstractSeries *series)
156 156 {
157 157 Q_ASSERT(series);
158 158 d_ptr->m_dataset->removeSeries(series);
159 159 }
160 160
161 161 /*!
162 162 Removes all the QChartSeries that have been added to the QChartView
163 163 It also deletes the pointed QChartSeries data objects
164 164 \sa addSeries(), removeSeries()
165 165 */
166 166 void QChart::removeAllSeries()
167 167 {
168 168 d_ptr->m_dataset->removeAllSeries();
169 169 }
170 170
171 171 /*!
172 172 Sets the \a brush that is used for painting the background of the chart area.
173 173 */
174 174 void QChart::setBackgroundBrush(const QBrush& brush)
175 175 {
176 176 d_ptr->m_presenter->setBackgroundBrush(brush);
177 177 }
178 178
179 179 /*!
180 180 Gets the brush that is used for painting the background of the chart area.
181 181 */
182 182 QBrush QChart::backgroundBrush() const
183 183 {
184 184 return d_ptr->m_presenter->backgroundBrush();
185 185 }
186 186
187 187 /*!
188 188 Sets the \a pen that is used for painting the background of the chart area.
189 189 */
190 190 void QChart::setBackgroundPen(const QPen& pen)
191 191 {
192 192 d_ptr->m_presenter->setBackgroundPen(pen);
193 193 }
194 194
195 195 /*!
196 196 Gets the pen that is used for painting the background of the chart area.
197 197 */
198 198 QPen QChart::backgroundPen() const
199 199 {
200 200 return d_ptr->m_presenter->backgroundPen();
201 201 }
202 202
203 203 /*!
204 204 Sets the chart \a title. The description text that is drawn above the chart.
205 205 */
206 206 void QChart::setTitle(const QString& title)
207 207 {
208 208 d_ptr->m_presenter->setTitle(title);
209 209 }
210 210
211 211 /*!
212 212 Returns the chart title. The description text that is drawn above the chart.
213 213 */
214 214 QString QChart::title() const
215 215 {
216 216 return d_ptr->m_presenter->title();
217 217 }
218 218
219 219 /*!
220 220 Sets the \a font that is used for drawing the chart description text that is rendered above the chart.
221 221 */
222 222 void QChart::setTitleFont(const QFont& font)
223 223 {
224 224 d_ptr->m_presenter->setTitleFont(font);
225 225 }
226 226
227 227 /*!
228 228 Gets the font that is used for drawing the chart description text that is rendered above the chart.
229 229 */
230 230 QFont QChart::titleFont() const
231 231 {
232 232 return d_ptr->m_presenter->titleFont();
233 233 }
234 234
235 235 /*!
236 236 Sets the \a brush used for rendering the title text.
237 237 */
238 238 void QChart::setTitleBrush(const QBrush &brush)
239 239 {
240 240 d_ptr->m_presenter->setTitleBrush(brush);
241 241 }
242 242
243 243 /*!
244 244 Returns the brush used for rendering the title text.
245 245 */
246 246 QBrush QChart::titleBrush() const
247 247 {
248 248 return d_ptr->m_presenter->titleBrush();
249 249 }
250 250
251 251 void QChart::setTheme(QChart::ChartTheme theme)
252 252 {
253 253 d_ptr->m_presenter->setTheme(theme);
254 254 }
255 255
256 256 QChart::ChartTheme QChart::theme() const
257 257 {
258 258 return d_ptr->m_presenter->theme();
259 259 }
260 260
261 261 /*!
262 262 Zooms in the view by a factor of 2
263 263 */
264 264 void QChart::zoomIn()
265 265 {
266 266 d_ptr->m_presenter->zoomIn(2.0);
267 267 }
268 268
269 269 /*!
270 270 Zooms in the view to a maximum level at which \a rect is still fully visible.
271 271 */
272 272 void QChart::zoomIn(const QRectF& rect)
273 273 {
274 274 if (!rect.isValid()) return;
275 275 d_ptr->m_presenter->zoomIn(rect);
276 276 }
277 277
278 278 /*!
279 279 Restores the view zoom level to the previous one.
280 280 */
281 281 void QChart::zoomOut()
282 282 {
283 283 d_ptr->m_presenter->zoomOut(2.0);
284 284 }
285 285
286 286 /*!
287 287 Zooms in the view by a \a factor.
288 288
289 289 A factor over 1.0 zooms the view in and factor between 0.0 and 1.0 zooms out.
290 290 */
291 291 void QChart::zoom(qreal factor)
292 292 {
293 293 if (qFuzzyIsNull(factor))
294 294 return;
295 295
296 296 if (qFuzzyCompare(factor, 1.0))
297 297 return;
298 298
299 299 if (factor < 0)
300 300 return;
301 301
302 302 if (factor > 1.0)
303 303 d_ptr->m_presenter->zoomIn(factor);
304 304 else
305 305 d_ptr->m_presenter->zoomOut(1.0 / factor);
306 306 }
307 307
308 308 /*!
309 309 Returns the pointer to the x axis object of the chart asociated with the specified \a series
310 If no series is provided then pointer to currently visible axis is provided
310 311 */
311 312 QAbstractAxis* QChart::axisX(QAbstractSeries* series) const
312 313 {
313 314 return d_ptr->m_dataset->axisX(series);
314 315 }
315 316
316 317 /*!
317 318 Returns the pointer to the y axis object of the chart asociated with the specified \a series
319 If no series is provided then pointer to currently visible axis is provided
318 320 */
319 321 QAbstractAxis* QChart::axisY(QAbstractSeries *series) const
320 322 {
321 323 return d_ptr->m_dataset->axisY(series);
322 324 }
323 325
324 326 /*!
325 327 NOTICE: This function has to be called after series has been added to the chart if no customized axes are set to the chart. Otherwise axisX(), axisY() calls return NULL.
326 328
327 329 Creates the axes for the chart based on the series that has already been added to the chart.
328 If QXYSeries derived series has been added to the chart then QValuesAxes are created as X and Y axes for the series.
329 If QBarSeries or series types derived from it has been added then QBarCategoriesAxis is created as X axis and QValueAxis as Y axis.
330
331 \table
332 \header
333 \o Series type
334 \o X-axis
335 \o Y-axis
336 \row
337 \o QXYSeries
338 \o QValuesAxis
339 \o QValuesAxis
340 \row
341 \o QBarSeries
342 \o QBarCategoriesAxis
343 \o QValuesAxis
344 \row
345 \o QPieSeries
346 \o None
347 \o None
348 \endtable
349
330 350 If there are several QXYSeries derived series added to the chart and no other series type has been added then only one pair of axes is created.
331 351 If there are sevaral series added of different types then each series gets its own axes pair.
332 352
333 353 NOTICE: if there is more than one x and y axes created then no axis is drawn by default and one needs to choose explicitly which axis should be shown.
334 354
335 355 Axis specifix to the series can be later obtained from the chart by providing the series as the parameter of axisX(), axisY() function calls.
336 356 QPieSeries does not create any axes.
337 357
338 358 \sa axisX(), axisY(), setAxisX(), setAxisY()
339 359 */
340 360 void QChart::createDefaultAxes()
341 361 {
342 362 d_ptr->m_dataset->createDefaultAxes();
343 363 }
344 364
345 365 /*!
346 366 Returns the legend object of the chart. Ownership stays in chart.
347 367 */
348 368 QLegend* QChart::legend() const
349 369 {
350 370 return d_ptr->m_legend;
351 371 }
352 372
353 373 /*!
354 374 Returns the rect that contains information about margins (distance between chart widget edge and axes).
355 375 Individual margins can be obtained by calling left, top, right, bottom on the returned rect.
356 376 */
357 377 QRectF QChart::margins() const
358 378 {
359 379 return d_ptr->m_presenter->margins();
360 380 }
361 381
362 382 /*!
363 383 Sets animation \a options for the chart
364 384 */
365 385
366 386 void QChart::setAnimationOptions(AnimationOptions options)
367 387 {
368 388 d_ptr->m_presenter->setAnimationOptions(options);
369 389 }
370 390
371 391 QChart::AnimationOptions QChart::animationOptions() const
372 392 {
373 393 return d_ptr->m_presenter->animationOptions();
374 394 }
375 395
376 396 /*!
377 397 Scrolls the visible area of the chart by the distance defined in the \a dx and \a dy.
378 398 */
379 399 void QChart::scroll(qreal dx, qreal dy)
380 400 {
381 401 d_ptr->m_presenter->scroll(dx, dy);
382 402 }
383 403
384 404 void QChart::setBackgroundVisible(bool visible)
385 405 {
386 406 d_ptr->m_presenter->setBackgroundVisible(visible);
387 407 }
388 408
389 409 bool QChart::isBackgroundVisible() const
390 410 {
391 411 return d_ptr->m_presenter->isBackgroundVisible();
392 412 }
393 413
394 414 void QChart::setDropShadowEnabled(bool enabled)
395 415 {
396 416 d_ptr->m_presenter->setBackgroundDropShadowEnabled(enabled);
397 417 }
398 418
399 419 bool QChart::isDropShadowEnabled() const
400 420 {
401 421 return d_ptr->m_presenter->isBackgroundDropShadowEnabled();
402 422 }
403 423
404 424 /*!
405 425 Returns all the series that are added to the chart.
406 426
407 427 \sa addSeries(), removeSeries(), removeAllSeries()
408 428 */
409 429 QList<QAbstractSeries*> QChart::series() const
410 430 {
411 431 return d_ptr->m_dataset->series();
412 432 }
413 433
414 434 void QChart::setMarginsMinimum(const QRectF& margins)
415 435 {
416 436 d_ptr->m_presenter->setMarginsMinimum(margins);
417 437 }
418 438
419 439 /*!
420 440 Sets \a axis to the chart, which will control the presentation of the \a series
421 441
422 442 \sa axisX(), axisY(), setAxisY(), createDefaultAxes()
423 443 */
424 444 void QChart::setAxisX(QAbstractAxis* axis , QAbstractSeries *series)
425 445 {
426 446 d_ptr->m_dataset->setAxisX(series,axis);
427 447 }
428 448
429 449 /*!
430 450 Sets \a axis to the chart, which will control the presentation of the \a series
431 451
432 452 \sa axisX(), axisY(), setAxisX(), createDefaultAxes()
433 453 */
434 454 void QChart::setAxisY( QAbstractAxis* axis , QAbstractSeries *series)
435 455 {
436 456 d_ptr->m_dataset->setAxisY(series,axis);
437 457 }
438 458
439 459 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
440 460
441 461 QChartPrivate::QChartPrivate():
442 462 m_legend(0),
443 463 m_dataset(0),
444 464 m_presenter(0)
445 465 {
446 466
447 467 }
448 468
449 469 QChartPrivate::~QChartPrivate()
450 470 {
451 471
452 472 }
453 473
454 474 void QChartPrivate::createConnections()
455 475 {
456 476 QObject::connect(m_dataset,SIGNAL(seriesAdded(QAbstractSeries*,Domain*)),m_presenter,SLOT(handleSeriesAdded(QAbstractSeries*,Domain*)));
457 477 QObject::connect(m_dataset,SIGNAL(seriesRemoved(QAbstractSeries*)),m_presenter,SLOT(handleSeriesRemoved(QAbstractSeries*)));
458 478 QObject::connect(m_dataset,SIGNAL(axisAdded(QAbstractAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QAbstractAxis*,Domain*)));
459 479 QObject::connect(m_dataset,SIGNAL(axisRemoved(QAbstractAxis*)),m_presenter,SLOT(handleAxisRemoved(QAbstractAxis*)));
460 480 //QObject::connect(m_presenter, SIGNAL(marginsChanged(QRectF)), q_ptr, SIGNAL(marginsChanged(QRectF)));
461 481 }
462 482
463 483 #include "moc_qchart.cpp"
464 484
465 485 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now