##// END OF EJS Templates
Documenting xy-series
Tero Ahola -
r1491:abdb70920d73
parent child
Show More
@@ -1,76 +1,71
1 1 /*!
2 2 \page qml.html
3 3 \title QtCommercial Charts QML API
4 4 \keyword Charts QML API
5 5
6 6 QtCommercial Charts QML API is an intuitive and simple way to show charts in your QML
7 7 applications. The following QML shows you to create a simple pie chart:
8 8 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1
9 9 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2
10 10 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3
11 11
12 \beginfloatleft
13 \image examples_qmlpiechart.png
14 \endfloat
15 \clearfloat
16
17 12 \raw HTML
18 13 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
19 14 <tr>
20 15 <th class="titleheader" width="25%"> ChartView and it's properties </th>
21 16 </tr>
22 17 <tr>
23 18 <td valign="top">
24 19 <ul>
25 20 <li><a href="qml-chartview.html">ChartView</a></li>
26 21 <li><a href="qml-axis.html">Axis</a></li>
27 22 <li><a href="qml-legend.html">Legend</a></li>
28 23 </ul>
29 24 </td>
30 25 </tr>
31 26 </table>
32 27 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
33 28 <tr>
34 29 <th class="titleheader" width="25%"> XY chart </th>
35 30 </tr>
36 31 <tr>
37 32 <td valign="top">
38 33 <ul>
39 34 <li><a href="qml-lineseries.html">LineSeries</a></li>
40 35 <li><a href="qml-areaseries.html">AreaSeries</a></li>
41 36 <li><a href="qml-scatterseries.html">ScatterSeries</a></li>
42 37 <li><a href="qml-splineseries.html">SplineSeries</a></li>
43 38 <li><a href="qml-xypoint.html">XyPoint</a></li>
44 39 </ul>
45 40 </td>
46 41 </tr>
47 42 </table>
48 43 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
49 44 <tr>
50 45 <th class="titleheader" width="25%"> Pie chart </th>
51 46 <tr>
52 47 <td valign="top">
53 48 <ul>
54 49 <li><a href="qml-pieseries.html">PieSeries</a></li>
55 50 <li><a href="qml-pieslice.html">PieSlice</a></li>
56 51 </ul>
57 52 </td>
58 53 </tr>
59 54 </table>
60 55 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
61 56 <tr>
62 57 <th class="titleheader" width="25%"> Bar chart </th>
63 58 <tr>
64 59 <td valign="top">
65 60 <ul>
66 61 <li><a href="qml-barseries.html">BarSeries</a></li>
67 62 <li><a href="qml-groupedbarseries.html">GroupedBarSeries</a></li>
68 63 <li><a href="qml-stackedbarseries.html">StackedBarSeries</a></li>
69 64 <li><a href="qml-percentbarseries.html">PercentBarSeries</a></li>
70 65 <li><a href="qml-barset.html">BarSet</a></li>
71 66 </ul>
72 67 </td>
73 68 </tr>
74 69 </table>
75 70 \endraw
76 71 */
@@ -1,69 +1,55
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 "declarativeareaseries.h"
22 22 #include "declarativechart.h"
23 23 #include "qchart.h"
24 24 #include "qxymodelmapper.h"
25 25
26 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 27
28 /*!
29 \qmlclass AreaSeries QAreaSeries
30
31 \section1 Example Usage
32
33 \beginfloatleft
34 \image demos_qmlchart4.png
35 \endfloat
36 \clearfloat
37
38 The following QML shows how to create a simple area chart:
39 \snippet ../demos/qmlchart/qml/qmlchart/View4.qml 1
40 */
41
42 28 DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) :
43 29 QAreaSeries(parent)
44 30 {
45 31 }
46 32
47 33 void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries* series)
48 34 {
49 35 QAreaSeries::setUpperSeries(series);
50 36 }
51 37
52 38 DeclarativeLineSeries* DeclarativeAreaSeries::upperSeries() const
53 39 {
54 40 return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::upperSeries());
55 41 }
56 42
57 43 void DeclarativeAreaSeries::setLowerSeries(DeclarativeLineSeries* series)
58 44 {
59 45 QAreaSeries::setLowerSeries(series);
60 46 }
61 47
62 48 DeclarativeLineSeries* DeclarativeAreaSeries::lowerSeries() const
63 49 {
64 50 return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::lowerSeries());
65 51 }
66 52
67 53 #include "moc_declarativeareaseries.cpp"
68 54
69 55 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,373 +1,375
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 "declarativechart.h"
22 22 #include <QPainter>
23 23 #include "declarativelineseries.h"
24 24 #include "declarativeareaseries.h"
25 25 #include "declarativebarseries.h"
26 26 #include "declarativepieseries.h"
27 27 #include "declarativesplineseries.h"
28 28 #include "declarativescatterseries.h"
29 29
30 30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 31
32 32 /*!
33 33 \qmlclass ChartView DeclarativeChart
34 34
35 35 ChartView element is the parent that is responsible for showing different chart series types.
36 36
37 The following QML shows how to create a simple line chart:
38 \snippet ../demos/qmlchart/qml/qmlchart/View2.qml 1
37 The following QML shows how to create a simple chart with one pie series:
38 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1
39 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2
40 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3
39 41
40 42 \beginfloatleft
41 \image demos_qmlchart2.png
43 \image examples_qmlpiechart.png
42 44 \endfloat
43 45 \clearfloat
44 46 */
45 47
46 48 /*!
47 49 \qmlproperty Theme ChartView::theme
48 50 Theme defines the visual appearance of the chart, including for example colors, fonts, line
49 51 widths and chart background.
50 52 */
51 53
52 54 /*!
53 55 \qmlproperty Animation ChartView::animation
54 56 Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations,
55 57 ChartView.SeriesAnimations or ChartView.AllAnimations.
56 58 */
57 59
58 60 /*!
59 61 \qmlproperty string ChartView::title
60 62 The title of the chart, shown on top of the chart.
61 63 \sa ChartView::titleColor
62 64 */
63 65
64 66 /*!
65 67 \qmlproperty string ChartView::titleColor
66 68 The color of the title text.
67 69 */
68 70
69 71 /*!
70 72 \qmlproperty Axis ChartView::axisX
71 73 The x-axis of the chart.
72 74 */
73 75
74 76 /*!
75 77 \qmlproperty Axis ChartView::axisY
76 78 The default y-axis of the chart.
77 79 */
78 80
79 81 /*!
80 82 \qmlproperty Legend ChartView::legend
81 83 The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart.
82 84 */
83 85
84 86 /*!
85 87 \qmlproperty int ChartView::count
86 88 The count of series added to the chart.
87 89 */
88 90
89 91 /*!
90 92 \qmlproperty color ChartView::backgroundColor
91 93 The color of the chart's background. By default background color is defined by chart theme.
92 94 \sa ChartView::theme
93 95 */
94 96
95 97 /*!
96 98 \qmlproperty bool ChartView::dropShadowEnabled
97 99 The chart's border drop shadow. Set to true to enable drop shadow.
98 100 */
99 101
100 102 /*!
101 103 \qmlmethod Axis ChartView::axisY(QAbstractSeries *series)
102 104 The y-axis of the series. This is the same as the default y-axis of the chart, unless you have
103 105 explicitly defined the series to have a non-default y-axis.
104 106 */
105 107
106 108 DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent)
107 109 : QDeclarativeItem(parent),
108 110 m_chart(new QChart(this))
109 111 {
110 112 setFlag(QGraphicsItem::ItemHasNoContents, false);
111 113 // m_chart->axisX()->setNiceNumbersEnabled(false);
112 114 }
113 115
114 116 DeclarativeChart::~DeclarativeChart()
115 117 {
116 118 delete m_chart;
117 119 }
118 120
119 121 void DeclarativeChart::childEvent(QChildEvent *event)
120 122 {
121 123 if (event->type() == QEvent::ChildAdded) {
122 124 if (qobject_cast<QAbstractSeries *>(event->child())) {
123 125 m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child()));
124 126 }
125 127 }
126 128 }
127 129
128 130 void DeclarativeChart::componentComplete()
129 131 {
130 132 foreach(QObject *child, children()) {
131 133 if (qobject_cast<QAbstractSeries *>(child)) {
132 134 // qDebug() << "DeclarativeChart::componentComplete(), add: " << child;
133 135 // TODO: how about optional y-axis?
134 136 m_chart->addSeries(qobject_cast<QAbstractSeries *>(child));
135 137 }
136 138 }
137 139 QDeclarativeItem::componentComplete();
138 140 }
139 141
140 142 void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
141 143 {
142 144 // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height();
143 145 if (newGeometry.isValid()) {
144 146 if (newGeometry.width() > 0 && newGeometry.height() > 0) {
145 147 m_chart->resize(newGeometry.width(), newGeometry.height());
146 148 }
147 149 }
148 150 QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
149 151 }
150 152
151 153 void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
152 154 {
153 155 Q_UNUSED(option)
154 156 Q_UNUSED(widget)
155 157
156 158 // TODO: optimized?
157 159 painter->setRenderHint(QPainter::Antialiasing, true);
158 160 }
159 161
160 162 void DeclarativeChart::setTheme(DeclarativeChart::Theme theme)
161 163 {
162 164 QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme;
163 165 if (chartTheme != m_chart->theme())
164 166 m_chart->setTheme(chartTheme);
165 167 }
166 168
167 169 DeclarativeChart::Theme DeclarativeChart::theme()
168 170 {
169 171 return (DeclarativeChart::Theme) m_chart->theme();
170 172 }
171 173
172 174 void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations)
173 175 {
174 176 QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations;
175 177 if (animationOptions != m_chart->animationOptions())
176 178 m_chart->setAnimationOptions(animationOptions);
177 179 }
178 180
179 181 DeclarativeChart::Animation DeclarativeChart::animationOptions()
180 182 {
181 183 if (m_chart->animationOptions().testFlag(QChart::AllAnimations))
182 184 return DeclarativeChart::AllAnimations;
183 185 else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations))
184 186 return DeclarativeChart::GridAxisAnimations;
185 187 else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations))
186 188 return DeclarativeChart::SeriesAnimations;
187 189 else
188 190 return DeclarativeChart::NoAnimation;
189 191 }
190 192
191 193 void DeclarativeChart::setTitle(QString title)
192 194 {
193 195 if (title != m_chart->title())
194 196 m_chart->setTitle(title);
195 197 }
196 198 QString DeclarativeChart::title()
197 199 {
198 200 return m_chart->title();
199 201 }
200 202
201 203 QAxis *DeclarativeChart::axisX()
202 204 {
203 205 return m_chart->axisX();
204 206 }
205 207
206 208 QAxis *DeclarativeChart::axisY(QAbstractSeries *series)
207 209 {
208 210 return m_chart->axisY(series);
209 211 }
210 212
211 213 QLegend *DeclarativeChart::legend()
212 214 {
213 215 return m_chart->legend();
214 216 }
215 217
216 218 QVariantList DeclarativeChart::axisXLabels()
217 219 {
218 220 QVariantList labels;
219 221 foreach (qreal value, m_chart->axisX()->categories()->values()) {
220 222 labels.append(value);
221 223 labels.append(m_chart->axisX()->categories()->label(value));
222 224 }
223 225 return labels;
224 226 }
225 227
226 228 void DeclarativeChart::setAxisXLabels(QVariantList list)
227 229 {
228 230 QVariant value(QVariant::Invalid);
229 231 foreach (QVariant element, list) {
230 232 if (value.isValid() && element.type() == QVariant::String) {
231 233 m_chart->axisX()->categories()->insert(value.toDouble(), element.toString());
232 234 value = QVariant(QVariant::Invalid);
233 235 } else {
234 236 if (element.canConvert(QVariant::Double))
235 237 value = element;
236 238 }
237 239 }
238 240 emit axisLabelsChanged();
239 241 }
240 242
241 243 void DeclarativeChart::setTitleColor(QColor color)
242 244 {
243 245 QBrush b = m_chart->titleBrush();
244 246 if (color != b.color()) {
245 247 b.setColor(color);
246 248 m_chart->setTitleBrush(b);
247 249 emit titleColorChanged();
248 250 }
249 251 }
250 252
251 253 QColor DeclarativeChart::titleColor()
252 254 {
253 255 return m_chart->titleBrush().color();
254 256 }
255 257
256 258 void DeclarativeChart::setBackgroundColor(QColor color)
257 259 {
258 260 QBrush b = m_chart->backgroundBrush();
259 261 if (b.style() != Qt::SolidPattern || color != b.color()) {
260 262 b.setStyle(Qt::SolidPattern);
261 263 b.setColor(color);
262 264 m_chart->setBackgroundBrush(b);
263 265 emit backgroundColorChanged();
264 266 }
265 267 }
266 268
267 269 QColor DeclarativeChart::backgroundColor()
268 270 {
269 271 return m_chart->backgroundBrush().color();
270 272 }
271 273
272 274 int DeclarativeChart::count()
273 275 {
274 276 return m_chart->series().count();
275 277 }
276 278
277 279 void DeclarativeChart::setDropShadowEnabled(bool enabled)
278 280 {
279 281 if (enabled != m_chart->isDropShadowEnabled()) {
280 282 m_chart->setDropShadowEnabled(enabled);
281 283 dropShadowEnabledChanged(enabled);
282 284 }
283 285 }
284 286
285 287 bool DeclarativeChart::dropShadowEnabled()
286 288 {
287 289 return m_chart->isDropShadowEnabled();
288 290 }
289 291
290 292 void DeclarativeChart::zoom(qreal factor)
291 293 {
292 294 m_chart->zoom(factor);
293 295 }
294 296
295 297 void DeclarativeChart::scrollLeft(qreal pixels)
296 298 {
297 299 m_chart->scroll(QPointF(pixels, 0));
298 300 }
299 301
300 302 void DeclarativeChart::scrollRight(qreal pixels)
301 303 {
302 304 m_chart->scroll(QPointF(-pixels, 0));
303 305 }
304 306
305 307 void DeclarativeChart::scrollUp(qreal pixels)
306 308 {
307 309 m_chart->scroll(QPointF(0, pixels));
308 310 }
309 311
310 312 void DeclarativeChart::scrollDown(qreal pixels)
311 313 {
312 314 m_chart->scroll(QPointF(0, -pixels));
313 315 }
314 316
315 317 QAbstractSeries *DeclarativeChart::series(int index)
316 318 {
317 319 if (index < m_chart->series().count()) {
318 320 return m_chart->series().at(index);
319 321 }
320 322 return 0;
321 323 }
322 324
323 325 QAbstractSeries *DeclarativeChart::series(QString seriesName)
324 326 {
325 327 foreach(QAbstractSeries *series, m_chart->series()) {
326 328 if (series->name() == seriesName)
327 329 return series;
328 330 }
329 331 return 0;
330 332 }
331 333
332 334 QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name)
333 335 {
334 336 QAbstractSeries *series = 0;
335 337 switch (type) {
336 338 case DeclarativeChart::SeriesTypeLine:
337 339 series = new DeclarativeLineSeries();
338 340 break;
339 341 case DeclarativeChart::SeriesTypeArea:
340 342 series = new DeclarativeAreaSeries();
341 343 break;
342 344 case DeclarativeChart::SeriesTypeBar:
343 345 series = new DeclarativeBarSeries();
344 346 break;
345 347 case DeclarativeChart::SeriesTypeStackedBar:
346 348 // TODO
347 349 break;
348 350 case DeclarativeChart::SeriesTypePercentBar:
349 351 // TODO
350 352 break;
351 353 case DeclarativeChart::SeriesTypeGroupedBar:
352 354 series = new DeclarativeGroupedBarSeries();
353 355 break;
354 356 case DeclarativeChart::SeriesTypePie:
355 357 series = new DeclarativePieSeries();
356 358 break;
357 359 case DeclarativeChart::SeriesTypeScatter:
358 360 series = new DeclarativeScatterSeries();
359 361 break;
360 362 case DeclarativeChart::SeriesTypeSpline:
361 363 series = new DeclarativeSplineSeries();
362 364 break;
363 365 default:
364 366 qWarning() << "Illegal series type";
365 367 }
366 368 series->setName(name);
367 369 m_chart->addSeries(series);
368 370 return series;
369 371 }
370 372
371 373 #include "moc_declarativechart.cpp"
372 374
373 375 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,72 +1,60
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 "declarativelineseries.h"
22 22 #include "declarativechart.h"
23 23 #include "qchart.h"
24 24 #include "qlineseries.h"
25 25
26 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 27
28 /*!
29 \qmlclass LineSeries QLineSeries
30
31 \beginfloatleft
32 \image demos_qmlchart2.png
33 \endfloat
34 \clearfloat
35
36 The following QML shows how to create a simple line chart:
37 \snippet ../demos/qmlchart/qml/qmlchart/View2.qml 1
38 */
39
40 28 DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) :
41 29 QLineSeries(parent)
42 30 {
43 31 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
44 32 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
45 33 }
46 34
47 35 QXYSeries *DeclarativeLineSeries::xySeries()
48 36 {
49 37 return this;
50 38 }
51 39
52 40 void DeclarativeLineSeries::handleCountChanged(int index)
53 41 {
54 42 Q_UNUSED(index)
55 43 emit countChanged(points().count());
56 44 }
57 45
58 46 QDeclarativeListProperty<QObject> DeclarativeLineSeries::declarativeChildren()
59 47 {
60 48 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
61 49 }
62 50
63 51 void DeclarativeLineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
64 52 {
65 53 Q_UNUSED(list)
66 54 Q_UNUSED(element)
67 55 // Empty implementation, childs are parsed in componentComplete
68 56 }
69 57
70 58 #include "moc_declarativelineseries.cpp"
71 59
72 60 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,143 +1,96
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 "declarativepieseries.h"
22 22 #include "declarativechart.h"
23 23 #include "qchart.h"
24 24 #include <qdeclarativelist.h>
25 25 #include <QVPieModelMapper>
26 26 #include <QHPieModelMapper>
27 27
28 28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 29
30 /*!
31 \qmlclass PieSeries QPieSeries
32
33 \section1 Example Usage
34
35 \beginfloatleft
36 \image demos_qmlchart1.png
37 \endfloat
38 \clearfloat
39
40 The following QML shows how to create a simple pie chart.
41
42 \snippet ../demos/qmlchart/qml/qmlchart/View1.qml 1
43 */
44
45 /*!
46 \qmlproperty real PieSeries::horizontalPosition
47 \brief Defines the horizontal position of the pie.
48
49 The value is a relative value to the chart rectangle where:
50
51 \list
52 \o 0.0 is the absolute left.
53 \o 1.0 is the absolute right.
54 \endlist
55
56 Default value is 0.5 (center).
57
58 \sa verticalPosition
59 */
60
61 /*!
62 \qmlproperty real PieSeries::verticalPosition
63 \brief Defines the vertical position of the pie.
64
65 The value is a relative value to the chart rectangle where:
66
67 \list
68 \o 0.0 is the absolute top.
69 \o 1.0 is the absolute bottom.
70 \endlist
71
72 Default value is 0.5 (center).
73
74 \sa horizontalPosition
75 */
76
77 30 DeclarativePieSeries::DeclarativePieSeries(QObject *parent) :
78 31 QPieSeries(parent)
79 32 {
80 33 }
81 34
82 35 void DeclarativePieSeries::classBegin()
83 36 {
84 37 }
85 38
86 39 void DeclarativePieSeries::componentComplete()
87 40 {
88 41 foreach(QObject *child, children()) {
89 42 if (qobject_cast<QPieSlice *>(child)) {
90 43 QPieSeries::append(qobject_cast<QPieSlice *>(child));
91 44 } else if(qobject_cast<QVPieModelMapper *>(child)) {
92 45 QVPieModelMapper *mapper = qobject_cast<QVPieModelMapper *>(child);
93 46 mapper->setSeries(this);
94 47 } else if(qobject_cast<QHPieModelMapper *>(child)) {
95 48 QHPieModelMapper *mapper = qobject_cast<QHPieModelMapper *>(child);
96 49 mapper->setSeries(this);
97 50 }
98 51 }
99 52 }
100 53
101 54 QDeclarativeListProperty<QObject> DeclarativePieSeries::seriesChildren()
102 55 {
103 56 return QDeclarativeListProperty<QObject>(this, 0, &DeclarativePieSeries::appendSeriesChildren);
104 57 }
105 58
106 59 void DeclarativePieSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element)
107 60 {
108 61 // Empty implementation; the children are parsed in componentComplete instead
109 62 Q_UNUSED(list);
110 63 Q_UNUSED(element);
111 64 }
112 65
113 66 QPieSlice *DeclarativePieSeries::at(int index)
114 67 {
115 68 QList<QPieSlice*> sliceList = slices();
116 69 if (index < sliceList.count())
117 70 return sliceList[index];
118 71
119 72 return 0;
120 73 }
121 74
122 75 QPieSlice* DeclarativePieSeries::find(QString label)
123 76 {
124 77 foreach (QPieSlice *slice, slices()) {
125 78 if (slice->label() == label)
126 79 return slice;
127 80 }
128 81 return 0;
129 82 }
130 83
131 84 QPieSlice* DeclarativePieSeries::append(QString label, qreal value)
132 85 {
133 86 // TODO: parameter order is wrong, switch it:
134 87 QPieSlice *slice = new QPieSlice(this);
135 88 slice->setLabel(label);
136 89 slice->setValue(value);
137 90 QPieSeries::append(slice);
138 91 return slice;
139 92 }
140 93
141 94 #include "moc_declarativepieseries.cpp"
142 95
143 96 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,73 +1,60
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 "declarativescatterseries.h"
22 22 #include "declarativechart.h"
23 23 #include "qchart.h"
24 24 #include "qscatterseries.h"
25 25
26 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 27
28 /*!
29 \qmlclass ScatterSeries QScatterSeries
30
31 The following QML shows how to create a chart with two simple scatter series:
32 \snippet ../demos/qmlchart/qml/qmlchart/View5.qml 1
33 \snippet ../demos/qmlchart/qml/qmlchart/View5.qml 2
34
35 \beginfloatleft
36 \image demos_qmlchart5.png
37 \endfloat
38 \clearfloat
39 */
40
41 28 DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) :
42 29 QScatterSeries(parent)
43 30 {
44 31 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
45 32 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
46 33 }
47 34
48 35 QXYSeries *DeclarativeScatterSeries::xySeries()
49 36 {
50 37 return this;
51 38 }
52 39
53 40 void DeclarativeScatterSeries::handleCountChanged(int index)
54 41 {
55 42 Q_UNUSED(index)
56 43 emit countChanged(QScatterSeries::count());
57 44 }
58 45
59 46 QDeclarativeListProperty<QObject> DeclarativeScatterSeries::declarativeChildren()
60 47 {
61 48 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
62 49 }
63 50
64 51 void DeclarativeScatterSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
65 52 {
66 53 Q_UNUSED(list)
67 54 Q_UNUSED(element)
68 55 // Empty implementation, childs are parsed in componentComplete
69 56 }
70 57
71 58 #include "moc_declarativescatterseries.cpp"
72 59
73 60 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,74 +1,60
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 "declarativesplineseries.h"
22 22 #include "declarativechart.h"
23 23 #include <QChart>
24 24 #include "declarativexypoint.h"
25 25
26 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 27
28 /*!
29 \qmlclass SplineSeries QSplineSeries
30
31 \section1 Example Usage
32
33 \beginfloatleft
34 \image demos_qmlchart3.png
35 \endfloat
36 \clearfloat
37
38 The following QML shows how to create a simple spline chart:
39 \snippet ../demos/qmlchart/qml/qmlchart/View3.qml 1
40 */
41
42 28 DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) :
43 29 QSplineSeries(parent)
44 30 {
45 31 connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int)));
46 32 connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int)));
47 33 }
48 34
49 35 QXYSeries *DeclarativeSplineSeries::xySeries()
50 36 {
51 37 return this;
52 38 }
53 39
54 40 void DeclarativeSplineSeries::handleCountChanged(int index)
55 41 {
56 42 Q_UNUSED(index)
57 43 emit countChanged(points().count());
58 44 }
59 45
60 46 QDeclarativeListProperty<QObject> DeclarativeSplineSeries::declarativeChildren()
61 47 {
62 48 return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren);
63 49 }
64 50
65 51 void DeclarativeSplineSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element)
66 52 {
67 53 Q_UNUSED(list)
68 54 Q_UNUSED(element)
69 55 // Empty implementation, childs are parsed in componentComplete
70 56 }
71 57
72 58 #include "moc_declarativesplineseries.cpp"
73 59
74 60 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,34 +1,51
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 "declarativexypoint.h"
22 22
23 23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 24
25 /*!
26 \qmlclass XyPoint QPointF
27 XyPoint is a convenience element for initializing XY-series with static coordinate data. To
28 manipulate an XY-series dynamically, use it's data manipulation functions instead.
29 \sa LineSeries, AreaSeries, ScatterSeries, SplineSeries
30 */
31
32 /*!
33 \qmlproperty real XyPoint::x
34 The x-coordinate of the point.
35 */
36
37 /*!
38 \qmlproperty real XyPoint::y
39 The y-coordinate of the point.
40 */
41
25 42 DeclarativeXyPoint::DeclarativeXyPoint(QObject *parent) :
26 43 QObject(parent)
27 44 {
28 45 setX(0.0);
29 46 setY(0.0);
30 47 }
31 48
32 49 #include "moc_declarativexypoint.cpp"
33 50
34 51 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,105 +1,105
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 <QtDeclarative/qdeclarativeextensionplugin.h>
22 22 #include <QtDeclarative/qdeclarative.h>
23 23 #include "qchart.h"
24 24 #include "qaxiscategories.h"
25 25 #include "declarativechart.h"
26 26 #include "declarativexypoint.h"
27 27 #include "declarativelineseries.h"
28 28 #include "declarativesplineseries.h"
29 29 #include "declarativeareaseries.h"
30 30 #include "declarativescatterseries.h"
31 31 #include "declarativebarseries.h"
32 32 #include "declarativepieseries.h"
33 33 #include <QVXYModelMapper>
34 34 #include <QHXYModelMapper>
35 35 #include <QHPieModelMapper>
36 36 #include <QVPieModelMapper>
37 37 #include <QHBarModelMapper>
38 38 #include <QVBarModelMapper>
39 39
40 40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
41 41
42 42 class ChartQmlPlugin : public QDeclarativeExtensionPlugin
43 43 {
44 44 Q_OBJECT
45 45 public:
46 46 virtual void registerTypes(const char *uri)
47 47 {
48 48 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
49 49
50 50 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView");
51 51 qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint");
52 52 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
53 53 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
54 54 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
55 55 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
56 56 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
57 57 qmlRegisterType<DeclarativeGroupedBarSeries>(uri, 1, 0, "GroupedBarSeries");
58 58 qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries");
59 59 qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries");
60 60 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
61 61 qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice");
62 62 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
63 63 qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper");
64 64 qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper");
65 65 qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper");
66 66 qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper");
67 67 qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper");
68 68 qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper");
69 69
70 70 qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend",
71 71 QLatin1String("Trying to create uncreatable: Legend."));
72 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "QXYSeries",
73 QLatin1String("Trying to create uncreatable: QXYSeries."));
72 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries",
73 QLatin1String("Trying to create uncreatable: XYSeries."));
74 74 qmlRegisterUncreatableType<QScatterSeries>(uri, 1, 0, "QScatterSeries",
75 75 QLatin1String("Trying to create uncreatable: QScatterSeries."));
76 76 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
77 77 QLatin1String("Trying to create uncreatable: QPieSeries."));
78 78 qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "QBarSet",
79 79 QLatin1String("Trying to create uncreatable: QBarSet."));
80 80 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
81 81 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
82 82 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
83 83 QLatin1String("Trying to create uncreatable: XYModelMapper."));
84 84 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
85 85 QLatin1String("Trying to create uncreatable: PieModelMapper."));
86 86 qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper",
87 87 QLatin1String("Trying to create uncreatable: BarModelMapper."));
88 88 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries",
89 89 QLatin1String("Trying to create uncreatable: AbstractSeries."));
90 90 qmlRegisterUncreatableType<QAxis>(uri, 1, 0, "Axis",
91 91 QLatin1String("Trying to create uncreatable: Axis."));
92 92 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
93 93 QLatin1String("Trying to create uncreatable: PieModelMapper."));
94 94 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
95 95 QLatin1String("Trying to create uncreatable: XYModelMapper."));
96 96 }
97 97 };
98 98
99 99 #include "plugin.moc"
100 100
101 101 QTCOMMERCIALCHART_END_NAMESPACE
102 102
103 103 QTCOMMERCIALCHART_USE_NAMESPACE
104 104
105 105 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
@@ -1,344 +1,385
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 "qareaseries.h"
22 22 #include "qareaseries_p.h"
23 23 #include "qlineseries.h"
24 24 #include "areachartitem_p.h"
25 25 #include "legendmarker_p.h"
26 26 #include "domain_p.h"
27 27 #include "chartdataset_p.h"
28 28 #include "charttheme_p.h"
29 29 #include "chartanimator_p.h"
30 30
31 31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32 32
33 33 /*!
34 34 \class QAreaSeries
35 35 \brief The QAreaSeries class is used for making area charts.
36 36
37 37 \mainclass
38 38
39 39 An area chart is used to show quantitative data. It is based on line chart, in the way that area between axis and the line
40 40 is emphasized with color. Since the area chart is based on line chart, QAreaSeries constructor needs QLineSeries instance,
41 41 which defines "upper" boundary of the area. "Lower" boundary is defined by default by axis X. Instead of axis X "lower" boundary can be specified by other line.
42 42 In that case QAreaSeries should be initiated with two QLineSerie instances. Please note terms "upper" and "lower" boundary can be misleading in cases
43 43 where "lower" boundary had bigger values than the "upper" one, however the main point that area between these two boundary lines will be filled.
44 44
45 45 See the \l {AreaChart Example} {area chart example} to learn how to create a simple area chart.
46 46 \image examples_areachart.png
47 47 */
48 /*!
49 \qmlclass AreaSeries QAreaSeries
50
51 The following QML shows how to create a simple area chart:
52 \snippet ../demos/qmlchart/qml/qmlchart/View4.qml 1
53 \beginfloatleft
54 \image demos_qmlchart4.png
55 \endfloat
56 \clearfloat
57 */
48 58
49 59 /*!
50 60 \property QAreaSeries::upperSeries
51 61 \brief The upper one of the two line series used to define area series boundaries.
52 62 */
63 /*!
64 \qmlproperty LineSeries AreaSeries::upperSeries
65 The upper one of the two line series used to define area series boundaries.
66 */
53 67
54 68 /*!
55 69 \property QAreaSeries::lowerSeries
56 70 The lower one of the two line series used to define are series boundaries. Note if
57 71 QAreaSeries was counstucted wihtout a\ lowerSeries this is null.
58 72 */
73 /*!
74 \qmlproperty LineSeries AreaSeries::lowerSeries
75 The lower one of the two line series used to define are series boundaries. Note if
76 AreaSeries was counstucted wihtout a\ lowerSeries this is null.
77 */
59 78
60 79 /*!
61 80 \property QAreaSeries::color
62 81 Fill (brush) color of the series. This is a convenience property for modifying the color of brush.
63 82 \sa QAreaSeries::brush()
64 83 */
84 /*!
85 \qmlproperty color AreaSeries::color
86 Fill (brush) color of the series.
87 */
65 88
66 89 /*!
67 90 \property QAreaSeries::borderColor
68 91 Line (pen) color of the series. This is a convenience property for modifying the color of pen.
69 92 \sa QAreaSeries::pen()
70 93 */
94 /*!
95 \qmlproperty color AreaSeries::borderColor
96 Line (pen) color of the series.
97 */
71 98
72 99 /*!
73 100 \fn QPen QAreaSeries::pen() const
74 101 \brief Returns the pen used to draw line for this series.
75 102 \sa setPen()
76 103 */
77 104
78 105 /*!
79 106 \fn QPen QAreaSeries::brush() const
80 107 \brief Returns the brush used to draw line for this series.
81 108 \sa setBrush()
82 109 */
83 110
84 111 /*!
85 112 \fn void QAreaSeries::colorChanged(QColor color)
86 113 \brief Signal is emitted when the fill (brush) color has changed to \a color.
87 114 */
115 /*!
116 \qmlsignal AreaSeries::colorChanged(color color)
117 Signal is emitted when the fill (brush) color has changed to \a color.
118 */
88 119
89 120 /*!
90 121 \fn void QAreaSeries::borderColorChanged(QColor color)
91 122 \brief Signal is emitted when the line (pen) color has changed to \a color.
92 123 */
93
94 124 /*!
95 \fn bool QAreaSeries::pointsVisible() const
96 \brief Returns if the points are drawn for this series.
97 \sa setPointsVisible()
125 \qmlsignal AreaSeries::borderColorChanged(color color)
126 Signal is emitted when the line (pen) color has changed to \a color.
98 127 */
99 128
100 129 /*!
101 130 \fn void QAreaSeries::clicked(const QPointF& point)
102 131 \brief Signal is emitted when user clicks the \a point on area chart.
103 132 */
133 /*!
134 \qmlsignal AreaSeries::clicked(QPointF point)
135 Signal is emitted when user clicks the \a point on area chart.
136 */
104 137
105 138 /*!
106 139 \fn void QAreaSeries::selected()
107
108 140 The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be
109 141 implemented by the user of QAreaSeries API.
110 142 */
143 /*!
144 \qmlsignal AreaSeries::selected()
145 The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be
146 implemented by the user of AreaSeries API.
147 */
111 148
112 149 /*!
113 150 \fn void QAreaSeriesPrivate::updated()
114 151 \brief \internal
115 152 */
116 153
117 154 /*!
118 155 Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a
119 156 upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead.
120 157 When series object is added to QChartView or QChart instance ownerships is transferred.
121 158 */
122 159 QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries)
123 160 : QAbstractSeries(*new QAreaSeriesPrivate(upperSeries,lowerSeries,this),upperSeries)
124 161 {
125 162 }
126 163
127 164 /*!
128 165 Constructs area series object without upper or lower series with \a parent object.
129 166 */
130 167 QAreaSeries::QAreaSeries(QObject *parent)
131 168 : QAbstractSeries(*new QAreaSeriesPrivate(0, 0, this), parent)
132 169 {
133 170 }
134 171
135 172 /*!
136 173 Destroys the object. Series added to QChartView or QChart instances are owned by those,
137 174 and are deleted when mentioned object are destroyed.
138 175 */
139 176 QAreaSeries::~QAreaSeries()
140 177 {
141 178 }
142 179
143 180 /*!
144 181 Returns QChartSeries::SeriesTypeArea.
145 182 */
146 183 QAbstractSeries::SeriesType QAreaSeries::type() const
147 184 {
148 185 return QAbstractSeries::SeriesTypeArea;
149 186 }
150 187
151 188 /*!
152 189 Sets the \a series that is to be used as the area chart upper series.
153 190 */
154 191 void QAreaSeries::setUpperSeries(QLineSeries* series)
155 192 {
156 193 Q_D(QAreaSeries);
157 194 d->m_upperSeries = series;
158 195 }
159 196
160 197 QLineSeries* QAreaSeries::upperSeries() const
161 198 {
162 199 Q_D(const QAreaSeries);
163 200 return d->m_upperSeries;
164 201 }
165 202
166 203 /*!
167 204 Sets the \a series that is to be used as the area chart lower series.
168 205 */
169 206 void QAreaSeries::setLowerSeries(QLineSeries* series)
170 207 {
171 208 Q_D(QAreaSeries);
172 209 d->m_lowerSeries = series;
173 210 }
174 211
175 212 QLineSeries* QAreaSeries::lowerSeries() const
176 213 {
177 214 Q_D(const QAreaSeries);
178 215 return d->m_lowerSeries;
179 216 }
180 217
181 218 /*!
182 219 Sets \a pen used for drawing area outline.
183 220 */
184 221 void QAreaSeries::setPen(const QPen &pen)
185 222 {
186 223 Q_D(QAreaSeries);
187 224 if (d->m_pen != pen) {
188 225 d->m_pen = pen;
189 226 emit d->updated();
190 227 }
191 228 }
192 229
193 230 QPen QAreaSeries::pen() const
194 231 {
195 232 Q_D(const QAreaSeries);
196 233 return d->m_pen;
197 234 }
198 235
199 236 /*!
200 237 Sets \a brush used for filling the area.
201 238 */
202 239 void QAreaSeries::setBrush(const QBrush &brush)
203 240 {
204 241 Q_D(QAreaSeries);
205 242 if (d->m_brush != brush) {
206 243 d->m_brush = brush;
207 244 emit d->updated();
208 245 }
209 246 }
210 247
211 248 QBrush QAreaSeries::brush() const
212 249 {
213 250 Q_D(const QAreaSeries);
214 251 return d->m_brush;
215 252 }
216 253
217 254 void QAreaSeries::setColor(const QColor &color)
218 255 {
219 256 QBrush b = brush();
220 257 if (b.color() != color) {
221 258 b.setColor(color);
222 259 setBrush(b);
223 260 emit colorChanged(color);
224 261 }
225 262 }
226 263
227 264 QColor QAreaSeries::color() const
228 265 {
229 266 return brush().color();
230 267 }
231 268
232 269 void QAreaSeries::setBorderColor(const QColor &color)
233 270 {
234 271 QPen p = pen();
235 272 if (p.color() != color) {
236 273 p.setColor(color);
237 274 setPen(p);
238 275 emit borderColorChanged(color);
239 276 }
240 277 }
241 278
242 279 QColor QAreaSeries::borderColor() const
243 280 {
244 281 return pen().color();
245 282 }
246 283
247 284 /*!
248 285 Sets if data points are \a visible and should be drawn on line.
249 286 */
250 287 void QAreaSeries::setPointsVisible(bool visible)
251 288 {
252 289 Q_D(QAreaSeries);
253 290 if (d->m_pointsVisible != visible) {
254 291 d->m_pointsVisible = visible;
255 292 emit d->updated();
256 293 }
257 294 }
258 295
296 /*!
297 Returns if the points are drawn for this series.
298 \sa setPointsVisible()
299 */
259 300 bool QAreaSeries::pointsVisible() const
260 301 {
261 302 Q_D(const QAreaSeries);
262 303 return d->m_pointsVisible;
263 304 }
264 305
265 306 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
266 307
267 308 QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q) :
268 309 QAbstractSeriesPrivate(q),
269 310 m_upperSeries(upperSeries),
270 311 m_lowerSeries(lowerSeries),
271 312 m_pointsVisible(false)
272 313 {
273 314 }
274 315
275 316 void QAreaSeriesPrivate::scaleDomain(Domain& domain)
276 317 {
277 318 Q_Q(QAreaSeries);
278 319
279 320 qreal minX(domain.minX());
280 321 qreal minY(domain.minY());
281 322 qreal maxX(domain.maxX());
282 323 qreal maxY(domain.maxY());
283 324 int tickXCount(domain.tickXCount());
284 325 int tickYCount(domain.tickYCount());
285 326
286 327 QLineSeries* upperSeries = q->upperSeries();
287 328 QLineSeries* lowerSeries = q->lowerSeries();
288 329
289 330 const QList<QPointF>& points = upperSeries->points();
290 331
291 332 for (int i = 0; i < points.count(); i++)
292 333 {
293 334 qreal x = points[i].x();
294 335 qreal y = points[i].y();
295 336 minX = qMin(minX, x);
296 337 minY = qMin(minY, y);
297 338 maxX = qMax(maxX, x);
298 339 maxY = qMax(maxY, y);
299 340 }
300 341 if(lowerSeries) {
301 342
302 343 const QList<QPointF>& points = lowerSeries->points();
303 344
304 345 for (int i = 0; i < points.count(); i++)
305 346 {
306 347 qreal x = points[i].x();
307 348 qreal y = points[i].y();
308 349 minX = qMin(minX, x);
309 350 minY = qMin(minY, y);
310 351 maxX = qMax(maxX, x);
311 352 maxY = qMax(maxY, y);
312 353 }}
313 354
314 355 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
315 356 }
316 357
317 358 Chart* QAreaSeriesPrivate::createGraphics(ChartPresenter* presenter)
318 359 {
319 360 Q_Q(QAreaSeries);
320 361
321 362 AreaChartItem* area = new AreaChartItem(q,presenter);
322 363 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
323 364 area->upperLineItem()->setAnimator(presenter->animator());
324 365 area->upperLineItem()->setAnimation(new XYAnimation(area->upperLineItem()));
325 366 if(q->lowerSeries()) {
326 367 area->lowerLineItem()->setAnimator(presenter->animator());
327 368 area->lowerLineItem()->setAnimation(new XYAnimation(area->lowerLineItem()));
328 369 }
329 370 }
330 371 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
331 372 return area;
332 373 }
333 374
334 375 QList<LegendMarker*> QAreaSeriesPrivate::createLegendMarker(QLegend* legend)
335 376 {
336 377 Q_Q(QAreaSeries);
337 378 QList<LegendMarker*> list;
338 379 return list << new AreaLegendMarker(q,legend);
339 380 }
340 381
341 382 #include "moc_qareaseries.cpp"
342 383 #include "moc_qareaseries_p.cpp"
343 384
344 385 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,123 +1,134
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 "qlineseries.h"
22 22 #include "qlineseries_p.h"
23 23 #include "linechartitem_p.h"
24 24 #include "chartdataset_p.h"
25 25 #include "charttheme_p.h"
26 26 #include "chartanimator_p.h"
27 27
28 28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 29
30 30 /*!
31 31 \class QLineSeries
32 32 \brief The QLineSeries class is used for making line charts.
33 33
34 34 \mainclass
35 35
36 36 A line chart is used to show information as a series of data points
37 37 connected by straight lines.
38 38
39 39 \image examples_linechart.png
40 40
41 41 Creating basic line chart is simple:
42 42 \code
43 43 QLineSeries* series = new QLineSeries();
44 44 series->append(0, 6);
45 45 series->append(2, 4);
46 46 ...
47 47 chart->addSeries(series);
48 48 \endcode
49 49 */
50 /*!
51 \qmlclass LineSeries QLineSeries
52 \inherits XYSeries
53
54 The following QML shows how to create a simple line chart:
55 \snippet ../demos/qmlchart/qml/qmlchart/View2.qml 1
56 \beginfloatleft
57 \image demos_qmlchart2.png
58 \endfloat
59 \clearfloat
60 */
50 61
51 62 /*!
52 63 \fn virtual SeriesType QLineSeries::type() const
53 64 \brief Returns type of series.
54 65 \sa QAbstractSeries, SeriesType
55 66 */
56 67
57 68 /*!
58 69 Constructs empty series object which is a child of \a parent.
59 70 When series object is added to QChartView or QChart instance ownerships is transferred.
60 71 */
61 72 QLineSeries::QLineSeries(QObject *parent) : QXYSeries(*new QLineSeriesPrivate(this),parent)
62 73 {
63 74
64 75 }
65 76
66 77 /*!
67 78 \internal
68 79 */
69 80 QLineSeries::QLineSeries(QLineSeriesPrivate &d,QObject *parent) : QXYSeries (d,parent)
70 81 {
71 82
72 83 }
73 84 /*!
74 85 Destroys the object. Series added to QChartView or QChart instances are owned by those,
75 86 and are deleted when mentioned object are destroyed.
76 87 */
77 88 QLineSeries::~QLineSeries()
78 89 {
79 90 Q_D(QLineSeries);
80 91 if(d->m_dataset){
81 92 d->m_dataset->removeSeries(this);
82 93 }
83 94 }
84 95
85 96 QAbstractSeries::SeriesType QLineSeries::type() const
86 97 {
87 98 return QAbstractSeries::SeriesTypeLine;
88 99 }
89 100
90 101 /*
91 102 QDebug operator<< (QDebug debug, const QLineSeries series)
92 103 {
93 104 Q_ASSERT(series.d_func()->m_x.size() == series.d_func()->m_y.size());
94 105 int size = series.d_func()->m_x.size();
95 106 for (int i=0; i<size; i++) {
96 107 debug.nospace() << "(" << series.d_func()->m_x.at(i) << ','<< series.d_func()->m_y.at(i) << ") ";
97 108 }
98 109 return debug.space();
99 110 }
100 111 */
101 112
102 113 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
103 114
104 115 QLineSeriesPrivate::QLineSeriesPrivate(QLineSeries* q):QXYSeriesPrivate(q)
105 116 {
106 117
107 118 };
108 119
109 120 Chart* QLineSeriesPrivate::createGraphics(ChartPresenter* presenter)
110 121 {
111 122 Q_Q(QLineSeries);
112 123 LineChartItem* line = new LineChartItem(q,presenter);
113 124 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
114 125 line->setAnimator(presenter->animator());
115 126 line->setAnimation(new XYAnimation(line));
116 127 }
117 128 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
118 129 return line;
119 130 }
120 131
121 132 #include "moc_qlineseries.cpp"
122 133
123 134 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,632 +1,654
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 "qpieseries.h"
22 22 #include "qpieseries_p.h"
23 23 #include "qpieslice.h"
24 24 #include "qpieslice_p.h"
25 25 #include "pieslicedata_p.h"
26 26 #include "chartdataset_p.h"
27 27 #include "charttheme_p.h"
28 28 #include "chartanimator_p.h"
29 29 #include "legendmarker_p.h"
30 30
31 31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32 32
33 33 /*!
34 34 \class QPieSeries
35 35 \brief Pie series API for QtCommercial Charts
36 36
37 37 The pie series defines a pie chart which consists of pie slices which are defined as QPieSlice objects.
38 38 The slices can have any values as the QPieSeries will calculate its relative value to the sum of all slices.
39 39 The actual slice size is determined by that relative value.
40 40
41 41 Pie size and position on the chart is controlled by using relative values which range from 0.0 to 1.0
42 42 These relate to the actual chart rectangle.
43 43
44 44 By default the pie is defined as a full pie but it can also be a partial pie.
45 45 This can be done by setting a starting angle and angle span to the series.
46 46 Full pie is 360 degrees where 0 is at 12 a'clock.
47 47
48 48 See the \l {PieChart Example} {pie chart example} to learn how to create a simple pie chart.
49 49 \image examples_piechart.png
50 50 */
51 /*!
52 \qmlclass PieSeries QPieSeries
53
54 The following QML shows how to create a simple pie chart.
55 \snippet ../demos/qmlchart/qml/qmlchart/View1.qml 1
56 \beginfloatleft
57 \image demos_qmlchart1.png
58 \endfloat
59 \clearfloat
60 */
51 61
52 62 /*!
53 63 \property QPieSeries::horizontalPosition
54 64 \brief Defines the horizontal position of the pie.
55
56 65 The value is a relative value to the chart rectangle where:
57
58 66 \list
59 67 \o 0.0 is the absolute left.
60 68 \o 1.0 is the absolute right.
61 69 \endlist
62
63 70 Default value is 0.5 (center).
64
71 \sa verticalPosition
72 */
73 /*!
74 \qmlproperty real PieSeries::horizontalPosition
75 Defines the horizontal position of the pie. The value is a relative value to the chart rectangle where:
76 \list
77 \o 0.0 is the absolute left.
78 \o 1.0 is the absolute right.
79 \endlist
80 Default value is 0.5 (center).
65 81 \sa verticalPosition
66 82 */
67 83
68 84 /*!
69 85 \property QPieSeries::verticalPosition
70 86 \brief Defines the vertical position of the pie.
71
72 87 The value is a relative value to the chart rectangle where:
73
74 88 \list
75 89 \o 0.0 is the absolute top.
76 90 \o 1.0 is the absolute bottom.
77 91 \endlist
78
79 92 Default value is 0.5 (center).
80
93 \sa horizontalPosition
94 */
95 /*!
96 \qmlproperty real PieSeries::verticalPosition
97 Defines the vertical position of the pie. The value is a relative value to the chart rectangle where:
98 \list
99 \o 0.0 is the absolute top.
100 \o 1.0 is the absolute bottom.
101 \endlist
102 Default value is 0.5 (center).
81 103 \sa horizontalPosition
82 104 */
83 105
84 106 /*!
85 107 \property QPieSeries::size
86 108 \brief Defines the pie size.
87 109
88 110 The value is a relative value to the chart rectangle where:
89 111
90 112 \list
91 113 \o 0.0 is the minimum size (pie not drawn).
92 114 \o 1.0 is the maximum size that can fit the chart.
93 115 \endlist
94 116
95 117 Default value is 0.7.
96 118 */
97 119
98 120 /*!
99 121 \property QPieSeries::startAngle
100 122 \brief Defines the starting angle of the pie.
101 123
102 124 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
103 125
104 126 Default is value is 0.
105 127 */
106 128
107 129 /*!
108 130 \property QPieSeries::endAngle
109 131 \brief Defines the ending angle of the pie.
110 132
111 133 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
112 134
113 135 Default is value is 360.
114 136 */
115 137
116 138 /*!
117 139 \property QPieSeries::count
118 140
119 141 Number of slices in the series.
120 142 */
121 143
122 144 /*!
123 145 \fn void QPieSeries::countChanged()
124 146
125 147 Emitted when the slice count has changed.
126 148
127 149 \sa count
128 150 */
129 151
130 152 /*!
131 153 \property QPieSeries::sum
132 154
133 155 Sum of all slices.
134 156
135 157 The series keeps track of the sum of all slices it holds.
136 158 */
137 159
138 160 /*!
139 161 \fn void QPieSeries::sumChanged()
140 162
141 163 Emitted when the sum of all slices has changed.
142 164
143 165 \sa sum
144 166 */
145 167
146 168 /*!
147 169 \fn void QPieSeries::added(QList<QPieSlice*> slices)
148 170
149 171 This signal is emitted when \a slices have been added to the series.
150 172
151 173 \sa append(), insert()
152 174 */
153 175
154 176 /*!
155 177 \fn void QPieSeries::removed(QList<QPieSlice*> slices)
156 178
157 179 This signal is emitted when \a slices have been removed from the series.
158 180
159 181 \sa remove()
160 182 */
161 183
162 184 /*!
163 185 \fn void QPieSeries::clicked(QPieSlice* slice)
164 186
165 187 This signal is emitted when a \a slice has been clicked.
166 188
167 189 \sa QPieSlice::clicked()
168 190 */
169 191
170 192 /*!
171 193 \fn void QPieSeries::hovered(QPieSlice* slice, bool state)
172 194
173 195 This signal is emitted when user has hovered over or away from the \a slice.
174 196
175 197 \a state is true when user has hovered over the slice and false when hover has moved away from the slice.
176 198
177 199 \sa QPieSlice::hovered()
178 200 */
179 201
180 202 /*!
181 203 Constructs a series object which is a child of \a parent.
182 204 */
183 205 QPieSeries::QPieSeries(QObject *parent) :
184 206 QAbstractSeries(*new QPieSeriesPrivate(this),parent)
185 207 {
186 208
187 209 }
188 210
189 211 /*!
190 212 Destroys the series and its slices.
191 213 */
192 214 QPieSeries::~QPieSeries()
193 215 {
194 216 // NOTE: d_prt destroyed by QObject
195 217 }
196 218
197 219 /*!
198 220 Returns QChartSeries::SeriesTypePie.
199 221 */
200 222 QAbstractSeries::SeriesType QPieSeries::type() const
201 223 {
202 224 return QAbstractSeries::SeriesTypePie;
203 225 }
204 226
205 227 /*!
206 228 Appends a single \a slice to the series.
207 229 Slice ownership is passed to the series.
208 230
209 231 Returns true if append was succesfull.
210 232 */
211 233 bool QPieSeries::append(QPieSlice* slice)
212 234 {
213 235 return append(QList<QPieSlice*>() << slice);
214 236 }
215 237
216 238 /*!
217 239 Appends an array of \a slices to the series.
218 240 Slice ownership is passed to the series.
219 241
220 242 Returns true if append was successfull.
221 243 */
222 244 bool QPieSeries::append(QList<QPieSlice*> slices)
223 245 {
224 246 Q_D(QPieSeries);
225 247
226 248 if (slices.count() == 0)
227 249 return false;
228 250
229 251 foreach (QPieSlice* s, slices) {
230 252 if (!s || d->m_slices.contains(s))
231 253 return false;
232 254 if (s->series()) // already added to some series
233 255 return false;
234 256 }
235 257
236 258 foreach (QPieSlice* s, slices) {
237 259 s->setParent(this);
238 260 QPieSlicePrivate::fromSlice(s)->m_series = this;
239 261 d->m_slices << s;
240 262 }
241 263
242 264 d->updateDerivativeData();
243 265
244 266 foreach (QPieSlice* s, slices) {
245 267 connect(s, SIGNAL(valueChanged()), d, SLOT(sliceValueChanged()));
246 268 connect(s, SIGNAL(clicked()), d, SLOT(sliceClicked()));
247 269 connect(s, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool)));
248 270 }
249 271
250 272 emit added(slices);
251 273 emit countChanged();
252 274
253 275 return true;
254 276 }
255 277
256 278 /*!
257 279 Appends a single \a slice to the series and returns a reference to the series.
258 280 Slice ownership is passed to the series.
259 281 */
260 282 QPieSeries& QPieSeries::operator << (QPieSlice* slice)
261 283 {
262 284 append(slice);
263 285 return *this;
264 286 }
265 287
266 288
267 289 /*!
268 290 Appends a single slice to the series with give \a value and \a label.
269 291 Slice ownership is passed to the series.
270 292 */
271 293 QPieSlice* QPieSeries::append(QString label, qreal value)
272 294 {
273 295 QPieSlice* slice = new QPieSlice(label, value);
274 296 append(slice);
275 297 return slice;
276 298 }
277 299
278 300 /*!
279 301 Inserts a single \a slice to the series before the slice at \a index position.
280 302 Slice ownership is passed to the series.
281 303
282 304 Returns true if insert was successfull.
283 305 */
284 306 bool QPieSeries::insert(int index, QPieSlice* slice)
285 307 {
286 308 Q_D(QPieSeries);
287 309
288 310 if (index < 0 || index > d->m_slices.count())
289 311 return false;
290 312
291 313 if (!slice || d->m_slices.contains(slice))
292 314 return false;
293 315
294 316 if (slice->series()) // already added to some series
295 317 return false;
296 318
297 319 slice->setParent(this);
298 320 QPieSlicePrivate::fromSlice(slice)->m_series = this;
299 321 d->m_slices.insert(index, slice);
300 322
301 323 d->updateDerivativeData();
302 324
303 325 connect(slice, SIGNAL(valueChanged()), d, SLOT(sliceValueChanged()));
304 326 connect(slice, SIGNAL(clicked()), d, SLOT(sliceClicked()));
305 327 connect(slice, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool)));
306 328
307 329 emit added(QList<QPieSlice*>() << slice);
308 330 emit countChanged();
309 331
310 332 return true;
311 333 }
312 334
313 335 /*!
314 336 Removes a single \a slice from the series and deletes the slice.
315 337
316 338 Do not reference the pointer after this call.
317 339
318 340 Returns true if remove was successfull.
319 341 */
320 342 bool QPieSeries::remove(QPieSlice* slice)
321 343 {
322 344 Q_D(QPieSeries);
323 345
324 346 if (!d->m_slices.removeOne(slice))
325 347 return false;
326 348
327 349 d->updateDerivativeData();
328 350
329 351 emit removed(QList<QPieSlice*>() << slice);
330 352 emit countChanged();
331 353
332 354 delete slice;
333 355 slice = 0;
334 356
335 357 return true;
336 358 }
337 359
338 360 /*!
339 361 Clears all slices from the series.
340 362 */
341 363 void QPieSeries::clear()
342 364 {
343 365 Q_D(QPieSeries);
344 366 if (d->m_slices.count() == 0)
345 367 return;
346 368
347 369 QList<QPieSlice*> slices = d->m_slices;
348 370 foreach (QPieSlice* s, d->m_slices) {
349 371 d->m_slices.removeOne(s);
350 372 delete s;
351 373 }
352 374
353 375 d->updateDerivativeData();
354 376
355 377 emit removed(slices);
356 378 emit countChanged();
357 379 }
358 380
359 381 /*!
360 382 Returns a list of slices that belong to this series.
361 383 */
362 384 QList<QPieSlice*> QPieSeries::slices() const
363 385 {
364 386 Q_D(const QPieSeries);
365 387 return d->m_slices;
366 388 }
367 389
368 390 /*!
369 391 returns the number of the slices in this series.
370 392 */
371 393 int QPieSeries::count() const
372 394 {
373 395 Q_D(const QPieSeries);
374 396 return d->m_slices.count();
375 397 }
376 398
377 399 /*!
378 400 Returns true is the series is empty.
379 401 */
380 402 bool QPieSeries::isEmpty() const
381 403 {
382 404 Q_D(const QPieSeries);
383 405 return d->m_slices.isEmpty();
384 406 }
385 407
386 408 /*!
387 409 Returns the sum of all slice values in this series.
388 410
389 411 \sa QPieSlice::value(), QPieSlice::setValue(), QPieSlice::percentage()
390 412 */
391 413 qreal QPieSeries::sum() const
392 414 {
393 415 Q_D(const QPieSeries);
394 416 return d->m_sum;
395 417 }
396 418
397 419 void QPieSeries::setHorizontalPosition(qreal relativePosition)
398 420 {
399 421 Q_D(QPieSeries);
400 422
401 423 if (relativePosition < 0.0)
402 424 relativePosition = 0.0;
403 425 if (relativePosition > 1.0)
404 426 relativePosition = 1.0;
405 427
406 428 if (!qFuzzyIsNull(d->m_pieRelativeHorPos - relativePosition)) {
407 429 d->m_pieRelativeHorPos = relativePosition;
408 430 emit d->horizontalPositionChanged();
409 431 }
410 432 }
411 433
412 434 qreal QPieSeries::horizontalPosition() const
413 435 {
414 436 Q_D(const QPieSeries);
415 437 return d->m_pieRelativeHorPos;
416 438 }
417 439
418 440 void QPieSeries::setVerticalPosition(qreal relativePosition)
419 441 {
420 442 Q_D(QPieSeries);
421 443
422 444 if (relativePosition < 0.0)
423 445 relativePosition = 0.0;
424 446 if (relativePosition > 1.0)
425 447 relativePosition = 1.0;
426 448
427 449 if (!qFuzzyIsNull(d->m_pieRelativeVerPos - relativePosition)) {
428 450 d->m_pieRelativeVerPos = relativePosition;
429 451 emit d->verticalPositionChanged();
430 452 }
431 453 }
432 454
433 455 qreal QPieSeries::verticalPosition() const
434 456 {
435 457 Q_D(const QPieSeries);
436 458 return d->m_pieRelativeVerPos;
437 459 }
438 460
439 461 void QPieSeries::setPieSize(qreal relativeSize)
440 462 {
441 463 Q_D(QPieSeries);
442 464
443 465 if (relativeSize < 0.0)
444 466 relativeSize = 0.0;
445 467 if (relativeSize > 1.0)
446 468 relativeSize = 1.0;
447 469
448 470 if (!qFuzzyIsNull(d->m_pieRelativeSize - relativeSize)) {
449 471 d->m_pieRelativeSize = relativeSize;
450 472 emit d->pieSizeChanged();
451 473 }
452 474 }
453 475
454 476 qreal QPieSeries::pieSize() const
455 477 {
456 478 Q_D(const QPieSeries);
457 479 return d->m_pieRelativeSize;
458 480 }
459 481
460 482
461 483 void QPieSeries::setPieStartAngle(qreal angle)
462 484 {
463 485 Q_D(QPieSeries);
464 486 if (qFuzzyIsNull(d->m_pieStartAngle - angle))
465 487 return;
466 488 d->m_pieStartAngle = angle;
467 489 d->updateDerivativeData();
468 490 emit d->pieStartAngleChanged();
469 491 }
470 492
471 493 qreal QPieSeries::pieStartAngle() const
472 494 {
473 495 Q_D(const QPieSeries);
474 496 return d->m_pieStartAngle;
475 497 }
476 498
477 499 /*!
478 500 Sets the end angle of the pie.
479 501
480 502 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
481 503
482 504 \a angle must be greater than start angle.
483 505
484 506 \sa pieEndAngle(), pieStartAngle(), setPieStartAngle()
485 507 */
486 508 void QPieSeries::setPieEndAngle(qreal angle)
487 509 {
488 510 Q_D(QPieSeries);
489 511 if (qFuzzyIsNull(d->m_pieEndAngle - angle))
490 512 return;
491 513 d->m_pieEndAngle = angle;
492 514 d->updateDerivativeData();
493 515 emit d->pieEndAngleChanged();
494 516 }
495 517
496 518 /*!
497 519 Returns the end angle of the pie.
498 520
499 521 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
500 522
501 523 \sa setPieEndAngle(), pieStartAngle(), setPieStartAngle()
502 524 */
503 525 qreal QPieSeries::pieEndAngle() const
504 526 {
505 527 Q_D(const QPieSeries);
506 528 return d->m_pieEndAngle;
507 529 }
508 530
509 531 /*!
510 532 Sets the all the slice labels \a visible or invisible.
511 533
512 534 Note that this affects only the current slices in the series.
513 535 If user adds a new slice the default label visibility is false.
514 536
515 537 \sa QPieSlice::isLabelVisible(), QPieSlice::setLabelVisible()
516 538 */
517 539 void QPieSeries::setLabelsVisible(bool visible)
518 540 {
519 541 Q_D(QPieSeries);
520 542 foreach (QPieSlice* s, d->m_slices)
521 543 s->setLabelVisible(visible);
522 544 }
523 545
524 546 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
525 547
526 548
527 549 QPieSeriesPrivate::QPieSeriesPrivate(QPieSeries *parent) :
528 550 QAbstractSeriesPrivate(parent),
529 551 m_pieRelativeHorPos(0.5),
530 552 m_pieRelativeVerPos(0.5),
531 553 m_pieRelativeSize(0.7),
532 554 m_pieStartAngle(0),
533 555 m_pieEndAngle(360),
534 556 m_sum(0)
535 557 {
536 558 }
537 559
538 560 QPieSeriesPrivate::~QPieSeriesPrivate()
539 561 {
540 562 }
541 563
542 564 void QPieSeriesPrivate::updateDerivativeData()
543 565 {
544 566 // calculate sum of all slices
545 567 qreal sum = 0;
546 568 foreach (QPieSlice* s, m_slices)
547 569 sum += s->value();
548 570
549 571 if (!qFuzzyIsNull(m_sum - sum)) {
550 572 m_sum = sum;
551 573 emit q_func()->sumChanged();
552 574 }
553 575
554 576 // nothing to show..
555 577 if (qFuzzyIsNull(m_sum))
556 578 return;
557 579
558 580 // update slice attributes
559 581 qreal sliceAngle = m_pieStartAngle;
560 582 qreal pieSpan = m_pieEndAngle - m_pieStartAngle;
561 583 QVector<QPieSlice*> changed;
562 584 foreach (QPieSlice* s, m_slices) {
563 585 QPieSlicePrivate *d = QPieSlicePrivate::fromSlice(s);
564 586 d->setPercentage(s->value() / m_sum);
565 587 d->setStartAngle(sliceAngle);
566 588 d->setAngleSpan(pieSpan * s->percentage());
567 589 sliceAngle += s->angleSpan();
568 590 }
569 591
570 592
571 593 emit calculatedDataChanged();
572 594 }
573 595
574 596 QPieSeriesPrivate* QPieSeriesPrivate::fromSeries(QPieSeries *series)
575 597 {
576 598 return series->d_func();
577 599 }
578 600
579 601 void QPieSeriesPrivate::sliceValueChanged()
580 602 {
581 603 Q_ASSERT(m_slices.contains(qobject_cast<QPieSlice *>(sender())));
582 604 updateDerivativeData();
583 605 }
584 606
585 607 void QPieSeriesPrivate::sliceClicked()
586 608 {
587 609 QPieSlice* slice = qobject_cast<QPieSlice *>(sender());
588 610 Q_ASSERT(m_slices.contains(slice));
589 611 Q_Q(QPieSeries);
590 612 emit q->clicked(slice);
591 613 }
592 614
593 615 void QPieSeriesPrivate::sliceHovered(bool state)
594 616 {
595 617 QPieSlice* slice = qobject_cast<QPieSlice *>(sender());
596 618 Q_ASSERT(m_slices.contains(slice));
597 619 Q_Q(QPieSeries);
598 620 emit q->hovered(slice, state);
599 621 }
600 622
601 623 void QPieSeriesPrivate::scaleDomain(Domain& domain)
602 624 {
603 625 Q_UNUSED(domain);
604 626 // does not apply to pie
605 627 }
606 628
607 629 Chart* QPieSeriesPrivate::createGraphics(ChartPresenter* presenter)
608 630 {
609 631 Q_Q(QPieSeries);
610 632 PieChartItem* pie = new PieChartItem(q,presenter);
611 633 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
612 634 presenter->animator()->addAnimation(pie);
613 635 }
614 636 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
615 637 return pie;
616 638 }
617 639
618 640 QList<LegendMarker*> QPieSeriesPrivate::createLegendMarker(QLegend* legend)
619 641 {
620 642 Q_Q(QPieSeries);
621 643 QList<LegendMarker*> markers;
622 644 foreach(QPieSlice* slice, q->slices()) {
623 645 PieLegendMarker* marker = new PieLegendMarker(q,slice,legend);
624 646 markers << marker;
625 647 }
626 648 return markers;
627 649 }
628 650
629 651 #include "moc_qpieseries.cpp"
630 652 #include "moc_qpieseries_p.cpp"
631 653
632 654 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,207 +1,232
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 "qscatterseries.h"
22 22 #include "qscatterseries_p.h"
23 23 #include "scatterchartitem_p.h"
24 24 #include "chartdataset_p.h"
25 25 #include "charttheme_p.h"
26 26 #include "chartanimator_p.h"
27 27
28 28 /*!
29 29 \class QScatterSeries
30 30 \brief The QScatterSeries class is used for making scatter charts.
31 31
32 32 \mainclass
33 33
34 34 The scatter data is displayed as a collection of points on the chart. Each point determines the position on the horizontal axis
35 35 and the vertical axis.
36 36
37 37 \image examples_scatterchart.png
38 38
39 39 Creating basic scatter chart is simple:
40 40 \code
41 41 QScatterSeries* series = new QScatterSeries();
42 42 series->append(0, 6);
43 43 series->append(2, 4);
44 44 ...
45 45 chart->addSeries(series);
46 46 \endcode
47 47 */
48 /*!
49 \qmlclass ScatterSeries QScatterSeries
50 \inherits XYSeries
51
52 The following QML shows how to create a chart with two simple scatter series:
53 \snippet ../demos/qmlchart/qml/qmlchart/View5.qml 1
54 \snippet ../demos/qmlchart/qml/qmlchart/View5.qml 2
55
56 \beginfloatleft
57 \image demos_qmlchart5.png
58 \endfloat
59 \clearfloat
60 */
48 61
49 62 /*!
50 63 \enum QScatterSeries::MarkerShape
51 64
52 65 This enum describes the shape used when rendering marker items.
53 66
54 67 \value MarkerShapeCircle
55 68 \value MarkerShapeRectangle
56 69 */
57 70
58 71 /*!
59 72 \property QScatterSeries::color
60 73 Fill (brush) color of the series. This is a convenience property for modifying the color of brush.
61 74 \sa QScatterSeries::brush()
62 75 */
63 76
64 77 /*!
65 78 \property QScatterSeries::borderColor
66 79 Line (pen) color of the series. This is a convenience property for modifying the color of pen.
67 80 \sa QScatterSeries::pen()
68 81 */
69 82
70 83 /*!
71 \property QScatterSeries::markerShape
72
73 Defines the shape of the marker used to draw the points in the series. The default shape is MarkerShapeCircle.
84 \property QScatterSeries::markerShape
85 Defines the shape of the marker used to draw the points in the series. The default shape is MarkerShapeCircle.
74 86 */
75
76 87 /*!
77 \property QScatterSeries::markerSize
88 \qmlproperty MarkerShape ScatterSeries::markerShape
89 Defines the shape of the marker used to draw the points in the series. One of ScatterSeries
90 ScatterSeries.MarkerShapeCircle or ScatterSeries.MarkerShapeRectangle.
91 The default shape is ScatterSeries.MarkerShapeCircle.
92 */
78 93
79 Defines the size of the marker used to draw the points in the series. The default size is 15.0.
94 /*!
95 \property QScatterSeries::markerSize
96 Defines the size of the marker used to draw the points in the series. The default size is 15.0.
97 */
98 /*!
99 \qmlproperty real ScatterSeries::markerSize
100 Defines the size of the marker used to draw the points in the series. The default size is 15.0.
80 101 */
81 102
82 103 /*!
83 104 \fn void QScatterSeries::colorChanged(QColor color)
84 \brief Signal is emitted when the fill (brush) color has changed to \a color.
105 Signal is emitted when the fill (brush) color has changed to \a color.
85 106 */
86 107
87 108 /*!
88 109 \fn void QScatterSeries::borderColorChanged(QColor color)
89 \brief Signal is emitted when the line (pen) color has changed to \a color.
110 Signal is emitted when the line (pen) color has changed to \a color.
111 */
112 /*!
113 \qmlsignal ScatterSeries::borderColorChanged(color color)
114 Signal is emitted when the line (pen) color has changed to \a color.
90 115 */
91 116
92 117 /*!
93 118 \fn QChartSeriesType QScatterSeries::type() const
94 \brief Returns QChartSeries::SeriesTypeScatter.
119 Returns QChartSeries::SeriesTypeScatter.
95 120 \sa QAbstractSeries, SeriesType
96 121 */
97 122
98 123 QTCOMMERCIALCHART_BEGIN_NAMESPACE
99 124
100 125 /*!
101 126 Constructs a series object which is a child of \a parent.
102 127 */
103 128 QScatterSeries::QScatterSeries(QObject *parent) : QXYSeries(*new QScatterSeriesPrivate(this),parent)
104 129 {
105 130 }
106 131
107 132 /*!
108 133 Destroys the object. Note that adding series to QChart transfers the ownership to the chart.
109 134 */
110 135 QScatterSeries::~QScatterSeries()
111 136 {
112 137 Q_D(QScatterSeries);
113 138 if(d->m_dataset) {
114 139 d->m_dataset->removeSeries(this);
115 140 }
116 141 }
117 142
118 143 QAbstractSeries::SeriesType QScatterSeries::type() const
119 144 {
120 145 return QAbstractSeries::SeriesTypeScatter;
121 146 }
122 147
123 148 void QScatterSeries::setColor(const QColor &color)
124 149 {
125 150 QBrush b = brush();
126 151 if (b.color() != color) {
127 152 b.setColor(color);
128 153 setBrush(b);
129 154 emit colorChanged(color);
130 155 }
131 156 }
132 157
133 158 QColor QScatterSeries::color() const
134 159 {
135 160 return brush().color();
136 161 }
137 162
138 163 void QScatterSeries::setBorderColor(const QColor &color)
139 164 {
140 165 QPen p = pen();
141 166 if (p.color() != color) {
142 167 p.setColor(color);
143 168 setPen(p);
144 169 emit borderColorChanged(color);
145 170 }
146 171 }
147 172
148 173 QColor QScatterSeries::borderColor() const
149 174 {
150 175 return pen().color();
151 176 }
152 177
153 178 QScatterSeries::MarkerShape QScatterSeries::markerShape() const
154 179 {
155 180 Q_D(const QScatterSeries);
156 181 return d->m_shape;
157 182 }
158 183
159 184 void QScatterSeries::setMarkerShape(MarkerShape shape)
160 185 {
161 186 Q_D(QScatterSeries);
162 187 if (d->m_shape != shape) {
163 188 d->m_shape = shape;
164 189 emit d->updated();
165 190 }
166 191 }
167 192
168 193 qreal QScatterSeries::markerSize() const
169 194 {
170 195 Q_D(const QScatterSeries);
171 196 return d->m_size;
172 197 }
173 198
174 199 void QScatterSeries::setMarkerSize(qreal size)
175 200 {
176 201 Q_D(QScatterSeries);
177 202
178 203 if (!qFuzzyIsNull(d->m_size - size)) {
179 204 d->m_size = size;
180 205 emit d->updated();
181 206 }
182 207 }
183 208
184 209 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
185 210
186 211 QScatterSeriesPrivate::QScatterSeriesPrivate(QScatterSeries* q):QXYSeriesPrivate(q),
187 212 m_shape(QScatterSeries::MarkerShapeCircle),
188 213 m_size(15.0)
189 214 {
190 215
191 216 };
192 217
193 218 Chart* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter)
194 219 {
195 220 Q_Q(QScatterSeries);
196 221 ScatterChartItem *scatter = new ScatterChartItem(q,presenter);
197 222 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
198 223 scatter->setAnimator(presenter->animator());
199 224 scatter->setAnimation(new XYAnimation(scatter));
200 225 }
201 226 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
202 227 return scatter;
203 228 }
204 229
205 230 #include "moc_qscatterseries.cpp"
206 231
207 232 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,224 +1,236
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 "qsplineseries.h"
22 22 #include "qsplineseries_p.h"
23 23 #include "splinechartitem_p.h"
24 24 #include "chartdataset_p.h"
25 25 #include "charttheme_p.h"
26 26 #include "chartanimator_p.h"
27 27
28 28 /*!
29 29 \class QSplineSeries
30 30 \brief Series type used to store data needed to draw a spline.
31 31
32 32 QSplineSeries stores the data points along with the segment control points needed by QPainterPath to draw spline
33 33 Control points are automatically calculated when data changes. The algorithm computes the points so that the normal spline can be drawn.
34 34
35 35 \image examples_splinechart.png
36 36
37 37 Creating basic spline chart is simple:
38 38 \code
39 39 QSplineSeries* series = new QSplineSeries();
40 40 series->append(0, 6);
41 41 series->append(2, 4);
42 42 ...
43 43 chart->addSeries(series);
44 44 \endcode
45 45 */
46 46
47 47 /*!
48 \fn QSeriesType QSplineSeries::type() const
49 Returns the type of the series
50 */
48 \qmlclass SplineSeries QSplineSeries
49 \inherits XYSeries
50
51 The following QML shows how to create a simple spline chart:
52 \snippet ../demos/qmlchart/qml/qmlchart/View3.qml 1
53 \beginfloatleft
54 \image demos_qmlchart3.png
55 \endfloat
56 \clearfloat
57 */
58
59 /*!
60 \fn QSeriesType QSplineSeries::type() const
61 Returns the type of the series
62 */
51 63
52 64 QTCOMMERCIALCHART_BEGIN_NAMESPACE
53 65
54 66 /*!
55 67 Constructs empty series object which is a child of \a parent.
56 68 When series object is added to QChartView or QChart instance then the ownerships is transferred.
57 69 */
58 70
59 71 QSplineSeries::QSplineSeries(QObject *parent) :
60 72 QLineSeries(*new QSplineSeriesPrivate(this),parent)
61 73 {
62 74 Q_D(QSplineSeries);
63 75 QObject::connect(this,SIGNAL(pointAdded(int)), d, SLOT(updateControlPoints()));
64 76 QObject::connect(this,SIGNAL(pointRemoved(int)), d, SLOT(updateControlPoints()));
65 77 QObject::connect(this,SIGNAL(pointReplaced(int)), d, SLOT(updateControlPoints()));
66 78 }
67 79
68 80 /*!
69 81 Destroys the object.
70 82 */
71 83 QSplineSeries::~QSplineSeries()
72 84 {
73 85 Q_D(QSplineSeries);
74 86 if(d->m_dataset){
75 87 d->m_dataset->removeSeries(this);
76 88 }
77 89 }
78 90
79 91 QAbstractSeries::SeriesType QSplineSeries::type() const
80 92 {
81 93 return QAbstractSeries::SeriesTypeSpline;
82 94 }
83 95
84 96 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
85 97
86 98 QSplineSeriesPrivate::QSplineSeriesPrivate(QSplineSeries* q):QLineSeriesPrivate(q)
87 99 {
88 100 }
89 101
90 102 /*!
91 103 Calculates control points which are needed by QPainterPath.cubicTo function to draw the cubic Bezier cureve between two points.
92 104 */
93 105 void QSplineSeriesPrivate::calculateControlPoints()
94 106 {
95 107 Q_Q(QSplineSeries);
96 108
97 109 const QList<QPointF>& points = q->points();
98 110
99 111 int n = points.count() - 1;
100 112
101 113 if (n == 1)
102 114 {
103 115 //for n==1
104 116 m_controlPoints[0].setX((2 * points[0].x() + points[1].x()) / 3);
105 117 m_controlPoints[0].setY((2 * points[0].y() + points[1].y()) / 3);
106 118 m_controlPoints[1].setX(2 * m_controlPoints[0].x() - points[0].x());
107 119 m_controlPoints[1].setY(2 * m_controlPoints[0].y() - points[0].y());
108 120 return;
109 121 }
110 122
111 123 // Calculate first Bezier control points
112 124 // Set of equations for P0 to Pn points.
113 125 //
114 126 // | 2 1 0 0 ... 0 0 0 ... 0 0 0 | | P1_1 | | P0 + 2 * P1 |
115 127 // | 1 4 1 0 ... 0 0 0 ... 0 0 0 | | P1_2 | | 4 * P1 + 2 * P2 |
116 128 // | 0 1 4 1 ... 0 0 0 ... 0 0 0 | | P1_3 | | 4 * P2 + 2 * P3 |
117 129 // | . . . . . . . . . . . . | | ... | | ... |
118 130 // | 0 0 0 0 ... 1 4 1 ... 0 0 0 | * | P1_i | = | 4 * P(i-1) + 2 * Pi |
119 131 // | . . . . . . . . . . . . | | ... | | ... |
120 132 // | 0 0 0 0 0 0 0 0 ... 1 4 1 | | P1_(n-1)| | 4 * P(n-2) + 2 * P(n-1) |
121 133 // | 0 0 0 0 0 0 0 0 ... 0 2 7 | | P1_n | | 8 * P(n-1) + Pn |
122 134 //
123 135 QVector<qreal> vector;
124 136 vector.resize(n);
125 137
126 138 vector[0] = points[0].x() + 2 * points[1].x();
127 139
128 140
129 141 for (int i = 1; i < n - 1; ++i){
130 142 vector[i] = 4 * points[i].x() + 2 * points[i + 1].x();
131 143 }
132 144
133 145 vector[n - 1] = (8 * points[n-1].x() + points[n].x()) / 2.0;
134 146
135 147 QVector<qreal> xControl = firstControlPoints(vector);
136 148
137 149 vector[0] = points[0].y() + 2 * points[1].y();
138 150
139 151 for (int i = 1; i < n - 1; ++i) {
140 152 vector[i] = 4 * points[i].y() + 2 * points[i + 1].y();
141 153 }
142 154
143 155 vector[n - 1] = (8 * points[n-1].y() + points[n].y()) / 2.0;
144 156
145 157 QVector<qreal> yControl = firstControlPoints(vector);
146 158
147 159 for (int i = 0,j =0; i < n; ++i, ++j) {
148 160
149 161 m_controlPoints[j].setX(xControl[i]);
150 162 m_controlPoints[j].setY(yControl[i]);
151 163
152 164 j++;
153 165
154 166 if (i < n - 1){
155 167 m_controlPoints[j].setX(2 * points[i+1].x() - xControl[i + 1]);
156 168 m_controlPoints[j].setY(2 * points[i+1].y() - yControl[i + 1]);
157 169 }else{
158 170 m_controlPoints[j].setX((points[n].x() + xControl[n - 1]) / 2);
159 171 m_controlPoints[j].setY((points[n].y() + yControl[n - 1]) / 2);
160 172 }
161 173 }
162 174 }
163 175
164 176 QVector<qreal> QSplineSeriesPrivate::firstControlPoints(const QVector<qreal>& vector)
165 177 {
166 178 QVector<qreal> result;
167 179
168 180 int count = vector.count();
169 181 result.resize(count);
170 182 result[0] = vector[0] / 2.0;
171 183
172 184 QVector<qreal> temp;
173 185 temp.resize(count);
174 186 temp[0] = 0;
175 187
176 188 qreal b = 2.0;
177 189
178 190 for (int i = 1; i < count; i++) {
179 191 temp[i] = 1 / b;
180 192 b = (i < count - 1 ? 4.0 : 3.5) - temp[i];
181 193 result[i]=(vector[i] - result[i - 1]) / b;
182 194 }
183 195 for (int i = 1; i < count; i++)
184 196 result[count - i - 1] -= temp[count - i] * result[count - i];
185 197
186 198 return result;
187 199 }
188 200
189 201 QPointF QSplineSeriesPrivate::controlPoint(int index) const
190 202 {
191 203 // Q_D(const QSplineSeries);
192 204 // return d->m_controlPoints[index];
193 205 return m_controlPoints[index];
194 206 }
195 207
196 208 /*!
197 209 Updates the control points, besed on currently avaiable knots.
198 210 */
199 211 void QSplineSeriesPrivate::updateControlPoints()
200 212 {
201 213 Q_Q(QSplineSeries);
202 214 if (q->count() > 1) {
203 215 m_controlPoints.resize(2*q->count()-2);
204 216 calculateControlPoints();
205 217 }
206 218 }
207 219
208 220 Chart* QSplineSeriesPrivate::createGraphics(ChartPresenter* presenter)
209 221 {
210 222 Q_Q(QSplineSeries);
211 223 SplineChartItem* spline = new SplineChartItem(q,presenter);
212 224 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
213 225 spline->setAnimator(presenter->animator());
214 226 spline->setAnimation(new SplineAnimation(spline));
215 227 }
216 228
217 229 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
218 230 return spline;
219 231 }
220 232
221 233 #include "moc_qsplineseries.cpp"
222 234 #include "moc_qsplineseries_p.cpp"
223 235
224 236 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,369 +1,415
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 "qxyseries.h"
22 22 #include "qxyseries_p.h"
23 23 #include "domain_p.h"
24 24 #include "legendmarker_p.h"
25 25
26 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 27
28 28 /*!
29 29 \class QXYSeries
30 30 \brief The QXYSeries class is a base class for line, spline and scatter series.
31 31 */
32 /*!
33 \qmlclass XYSeries
34 \brief The XYSeries class is a base class for line, spline and scatter series.
35
36 The class cannot be instantiated directly.
37 */
32 38
33 39 /*!
34 40 \property QXYSeries::pointsVisible
35
41 Controls if the data points are visible and should be drawn.
42 */
43 /*!
44 \qmlproperty bool XYSeries::pointsVisible
36 45 Controls if the data points are visible and should be drawn.
37 46 */
38 47
39 48 /*!
40 49 \fn QPen QXYSeries::pen() const
41 50 \brief Returns pen used to draw points for series.
42 51 \sa setPen()
43 52 */
44 53
45 54 /*!
46 55 \fn QBrush QXYSeries::brush() const
47 56 \brief Returns brush used to draw points for series.
48 57 \sa setBrush()
49 58 */
50 59
51 60 /*!
52 61 \property QXYSeries::color
53 Line (pen) color of the series. This is a convenience property for modifying the color of pen.
54 \sa QXYSeries::pen()
62 The color of the series. This is line (pen) color in case of QLineSeries or QSplineSeries and
63 fill (brush) color in case of QScatterSeries or QAreaSeries.
64 \sa QXYSeries::pen(), QXYSeries::brush()
65 */
66 /*!
67 \qmlproperty color XYSeries::color
68 The color of the series. This is line (pen) color in case of LineSeries or SplineSeries and
69 fill (brush) color in case of ScatterSeries or AreaSeries.
55 70 */
56 71
57 72 /*!
58 73 \fn void QXYSeries::clicked(const QPointF& point)
59 74 \brief Signal is emitted when user clicks the \a point on chart.
60 75 */
76 /*!
77 \qmlsignal XYSeries::onClicked(QPointF point)
78 Signal is emitted when user clicks the \a point on chart. For example:
79 \code
80 LineSeries {
81 XyPoint { x: 0; y: 0 }
82 XyPoint { x: 1.1; y: 2.1 }
83 onClicked: console.log("onClicked: " + point.x + ", " + point.y);
84 }
85 \endcode
86 */
61 87
62 88 /*!
63 89 \fn void QXYSeries::pointReplaced(int index)
64 \brief Signal is emitted when user replaces a point at \a index.
90 Signal is emitted when a point has been replaced at \a index.
65 91 \sa replace()
66 92 */
93 /*!
94 \qmlsignal XYSeries::pointReplaced(int index)
95 Signal is emitted when a point has been replaced at \a index.
96 */
67 97
68 98 /*!
69 99 \fn void QXYSeries::pointAdded(int index)
70 \brief Signal is emitted when user adds a point at \a index.
100 Signal is emitted when a point has been added at \a index.
71 101 \sa append(), insert()
72 102 */
103 /*!
104 \qmlsignal XYSeries::pointAdded(int index)
105 Signal is emitted when a point has been added at \a index.
106 */
73 107
74 108 /*!
75 109 \fn void QXYSeries::pointRemoved(int index)
76 \brief Signal is emitted when user removes a point at \a index.
110 Signal is emitted when a point has been removed from \a index.
77 111 \sa remove()
78 112 */
113 /*!
114 \qmlsignal XYSeries::pointRemoved(int index)
115 Signal is emitted when a point has been removed from \a index.
116 */
79 117
80 118 /*!
81 119 \fn void QXYSeries::colorChanged(QColor color)
82 120 \brief Signal is emitted when the line (pen) color has changed to \a color.
83 121 */
122 /*!
123 \qmlsignal XYSeries::colorChanged(QColor color)
124 Signal is emitted when the line (pen) color has changed to \a color.
125 */
84 126
85 127 /*!
86 128 \fn void QXYSeriesPrivate::updated()
87 129 \brief \internal
88 130 */
89 131
90 132 /*!
133 \qmlmethod XyPoint XYSeries::at(int index)
134 */
135
136 /*!
91 137 \internal
92 138
93 139 Constructs empty series object which is a child of \a parent.
94 140 When series object is added to QChartView or QChart instance ownerships is transferred.
95 141 */
96 142 QXYSeries::QXYSeries(QXYSeriesPrivate &d,QObject *parent) : QAbstractSeries(d, parent)
97 143 {
98 144 }
99 145
100 146 /*!
101 147 Destroys the object. Series added to QChartView or QChart instances are owned by those,
102 148 and are deleted when mentioned object are destroyed.
103 149 */
104 150 QXYSeries::~QXYSeries()
105 151 {
106 152 }
107 153
108 154 /*!
109 155 Adds data point \a x \a y to the series. Points are connected with lines on the chart.
110 156 */
111 157 void QXYSeries::append(qreal x,qreal y)
112 158 {
113 159 append(QPointF(x,y));
114 160 }
115 161
116 162 /*!
117 163 This is an overloaded function.
118 164 Adds data \a point to the series. Points are connected with lines on the chart.
119 165 */
120 166 void QXYSeries::append(const QPointF &point)
121 167 {
122 168 Q_D(QXYSeries);
123 169 d->m_points<<point;
124 170 // emit d->pointAdded(d->m_points.count()-1);
125 171 emit pointAdded(d->m_points.count()-1);
126 172 }
127 173
128 174 /*!
129 175 This is an overloaded function.
130 176 Adds list of data \a points to the series. Points are connected with lines on the chart.
131 177 */
132 178 void QXYSeries::append(const QList<QPointF> &points)
133 179 {
134 180 foreach(const QPointF& point , points) {
135 181 append(point);
136 182 }
137 183 }
138 184
139 185 /*!
140 186 Replaces data point \a oldX \a oldY with data point \a newX \a newY.
141 187 */
142 188 void QXYSeries::replace(qreal oldX,qreal oldY,qreal newX,qreal newY)
143 189 {
144 190 replace(QPointF(oldX,oldY),QPointF(newX,newY));
145 191 }
146 192
147 193 /*!
148 194 Replaces \a oldPoint with \a newPoint.
149 195 */
150 196 void QXYSeries::replace(const QPointF &oldPoint,const QPointF &newPoint)
151 197 {
152 198 Q_D(QXYSeries);
153 199 int index = d->m_points.indexOf(oldPoint);
154 200 if(index==-1) return;
155 201 d->m_points[index] = newPoint;
156 202 // emit d->pointReplaced(index);
157 203 emit pointReplaced(index);
158 204 }
159 205
160 206 /*!
161 207 Removes current \a x and \a y value.
162 208 */
163 209 void QXYSeries::remove(qreal x,qreal y)
164 210 {
165 211 remove(QPointF(x,y));
166 212 }
167 213
168 214 /*!
169 215 Removes current \a point x value.
170 216
171 217 Note: point y value is ignored.
172 218 */
173 219 void QXYSeries::remove(const QPointF &point)
174 220 {
175 221 Q_D(QXYSeries);
176 222 int index = d->m_points.indexOf(point);
177 223 if(index==-1) return;
178 224 d->m_points.remove(index);
179 225 // emit d->pointRemoved(index);
180 226 emit pointRemoved(index);
181 227 }
182 228
183 229 /*!
184 230 Inserts a \a point in the series at \a index position.
185 231 */
186 232 void QXYSeries::insert(int index, const QPointF &point)
187 233 {
188 234 Q_D(QXYSeries);
189 235 d->m_points.insert(index, point);
190 236 // emit d->pointAdded(index);
191 237 emit pointAdded(index);
192 238 }
193 239
194 240 /*!
195 241 Removes all points from the series.
196 242 */
197 243 void QXYSeries::clear()
198 244 {
199 245 Q_D(QXYSeries);
200 246 for (int i = d->m_points.size() - 1; i >= 0; i--)
201 247 remove(d->m_points.at(i));
202 248 }
203 249
204 250 /*!
205 251 \internal \a pos
206 252 */
207 253 QList<QPointF> QXYSeries::points() const
208 254 {
209 255 Q_D(const QXYSeries);
210 256 return d->m_points.toList();
211 257 }
212 258
213 259 /*!
214 260 Returns number of data points within series.
215 261 */
216 262 int QXYSeries::count() const
217 263 {
218 264 Q_D(const QXYSeries);
219 265 return d->m_points.count();
220 266 }
221 267
222 268
223 269 /*!
224 270 Sets \a pen used for drawing points on the chart. If the pen is not defined, the
225 271 pen from chart theme is used.
226 272 \sa QChart::setTheme()
227 273 */
228 274 void QXYSeries::setPen(const QPen &pen)
229 275 {
230 276 Q_D(QXYSeries);
231 277 if (d->m_pen!=pen) {
232 278 d->m_pen = pen;
233 279 emit d->updated();
234 280 }
235 281 }
236 282
237 283 QPen QXYSeries::pen() const
238 284 {
239 285 Q_D(const QXYSeries);
240 286 return d->m_pen;
241 287 }
242 288
243 289 /*!
244 290 Sets \a brush used for drawing points on the chart. If the brush is not defined, brush
245 291 from chart theme setting is used.
246 292 \sa QChart::setTheme()
247 293 */
248 294 void QXYSeries::setBrush(const QBrush &brush)
249 295 {
250 296 Q_D(QXYSeries);
251 297 if (d->m_brush!=brush) {
252 298 d->m_brush = brush;
253 299 emit d->updated();
254 300 }
255 301 }
256 302
257 303 QBrush QXYSeries::brush() const
258 304 {
259 305 Q_D(const QXYSeries);
260 306 return d->m_brush;
261 307 }
262 308
263 309 void QXYSeries::setColor(const QColor &color)
264 310 {
265 311 QPen p = pen();
266 312 if (p.color() != color) {
267 313 p.setColor(color);
268 314 setPen(p);
269 315 emit colorChanged(color);
270 316 }
271 317 }
272 318
273 319 QColor QXYSeries::color() const
274 320 {
275 321 return pen().color();
276 322 }
277 323
278 324 void QXYSeries::setPointsVisible(bool visible)
279 325 {
280 326 Q_D(QXYSeries);
281 327 if (d->m_pointsVisible != visible){
282 328 d->m_pointsVisible = visible;
283 329 emit d->updated();
284 330 }
285 331 }
286 332
287 333 bool QXYSeries::pointsVisible() const
288 334 {
289 335 Q_D(const QXYSeries);
290 336 return d->m_pointsVisible;
291 337 }
292 338
293 339
294 340 /*!
295 341 Stream operator for adding a data \a point to the series.
296 342 \sa append()
297 343 */
298 344 QXYSeries& QXYSeries::operator<< (const QPointF &point)
299 345 {
300 346 append(point);
301 347 return *this;
302 348 }
303 349
304 350
305 351 /*!
306 352 Stream operator for adding a list of \a points to the series.
307 353 \sa append()
308 354 */
309 355
310 356 QXYSeries& QXYSeries::operator<< (const QList<QPointF>& points)
311 357 {
312 358 append(points);
313 359 return *this;
314 360 }
315 361
316 362 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
317 363
318 364
319 365 QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) :
320 366 QAbstractSeriesPrivate(q),
321 367 m_pointsVisible(false)
322 368 {
323 369 }
324 370
325 371 void QXYSeriesPrivate::scaleDomain(Domain& domain)
326 372 {
327 373 qreal minX(domain.minX());
328 374 qreal minY(domain.minY());
329 375 qreal maxX(domain.maxX());
330 376 qreal maxY(domain.maxY());
331 377 int tickXCount(domain.tickXCount());
332 378 int tickYCount(domain.tickYCount());
333 379
334 380 Q_Q(QXYSeries);
335 381
336 382 const QList<QPointF>& points = q->points();
337 383
338 384
339 385 if(points.isEmpty()){
340 386 minX=0.0;
341 387 minY=0.0;
342 388 maxX=1.0;
343 389 maxY=1.0;
344 390 }
345 391
346 392 for (int i = 0; i < points.count(); i++)
347 393 {
348 394 qreal x = points[i].x();
349 395 qreal y = points[i].y();
350 396 minX = qMin(minX, x);
351 397 minY = qMin(minY, y);
352 398 maxX = qMax(maxX, x);
353 399 maxY = qMax(maxY, y);
354 400 }
355 401
356 402 domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount);
357 403 }
358 404
359 405 QList<LegendMarker*> QXYSeriesPrivate::createLegendMarker(QLegend* legend)
360 406 {
361 407 Q_Q(QXYSeries);
362 408 QList<LegendMarker*> list;
363 409 return list << new XYLegendMarker(q,legend);
364 410 }
365 411
366 412 #include "moc_qxyseries.cpp"
367 413 #include "moc_qxyseries_p.cpp"
368 414
369 415 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,64 +1,66
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 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 24 ChartView {
25 25 title: "area series"
26 26 anchors.fill: parent
27 27 axisXLabels: ["0", "2000", "1", "2001", "2", "2002", "3", "2003", "4", "2004", "5", "2005",
28 28 "6", "2006", "7", "2007", "8", "2008", "9", "2009", "10", "2010", "11", "2011"]
29 29
30 30 property variant series: daSeries
31 31
32 32 AreaSeries {
33 33 id: daSeries
34 34 name: "area 1"
35 onSelected: console.log("areaSeries.onSelected");
36 onClicked: console.log("areaSeries.onClicked: " + point.x + ", " + point.y);
35 37 upperSeries: LineSeries {
36 38 XyPoint { x: 0; y: 1 }
37 39 XyPoint { x: 1; y: 1 }
38 40 XyPoint { x: 2; y: 3 }
39 41 XyPoint { x: 3; y: 3 }
40 42 XyPoint { x: 4; y: 2 }
41 43 XyPoint { x: 5; y: 0 }
42 44 XyPoint { x: 6; y: 2 }
43 45 XyPoint { x: 7; y: 1 }
44 46 XyPoint { x: 8; y: 2 }
45 47 XyPoint { x: 9; y: 1 }
46 48 XyPoint { x: 10; y: 3 }
47 49 XyPoint { x: 11; y: 3 }
48 50 }
49 51 lowerSeries: LineSeries {
50 52 XyPoint { x: 0; y: 0 }
51 53 XyPoint { x: 1; y: 0 }
52 54 XyPoint { x: 2; y: 0 }
53 55 XyPoint { x: 3; y: 0 }
54 56 XyPoint { x: 4; y: 0 }
55 57 XyPoint { x: 5; y: 0 }
56 58 XyPoint { x: 6; y: 0 }
57 59 XyPoint { x: 7; y: 0 }
58 60 XyPoint { x: 8; y: 0 }
59 61 XyPoint { x: 9; y: 0 }
60 62 XyPoint { x: 10; y: 0 }
61 63 XyPoint { x: 11; y: 0 }
62 64 }
63 65 }
64 66 }
@@ -1,42 +1,45
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 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 24 ChartView {
25 25 title: "Bar series"
26 26 anchors.fill: parent
27 27 theme: ChartView.ChartThemeLight
28 28 legend.alignment: Qt.AlignBottom
29 29 axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"]
30 30
31 31 property variant series: daSeries
32 32
33 33 BarSeries {
34 34 id: daSeries
35 35 name: "bar"
36 36 onClicked: console.log("onClicked: " + barset + " " + index);
37 37 onHovered: console.log("onHovered: " + barset + " " + status);
38 BarSet { label: "Bob"; values: [4, 7, 3, 10, 5, 6] }
38 BarSet { label: "Bob"; values: [4, 7, 3, 10, 5, 6]
39 onClicked: console.log("barset.onClicked: " + index);
40 onHovered: console.log("barset.onHovered: " + status);
41 }
39 42 BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 8] }
40 43 BarSet { label: "James"; values: [3, 5, 8, 5, 4, 7] }
41 44 }
42 45 }
@@ -1,51 +1,52
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 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23
24 24 ChartView {
25 25 title: "line series"
26 26 anchors.fill: parent
27 27
28 28 property variant series: daSeries
29 29
30 30 LineSeries {
31 31 id: daSeries
32 32 name: "line 1"
33 onClicked: console.log("onClicked: " + point.x + ", " + point.y);
33 34 XyPoint { x: 0; y: 0 }
34 35 XyPoint { x: 1.1; y: 2.1 }
35 36 XyPoint { x: 1.9; y: 3.3 }
36 37 XyPoint { x: 2.1; y: 2.1 }
37 38 XyPoint { x: 2.9; y: 4.9 }
38 39 XyPoint { x: 3.4; y: 3.0 }
39 40 XyPoint { x: 4.1; y: 3.3 }
40 41 }
41 42
42 43 LineSeries {
43 44 name: "line 2"
44 45 XyPoint { x: 1.1; y: 1.1 }
45 46 XyPoint { x: 1.9; y: 2.3 }
46 47 XyPoint { x: 2.1; y: 1.1 }
47 48 XyPoint { x: 2.9; y: 3.9 }
48 49 XyPoint { x: 3.4; y: 2.0 }
49 50 XyPoint { x: 4.1; y: 2.3 }
50 51 }
51 52 }
General Comments 0
You need to be logged in to leave comments. Login now