@@ -1,109 +1,109 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qgroupedbarseries.h" |
|
21 | #include "qgroupedbarseries.h" | |
22 | #include "qgroupedbarseries_p.h" |
|
22 | #include "qgroupedbarseries_p.h" | |
23 | #include "groupedbarchartitem_p.h" |
|
23 | #include "groupedbarchartitem_p.h" | |
24 | #include "chartdataset_p.h" |
|
24 | #include "chartdataset_p.h" | |
25 | #include "charttheme_p.h" |
|
25 | #include "charttheme_p.h" | |
26 | #include "chartanimator_p.h" |
|
26 | #include "chartanimator_p.h" | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 | /*! |
|
30 | /*! | |
31 | \class QGroupedBarSeries |
|
31 | \class QGroupedBarSeries | |
32 | \brief part of QtCommercial chart API. |
|
32 | \brief part of QtCommercial chart API. | |
33 | \mainclass |
|
33 | \mainclass | |
34 |
|
34 | |||
35 | QGroupedBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars |
|
35 | QGroupedBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars | |
36 | as groups, where bars in same category are grouped next to each other. QGroupedBarSeries groups the data |
|
36 | as groups, where bars in same category are grouped next to each other. QGroupedBarSeries groups the data | |
37 | from sets to categories, which are defined by a QStringList. |
|
37 | from sets to categories, which are defined by a QStringList. | |
38 |
|
38 | |||
39 | See the \l {GroupedbarChart Example} {grouped bar chart example} to learn how to create a grouped bar chart. |
|
39 | See the \l {GroupedbarChart Example} {grouped bar chart example} to learn how to create a grouped bar chart. | |
40 | \image examples_groupedbarchart.png |
|
40 | \image examples_groupedbarchart.png | |
41 |
|
41 | |||
42 | \sa QBarSet, QPercentBarSeries, QBarSeries, QStackedBarSeries |
|
42 | \sa QBarSet, QPercentBarSeries, QBarSeries, QStackedBarSeries | |
43 | */ |
|
43 | */ | |
44 |
|
44 | |||
45 | /*! |
|
45 | /*! | |
46 | \fn virtual QSeriesType QGroupedBarSeries::type() const |
|
46 | \fn virtual QSeriesType QGroupedBarSeries::type() const | |
47 | \brief Returns type of series. |
|
47 | \brief Returns type of series. | |
48 | \sa QAbstractSeries, QSeriesType |
|
48 | \sa QAbstractSeries, QSeriesType | |
49 | */ |
|
49 | */ | |
50 |
|
50 | |||
51 | /*! |
|
51 | /*! | |
52 | Constructs empty QGroupedBarSeries. |
|
52 | Constructs empty QGroupedBarSeries. | |
53 | QGroupedBarSeries is QObject which is a child of a \a parent. |
|
53 | QGroupedBarSeries is QObject which is a child of a \a parent. | |
54 | */ |
|
54 | */ | |
55 | QGroupedBarSeries::QGroupedBarSeries(QObject *parent) |
|
55 | QGroupedBarSeries::QGroupedBarSeries(QObject *parent) | |
56 | : QBarSeries(*new QGroupedBarSeriesPrivate(this), parent) |
|
56 | : QBarSeries(*new QGroupedBarSeriesPrivate(this), parent) | |
57 | { |
|
57 | { | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
60 | QAbstractSeries::SeriesType QGroupedBarSeries::type() const |
|
60 | QAbstractSeries::SeriesType QGroupedBarSeries::type() const | |
61 | { |
|
61 | { | |
62 | return QAbstractSeries::SeriesTypeGroupedBar; |
|
62 | return QAbstractSeries::SeriesTypeGroupedBar; | |
63 | } |
|
63 | } | |
64 |
|
64 | |||
65 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
65 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
66 |
|
66 | |||
67 | QGroupedBarSeriesPrivate::QGroupedBarSeriesPrivate(QGroupedBarSeries *q) : QBarSeriesPrivate(q) |
|
67 | QGroupedBarSeriesPrivate::QGroupedBarSeriesPrivate(QGroupedBarSeries *q) : QBarSeriesPrivate(q) | |
68 | { |
|
68 | { | |
69 |
|
69 | |||
70 | } |
|
70 | } | |
71 |
|
71 | |||
72 | void QGroupedBarSeriesPrivate::scaleDomain(Domain& domain) |
|
72 | void QGroupedBarSeriesPrivate::scaleDomain(Domain& domain) | |
73 | { |
|
73 | { | |
74 | Q_Q(QGroupedBarSeries); |
|
74 | Q_Q(QGroupedBarSeries); | |
75 | qreal minX(domain.minX()); |
|
75 | qreal minX(domain.minX()); | |
76 | qreal minY(domain.minY()); |
|
76 | qreal minY(domain.minY()); | |
77 | qreal maxX(domain.maxX()); |
|
77 | qreal maxX(domain.maxX()); | |
78 | qreal maxY(domain.maxY()); |
|
78 | qreal maxY(domain.maxY()); | |
79 | int tickXCount(domain.tickXCount()); |
|
79 | int tickXCount(domain.tickXCount()); | |
80 | int tickYCount(domain.tickYCount()); |
|
80 | int tickYCount(domain.tickYCount()); | |
81 |
|
81 | |||
82 | qreal x = q->categoryCount(); |
|
82 | qreal x = q->categoryCount(); | |
83 |
qreal y = max |
|
83 | qreal y = max(); | |
84 | minX = qMin(minX, x); |
|
84 | minX = qMin(minX, x); | |
85 | minY = qMin(minY, y); |
|
85 | minY = qMin(minY, y); | |
86 | maxX = qMax(maxX, x); |
|
86 | maxX = qMax(maxX, x); | |
87 | maxY = qMax(maxY, y); |
|
87 | maxY = qMax(maxY, y); | |
88 | tickXCount = x+1; |
|
88 | tickXCount = x+1; | |
89 |
|
89 | |||
90 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); |
|
90 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); | |
91 | } |
|
91 | } | |
92 |
|
92 | |||
93 |
|
93 | |||
94 | Chart* QGroupedBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
94 | Chart* QGroupedBarSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
95 | { |
|
95 | { | |
96 | Q_Q(QGroupedBarSeries); |
|
96 | Q_Q(QGroupedBarSeries); | |
97 |
|
97 | |||
98 | GroupedBarChartItem* bar = new GroupedBarChartItem(q,presenter); |
|
98 | GroupedBarChartItem* bar = new GroupedBarChartItem(q,presenter); | |
99 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
99 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
100 | presenter->animator()->addAnimation(bar); |
|
100 | presenter->animator()->addAnimation(bar); | |
101 | } |
|
101 | } | |
102 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
102 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
103 | return bar; |
|
103 | return bar; | |
104 | } |
|
104 | } | |
105 |
|
105 | |||
106 | #include "moc_qgroupedbarseries.cpp" |
|
106 | #include "moc_qgroupedbarseries.cpp" | |
107 |
|
107 | |||
108 | QTCOMMERCIALCHART_END_NAMESPACE |
|
108 | QTCOMMERCIALCHART_END_NAMESPACE | |
109 |
|
109 |
General Comments 0
You need to be logged in to leave comments.
Login now