##// END OF EJS Templates
Remove createAxis from subclassess, if it is not nessery
Michal Klocek -
r1560:e99e16c1c580
parent child
Show More
@@ -1,130 +1,119
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 #include "qcategoriesaxis.h"
28 28 #include "qvaluesaxis.h"
29 29
30 30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 31
32 32 /*!
33 33 \class QGroupedBarSeries
34 34 \brief Series for creating grouped bar chart
35 35 \mainclass
36 36
37 37 QGroupedBarSeries 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. QGroupedBarSeries groups the data
39 39 from sets to categories, which are defined by a QStringList.
40 40
41 41 See the \l {GroupedbarChart Example} {grouped bar chart example} to learn how to create a grouped bar chart.
42 42 \image examples_groupedbarchart.png
43 43
44 44 \sa QBarSet, QPercentBarSeries, QBarSeries, QStackedBarSeries
45 45 */
46 46 /*!
47 47 \qmlclass GroupedBarSeries QGroupedBarSeries
48 48 \inherits BarSeries
49 49
50 50 The following QML shows how to create a simple grouped bar chart:
51 51 \snippet ../demos/qmlchart/qml/qmlchart/View8.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 QGroupedBarSeries.
60 60 QGroupedBarSeries is QObject which is a child of a \a parent.
61 61 */
62 62 QGroupedBarSeries::QGroupedBarSeries(QObject *parent)
63 63 : QBarSeries(*new QGroupedBarSeriesPrivate(this), parent)
64 64 {
65 65 }
66 66
67 67 /*!
68 68 Returns QChartSeries::SeriesTypeGroupedBar.
69 69 */
70 70 QAbstractSeries::SeriesType QGroupedBarSeries::type() const
71 71 {
72 72 return QAbstractSeries::SeriesTypeGroupedBar;
73 73 }
74 74
75 75 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
76 76
77 77 QGroupedBarSeriesPrivate::QGroupedBarSeriesPrivate(QGroupedBarSeries *q) : QBarSeriesPrivate(q)
78 78 {
79 79
80 80 }
81 81
82 82 void QGroupedBarSeriesPrivate::scaleDomain(Domain& domain)
83 83 {
84 84 qreal minX(domain.minX());
85 85 qreal minY(domain.minY());
86 86 qreal maxX(domain.maxX());
87 87 qreal maxY(domain.maxY());
88 88 int tickXCount(domain.tickXCount());
89 89 int tickYCount(domain.tickYCount());
90 90
91 91 qreal x = categoryCount();
92 92 qreal y = max();
93 93 minX = qMin(minX, -0.5);
94 94 minY = qMin(minY, y);
95 95 maxX = qMax(maxX, x - 0.5);
96 96 maxY = qMax(maxY, y);
97 97 tickXCount = x+1;
98 98
99 99 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
100 100 }
101 101
102 102
103 103 Chart* QGroupedBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
104 104 {
105 105 Q_Q(QGroupedBarSeries);
106 106
107 107 GroupedBarChartItem* bar = new GroupedBarChartItem(q,presenter);
108 108 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
109 109 presenter->animator()->addAnimation(bar);
110 110 }
111 111 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
112 112 return bar;
113 113 }
114 114
115 QAbstractAxis* QGroupedBarSeriesPrivate::createAxisX()
116 {
117 // TODO: parent?
118 return new QCategoriesAxis(this);
119 }
120
121 QAbstractAxis* QGroupedBarSeriesPrivate::createAxisY()
122 {
123 // TODO: parent?
124 return new QValuesAxis(this);
125 }
126 115
127 116 #include "moc_qgroupedbarseries.cpp"
128 117
129 118 QTCOMMERCIALCHART_END_NAMESPACE
130 119
@@ -1,54 +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 QGROUPEDBARSERIES_P_H
31 31 #define QGROUPEDBARSERIES_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 QGroupedBarSeriesPrivate: public QBarSeriesPrivate
40 40 {
41 41 public:
42 42 QGroupedBarSeriesPrivate(QGroupedBarSeries* q);
43 43 Chart* createGraphics(ChartPresenter* presenter);
44 44 void scaleDomain(Domain& domain);
45 QAbstractAxis* createAxisX();
46 QAbstractAxis* createAxisY();
47 45
48 46 private:
49 47 Q_DECLARE_PUBLIC(QGroupedBarSeries)
50 48 };
51 49
52 50 QTCOMMERCIALCHART_END_NAMESPACE
53 51
54 52 #endif // QGROUPEDBARSERIES_P_H
@@ -1,129 +1,117
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 "chartanimator_p.h"
27 27 #include "qcategoriesaxis.h"
28 28 #include "qvaluesaxis.h"
29 29
30 30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 31
32 32 /*!
33 33 \class QPercentBarSeries
34 34 \brief Series for creating percent bar chart
35 35 \mainclass
36 36
37 37 QPercentBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars
38 38 as stacks, where each bar is shown as percentage of all bars in that category.
39 39 QPercentBarSeries groups the data from sets to categories, which are defined by a QStringList.
40 40
41 41 See the \l {PercentbarChart Example} {percent bar chart example} to learn how to create a percent bar chart.
42 42 \image examples_percentbarchart.png
43 43
44 44 \sa QBarSet, QStackedBarSeries, QBarSeries
45 45 */
46 46 /*!
47 47 \qmlclass PercentBarSeries QPercentBarSeries
48 48 \inherits BarSeries
49 49
50 50 The following QML shows how to create a simple percent bar chart:
51 51 \snippet ../demos/qmlchart/qml/qmlchart/View9.qml 1
52 52 \beginfloatleft
53 53 \image demos_qmlchart9.png
54 54 \endfloat
55 55 \clearfloat
56 56 */
57 57
58 58 /*!
59 59 Constructs empty QPercentBarSeries.
60 60 QPercentBarSeries is QObject which is a child of a \a parent.
61 61 */
62 62 QPercentBarSeries::QPercentBarSeries(QObject *parent)
63 63 : QBarSeries(*new QPercentBarSeriesPrivate(this), parent)
64 64 {
65 65 }
66 66
67 67 /*!
68 68 Returns QChartSeries::SeriesTypePercentBar.
69 69 */
70 70 QAbstractSeries::SeriesType QPercentBarSeries::type() const
71 71 {
72 72 return QAbstractSeries::SeriesTypePercentBar;
73 73 }
74 74
75 75 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
76 76
77 77 QPercentBarSeriesPrivate::QPercentBarSeriesPrivate(QPercentBarSeries *q) : QBarSeriesPrivate(q)
78 78 {
79 79
80 80 }
81 81
82 82 void QPercentBarSeriesPrivate::scaleDomain(Domain& domain)
83 83 {
84 84 qreal minX(domain.minX());
85 85 qreal minY(domain.minY());
86 86 qreal maxX(domain.maxX());
87 87 qreal maxY(domain.maxY());
88 88 int tickXCount(domain.tickXCount());
89 89 int tickYCount(domain.tickYCount());
90 90
91 91 qreal x = categoryCount();
92 92 minX = qMin(minX, -0.5);
93 93 maxX = qMax(maxX, x - 0.5);
94 94 minY = 0;
95 95 maxY = 100;
96 96 tickXCount = x+1;
97 97
98 98 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
99 99 }
100 100
101 101
102 102 Chart* QPercentBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
103 103 {
104 104 Q_Q(QPercentBarSeries);
105 105
106 106 PercentBarChartItem* bar = new PercentBarChartItem(q,presenter);
107 107 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
108 108 presenter->animator()->addAnimation(bar);
109 109 }
110 110 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
111 111 return bar;
112 112 }
113 113
114 QAbstractAxis* QPercentBarSeriesPrivate::createAxisX()
115 {
116 // TODO: parent?
117 return new QCategoriesAxis(this);
118 }
119
120 QAbstractAxis* QPercentBarSeriesPrivate::createAxisY()
121 {
122 // TODO: parent?
123 return new QValuesAxis(this);
124 }
125
126 114 #include "moc_qpercentbarseries.cpp"
127 115
128 116 QTCOMMERCIALCHART_END_NAMESPACE
129 117
@@ -1,54 +1,51
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 42 QPercentBarSeriesPrivate(QPercentBarSeries* q);
43 43 void scaleDomain(Domain& domain);
44 44 Chart* createGraphics(ChartPresenter* presenter);
45 QAbstractAxis* createAxisX();
46 QAbstractAxis* createAxisY();
47
48 45 private:
49 46 Q_DECLARE_PUBLIC(QPercentBarSeries)
50 47 };
51 48
52 49 QTCOMMERCIALCHART_END_NAMESPACE
53 50
54 51 #endif
@@ -1,132 +1,120
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 #include "qcategoriesaxis.h"
28 28 #include "qvaluesaxis.h"
29 29
30 30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 31
32 32 /*!
33 33 \class QStackedBarSeries
34 34 \brief Series for creating stacked bar chart
35 35 \mainclass
36 36
37 37 QStackedBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars
38 38 as stacks, where bars in same category are stacked on top of each other.
39 39 QStackedBarSeries groups the data from sets to categories, which are defined by QStringList.
40 40
41 41 See the \l {StackedbarChart Example} {stacked bar chart example} to learn how to create a stacked bar chart.
42 42 \image examples_stackedbarchart.png
43 43
44 44 \sa QBarSet, QPercentBarSeries, QBarSeries
45 45 */
46 46
47 47 /*!
48 48 \qmlclass StackedBarSeries QStackedBarSeries
49 49 \inherits BarSeries
50 50
51 51 The following QML shows how to create a simple stacked bar chart:
52 52 \snippet ../demos/qmlchart/qml/qmlchart/View8.qml 1
53 53 \beginfloatleft
54 54 \image demos_qmlchart8.png
55 55 \endfloat
56 56 \clearfloat
57 57 */
58 58
59 59 /*!
60 60 Constructs empty QStackedBarSeries.
61 61 QStackedBarSeries is QObject which is a child of a \a parent.
62 62 */
63 63 QStackedBarSeries::QStackedBarSeries(QObject *parent)
64 64 : QBarSeries(*new QStackedBarSeriesPrivate(this), parent)
65 65 {
66 66 }
67 67
68 68 /*!
69 69 Returns QChartSeries::SeriesTypeStackedBar.
70 70 */
71 71 QAbstractSeries::SeriesType QStackedBarSeries::type() const
72 72 {
73 73 return QAbstractSeries::SeriesTypeStackedBar;
74 74 }
75 75
76 76 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
77 77
78 78 QStackedBarSeriesPrivate::QStackedBarSeriesPrivate(QStackedBarSeries *q) : QBarSeriesPrivate(q)
79 79 {
80 80
81 81 }
82 82
83 83 void QStackedBarSeriesPrivate::scaleDomain(Domain& domain)
84 84 {
85 85 qreal minX(domain.minX());
86 86 qreal minY(domain.minY());
87 87 qreal maxX(domain.maxX());
88 88 qreal maxY(domain.maxY());
89 89 int tickXCount(domain.tickXCount());
90 90 int tickYCount(domain.tickYCount());
91 91
92 92 qreal x = categoryCount();
93 93 qreal y = maxCategorySum();
94 94 minX = qMin(minX, -0.5);
95 95 minY = qMin(minY, y);
96 96 maxX = qMax(maxX, x - 0.5);
97 97 maxY = qMax(maxY, y);
98 98 tickXCount = x+1;
99 99
100 100 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
101 101 }
102 102
103 103
104 104 Chart* QStackedBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
105 105 {
106 106 Q_Q(QStackedBarSeries);
107 107
108 108 StackedBarChartItem* bar = new StackedBarChartItem(q,presenter);
109 109 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
110 110 presenter->animator()->addAnimation(bar);
111 111 }
112 112 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
113 113 return bar;
114 114 }
115 115
116 QAbstractAxis* QStackedBarSeriesPrivate::createAxisX()
117 {
118 // TODO: parent?
119 return new QCategoriesAxis(this);
120 }
121
122 QAbstractAxis* QStackedBarSeriesPrivate::createAxisY()
123 {
124 // TODO: parent?
125 return new QValuesAxis(this);
126 }
127
128 116
129 117 #include "moc_qstackedbarseries.cpp"
130 118
131 119 QTCOMMERCIALCHART_END_NAMESPACE
132 120
@@ -1,54 +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 42 QStackedBarSeriesPrivate(QStackedBarSeries* q);
43 43 Chart* createGraphics(ChartPresenter* presenter);
44 44 void scaleDomain(Domain& domain);
45 QAbstractAxis* createAxisX();
46 QAbstractAxis* createAxisY();
47 45
48 46 private:
49 47 Q_DECLARE_PUBLIC(QStackedBarSeries)
50 48 };
51 49
52 50 QTCOMMERCIALCHART_END_NAMESPACE
53 51
54 52 #endif
General Comments 0
You need to be logged in to leave comments. Login now