@@ -35,15 +35,16 QBoxSet* BoxDataReader::readBox() | |||||
35 |
|
35 | |||
36 | QStringList strList = line.split(" ", QString::SkipEmptyParts); |
|
36 | QStringList strList = line.split(" ", QString::SkipEmptyParts); | |
37 | sortedList.clear(); |
|
37 | sortedList.clear(); | |
38 | foreach (QString str, strList) { |
|
38 | ||
39 | sortedList.append(str.toDouble()); |
|
39 | for (int i = 1; i < strList.count(); i++) { | |
|
40 | sortedList.append(strList.at(i).toDouble()); | |||
40 | } |
|
41 | } | |
41 |
|
42 | |||
42 | qSort(sortedList.begin(), sortedList.end()); |
|
43 | qSort(sortedList.begin(), sortedList.end()); | |
43 |
|
44 | |||
44 | int count = sortedList.count(); |
|
45 | int count = sortedList.count(); | |
45 |
|
46 | |||
46 | QBoxSet *box = new QBoxSet(); |
|
47 | QBoxSet *box = new QBoxSet(strList.first()); | |
47 | box->setLowerExtreme(sortedList.first()); |
|
48 | box->setLowerExtreme(sortedList.first()); | |
48 | box->setUpperExtreme(sortedList.last()); |
|
49 | box->setUpperExtreme(sortedList.last()); | |
49 | box->setMedian(findMedian(0, count)); |
|
50 | box->setMedian(findMedian(0, count)); |
@@ -1,8 +1,8 | |||||
1 | 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 |
|
1 | Jan 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 | |
2 | #0 1 2 3 4 5 6 7 8 9 |
|
2 | #0 1 2 3 4 5 6 7 8 9 | |
3 | 4.3 5.1 3.9 4.5 4.4 4.9 5.0 4.7 4.1 4.6 4.4 4.3 4.8 4.4 4.2 4.5 4.4 |
|
3 | Feb 4.3 5.1 3.9 4.5 4.4 4.9 5.0 4.7 4.1 4.6 4.4 4.3 4.8 4.4 4.2 4.5 4.4 | |
4 | 1.0 1.2 2.0 2.4 2.5 3.0 3.5 3.7 4.0 4.7 5.0 |
|
4 | Mar 1.0 1.2 2.0 2.4 2.5 3.0 3.5 3.7 4.0 4.7 5.0 | |
5 | 4.6 4.7 5.2 7.3 8.4 8.8 9.1 8.3 7.4 6.4 5.3 |
|
5 | Apr 4.6 4.7 5.2 7.3 8.4 8.8 9.1 8.3 7.4 6.4 5.3 | |
6 | 3.5 7.2 5.4 6.3 7.4 8.3 8.8 3.3 5.4 5.7 3.9 |
|
6 | May 3.5 7.2 5.4 6.3 7.4 8.3 8.8 3.3 5.4 5.7 3.9 | |
7 | #0 1 2 3 4 5 6 7 8 9 10 |
|
7 | #0 1 2 3 4 5 6 7 8 9 10 | |
8 | # * * * |
|
8 | # * * * |
@@ -320,8 +320,13 void QBoxPlotSeriesPrivate::populateCategories(QBarCategoryAxis *axis) | |||||
320 | { |
|
320 | { | |
321 | QStringList categories; |
|
321 | QStringList categories; | |
322 | if (axis->categories().isEmpty()) { |
|
322 | if (axis->categories().isEmpty()) { | |
323 | for (int i(1); i < m_boxSets.count() + 1; i++) |
|
323 | for (int i(1); i < m_boxSets.count() + 1; i++) { | |
324 | categories << QString::number(i); |
|
324 | QBoxSet *set = m_boxSets.at(i - 1); | |
|
325 | if (set->label().isEmpty()) | |||
|
326 | categories << QString::number(i); | |||
|
327 | else | |||
|
328 | categories << set->label(); | |||
|
329 | } | |||
325 | axis->append(categories); |
|
330 | axis->append(categories); | |
326 | } |
|
331 | } | |
327 | } |
|
332 | } |
@@ -29,15 +29,15 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
29 | /*! |
|
29 | /*! | |
30 | Constructs QBoxSet with parent of \a parent |
|
30 | Constructs QBoxSet with parent of \a parent | |
31 | */ |
|
31 | */ | |
32 | QBoxSet::QBoxSet(QObject *parent) |
|
32 | QBoxSet::QBoxSet(const QString label, QObject *parent) | |
33 | : QObject(parent), |
|
33 | : QObject(parent), | |
34 | d_ptr(new QBoxSetPrivate(this)) |
|
34 | d_ptr(new QBoxSetPrivate(label, this)) | |
35 | { |
|
35 | { | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | QBoxSet::QBoxSet(qreal value1, qreal value2, qreal value3, qreal value4, qreal value5, QObject *parent) |
|
38 | QBoxSet::QBoxSet(qreal value1, qreal value2, qreal value3, qreal value4, qreal value5, const QString label, QObject *parent) | |
39 | : QObject(parent), |
|
39 | : QObject(parent), | |
40 | d_ptr(new QBoxSetPrivate(this)) |
|
40 | d_ptr(new QBoxSetPrivate(label, this)) | |
41 | { |
|
41 | { | |
42 | d_ptr->append(value1); |
|
42 | d_ptr->append(value1); | |
43 | d_ptr->append(value2); |
|
43 | d_ptr->append(value2); | |
@@ -168,6 +168,22 qreal QBoxSet::upperExtreme() | |||||
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | /*! |
|
170 | /*! | |
|
171 | Sets new \a label for set. | |||
|
172 | */ | |||
|
173 | void QBoxSet::setLabel(const QString label) | |||
|
174 | { | |||
|
175 | d_ptr->m_label = label; | |||
|
176 | } | |||
|
177 | ||||
|
178 | /*! | |||
|
179 | Returns label of the set. | |||
|
180 | */ | |||
|
181 | QString QBoxSet::label() const | |||
|
182 | { | |||
|
183 | return d_ptr->m_label; | |||
|
184 | } | |||
|
185 | ||||
|
186 | /*! | |||
171 | Convenience operator. Same as append, with real \a value. |
|
187 | Convenience operator. Same as append, with real \a value. | |
172 | \sa append() |
|
188 | \sa append() | |
173 | */ |
|
189 | */ | |
@@ -318,8 +334,9 void QBoxSet::setBorderColor(QColor color) | |||||
318 |
|
334 | |||
319 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
335 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
320 |
|
336 | |||
321 | QBoxSetPrivate::QBoxSetPrivate(QBoxSet *parent) : QObject(parent), |
|
337 | QBoxSetPrivate::QBoxSetPrivate(const QString label, QBoxSet *parent) : QObject(parent), | |
322 | q_ptr(parent), |
|
338 | q_ptr(parent), | |
|
339 | m_label(label), | |||
323 | m_valuesCount(5), |
|
340 | m_valuesCount(5), | |
324 | m_appendCount(0), |
|
341 | m_appendCount(0), | |
325 | m_pen(QPen(Qt::NoPen)), |
|
342 | m_pen(QPen(Qt::NoPen)), |
@@ -38,8 +38,8 class QTCOMMERCIALCHART_EXPORT QBoxSet : public QObject | |||||
38 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) |
|
38 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) | |
39 |
|
39 | |||
40 | public: |
|
40 | public: | |
41 | explicit QBoxSet(QObject *parent = 0); |
|
41 | explicit QBoxSet(const QString label = "", QObject *parent = 0); | |
42 | explicit QBoxSet(qreal value1, qreal value2, qreal value3, qreal value4, qreal value5, QObject *parent = 0); |
|
42 | explicit QBoxSet(const qreal value1, const qreal value2, const qreal value3, const qreal value4, const qreal value5, const QString label = "", QObject *parent = 0); | |
43 | virtual ~QBoxSet(); |
|
43 | virtual ~QBoxSet(); | |
44 |
|
44 | |||
45 | void append(const qreal value); |
|
45 | void append(const qreal value); | |
@@ -56,6 +56,9 public: | |||||
56 | void setUpperExtreme(const qreal value); |
|
56 | void setUpperExtreme(const qreal value); | |
57 | qreal upperExtreme(); |
|
57 | qreal upperExtreme(); | |
58 |
|
58 | |||
|
59 | void setLabel(const QString label); | |||
|
60 | QString label() const; | |||
|
61 | ||||
59 | QBoxSet &operator << (const qreal &value); |
|
62 | QBoxSet &operator << (const qreal &value); | |
60 |
|
63 | |||
61 | void insert(const int index, const qreal value); |
|
64 | void insert(const int index, const qreal value); |
@@ -52,7 +52,7 public: | |||||
52 | }; |
|
52 | }; | |
53 |
|
53 | |||
54 | public: |
|
54 | public: | |
55 | QBoxSetPrivate(QBoxSet *parent); |
|
55 | QBoxSetPrivate(const QString label, QBoxSet *parent); | |
56 | ~QBoxSetPrivate(); |
|
56 | ~QBoxSetPrivate(); | |
57 |
|
57 | |||
58 | void append(qreal value); |
|
58 | void append(qreal value); | |
@@ -72,7 +72,7 Q_SIGNALS: | |||||
72 |
|
72 | |||
73 | public: |
|
73 | public: | |
74 | QBoxSet * const q_ptr; |
|
74 | QBoxSet * const q_ptr; | |
75 |
|
|
75 | QString m_label; | |
76 | //QList<qreal> m_values; |
|
76 | //QList<qreal> m_values; | |
77 | const int m_valuesCount; |
|
77 | const int m_valuesCount; | |
78 | qreal *m_values; |
|
78 | qreal *m_values; |
General Comments 0
You need to be logged in to leave comments.
Login now