@@ -1,82 +1,83 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QVALUEAXIS_H |
|
21 | #ifndef QVALUEAXIS_H | |
22 | #define QVALUEAXIS_H |
|
22 | #define QVALUEAXIS_H | |
23 |
|
23 | |||
24 | #include "qabstractaxis.h" |
|
24 | #include "qabstractaxis.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | class QValueAxisPrivate; |
|
28 | class QValueAxisPrivate; | |
29 |
|
29 | |||
30 | class QTCOMMERCIALCHART_EXPORT QValueAxis : public QAbstractAxis |
|
30 | class QTCOMMERCIALCHART_EXPORT QValueAxis : public QAbstractAxis | |
31 | { |
|
31 | { | |
32 | Q_OBJECT |
|
32 | Q_OBJECT | |
33 | Q_PROPERTY(int tickCount READ tickCount WRITE setTickCount NOTIFY tickCountChanged) |
|
33 | Q_PROPERTY(int tickCount READ tickCount WRITE setTickCount NOTIFY tickCountChanged) | |
34 | Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled) |
|
34 | Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled) | |
35 | Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged) |
|
35 | Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged) | |
36 | Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged) |
|
36 | Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged) | |
37 | Q_PROPERTY(QString labelFormat READ labelFormat WRITE setLabelFormat) |
|
37 | Q_PROPERTY(QString labelFormat READ labelFormat WRITE setLabelFormat) | |
38 |
|
38 | |||
39 | public: |
|
39 | public: | |
40 | explicit QValueAxis(QObject *parent = 0); |
|
40 | explicit QValueAxis(QObject *parent = 0); | |
41 | ~QValueAxis(); |
|
41 | ~QValueAxis(); | |
42 |
|
42 | |||
43 | protected: |
|
43 | protected: | |
44 | QValueAxis(QValueAxisPrivate &d, QObject *parent = 0); |
|
44 | QValueAxis(QValueAxisPrivate &d, QObject *parent = 0); | |
45 |
|
45 | |||
46 | public: |
|
46 | public: | |
47 | AxisType type() const; |
|
47 | AxisType type() const; | |
48 |
|
48 | |||
49 | //range handling |
|
49 | //range handling | |
50 | void setMin(qreal min); |
|
50 | void setMin(qreal min); | |
51 | qreal min() const; |
|
51 | qreal min() const; | |
52 | void setMax(qreal max); |
|
52 | void setMax(qreal max); | |
53 | qreal max() const; |
|
53 | qreal max() const; | |
54 | void setRange(qreal min, qreal max); |
|
54 | void setRange(qreal min, qreal max); | |
55 |
|
55 | |||
56 | //ticks handling |
|
56 | //ticks handling | |
57 | void setTickCount(int count); |
|
57 | void setTickCount(int count); | |
58 | int tickCount() const; |
|
58 | int tickCount() const; | |
59 |
|
59 | |||
60 | void setLabelFormat(const QString &format); |
|
60 | void setLabelFormat(const QString &format); | |
61 | QString labelFormat() const; |
|
61 | QString labelFormat() const; | |
62 |
|
62 | |||
63 | void applyNiceNumbers(); |
|
|||
64 |
|
||||
65 | //TODO: depreciated ! |
|
63 | //TODO: depreciated ! | |
66 | void setNiceNumbersEnabled(bool enable = true); |
|
64 | void setNiceNumbersEnabled(bool enable = true); | |
67 | bool niceNumbersEnabled() const; |
|
65 | bool niceNumbersEnabled() const; | |
68 |
|
66 | |||
|
67 | public Q_SLOTS: | |||
|
68 | void applyNiceNumbers(); | |||
|
69 | ||||
69 | Q_SIGNALS: |
|
70 | Q_SIGNALS: | |
70 | void minChanged(qreal min); |
|
71 | void minChanged(qreal min); | |
71 | void maxChanged(qreal max); |
|
72 | void maxChanged(qreal max); | |
72 | void rangeChanged(qreal min, qreal max); |
|
73 | void rangeChanged(qreal min, qreal max); | |
73 | void tickCountChanged(int ticks); |
|
74 | void tickCountChanged(int ticks); | |
74 |
|
75 | |||
75 | private: |
|
76 | private: | |
76 | Q_DECLARE_PRIVATE(QValueAxis) |
|
77 | Q_DECLARE_PRIVATE(QValueAxis) | |
77 | Q_DISABLE_COPY(QValueAxis) |
|
78 | Q_DISABLE_COPY(QValueAxis) | |
78 | }; |
|
79 | }; | |
79 |
|
80 | |||
80 | QTCOMMERCIALCHART_END_NAMESPACE |
|
81 | QTCOMMERCIALCHART_END_NAMESPACE | |
81 |
|
82 | |||
82 | #endif // QVALUEAXIS_H |
|
83 | #endif // QVALUEAXIS_H |
@@ -1,158 +1,160 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtQuickTest 1.0 |
|
22 | import QtQuickTest 1.0 | |
23 | import QtCommercial.Chart 1.2 |
|
23 | import QtCommercial.Chart 1.2 | |
24 |
|
24 | |||
25 | Rectangle { |
|
25 | Rectangle { | |
26 | width: 400 |
|
26 | width: 400 | |
27 | height: 300 |
|
27 | height: 300 | |
28 |
|
28 | |||
29 | TestCase { |
|
29 | TestCase { | |
30 | id: tc1 |
|
30 | id: tc1 | |
31 | name: "tst_qml-qtquicktest ChartView Functions" |
|
31 | name: "tst_qml-qtquicktest ChartView Functions" | |
32 | when: windowShown |
|
32 | when: windowShown | |
33 |
|
33 | |||
34 | function test_chartViewSeriesAndAxes() { |
|
34 | function test_chartViewSeriesAndAxes() { | |
35 | // Create XY series |
|
35 | // Create XY series | |
36 | var line = chartView.createSeries(ChartView.SeriesTypeLine, "line"); |
|
36 | var line = chartView.createSeries(ChartView.SeriesTypeLine, "line"); | |
37 | verify(line != null && line != undefined); |
|
37 | verify(line != null && line != undefined); | |
38 | var spline = chartView.createSeries(ChartView.SeriesTypeSpline, "spline"); |
|
38 | var spline = chartView.createSeries(ChartView.SeriesTypeSpline, "spline"); | |
39 | verify(spline != null && spline != undefined); |
|
39 | verify(spline != null && spline != undefined); | |
40 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter"); |
|
40 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter"); | |
41 | verify(scatter != null && scatter != undefined); |
|
41 | verify(scatter != null && scatter != undefined); | |
42 |
|
42 | |||
43 | // Create a series with specific axes |
|
43 | // Create a series with specific axes | |
44 | var line2 = chartView.createSeries(ChartView.SeriesTypeLine, "line2", chartView.axisX(line), chartView.axisY(line)); |
|
44 | var line2 = chartView.createSeries(ChartView.SeriesTypeLine, "line2", chartView.axisX(line), chartView.axisY(line)); | |
45 |
|
45 | |||
46 | // Check that all the XY series use the same axes |
|
46 | // Check that all the XY series use the same axes | |
47 | verify(chartView.axisX(line) != null); |
|
47 | verify(chartView.axisX(line) != null); | |
48 | verify(chartView.axisY(line) != null); |
|
48 | verify(chartView.axisY(line) != null); | |
49 | compare(chartView.axisX(line), chartView.axisX(line2)); |
|
49 | compare(chartView.axisX(line), chartView.axisX(line2)); | |
50 | compare(chartView.axisY(line), chartView.axisY(line2)); |
|
50 | compare(chartView.axisY(line), chartView.axisY(line2)); | |
51 | compare(chartView.axisX(line), chartView.axisX(spline)); |
|
51 | compare(chartView.axisX(line), chartView.axisX(spline)); | |
52 | compare(chartView.axisY(line), chartView.axisY(spline)); |
|
52 | compare(chartView.axisY(line), chartView.axisY(spline)); | |
53 | compare(chartView.axisX(line), chartView.axisX(scatter)); |
|
53 | compare(chartView.axisX(line), chartView.axisX(scatter)); | |
54 | compare(chartView.axisY(line), chartView.axisY(scatter)); |
|
54 | compare(chartView.axisY(line), chartView.axisY(scatter)); | |
55 |
|
55 | |||
56 | var bar = chartView.createSeries(ChartView.SeriesTypeBar, "bar"); |
|
56 | var bar = chartView.createSeries(ChartView.SeriesTypeBar, "bar"); | |
57 | verify(bar != null && bar != undefined); |
|
57 | verify(bar != null && bar != undefined); | |
58 | var stackedbar = chartView.createSeries(ChartView.SeriesTypeStackedBar, "stackedbar"); |
|
58 | var stackedbar = chartView.createSeries(ChartView.SeriesTypeStackedBar, "stackedbar"); | |
59 | verify(stackedbar != null && stackedbar != undefined); |
|
59 | verify(stackedbar != null && stackedbar != undefined); | |
60 | var percentbar = chartView.createSeries(ChartView.SeriesTypePercentBar, "percentbar"); |
|
60 | var percentbar = chartView.createSeries(ChartView.SeriesTypePercentBar, "percentbar"); | |
61 | verify(percentbar != null && percentbar != undefined); |
|
61 | verify(percentbar != null && percentbar != undefined); | |
62 | var horizontalbar = chartView.createSeries(ChartView.SeriesTypeHorizontalBar, "horizontalbar"); |
|
62 | var horizontalbar = chartView.createSeries(ChartView.SeriesTypeHorizontalBar, "horizontalbar"); | |
63 | verify(horizontalbar != null && horizontalbar != undefined); |
|
63 | verify(horizontalbar != null && horizontalbar != undefined); | |
64 | var horizontalstackedbar = chartView.createSeries(ChartView.SeriesTypeHorizontalStackedBar, "horizontalstackedbar"); |
|
64 | var horizontalstackedbar = chartView.createSeries(ChartView.SeriesTypeHorizontalStackedBar, "horizontalstackedbar"); | |
65 | verify(horizontalstackedbar != null && horizontalstackedbar != undefined); |
|
65 | verify(horizontalstackedbar != null && horizontalstackedbar != undefined); | |
66 | var horizontalpercentbar = chartView.createSeries(ChartView.SeriesTypeHorizontalPercentBar, "horizontalpercentbar"); |
|
66 | var horizontalpercentbar = chartView.createSeries(ChartView.SeriesTypeHorizontalPercentBar, "horizontalpercentbar"); | |
67 | verify(horizontalpercentbar != null && horizontalpercentbar != undefined); |
|
67 | verify(horizontalpercentbar != null && horizontalpercentbar != undefined); | |
68 | var area = chartView.createSeries(ChartView.SeriesTypeArea, "area"); |
|
68 | var area = chartView.createSeries(ChartView.SeriesTypeArea, "area"); | |
69 | verify(area != null && area != undefined); |
|
69 | verify(area != null && area != undefined); | |
70 |
|
70 | |||
71 | // Remove all series |
|
71 | // Remove all series | |
72 | chartView.removeAllSeries(); |
|
72 | chartView.removeAllSeries(); | |
73 | compare(chartView.count, 0); |
|
73 | compare(chartView.count, 0); | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | function test_chartViewRange() { |
|
76 | function test_chartViewRange() { | |
77 | // Set initial values |
|
77 | // Set initial values | |
78 | chartView.createSeries(ChartView.SeriesTypeLine, "line"); |
|
78 | chartView.createSeries(ChartView.SeriesTypeLine, "line"); | |
79 | verify(chartView.axisX() != null); |
|
79 | verify(chartView.axisX() != null); | |
80 | verify(chartView.axisY() != null); |
|
80 | verify(chartView.axisY() != null); | |
81 | chartView.axisX().min = 1.0; |
|
81 | chartView.axisX().min = 1.0; | |
82 | chartView.axisX().max = 2.0; |
|
82 | chartView.axisX().max = 2.0; | |
83 | chartView.axisY().min = 1.0; |
|
83 | chartView.axisY().min = 1.0; | |
84 | chartView.axisY().max = 2.0; |
|
84 | chartView.axisY().max = 2.0; | |
85 |
|
85 | |||
86 | var xMax = chartView.axisX().max; |
|
86 | var xMax = chartView.axisX().max; | |
87 | var xMin = chartView.axisX().min; |
|
87 | var xMin = chartView.axisX().min; | |
88 | var yMax = chartView.axisY().max; |
|
88 | var yMax = chartView.axisY().max; | |
89 | var yMin = chartView.axisY().min; |
|
89 | var yMin = chartView.axisY().min; | |
90 |
|
90 | |||
91 | // zoom x 2.5 |
|
91 | // zoom x 2.5 | |
92 | chartView.zoom(1.5); |
|
92 | chartView.zoom(1.5); | |
93 | verify(chartView.axisX().max < xMax); |
|
93 | verify(chartView.axisX().max < xMax); | |
94 | verify(chartView.axisX().min > xMin); |
|
94 | verify(chartView.axisX().min > xMin); | |
95 | verify(chartView.axisY().max < yMax); |
|
95 | verify(chartView.axisY().max < yMax); | |
96 | verify(chartView.axisY().min > yMin); |
|
96 | verify(chartView.axisY().min > yMin); | |
97 | xMax = chartView.axisX().max; |
|
97 | xMax = chartView.axisX().max; | |
98 | xMin = chartView.axisX().min; |
|
98 | xMin = chartView.axisX().min; | |
99 | yMax = chartView.axisY().max; |
|
99 | yMax = chartView.axisY().max; | |
100 | yMin = chartView.axisY().min; |
|
100 | yMin = chartView.axisY().min; | |
101 |
|
101 | |||
102 | // zoom x 0.5 |
|
102 | // zoom x 0.5 | |
103 | chartView.zoom(0.5); |
|
103 | chartView.zoom(0.5); | |
104 | verify(chartView.axisX().max > xMax); |
|
104 | verify(chartView.axisX().max > xMax); | |
105 | verify(chartView.axisX().min < xMin); |
|
105 | verify(chartView.axisX().min < xMin); | |
106 | verify(chartView.axisY().max > yMax); |
|
106 | verify(chartView.axisY().max > yMax); | |
107 | verify(chartView.axisY().min < yMin); |
|
107 | verify(chartView.axisY().min < yMin); | |
108 | xMax = chartView.axisX().max; |
|
108 | xMax = chartView.axisX().max; | |
109 | xMin = chartView.axisX().min; |
|
109 | xMin = chartView.axisX().min; | |
110 | yMax = chartView.axisY().max; |
|
110 | yMax = chartView.axisY().max; | |
111 | yMin = chartView.axisY().min; |
|
111 | yMin = chartView.axisY().min; | |
112 |
|
112 | |||
113 | // Scroll up |
|
113 | // Scroll up | |
114 | chartView.scrollUp(10); |
|
114 | chartView.scrollUp(10); | |
115 | compare(chartView.axisX().max, xMax); |
|
115 | compare(chartView.axisX().max, xMax); | |
116 | compare(chartView.axisX().min, xMin); |
|
116 | compare(chartView.axisX().min, xMin); | |
117 | verify(chartView.axisY().max > yMax); |
|
117 | verify(chartView.axisY().max > yMax); | |
118 | verify(chartView.axisY().min > yMin); |
|
118 | verify(chartView.axisY().min > yMin); | |
119 | xMax = chartView.axisX().max; |
|
119 | xMax = chartView.axisX().max; | |
120 | xMin = chartView.axisX().min; |
|
120 | xMin = chartView.axisX().min; | |
121 | yMax = chartView.axisY().max; |
|
121 | yMax = chartView.axisY().max; | |
122 | yMin = chartView.axisY().min; |
|
122 | yMin = chartView.axisY().min; | |
123 |
|
123 | |||
124 | // Scroll down |
|
124 | // Scroll down | |
125 | chartView.scrollDown(10); |
|
125 | chartView.scrollDown(10); | |
126 | compare(chartView.axisX().max, xMax); |
|
126 | compare(chartView.axisX().max, xMax); | |
127 | compare(chartView.axisX().min, xMin); |
|
127 | compare(chartView.axisX().min, xMin); | |
128 | verify(chartView.axisY().max < yMax); |
|
128 | verify(chartView.axisY().max < yMax); | |
129 | verify(chartView.axisY().min < yMin); |
|
129 | verify(chartView.axisY().min < yMin); | |
130 | xMax = chartView.axisX().max; |
|
130 | xMax = chartView.axisX().max; | |
131 | xMin = chartView.axisX().min; |
|
131 | xMin = chartView.axisX().min; | |
132 | yMax = chartView.axisY().max; |
|
132 | yMax = chartView.axisY().max; | |
133 | yMin = chartView.axisY().min; |
|
133 | yMin = chartView.axisY().min; | |
134 |
|
134 | |||
|
135 | // Scroll left | |||
135 | chartView.scrollLeft(10); |
|
136 | chartView.scrollLeft(10); | |
136 | verify(chartView.axisX().max < xMax); |
|
137 | verify(chartView.axisX().max < xMax); | |
137 | verify(chartView.axisX().min < xMin); |
|
138 | verify(chartView.axisX().min < xMin); | |
138 | compare(chartView.axisY().max, yMax); |
|
139 | compare(chartView.axisY().max, yMax); | |
139 | compare(chartView.axisY().min, yMin); |
|
140 | compare(chartView.axisY().min, yMin); | |
140 | xMax = chartView.axisX().max; |
|
141 | xMax = chartView.axisX().max; | |
141 | xMin = chartView.axisX().min; |
|
142 | xMin = chartView.axisX().min; | |
142 | yMax = chartView.axisY().max; |
|
143 | yMax = chartView.axisY().max; | |
143 | yMin = chartView.axisY().min; |
|
144 | yMin = chartView.axisY().min; | |
144 |
|
145 | |||
|
146 | // Scroll right | |||
145 | chartView.scrollRight(10); |
|
147 | chartView.scrollRight(10); | |
146 | verify(chartView.axisX().max > xMax); |
|
148 | verify(chartView.axisX().max > xMax); | |
147 | verify(chartView.axisX().min > xMin); |
|
149 | verify(chartView.axisX().min > xMin); | |
148 | compare(chartView.axisY().max, yMax); |
|
150 | compare(chartView.axisY().max, yMax); | |
149 | compare(chartView.axisY().min, yMin); |
|
151 | compare(chartView.axisY().min, yMin); | |
150 | } |
|
152 | } | |
151 | } |
|
153 | } | |
152 |
|
154 | |||
153 | ChartView { |
|
155 | ChartView { | |
154 | id: chartView |
|
156 | id: chartView | |
155 | anchors.fill: parent |
|
157 | anchors.fill: parent | |
156 | title: "Chart" |
|
158 | title: "Chart" | |
157 | } |
|
159 | } | |
158 | } |
|
160 | } |
@@ -1,100 +1,117 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtQuickTest 1.0 |
|
22 | import QtQuickTest 1.0 | |
23 | import QtCommercial.Chart 1.2 |
|
23 | import QtCommercial.Chart 1.2 | |
24 |
|
24 | |||
25 | Rectangle { |
|
25 | Rectangle { | |
26 | width: 400 |
|
26 | width: 400 | |
27 | height: 300 |
|
27 | height: 300 | |
28 |
|
28 | |||
29 | TestCase { |
|
29 | TestCase { | |
30 | id: tc1 |
|
30 | id: tc1 | |
31 | name: "tst_qml-qtquicktest ValueAxis" |
|
31 | name: "tst_qml-qtquicktest ValueAxis" | |
32 | when: windowShown |
|
32 | when: windowShown | |
33 |
|
33 | |||
34 |
function test_ |
|
34 | function test_properties() { | |
|
35 | // Default properties | |||
35 | verify(axisX.min < 0, "AxisX min"); |
|
36 | verify(axisX.min < 0, "AxisX min"); | |
36 | verify(axisX.max > 0, "AxisX max"); |
|
37 | verify(axisX.max > 0, "AxisX max"); | |
37 | verify(axisY.min < 0, "AxisY min"); |
|
38 | verify(axisY.min < 0, "AxisY min"); | |
38 | verify(axisY.max > 0, "AxisY max"); |
|
39 | verify(axisY.max > 0, "AxisY max"); | |
39 | verify(axisX.tickCount > 0, "AxisX tick count"); |
|
40 | verify(axisX.tickCount > 0, "AxisX tick count"); | |
40 | verify(axisY.tickCount > 0, "AxisX tick count"); |
|
41 | verify(axisY.tickCount > 0, "AxisX tick count"); | |
41 | compare(axisX.niceNumbersEnabled, false, "nice numbers"); |
|
42 | compare(axisX.niceNumbersEnabled, false, "nice numbers"); | |
42 | compare(axisX.labelFormat, "", "label format"); |
|
43 | compare(axisX.labelFormat, "", "label format"); | |
43 | } |
|
|||
44 |
|
44 | |||
45 |
|
|
45 | // Modify properties | |
46 | axisX.tickCount = 3; |
|
46 | axisX.tickCount = 3; | |
47 | compare(axisX.tickCount, 3, "set tick count"); |
|
47 | compare(axisX.tickCount, 3, "set tick count"); | |
48 |
|
||||
49 | axisX.niceNumbersEnabled = true; |
|
48 | axisX.niceNumbersEnabled = true; | |
50 | compare(axisX.niceNumbersEnabled, true, "nice numbers"); |
|
49 | compare(axisX.niceNumbersEnabled, true, "nice numbers"); | |
51 | } |
|
50 | } | |
52 |
|
51 | |||
|
52 | function test_functions() { | |||
|
53 | // Set the axis ranges to not "nice" ones... | |||
|
54 | var min = 0.032456456; | |||
|
55 | var max = 10.67845634; | |||
|
56 | axisX.max = min; | |||
|
57 | axisX.max = max; | |||
|
58 | axisY.max = min; | |||
|
59 | axisY.max = max; | |||
|
60 | ||||
|
61 | // ...And then apply nice numbers and verify the range was changed | |||
|
62 | axisX.applyNiceNumbers(); | |||
|
63 | axisY.applyNiceNumbers(); | |||
|
64 | verify(axisX.min != min); | |||
|
65 | verify(axisX.max != max); | |||
|
66 | verify(axisY.min != min); | |||
|
67 | verify(axisY.max != max); | |||
|
68 | } | |||
|
69 | ||||
53 | function test_signals() { |
|
70 | function test_signals() { | |
54 | minChangedSpy.clear(); |
|
71 | minChangedSpy.clear(); | |
55 | maxChangedSpy.clear(); |
|
72 | maxChangedSpy.clear(); | |
56 | axisX.min = 2; |
|
73 | axisX.min = 2; | |
57 | compare(minChangedSpy.count, 1, "onMinChanged"); |
|
74 | compare(minChangedSpy.count, 1, "onMinChanged"); | |
58 | compare(maxChangedSpy.count, 0, "onMaxChanged"); |
|
75 | compare(maxChangedSpy.count, 0, "onMaxChanged"); | |
59 |
|
76 | |||
60 | axisX.max = 8; |
|
77 | axisX.max = 8; | |
61 | compare(minChangedSpy.count, 1, "onMinChanged"); |
|
78 | compare(minChangedSpy.count, 1, "onMinChanged"); | |
62 | compare(maxChangedSpy.count, 1, "onMaxChanged"); |
|
79 | compare(maxChangedSpy.count, 1, "onMaxChanged"); | |
63 |
|
80 | |||
64 | // restore original values |
|
81 | // restore original values | |
65 | axisX.min = 0; |
|
82 | axisX.min = 0; | |
66 | axisX.max = 10; |
|
83 | axisX.max = 10; | |
67 | compare(minChangedSpy.count, 2, "onMinChanged"); |
|
84 | compare(minChangedSpy.count, 2, "onMinChanged"); | |
68 | compare(maxChangedSpy.count, 2, "onMaxChanged"); |
|
85 | compare(maxChangedSpy.count, 2, "onMaxChanged"); | |
69 | } |
|
86 | } | |
70 | } |
|
87 | } | |
71 |
|
88 | |||
72 | ChartView { |
|
89 | ChartView { | |
73 | id: chartView |
|
90 | id: chartView | |
74 | anchors.fill: parent |
|
91 | anchors.fill: parent | |
75 |
|
92 | |||
76 | LineSeries { |
|
93 | LineSeries { | |
77 | id: lineSeries1 |
|
94 | id: lineSeries1 | |
78 | axisX: ValueAxis { |
|
95 | axisX: ValueAxis { | |
79 | id: axisX |
|
96 | id: axisX | |
80 | } |
|
97 | } | |
81 | axisY: ValueAxis { |
|
98 | axisY: ValueAxis { | |
82 | id: axisY |
|
99 | id: axisY | |
83 | } |
|
100 | } | |
84 | XYPoint { x: -1; y: -1 } |
|
101 | XYPoint { x: -1; y: -1 } | |
85 | XYPoint { x: 0; y: 0 } |
|
102 | XYPoint { x: 0; y: 0 } | |
86 | XYPoint { x: 5; y: 5 } |
|
103 | XYPoint { x: 5; y: 5 } | |
87 | } |
|
104 | } | |
88 |
|
105 | |||
89 | SignalSpy { |
|
106 | SignalSpy { | |
90 | id: minChangedSpy |
|
107 | id: minChangedSpy | |
91 | target: axisX |
|
108 | target: axisX | |
92 | signalName: "minChanged" |
|
109 | signalName: "minChanged" | |
93 | } |
|
110 | } | |
94 | SignalSpy { |
|
111 | SignalSpy { | |
95 | id: maxChangedSpy |
|
112 | id: maxChangedSpy | |
96 | target: axisX |
|
113 | target: axisX | |
97 | signalName: "maxChanged" |
|
114 | signalName: "maxChanged" | |
98 | } |
|
115 | } | |
99 | } |
|
116 | } | |
100 | } |
|
117 | } |
General Comments 0
You need to be logged in to leave comments.
Login now