@@ -51,7 +51,7 void ChartDateTimeAxisX::createLabels(QStringList &labels,qreal min, qreal max, | |||||
51 | n++; |
|
51 | n++; | |
52 | for (int i=0; i< ticks; i++) { |
|
52 | for (int i=0; i< ticks; i++) { | |
53 | qreal value = min + (i * (max - min)/ (ticks-1)); |
|
53 | qreal value = min + (i * (max - min)/ (ticks-1)); | |
54 |
labels << QDateTime::fromMSecsSinceEpoch(value).toString(axis->format |
|
54 | labels << QDateTime::fromMSecsSinceEpoch(value).toString(axis->format()); | |
55 | } |
|
55 | } | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
@@ -129,7 +129,7 void ChartDateTimeAxisX::handleAxisUpdated() | |||||
129 | { |
|
129 | { | |
130 | //TODO:: fix this |
|
130 | //TODO:: fix this | |
131 | QDateTimeAxis* axis = qobject_cast<QDateTimeAxis*>(m_chartAxis); |
|
131 | QDateTimeAxis* axis = qobject_cast<QDateTimeAxis*>(m_chartAxis); | |
132 |
m_tickCount = axis->tick |
|
132 | m_tickCount = axis->tickCount(); | |
133 | ChartAxis::handleAxisUpdated(); |
|
133 | ChartAxis::handleAxisUpdated(); | |
134 | } |
|
134 | } | |
135 |
|
135 |
@@ -51,7 +51,7 void ChartDateTimeAxisY::createLabels(QStringList &labels,qreal min, qreal max, | |||||
51 | n++; |
|
51 | n++; | |
52 | for (int i=0; i< ticks; i++) { |
|
52 | for (int i=0; i< ticks; i++) { | |
53 | qreal value = min + (i * (max - min)/ (ticks-1)); |
|
53 | qreal value = min + (i * (max - min)/ (ticks-1)); | |
54 |
labels << QDateTime::fromMSecsSinceEpoch(value).toString(axis->format |
|
54 | labels << QDateTime::fromMSecsSinceEpoch(value).toString(axis->format()); | |
55 | } |
|
55 | } | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
@@ -134,7 +134,7 void ChartDateTimeAxisY::handleAxisUpdated() | |||||
134 | { |
|
134 | { | |
135 | //TODO:: fix this |
|
135 | //TODO:: fix this | |
136 | QDateTimeAxis* axis = qobject_cast<QDateTimeAxis*>(m_chartAxis); |
|
136 | QDateTimeAxis* axis = qobject_cast<QDateTimeAxis*>(m_chartAxis); | |
137 |
m_tickCount = axis->tick |
|
137 | m_tickCount = axis->tickCount(); | |
138 | ChartAxis::handleAxisUpdated(); |
|
138 | ChartAxis::handleAxisUpdated(); | |
139 | } |
|
139 | } | |
140 |
|
140 |
@@ -32,30 +32,18 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
32 | \brief The QDateTimeAxis class is used for manipulating chart's axis. |
|
32 | \brief The QDateTimeAxis class is used for manipulating chart's axis. | |
33 | \mainclass |
|
33 | \mainclass | |
34 |
|
34 | |||
|
35 | The labels can be configured by setting an appropriate DateTime format. | |||
35 | 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 4800 BCE or after about 1.4 million CE may not be accurately stored. | |
36 |
|
37 | QDateTimeAxis can be setup to show axis line with tick marks, grid lines and shades. | ||
37 | ValuesAxis can be setup to show axis line with tick marks, grid lines and shades. |
|
|||
38 | Values of axis are drawn to position of ticks |
|
|||
39 | */ |
|
38 | */ | |
40 |
|
39 | |||
41 | /*! |
|
40 | /*! | |
42 |
\qmlclass |
|
41 | \qmlclass DateTimeAxis QDateTimeAxis | |
43 |
\brief The |
|
42 | \brief The DateTimeAxis element is used for manipulating chart's axes | |
44 |
|
43 | |||
45 | ValueAxis can be setup to show axis line with tick marks, grid lines and shades. |
|
44 | The labels can be configured by setting an appropriate DateTime format. | |
46 | Values of axis are drawn to position of ticks |
|
45 | Note that any date before 4800 BCE or after about 1.4 million CE may not be accurately stored. | |
47 |
|
46 | DateTimeAxis can be setup to show axis line with tick marks, grid lines and shades. | ||
48 | To access Axes you can use ChartView API. For example: |
|
|||
49 | \code |
|
|||
50 | ChartView { |
|
|||
51 | ValuesAxis { |
|
|||
52 | id: xAxis |
|
|||
53 | min: 0 |
|
|||
54 | max: 10 |
|
|||
55 | } |
|
|||
56 | // Add a few series... |
|
|||
57 | } |
|
|||
58 | \endcode |
|
|||
59 | */ |
|
47 | */ | |
60 |
|
48 | |||
61 | /*! |
|
49 | /*! | |
@@ -200,7 +188,7 void QDateTimeAxis::setRange(QDateTime min, QDateTime max) | |||||
200 | Check QDateTime documentation for information on how the string should be defined. |
|
188 | Check QDateTime documentation for information on how the string should be defined. | |
201 | \sa formatString() |
|
189 | \sa formatString() | |
202 | */ |
|
190 | */ | |
203 |
void QDateTimeAxis::setFormat |
|
191 | void QDateTimeAxis::setFormat(QString format) | |
204 | { |
|
192 | { | |
205 | Q_D(QDateTimeAxis); |
|
193 | Q_D(QDateTimeAxis); | |
206 | d->m_format = format; |
|
194 | d->m_format = format; | |
@@ -211,7 +199,7 void QDateTimeAxis::setFormatString(QString format) | |||||
211 | Check QDateTime documentation for information on how the string should be defined. |
|
199 | Check QDateTime documentation for information on how the string should be defined. | |
212 | \sa setFormatString() |
|
200 | \sa setFormatString() | |
213 | */ |
|
201 | */ | |
214 |
QString QDateTimeAxis::format |
|
202 | QString QDateTimeAxis::format() const | |
215 | { |
|
203 | { | |
216 | Q_D(const QDateTimeAxis); |
|
204 | Q_D(const QDateTimeAxis); | |
217 | return d->m_format; |
|
205 | return d->m_format; | |
@@ -220,7 +208,7 QString QDateTimeAxis::formatString() const | |||||
220 | /*! |
|
208 | /*! | |
221 | Sets \a count for ticks on the axis. |
|
209 | Sets \a count for ticks on the axis. | |
222 | */ |
|
210 | */ | |
223 |
void QDateTimeAxis::setTick |
|
211 | void QDateTimeAxis::setTickCount(int count) | |
224 | { |
|
212 | { | |
225 | Q_D(QDateTimeAxis); |
|
213 | Q_D(QDateTimeAxis); | |
226 | if (d->m_tickCount != count && count >=2) { |
|
214 | if (d->m_tickCount != count && count >=2) { | |
@@ -233,7 +221,7 void QDateTimeAxis::setTicksCount(int count) | |||||
233 | \fn int QDateTimeAxis::ticksCount() const |
|
221 | \fn int QDateTimeAxis::ticksCount() const | |
234 | Return number of ticks on the axis |
|
222 | Return number of ticks on the axis | |
235 | */ |
|
223 | */ | |
236 |
int QDateTimeAxis::tick |
|
224 | int QDateTimeAxis::tickCount() const | |
237 | { |
|
225 | { | |
238 | Q_D(const QDateTimeAxis); |
|
226 | Q_D(const QDateTimeAxis); | |
239 | return d->m_tickCount; |
|
227 | return d->m_tickCount; |
@@ -32,7 +32,7 class QDateTimeAxisPrivate; | |||||
32 | class QTCOMMERCIALCHART_EXPORT QDateTimeAxis : public QAbstractAxis |
|
32 | class QTCOMMERCIALCHART_EXPORT QDateTimeAxis : public QAbstractAxis | |
33 | { |
|
33 | { | |
34 | Q_OBJECT |
|
34 | Q_OBJECT | |
35 |
Q_PROPERTY(int tick |
|
35 | Q_PROPERTY(int tickCount READ tickCount WRITE setTickCount) | |
36 | Q_PROPERTY(QDateTime min READ min WRITE setMin NOTIFY minChanged) |
|
36 | Q_PROPERTY(QDateTime min READ min WRITE setMin NOTIFY minChanged) | |
37 | Q_PROPERTY(QDateTime max READ max WRITE setMax NOTIFY maxChanged) |
|
37 | Q_PROPERTY(QDateTime max READ max WRITE setMax NOTIFY maxChanged) | |
38 |
|
38 | |||
@@ -53,12 +53,12 public: | |||||
53 | QDateTime max() const; |
|
53 | QDateTime max() const; | |
54 | void setRange(QDateTime min, QDateTime max); |
|
54 | void setRange(QDateTime min, QDateTime max); | |
55 |
|
55 | |||
56 |
void setFormat |
|
56 | void setFormat(QString format); | |
57 |
QString format |
|
57 | QString format() const; | |
58 |
|
58 | |||
59 | //ticks handling |
|
59 | //ticks handling | |
60 |
void setTick |
|
60 | void setTickCount(int count); | |
61 |
int tick |
|
61 | int tickCount() const; | |
62 |
|
62 | |||
63 | Q_SIGNALS: |
|
63 | Q_SIGNALS: | |
64 | void minChanged(QDateTime min); |
|
64 | void minChanged(QDateTime min); |
@@ -49,13 +49,13 class QDateTimeAxisPrivate : public QAbstractAxisPrivate | |||||
49 | void handleDomainUpdated(); |
|
49 | void handleDomainUpdated(); | |
50 | qreal min(){ return m_min.toMSecsSinceEpoch(); } |
|
50 | qreal min(){ return m_min.toMSecsSinceEpoch(); } | |
51 | qreal max(){ return m_max.toMSecsSinceEpoch(); } |
|
51 | qreal max(){ return m_max.toMSecsSinceEpoch(); } | |
52 |
int count() const { /*TODO:*/ return 0;} |
|
52 | int count() const { /*TODO:*/ return 0;} | |
53 |
|
53 | |||
54 | protected: |
|
54 | protected: | |
55 | void setMin(const QVariant &min); |
|
55 | void setMin(const QVariant &min); | |
56 | void setMax(const QVariant &max); |
|
56 | void setMax(const QVariant &max); | |
57 | void setRange(const QVariant &min, const QVariant &max); |
|
57 | void setRange(const QVariant &min, const QVariant &max); | |
58 |
int tick |
|
58 | int tickCount() const; | |
59 |
|
59 | |||
60 | protected: |
|
60 | protected: | |
61 | QDateTime m_min; |
|
61 | QDateTime m_min; |
General Comments 0
You need to be logged in to leave comments.
Login now