@@ -1,30 +1,30 | |||
|
1 | 1 | INCLUDEPATH += $$PWD |
|
2 | 2 | DEPENDPATH += $$PWD |
|
3 | 3 | |
|
4 | 4 | SOURCES += \ |
|
5 | 5 | $$PWD/chartaxis.cpp \ |
|
6 | 6 | $$PWD/chartvaluesaxisx.cpp \ |
|
7 | 7 | $$PWD/chartvaluesaxisy.cpp \ |
|
8 | 8 | $$PWD/chartcategoriesaxisx.cpp \ |
|
9 | 9 | $$PWD/chartcategoriesaxisy.cpp \ |
|
10 | 10 | $$PWD/qbarcategoriesaxis.cpp \ |
|
11 |
$$PWD/q |
|
|
11 | $$PWD/qintervalaxis.cpp \ | |
|
12 | 12 | $$PWD/qvaluesaxis.cpp \ |
|
13 | 13 | $$PWD/qabstractaxis.cpp |
|
14 | 14 | |
|
15 | 15 | PRIVATE_HEADERS += \ |
|
16 | 16 | $$PWD/chartaxis_p.h \ |
|
17 | 17 | $$PWD/chartvaluesaxisx_p.h \ |
|
18 | 18 | $$PWD/chartvaluesaxisy_p.h \ |
|
19 | 19 | $$PWD/chartcategoriesaxisx_p.h \ |
|
20 | 20 | $$PWD/chartcategoriesaxisy_p.h \ |
|
21 | 21 | $$PWD/qbarcategoriesaxis_p.h \ |
|
22 |
$$PWD/q |
|
|
22 | $$PWD/qintervalaxis_p.h \ | |
|
23 | 23 | $$PWD/qvaluesaxis_p.h \ |
|
24 | 24 | $$PWD/qabstractaxis_p.h |
|
25 | 25 | |
|
26 | 26 | PUBLIC_HEADERS += \ |
|
27 | 27 | $$PWD/qbarcategoriesaxis.h \ |
|
28 |
$$PWD/q |
|
|
28 | $$PWD/qintervalaxis.h \ | |
|
29 | 29 | $$PWD/qvaluesaxis.h \ |
|
30 | 30 | $$PWD/qabstractaxis.h |
@@ -1,149 +1,149 | |||
|
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 |
#include "q |
|
|
22 |
#include "q |
|
|
21 | #include "qintervalaxis.h" | |
|
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 | QIntervalAxis::QIntervalAxis(QObject *parent): |
|
31 | 31 | QValuesAxis(*new QIntervalAxisPrivate(this),parent) |
|
32 | 32 | { |
|
33 | 33 | } |
|
34 | 34 | |
|
35 | 35 | QIntervalAxis::~QIntervalAxis() |
|
36 | 36 | { |
|
37 | 37 | } |
|
38 | 38 | |
|
39 | 39 | QIntervalAxis::QIntervalAxis(QIntervalAxisPrivate &d,QObject *parent):QValuesAxis(d,parent) |
|
40 | 40 | { |
|
41 | 41 | |
|
42 | 42 | } |
|
43 | 43 | |
|
44 | 44 | /*! |
|
45 | 45 | Appends \a categories to axis |
|
46 | 46 | */ |
|
47 | 47 | void QIntervalAxis::append(const QString& category, qreal x) |
|
48 | 48 | { |
|
49 | 49 | Q_D(QIntervalAxis); |
|
50 | 50 | if (!d->m_categories.contains(category)) |
|
51 | 51 | { |
|
52 | 52 | if(d->m_categories.isEmpty()){ |
|
53 | 53 | Range range(d->m_categoryMinimum,x); |
|
54 | 54 | d->m_categoriesMap.insert(category,range); |
|
55 | 55 | d->m_categories.append(category); |
|
56 | 56 | }else{ |
|
57 | 57 | Range range = d->m_categoriesMap.value(d->m_categories.last()); |
|
58 | 58 | d->m_categoriesMap.insert(category,Range(range.first,x)); |
|
59 | 59 | d->m_categories.append(category); |
|
60 | 60 | } |
|
61 | 61 | setRange(d->m_min,x); |
|
62 | 62 | } |
|
63 | 63 | } |
|
64 | 64 | |
|
65 | 65 | void QIntervalAxis::setFisrtCategoryMinimum(qreal x) |
|
66 | 66 | { |
|
67 | 67 | Q_D(QIntervalAxis); |
|
68 | 68 | if(d->m_categories.isEmpty()){ |
|
69 | 69 | d->m_categoryMinimum=x; |
|
70 | 70 | }else{ |
|
71 | 71 | Range range = d->m_categoriesMap.value(d->m_categories.first()); |
|
72 | 72 | d->m_categoriesMap.insert(d->m_categories.first(),Range(x,range.second)); |
|
73 | 73 | setRange(x,d->m_min); |
|
74 | 74 | } |
|
75 | 75 | } |
|
76 | 76 | |
|
77 | 77 | /*! |
|
78 | 78 | Removes \a category from axis |
|
79 | 79 | */ |
|
80 | 80 | void QIntervalAxis::remove(const QString &category) |
|
81 | 81 | { |
|
82 | 82 | Q_UNUSED(category); |
|
83 | 83 | //TODO |
|
84 | 84 | } |
|
85 | 85 | |
|
86 | 86 | QStringList QIntervalAxis::categories() |
|
87 | 87 | { |
|
88 | 88 | Q_D(QIntervalAxis); |
|
89 | 89 | return d->m_categories; |
|
90 | 90 | } |
|
91 | 91 | |
|
92 | 92 | /*! |
|
93 | 93 | Returns number of categories. |
|
94 | 94 | */ |
|
95 | 95 | int QIntervalAxis::count() const |
|
96 | 96 | { |
|
97 | 97 | Q_D(const QIntervalAxis); |
|
98 | 98 | return d->m_categories.count(); |
|
99 | 99 | } |
|
100 | 100 | |
|
101 | 101 | /*! |
|
102 | 102 | Returns the type of axis. |
|
103 | 103 | */ |
|
104 | 104 | QAbstractAxis::AxisType QIntervalAxis::type() const |
|
105 | 105 | { |
|
106 | 106 | return AxisTypeCategories; |
|
107 | 107 | } |
|
108 | 108 | |
|
109 | 109 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
110 | 110 | |
|
111 | 111 | QIntervalAxisPrivate::QIntervalAxisPrivate(QIntervalAxis* q): |
|
112 | 112 | QValuesAxisPrivate(q), |
|
113 | 113 | m_categoryMinimum(0) |
|
114 | 114 | { |
|
115 | 115 | |
|
116 | 116 | } |
|
117 | 117 | |
|
118 | 118 | QIntervalAxisPrivate::~QIntervalAxisPrivate() |
|
119 | 119 | { |
|
120 | 120 | |
|
121 | 121 | } |
|
122 | 122 | |
|
123 | 123 | int QIntervalAxisPrivate::ticksCount() const |
|
124 | 124 | { |
|
125 | 125 | return m_categories.count()+1; |
|
126 | 126 | } |
|
127 | 127 | |
|
128 | 128 | void QIntervalAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) |
|
129 | 129 | { |
|
130 | 130 | m_min = min; |
|
131 | 131 | m_max = max; |
|
132 | 132 | m_ticksCount = count; |
|
133 | 133 | } |
|
134 | 134 | |
|
135 | 135 | ChartAxis* QIntervalAxisPrivate::createGraphics(ChartPresenter* presenter) |
|
136 | 136 | { |
|
137 | 137 | Q_UNUSED(presenter); |
|
138 | 138 | // Q_Q( QCategoriesAxis); |
|
139 | 139 | if(m_orientation == Qt::Vertical){ |
|
140 | 140 | return 0; |
|
141 | 141 | }else{ |
|
142 | 142 | return 0; |
|
143 | 143 | } |
|
144 | 144 | } |
|
145 | 145 | |
|
146 |
#include "moc_q |
|
|
147 |
#include "moc_q |
|
|
146 | #include "moc_qintervalaxis.cpp" | |
|
147 | #include "moc_qintervalaxis_p.cpp" | |
|
148 | 148 | |
|
149 | 149 | QTCOMMERCIALCHART_END_NAMESPACE |
|
1 | NO CONTENT: file renamed from src/axis/qcategoriesaxis.h to src/axis/qintervalaxis.h |
@@ -1,71 +1,71 | |||
|
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 |
#ifndef Q |
|
|
31 |
#define Q |
|
|
30 | #ifndef QINTERVALAXIS_P_H | |
|
31 | #define QINTERVALAXIS_P_H | |
|
32 | 32 | |
|
33 |
#include "q |
|
|
33 | #include "qintervalaxis.h" | |
|
34 | 34 | #include "qvaluesaxis_p.h" |
|
35 | 35 | |
|
36 | 36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | 37 | |
|
38 | 38 | |
|
39 | 39 | typedef QPair<qreal, qreal> Range; |
|
40 | 40 | |
|
41 | 41 | class QIntervalAxisPrivate : public QValuesAxisPrivate |
|
42 | 42 | { |
|
43 | 43 | Q_OBJECT |
|
44 | 44 | |
|
45 | 45 | public: |
|
46 | 46 | QIntervalAxisPrivate(QIntervalAxis *q); |
|
47 | 47 | ~QIntervalAxisPrivate(); |
|
48 | 48 | |
|
49 | 49 | |
|
50 | 50 | public: |
|
51 | 51 | ChartAxis* createGraphics(ChartPresenter* presenter); |
|
52 | 52 | int ticksCount() const; |
|
53 | 53 | |
|
54 | 54 | Q_SIGNALS: |
|
55 | 55 | void changed(qreal min, qreal max, int tickCount,bool niceNumbers); |
|
56 | 56 | |
|
57 | 57 | public Q_SLOTS: |
|
58 | 58 | void handleAxisRangeChanged(qreal min, qreal max,int count); |
|
59 | 59 | |
|
60 | 60 | private: |
|
61 | 61 | QMap<QString , Range> m_categoriesMap; |
|
62 | 62 | QStringList m_categories; |
|
63 | 63 | qreal m_categoryMinimum; |
|
64 | 64 | |
|
65 | 65 | private: |
|
66 | 66 | Q_DECLARE_PUBLIC(QIntervalAxis) |
|
67 | 67 | }; |
|
68 | 68 | |
|
69 | 69 | QTCOMMERCIALCHART_END_NAMESPACE |
|
70 | 70 | |
|
71 | 71 | #endif // QCATEGORIESAXIS_P_H |
@@ -1,119 +1,118 | |||
|
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 "groupedbarchartitem_p.h" |
|
24 | 24 | #include "chartdataset_p.h" |
|
25 | 25 | #include "charttheme_p.h" |
|
26 | 26 | #include "chartanimator_p.h" |
|
27 | #include "qcategoriesaxis.h" | |
|
28 | 27 | #include "qvaluesaxis.h" |
|
29 | 28 | |
|
30 | 29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | 30 | |
|
32 | 31 | /*! |
|
33 | 32 | \class QBarSeries |
|
34 | 33 | \brief Series for creating bar chart |
|
35 | 34 | \mainclass |
|
36 | 35 | |
|
37 | 36 | QBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars |
|
38 | 37 | as groups, where bars in same category are grouped next to each other. QBarSeries groups the data |
|
39 | 38 | from sets to categories, which are defined by a QStringList. |
|
40 | 39 | |
|
41 | 40 | See the \l {GroupedbarChart Example} {grouped bar chart example} to learn how to create a grouped bar chart. |
|
42 | 41 | \image examples_groupedbarchart.png |
|
43 | 42 | |
|
44 | 43 | \sa QBarSet, QPercentBarSeries, QAbstractBarSeries, QStackedBarSeries |
|
45 | 44 | */ |
|
46 | 45 | /*! |
|
47 | 46 | \qmlclass BarSeries QBarSeries |
|
48 | 47 | \inherits AbstractBarSeries |
|
49 | 48 | |
|
50 | 49 | The following QML shows how to create a simple grouped bar chart: |
|
51 | 50 | \snippet ../demos/qmlchart/qml/qmlchart/View8.qml 1 |
|
52 | 51 | \beginfloatleft |
|
53 | 52 | \image demos_qmlchart7.png |
|
54 | 53 | \endfloat |
|
55 | 54 | \clearfloat |
|
56 | 55 | */ |
|
57 | 56 | |
|
58 | 57 | /*! |
|
59 | 58 | Constructs empty QBarSeries. |
|
60 | 59 | QBarSeries is QObject which is a child of a \a parent. |
|
61 | 60 | */ |
|
62 | 61 | QBarSeries::QBarSeries(QObject *parent) |
|
63 | 62 | : QAbstractBarSeries(*new QBarSeriesPrivate(this), parent) |
|
64 | 63 | { |
|
65 | 64 | } |
|
66 | 65 | |
|
67 | 66 | /*! |
|
68 | 67 | Returns QChartSeries::SeriesTypeGroupedBar. |
|
69 | 68 | */ |
|
70 | 69 | QAbstractSeries::SeriesType QBarSeries::type() const |
|
71 | 70 | { |
|
72 | 71 | return QAbstractSeries::SeriesTypeBar; |
|
73 | 72 | } |
|
74 | 73 | |
|
75 | 74 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
76 | 75 | |
|
77 | 76 | QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) : QAbstractBarSeriesPrivate(q) |
|
78 | 77 | { |
|
79 | 78 | |
|
80 | 79 | } |
|
81 | 80 | |
|
82 | 81 | void QBarSeriesPrivate::scaleDomain(Domain& domain) |
|
83 | 82 | { |
|
84 | 83 | qreal minX(domain.minX()); |
|
85 | 84 | qreal minY(domain.minY()); |
|
86 | 85 | qreal maxX(domain.maxX()); |
|
87 | 86 | qreal maxY(domain.maxY()); |
|
88 | 87 | int tickXCount(domain.tickXCount()); |
|
89 | 88 | int tickYCount(domain.tickYCount()); |
|
90 | 89 | |
|
91 | 90 | qreal x = categoryCount(); |
|
92 | 91 | qreal y = max(); |
|
93 | 92 | minX = qMin(minX, -0.5); |
|
94 | 93 | minY = qMin(minY, y); |
|
95 | 94 | maxX = qMax(maxX, x - 0.5); |
|
96 | 95 | maxY = qMax(maxY, y); |
|
97 | 96 | tickXCount = x+1; |
|
98 | 97 | |
|
99 | 98 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); |
|
100 | 99 | } |
|
101 | 100 | |
|
102 | 101 | |
|
103 | 102 | Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
104 | 103 | { |
|
105 | 104 | Q_Q(QBarSeries); |
|
106 | 105 | |
|
107 | 106 | GroupedBarChartItem* bar = new GroupedBarChartItem(q,presenter); |
|
108 | 107 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
109 | 108 | presenter->animator()->addAnimation(bar); |
|
110 | 109 | } |
|
111 | 110 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
112 | 111 | return bar; |
|
113 | 112 | } |
|
114 | 113 | |
|
115 | 114 | |
|
116 | 115 | #include "moc_qbarseries.cpp" |
|
117 | 116 | |
|
118 | 117 | QTCOMMERCIALCHART_END_NAMESPACE |
|
119 | 118 |
@@ -1,117 +1,116 | |||
|
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 | #include "qcategoriesaxis.h" | |
|
28 | 27 | #include "qvaluesaxis.h" |
|
29 | 28 | |
|
30 | 29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | 30 | |
|
32 | 31 | /*! |
|
33 | 32 | \class QPercentBarSeries |
|
34 | 33 | \brief Series for creating percent bar chart |
|
35 | 34 | \mainclass |
|
36 | 35 | |
|
37 | 36 | QPercentBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars |
|
38 | 37 | as stacks, where each bar is shown as percentage of all bars in that category. |
|
39 | 38 | QPercentBarSeries groups the data from sets to categories, which are defined by a QStringList. |
|
40 | 39 | |
|
41 | 40 | See the \l {PercentbarChart Example} {percent bar chart example} to learn how to create a percent bar chart. |
|
42 | 41 | \image examples_percentbarchart.png |
|
43 | 42 | |
|
44 | 43 | \sa QBarSet, QStackedBarSeries, QAbstractBarSeries |
|
45 | 44 | */ |
|
46 | 45 | /*! |
|
47 | 46 | \qmlclass PercentBarSeries QPercentBarSeries |
|
48 | 47 | \inherits QAbstractBarSeries |
|
49 | 48 | |
|
50 | 49 | The following QML shows how to create a simple percent bar chart: |
|
51 | 50 | \snippet ../demos/qmlchart/qml/qmlchart/View9.qml 1 |
|
52 | 51 | \beginfloatleft |
|
53 | 52 | \image demos_qmlchart9.png |
|
54 | 53 | \endfloat |
|
55 | 54 | \clearfloat |
|
56 | 55 | */ |
|
57 | 56 | |
|
58 | 57 | /*! |
|
59 | 58 | Constructs empty QPercentBarSeries. |
|
60 | 59 | QPercentBarSeries is QObject which is a child of a \a parent. |
|
61 | 60 | */ |
|
62 | 61 | QPercentBarSeries::QPercentBarSeries(QObject *parent) |
|
63 | 62 | : QAbstractBarSeries(*new QPercentBarSeriesPrivate(this), parent) |
|
64 | 63 | { |
|
65 | 64 | } |
|
66 | 65 | |
|
67 | 66 | /*! |
|
68 | 67 | Returns QChartSeries::SeriesTypePercentBar. |
|
69 | 68 | */ |
|
70 | 69 | QAbstractSeries::SeriesType QPercentBarSeries::type() const |
|
71 | 70 | { |
|
72 | 71 | return QAbstractSeries::SeriesTypePercentBar; |
|
73 | 72 | } |
|
74 | 73 | |
|
75 | 74 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
76 | 75 | |
|
77 | 76 | QPercentBarSeriesPrivate::QPercentBarSeriesPrivate(QPercentBarSeries *q) : QAbstractBarSeriesPrivate(q) |
|
78 | 77 | { |
|
79 | 78 | |
|
80 | 79 | } |
|
81 | 80 | |
|
82 | 81 | void QPercentBarSeriesPrivate::scaleDomain(Domain& domain) |
|
83 | 82 | { |
|
84 | 83 | qreal minX(domain.minX()); |
|
85 | 84 | qreal minY(domain.minY()); |
|
86 | 85 | qreal maxX(domain.maxX()); |
|
87 | 86 | qreal maxY(domain.maxY()); |
|
88 | 87 | int tickXCount(domain.tickXCount()); |
|
89 | 88 | int tickYCount(domain.tickYCount()); |
|
90 | 89 | |
|
91 | 90 | qreal x = categoryCount(); |
|
92 | 91 | minX = qMin(minX, -0.5); |
|
93 | 92 | maxX = qMax(maxX, x - 0.5); |
|
94 | 93 | minY = 0; |
|
95 | 94 | maxY = 100; |
|
96 | 95 | tickXCount = x+1; |
|
97 | 96 | |
|
98 | 97 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); |
|
99 | 98 | } |
|
100 | 99 | |
|
101 | 100 | |
|
102 | 101 | Chart* QPercentBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
103 | 102 | { |
|
104 | 103 | Q_Q(QPercentBarSeries); |
|
105 | 104 | |
|
106 | 105 | PercentBarChartItem* bar = new PercentBarChartItem(q,presenter); |
|
107 | 106 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
108 | 107 | presenter->animator()->addAnimation(bar); |
|
109 | 108 | } |
|
110 | 109 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
111 | 110 | return bar; |
|
112 | 111 | } |
|
113 | 112 | |
|
114 | 113 | #include "moc_qpercentbarseries.cpp" |
|
115 | 114 | |
|
116 | 115 | QTCOMMERCIALCHART_END_NAMESPACE |
|
117 | 116 |
@@ -1,120 +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 "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 | #include "qcategoriesaxis.h" | |
|
28 | 27 | #include "qvaluesaxis.h" |
|
29 | 28 | |
|
30 | 29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | 30 | |
|
32 | 31 | /*! |
|
33 | 32 | \class QStackedBarSeries |
|
34 | 33 | \brief Series for creating stacked bar chart |
|
35 | 34 | \mainclass |
|
36 | 35 | |
|
37 | 36 | QStackedBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars |
|
38 | 37 | as stacks, where bars in same category are stacked on top of each other. |
|
39 | 38 | QStackedBarSeries groups the data from sets to categories, which are defined by QStringList. |
|
40 | 39 | |
|
41 | 40 | See the \l {StackedbarChart Example} {stacked bar chart example} to learn how to create a stacked bar chart. |
|
42 | 41 | \image examples_stackedbarchart.png |
|
43 | 42 | |
|
44 | 43 | \sa QBarSet, QPercentBarSeries, QAbstractBarSeries |
|
45 | 44 | */ |
|
46 | 45 | |
|
47 | 46 | /*! |
|
48 | 47 | \qmlclass StackedBarSeries QStackedBarSeries |
|
49 | 48 | \inherits AbstractBarSeries |
|
50 | 49 | |
|
51 | 50 | The following QML shows how to create a simple stacked bar chart: |
|
52 | 51 | \snippet ../demos/qmlchart/qml/qmlchart/View8.qml 1 |
|
53 | 52 | \beginfloatleft |
|
54 | 53 | \image demos_qmlchart8.png |
|
55 | 54 | \endfloat |
|
56 | 55 | \clearfloat |
|
57 | 56 | */ |
|
58 | 57 | |
|
59 | 58 | /*! |
|
60 | 59 | Constructs empty QStackedBarSeries. |
|
61 | 60 | QStackedBarSeries is QObject which is a child of a \a parent. |
|
62 | 61 | */ |
|
63 | 62 | QStackedBarSeries::QStackedBarSeries(QObject *parent) |
|
64 | 63 | : QAbstractBarSeries(*new QStackedBarSeriesPrivate(this), parent) |
|
65 | 64 | { |
|
66 | 65 | } |
|
67 | 66 | |
|
68 | 67 | /*! |
|
69 | 68 | Returns QChartSeries::SeriesTypeStackedBar. |
|
70 | 69 | */ |
|
71 | 70 | QAbstractSeries::SeriesType QStackedBarSeries::type() const |
|
72 | 71 | { |
|
73 | 72 | return QAbstractSeries::SeriesTypeStackedBar; |
|
74 | 73 | } |
|
75 | 74 | |
|
76 | 75 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
77 | 76 | |
|
78 | 77 | QStackedBarSeriesPrivate::QStackedBarSeriesPrivate(QStackedBarSeries *q) : QAbstractBarSeriesPrivate(q) |
|
79 | 78 | { |
|
80 | 79 | |
|
81 | 80 | } |
|
82 | 81 | |
|
83 | 82 | void QStackedBarSeriesPrivate::scaleDomain(Domain& domain) |
|
84 | 83 | { |
|
85 | 84 | qreal minX(domain.minX()); |
|
86 | 85 | qreal minY(domain.minY()); |
|
87 | 86 | qreal maxX(domain.maxX()); |
|
88 | 87 | qreal maxY(domain.maxY()); |
|
89 | 88 | int tickXCount(domain.tickXCount()); |
|
90 | 89 | int tickYCount(domain.tickYCount()); |
|
91 | 90 | |
|
92 | 91 | qreal x = categoryCount(); |
|
93 | 92 | qreal y = maxCategorySum(); |
|
94 | 93 | minX = qMin(minX, -0.5); |
|
95 | 94 | minY = qMin(minY, y); |
|
96 | 95 | maxX = qMax(maxX, x - 0.5); |
|
97 | 96 | maxY = qMax(maxY, y); |
|
98 | 97 | tickXCount = x+1; |
|
99 | 98 | |
|
100 | 99 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); |
|
101 | 100 | } |
|
102 | 101 | |
|
103 | 102 | |
|
104 | 103 | Chart* QStackedBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
105 | 104 | { |
|
106 | 105 | Q_Q(QStackedBarSeries); |
|
107 | 106 | |
|
108 | 107 | StackedBarChartItem* bar = new StackedBarChartItem(q,presenter); |
|
109 | 108 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
110 | 109 | presenter->animator()->addAnimation(bar); |
|
111 | 110 | } |
|
112 | 111 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
113 | 112 | return bar; |
|
114 | 113 | } |
|
115 | 114 | |
|
116 | 115 | |
|
117 | 116 | #include "moc_qstackedbarseries.cpp" |
|
118 | 117 | |
|
119 | 118 | QTCOMMERCIALCHART_END_NAMESPACE |
|
120 | 119 |
General Comments 0
You need to be logged in to leave comments.
Login now