##// END OF EJS Templates
Some axes docs update
Marek Rosa -
r1834:aeeb738d6b7d
parent child
Show More
@@ -1,242 +1,264
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 "qcategoryaxis.h"
22 22 #include "qcategoryaxis_p.h"
23 23 #include "chartcategoryaxisx_p.h"
24 24 #include "chartcategoryaxisy_p.h"
25 25 #include <qmath.h>
26 26 #include <QDebug>
27 27
28 28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 29 /*!
30 30 \class QCategoryAxis
31 \brief The QCategoryAxis class is used for manipulating chart's axis.
31 \brief The QCategoryAxis class allows putting a named ranges on the axis.
32 32 \mainclass
33
34 This class can be used when the underlying data needs to be given extra meaning.
35 Unlike with the QBarCategoryAxis the QCategoryAxis allows the categories ranges widths to be specified freely.
33 36 */
34 37
35 38 /*!
36 39 \qmlclass CategoryAxis QCategoryAxis
37 \brief The Axis element is used for manipulating chart's axes.
40 \brief The QCategoryAxis class allows putting a named ranges on the axis.
41 */
42
43 /*!
44 \property QCategoryAxis::startValue
45 Defines the low end of the first category on the axis.
46 */
47
48 /*!
49 \qmlproperty int CategoryAxis::startValue
50 Defines the low end of the first category on the axis.
38 51 */
39 52
40 53 /*!
41 54 Constructs an axis object which is a child of \a parent.
42 55 */
43 56 QCategoryAxis::QCategoryAxis(QObject *parent):
44 57 QValueAxis(*new QCategoryAxisPrivate(this),parent)
45 58 {
46 59 }
47 60
48 61 /*!
49 62 Destroys the object
50 63 */
51 64 QCategoryAxis::~QCategoryAxis()
52 65 {
53 66 // Q_D(QValueAxis);
54 67 // if(d->m_dataset) {
55 68 // d->m_dataset->removeAxis(this);
56 69 // }
57 70 }
58 71
59 72 /*!
60 73 \internal
61 74 */
62 75 QCategoryAxis::QCategoryAxis(QCategoryAxisPrivate &d,QObject *parent):QValueAxis(d,parent)
63 76 {
64 77
65 78 }
66 79
67 80 /*!
68 81 Appends new category to the axis with an \a categoryLabel.
69 82 Category label has to be unique.
70 83 Parameter \a categoryHighEnd specifies the high end limit of the category.
71 84 It has to be greater than the high end limit of the previous category.
72 85 Otherwise the method returns without adding a new category.
73 86 */
74 87 void QCategoryAxis::append(const QString& categoryLabel, qreal categoryHighEnd)
75 88 {
76 89 Q_D(QCategoryAxis);
77 90
78 91 if (!d->m_categories.contains(categoryLabel))
79 92 {
80 93 if(d->m_categories.isEmpty()){
81 94 Range range(d->m_categoryMinimum, categoryHighEnd);
82 95 d->m_categoriesMap.insert(categoryLabel, range);
83 96 d->m_categories.append(categoryLabel);
84 97 }else if (categoryHighEnd > categoryEnd(d->m_categories.last())){
85 98 Range previousRange = d->m_categoriesMap.value(d->m_categories.last());
86 99 d->m_categoriesMap.insert(categoryLabel, Range(previousRange.second, categoryHighEnd));
87 100 d->m_categories.append(categoryLabel);
88 101 }
89 102 }
90 103 }
91 104
92 105 /*!
93 Sets to \a min the low end limit of the first category on the axis.
106 Returns the low end limit of the first category on the axis.
107 */
108 qreal QCategoryAxis::startValue() const
109 {
110 Q_D(const QCategoryAxis);
111 return d->m_categoryMinimum;
112 }
113
114 /*!
115 Sets \a min to be the low end limit of the first category on the axis.
94 116 */
95 117 void QCategoryAxis::setStartValue(qreal min)
96 118 {
97 119 Q_D(QCategoryAxis);
98 120 if(d->m_categories.isEmpty()){
99 121 d->m_categoryMinimum = min;
100 122 }else{
101 123 Range range = d->m_categoriesMap.value(d->m_categories.first());
102 124 d->m_categoriesMap.insert(d->m_categories.first(), Range(min, range.second));
103 125 }
104 126 }
105 127
106 128 /*!
107 129 Returns the low end limit of the category specified by an \a categoryLabel
108 130 */
109 131 qreal QCategoryAxis::categoryStart(const QString& categoryLabel) const
110 132 {
111 133 Q_D(const QCategoryAxis);
112 134 return d->m_categoriesMap.value(categoryLabel).first;
113 135 }
114 136
115 137 /*!
116 138 Returns the high end limit of the interval specified by an \a categoryLabel
117 139 */
118 140 qreal QCategoryAxis::categoryEnd(const QString& categoryLabel) const
119 141 {
120 142 Q_D(const QCategoryAxis);
121 143 return d->m_categoriesMap.value(categoryLabel).second;
122 144 }
123 145
124 146 /*!
125 147 Removes an interval specified by the \a categoryLabel from the axis
126 148 */
127 149 void QCategoryAxis::remove(const QString &categoryLabel)
128 150 {
129 151 Q_D(QCategoryAxis);
130 152 int labelIndex = d->m_categories.indexOf(categoryLabel);
131 153
132 154 // check if such label exists
133 155 if (labelIndex != -1) {
134 156 d->m_categories.removeAt(labelIndex);
135 157 d->m_categoriesMap.remove(categoryLabel);
136 158
137 159 // the range of the interval that follows (if exists) needs to be updated
138 160 if (labelIndex < d->m_categories.count()) {
139 161 QString label = d->m_categories.at(labelIndex);
140 162 Range range = d->m_categoriesMap.value(label);
141 163
142 164 // set the range
143 165 if (labelIndex == 0) {
144 166 range.first = d->m_categoryMinimum;
145 167 d->m_categoriesMap.insert(label, range);
146 168 } else {
147 169 range.first = d->m_categoriesMap.value(d->m_categories.at(labelIndex - 1)).second;
148 170 d->m_categoriesMap.insert(label, range);
149 171 }
150 172 }
151 173 d->emitUpdated();
152 174 }
153 175 }
154 176
155 177 /*!
156 178 Replaces \a oldLabel of an existing category with a \a newLabel
157 179 If the old label does not exist the method returns without making any changes.
158 180 */
159 181 void QCategoryAxis::replaceLabel(const QString& oldLabel, const QString& newLabel)
160 182 {
161 183 Q_D(QCategoryAxis);
162 184 int labelIndex = d->m_categories.indexOf(oldLabel);
163 185
164 186 // check if such label exists
165 187 if (labelIndex != -1) {
166 188 d->m_categories.replace(labelIndex, newLabel);
167 189 Range range = d->m_categoriesMap.value(oldLabel);
168 190 d->m_categoriesMap.remove(oldLabel);
169 191 d->m_categoriesMap.insert(newLabel, range);
170 192 d->emitUpdated();
171 193 }
172 194
173 195 }
174 196
175 197 /*!
176 198 Returns the list of the intervals labels
177 199 */
178 200 QStringList QCategoryAxis::categoriesLabels()
179 201 {
180 202 Q_D(QCategoryAxis);
181 203 return d->m_categories;
182 204 }
183 205
184 206 /*!
185 207 Returns number of intervals.
186 208 */
187 209 int QCategoryAxis::count() const
188 210 {
189 211 Q_D(const QCategoryAxis);
190 212 return d->m_categories.count();
191 213 }
192 214
193 215 /*!
194 216 Returns the type of the axis
195 217 */
196 218 QAbstractAxis::AxisType QCategoryAxis::type() const
197 219 {
198 220 return QAbstractAxis::AxisTypeCategory;
199 221 }
200 222
201 223 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
202 224
203 225 QCategoryAxisPrivate::QCategoryAxisPrivate(QCategoryAxis* q):
204 226 QValueAxisPrivate(q),
205 227 m_categoryMinimum(0)
206 228 {
207 229
208 230 }
209 231
210 232 QCategoryAxisPrivate::~QCategoryAxisPrivate()
211 233 {
212 234
213 235 }
214 236
215 237 int QCategoryAxisPrivate::ticksCount() const
216 238 {
217 239 return m_categories.count() + 1;
218 240 }
219 241
220 242 void QCategoryAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count)
221 243 {
222 244 Q_UNUSED(count);
223 245 Q_UNUSED(min);
224 246 Q_UNUSED(max);
225 247 //m_min = min;
226 248 //m_max = max;
227 249 }
228 250
229 251 ChartAxis* QCategoryAxisPrivate::createGraphics(ChartPresenter* presenter)
230 252 {
231 253 Q_Q(QCategoryAxis);
232 254 if(m_orientation == Qt::Vertical){
233 255 return new ChartCategoryAxisY(q,presenter);
234 256 }else{
235 257 return new ChartCategoryAxisX(q,presenter);
236 258 }
237 259 }
238 260
239 261 #include "moc_qcategoryaxis.cpp"
240 262 #include "moc_qcategoryaxis_p.cpp"
241 263
242 264 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,65 +1,66
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 #ifndef QCATEGORIESAXIS_H
22 22 #define QCATEGORIESAXIS_H
23 23
24 24 #include "qabstractaxis.h"
25 25 #include "qvalueaxis.h"
26 26
27 27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 28
29 29 class QCategoryAxisPrivate;
30 30
31 31 class QTCOMMERCIALCHART_EXPORT QCategoryAxis : public QValueAxis
32 32 {
33 33 Q_OBJECT
34 Q_PROPERTY(qreal startValue READ startValue WRITE setStartValue)
34 35
35 36 public:
36 37 explicit QCategoryAxis(QObject *parent = 0);
37 38 ~QCategoryAxis();
38 39
39 40 protected:
40 41 QCategoryAxis(QCategoryAxisPrivate &d,QObject *parent = 0);
41 42
42 43 public:
43 44 AxisType type() const;
44 45
45 46 void append(const QString& label, qreal categoryHighEnd);
46 47 void remove(const QString& label);
47 48 void replaceLabel(const QString& oldLabel, const QString& newLabel);
48 49
50 qreal startValue() const;
49 51 void setStartValue(qreal min);
50 52
51 53 qreal categoryStart(const QString& categoryLabel) const;
52 54 qreal categoryEnd(const QString& categoryLabel) const;
53 55
54 56 QStringList categoriesLabels();
55 57 int count() const;
56 58
57
58 59 private:
59 60 Q_DECLARE_PRIVATE(QCategoryAxis)
60 61 Q_DISABLE_COPY(QCategoryAxis)
61 62 };
62 63
63 64 QTCOMMERCIALCHART_END_NAMESPACE
64 65
65 66 #endif // QCATEGORIESAXIS_H
@@ -1,70 +1,68
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 QCATEGORYAXIS_P_H
31 31 #define QCATEGORYAXIS_P_H
32 32
33 33 #include "qcategoryaxis.h"
34 34 #include "qvalueaxis_p.h"
35 35
36 36 QTCOMMERCIALCHART_BEGIN_NAMESPACE
37 37
38 38 typedef QPair<qreal, qreal> Range;
39 39
40 40 class QCategoryAxisPrivate : public QValueAxisPrivate
41 41 {
42 42 Q_OBJECT
43 43
44 44 public:
45 45 QCategoryAxisPrivate(QCategoryAxis *q);
46 46 ~QCategoryAxisPrivate();
47 47
48
49 public:
50 48 ChartAxis* createGraphics(ChartPresenter* presenter);
51 49 int ticksCount() const;
52 50
53 51 Q_SIGNALS:
54 52 void changed(qreal min, qreal max, int tickCount,bool niceNumbers);
55 53
56 54 public Q_SLOTS:
57 55 void handleAxisRangeChanged(qreal min, qreal max,int count);
58 56
59 57 private:
60 58 QMap<QString , Range> m_categoriesMap;
61 59 QStringList m_categories;
62 60 qreal m_categoryMinimum;
63 61
64 62 private:
65 63 Q_DECLARE_PUBLIC(QCategoryAxis)
66 64 };
67 65
68 66 QTCOMMERCIALCHART_END_NAMESPACE
69 67
70 68 #endif // QCATEGORYAXIS_P_H
@@ -1,322 +1,320
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 "qdatetimeaxis.h"
22 22 #include "qdatetimeaxis_p.h"
23 23 #include "chartdatetimeaxisx_p.h"
24 24 #include "chartdatetimeaxisy_p.h"
25 25 #include "domain_p.h"
26 26 #include <cmath>
27 27 #include <QDebug>
28 28
29 29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 30 /*!
31 31 \class QDateTimeAxis
32 32 \brief The QDateTimeAxis class is used for manipulating chart's axis.
33 33 \mainclass
34 34
35 35 The labels can be configured by setting an appropriate DateTime format.
36 Note that any date before 4800 BCE or after about 1.4 million CE may not be accurately stored.
36 Note that any date before 4714 BCE or after about 1.4 million CE may not be accurately stored.
37 37 QDateTimeAxis can be setup to show axis line with tick marks, grid lines and shades.
38 38 */
39 39
40 40 /*!
41 41 \qmlclass DateTimeAxis QDateTimeAxis
42 42 \brief The DateTimeAxis element is used for manipulating chart's axes
43 43
44 44 The labels can be configured by setting an appropriate DateTime format.
45 Note that any date before 4800 BCE or after about 1.4 million CE may not be accurately stored.
45 Note that any date before 4714 BCE or after about 1.4 million CE may not be accurately stored.
46 46 DateTimeAxis can be setup to show axis line with tick marks, grid lines and shades.
47 47 */
48 48
49 49 /*!
50 50 \property QDateTimeAxis::min
51 51 Defines the minimum value on the axis.
52 52 When setting this property the max is adjusted if necessary, to ensure that the range remains valid.
53 53 */
54 54 /*!
55 55 \qmlproperty real ValuesAxis::min
56 56 Defines the minimum value on the axis.
57 57 When setting this property the max is adjusted if necessary, to ensure that the range remains valid.
58 58 */
59 59
60 60 /*!
61 61 \property QDateTimeAxis::max
62 62 Defines the maximum value on the axis.
63 63 When setting this property the min is adjusted if necessary, to ensure that the range remains valid.
64 64 */
65 65 /*!
66 66 \qmlproperty real ValuesAxis::max
67 67 Defines the maximum value on the axis.
68 68 When setting this property the min is adjusted if necessary, to ensure that the range remains valid.
69 69 */
70 70
71 71 /*!
72 72 \fn void QDateTimeAxis::minChanged(QDateTime min)
73 73 Axis emits signal when \a min of axis has changed.
74 74 */
75 75 /*!
76 76 \qmlsignal ValuesAxis::onMinChanged(QDateTime min)
77 77 Axis emits signal when \a min of axis has changed.
78 78 */
79 79
80 80 /*!
81 81 \fn void QDateTimeAxis::maxChanged(QDateTime max)
82 82 Axis emits signal when \a max of axis has changed.
83 83 */
84 84 /*!
85 85 \qmlsignal ValuesAxis::onMaxChanged(QDateTime max)
86 86 Axis emits signal when \a max of axis has changed.
87 87 */
88 88
89 89 /*!
90 90 \fn void QDateTimeAxis::rangeChanged(QDateTime min, QDateTime max)
91 91 Axis emits signal when \a min or \a max of axis has changed.
92 92 */
93 93
94 94 /*!
95 95 \property QDateTimeAxis::tickCount
96 96 The number of tick marks for the axis.
97 97 */
98 98
99 99 /*!
100 100 \qmlproperty int ValuesAxis::tickCount
101 101 The number of tick marks for the axis.
102 102 */
103 103
104 104 /*!
105 105 Constructs an axis object which is a child of \a parent.
106 106 */
107 107 QDateTimeAxis::QDateTimeAxis(QObject *parent) :
108 108 QAbstractAxis(*new QDateTimeAxisPrivate(this),parent)
109 109 {
110 110
111 111 }
112 112
113 113 /*!
114 114 \internal
115 115 */
116 116 QDateTimeAxis::QDateTimeAxis(QDateTimeAxisPrivate &d,QObject *parent) : QAbstractAxis(d,parent)
117 117 {
118 118
119 119 }
120 120
121 121 /*!
122 122 Destroys the object
123 123 */
124 124 QDateTimeAxis::~QDateTimeAxis()
125 125 {
126 126
127 127 }
128 128
129 129 void QDateTimeAxis::setMin(QDateTime min)
130 130 {
131 131 Q_D(QDateTimeAxis);
132 132 if (min.isValid())
133 133 setRange(min, qMax(d->m_max, min));
134 134 }
135 135
136 136 QDateTime QDateTimeAxis::min() const
137 137 {
138 138 Q_D(const QDateTimeAxis);
139 139 return d->m_min;
140 140 }
141 141
142 142 void QDateTimeAxis::setMax(QDateTime max)
143 143 {
144 144 Q_D(QDateTimeAxis);
145 145 if (max.isValid())
146 146 setRange(qMin(d->m_min, max), max);
147 147 }
148 148
149 149 QDateTime QDateTimeAxis::max() const
150 150 {
151 151 Q_D(const QDateTimeAxis);
152 152 return d->m_max;
153 153 }
154 154
155 155 /*!
156 156 Sets range from \a min to \a max on the axis.
157 157 If min is greater than max then this function returns without making any changes.
158 158 */
159 159 void QDateTimeAxis::setRange(QDateTime min, QDateTime max)
160 160 {
161 161 Q_D(QDateTimeAxis);
162 162 if (!min.isValid() || !max.isValid() || min > max)
163 163 return;
164 164
165 165 bool changed = false;
166 166 if (d->m_min != min) {
167 167 d->m_min = min;
168 168 changed = true;
169 169 emit minChanged(min);
170 170 }
171 171
172 172 if (d->m_max != max) {
173 173 d->m_max = max;
174 174 changed = true;
175 175 emit maxChanged(max);
176 176 }
177 177
178 // if(d->m_niceNumbers) d->looseNiceNumbers(d->m_min, d->m_max, d->m_tickCount);
179
180 178 if (changed) {
181 179 emit rangeChanged(d->m_min,d->m_max);
182 180 d->emitUpdated();
183 181 }
184 182 }
185 183
186 184 /*!
187 185 Sets \a format string that is used when creating label for the axis out of the QDateTime object.
188 186 Check QDateTime documentation for information on how the string should be defined.
189 187 \sa format()
190 188 */
191 189 void QDateTimeAxis::setFormat(QString format)
192 190 {
193 191 Q_D(QDateTimeAxis);
194 192 d->m_format = format;
195 193 }
196 194
197 195 /*!
198 196 Returns the format string that is used when creating label for the axis out of the QDateTime object.
199 197 Check QDateTime documentation for information on how the string should be defined.
200 198 \sa setFormat()
201 199 */
202 200 QString QDateTimeAxis::format() const
203 201 {
204 202 Q_D(const QDateTimeAxis);
205 203 return d->m_format;
206 204 }
207 205
208 206 /*!
209 207 Sets \a count for ticks on the axis.
210 208 */
211 209 void QDateTimeAxis::setTickCount(int count)
212 210 {
213 211 Q_D(QDateTimeAxis);
214 212 if (d->m_tickCount != count && count >=2) {
215 213 d->m_tickCount = count;
216 214 d->emitUpdated();
217 215 }
218 216 }
219 217
220 218 /*!
221 219 \fn int QDateTimeAxis::tickCount() const
222 220 Return number of ticks on the axis
223 221 */
224 222 int QDateTimeAxis::tickCount() const
225 223 {
226 224 Q_D(const QDateTimeAxis);
227 225 return d->m_tickCount;
228 226 }
229 227
230 228 /*!
231 229 Returns the type of the axis
232 230 */
233 231 QAbstractAxis::AxisType QDateTimeAxis::type() const
234 232 {
235 233 return AxisTypeDateTime;
236 234 }
237 235
238 236 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
239 237
240 238 QDateTimeAxisPrivate::QDateTimeAxisPrivate(QDateTimeAxis* q):
241 239 QAbstractAxisPrivate(q),
242 240 m_tickCount(5)
243 241 {
244 242 m_min = QDateTime::fromMSecsSinceEpoch(0);
245 243 m_max = QDateTime::fromMSecsSinceEpoch(0);
246 244 m_format = "dd-MMM-yyyy\nh:mm";
247 245 }
248 246
249 247 QDateTimeAxisPrivate::~QDateTimeAxisPrivate()
250 248 {
251 249
252 250 }
253 251
254 252 void QDateTimeAxisPrivate::handleDomainUpdated()
255 253 {
256 254 Q_Q(QDateTimeAxis);
257 255 Domain* domain = qobject_cast<Domain*>(sender());
258 256 Q_ASSERT(domain);
259 257
260 258 if(orientation()==Qt::Horizontal){
261 259 q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minX()), QDateTime::fromMSecsSinceEpoch(domain->maxX()));
262 260 }else if(orientation()==Qt::Vertical){
263 261 q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minY()), QDateTime::fromMSecsSinceEpoch(domain->maxY()));
264 262 }
265 263 }
266 264
267 265
268 266 void QDateTimeAxisPrivate::setMin(const QVariant &min)
269 267 {
270 268 Q_Q(QDateTimeAxis);
271 269 if (min.canConvert(QVariant::DateTime))
272 270 q->setMin(min.toDateTime());
273 271 }
274 272
275 273 void QDateTimeAxisPrivate::setMax(const QVariant &max)
276 274 {
277 275
278 276 Q_Q(QDateTimeAxis);
279 277 if (max.canConvert(QVariant::DateTime))
280 278 q->setMax(max.toDateTime());
281 279 }
282 280
283 281 void QDateTimeAxisPrivate::setRange(const QVariant &min, const QVariant &max)
284 282 {
285 283 Q_Q(QDateTimeAxis);
286 284 if (min.canConvert(QVariant::DateTime) && max.canConvert(QVariant::DateTime))
287 285 q->setRange(min.toDateTime(), max.toDateTime());
288 286 }
289 287
290 288 ChartAxis* QDateTimeAxisPrivate::createGraphics(ChartPresenter* presenter)
291 289 {
292 290 Q_Q(QDateTimeAxis);
293 291 if(m_orientation == Qt::Vertical){
294 292 return new ChartDateTimeAxisY(q,presenter);
295 293 }else{
296 294 return new ChartDateTimeAxisX(q,presenter);
297 295 }
298 296
299 297 }
300 298
301 299 void QDateTimeAxisPrivate::intializeDomain(Domain* domain)
302 300 {
303 301 Q_Q(QDateTimeAxis);
304 302 if(m_max == m_min) {
305 303 if(m_orientation==Qt::Vertical){
306 304 q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minY()), QDateTime::fromMSecsSinceEpoch(domain->maxY()));
307 305 }else{
308 306 q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minX()), QDateTime::fromMSecsSinceEpoch(domain->maxX()));
309 307 }
310 308 } else {
311 309 if(m_orientation==Qt::Vertical){
312 310 domain->setRangeY(m_min.toMSecsSinceEpoch(), m_max.toMSecsSinceEpoch());
313 311 }else{
314 312 domain->setRangeX(m_min.toMSecsSinceEpoch(), m_max.toMSecsSinceEpoch());
315 313 }
316 314 }
317 315 }
318 316
319 317 #include "moc_qdatetimeaxis.cpp"
320 318 #include "moc_qdatetimeaxis_p.cpp"
321 319
322 320 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now