@@ -20,6 +20,7 | |||
|
20 | 20 | <li><a href="qml-chartview.html">ChartView</a></li> |
|
21 | 21 | <li><a href="qml-axis.html">Axis</a></li> |
|
22 | 22 | <li><a href="qml-legend.html">Legend</a></li> |
|
23 | <li><a href="qml-abstractseries.html">AbstractSeries</a></li> | |
|
23 | 24 | </ul> |
|
24 | 25 | </td> |
|
25 | 26 | </tr> |
@@ -31,6 +32,7 | |||
|
31 | 32 | <tr> |
|
32 | 33 | <td valign="top"> |
|
33 | 34 | <ul> |
|
35 | <li><a href="qml-xyseries.html">XYSeries</a></li> | |
|
34 | 36 | <li><a href="qml-lineseries.html">LineSeries</a></li> |
|
35 | 37 | <li><a href="qml-areaseries.html">AreaSeries</a></li> |
|
36 | 38 | <li><a href="qml-scatterseries.html">ScatterSeries</a></li> |
@@ -126,10 +126,16 DeclarativeBarSet *DeclarativeBarSeries::at(int index) | |||
|
126 | 126 | |
|
127 | 127 | DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values) |
|
128 | 128 | { |
|
129 | int insertIndex = index; | |
|
130 | if (insertIndex < 0) | |
|
131 | insertIndex = 0; | |
|
132 | else if (insertIndex > count()) | |
|
133 | insertIndex = count(); | |
|
134 | ||
|
129 | 135 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
130 | 136 | barset->setLabel(label); |
|
131 | 137 | barset->setValues(values); |
|
132 | if (QBarSeries::insert(index, barset)) | |
|
138 | if (QBarSeries::insert(insertIndex, barset)) | |
|
133 | 139 | return barset; |
|
134 | 140 | delete barset; |
|
135 | 141 | return 0; |
@@ -107,9 +107,58 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
107 | 107 | */ |
|
108 | 108 | |
|
109 | 109 | /*! |
|
110 | \qmlmethod AbstractSeries ChartView::series(int index) | |
|
111 | Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with | |
|
112 | the count property of the chart. | |
|
113 | */ | |
|
114 | ||
|
115 | /*! | |
|
116 | \qmlmethod AbstractSeries ChartView::series(string name) | |
|
117 | Returns the first series on the chart with \a name. If there is no series with that name, returns null. | |
|
118 | */ | |
|
119 | ||
|
120 | /*! | |
|
121 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name) | |
|
122 | Creates a series object of \a type to the chart. For example: | |
|
123 | \code | |
|
124 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series"); | |
|
125 | scatter.markerSize = 22; | |
|
126 | scatter.append(1.1, 2.0); | |
|
127 | \endcode | |
|
128 | */ | |
|
129 | ||
|
130 | /*! | |
|
110 | 131 | \qmlmethod Axis ChartView::axisY(QAbstractSeries *series) |
|
111 |
The y-axis of the series. This is the same as the default y-axis of the chart |
|
|
112 | explicitly defined the series to have a non-default y-axis. | |
|
132 | The y-axis of the series. This is the same as the default y-axis of the chart as multiple y-axes are not yet supported. | |
|
133 | */ | |
|
134 | ||
|
135 | /*! | |
|
136 | \qmlmethod ChartView::zoomY(real factor) | |
|
137 | Zooms in by \a factor on the center of the chart. | |
|
138 | */ | |
|
139 | ||
|
140 | /*! | |
|
141 | \qmlmethod ChartView::scrollLeft(real pixels) | |
|
142 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. | |
|
143 | \sa Axis::min, Axis::max | |
|
144 | */ | |
|
145 | ||
|
146 | /*! | |
|
147 | \qmlmethod ChartView::scrollRight(real pixels) | |
|
148 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. | |
|
149 | \sa Axis::min, Axis::max | |
|
150 | */ | |
|
151 | ||
|
152 | /*! | |
|
153 | \qmlmethod ChartView::scrollUp(real pixels) | |
|
154 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. | |
|
155 | \sa Axis::min, Axis::max | |
|
156 | */ | |
|
157 | ||
|
158 | /*! | |
|
159 | \qmlmethod ChartView::scrollDown(real pixels) | |
|
160 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. | |
|
161 | \sa Axis::min, Axis::max | |
|
113 | 162 | */ |
|
114 | 163 | |
|
115 | 164 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) |
@@ -100,7 +100,6 public: | |||
|
100 | 100 | void setTitle(QString title); |
|
101 | 101 | QString title(); |
|
102 | 102 | QAxis *axisX(); |
|
103 | Q_INVOKABLE QAxis *axisY(QAbstractSeries *series = 0); | |
|
104 | 103 | QLegend *legend(); |
|
105 | 104 | QVariantList axisXLabels(); |
|
106 | 105 | void setAxisXLabels(QVariantList list); |
@@ -113,14 +112,17 public: | |||
|
113 | 112 | int count(); |
|
114 | 113 | void setDropShadowEnabled(bool enabled); |
|
115 | 114 | bool dropShadowEnabled(); |
|
115 | ||
|
116 | public: | |
|
117 | Q_INVOKABLE QAbstractSeries *series(int index); | |
|
118 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); | |
|
119 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); | |
|
120 | Q_INVOKABLE QAxis *axisY(QAbstractSeries *series = 0); | |
|
116 | 121 | Q_INVOKABLE void zoom(qreal factor); |
|
117 | 122 | Q_INVOKABLE void scrollLeft(qreal pixels); |
|
118 | 123 | Q_INVOKABLE void scrollRight(qreal pixels); |
|
119 | 124 | Q_INVOKABLE void scrollUp(qreal pixels); |
|
120 | 125 | Q_INVOKABLE void scrollDown(qreal pixels); |
|
121 | Q_INVOKABLE QAbstractSeries *series(int index); | |
|
122 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); | |
|
123 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); | |
|
124 | 126 | |
|
125 | 127 | Q_SIGNALS: |
|
126 | 128 | void axisLabelsChanged(); |
@@ -47,13 +47,13 public: // from QDeclarativeParserStatus | |||
|
47 | 47 | void classBegin() { DeclarativeXySeries::classBegin(); } |
|
48 | 48 | void componentComplete() { DeclarativeXySeries::componentComplete(); } |
|
49 | 49 | |
|
50 | public: // from QLineSeries | |
|
51 |
Q_INVOKABLE void append(qreal x, qreal y) { |
|
|
52 |
Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { |
|
|
53 |
Q_INVOKABLE void remove(qreal x, qreal y) { |
|
|
54 |
Q_INVOKABLE void insert(int index, qreal x, qreal y) { |
|
|
55 |
Q_INVOKABLE void clear() { |
|
|
56 |
Q_INVOKABLE |
|
|
50 | public: | |
|
51 | Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); } | |
|
52 | Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); } | |
|
53 | Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); } | |
|
54 | Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); } | |
|
55 | Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); } | |
|
56 | Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); } | |
|
57 | 57 | |
|
58 | 58 | Q_SIGNALS: |
|
59 | 59 | void countChanged(int count); |
@@ -46,13 +46,13 public: // from QDeclarativeParserStatus | |||
|
46 | 46 | void classBegin() { DeclarativeXySeries::classBegin(); } |
|
47 | 47 | void componentComplete() { DeclarativeXySeries::componentComplete(); } |
|
48 | 48 | |
|
49 | public: // from QScatterSeries | |
|
50 |
Q_INVOKABLE void append(qreal x, qreal y) { |
|
|
51 |
Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { |
|
|
52 |
Q_INVOKABLE void remove(qreal x, qreal y) { |
|
|
53 | Q_INVOKABLE void clear() { QScatterSeries::clear(); } | |
|
54 | Q_INVOKABLE void insert(int index, qreal x, qreal y) { QScatterSeries::insert(index, QPointF(x, y)); } | |
|
55 |
Q_INVOKABLE |
|
|
49 | public: | |
|
50 | Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); } | |
|
51 | Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); } | |
|
52 | Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); } | |
|
53 | Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); } | |
|
54 | Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); } | |
|
55 | Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); } | |
|
56 | 56 | |
|
57 | 57 | Q_SIGNALS: |
|
58 | 58 | void countChanged(int count); |
@@ -47,13 +47,13 public: // from QDeclarativeParserStatus | |||
|
47 | 47 | void classBegin() { DeclarativeXySeries::classBegin(); } |
|
48 | 48 | void componentComplete() { DeclarativeXySeries::componentComplete(); } |
|
49 | 49 | |
|
50 | public: // from QSplineSeries | |
|
51 |
Q_INVOKABLE void append(qreal x, qreal y) { |
|
|
52 |
Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { |
|
|
53 |
Q_INVOKABLE void remove(qreal x, qreal y) { |
|
|
54 | Q_INVOKABLE void clear() { QSplineSeries::clear(); } | |
|
55 | Q_INVOKABLE void insert(int index, qreal x, qreal y) { QSplineSeries::insert(index, QPointF(x, y)); } | |
|
56 |
Q_INVOKABLE |
|
|
50 | public: | |
|
51 | Q_INVOKABLE void append(qreal x, qreal y) { DeclarativeXySeries::append(x, y); } | |
|
52 | Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY) { DeclarativeXySeries::replace(oldX, oldY, newX, newY); } | |
|
53 | Q_INVOKABLE void remove(qreal x, qreal y) { DeclarativeXySeries::remove(x, y); } | |
|
54 | Q_INVOKABLE void insert(int index, qreal x, qreal y) { DeclarativeXySeries::insert(index, x, y); } | |
|
55 | Q_INVOKABLE void clear() { DeclarativeXySeries::clear(); } | |
|
56 | Q_INVOKABLE QPointF at(int index) { return DeclarativeXySeries::at(index); } | |
|
57 | 57 | |
|
58 | 58 | Q_SIGNALS: |
|
59 | 59 | void countChanged(int count); |
@@ -59,19 +59,48 void DeclarativeXySeries::componentComplete() | |||
|
59 | 59 | } |
|
60 | 60 | } |
|
61 | 61 | |
|
62 | DeclarativeXyPoint *DeclarativeXySeries::at(int index) | |
|
62 | void DeclarativeXySeries::append(qreal x, qreal y) | |
|
63 | 63 | { |
|
64 | 64 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
65 | 65 | Q_ASSERT(series); |
|
66 | if (index < series->count()) { | |
|
67 | QPointF point = series->points().at(index); | |
|
68 | DeclarativeXyPoint *xyPoint = new DeclarativeXyPoint(series); | |
|
69 | xyPoint->setX(point.x()); | |
|
70 | xyPoint->setY(point.y()); | |
|
71 | return xyPoint; | |
|
72 | } | |
|
73 | return 0; | |
|
66 | series->append(x, y); | |
|
74 | 67 | } |
|
75 | 68 | |
|
69 | void DeclarativeXySeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY) | |
|
70 | { | |
|
71 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
|
72 | Q_ASSERT(series); | |
|
73 | series->replace(oldX, oldY, newX, newY); | |
|
74 | } | |
|
75 | ||
|
76 | void DeclarativeXySeries::remove(qreal x, qreal y) | |
|
77 | { | |
|
78 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
|
79 | Q_ASSERT(series); | |
|
80 | series->remove(x, y); | |
|
81 | } | |
|
82 | ||
|
83 | void DeclarativeXySeries::insert(int index, qreal x, qreal y) | |
|
84 | { | |
|
85 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
|
86 | Q_ASSERT(series); | |
|
87 | series->insert(index, QPointF(x, y)); | |
|
88 | } | |
|
89 | ||
|
90 | void DeclarativeXySeries::clear() | |
|
91 | { | |
|
92 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
|
93 | Q_ASSERT(series); | |
|
94 | series->clear(); | |
|
95 | } | |
|
96 | ||
|
97 | QPointF DeclarativeXySeries::at(int index) | |
|
98 | { | |
|
99 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
|
100 | Q_ASSERT(series); | |
|
101 | if (index >= 0 || index < series->count()) | |
|
102 | return series->points().at(index); | |
|
103 | return QPointF(0, 0); | |
|
104 | } | |
|
76 | 105 | |
|
77 | 106 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -41,7 +41,13 public: | |||
|
41 | 41 | void classBegin(); |
|
42 | 42 | void componentComplete(); |
|
43 | 43 | virtual QXYSeries *xySeries() = 0; |
|
44 | DeclarativeXyPoint *at(int index); | |
|
44 | ||
|
45 | void append(qreal x, qreal y); | |
|
46 | void replace(qreal oldX, qreal oldY, qreal newX, qreal newY); | |
|
47 | void remove(qreal x, qreal y); | |
|
48 | void insert(int index, qreal x, qreal y); | |
|
49 | void clear(); | |
|
50 | QPointF at(int index); | |
|
45 | 51 | }; |
|
46 | 52 | |
|
47 | 53 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -47,14 +47,15 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
47 | 47 | */ |
|
48 | 48 | /*! |
|
49 | 49 | \qmlclass BarSeries QBarSeries |
|
50 | \inherits AbstractSeries | |
|
51 | ||
|
52 | The following QML shows how to create a simple bar chart: | |
|
53 | \snippet ../demos/qmlchart/qml/qmlchart/View6.qml 1 | |
|
50 | 54 | |
|
51 | 55 | \beginfloatleft |
|
52 | 56 | \image demos_qmlchart6.png |
|
53 | 57 | \endfloat |
|
54 | 58 | \clearfloat |
|
55 | ||
|
56 | The following QML shows how to create a simple bar chart: | |
|
57 | \snippet ../demos/qmlchart/qml/qmlchart/View6.qml 1 | |
|
58 | 59 | */ |
|
59 | 60 | |
|
60 | 61 | /*! |
@@ -155,6 +156,39 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
155 | 156 | */ |
|
156 | 157 | |
|
157 | 158 | /*! |
|
159 | \qmlmethod BarSet BarSeries::at(int index) | |
|
160 | Returns bar set at \a index. Returns null if the index is not valid. | |
|
161 | */ | |
|
162 | ||
|
163 | /*! | |
|
164 | \qmlmethod BarSet BarSeries::append(string label, VariantList values) | |
|
165 | Adds a new bar set with \a label and \a values to \a index. Values can be a list of reals or a list of XyPoints. | |
|
166 | For example: | |
|
167 | \code | |
|
168 | myBarSeries.append("set 1", [0, 0.2, 0.2, 0.5, 0.4, 1.5, 0.9]); | |
|
169 | myBarSeries.append("set 2", [Qt.point(0, 1), Qt.point(2, 2.5), Qt.point(3.5, 2.2)]); | |
|
170 | \endcode | |
|
171 | */ | |
|
172 | ||
|
173 | /*! | |
|
174 | \qmlmethod BarSet BarSeries::insert(int index, string label, VariantList values) | |
|
175 | Inserts a new bar set with \a label and \a values to \a index. Values can be a list of reals or a list of XyPoints. | |
|
176 | If index is zero or smaller, the new barset is prepended. If the index is count or bigger, the new barset is | |
|
177 | appended. | |
|
178 | \sa BarSeries::append() | |
|
179 | */ | |
|
180 | ||
|
181 | /*! | |
|
182 | \qmlmethod bool BarSeries::remove(BarSet barset) | |
|
183 | Removes the barset from the series. Returns true if successfull, false otherwise. | |
|
184 | */ | |
|
185 | ||
|
186 | /*! | |
|
187 | \qmlmethod BarSeries::clear() | |
|
188 | Removes all barsets from the series. | |
|
189 | */ | |
|
190 | ||
|
191 | /*! | |
|
158 | 192 | Constructs empty QBarSeries. |
|
159 | 193 | QBarSeries is QObject which is a child of a \a parent. |
|
160 | 194 | */ |
@@ -50,6 +50,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
50 | 50 | */ |
|
51 | 51 | /*! |
|
52 | 52 | \qmlclass PieSeries QPieSeries |
|
53 | \inherits AbstractSeries | |
|
53 | 54 | |
|
54 | 55 | The following QML shows how to create a simple pie chart. |
|
55 | 56 | |
@@ -271,6 +272,31 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
271 | 272 | */ |
|
272 | 273 | |
|
273 | 274 | /*! |
|
275 | \qmlmethod PieSlice PieSeries::at(int index) | |
|
276 | Returns slice at \a index. Returns null if the index is not valid. | |
|
277 | */ | |
|
278 | ||
|
279 | /*! | |
|
280 | \qmlmethod PieSlice PieSeries::find(string label) | |
|
281 | Returns the first slice with \a label. Returns null if the index is not valid. | |
|
282 | */ | |
|
283 | ||
|
284 | /*! | |
|
285 | \qmlmethod PieSlice PieSeries::append(string label, real value) | |
|
286 | Adds a new slice with \a label and \a value to the pie. | |
|
287 | */ | |
|
288 | ||
|
289 | /*! | |
|
290 | \qmlmethod bool PieSeries::remove(PieSlice slice) | |
|
291 | Removes the \a slice from the pie. Returns true if the removal was successfull, false otherwise. | |
|
292 | */ | |
|
293 | ||
|
294 | /*! | |
|
295 | \qmlmethod PieSeries::clear() | |
|
296 | Removes all slices from the pie. | |
|
297 | */ | |
|
298 | ||
|
299 | /*! | |
|
274 | 300 | Constructs a series object which is a child of \a parent. |
|
275 | 301 | */ |
|
276 | 302 | QPieSeries::QPieSeries(QObject *parent) : |
@@ -33,6 +33,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
33 | 33 | \sa QXYSeries, QLineSeries, QSplineSeries, QScatterSeries, QAreaSeries, QBarSeries, QStackedBarSeries, |
|
34 | 34 | QPercentBarSeries, QPieSeries |
|
35 | 35 | */ |
|
36 | /*! | |
|
37 | \qmlclass AbstractSeries | |
|
38 | AbstractSeries is the base class for all series. | |
|
39 | The class cannot be instantiated by the user. | |
|
40 | */ | |
|
36 | 41 | |
|
37 | 42 | /*! |
|
38 | 43 | \enum QAbstractSeries::SeriesType |
@@ -54,18 +59,27 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
54 | 59 | \property QAbstractSeries::type |
|
55 | 60 | The type of the series. |
|
56 | 61 | */ |
|
62 | /*! | |
|
63 | \qmlproperty ChartView.SeriesType AbstractSeries::type | |
|
64 | The type of the series. | |
|
65 | */ | |
|
57 | 66 | |
|
58 | 67 | /*! |
|
59 | 68 | \property QAbstractSeries::name |
|
60 | \brief name of the series property | |
|
69 | \brief name of the series property. The name is shown in legend for QXYSeries. | |
|
70 | */ | |
|
71 | /*! | |
|
72 | \qmlproperty string AbstractSeries::name | |
|
73 | Name of the series. The name is shown in legend for QXYSeries. | |
|
61 | 74 | */ |
|
62 | 75 | |
|
63 | 76 | /*! |
|
64 | 77 | \fn void QAbstractSeries::nameChanged() |
|
65 | ||
|
66 | 78 | This signal is emitted when the series name changes. |
|
67 | ||
|
68 | \sa name | |
|
79 | */ | |
|
80 | /*! | |
|
81 | \qmlsignal AbstractSeries::nameChanged() | |
|
82 | This signal is emitted when the series name changes. | |
|
69 | 83 | */ |
|
70 | 84 | |
|
71 | 85 | /*! |
@@ -96,14 +110,6 QAbstractSeries::~QAbstractSeries() | |||
|
96 | 110 | if(d_ptr->m_dataset) qFatal("Still binded series detected !"); |
|
97 | 111 | } |
|
98 | 112 | |
|
99 | /*! | |
|
100 | \brief Sets a \a name for the series. | |
|
101 | ||
|
102 | The name of a series is shown in the legend for QXYSeries. | |
|
103 | \sa QChart::setTitle() | |
|
104 | \sa QPieSlice::setLabel() | |
|
105 | \sa QBarSet::setName() | |
|
106 | */ | |
|
107 | 113 | void QAbstractSeries::setName(const QString& name) |
|
108 | 114 | { |
|
109 | 115 | if (name != d_ptr->m_name) { |
@@ -112,10 +118,6 void QAbstractSeries::setName(const QString& name) | |||
|
112 | 118 | } |
|
113 | 119 | } |
|
114 | 120 | |
|
115 | /*! | |
|
116 | \brief Returns the name of the series. | |
|
117 | \sa setName() | |
|
118 | */ | |
|
119 | 121 | QString QAbstractSeries::name() const |
|
120 | 122 | { |
|
121 | 123 | return d_ptr->m_name; |
@@ -31,7 +31,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
31 | 31 | */ |
|
32 | 32 | /*! |
|
33 | 33 | \qmlclass XYSeries |
|
34 | \brief The XYSeries class is a base class for line, spline and scatter series. | |
|
34 | \inherits AbstractSeries | |
|
35 | The XYSeries class is a base class for line, spline and scatter series. | |
|
35 | 36 | |
|
36 | 37 | The class cannot be instantiated directly. |
|
37 | 38 | */ |
@@ -130,7 +131,30 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
130 | 131 | */ |
|
131 | 132 | |
|
132 | 133 | /*! |
|
133 |
\qmlmethod X |
|
|
134 | \qmlmethod XYSeries::append(real x, real y) | |
|
135 | Append point (\a x, \a y) to the series | |
|
136 | */ | |
|
137 | ||
|
138 | /*! | |
|
139 | \qmlmethod XYSeries::replace(real oldX, real oldY, real newX, real newY) | |
|
140 | Replaces point (\a oldX, \a oldY) with point (\a newX, \a newY). Does nothing, if point (oldX, oldY) does not | |
|
141 | exist. | |
|
142 | */ | |
|
143 | ||
|
144 | /*! | |
|
145 | \qmlmethod XYSeries::remove(real x, real y) | |
|
146 | Removes point (\a x, \a y) from the series. Does nothing, if point (x, y) does not exist. | |
|
147 | */ | |
|
148 | ||
|
149 | /*! | |
|
150 | \qmlmethod XYSeries::insert(int index, real x, real y) | |
|
151 | Inserts point (\a x, \a y) to the \a index. If index is 0 or smaller than 0 the point is prepended to the list of | |
|
152 | points. If index is the same as or bigger than count, the point is appended to the list of points. | |
|
153 | */ | |
|
154 | ||
|
155 | /*! | |
|
156 | \qmlmethod QPointF XYSeries::at(int index) | |
|
157 | Returns point at \a index. Returns (0, 0) if the index is not valid. | |
|
134 | 158 | */ |
|
135 | 159 | |
|
136 | 160 | /*! |
@@ -44,6 +44,25 void tst_QXYSeries::cleanup() | |||
|
44 | 44 | m_series = 0; |
|
45 | 45 | } |
|
46 | 46 | |
|
47 | void tst_QXYSeries::seriesName() | |
|
48 | { | |
|
49 | QSignalSpy nameSpy(m_series, SIGNAL(nameChanged())); | |
|
50 | QCOMPARE(m_series->name(), QString()); | |
|
51 | m_series->setName("seriesname"); | |
|
52 | QCOMPARE(m_series->name(), QString("seriesname")); | |
|
53 | TRY_COMPARE(nameSpy.count(), 1); | |
|
54 | } | |
|
55 | ||
|
56 | void tst_QXYSeries::seriesVisible() | |
|
57 | { | |
|
58 | QSignalSpy visibleSpy(m_series, SIGNAL(visibleChanged())); | |
|
59 | QCOMPARE(m_series->isVisible(), true); | |
|
60 | m_series->setVisible(false); | |
|
61 | QCOMPARE(m_series->isVisible(), false); | |
|
62 | m_series->setVisible(true); | |
|
63 | TRY_COMPARE(visibleSpy.count(), 2); | |
|
64 | } | |
|
65 | ||
|
47 | 66 | void tst_QXYSeries::append_data() |
|
48 | 67 | { |
|
49 | 68 | QTest::addColumn< QList<QPointF> >("points"); |
@@ -61,8 +80,10 void tst_QXYSeries::append_raw() | |||
|
61 | 80 | { |
|
62 | 81 | QFETCH(QList<QPointF>, points); |
|
63 | 82 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
83 | QSignalSpy addedSpy(m_series, SIGNAL(pointAdded(int))); | |
|
64 | 84 | m_series->append(points); |
|
65 | 85 | TRY_COMPARE(spy0.count(), 0); |
|
86 | TRY_COMPARE(addedSpy.count(), points.count()); | |
|
66 | 87 | QCOMPARE(m_series->points(), points); |
|
67 | 88 | } |
|
68 | 89 | |
@@ -233,13 +254,18 void tst_QXYSeries::replace_raw_data() | |||
|
233 | 254 | void tst_QXYSeries::replace_raw() |
|
234 | 255 | { |
|
235 | 256 | QFETCH(QList<QPointF>, points); |
|
236 |
QSignalSpy |
|
|
257 | QSignalSpy replacedSpy(m_series, SIGNAL(pointReplaced(int))); | |
|
237 | 258 | m_series->append(points); |
|
238 |
TRY_COMPARE( |
|
|
259 | TRY_COMPARE(replacedSpy.count(), 0); | |
|
239 | 260 | QCOMPARE(m_series->points(), points); |
|
240 | 261 | |
|
241 | foreach(const QPointF& point,points) | |
|
262 | foreach(const QPointF& point, points) | |
|
242 | 263 | m_series->replace(point.x(),point.y(),point.x(),0); |
|
264 | TRY_COMPARE(replacedSpy.count(), points.count()); | |
|
265 | ||
|
266 | // Replace a point that does not exist | |
|
267 | m_series->replace(-123, 999, 0, 0); | |
|
268 | TRY_COMPARE(replacedSpy.count(), points.count()); | |
|
243 | 269 | |
|
244 | 270 | QList<QPointF> newPoints = m_series->points(); |
|
245 | 271 | |
@@ -276,6 +302,27 void tst_QXYSeries::replace_chart_animation() | |||
|
276 | 302 | replace_chart(); |
|
277 | 303 | } |
|
278 | 304 | |
|
305 | void tst_QXYSeries::insert_data() | |
|
306 | { | |
|
307 | append_data(); | |
|
308 | } | |
|
309 | ||
|
310 | void tst_QXYSeries::insert() | |
|
311 | { | |
|
312 | QFETCH(QList<QPointF>, points); | |
|
313 | m_series->append(points); | |
|
314 | ||
|
315 | QSignalSpy addedSpy(m_series, SIGNAL(pointAdded(int))); | |
|
316 | ||
|
317 | m_series->insert(0, QPointF(5, 5)); | |
|
318 | TRY_COMPARE(addedSpy.count(), 1); | |
|
319 | QCOMPARE(m_series->points().count(), points.count() + 1); | |
|
320 | ||
|
321 | m_series->insert(m_series->count(), QPointF(6, 6)); | |
|
322 | TRY_COMPARE(addedSpy.count(), 2); | |
|
323 | QCOMPARE(m_series->points().count(), points.count() + 2); | |
|
324 | } | |
|
325 | ||
|
279 | 326 | void tst_QXYSeries::oper_data() |
|
280 | 327 | { |
|
281 | 328 | append_data(); |
@@ -40,6 +40,8 public slots: | |||
|
40 | 40 | virtual void cleanup(); |
|
41 | 41 | |
|
42 | 42 | private slots: |
|
43 | void seriesName(); | |
|
44 | void seriesVisible(); | |
|
43 | 45 | void oper_data(); |
|
44 | 46 | void oper(); |
|
45 | 47 | void pen_data(); |
@@ -74,6 +76,8 private slots: | |||
|
74 | 76 | void replace_chart(); |
|
75 | 77 | void replace_chart_animation_data(); |
|
76 | 78 | void replace_chart_animation(); |
|
79 | void insert_data(); | |
|
80 | void insert(); | |
|
77 | 81 | void changedSignals(); |
|
78 | 82 | protected: |
|
79 | 83 | void append_data(); |
General Comments 0
You need to be logged in to leave comments.
Login now