@@ -0,0 +1,299 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | #include "qbarcategoriesaxis.h" | |||
|
22 | #include "qbarcategoriesaxis_p.h" | |||
|
23 | #include "chartcategoriesaxisx_p.h" | |||
|
24 | #include "chartcategoriesaxisy_p.h" | |||
|
25 | #include <qmath.h> | |||
|
26 | #include <QDebug> | |||
|
27 | ||||
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
29 | ||||
|
30 | QBarCategoriesAxis::QBarCategoriesAxis(QObject *parent): | |||
|
31 | QAbstractAxis(*new QBarCategoriesAxisPrivate(this),parent) | |||
|
32 | { | |||
|
33 | } | |||
|
34 | ||||
|
35 | QBarCategoriesAxis::~QBarCategoriesAxis() | |||
|
36 | { | |||
|
37 | } | |||
|
38 | ||||
|
39 | QBarCategoriesAxis::QBarCategoriesAxis(QBarCategoriesAxisPrivate &d,QObject *parent):QAbstractAxis(d,parent) | |||
|
40 | { | |||
|
41 | ||||
|
42 | } | |||
|
43 | ||||
|
44 | /*! | |||
|
45 | Appends \a categories to axis | |||
|
46 | */ | |||
|
47 | void QBarCategoriesAxis::append(const QStringList &categories) | |||
|
48 | { | |||
|
49 | Q_D(QBarCategoriesAxis); | |||
|
50 | if (d->m_categories.isEmpty()) { | |||
|
51 | d->m_categories.append(categories); | |||
|
52 | setRange(categories.first(),categories.last()); | |||
|
53 | }else{ | |||
|
54 | d->m_categories.append(categories); | |||
|
55 | } | |||
|
56 | ||||
|
57 | emit categoriesChanged(); | |||
|
58 | } | |||
|
59 | ||||
|
60 | /*! | |||
|
61 | Appends \a category to axis | |||
|
62 | */ | |||
|
63 | void QBarCategoriesAxis::append(const QString &category) | |||
|
64 | { | |||
|
65 | Q_D(QBarCategoriesAxis); | |||
|
66 | if (d->m_categories.isEmpty()) { | |||
|
67 | d->m_categories.append(category); | |||
|
68 | setRange(category,category); | |||
|
69 | }else{ | |||
|
70 | d->m_categories.append(category); | |||
|
71 | } | |||
|
72 | emit categoriesChanged(); | |||
|
73 | } | |||
|
74 | ||||
|
75 | /*! | |||
|
76 | Removes \a category from axis | |||
|
77 | */ | |||
|
78 | void QBarCategoriesAxis::remove(const QString &category) | |||
|
79 | { | |||
|
80 | Q_D(QBarCategoriesAxis); | |||
|
81 | if (d->m_categories.contains(category)) { | |||
|
82 | d->m_categories.removeAt(d->m_categories.indexOf(category)); | |||
|
83 | setRange(d->m_categories.first(),d->m_categories.last()); | |||
|
84 | emit categoriesChanged(); | |||
|
85 | } | |||
|
86 | } | |||
|
87 | ||||
|
88 | /*! | |||
|
89 | Inserts \a category to axis at \a index | |||
|
90 | */ | |||
|
91 | void QBarCategoriesAxis::insert(int index, const QString &category) | |||
|
92 | { | |||
|
93 | Q_D(QBarCategoriesAxis); | |||
|
94 | if (d->m_categories.isEmpty()) { | |||
|
95 | d->m_categories.insert(index,category); | |||
|
96 | setRange(category,category); | |||
|
97 | }else{ | |||
|
98 | ||||
|
99 | } | |||
|
100 | emit categoriesChanged(); | |||
|
101 | } | |||
|
102 | ||||
|
103 | /*! | |||
|
104 | Removes all categories. | |||
|
105 | */ | |||
|
106 | void QBarCategoriesAxis::clear() | |||
|
107 | { | |||
|
108 | Q_D(QBarCategoriesAxis); | |||
|
109 | d->m_categories.clear(); | |||
|
110 | setRange(QString::null,QString::null); | |||
|
111 | emit categoriesChanged(); | |||
|
112 | } | |||
|
113 | ||||
|
114 | void QBarCategoriesAxis::setCategories(const QStringList &categories) | |||
|
115 | { | |||
|
116 | Q_D(QBarCategoriesAxis); | |||
|
117 | if(d->m_categories!=categories){ | |||
|
118 | d->m_categories = categories; | |||
|
119 | setRange(categories.first(),categories.last()); | |||
|
120 | emit categoriesChanged(); | |||
|
121 | } | |||
|
122 | } | |||
|
123 | ||||
|
124 | QStringList QBarCategoriesAxis::categories() | |||
|
125 | { | |||
|
126 | Q_D(QBarCategoriesAxis); | |||
|
127 | return d->m_categories; | |||
|
128 | } | |||
|
129 | ||||
|
130 | /*! | |||
|
131 | Returns number of categories. | |||
|
132 | */ | |||
|
133 | int QBarCategoriesAxis::count() const | |||
|
134 | { | |||
|
135 | Q_D(const QBarCategoriesAxis); | |||
|
136 | return d->m_categories.count(); | |||
|
137 | } | |||
|
138 | ||||
|
139 | /*! | |||
|
140 | Returns category at \a index. Index must be valid. | |||
|
141 | */ | |||
|
142 | QString QBarCategoriesAxis::at(int index) const | |||
|
143 | { | |||
|
144 | Q_D(const QBarCategoriesAxis); | |||
|
145 | return d->m_categories.at(index); | |||
|
146 | } | |||
|
147 | ||||
|
148 | /*! | |||
|
149 | Sets minimum category to \a min. | |||
|
150 | */ | |||
|
151 | void QBarCategoriesAxis::setMin(const QString& min) | |||
|
152 | { | |||
|
153 | Q_D(QBarCategoriesAxis); | |||
|
154 | setRange(min,d->m_maxCategory); | |||
|
155 | } | |||
|
156 | ||||
|
157 | /*! | |||
|
158 | Returns minimum category. | |||
|
159 | */ | |||
|
160 | QString QBarCategoriesAxis::min() const | |||
|
161 | { | |||
|
162 | Q_D(const QBarCategoriesAxis); | |||
|
163 | return d->m_minCategory; | |||
|
164 | } | |||
|
165 | ||||
|
166 | /*! | |||
|
167 | Sets maximum category to \a max. | |||
|
168 | */ | |||
|
169 | void QBarCategoriesAxis::setMax(const QString& max) | |||
|
170 | { | |||
|
171 | Q_D(QBarCategoriesAxis); | |||
|
172 | setRange(d->m_minCategory,max); | |||
|
173 | } | |||
|
174 | ||||
|
175 | /*! | |||
|
176 | Returns maximum category | |||
|
177 | */ | |||
|
178 | QString QBarCategoriesAxis::max() const | |||
|
179 | { | |||
|
180 | Q_D(const QBarCategoriesAxis); | |||
|
181 | return d->m_maxCategory; | |||
|
182 | } | |||
|
183 | ||||
|
184 | /*! | |||
|
185 | Sets range from \a minCategory to \a maxCategory | |||
|
186 | */ | |||
|
187 | void QBarCategoriesAxis::setRange(const QString& minCategory, const QString& maxCategory) | |||
|
188 | { | |||
|
189 | Q_D(QBarCategoriesAxis); | |||
|
190 | ||||
|
191 | int minIndex = d->m_categories.indexOf(minCategory); | |||
|
192 | if (minIndex == -1) { | |||
|
193 | return; | |||
|
194 | } | |||
|
195 | int maxIndex = d->m_categories.indexOf(maxCategory); | |||
|
196 | if (maxIndex == -1) { | |||
|
197 | return; | |||
|
198 | } | |||
|
199 | ||||
|
200 | if (maxIndex <= minIndex) { | |||
|
201 | // max must be greater than min | |||
|
202 | return; | |||
|
203 | } | |||
|
204 | ||||
|
205 | bool changed = false; | |||
|
206 | if (!qFuzzyIsNull(d->m_min - (minIndex))) { | |||
|
207 | d->m_minCategory = minCategory; | |||
|
208 | d->m_min = minIndex; | |||
|
209 | emit minChanged(minCategory); | |||
|
210 | changed = true; | |||
|
211 | } | |||
|
212 | ||||
|
213 | if (!qFuzzyIsNull(d->m_max - (maxIndex))) { | |||
|
214 | d->m_max = maxIndex; | |||
|
215 | d->m_maxCategory = maxCategory; | |||
|
216 | emit maxChanged(maxCategory); | |||
|
217 | changed = true; | |||
|
218 | } | |||
|
219 | ||||
|
220 | if ((changed)) { | |||
|
221 | d->emitRange(); | |||
|
222 | emit categoriesChanged(); | |||
|
223 | } | |||
|
224 | } | |||
|
225 | ||||
|
226 | /*! | |||
|
227 | Returns the type of axis. | |||
|
228 | */ | |||
|
229 | QAbstractAxis::AxisType QBarCategoriesAxis::type() const | |||
|
230 | { | |||
|
231 | return AxisTypeCategories; | |||
|
232 | } | |||
|
233 | ||||
|
234 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
|
235 | ||||
|
236 | QBarCategoriesAxisPrivate::QBarCategoriesAxisPrivate(QBarCategoriesAxis* q): | |||
|
237 | QAbstractAxisPrivate(q) | |||
|
238 | { | |||
|
239 | ||||
|
240 | } | |||
|
241 | ||||
|
242 | QBarCategoriesAxisPrivate::~QBarCategoriesAxisPrivate() | |||
|
243 | { | |||
|
244 | ||||
|
245 | } | |||
|
246 | ||||
|
247 | void QBarCategoriesAxisPrivate::setMin(const QVariant &min) | |||
|
248 | { | |||
|
249 | setRange(min,m_maxCategory); | |||
|
250 | } | |||
|
251 | ||||
|
252 | void QBarCategoriesAxisPrivate::setMax(const QVariant &max) | |||
|
253 | { | |||
|
254 | setRange(m_minCategory,max); | |||
|
255 | } | |||
|
256 | ||||
|
257 | void QBarCategoriesAxisPrivate::setRange(const QVariant &min, const QVariant &max) | |||
|
258 | { | |||
|
259 | Q_Q(QBarCategoriesAxis); | |||
|
260 | QString value1 = min.toString(); | |||
|
261 | QString value2 = max.toString(); | |||
|
262 | q->setRange(value1,value2); | |||
|
263 | } | |||
|
264 | ||||
|
265 | int QBarCategoriesAxisPrivate::ticksCount() const | |||
|
266 | { | |||
|
267 | return m_categories.count()+1; | |||
|
268 | } | |||
|
269 | ||||
|
270 | void QBarCategoriesAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) | |||
|
271 | { | |||
|
272 | m_min = min; | |||
|
273 | m_max = max; | |||
|
274 | m_ticksCount = count; | |||
|
275 | } | |||
|
276 | ||||
|
277 | ChartAxis* QBarCategoriesAxisPrivate::createGraphics(ChartPresenter* presenter) | |||
|
278 | { | |||
|
279 | Q_Q( QBarCategoriesAxis); | |||
|
280 | if(m_orientation == Qt::Vertical){ | |||
|
281 | return new ChartCategoriesAxisY(q,presenter); | |||
|
282 | }else{ | |||
|
283 | return new ChartCategoriesAxisX(q,presenter); | |||
|
284 | } | |||
|
285 | } | |||
|
286 | ||||
|
287 | void QBarCategoriesAxisPrivate::emitRange() | |||
|
288 | { | |||
|
289 | Q_Q( QBarCategoriesAxis); | |||
|
290 | if(!q->signalsBlocked()) { | |||
|
291 | emit changed(m_min -0.5, m_max +0.5, qCeil(m_max + 0.5) -qCeil(m_min - 0.5) +1, false); | |||
|
292 | } | |||
|
293 | } | |||
|
294 | ||||
|
295 | ||||
|
296 | #include "moc_qbarcategoriesaxis.cpp" | |||
|
297 | #include "moc_qbarcategoriesaxis_p.cpp" | |||
|
298 | ||||
|
299 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -0,0 +1,76 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | #ifndef QBARCATEGORIESAXIS_H | |||
|
22 | #define QBARCATEGORIESAXIS_H | |||
|
23 | ||||
|
24 | #include "qabstractaxis.h" | |||
|
25 | ||||
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
27 | ||||
|
28 | class QBarCategoriesAxisPrivate; | |||
|
29 | ||||
|
30 | class QTCOMMERCIALCHART_EXPORT QBarCategoriesAxis : public QAbstractAxis | |||
|
31 | { | |||
|
32 | Q_OBJECT | |||
|
33 | Q_PROPERTY(QStringList categories READ categories WRITE setCategories NOTIFY categoriesChanged) | |||
|
34 | Q_PROPERTY(QString min READ min WRITE setMin NOTIFY minChanged) | |||
|
35 | Q_PROPERTY(QString max READ max WRITE setMax NOTIFY maxChanged) | |||
|
36 | ||||
|
37 | public: | |||
|
38 | explicit QBarCategoriesAxis(QObject *parent = 0); | |||
|
39 | ~QBarCategoriesAxis(); | |||
|
40 | ||||
|
41 | protected: | |||
|
42 | QBarCategoriesAxis(QBarCategoriesAxisPrivate &d,QObject *parent = 0); | |||
|
43 | ||||
|
44 | public: | |||
|
45 | AxisType type() const; | |||
|
46 | void append(const QStringList &categories); | |||
|
47 | void append(const QString &category); | |||
|
48 | void remove(const QString &category); | |||
|
49 | void insert(int index, const QString &category); | |||
|
50 | void clear(); | |||
|
51 | void setCategories(const QStringList &categories); | |||
|
52 | QStringList categories(); | |||
|
53 | int count() const; | |||
|
54 | QString at(int index) const; | |||
|
55 | ||||
|
56 | //range handling | |||
|
57 | void setMin(const QString& minCategory); | |||
|
58 | QString min() const; | |||
|
59 | void setMax(const QString& maxCategory); | |||
|
60 | QString max() const; | |||
|
61 | void setRange(const QString& minCategory, const QString& maxCategory); | |||
|
62 | ||||
|
63 | Q_SIGNALS: | |||
|
64 | void categoriesChanged(); | |||
|
65 | void minChanged(const QString &min); | |||
|
66 | void maxChanged(const QString &max); | |||
|
67 | void rangeChanged(const QString &min, const QString &max); | |||
|
68 | ||||
|
69 | private: | |||
|
70 | Q_DECLARE_PRIVATE(QBarCategoriesAxis) | |||
|
71 | Q_DISABLE_COPY(QBarCategoriesAxis) | |||
|
72 | }; | |||
|
73 | ||||
|
74 | QTCOMMERCIALCHART_END_NAMESPACE | |||
|
75 | ||||
|
76 | #endif // QCATEGORIESAXIS_H |
@@ -0,0 +1,74 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | // W A R N I N G | |||
|
22 | // ------------- | |||
|
23 | // | |||
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |||
|
25 | // implementation detail. This header file may change from version to | |||
|
26 | // version without notice, or even be removed. | |||
|
27 | // | |||
|
28 | // We mean it. | |||
|
29 | ||||
|
30 | #ifndef QBARCATEGORIESAXIS_P_H | |||
|
31 | #define QBARCATEGORIESAXIS_P_H | |||
|
32 | ||||
|
33 | #include "qbarcategoriesaxis.h" | |||
|
34 | #include "qabstractaxis_p.h" | |||
|
35 | ||||
|
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
37 | ||||
|
38 | class QBarCategoriesAxisPrivate : public QAbstractAxisPrivate | |||
|
39 | { | |||
|
40 | Q_OBJECT | |||
|
41 | ||||
|
42 | public: | |||
|
43 | QBarCategoriesAxisPrivate(QBarCategoriesAxis *q); | |||
|
44 | ~QBarCategoriesAxisPrivate(); | |||
|
45 | ||||
|
46 | public: | |||
|
47 | ChartAxis* createGraphics(ChartPresenter* presenter); | |||
|
48 | void emitRange(); | |||
|
49 | ||||
|
50 | private: | |||
|
51 | //range handling | |||
|
52 | void setMin(const QVariant &min); | |||
|
53 | void setMax(const QVariant &max); | |||
|
54 | void setRange(const QVariant &min, const QVariant &max); | |||
|
55 | int ticksCount() const; | |||
|
56 | ||||
|
57 | Q_SIGNALS: | |||
|
58 | void changed(qreal min, qreal max, int tickCount,bool niceNumbers); | |||
|
59 | ||||
|
60 | public Q_SLOTS: | |||
|
61 | void handleAxisRangeChanged(qreal min, qreal max,int count); | |||
|
62 | ||||
|
63 | private: | |||
|
64 | QStringList m_categories; | |||
|
65 | QString m_minCategory; | |||
|
66 | QString m_maxCategory; | |||
|
67 | ||||
|
68 | private: | |||
|
69 | Q_DECLARE_PUBLIC(QBarCategoriesAxis) | |||
|
70 | }; | |||
|
71 | ||||
|
72 | QTCOMMERCIALCHART_END_NAMESPACE | |||
|
73 | ||||
|
74 | #endif // QBARCATEGORIESAXIS_P_H |
@@ -40,7 +40,7 | |||||
40 | #include <QGroupBox> |
|
40 | #include <QGroupBox> | |
41 | #include <QLabel> |
|
41 | #include <QLabel> | |
42 | #include <QTime> |
|
42 | #include <QTime> | |
43 | #include <QCategoriesAxis> |
|
43 | #include <QBarCategoriesAxis> | |
44 |
|
44 | |||
45 | ThemeWidget::ThemeWidget(QWidget* parent) : |
|
45 | ThemeWidget::ThemeWidget(QWidget* parent) : | |
46 | QWidget(parent), |
|
46 | QWidget(parent), |
@@ -24,7 +24,7 | |||||
24 | #include <QBarSeries> |
|
24 | #include <QBarSeries> | |
25 | #include <QBarSet> |
|
25 | #include <QBarSet> | |
26 | #include <QLegend> |
|
26 | #include <QLegend> | |
27 | #include <QCategoriesAxis> |
|
27 | #include <QBarCategoriesAxis> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | QTCOMMERCIALCHART_USE_NAMESPACE | |
30 |
|
30 |
@@ -30,7 +30,7 | |||||
30 | #include <QBarSet> |
|
30 | #include <QBarSet> | |
31 | #include <QVBarModelMapper> |
|
31 | #include <QVBarModelMapper> | |
32 | #include <QHeaderView> |
|
32 | #include <QHeaderView> | |
33 | #include <QCategoriesAxis> |
|
33 | #include <QBarCategoriesAxis> | |
34 |
|
34 | |||
35 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
35 | QTCOMMERCIALCHART_USE_NAMESPACE | |
36 |
|
36 |
@@ -24,7 +24,7 | |||||
24 | #include <QPercentBarSeries> |
|
24 | #include <QPercentBarSeries> | |
25 | #include <QBarSet> |
|
25 | #include <QBarSet> | |
26 | #include <QLegend> |
|
26 | #include <QLegend> | |
27 | #include <QCategoriesAxis> |
|
27 | #include <QBarCategoriesAxis> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | QTCOMMERCIALCHART_USE_NAMESPACE | |
30 |
|
30 |
@@ -24,7 +24,7 | |||||
24 | #include <QStackedBarSeries> |
|
24 | #include <QStackedBarSeries> | |
25 | #include <QBarSet> |
|
25 | #include <QBarSet> | |
26 | #include <QLegend> |
|
26 | #include <QLegend> | |
27 | #include <QCategoriesAxis> |
|
27 | #include <QBarCategoriesAxis> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | QTCOMMERCIALCHART_USE_NAMESPACE | |
30 |
|
30 |
@@ -19,7 +19,7 | |||||
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "drilldownchart.h" |
|
21 | #include "drilldownchart.h" | |
22 | #include <QCategoriesAxis> |
|
22 | #include <QBarCategoriesAxis> | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
24 | QTCOMMERCIALCHART_USE_NAMESPACE | |
25 |
|
25 |
@@ -26,7 +26,7 | |||||
26 | #include "declarativepieseries.h" |
|
26 | #include "declarativepieseries.h" | |
27 | #include "declarativesplineseries.h" |
|
27 | #include "declarativesplineseries.h" | |
28 | #include "declarativescatterseries.h" |
|
28 | #include "declarativescatterseries.h" | |
29 | #include "qcategoriesaxis.h" |
|
29 | #include "qbarcategoriesaxis.h" | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 |
@@ -23,7 +23,7 | |||||
23 | #include "qchart.h" |
|
23 | #include "qchart.h" | |
24 | #include "qabstractaxis.h" |
|
24 | #include "qabstractaxis.h" | |
25 | #include "qvaluesaxis.h" |
|
25 | #include "qvaluesaxis.h" | |
26 | #include "qcategoriesaxis.h" |
|
26 | #include "qbarcategoriesaxis.h" | |
27 | #include "declarativechart.h" |
|
27 | #include "declarativechart.h" | |
28 | #include "declarativexypoint.h" |
|
28 | #include "declarativexypoint.h" | |
29 | #include "declarativelineseries.h" |
|
29 | #include "declarativelineseries.h" |
@@ -3,29 +3,28 DEPENDPATH += $$PWD | |||||
3 |
|
3 | |||
4 | SOURCES += \ |
|
4 | SOURCES += \ | |
5 | $$PWD/chartaxis.cpp \ |
|
5 | $$PWD/chartaxis.cpp \ | |
6 | # $$PWD/chartaxisx.cpp \ |
|
|||
7 | # $$PWD/chartaxisy.cpp \ |
|
|||
8 | $$PWD/chartvaluesaxisx.cpp \ |
|
6 | $$PWD/chartvaluesaxisx.cpp \ | |
9 | $$PWD/chartvaluesaxisy.cpp \ |
|
7 | $$PWD/chartvaluesaxisy.cpp \ | |
10 | $$PWD/chartcategoriesaxisx.cpp \ |
|
8 | $$PWD/chartcategoriesaxisx.cpp \ | |
11 | $$PWD/chartcategoriesaxisy.cpp \ |
|
9 | $$PWD/chartcategoriesaxisy.cpp \ | |
|
10 | $$PWD/qbarcategoriesaxis.cpp \ | |||
12 | $$PWD/qcategoriesaxis.cpp \ |
|
11 | $$PWD/qcategoriesaxis.cpp \ | |
13 | $$PWD/qvaluesaxis.cpp \ |
|
12 | $$PWD/qvaluesaxis.cpp \ | |
14 | $$PWD/qabstractaxis.cpp |
|
13 | $$PWD/qabstractaxis.cpp | |
15 |
|
14 | |||
16 | PRIVATE_HEADERS += \ |
|
15 | PRIVATE_HEADERS += \ | |
17 | $$PWD/chartaxis_p.h \ |
|
16 | $$PWD/chartaxis_p.h \ | |
18 | # $$PWD/chartaxisx_p.h \ |
|
|||
19 | # $$PWD/chartaxisy_p.h \ |
|
|||
20 | $$PWD/chartvaluesaxisx_p.h \ |
|
17 | $$PWD/chartvaluesaxisx_p.h \ | |
21 | $$PWD/chartvaluesaxisy_p.h \ |
|
18 | $$PWD/chartvaluesaxisy_p.h \ | |
22 | $$PWD/chartcategoriesaxisx_p.h \ |
|
19 | $$PWD/chartcategoriesaxisx_p.h \ | |
23 | $$PWD/chartcategoriesaxisy_p.h \ |
|
20 | $$PWD/chartcategoriesaxisy_p.h \ | |
|
21 | $$PWD/qbarcategoriesaxis_p.h \ | |||
24 | $$PWD/qcategoriesaxis_p.h \ |
|
22 | $$PWD/qcategoriesaxis_p.h \ | |
25 | $$PWD/qvaluesaxis_p.h \ |
|
23 | $$PWD/qvaluesaxis_p.h \ | |
26 | $$PWD/qabstractaxis_p.h |
|
24 | $$PWD/qabstractaxis_p.h | |
27 |
|
25 | |||
28 | PUBLIC_HEADERS += \ |
|
26 | PUBLIC_HEADERS += \ | |
|
27 | $$PWD/qbarcategoriesaxis.h \ | |||
29 | $$PWD/qcategoriesaxis.h \ |
|
28 | $$PWD/qcategoriesaxis.h \ | |
30 | $$PWD/qvaluesaxis.h \ |
|
29 | $$PWD/qvaluesaxis.h \ | |
31 | $$PWD/qabstractaxis.h |
|
30 | $$PWD/qabstractaxis.h |
@@ -25,7 +25,7 | |||||
25 | #include <QGraphicsLayout> |
|
25 | #include <QGraphicsLayout> | |
26 | #include <QDebug> |
|
26 | #include <QDebug> | |
27 | #include <QFontMetrics> |
|
27 | #include <QFontMetrics> | |
28 | #include <QCategoriesAxis> |
|
28 | #include <QBarCategoriesAxis> | |
29 |
|
29 | |||
30 | static int label_padding = 5; |
|
30 | static int label_padding = 5; | |
31 |
|
31 |
@@ -25,7 +25,7 | |||||
25 | #include <QGraphicsLayout> |
|
25 | #include <QGraphicsLayout> | |
26 | #include <QDebug> |
|
26 | #include <QDebug> | |
27 | #include <QFontMetrics> |
|
27 | #include <QFontMetrics> | |
28 | #include <QCategoriesAxis> |
|
28 | #include <QBarCategoriesAxis> | |
29 |
|
29 | |||
30 | static int label_padding = 5; |
|
30 | static int label_padding = 5; | |
31 |
|
31 |
@@ -27,16 +27,16 | |||||
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 |
Q |
|
30 | QCategoriesAxis::QCategoriesAxis(QObject *parent): | |
31 |
Q |
|
31 | QValuesAxis(*new QCategoriesAxisPrivate(this),parent) | |
32 | { |
|
32 | { | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 |
Q |
|
35 | QCategoriesAxis::~QCategoriesAxis() | |
36 | { |
|
36 | { | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 |
Q |
|
39 | QCategoriesAxis::QCategoriesAxis(QCategoriesAxisPrivate &d,QObject *parent):QValuesAxis(d,parent) | |
40 | { |
|
40 | { | |
41 |
|
41 | |||
42 | } |
|
42 | } | |
@@ -44,253 +44,105 QBarCategoriesAxis::QBarCategoriesAxis(QBarCategoriesAxisPrivate &d,QObject *par | |||||
44 | /*! |
|
44 | /*! | |
45 | Appends \a categories to axis |
|
45 | Appends \a categories to axis | |
46 | */ |
|
46 | */ | |
47 |
void Q |
|
47 | void QCategoriesAxis::append(const QString& category, qreal x) | |
48 | { |
|
48 | { | |
49 |
Q_D(Q |
|
49 | Q_D(QCategoriesAxis); | |
50 |
if (d->m_categories.is |
|
50 | if (!d->m_categories.contains(category)) | |
51 | d->m_categories.append(categories); |
|
|||
52 | setRange(categories.first(),categories.last()); |
|
|||
53 | }else{ |
|
|||
54 | d->m_categories.append(categories); |
|
|||
55 | } |
|
|||
56 |
|
||||
57 | emit categoriesChanged(); |
|
|||
58 | } |
|
|||
59 |
|
||||
60 | /*! |
|
|||
61 | Appends \a category to axis |
|
|||
62 | */ |
|
|||
63 | void QBarCategoriesAxis::append(const QString &category) |
|
|||
64 | { |
|
51 | { | |
65 | Q_D(QBarCategoriesAxis); |
|
|||
66 |
if |
|
52 | if(d->m_categories.isEmpty()){ | |
|
53 | Range range(d->m_categoryMinimum,x); | |||
|
54 | d->m_categoriesMap.insert(category,range); | |||
67 | d->m_categories.append(category); |
|
55 | d->m_categories.append(category); | |
68 | setRange(category,category); |
|
|||
69 | }else{ |
|
56 | }else{ | |
|
57 | Range range = d->m_categoriesMap.value(d->m_categories.last()); | |||
|
58 | d->m_categoriesMap.insert(category,Range(range.first,x)); | |||
70 | d->m_categories.append(category); |
|
59 | d->m_categories.append(category); | |
71 | } |
|
60 | } | |
72 | emit categoriesChanged(); |
|
61 | setRange(d->m_min,x); | |
73 | } |
|
|||
74 |
|
||||
75 | /*! |
|
|||
76 | Removes \a category from axis |
|
|||
77 | */ |
|
|||
78 | void QBarCategoriesAxis::remove(const QString &category) |
|
|||
79 | { |
|
|||
80 | Q_D(QBarCategoriesAxis); |
|
|||
81 | if (d->m_categories.contains(category)) { |
|
|||
82 | d->m_categories.removeAt(d->m_categories.indexOf(category)); |
|
|||
83 | setRange(d->m_categories.first(),d->m_categories.last()); |
|
|||
84 | emit categoriesChanged(); |
|
|||
85 | } |
|
62 | } | |
86 | } |
|
63 | } | |
87 |
|
64 | |||
88 | /*! |
|
65 | void QCategoriesAxis::setFisrtCategoryMinimum(qreal x) | |
89 | Inserts \a category to axis at \a index |
|
|||
90 | */ |
|
|||
91 | void QBarCategoriesAxis::insert(int index, const QString &category) |
|
|||
92 | { |
|
66 | { | |
93 |
|
|
67 | Q_D(QCategoriesAxis); | |
94 |
|
|
68 | if(d->m_categories.isEmpty()){ | |
95 | d->m_categories.insert(index,category); |
|
69 | d->m_categoryMinimum=x; | |
96 | setRange(category,category); |
|
|||
97 |
|
|
70 | }else{ | |
98 |
|
71 | Range range = d->m_categoriesMap.value(d->m_categories.first()); | ||
|
72 | d->m_categoriesMap.insert(d->m_categories.first(),Range(x,range.second)); | |||
|
73 | setRange(x,d->m_min); | |||
99 | } |
|
74 | } | |
100 | emit categoriesChanged(); |
|
|||
101 | } |
|
75 | } | |
102 |
|
76 | |||
103 | /*! |
|
77 | /*! | |
104 |
Removes a |
|
78 | Removes \a category from axis | |
105 |
|
|
79 | */ | |
106 |
void Q |
|
80 | void QCategoriesAxis::remove(const QString &category) | |
107 | { |
|
81 | { | |
108 | Q_D(QBarCategoriesAxis); |
|
82 | Q_UNUSED(category); | |
109 | d->m_categories.clear(); |
|
83 | //TODO | |
110 | setRange(QString::null,QString::null); |
|
|||
111 | emit categoriesChanged(); |
|
|||
112 | } |
|
84 | } | |
113 |
|
85 | |||
114 | void QBarCategoriesAxis::setCategories(const QStringList &categories) |
|
86 | QStringList QCategoriesAxis::categories() | |
115 | { |
|
87 | { | |
116 |
Q_D(Q |
|
88 | Q_D(QCategoriesAxis); | |
117 | if(d->m_categories!=categories){ |
|
|||
118 | d->m_categories = categories; |
|
|||
119 | setRange(categories.first(),categories.last()); |
|
|||
120 | emit categoriesChanged(); |
|
|||
121 | } |
|
|||
122 | } |
|
|||
123 |
|
||||
124 | QStringList QBarCategoriesAxis::categories() |
|
|||
125 | { |
|
|||
126 | Q_D(QBarCategoriesAxis); |
|
|||
127 | return d->m_categories; |
|
89 | return d->m_categories; | |
128 | } |
|
90 | } | |
129 |
|
91 | |||
130 | /*! |
|
92 | /*! | |
131 | Returns number of categories. |
|
93 | Returns number of categories. | |
132 | */ |
|
94 | */ | |
133 |
int Q |
|
95 | int QCategoriesAxis::count() const | |
134 | { |
|
96 | { | |
135 |
Q_D(const Q |
|
97 | Q_D(const QCategoriesAxis); | |
136 | return d->m_categories.count(); |
|
98 | return d->m_categories.count(); | |
137 | } |
|
99 | } | |
138 |
|
100 | |||
139 | /*! |
|
101 | /*! | |
140 | Returns category at \a index. Index must be valid. |
|
|||
141 | */ |
|
|||
142 | QString QBarCategoriesAxis::at(int index) const |
|
|||
143 | { |
|
|||
144 | Q_D(const QBarCategoriesAxis); |
|
|||
145 | return d->m_categories.at(index); |
|
|||
146 | } |
|
|||
147 |
|
||||
148 | /*! |
|
|||
149 | Sets minimum category to \a min. |
|
|||
150 | */ |
|
|||
151 | void QBarCategoriesAxis::setMin(const QString& min) |
|
|||
152 | { |
|
|||
153 | Q_D(QBarCategoriesAxis); |
|
|||
154 | setRange(min,d->m_maxCategory); |
|
|||
155 | } |
|
|||
156 |
|
||||
157 | /*! |
|
|||
158 | Returns minimum category. |
|
|||
159 | */ |
|
|||
160 | QString QBarCategoriesAxis::min() const |
|
|||
161 | { |
|
|||
162 | Q_D(const QBarCategoriesAxis); |
|
|||
163 | return d->m_minCategory; |
|
|||
164 | } |
|
|||
165 |
|
||||
166 | /*! |
|
|||
167 | Sets maximum category to \a max. |
|
|||
168 | */ |
|
|||
169 | void QBarCategoriesAxis::setMax(const QString& max) |
|
|||
170 | { |
|
|||
171 | Q_D(QBarCategoriesAxis); |
|
|||
172 | setRange(d->m_minCategory,max); |
|
|||
173 | } |
|
|||
174 |
|
||||
175 | /*! |
|
|||
176 | Returns maximum category |
|
|||
177 | */ |
|
|||
178 | QString QBarCategoriesAxis::max() const |
|
|||
179 | { |
|
|||
180 | Q_D(const QBarCategoriesAxis); |
|
|||
181 | return d->m_maxCategory; |
|
|||
182 | } |
|
|||
183 |
|
||||
184 | /*! |
|
|||
185 | Sets range from \a minCategory to \a maxCategory |
|
|||
186 | */ |
|
|||
187 | void QBarCategoriesAxis::setRange(const QString& minCategory, const QString& maxCategory) |
|
|||
188 | { |
|
|||
189 | Q_D(QBarCategoriesAxis); |
|
|||
190 |
|
||||
191 | int minIndex = d->m_categories.indexOf(minCategory); |
|
|||
192 | if (minIndex == -1) { |
|
|||
193 | return; |
|
|||
194 | } |
|
|||
195 | int maxIndex = d->m_categories.indexOf(maxCategory); |
|
|||
196 | if (maxIndex == -1) { |
|
|||
197 | return; |
|
|||
198 | } |
|
|||
199 |
|
||||
200 | if (maxIndex <= minIndex) { |
|
|||
201 | // max must be greater than min |
|
|||
202 | return; |
|
|||
203 | } |
|
|||
204 |
|
||||
205 | bool changed = false; |
|
|||
206 | if (!qFuzzyIsNull(d->m_min - (minIndex))) { |
|
|||
207 | d->m_minCategory = minCategory; |
|
|||
208 | d->m_min = minIndex; |
|
|||
209 | changed = true; |
|
|||
210 | } |
|
|||
211 |
|
||||
212 | if (!qFuzzyIsNull(d->m_max - (maxIndex))) { |
|
|||
213 | d->m_max = maxIndex; |
|
|||
214 | d->m_maxCategory = maxCategory; |
|
|||
215 | changed = true; |
|
|||
216 | } |
|
|||
217 |
|
||||
218 | if ((changed)) { |
|
|||
219 | d->emitRange(); |
|
|||
220 | emit categoriesChanged(); |
|
|||
221 | } |
|
|||
222 | } |
|
|||
223 |
|
||||
224 | /*! |
|
|||
225 | Returns the type of axis. |
|
102 | Returns the type of axis. | |
226 | */ |
|
103 | */ | |
227 |
QAbstractAxis::AxisType Q |
|
104 | QAbstractAxis::AxisType QCategoriesAxis::type() const | |
228 | { |
|
105 | { | |
229 | return AxisTypeCategories; |
|
106 | return AxisTypeCategories; | |
230 | } |
|
107 | } | |
231 |
|
108 | |||
232 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
109 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
233 |
|
110 | |||
234 |
Q |
|
111 | QCategoriesAxisPrivate::QCategoriesAxisPrivate(QCategoriesAxis* q): | |
235 |
Q |
|
112 | QValuesAxisPrivate(q), | |
|
113 | m_categoryMinimum(0) | |||
236 | { |
|
114 | { | |
237 |
|
115 | |||
238 | } |
|
116 | } | |
239 |
|
117 | |||
240 |
Q |
|
118 | QCategoriesAxisPrivate::~QCategoriesAxisPrivate() | |
241 | { |
|
119 | { | |
242 |
|
120 | |||
243 | } |
|
121 | } | |
244 |
|
122 | |||
245 |
|
|
123 | int QCategoriesAxisPrivate::ticksCount() const | |
246 | { |
|
|||
247 | setRange(min,m_maxCategory); |
|
|||
248 | } |
|
|||
249 |
|
||||
250 | void QBarCategoriesAxisPrivate::setMax(const QVariant &max) |
|
|||
251 | { |
|
|||
252 | setRange(m_minCategory,max); |
|
|||
253 | } |
|
|||
254 |
|
||||
255 | void QBarCategoriesAxisPrivate::setRange(const QVariant &min, const QVariant &max) |
|
|||
256 | { |
|
|||
257 | Q_Q(QBarCategoriesAxis); |
|
|||
258 | QString value1 = min.toString(); |
|
|||
259 | QString value2 = max.toString(); |
|
|||
260 | q->setRange(value1,value2); |
|
|||
261 | } |
|
|||
262 |
|
||||
263 | int QBarCategoriesAxisPrivate::ticksCount() const |
|
|||
264 | { |
|
124 | { | |
265 | return m_categories.count()+1; |
|
125 | return m_categories.count()+1; | |
266 | } |
|
126 | } | |
267 |
|
127 | |||
268 |
void Q |
|
128 | void QCategoriesAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) | |
269 | { |
|
129 | { | |
270 | m_min = min; |
|
130 | m_min = min; | |
271 | m_max = max; |
|
131 | m_max = max; | |
272 | m_ticksCount = count; |
|
132 | m_ticksCount = count; | |
273 | } |
|
133 | } | |
274 |
|
134 | |||
275 |
ChartAxis* Q |
|
135 | ChartAxis* QCategoriesAxisPrivate::createGraphics(ChartPresenter* presenter) | |
276 | { |
|
136 | { | |
277 | Q_Q( QBarCategoriesAxis); |
|
137 | Q_UNUSED(presenter); | |
|
138 | // Q_Q( QCategoriesAxis); | |||
278 | if(m_orientation == Qt::Vertical){ |
|
139 | if(m_orientation == Qt::Vertical){ | |
279 | return new ChartCategoriesAxisY(q,presenter); |
|
140 | return 0; | |
280 | }else{ |
|
141 | }else{ | |
281 | return new ChartCategoriesAxisX(q,presenter); |
|
142 | return 0; | |
282 | } |
|
143 | } | |
283 | } |
|
144 | } | |
284 |
|
145 | |||
285 | void QBarCategoriesAxisPrivate::emitRange() |
|
|||
286 | { |
|
|||
287 | Q_Q( QBarCategoriesAxis); |
|
|||
288 | if(!q->signalsBlocked()) { |
|
|||
289 | emit changed(m_min -0.5, m_max +0.5, qCeil(m_max + 0.5) -qCeil(m_min - 0.5) +1, false); |
|
|||
290 | } |
|
|||
291 | } |
|
|||
292 |
|
||||
293 |
|
||||
294 | #include "moc_qcategoriesaxis.cpp" |
|
146 | #include "moc_qcategoriesaxis.cpp" | |
295 | #include "moc_qcategoriesaxis_p.cpp" |
|
147 | #include "moc_qcategoriesaxis_p.cpp" | |
296 |
|
148 |
@@ -22,53 +22,41 | |||||
22 | #define QCATEGORIESAXIS_H |
|
22 | #define QCATEGORIESAXIS_H | |
23 |
|
23 | |||
24 | #include "qabstractaxis.h" |
|
24 | #include "qabstractaxis.h" | |
|
25 | #include "qvaluesaxis.h" | |||
25 |
|
26 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
28 | |||
28 |
class Q |
|
29 | class QCategoriesAxisPrivate; | |
29 |
|
30 | |||
30 |
class QTCOMMERCIALCHART_EXPORT Q |
|
31 | class QTCOMMERCIALCHART_EXPORT QCategoriesAxis : public QValuesAxis | |
31 | { |
|
32 | { | |
32 | Q_OBJECT |
|
33 | Q_OBJECT | |
33 | Q_PROPERTY(QStringList categories READ categories WRITE setCategories NOTIFY categoriesChanged) |
|
|||
34 | Q_PROPERTY(QString min READ min WRITE setMin NOTIFY minChanged) |
|
|||
35 | Q_PROPERTY(QString max READ max WRITE setMax NOTIFY maxChanged) |
|
|||
36 |
|
34 | |||
37 | public: |
|
35 | public: | |
38 |
explicit Q |
|
36 | explicit QCategoriesAxis(QObject *parent = 0); | |
39 |
~Q |
|
37 | ~QCategoriesAxis(); | |
40 |
|
38 | |||
41 | protected: |
|
39 | protected: | |
42 |
Q |
|
40 | QCategoriesAxis(QCategoriesAxisPrivate &d,QObject *parent = 0); | |
43 |
|
41 | |||
44 | public: |
|
42 | public: | |
45 | AxisType type() const; |
|
43 | AxisType type() const; | |
46 | void append(const QStringList &categories); |
|
44 | ||
47 |
void append(const QString |
|
45 | void append(const QString& category, qreal interval = 1); | |
48 |
void remove(const QString |
|
46 | void remove(const QString& category); | |
49 | void insert(int index, const QString &category); |
|
47 | ||
50 | void clear(); |
|
48 | void setFisrtCategoryMinimum(qreal x); | |
51 | void setCategories(const QStringList &categories); |
|
49 | ||
|
50 | qreal categoryMin(const QString& category) const; | |||
|
51 | qreal categoryMax(const QString& category) const; | |||
|
52 | ||||
52 | QStringList categories(); |
|
53 | QStringList categories(); | |
53 | int count() const; |
|
54 | int count() const; | |
54 | QString at(int index) const; |
|
|||
55 |
|
||||
56 | //range handling |
|
|||
57 | void setMin(const QString& minCategory); |
|
|||
58 | QString min() const; |
|
|||
59 | void setMax(const QString& maxCategory); |
|
|||
60 | QString max() const; |
|
|||
61 | void setRange(const QString& minCategory, const QString& maxCategory); |
|
|||
62 |
|
55 | |||
63 | Q_SIGNALS: |
|
|||
64 | void categoriesChanged(); |
|
|||
65 | void minChanged(const QString &min); |
|
|||
66 | void maxChanged(const QString &max); |
|
|||
67 | void rangeChanged(const QString &min, const QString &max); |
|
|||
68 |
|
56 | |||
69 | private: |
|
57 | private: | |
70 |
Q_DECLARE_PRIVATE(Q |
|
58 | Q_DECLARE_PRIVATE(QCategoriesAxis) | |
71 |
Q_DISABLE_COPY(Q |
|
59 | Q_DISABLE_COPY(QCategoriesAxis) | |
72 | }; |
|
60 | }; | |
73 |
|
61 | |||
74 | QTCOMMERCIALCHART_END_NAMESPACE |
|
62 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -31,27 +31,24 | |||||
31 | #define QCATEGORIESAXIS_P_H |
|
31 | #define QCATEGORIESAXIS_P_H | |
32 |
|
32 | |||
33 | #include "qcategoriesaxis.h" |
|
33 | #include "qcategoriesaxis.h" | |
34 |
#include "q |
|
34 | #include "qvaluesaxis_p.h" | |
35 |
|
35 | |||
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
37 |
|
37 | |||
38 | class QBarCategoriesAxisPrivate : public QAbstractAxisPrivate |
|
38 | ||
|
39 | typedef QPair<qreal, qreal> Range; | |||
|
40 | ||||
|
41 | class QCategoriesAxisPrivate : public QValuesAxisPrivate | |||
39 | { |
|
42 | { | |
40 | Q_OBJECT |
|
43 | Q_OBJECT | |
41 |
|
44 | |||
42 | public: |
|
45 | public: | |
43 |
Q |
|
46 | QCategoriesAxisPrivate(QCategoriesAxis *q); | |
44 |
~Q |
|
47 | ~QCategoriesAxisPrivate(); | |
|
48 | ||||
45 |
|
49 | |||
46 | public: |
|
50 | public: | |
47 | ChartAxis* createGraphics(ChartPresenter* presenter); |
|
51 | ChartAxis* createGraphics(ChartPresenter* presenter); | |
48 | void emitRange(); |
|
|||
49 |
|
||||
50 | private: |
|
|||
51 | //range handling |
|
|||
52 | void setMin(const QVariant &min); |
|
|||
53 | void setMax(const QVariant &max); |
|
|||
54 | void setRange(const QVariant &min, const QVariant &max); |
|
|||
55 | int ticksCount() const; |
|
52 | int ticksCount() const; | |
56 |
|
53 | |||
57 | Q_SIGNALS: |
|
54 | Q_SIGNALS: | |
@@ -61,12 +58,12 public Q_SLOTS: | |||||
61 | void handleAxisRangeChanged(qreal min, qreal max,int count); |
|
58 | void handleAxisRangeChanged(qreal min, qreal max,int count); | |
62 |
|
59 | |||
63 | private: |
|
60 | private: | |
|
61 | QMap<QString , Range> m_categoriesMap; | |||
64 | QStringList m_categories; |
|
62 | QStringList m_categories; | |
65 | QString m_minCategory; |
|
63 | qreal m_categoryMinimum; | |
66 | QString m_maxCategory; |
|
|||
67 |
|
64 | |||
68 | private: |
|
65 | private: | |
69 |
Q_DECLARE_PUBLIC(Q |
|
66 | Q_DECLARE_PUBLIC(QCategoriesAxis) | |
70 | }; |
|
67 | }; | |
71 |
|
68 | |||
72 | QTCOMMERCIALCHART_END_NAMESPACE |
|
69 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -28,7 +28,7 | |||||
28 | #include "charttheme_p.h" |
|
28 | #include "charttheme_p.h" | |
29 | #include "chartanimator_p.h" |
|
29 | #include "chartanimator_p.h" | |
30 | #include "qvaluesaxis.h" |
|
30 | #include "qvaluesaxis.h" | |
31 | #include "qcategoriesaxis.h" |
|
31 | #include "qbarcategoriesaxis.h" | |
32 |
|
32 | |||
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
34 |
|
34 |
@@ -21,7 +21,7 | |||||
21 | #include "chartdataset_p.h" |
|
21 | #include "chartdataset_p.h" | |
22 | #include "qchart.h" |
|
22 | #include "qchart.h" | |
23 | #include "qvaluesaxis.h" |
|
23 | #include "qvaluesaxis.h" | |
24 | #include "qcategoriesaxis.h" |
|
24 | #include "qbarcategoriesaxis.h" | |
25 | #include "qvaluesaxis_p.h" |
|
25 | #include "qvaluesaxis_p.h" | |
26 | #include "qabstractseries_p.h" |
|
26 | #include "qabstractseries_p.h" | |
27 | #include "qabstractbarseries.h" |
|
27 | #include "qabstractbarseries.h" |
@@ -21,7 +21,7 | |||||
21 | #include <QtTest/QtTest> |
|
21 | #include <QtTest/QtTest> | |
22 | #include <qabstractaxis.h> |
|
22 | #include <qabstractaxis.h> | |
23 | #include <qvaluesaxis.h> |
|
23 | #include <qvaluesaxis.h> | |
24 | #include <qcategoriesaxis.h> |
|
24 | #include <qbarcategoriesaxis.h> | |
25 | #include <qlineseries.h> |
|
25 | #include <qlineseries.h> | |
26 | #include <qareaseries.h> |
|
26 | #include <qareaseries.h> | |
27 | #include <qscatterseries.h> |
|
27 | #include <qscatterseries.h> |
@@ -42,7 +42,7 | |||||
42 | #include <cmath> |
|
42 | #include <cmath> | |
43 | #include <QDebug> |
|
43 | #include <QDebug> | |
44 | #include <QStandardItemModel> |
|
44 | #include <QStandardItemModel> | |
45 | #include <QCategoriesAxis> |
|
45 | #include <QBarCategoriesAxis> | |
46 |
|
46 | |||
47 |
|
47 | |||
48 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
48 | QTCOMMERCIALCHART_USE_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now