@@ -1,108 +1,109 | |||
|
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 "qgroupedbarseries.h" |
|
22 | 22 | #include "qgroupedbarseries_p.h" |
|
23 | 23 | #include "groupedbarchartitem_p.h" |
|
24 | 24 | #include "chartdataset_p.h" |
|
25 | 25 | #include "charttheme_p.h" |
|
26 | 26 | #include "chartanimator_p.h" |
|
27 | 27 | |
|
28 | 28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | 29 | |
|
30 | 30 | /*! |
|
31 | 31 | \class QGroupedBarSeries |
|
32 | 32 | \brief part of QtCommercial chart API. |
|
33 | 33 | \mainclass |
|
34 | 34 | |
|
35 | 35 | QGroupedBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars |
|
36 | 36 | as groups, where bars in same category are grouped next to each other. QGroupedBarSeries groups the data |
|
37 | 37 | from sets to categories, which are defined by a QStringList. |
|
38 | 38 | |
|
39 | 39 | See the \l {GroupedbarChart Example} {grouped bar chart example} to learn how to create a grouped bar chart. |
|
40 | 40 | \image examples_groupedbarchart.png |
|
41 | 41 | |
|
42 | 42 | \sa QBarSet, QPercentBarSeries, QBarSeries, QStackedBarSeries |
|
43 | 43 | */ |
|
44 | 44 | |
|
45 | 45 | /*! |
|
46 | 46 | \fn virtual QSeriesType QGroupedBarSeries::type() const |
|
47 | 47 | \brief Returns type of series. |
|
48 | 48 | \sa QAbstractSeries, QSeriesType |
|
49 | 49 | */ |
|
50 | 50 | |
|
51 | 51 | /*! |
|
52 | 52 | Constructs empty QGroupedBarSeries. |
|
53 | 53 | QGroupedBarSeries is QObject which is a child of a \a parent. |
|
54 | 54 | */ |
|
55 | 55 | QGroupedBarSeries::QGroupedBarSeries(QObject *parent) |
|
56 | 56 | : QBarSeries(*new QGroupedBarSeriesPrivate(this), parent) |
|
57 | 57 | { |
|
58 | 58 | } |
|
59 | 59 | |
|
60 | 60 | QAbstractSeries::SeriesType QGroupedBarSeries::type() const |
|
61 | 61 | { |
|
62 | 62 | return QAbstractSeries::SeriesTypeGroupedBar; |
|
63 | 63 | } |
|
64 | 64 | |
|
65 | 65 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
66 | 66 | |
|
67 |
QGroupedBarSeriesPrivate::QGroupedBarSeriesPrivate( |
|
|
67 | QGroupedBarSeriesPrivate::QGroupedBarSeriesPrivate(QGroupedBarSeries *q) : QBarSeriesPrivate(q) | |
|
68 | 68 | { |
|
69 | 69 | |
|
70 | 70 | } |
|
71 | 71 | |
|
72 | 72 | void QGroupedBarSeriesPrivate::scaleDomain(Domain& domain) |
|
73 | 73 | { |
|
74 | Q_Q(QGroupedBarSeries); | |
|
74 | 75 | qreal minX(domain.minX()); |
|
75 | 76 | qreal minY(domain.minY()); |
|
76 | 77 | qreal maxX(domain.maxX()); |
|
77 | 78 | qreal maxY(domain.maxY()); |
|
78 | 79 | int tickXCount(domain.tickXCount()); |
|
79 | 80 | int tickYCount(domain.tickYCount()); |
|
80 | 81 | |
|
81 |
qreal x = |
|
|
82 | qreal x = q->categoryCount(); | |
|
82 | 83 | qreal y = maxCategorySum(); |
|
83 | 84 | minX = qMin(minX, x); |
|
84 | 85 | minY = qMin(minY, y); |
|
85 | 86 | maxX = qMax(maxX, x); |
|
86 | 87 | maxY = qMax(maxY, y); |
|
87 | 88 | tickXCount = x+1; |
|
88 | 89 | |
|
89 | 90 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); |
|
90 | 91 | } |
|
91 | 92 | |
|
92 | 93 | |
|
93 | 94 | Chart* QGroupedBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
94 | 95 | { |
|
95 | 96 | Q_Q(QGroupedBarSeries); |
|
96 | 97 | |
|
97 | 98 | GroupedBarChartItem* bar = new GroupedBarChartItem(q,presenter); |
|
98 | 99 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
99 | 100 | presenter->animator()->addAnimation(bar); |
|
100 | 101 | } |
|
101 | 102 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
102 | 103 | return bar; |
|
103 | 104 | } |
|
104 | 105 | |
|
105 | 106 | #include "moc_qgroupedbarseries.cpp" |
|
106 | 107 | |
|
107 | 108 | QTCOMMERCIALCHART_END_NAMESPACE |
|
108 | 109 |
@@ -1,52 +1,52 | |||
|
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 | // W A R N I N G |
|
22 | 22 | // ------------- |
|
23 | 23 | // |
|
24 | 24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
25 | 25 | // implementation detail. This header file may change from version to |
|
26 | 26 | // version without notice, or even be removed. |
|
27 | 27 | // |
|
28 | 28 | // We mean it. |
|
29 | 29 | |
|
30 | 30 | #ifndef QPERCENTBARSERIES_P_H |
|
31 | 31 | #define QPERCENTBARSERIES_P_H |
|
32 | 32 | |
|
33 | 33 | #include "qbarseries_p.h" |
|
34 | 34 | #include "domain_p.h" |
|
35 | 35 | |
|
36 | 36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | 37 | |
|
38 | 38 | |
|
39 | 39 | class QPercentBarSeriesPrivate: public QBarSeriesPrivate |
|
40 | 40 | { |
|
41 | 41 | public: |
|
42 |
QPercentBarSeriesPrivate( |
|
|
42 | QPercentBarSeriesPrivate(QPercentBarSeries* q); | |
|
43 | 43 | void scaleDomain(Domain& domain); |
|
44 | 44 | Chart* createGraphics(ChartPresenter* presenter); |
|
45 | 45 | |
|
46 | 46 | private: |
|
47 | 47 | Q_DECLARE_PUBLIC(QPercentBarSeries) |
|
48 | 48 | }; |
|
49 | 49 | |
|
50 | 50 | QTCOMMERCIALCHART_END_NAMESPACE |
|
51 | 51 | |
|
52 | 52 | #endif |
@@ -1,108 +1,109 | |||
|
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 "chartanimator_p.h" |
|
27 | 27 | |
|
28 | 28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | 29 | |
|
30 | 30 | /*! |
|
31 | 31 | \class QStackedBarSeries |
|
32 | 32 | \brief part of QtCommercial chart API. |
|
33 | 33 | \mainclass |
|
34 | 34 | |
|
35 | 35 | QStackedBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars |
|
36 | 36 | as stacks, where bars in same category are stacked on top of each other. |
|
37 | 37 | QStackedBarSeries groups the data from sets to categories, which are defined by QStringList. |
|
38 | 38 | |
|
39 | 39 | See the \l {StackedbarChart Example} {stacked bar chart example} to learn how to create a stacked bar chart. |
|
40 | 40 | \image examples_stackedbarchart.png |
|
41 | 41 | |
|
42 | 42 | \sa QBarSet, QPercentBarSeries, QBarSeries |
|
43 | 43 | */ |
|
44 | 44 | |
|
45 | 45 | /*! |
|
46 | 46 | \fn virtual QSeriesType QStackedBarSeries::type() const |
|
47 | 47 | \brief Returns type of series. |
|
48 | 48 | \sa QAbstractSeries, QSeriesType |
|
49 | 49 | */ |
|
50 | 50 | |
|
51 | 51 | /*! |
|
52 | 52 | Constructs empty QStackedBarSeries. |
|
53 | 53 | QStackedBarSeries is QObject which is a child of a \a parent. |
|
54 | 54 | */ |
|
55 | 55 | QStackedBarSeries::QStackedBarSeries(QObject *parent) |
|
56 | 56 | : QBarSeries(*new QStackedBarSeriesPrivate(this), parent) |
|
57 | 57 | { |
|
58 | 58 | } |
|
59 | 59 | |
|
60 | 60 | QAbstractSeries::SeriesType QStackedBarSeries::type() const |
|
61 | 61 | { |
|
62 | 62 | return QAbstractSeries::SeriesTypeStackedBar; |
|
63 | 63 | } |
|
64 | 64 | |
|
65 | 65 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
66 | 66 | |
|
67 | 67 | QStackedBarSeriesPrivate::QStackedBarSeriesPrivate(QStackedBarSeries *q) : QBarSeriesPrivate(q) |
|
68 | 68 | { |
|
69 | 69 | |
|
70 | 70 | } |
|
71 | 71 | |
|
72 | 72 | void QStackedBarSeriesPrivate::scaleDomain(Domain& domain) |
|
73 | 73 | { |
|
74 | Q_Q(QStackedBarSeries); | |
|
74 | 75 | qreal minX(domain.minX()); |
|
75 | 76 | qreal minY(domain.minY()); |
|
76 | 77 | qreal maxX(domain.maxX()); |
|
77 | 78 | qreal maxY(domain.maxY()); |
|
78 | 79 | int tickXCount(domain.tickXCount()); |
|
79 | 80 | int tickYCount(domain.tickYCount()); |
|
80 | 81 | |
|
81 |
qreal x = |
|
|
82 | qreal x = q->categoryCount(); | |
|
82 | 83 | qreal y = maxCategorySum(); |
|
83 | 84 | minX = qMin(minX, x); |
|
84 | 85 | minY = qMin(minY, y); |
|
85 | 86 | maxX = qMax(maxX, x); |
|
86 | 87 | maxY = qMax(maxY, y); |
|
87 | 88 | tickXCount = x+1; |
|
88 | 89 | |
|
89 | 90 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); |
|
90 | 91 | } |
|
91 | 92 | |
|
92 | 93 | |
|
93 | 94 | Chart* QStackedBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
94 | 95 | { |
|
95 | 96 | Q_Q(QStackedBarSeries); |
|
96 | 97 | |
|
97 | 98 | StackedBarChartItem* bar = new StackedBarChartItem(q,presenter); |
|
98 | 99 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
99 | 100 | presenter->animator()->addAnimation(bar); |
|
100 | 101 | } |
|
101 | 102 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
102 | 103 | return bar; |
|
103 | 104 | } |
|
104 | 105 | |
|
105 | 106 | #include "moc_qstackedbarseries.cpp" |
|
106 | 107 | |
|
107 | 108 | QTCOMMERCIALCHART_END_NAMESPACE |
|
108 | 109 |
@@ -1,52 +1,52 | |||
|
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 | // W A R N I N G |
|
22 | 22 | // ------------- |
|
23 | 23 | // |
|
24 | 24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
25 | 25 | // implementation detail. This header file may change from version to |
|
26 | 26 | // version without notice, or even be removed. |
|
27 | 27 | // |
|
28 | 28 | // We mean it. |
|
29 | 29 | |
|
30 | 30 | #ifndef QSTACKEDBARSERIES_P_H |
|
31 | 31 | #define QSTACKEDBARSERIES_P_H |
|
32 | 32 | |
|
33 | 33 | #include "qbarseries_p.h" |
|
34 | 34 | #include "domain_p.h" |
|
35 | 35 | |
|
36 | 36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | 37 | |
|
38 | 38 | |
|
39 | 39 | class QStackedBarSeriesPrivate: public QBarSeriesPrivate |
|
40 | 40 | { |
|
41 | 41 | public: |
|
42 |
QStackedBarSeriesPrivate( |
|
|
42 | QStackedBarSeriesPrivate(QStackedBarSeries* q); | |
|
43 | 43 | Chart* createGraphics(ChartPresenter* presenter); |
|
44 | 44 | void scaleDomain(Domain& domain); |
|
45 | 45 | |
|
46 | 46 | private: |
|
47 | 47 | Q_DECLARE_PUBLIC(QStackedBarSeries) |
|
48 | 48 | }; |
|
49 | 49 | |
|
50 | 50 | QTCOMMERCIALCHART_END_NAMESPACE |
|
51 | 51 | |
|
52 | 52 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now