##// END OF EJS Templates
Some interval axis docs updates
Marek Rosa -
r1800:0d55302d18fc
parent child
Show More
@@ -1,89 +1,90
1 1 /*!
2 2 \page classes.html
3 3 \title QtCommercial Charts API
4 4 \keyword All Classes
5 5
6 6 Charts API is build on top of Qt Graphics View Framework. Charts can be displayed as QGraphicsWidget using QChart class. However
7 7 there is also convenience class QChartView which is QWidget based. These lets quickly use QCharts as normal Qt widget.
8 8
9 9 Each chart type is represented by QAbstractSeries derived class. To create given chart type users have to use instance of related series class and add it to QChart instance.
10 10 \code
11 11 QLineSeries* series = new QLineSeries();
12 12 series->add(0, 6);
13 13 series->add(2, 4);
14 14 ...
15 15 chartView->chart()->addSeries(series);
16 16 chartView->chart()->createDefaultAxes();
17 17 \endcode
18 18
19 19 \raw HTML
20 20 <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable">
21 21 <tr>
22 22 <th class="titleheader" width="25%">
23 23 Common and global
24 24 </th>
25 25 <th class="titleheader" width="25%">
26 26 XY chart
27 27 </th>
28 28 </tr>
29 29 <tr>
30 30 <td valign="top">
31 31 <ul>
32 32 <li><a href="qchart.html">QChart</a></li>
33 33 <li><a href="qchartview.html">QChartView</a></li>
34 34 <li><a href="qabstractaxis.html">QAbstractAxis</a></li>
35 35 <li><a href="qvaluesaxis.html">QValuesAxis</a></li>
36 36 <li><a href="qbarcategoriesaxis.html">QBarCategoriesAxis</a></li>
37 <li><a href="qintervalsaxis.html">QIntervalsAxis</a></li>
37 38 <li><a href="qlegend.html">QLegend</a></li>
38 39 <li><a href="qabstractseries.html">QAbstractSeries</a></li>
39 40 <li><a href="qchartglobal.html">QChartGlobal</a></li>
40 41 </ul>
41 42 </td>
42 43 <td valign="top">
43 44 <ul>
44 45 <li><a href="qxyseries.html">QXYSeries</a></li>
45 46 <li><a href="qlineseries.html">QLineSeries</a></li>
46 47 <li><a href="qareaseries.html">QAreaSeries</a></li>
47 48 <li><a href="qscatterseries.html">QScatterSeries</a></li>
48 49 <li><a href="qsplineseries.html">QSplineSeries</a></li>
49 50 <li><a href="qhxymodelmapper.html">QHXYModelMapper</a></li>
50 51 <li><a href="qvxymodelmapper.html">QVXYModelMapper</a></li>
51 52 </ul>
52 53 </td>
53 54 </tr>
54 55 </table>
55 56 <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable">
56 57 <tr>
57 58 <th class="titleheader" width="25%">
58 59 Pie chart
59 60 </th>
60 61 <th class="titleheader" width="25%">
61 62 Bar chart
62 63 </th>
63 64 <tr>
64 65 <td valign="top">
65 66 <ul>
66 67 <li><a href="qpieseries.html">QPieSeries</a></li>
67 68 <li><a href="qpieslice.html">QPieSlice</a></li>
68 69 <li><a href="qhpiemodelmapper.html">QHPieModelMapper</a></li>
69 70 <li><a href="qvpiemodelmapper.html">QVPieModelMapper</a></li>
70 71 </ul>
71 72 </td>
72 73 <td valign="top">
73 74 <ul>
74 75 <li><a href="qbarseries.html">QBarSeries</a></li>
75 76 <li><a href="qbarset.html">QBarSet</a></li>
76 77 <li><a href="qpercentbarseries.html">QPercentBarSeries</a></li>
77 78 <li><a href="qstackedbarseries.html">QStackedBarSeries</a></li>
78 79 <li><a href="qhbarmodelmapper.html">QHBarModelMapper</a></li>
79 80 <li><a href="qvbarmodelmapper.html">QVBarModelMapper</a></li>
80 81 <li><a href="qhorizontalbarseries.html">QHorizontalBarSeries</a></li>
81 82 <li><a href="qhorizontalstackedbarseries.html">QHorizontalStackedBarSeries</a></li>
82 83 <li><a href="qhorizontalpercentbarseries.html">QHorizontalPercentBarSeries</a></li>
83 84 </ul>
84 85 </td>
85 86 </tr>
86 87 </table>
87 88 \endraw
88 89
89 90 */
@@ -1,245 +1,249
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 "qintervalsaxis.h"
22 22 #include "qintervalsaxis_p.h"
23 23 #include "chartintervalsaxisx_p.h"
24 24 #include "chartintervalsaxisy_p.h"
25 25 #include <qmath.h>
26 26 #include <QDebug>
27 27
28 28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 29 /*!
30 \internal
31 30 \class QIntervalsAxis
32 31 \brief The QIntervalsAxis class is used for manipulating chart's axis.
33 32 \mainclass
34
35 Axis can be setup to show axis line with tick marks, grid lines and shades.
36 33 */
37 34
38 35 /*!
39 36 \qmlclass Axis QIntervalsAxis
40 37 \brief The Axis element is used for manipulating chart's axes.
41 38
42 39 Axis can be setup to show axis line with tick marks, grid lines and shades.
43 40
44 41 To access Axes you can use ChartView API. For example:
45 42 \code
46 43 // TODO :)
47 44 \endcode
48 45 */
49 46
50 47 /*!
51 48 Constructs an axis object which is a child of \a parent.
52 49 */
53 50 QIntervalsAxis::QIntervalsAxis(QObject *parent):
54 51 QValuesAxis(*new QIntervalsAxisPrivate(this),parent)
55 52 {
56 53 }
57 54
58 55 /*!
59 56 Destroys the object
60 57 */
61 58 QIntervalsAxis::~QIntervalsAxis()
62 59 {
63 60 // Q_D(QValuesAxis);
64 61 // if(d->m_dataset) {
65 62 // d->m_dataset->removeAxis(this);
66 63 // }
67 64 }
68 65
69 66 /*!
70 67 \internal
71 68 */
72 69 QIntervalsAxis::QIntervalsAxis(QIntervalsAxisPrivate &d,QObject *parent):QValuesAxis(d,parent)
73 70 {
74 71
75 72 }
76 73
77 74 /*!
78 75 Appends new interval to the axis with an \a intervalLabel.
79 76 Interval label has to be unique.
80 Parameter \a interval specifies the high end limit of the interval.
77 Parameter \a intervalEnd specifies the high end limit of the interval.
81 78 It has to be greater than the high end limit of the previous interval.
82 79 Otherwise the method returns without adding a new interval.
83 80 */
84 81 void QIntervalsAxis::append(const QString& intervalLabel, qreal intervalEnd)
85 82 {
86 83 Q_D(QIntervalsAxis);
87 84
88 85 if (!d->m_intervals.contains(intervalLabel))
89 86 {
90 87 if(d->m_intervals.isEmpty()){
91 88 Range range(d->m_categoryMinimum, intervalEnd);
92 89 d->m_intervalsMap.insert(intervalLabel, range);
93 90 d->m_intervals.append(intervalLabel);
94 91 }else if (intervalEnd > intervalMax(d->m_intervals.last())){
95 92 Range range = d->m_intervalsMap.value(d->m_intervals.last());
96 93 d->m_intervalsMap.insert(intervalLabel, Range(range.second, intervalEnd));
97 94 d->m_intervals.append(intervalLabel);
98 95 }
99 96 }
100 97 }
101 98
102 99 /*!
103 100 Sets to \a min the low end limit of the first interval on the axis.
104 101 */
105 102 void QIntervalsAxis::setFisrtIntervalMinimum(qreal min)
106 103 {
107 104 Q_D(QIntervalsAxis);
108 105 if(d->m_intervals.isEmpty()){
109 106 d->m_categoryMinimum = min;
110 107 }else{
111 108 Range range = d->m_intervalsMap.value(d->m_intervals.first());
112 109 d->m_intervalsMap.insert(d->m_intervals.first(), Range(min, range.second));
113 110 }
114 111 }
115 112
116 113 /*!
117 114 Returns the low end limit of the interval specified by an \a intervalLabel
118 115 */
119 116 qreal QIntervalsAxis::intervalMin(const QString& intervalLabel) const
120 117 {
121 118 Q_D(const QIntervalsAxis);
122 119 return d->m_intervalsMap.value(intervalLabel).first;
123 120 }
124 121
125 122 /*!
126 123 Returns the high end limit of the interval specified by an \a intervalLabel
127 124 */
128 125 qreal QIntervalsAxis::intervalMax(const QString& intervalLabel) const
129 126 {
130 127 Q_D(const QIntervalsAxis);
131 128 return d->m_intervalsMap.value(intervalLabel).second;
132 129 }
133 130
134 131 /*!
135 Removes \a interval from axis
132 Removes an interval specified by the \a intervalLabel from the axis
136 133 */
137 134 void QIntervalsAxis::remove(const QString &intervalLabel)
138 135 {
139 136 Q_D(QIntervalsAxis);
140 137 int labelIndex = d->m_intervals.indexOf(intervalLabel);
141 138
142 139 // check if such label exists
143 140 if (labelIndex != -1) {
144 141 d->m_intervals.removeAt(labelIndex);
145 142 d->m_intervalsMap.remove(intervalLabel);
146 143
147 144 // the range of the interval that follows (if exists) needs to be updated
148 145 if (labelIndex < d->m_intervals.count()) {
149 146 QString label = d->m_intervals.at(labelIndex);
150 147 Range range = d->m_intervalsMap.value(label);
151 148
152 149 // set the range
153 150 if (labelIndex == 0) {
154 151 range.first = d->m_categoryMinimum;
155 152 d->m_intervalsMap.insert(label, range);
156 153 } else {
157 154 range.first = d->m_intervalsMap.value(d->m_intervals.at(labelIndex - 1)).second;
158 155 d->m_intervalsMap.insert(label, range);
159 156 }
160 157 }
161 158 d->emitUpdated();
162 159 }
163 160 }
164 161
162 /*!
163 Replaces \a oldLabel of an existing interval with a \a newLabel
164 If the old label does not exist the method returns without making any changes.
165 */
165 166 void QIntervalsAxis::replaceLabel(const QString& oldLabel, const QString& newLabel)
166 167 {
167 168 Q_D(QIntervalsAxis);
168 169 int labelIndex = d->m_intervals.indexOf(oldLabel);
169 170
170 171 // check if such label exists
171 172 if (labelIndex != -1) {
172 173 d->m_intervals.replace(labelIndex, newLabel);
173 174 Range range = d->m_intervalsMap.value(oldLabel);
174 175 d->m_intervalsMap.remove(oldLabel);
175 176 d->m_intervalsMap.insert(newLabel, range);
176 177 d->emitUpdated();
177 178 }
178 179
179 180 }
180 181
182 /*!
183 Returns the list of the intervals labels
184 */
181 185 QStringList QIntervalsAxis::intervalsLabels()
182 186 {
183 187 Q_D(QIntervalsAxis);
184 188 return d->m_intervals;
185 189 }
186 190
187 191 /*!
188 192 Returns number of intervals.
189 193 */
190 194 int QIntervalsAxis::count() const
191 195 {
192 196 Q_D(const QIntervalsAxis);
193 197 return d->m_intervals.count();
194 198 }
195 199
196 200 /*!
197 201 Returns the type of the axis
198 202 */
199 203 QAbstractAxis::AxisType QIntervalsAxis::type() const
200 204 {
201 205 return QAbstractAxis::AxisTypeIntervals;
202 206 }
203 207
204 208 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
205 209
206 210 QIntervalsAxisPrivate::QIntervalsAxisPrivate(QIntervalsAxis* q):
207 211 QValuesAxisPrivate(q),
208 212 m_categoryMinimum(0)
209 213 {
210 214
211 215 }
212 216
213 217 QIntervalsAxisPrivate::~QIntervalsAxisPrivate()
214 218 {
215 219
216 220 }
217 221
218 222 int QIntervalsAxisPrivate::ticksCount() const
219 223 {
220 224 return m_intervals.count() + 1;
221 225 }
222 226
223 227 void QIntervalsAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count)
224 228 {
225 229 Q_UNUSED(count);
226 230 Q_UNUSED(min);
227 231 Q_UNUSED(max);
228 232 //m_min = min;
229 233 //m_max = max;
230 234 }
231 235
232 236 ChartAxis* QIntervalsAxisPrivate::createGraphics(ChartPresenter* presenter)
233 237 {
234 238 Q_Q(QIntervalsAxis);
235 239 if(m_orientation == Qt::Vertical){
236 240 return new ChartIntervalAxisY(q,presenter);
237 241 }else{
238 242 return new ChartIntervalAxisX(q,presenter);
239 243 }
240 244 }
241 245
242 246 #include "moc_qintervalsaxis.cpp"
243 247 #include "moc_qintervalsaxis_p.cpp"
244 248
245 249 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,304 +1,304
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 "../qabstractaxis/tst_qabstractaxis.h"
22 22 #include "qintervalsaxis.h"
23 23 #include <qlineseries.h>
24 24
25 25 class tst_QIntervalsAxis: public tst_QAbstractAxis
26 26 {
27 27 Q_OBJECT
28 28
29 29 public slots:
30 30 void initTestCase();
31 31 void cleanupTestCase();
32 32 void init();
33 33 void cleanup();
34 34
35 35 private slots:
36 36 void qintervalsaxis_data();
37 37 void qintervalsaxis();
38 38
39 39 void max_raw_data();
40 40 void max_raw();
41 41 void max_data();
42 42 void max();
43 43 void max_animation_data();
44 44 void max_animation();
45 45 void min_raw_data();
46 46 void min_raw();
47 47 void min_data();
48 48 void min();
49 49 void min_animation_data();
50 50 void min_animation();
51 51 void range_raw_data();
52 52 void range_raw();
53 53 void range_data();
54 54 void range();
55 55 void range_animation_data();
56 56 void range_animation();
57 57
58 58 void interval_data();
59 59 void interval();
60 60
61 61 private:
62 62 QIntervalsAxis* m_intervalsaxis;
63 63 QLineSeries* m_series;
64 64 };
65 65
66 66 void tst_QIntervalsAxis::initTestCase()
67 67 {
68 68 }
69 69
70 70 void tst_QIntervalsAxis::cleanupTestCase()
71 71 {
72 72 }
73 73
74 74 void tst_QIntervalsAxis::init()
75 75 {
76 76 m_intervalsaxis = new QIntervalsAxis();
77 77 m_series = new QLineSeries();
78 78 *m_series << QPointF(-100, -100) << QPointF(0, 0) << QPointF(100, 100);
79 79 tst_QAbstractAxis::init(m_intervalsaxis, m_series);
80 80 m_chart->addSeries(m_series);
81 81 m_chart->createDefaultAxes();
82 82 }
83 83
84 84 void tst_QIntervalsAxis::cleanup()
85 85 {
86 86 delete m_series;
87 87 delete m_intervalsaxis;
88 88 m_series = 0;
89 89 m_intervalsaxis = 0;
90 90 tst_QAbstractAxis::cleanup();
91 91 }
92 92
93 93 void tst_QIntervalsAxis::qintervalsaxis_data()
94 94 {
95 95 }
96 96
97 97 void tst_QIntervalsAxis::qintervalsaxis()
98 98 {
99 99 qabstractaxis();
100 100
101 101 QVERIFY(qFuzzyIsNull(m_intervalsaxis->max()));
102 102 QVERIFY(qFuzzyIsNull(m_intervalsaxis->min()));
103 103 QCOMPARE(m_intervalsaxis->type(), QAbstractAxis::AxisTypeIntervals);
104 104
105 105 m_chart->setAxisX(m_intervalsaxis, m_series);
106 106 m_view->show();
107 107 QTest::qWaitForWindowShown(m_view);
108 108
109 109 QVERIFY(!qFuzzyIsNull(m_intervalsaxis->max()));
110 110 QVERIFY(!qFuzzyIsNull(m_intervalsaxis->min()));
111 111 }
112 112
113 113 void tst_QIntervalsAxis::max_raw_data()
114 114 {
115 115 QTest::addColumn<qreal>("max");
116 116 QTest::newRow("1.0") << 1.0;
117 117 QTest::newRow("50.0") << 50.0;
118 118 QTest::newRow("101.0") << 101.0;
119 119 }
120 120
121 121 void tst_QIntervalsAxis::max_raw()
122 122 {
123 123 QFETCH(qreal, max);
124 124
125 125 QSignalSpy spy0(m_intervalsaxis, SIGNAL(maxChanged(qreal)));
126 126 QSignalSpy spy1(m_intervalsaxis, SIGNAL(minChanged(qreal)));
127 127 QSignalSpy spy2(m_intervalsaxis, SIGNAL(rangeChanged(qreal, qreal)));
128 128
129 129 m_intervalsaxis->setMax(max);
130 130 QVERIFY2(qFuzzyIsNull(m_intervalsaxis->max() - max), "Not equal");
131 131
132 132 QCOMPARE(spy0.count(), 1);
133 133 QCOMPARE(spy1.count(), 0);
134 134 QCOMPARE(spy2.count(), 1);
135 135 }
136 136
137 137 void tst_QIntervalsAxis::max_data()
138 138 {
139 139 max_raw_data();
140 140 }
141 141
142 142 void tst_QIntervalsAxis::max()
143 143 {
144 144 m_chart->setAxisX(m_intervalsaxis, m_series);
145 145 m_view->show();
146 146 QTest::qWaitForWindowShown(m_view);
147 147 max_raw();
148 148 }
149 149
150 150 void tst_QIntervalsAxis::max_animation_data()
151 151 {
152 152 max_data();
153 153 }
154 154
155 155 void tst_QIntervalsAxis::max_animation()
156 156 {
157 157 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
158 158 max();
159 159 }
160 160
161 161 void tst_QIntervalsAxis::min_raw_data()
162 162 {
163 163 QTest::addColumn<qreal>("min");
164 164 QTest::newRow("-1.0") << -1.0;
165 165 QTest::newRow("-50.0") << -50.0;
166 166 QTest::newRow("-101.0") << -101.0;
167 167 }
168 168
169 169 void tst_QIntervalsAxis::min_raw()
170 170 {
171 171 QFETCH(qreal, min);
172 172
173 173 QSignalSpy spy0(m_intervalsaxis, SIGNAL(maxChanged(qreal)));
174 174 QSignalSpy spy1(m_intervalsaxis, SIGNAL(minChanged(qreal)));
175 175 QSignalSpy spy2(m_intervalsaxis, SIGNAL(rangeChanged(qreal, qreal)));
176 176
177 177 m_intervalsaxis->setMin(min);
178 178 QVERIFY2(qFuzzyIsNull(m_intervalsaxis->min() - min), "Not equal");
179 179
180 180 QCOMPARE(spy0.count(), 0);
181 181 QCOMPARE(spy1.count(), 1);
182 182 QCOMPARE(spy2.count(), 1);
183 183 }
184 184
185 185 void tst_QIntervalsAxis::min_data()
186 186 {
187 187 min_raw_data();
188 188 }
189 189
190 190 void tst_QIntervalsAxis::min()
191 191 {
192 192 m_chart->setAxisX(m_intervalsaxis, m_series);
193 193 m_view->show();
194 194 QTest::qWaitForWindowShown(m_view);
195 195 min_raw();
196 196 }
197 197
198 198 void tst_QIntervalsAxis::min_animation_data()
199 199 {
200 200 min_data();
201 201 }
202 202
203 203 void tst_QIntervalsAxis::min_animation()
204 204 {
205 205 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
206 206 min();
207 207 }
208 208
209 209 void tst_QIntervalsAxis::range_raw_data()
210 210 {
211 211 QTest::addColumn<qreal>("min");
212 212 QTest::addColumn<qreal>("max");
213 213 QTest::newRow("1.0 - 101.0") << -1.0 << 101.0;
214 214 QTest::newRow("25.0 - 75.0") << 25.0 << 75.0;
215 215 QTest::newRow("101.0") << 40.0 << 60.0;
216 216 }
217 217
218 218 void tst_QIntervalsAxis::range_raw()
219 219 {
220 220 QFETCH(qreal, min);
221 221 QFETCH(qreal, max);
222 222
223 223 QSignalSpy spy0(m_intervalsaxis, SIGNAL(maxChanged(qreal)));
224 224 QSignalSpy spy1(m_intervalsaxis, SIGNAL(minChanged(qreal)));
225 225 QSignalSpy spy2(m_intervalsaxis, SIGNAL(rangeChanged(qreal, qreal)));
226 226
227 227 m_intervalsaxis->setRange(min, max);
228 228 QVERIFY2(qFuzzyIsNull(m_intervalsaxis->min() - min), "Min not equal");
229 229 QVERIFY2(qFuzzyIsNull(m_intervalsaxis->max() - max), "Max not equal");
230 230
231 231 QCOMPARE(spy0.count(), 1);
232 232 QCOMPARE(spy1.count(), 1);
233 233 QCOMPARE(spy2.count(), 1);
234 234 }
235 235
236 236 void tst_QIntervalsAxis::range_data()
237 237 {
238 238 range_raw_data();
239 239 }
240 240
241 241 void tst_QIntervalsAxis::range()
242 242 {
243 243 m_chart->setAxisX(m_intervalsaxis, m_series);
244 244 m_view->show();
245 245 QTest::qWaitForWindowShown(m_view);
246 246 range_raw();
247 247 }
248 248
249 249 void tst_QIntervalsAxis::range_animation_data()
250 250 {
251 251 range_data();
252 252 }
253 253
254 254 void tst_QIntervalsAxis::range_animation()
255 255 {
256 256 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
257 257 range();
258 258 }
259 259
260 260 void tst_QIntervalsAxis::interval_data()
261 261 {
262 262 //
263 263 }
264 264
265 265 void tst_QIntervalsAxis::interval()
266 266 {
267 267 // append one correct interval
268 268 m_intervalsaxis->append("first", (qreal)45);
269 269 QCOMPARE(m_intervalsaxis->intervalMin("first"), (qreal)0);
270 270 QCOMPARE(m_intervalsaxis->intervalMax("first"), (qreal)45);
271 271
272 272 // append one more correct interval
273 273 m_intervalsaxis->append("second", (qreal)75);
274 274 QCOMPARE(m_intervalsaxis->intervalMin("second"), (qreal)45);
275 275 QCOMPARE(m_intervalsaxis->intervalMax("second"), (qreal)75);
276 276
277 277 // append one incorrect interval
278 278 m_intervalsaxis->append("third", (qreal)15);
279 279 QCOMPARE(m_intervalsaxis->count(), 2);
280 280 QCOMPARE(m_intervalsaxis->intervalMax(m_intervalsaxis->intervalsLabels().last()), (qreal)75);
281 281 // QCOMPARE(intervalMax("first"), (qreal)75);
282 282
283 283 // append one more correct interval
284 284 m_intervalsaxis->append("third", (qreal)100);
285 285 QCOMPARE(m_intervalsaxis->count(), 3);
286 286 QCOMPARE(m_intervalsaxis->intervalMin("third"), (qreal)75);
287 287 QCOMPARE(m_intervalsaxis->intervalMax("third"), (qreal)100);
288 288
289 289 // remove one interval
290 290 m_intervalsaxis->remove("first");
291 291 QCOMPARE(m_intervalsaxis->count(), 2);
292 292 QCOMPARE(m_intervalsaxis->intervalMin("second"), (qreal)0); // second interval should extend to firstInterval minimum
293 293 QCOMPARE(m_intervalsaxis->intervalMax("second"), (qreal)75);
294 294
295 295 // remove one interval
296 m_intervalsaxis->replace("second", "replaced");
296 m_intervalsaxis->replaceLabel("second", "replaced");
297 297 QCOMPARE(m_intervalsaxis->count(), 2);
298 298 QCOMPARE(m_intervalsaxis->intervalMin("replaced"), (qreal)0); // second interval should extend to firstInterval minimum
299 299 QCOMPARE(m_intervalsaxis->intervalMax("replaced"), (qreal)75);
300 300 }
301 301
302 302 QTEST_MAIN(tst_QIntervalsAxis)
303 303 #include "tst_qintervalsaxis.moc"
304 304
General Comments 0
You need to be logged in to leave comments. Login now