##// END OF EJS Templates
fixed warnings from barchart docs
sauimone -
r1850:734071afb80c
parent child
Show More
@@ -1,828 +1,834
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 "qabstractbarseries.h"
22 22 #include "qabstractbarseries_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 "qvalueaxis.h"
30 30 #include "qbarcategoryaxis.h"
31 31
32 32 QTCOMMERCIALCHART_BEGIN_NAMESPACE
33 33
34 34 /*!
35 35 \class QAbstractBarSeries
36 36 \brief Series for creating a bar chart
37 37 \mainclass
38 38
39 39 QAbstractBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars to
40 40 the position defined by data. Single bar is defined by QPointF, where x value is the x-coordinate of the bar
41 41 and y-value is the height of the bar. The category names are ignored with this series and x-axis
42 42 shows the x-values.
43 43
44 44 See the \l {BarChart Example} {bar chart example} to learn how to create a simple bar chart.
45 45 \image examples_barchart.png
46 46
47 47 \sa QBarSet, QStackedBarSeries, QPercentBarSeries
48 48 */
49 49 /*!
50 50 \qmlclass AbstractBarSeries QAbstractBarSeries
51 51 \inherits QAbstractSeries
52 52
53 53 The following QML shows how to create a simple bar chart:
54 54 \snippet ../demos/qmlchart/qml/qmlchart/View6.qml 1
55 55
56 56 \beginfloatleft
57 57 \image demos_qmlchart6.png
58 58 \endfloat
59 59 \clearfloat
60 60 */
61 61
62 62 /*!
63 63 \property QAbstractBarSeries::barWidth
64 64 The width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars
65 65 is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen
66 66 is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis.
67 67 Note that with QBarSeries this value means the width of one group of bars instead of just one bar.
68 68 \sa QBarSeries
69 69 */
70 70 /*!
71 71 \qmlproperty real AbstractBarSeries::barWidth
72 72 The width of the bars of the series. The unit of width is the unit of x-axis. The minimum width for bars
73 73 is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen
74 74 is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis.
75 75 Note that with QBarSeries this value means the width of one group of bars instead of just one bar.
76 76 */
77 77
78 78 /*!
79 79 \property QAbstractBarSeries::count
80 80 Holds the number of sets in series.
81 81 */
82 82 /*!
83 83 \qmlproperty int AbstractBarSeries::count
84 84 Holds the number of sets in series.
85 85 */
86 86
87 87 /*!
88 88 \property QAbstractBarSeries::labelsVisible
89 89 Defines the visibility of the labels in series
90 90 */
91 91 /*!
92 92 \qmlproperty bool AbstractBarSeries::labelsVisible
93 93 Defines the visibility of the labels in series
94 94 */
95 95
96 96 /*!
97 97 \fn void QAbstractBarSeries::clicked(int index, QBarSet *barset)
98 98 The signal is emitted if the user clicks with a mouse on top of QBarSet \a barset.
99 99 Clicked bar inside set is indexed by \a index
100 100 */
101 101 /*!
102 102 \qmlsignal AbstractBarSeries::onClicked(int index, BarSet barset)
103 103 The signal is emitted if the user clicks with a mouse on top of BarSet.
104 104 Clicked bar inside set is indexed by \a index
105 105 */
106 106
107 107 /*!
108 108 \fn void QAbstractBarSeries::hovered(bool status, QBarSet* barset)
109 109
110 110 The signal is emitted if mouse is hovered on top of series.
111 111 Parameter \a barset is the pointer of barset, where hover happened.
112 112 Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series.
113 113 */
114 114 /*!
115 115 \qmlsignal AbstractBarSeries::onHovered(bool status, BarSet barset)
116 116
117 117 The signal is emitted if mouse is hovered on top of series.
118 118 Parameter \a barset is the pointer of barset, where hover happened.
119 119 Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series.
120 120 */
121 121
122 122 /*!
123 123 \fn void QAbstractBarSeries::countChanged()
124 124 This signal is emitted when barset count has been changed, for example by append or remove.
125 125 */
126 126 /*!
127 127 \qmlsignal AbstractBarSeries::onCountChanged()
128 128 This signal is emitted when barset count has been changed, for example by append or remove.
129 129 */
130 130
131 131 /*!
132 132 \fn void QAbstractBarSeries::labelsVisibleChanged()
133 133 This signal is emitted when labels visibility have changed.
134 134 \sa isLabelsVisible(), setLabelsVisible()
135 135 */
136 136
137 137 /*!
138 138 \fn void QAbstractBarSeries::barsetsAdded(QList<QBarSet*> sets)
139 139 This signal is emitted when \a sets have been added to the series.
140 140 \sa append(), insert()
141 141 */
142 142 /*!
143 143 \qmlsignal AbstractBarSeries::onAdded(BarSet barset)
144 144 Emitted when \a barset has been added to the series.
145 145 */
146 146
147 147 /*!
148 148 \fn void QAbstractBarSeries::barsetsRemoved(QList<QBarSet*> sets)
149 149 This signal is emitted when \a sets have been removed from the series.
150 150 \sa remove()
151 151 */
152 152 /*!
153 153 \qmlsignal AbstractBarSeries::onRemoved(BarSet barset)
154 154 Emitted when \a barset has been removed from the series.
155 155 */
156 156
157 157 /*!
158 158 \qmlmethod BarSet AbstractBarSeries::at(int index)
159 159 Returns bar set at \a index. Returns null if the index is not valid.
160 160 */
161 161
162 162 /*!
163 163 \qmlmethod BarSet AbstractBarSeries::append(string label, VariantList values)
164 164 Adds a new bar set with \a label and \a values to \a index. Values can be a list of reals or a list of XYPoints.
165 165 For example:
166 166 \code
167 167 myBarSeries.append("set 1", [0, 0.2, 0.2, 0.5, 0.4, 1.5, 0.9]);
168 168 myBarSeries.append("set 2", [Qt.point(0, 1), Qt.point(2, 2.5), Qt.point(3.5, 2.2)]);
169 169 \endcode
170 170 */
171 171
172 172 /*!
173 173 \qmlmethod BarSet AbstractBarSeries::insert(int index, string label, VariantList values)
174 174 Inserts a new bar set with \a label and \a values to \a index. Values can be a list of reals or a list of XYPoints.
175 175 If index is zero or smaller, the new barset is prepended. If the index is count or bigger, the new barset is
176 176 appended.
177 177 \sa AbstractBarSeries::append()
178 178 */
179 179
180 180 /*!
181 181 \qmlmethod bool AbstractBarSeries::remove(BarSet barset)
182 182 Removes the barset from the series. Returns true if successfull, false otherwise.
183 183 */
184 184
185 185 /*!
186 186 \qmlmethod AbstractBarSeries::clear()
187 187 Removes all barsets from the series.
188 188 */
189 189
190 190 /*!
191 191 This is depreciated constructor.
192 \a parent
192 193 */
193 194 QAbstractBarSeries::QAbstractBarSeries(QObject *parent) :
194 195 QAbstractSeries(*(QAbstractBarSeriesPrivate*)(0),parent)
195 196 {
196 197 }
197 198
198 199 /*!
199 200 Destructs abstractbarseries and owned barsets.
200 201 */
201 202 QAbstractBarSeries::~QAbstractBarSeries()
202 203 {
203 204
204 205 }
205 206
206 207 /*!
207 208 \internal
208 209 */
209 210 QAbstractBarSeries::QAbstractBarSeries(QAbstractBarSeriesPrivate &d, QObject *parent) :
210 211 QAbstractSeries(d,parent)
211 212 {
212 213 }
213 214
214 215 /*!
215 216 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
216 217 is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen
217 218 is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis.
218 219 Note that with \link QBarSeries \endlink this value means the width of one group of bars instead of just one bar.
219 220 */
220 221 void QAbstractBarSeries::setBarWidth(qreal width)
221 222 {
222 223 Q_D(QAbstractBarSeries);
223 224 d->setBarWidth(width);
224 225 }
225 226
226 227 /*!
227 228 Returns the width of the bars of the series.
228 229 \sa setBarWidth()
229 230 */
230 231 qreal QAbstractBarSeries::barWidth() const
231 232 {
232 233 Q_D(const QAbstractBarSeries);
233 234 return d->barWidth();
234 235 }
235 236
236 237 /*!
237 238 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.
238 239 Returns true, if appending succeeded.
239 240 */
240 241 bool QAbstractBarSeries::append(QBarSet *set)
241 242 {
242 243 Q_D(QAbstractBarSeries);
243 244 bool success = d->append(set);
244 245 if (success) {
245 246 QList<QBarSet*> sets;
246 247 sets.append(set);
247 248 set->setParent(this);
248 249 emit barsetsAdded(sets);
249 250 emit countChanged();
250 251 }
251 252 return success;
252 253 }
253 254
254 255 /*!
255 256 Removes barset from series. Releases ownership of \a set. Deletes the set, if remove
256 257 was successful.
257 258 Returns true, if set was removed.
258 259 */
259 260 bool QAbstractBarSeries::remove(QBarSet *set)
260 261 {
261 262 Q_D(QAbstractBarSeries);
262 263 bool success = d->remove(set);
263 264 if (success) {
264 265 QList<QBarSet*> sets;
265 266 sets.append(set);
266 267 set->setParent(0);
267 268 emit barsetsRemoved(sets);
268 269 emit countChanged();
269 270 delete set;
270 271 set = 0;
271 272 }
272 273 return success;
273 274 }
274 275
275 276 /*!
276 277 Takes a single \a set from the series. Does not delete the barset object.
277 278
278 279 NOTE: The series remains as the barset's parent object. You must set the
279 280 parent object to take full ownership.
280 281
281 282 Returns true if take was successfull.
282 283 */
283 284 bool QAbstractBarSeries::take(QBarSet *set)
284 285 {
285 286 Q_D(QAbstractBarSeries);
286 287 bool success = d->remove(set);
287 288 if (success) {
288 289 QList<QBarSet*> sets;
289 290 sets.append(set);
290 291 emit barsetsRemoved(sets);
291 292 emit countChanged();
292 293 }
293 294 return success;
294 295 }
295 296
296 297 /*!
297 298 Adds a list of barsets to series. Takes ownership of \a sets.
298 299 Returns true, if all sets were appended succesfully. If any of the sets is null or is already appended to series,
299 300 nothing is appended and function returns false. If any of the sets is in list more than once, nothing is appended
300 301 and function returns false.
301 302 */
302 303 bool QAbstractBarSeries::append(QList<QBarSet* > sets)
303 304 {
304 305 Q_D(QAbstractBarSeries);
305 306 bool success = d->append(sets);
306 307 if (success) {
307 308 emit barsetsAdded(sets);
308 309 emit countChanged();
309 310 }
310 311 return success;
311 312 }
312 313
313 314 /*!
314 315 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.
315 316 Returns true, if inserting succeeded.
316 317
317 318 */
318 319 bool QAbstractBarSeries::insert(int index, QBarSet *set)
319 320 {
320 321 Q_D(QAbstractBarSeries);
321 322 bool success = d->insert(index, set);
322 323 if (success) {
323 324 QList<QBarSet*> sets;
324 325 sets.append(set);
325 326 emit barsetsAdded(sets);
326 327 emit countChanged();
327 328 }
328 329 return success;
329 330 }
330 331
331 332 /*!
332 333 Removes all barsets from the series. Deletes removed sets.
333 334 */
334 335 void QAbstractBarSeries::clear()
335 336 {
336 337 Q_D(QAbstractBarSeries);
337 338 QList<QBarSet *> sets = barSets();
338 339 bool success = d->remove(sets);
339 340 if (success) {
340 341 emit barsetsRemoved(sets);
341 342 emit countChanged();
342 343 foreach (QBarSet* set, sets) {
343 344 delete set;
344 345 }
345 346 }
346 347 }
347 348
348 349 /*!
349 350 Returns number of sets in series.
350 351 */
351 352 int QAbstractBarSeries::count() const
352 353 {
353 354 Q_D(const QAbstractBarSeries);
354 355 return d->m_barSets.count();
355 356 }
356 357
357 358 /*!
358 359 Returns a list of sets in series. Keeps ownership of sets.
359 360 */
360 361 QList<QBarSet*> QAbstractBarSeries::barSets() const
361 362 {
362 363 Q_D(const QAbstractBarSeries);
363 364 return d->m_barSets;
364 365 }
365 366
366 367 /*!
367 368 Sets the visibility of labels in series to \a visible
368 369 */
369 370 void QAbstractBarSeries::setLabelsVisible(bool visible)
370 371 {
371 372 Q_D(QAbstractBarSeries);
372 373 if (d->m_labelsVisible != visible) {
373 374 d->setLabelsVisible(visible);
374 375 emit labelsVisibleChanged();
375 376 }
376 377 }
377 378
378 379 /*!
379 380 Returns the visibility of labels
380 381 */
381 382 bool QAbstractBarSeries::isLabelsVisible() const
382 383 {
383 384 Q_D(const QAbstractBarSeries);
384 385 return d->m_labelsVisible;
385 386 }
386 387
388 /*!
389 Sets the grouped drawing mode for bars. If \a grouping is true, then the bars
390 are drawn at same position inside group. Can be used for example to draw negative bars
391 at same position on axis than positive bars.
392 */
387 393 void QAbstractBarSeries::setGrouping(bool grouping)
388 394 {
389 395 Q_D(QAbstractBarSeries);
390 396 d->setGrouping(grouping);
391 397 }
392 398
393 399
394 400
395 401 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
396 402
397 403 QAbstractBarSeriesPrivate::QAbstractBarSeriesPrivate(QAbstractBarSeries *q) :
398 404 QAbstractSeriesPrivate(q),
399 405 m_barWidth(0.5), // Default value is 50% of category width
400 406 m_labelsVisible(false),
401 407 m_visible(true),
402 408 m_grouping(true)
403 409 {
404 410 }
405 411
406 412 int QAbstractBarSeriesPrivate::categoryCount() const
407 413 {
408 414 // No categories defined. return count of longest set.
409 415 int count = 0;
410 416 for (int i=0; i<m_barSets.count(); i++) {
411 417 if (m_barSets.at(i)->count() > count) {
412 418 count = m_barSets.at(i)->count();
413 419 }
414 420 }
415 421
416 422 return count;
417 423 }
418 424
419 425 void QAbstractBarSeriesPrivate::setBarWidth(qreal width)
420 426 {
421 427 if (width < 0.0) {
422 428 width = 0.0;
423 429 }
424 430 m_barWidth = width;
425 431 emit updatedBars();
426 432 }
427 433
428 434 qreal QAbstractBarSeriesPrivate::barWidth() const
429 435 {
430 436 return m_barWidth;
431 437 }
432 438
433 439 QBarSet* QAbstractBarSeriesPrivate::barsetAt(int index)
434 440 {
435 441 return m_barSets.at(index);
436 442 }
437 443
438 444 void QAbstractBarSeriesPrivate::setVisible(bool visible)
439 445 {
440 446 m_visible = visible;
441 447 emit updatedBars();
442 448 }
443 449
444 450 void QAbstractBarSeriesPrivate::setLabelsVisible(bool visible)
445 451 {
446 452 m_labelsVisible = visible;
447 453 emit labelsVisibleChanged(visible);
448 454 }
449 455
450 456 void QAbstractBarSeriesPrivate::setGrouping(bool grouping)
451 457 {
452 458 if (m_grouping != grouping) {
453 459 m_grouping = grouping;
454 460 emit updatedBars();
455 461 }
456 462 }
457 463
458 464 qreal QAbstractBarSeriesPrivate::min()
459 465 {
460 466 if (m_barSets.count() <= 0) {
461 467 return 0;
462 468 }
463 469 qreal min = INT_MAX;
464 470
465 471 for (int i = 0; i < m_barSets.count(); i++) {
466 472 int categoryCount = m_barSets.at(i)->count();
467 473 for (int j = 0; j < categoryCount; j++) {
468 474 qreal temp = m_barSets.at(i)->at(j);
469 475 if (temp < min)
470 476 min = temp;
471 477 }
472 478 }
473 479 return min;
474 480 }
475 481
476 482 qreal QAbstractBarSeriesPrivate::max()
477 483 {
478 484 if (m_barSets.count() <= 0) {
479 485 return 0;
480 486 }
481 487 qreal max = INT_MIN;
482 488
483 489 for (int i = 0; i < m_barSets.count(); i++) {
484 490 int categoryCount = m_barSets.at(i)->count();
485 491 for (int j = 0; j < categoryCount; j++) {
486 492 qreal temp = m_barSets.at(i)->at(j);
487 493 if (temp > max)
488 494 max = temp;
489 495 }
490 496 }
491 497
492 498 return max;
493 499 }
494 500
495 501 qreal QAbstractBarSeriesPrivate::valueAt(int set, int category)
496 502 {
497 503 if ((set < 0) || (set >= m_barSets.count())) {
498 504 // No set, no value.
499 505 return 0;
500 506 } else if ((category < 0) || (category >= m_barSets.at(set)->count())) {
501 507 // No category, no value.
502 508 return 0;
503 509 }
504 510
505 511 return m_barSets.at(set)->at(category);
506 512 }
507 513
508 514 qreal QAbstractBarSeriesPrivate::percentageAt(int set, int category)
509 515 {
510 516 if ((set < 0) || (set >= m_barSets.count())) {
511 517 // No set, no value.
512 518 return 0;
513 519 } else if ((category < 0) || (category >= m_barSets.at(set)->count())) {
514 520 // No category, no value.
515 521 return 0;
516 522 }
517 523
518 524 qreal value = m_barSets.at(set)->at(category);
519 525 qreal sum = categorySum(category);
520 526 if ( qFuzzyIsNull(sum) ) {
521 527 return 0;
522 528 }
523 529
524 530 return value / sum;
525 531 }
526 532
527 533 qreal QAbstractBarSeriesPrivate::categorySum(int category)
528 534 {
529 535 qreal sum(0);
530 536 int count = m_barSets.count(); // Count sets
531 537 for (int set = 0; set < count; set++) {
532 538 if (category < m_barSets.at(set)->count())
533 539 sum += m_barSets.at(set)->at(category);
534 540 }
535 541 return sum;
536 542 }
537 543
538 544 qreal QAbstractBarSeriesPrivate::absoluteCategorySum(int category)
539 545 {
540 546 qreal sum(0);
541 547 int count = m_barSets.count(); // Count sets
542 548 for (int set = 0; set < count; set++) {
543 549 if (category < m_barSets.at(set)->count())
544 550 sum += qAbs(m_barSets.at(set)->at(category));
545 551 }
546 552 return sum;
547 553 }
548 554
549 555 qreal QAbstractBarSeriesPrivate::maxCategorySum()
550 556 {
551 557 qreal max = INT_MIN;
552 558 int count = categoryCount();
553 559 for (int i = 0; i < count; i++) {
554 560 qreal sum = categorySum(i);
555 561 if (sum > max)
556 562 max = sum;
557 563 }
558 564 return max;
559 565 }
560 566
561 567 qreal QAbstractBarSeriesPrivate::minX()
562 568 {
563 569 if (m_barSets.count() <= 0) {
564 570 return 0;
565 571 }
566 572 qreal min = INT_MAX;
567 573
568 574 for (int i = 0; i < m_barSets.count(); i++) {
569 575 int categoryCount = m_barSets.at(i)->count();
570 576 for (int j = 0; j < categoryCount; j++) {
571 577 qreal temp = m_barSets.at(i)->d_ptr.data()->m_values.at(j).x();
572 578 if (temp < min)
573 579 min = temp;
574 580 }
575 581 }
576 582 return min;
577 583 }
578 584
579 585 qreal QAbstractBarSeriesPrivate::maxX()
580 586 {
581 587 if (m_barSets.count() <= 0) {
582 588 return 0;
583 589 }
584 590 qreal max = INT_MIN;
585 591
586 592 for (int i = 0; i < m_barSets.count(); i++) {
587 593 int categoryCount = m_barSets.at(i)->count();
588 594 for (int j = 0; j < categoryCount; j++) {
589 595 qreal temp = m_barSets.at(i)->d_ptr.data()->m_values.at(j).x();
590 596 if (temp > max)
591 597 max = temp;
592 598 }
593 599 }
594 600
595 601 return max;
596 602 }
597 603
598 604
599 605 void QAbstractBarSeriesPrivate::scaleDomain(Domain& domain)
600 606 {
601 607 qreal minX(domain.minX());
602 608 qreal minY(domain.minY());
603 609 qreal maxX(domain.maxX());
604 610 qreal maxY(domain.maxY());
605 611
606 612 qreal seriesMinX = this->minX();
607 613 qreal seriesMaxX = this->maxX();
608 614 qreal y = max();
609 615 minX = qMin(minX, seriesMinX - (qreal)0.5);
610 616 minY = qMin(minY, y);
611 617 maxX = qMax(maxX, seriesMaxX + (qreal)0.5);
612 618 maxY = qMax(maxY, y);
613 619
614 620 domain.setRange(minX,maxX,minY,maxY);
615 621 }
616 622
617 623 ChartElement* QAbstractBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
618 624 {
619 625 Q_UNUSED(presenter);
620 626 qWarning() << "QAbstractBarSeriesPrivate::createGraphics called";
621 627 return 0;
622 628 }
623 629
624 630 QList<LegendMarker*> QAbstractBarSeriesPrivate::createLegendMarker(QLegend* legend)
625 631 {
626 632 Q_Q(QAbstractBarSeries);
627 633 QList<LegendMarker*> markers;
628 634 foreach(QBarSet* set, q->barSets()) {
629 635 BarLegendMarker* marker = new BarLegendMarker(q,set,legend);
630 636 markers << marker;
631 637 }
632 638
633 639 return markers;
634 640 }
635 641
636 642 bool QAbstractBarSeriesPrivate::append(QBarSet *set)
637 643 {
638 644 Q_Q(QAbstractBarSeries);
639 645 if ((m_barSets.contains(set)) || (set == 0)) {
640 646 // Fail if set is already in list or set is null.
641 647 return false;
642 648 }
643 649 m_barSets.append(set);
644 650 QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
645 651 QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
646 652 emit restructuredBars(); // this notifies barchartitem
647 653 if (m_dataset) {
648 654 m_dataset->updateSeries(q); // this notifies legend
649 655 }
650 656 return true;
651 657 }
652 658
653 659 bool QAbstractBarSeriesPrivate::remove(QBarSet *set)
654 660 {
655 661 Q_Q(QAbstractBarSeries);
656 662 if (!m_barSets.contains(set)) {
657 663 // Fail if set is not in list
658 664 return false;
659 665 }
660 666 m_barSets.removeOne(set);
661 667 QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
662 668 QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
663 669 emit restructuredBars(); // this notifies barchartitem
664 670 if (m_dataset) {
665 671 m_dataset->updateSeries(q); // this notifies legend
666 672 }
667 673 return true;
668 674 }
669 675
670 676 bool QAbstractBarSeriesPrivate::append(QList<QBarSet* > sets)
671 677 {
672 678 Q_Q(QAbstractBarSeries);
673 679 foreach (QBarSet* set, sets) {
674 680 if ((set == 0) || (m_barSets.contains(set))) {
675 681 // Fail if any of the sets is null or is already appended.
676 682 return false;
677 683 }
678 684 if (sets.count(set) != 1) {
679 685 // Also fail if same set is more than once in given list.
680 686 return false;
681 687 }
682 688 }
683 689
684 690 foreach (QBarSet* set, sets) {
685 691 m_barSets.append(set);
686 692 QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
687 693 QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
688 694 }
689 695 emit restructuredBars(); // this notifies barchartitem
690 696 if (m_dataset) {
691 697 m_dataset->updateSeries(q); // this notifies legend
692 698 }
693 699 return true;
694 700 }
695 701
696 702 bool QAbstractBarSeriesPrivate::remove(QList<QBarSet* > sets)
697 703 {
698 704 Q_Q(QAbstractBarSeries);
699 705 if (sets.count() == 0) {
700 706 return false;
701 707 }
702 708 foreach (QBarSet* set, sets) {
703 709 if ((set == 0) || (!m_barSets.contains(set))) {
704 710 // Fail if any of the sets is null or is not in series
705 711 return false;
706 712 }
707 713 if (sets.count(set) != 1) {
708 714 // Also fail if same set is more than once in given list.
709 715 return false;
710 716 }
711 717 }
712 718
713 719 foreach (QBarSet* set, sets) {
714 720 m_barSets.removeOne(set);
715 721 QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
716 722 QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
717 723 }
718 724
719 725 emit restructuredBars(); // this notifies barchartitem
720 726 if (m_dataset) {
721 727 m_dataset->updateSeries(q); // this notifies legend
722 728 }
723 729 return true;
724 730 }
725 731
726 732 bool QAbstractBarSeriesPrivate::insert(int index, QBarSet *set)
727 733 {
728 734 Q_Q(QAbstractBarSeries);
729 735 if ((m_barSets.contains(set)) || (set == 0)) {
730 736 // Fail if set is already in list or set is null.
731 737 return false;
732 738 }
733 739 m_barSets.insert(index, set);
734 740 QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
735 741 QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
736 742 emit restructuredBars(); // this notifies barchartitem
737 743 if (m_dataset) {
738 744 m_dataset->updateSeries(q); // this notifies legend
739 745 }
740 746 return true;
741 747 }
742 748
743 749 void QAbstractBarSeriesPrivate::initializeAxis(QAbstractAxis* axis)
744 750 {
745 751 Q_Q(QAbstractBarSeries);
746 752
747 753 if(axis->type()==QAbstractAxis::AxisTypeBarCategory) {
748 754
749 755 switch(q->type()) {
750 756
751 757 case QAbstractSeries::SeriesTypeHorizontalBar:
752 758 case QAbstractSeries::SeriesTypeHorizontalPercentBar:
753 759 case QAbstractSeries::SeriesTypeHorizontalStackedBar: {
754 760
755 761 if(axis->orientation()==Qt::Vertical)
756 762 {
757 763 populateCategories(qobject_cast<QBarCategoryAxis*>(axis));
758 764 }
759 765 break;
760 766 }
761 767 case QAbstractSeries::SeriesTypeBar:
762 768 case QAbstractSeries::SeriesTypePercentBar:
763 769 case QAbstractSeries::SeriesTypeStackedBar: {
764 770
765 771 if(axis->orientation()==Qt::Horizontal)
766 772 {
767 773 populateCategories(qobject_cast<QBarCategoryAxis*>(axis));
768 774 }
769 775 break;
770 776 }
771 777 default:
772 778 qWarning()<<"Unexpected series type";
773 779 break;
774 780
775 781 }
776 782 }
777 783 }
778 784
779 785 QAbstractAxis::AxisType QAbstractBarSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const
780 786 {
781 787 Q_Q(const QAbstractBarSeries);
782 788
783 789 switch(q->type()) {
784 790
785 791 case QAbstractSeries::SeriesTypeHorizontalBar:
786 792 case QAbstractSeries::SeriesTypeHorizontalPercentBar:
787 793 case QAbstractSeries::SeriesTypeHorizontalStackedBar: {
788 794
789 795 if(orientation==Qt::Vertical)
790 796 {
791 797 return QAbstractAxis::AxisTypeBarCategory;
792 798 }
793 799 break;
794 800 }
795 801 case QAbstractSeries::SeriesTypeBar:
796 802 case QAbstractSeries::SeriesTypePercentBar:
797 803 case QAbstractSeries::SeriesTypeStackedBar: {
798 804
799 805 if(orientation==Qt::Horizontal)
800 806 {
801 807 return QAbstractAxis::AxisTypeBarCategory;
802 808 }
803 809 break;
804 810 }
805 811 default:
806 812 qWarning()<<"Unexpected series type";
807 813 break;
808 814
809 815 }
810 816 return QAbstractAxis::AxisTypeValue;
811 817
812 818 }
813 819
814 820 void QAbstractBarSeriesPrivate::populateCategories(QBarCategoryAxis* axis)
815 821 {
816 822 QStringList categories;
817 823 if(axis->categories().isEmpty()) {
818 824 for (int i(1); i < categoryCount()+1; i++)
819 825 categories << QString::number(i);
820 826 axis->append(categories);
821 827 }
822 828 }
823 829
824 830 #include "moc_qabstractbarseries.cpp"
825 831 #include "moc_qabstractbarseries_p.cpp"
826 832
827 833
828 834 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,91 +1,89
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 //TODO DEPRECIATED
42 42 explicit QAbstractBarSeries(QObject *parent = 0);
43 43
44 44 public:
45 45 virtual ~QAbstractBarSeries();
46 46
47 47 void setBarWidth(qreal width);
48 48 qreal barWidth() const;
49 49
50 50 bool append(QBarSet *set);
51 51 bool remove(QBarSet *set);
52 52 bool take(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 // TODO. Good name for this. This affects how bars are laid out on chart. (for example with pyramid chart)
63 // Also do we support same for stacked and percent bar charts or just normal bar charts?
64 62 void setGrouping(bool grouping = true);
65 63
66 64 protected:
67 65 explicit QAbstractBarSeries(QAbstractBarSeriesPrivate &d,QObject *parent = 0);
68 66
69 67 Q_SIGNALS:
70 68 void clicked(int index, QBarSet *barset);
71 69 void hovered(bool status, QBarSet *barset);
72 70 void countChanged();
73 71 void labelsVisibleChanged();
74 72
75 73 void barsetsAdded(QList<QBarSet*> sets);
76 74 void barsetsRemoved(QList<QBarSet*> sets);
77 75
78 76 protected:
79 77 Q_DECLARE_PRIVATE(QAbstractBarSeries)
80 78 friend class AbstractBarChartItem;
81 79 friend class PercentBarChartItem;
82 80 friend class StackedBarChartItem;
83 81 friend class BarChartItem;
84 82 friend class HorizontalBarChartItem;
85 83 friend class HorizontalStackedBarChartItem;
86 84 friend class HorizontalPercentBarChartItem;
87 85 };
88 86
89 87 QTCOMMERCIALCHART_END_NAMESPACE
90 88
91 89 #endif // ABSTRACTBARSERIES_H
@@ -1,121 +1,124
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 "barchartitem_p.h"
24 24 #include "chartdataset_p.h"
25 25 #include "charttheme_p.h"
26 26 #include "baranimation_p.h"
27 27 #include "qvalueaxis.h"
28 28 #include "qbarcategoryaxis.h"
29 29
30 30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 31
32 32 /*!
33 33 \class QBarSeries
34 34 \brief Series for creating bar chart
35 35 \mainclass
36 36
37 37 QBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars
38 38 as groups, where bars in same category are grouped next to each other. QBarSeries groups the data
39 39 from sets to categories, which are defined by a QStringList.
40 40
41 41 See the \l {BarChart Example} {bar chart example} to learn how to create a grouped bar chart.
42 42 \image examples_barchart.png
43 43
44 44 \sa QBarSet, QPercentBarSeries, QAbstractBarSeries, QStackedBarSeries
45 45 */
46 46 /*!
47 47 \qmlclass BarSeries QBarSeries
48 48 \inherits AbstractBarSeries
49 49
50 50 The following QML shows how to create a simple grouped bar chart:
51 51 \snippet ../demos/qmlchart/qml/qmlchart/View6.qml 1
52 52 \beginfloatleft
53 53 \image demos_qmlchart6.png
54 54 \endfloat
55 55 \clearfloat
56 56 */
57 57
58 58 /*!
59 59 Constructs empty QBarSeries.
60 60 QBarSeries is QObject which is a child of a \a parent.
61 61 */
62 62 QBarSeries::QBarSeries(QObject *parent)
63 63 : QAbstractBarSeries(*new QBarSeriesPrivate(this), parent)
64 64 {
65 65 }
66 66
67 67 /*!
68 68 Returns QChartSeries::SeriesTypeBar.
69 69 */
70 70 QAbstractSeries::SeriesType QBarSeries::type() const
71 71 {
72 72 return QAbstractSeries::SeriesTypeBar;
73 73 }
74 74
75 /*!
76 Destructor. Removes series from chart.
77 */
75 78 QBarSeries::~QBarSeries()
76 79 {
77 80 Q_D(QBarSeries);
78 81 if(d->m_dataset) {
79 82 d->m_dataset->removeSeries(this);
80 83 }
81 84 }
82 85 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
83 86
84 87 QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) : QAbstractBarSeriesPrivate(q)
85 88 {
86 89
87 90 }
88 91
89 92 void QBarSeriesPrivate::scaleDomain(Domain& domain)
90 93 {
91 94 qreal minX(domain.minX());
92 95 qreal minY(domain.minY());
93 96 qreal maxX(domain.maxX());
94 97 qreal maxY(domain.maxY());
95 98
96 99 qreal x = categoryCount();
97 100 minX = qMin(minX, - (qreal)0.5);
98 101 minY = qMin(minY, min());
99 102 maxX = qMax(maxX, x - (qreal)0.5);
100 103 maxY = qMax(maxY, max());
101 104
102 105 domain.setRange(minX,maxX,minY,maxY);
103 106 }
104 107
105 108
106 109 ChartElement* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
107 110 {
108 111 Q_Q(QBarSeries);
109 112
110 113 BarChartItem* bar = new BarChartItem(q,presenter);
111 114 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
112 115 bar->setAnimation(new BarAnimation(bar));
113 116 }
114 117 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
115 118 return bar;
116 119 }
117 120
118 121 #include "moc_qbarseries.cpp"
119 122
120 123 QTCOMMERCIALCHART_END_NAMESPACE
121 124
@@ -1,121 +1,124
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 "qpercentbarseries.h"
22 22 #include "qpercentbarseries_p.h"
23 23 #include "percentbarchartitem_p.h"
24 24 #include "chartdataset_p.h"
25 25 #include "charttheme_p.h"
26 26 #include "qvalueaxis.h"
27 27 #include "percentbaranimation_p.h"
28 28
29 29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 30
31 31 /*!
32 32 \class QPercentBarSeries
33 33 \brief Series for creating percent bar chart
34 34 \mainclass
35 35
36 36 QPercentBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars
37 37 as stacks, where each bar is shown as percentage of all bars in that category.
38 38 QPercentBarSeries groups the data from sets to categories, which are defined by a QStringList.
39 39
40 40 See the \l {PercentbarChart Example} {percent bar chart example} to learn how to create a percent bar chart.
41 41 \image examples_percentbarchart.png
42 42
43 43 \sa QBarSet, QStackedBarSeries, QAbstractBarSeries
44 44 */
45 45 /*!
46 46 \qmlclass PercentBarSeries QPercentBarSeries
47 47 \inherits QAbstractBarSeries
48 48
49 49 The following QML shows how to create a simple percent bar chart:
50 50 \snippet ../demos/qmlchart/qml/qmlchart/View8.qml 1
51 51 \beginfloatleft
52 52 \image demos_qmlchart8.png
53 53 \endfloat
54 54 \clearfloat
55 55 */
56 56
57 57 /*!
58 58 Constructs empty QPercentBarSeries.
59 59 QPercentBarSeries is QObject which is a child of a \a parent.
60 60 */
61 61 QPercentBarSeries::QPercentBarSeries(QObject *parent)
62 62 : QAbstractBarSeries(*new QPercentBarSeriesPrivate(this), parent)
63 63 {
64 64 }
65 65
66 /*!
67 Destructor. Removes series from chart.
68 */
66 69 QPercentBarSeries::~QPercentBarSeries()
67 70 {
68 71 Q_D(QPercentBarSeries);
69 72 if(d->m_dataset) {
70 73 d->m_dataset->removeSeries(this);
71 74 }
72 75 }
73 76
74 77 /*!
75 78 Returns QChartSeries::SeriesTypePercentBar.
76 79 */
77 80 QAbstractSeries::SeriesType QPercentBarSeries::type() const
78 81 {
79 82 return QAbstractSeries::SeriesTypePercentBar;
80 83 }
81 84
82 85 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
83 86
84 87 QPercentBarSeriesPrivate::QPercentBarSeriesPrivate(QPercentBarSeries *q) : QAbstractBarSeriesPrivate(q)
85 88 {
86 89
87 90 }
88 91
89 92 void QPercentBarSeriesPrivate::scaleDomain(Domain& domain)
90 93 {
91 94 qreal minX(domain.minX());
92 95 qreal minY(domain.minY());
93 96 qreal maxX(domain.maxX());
94 97 qreal maxY(domain.maxY());
95 98
96 99 qreal x = categoryCount();
97 100 minX = qMin(minX, - (qreal)0.5);
98 101 maxX = qMax(maxX, x - (qreal)0.5);
99 102 minY = 0;
100 103 maxY = 100;
101 104
102 105 domain.setRange(minX,maxX,minY,maxY);
103 106 }
104 107
105 108
106 109 ChartElement* QPercentBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
107 110 {
108 111 Q_Q(QPercentBarSeries);
109 112
110 113 PercentBarChartItem* bar = new PercentBarChartItem(q,presenter);
111 114 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
112 115 bar->setAnimation(new PercentBarAnimation(bar));
113 116 }
114 117 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
115 118 return bar;
116 119 }
117 120
118 121 #include "moc_qpercentbarseries.cpp"
119 122
120 123 QTCOMMERCIALCHART_END_NAMESPACE
121 124
@@ -1,122 +1,125
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 "qstackedbarseries.h"
22 22 #include "qstackedbarseries_p.h"
23 23 #include "stackedbarchartitem_p.h"
24 24 #include "chartdataset_p.h"
25 25 #include "charttheme_p.h"
26 26 #include "qvalueaxis.h"
27 27 #include "stackedbaranimation_p.h"
28 28
29 29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 30
31 31 /*!
32 32 \class QStackedBarSeries
33 33 \brief Series for creating stacked bar chart
34 34 \mainclass
35 35
36 36 QStackedBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars
37 37 as stacks, where bars in same category are stacked on top of each other.
38 38 QStackedBarSeries groups the data from sets to categories, which are defined by QStringList.
39 39
40 40 See the \l {StackedbarChart Example} {stacked bar chart example} to learn how to create a stacked bar chart.
41 41 \image examples_stackedbarchart.png
42 42
43 43 \sa QBarSet, QPercentBarSeries, QAbstractBarSeries
44 44 */
45 45
46 46 /*!
47 47 \qmlclass StackedBarSeries QStackedBarSeries
48 48 \inherits AbstractBarSeries
49 49
50 50 The following QML shows how to create a simple stacked bar chart:
51 51 \snippet ../demos/qmlchart/qml/qmlchart/View7.qml 1
52 52 \beginfloatleft
53 53 \image demos_qmlchart7.png
54 54 \endfloat
55 55 \clearfloat
56 56 */
57 57
58 58 /*!
59 59 Constructs empty QStackedBarSeries.
60 60 QStackedBarSeries is QObject which is a child of a \a parent.
61 61 */
62 62 QStackedBarSeries::QStackedBarSeries(QObject *parent)
63 63 : QAbstractBarSeries(*new QStackedBarSeriesPrivate(this), parent)
64 64 {
65 65 }
66 66
67 /*!
68 Destructor. Removes series from chart.
69 */
67 70 QStackedBarSeries::~QStackedBarSeries()
68 71 {
69 72 Q_D(QStackedBarSeries);
70 73 if(d->m_dataset) {
71 74 d->m_dataset->removeSeries(this);
72 75 }
73 76 }
74 77 /*!
75 78 Returns QChartSeries::SeriesTypeStackedBar.
76 79 */
77 80 QAbstractSeries::SeriesType QStackedBarSeries::type() const
78 81 {
79 82 return QAbstractSeries::SeriesTypeStackedBar;
80 83 }
81 84
82 85 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
83 86
84 87 QStackedBarSeriesPrivate::QStackedBarSeriesPrivate(QStackedBarSeries *q) : QAbstractBarSeriesPrivate(q)
85 88 {
86 89
87 90 }
88 91
89 92 void QStackedBarSeriesPrivate::scaleDomain(Domain& domain)
90 93 {
91 94 qreal minX(domain.minX());
92 95 qreal minY(domain.minY());
93 96 qreal maxX(domain.maxX());
94 97 qreal maxY(domain.maxY());
95 98
96 99 qreal x = categoryCount();
97 100 qreal y = maxCategorySum();
98 101 minX = qMin(minX, - (qreal)0.5);
99 102 minY = qMin(minY, y);
100 103 maxX = qMax(maxX, x - (qreal)0.5);
101 104 maxY = qMax(maxY, y);
102 105
103 106 domain.setRange(minX,maxX,minY,maxY);
104 107 }
105 108
106 109
107 110 ChartElement* QStackedBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
108 111 {
109 112 Q_Q(QStackedBarSeries);
110 113
111 114 StackedBarChartItem* bar = new StackedBarChartItem(q,presenter);
112 115 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
113 116 bar->setAnimation(new StackedBarAnimation(bar));
114 117 }
115 118 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
116 119 return bar;
117 120 }
118 121
119 122 #include "moc_qstackedbarseries.cpp"
120 123
121 124 QTCOMMERCIALCHART_END_NAMESPACE
122 125
General Comments 0
You need to be logged in to leave comments. Login now