##// END OF EJS Templates
Clarified QAreaSeries documentation...
Titta Heikkala -
r2754:bd5b4a26e989
parent child
Show More
@@ -1,695 +1,699
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2014 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.io
6 6 **
7 7 ** This file is part of the Qt Charts module.
8 8 **
9 9 ** Licensees holding valid commercial license for Qt may use this file in
10 10 ** accordance with the Qt License Agreement provided with the Software
11 11 ** or, alternatively, in accordance with the terms contained in a written
12 12 ** agreement between you and Digia.
13 13 **
14 14 ** If you have questions regarding the use of this file, please use
15 15 ** contact form at http://qt.io
16 16 **
17 17 ****************************************************************************/
18 18
19 19 #include <QtCharts/QAreaSeries>
20 20 #include <private/qareaseries_p.h>
21 21 #include <QtCharts/QLineSeries>
22 22 #include <private/areachartitem_p.h>
23 23 #include <private/abstractdomain_p.h>
24 24 #include <private/chartdataset_p.h>
25 25 #include <private/charttheme_p.h>
26 26 #include <QtCharts/QValueAxis>
27 27 #include <QtCharts/QAreaLegendMarker>
28 28 #include <private/qchart_p.h>
29 29
30 30 QT_CHARTS_BEGIN_NAMESPACE
31 31
32 32 /*!
33 33 \class QAreaSeries
34 34 \inmodule Qt Charts
35 35 \brief The QAreaSeries class is used for making area charts.
36 36
37 37 \mainclass
38 38
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 is emphasized with color. Since the area chart is based on line chart, QAreaSeries constructor needs QLineSeries instance,
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 In that case QAreaSeries should be initiated with two QLineSeries instances. Please note terms "upper" and "lower" boundary can be misleading in cases
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.
39 An area series is used to show quantitative data. It is based on line series, in the way that
40 the area between the boundary lines is emphasized with color. Since the area series is based on
41 line series, QAreaSeries constructor needs a QLineSeries instance, which defines "upper"
42 boundary of the area. The area chart is drawn using the bottom of the plot area as the "lower"
43 boundary by default. Instead of the bottom of the plot area, the "lower" boundary can be
44 specified by another line. In that case QAreaSeries should be initialized with two QLineSeries
45 instances. Please note that the terms "upper" and "lower" boundary can be misleading in cases
46 where the "lower" boundary has bigger values than the "upper" one. The main point is that the
47 area between these two boundary lines will be filled.
44 48
45 49 See the \l {AreaChart Example} {area chart example} to learn how to create a simple area chart.
46 50 \image examples_areachart.png
47 51 */
48 52
49 53 /*!
50 54 \qmltype AreaSeries
51 55 \instantiates QAreaSeries
52 56 \inqmlmodule QtCharts
53 57
54 58 \inherits AbstractSeries
55 59
56 60 \brief The AreaSeries type is used for making area charts.
57 61
58 62 The following QML shows how to create a simple area chart:
59 63 \snippet qmlchart/qml/qmlchart/View4.qml 1
60 64 \beginfloatleft
61 65 \image examples_qmlchart4.png
62 66 \endfloat
63 67 \clearfloat
64 68 */
65 69
66 70 /*!
67 71 \property QAreaSeries::upperSeries
68 72 \brief The upper one of the two line series used to define area series boundaries.
69 73 */
70 74 /*!
71 75 \qmlproperty LineSeries AreaSeries::upperSeries
72 76 The upper one of the two line series used to define area series boundaries.
73 77 */
74 78
75 79 /*!
76 80 \property QAreaSeries::lowerSeries
77 81 The lower one of the two line series used to define are series boundaries. Note if
78 82 QAreaSeries was constructed without a\ lowerSeries this is null.
79 83 */
80 84 /*!
81 85 \qmlproperty LineSeries AreaSeries::lowerSeries
82 86 The lower one of the two line series used to define are series boundaries. Note if
83 87 AreaSeries was constructed without a\ lowerSeries this is null.
84 88 */
85 89
86 90 /*!
87 91 \property QAreaSeries::color
88 92 Fill (brush) color of the series. This is a convenience property for modifying the color of brush.
89 93 \sa QAreaSeries::brush()
90 94 */
91 95 /*!
92 96 \qmlproperty color AreaSeries::color
93 97 Fill (brush) color of the series.
94 98 */
95 99
96 100 /*!
97 101 \property QAreaSeries::borderColor
98 102 Line (pen) color of the series. This is a convenience property for modifying the color of pen.
99 103 \sa QAreaSeries::pen()
100 104 */
101 105 /*!
102 106 \qmlproperty color AreaSeries::borderColor
103 107 Line (pen) color of the series.
104 108 */
105 109
106 110 /*!
107 111 \qmlproperty real AreaSeries::borderWidth
108 112 The width of the border line. By default the width is 2.0.
109 113 */
110 114
111 115 /*!
112 116 \fn QPen QAreaSeries::pen() const
113 117 \brief Returns the pen used to draw line for this series.
114 118 \sa setPen()
115 119 */
116 120
117 121 /*!
118 122 \fn QPen QAreaSeries::brush() const
119 123 \brief Returns the brush used to draw line for this series.
120 124 \sa setBrush()
121 125 */
122 126
123 127 /*!
124 128 \qmlproperty QString AreaSeries::brushFilename
125 129 The name of the file used as a brush image for the series.
126 130 */
127 131
128 132 /*!
129 133 \fn void QAreaSeries::colorChanged(QColor color)
130 134 \brief Signal is emitted when the fill (brush) color has changed to \a color.
131 135 */
132 136 /*!
133 137 \qmlsignal AreaSeries::onColorChanged(color color)
134 138 Signal is emitted when the fill (brush) color has changed to \a color.
135 139 */
136 140
137 141 /*!
138 142 \fn void QAreaSeries::borderColorChanged(QColor color)
139 143 \brief Signal is emitted when the line (pen) color has changed to \a color.
140 144 */
141 145 /*!
142 146 \qmlsignal AreaSeries::onBorderColorChanged(color color)
143 147 Signal is emitted when the line (pen) color has changed to \a color.
144 148 */
145 149
146 150 /*!
147 151 \fn void QAreaSeries::clicked(const QPointF& point)
148 152 \brief Signal is emitted when user clicks the \a point on area chart. The \a point is the point
149 153 where the press was triggered.
150 154 \sa pressed, released, doubleClicked
151 155 */
152 156 /*!
153 157 \qmlsignal AreaSeries::onClicked(QPointF point)
154 158 Signal is emitted when user clicks the \a point on area chart. The \a point is the point where
155 159 the press was triggered.
156 160 \sa onPressed, onReleased, onDoubleClicked
157 161 */
158 162
159 163 /*!
160 164 \fn void QAreaSeries::hovered(const QPointF &point, bool state)
161 165 This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate)
162 166 of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from
163 167 the series.
164 168 */
165 169 /*!
166 170 \qmlsignal AreaSeries::onHovered(point point, bool state)
167 171 This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate)
168 172 of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from
169 173 the series.
170 174 */
171 175
172 176 /*!
173 177 \fn void QAreaSeries::pressed(const QPointF& point)
174 178 \brief Signal is emitted when user presses the \a point on area chart.
175 179 \sa clicked, released, doubleClicked
176 180 */
177 181 /*!
178 182 \qmlsignal AreaSeries::onPressed(QPointF point)
179 183 Signal is emitted when user presses the \a point on area chart.
180 184 \sa onClicked, onReleased, onDoubleClicked
181 185 */
182 186
183 187 /*!
184 188 \fn void QAreaSeries::released(const QPointF& point)
185 189 \brief Signal is emitted when user releases a press that was triggered on a \a point on area
186 190 chart.
187 191 \sa pressed, clicked, doubleClicked
188 192 */
189 193 /*!
190 194 \qmlsignal AreaSeries::onReleased(QPointF point)
191 195 Signal is emitted when user releases a press that was triggered on a \a point on area chart.
192 196 \sa onPressed, onClicked, onDoubleClicked
193 197 */
194 198
195 199 /*!
196 200 \fn void QAreaSeries::doubleClicked(const QPointF& point)
197 201 \brief Signal is emitted when user doubleclicks the \a point on area chart. The \a point is the
198 202 point where the first press was triggered.
199 203 \sa pressed, released, clicked
200 204 */
201 205 /*!
202 206 \qmlsignal AreaSeries::onDoubleClicked(QPointF point)
203 207 Signal is emitted when user doubleclicks the \a point on area chart. The \a point is the point
204 208 where the first press was triggered.
205 209 \sa onPressed, onReleased, onClicked
206 210 */
207 211
208 212 /*!
209 213 \fn void QAreaSeries::selected()
210 214 The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be
211 215 implemented by the user of QAreaSeries API.
212 216 */
213 217 /*!
214 218 \qmlsignal AreaSeries::onSelected()
215 219 The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be
216 220 implemented by the user of AreaSeries API.
217 221 */
218 222
219 223 /*!
220 224 \fn void QAreaSeriesPrivate::updated()
221 225 \brief \internal
222 226 */
223 227
224 228 /*!
225 229 \property QAreaSeries::pointLabelsFormat
226 230 The \a format used for showing labels with series points.
227 231
228 232 QAreaSeries supports the following format tags:
229 233 \table
230 234 \row
231 235 \li @xPoint \li The x value of the data point
232 236 \row
233 237 \li @yPoint \li The y value of the data point
234 238 \endtable
235 239
236 240 For example, the following usage of the format tags would produce labels that have the data
237 241 point (x, y) shown inside brackets separated by a comma:
238 242 \code
239 243 series->setPointLabelsFormat("(@xPoint, @yPoint)");
240 244 \endcode
241 245
242 246 By default, the labels format is set to '@xPoint, @yPoint'. The labels are shown on the plot
243 247 area, labels on the edge of the plot area are cut. If the points are close to each other the
244 248 labels may overlap.
245 249
246 250 \sa QAreaSeries::pointLabelsVisible, QAreaSeries::pointLabelsFont, QAreaSeries::pointLabelsColor
247 251 */
248 252 /*!
249 253 \qmlproperty string AreaSeries::pointLabelsFormat
250 254 The \a format used for showing labels with series points.
251 255
252 256 \sa QAreaSeries::pointLabelsFormat, pointLabelsVisible, pointLabelsFont, pointLabelsColor
253 257 */
254 258 /*!
255 259 \fn void QAreaSeries::pointLabelsFormatChanged(const QString &format)
256 260 Signal is emitted when the \a format of data point labels is changed.
257 261 */
258 262 /*!
259 263 \qmlsignal AreaSeries::onPointLabelsFormatChanged(string format)
260 264 Signal is emitted when the \a format of data point labels is changed.
261 265 */
262 266
263 267 /*!
264 268 \property QAreaSeries::pointLabelsVisible
265 269 Defines the visibility for data point labels. False by default.
266 270
267 271 \sa QAreaSeries::pointLabelsFormat
268 272 */
269 273 /*!
270 274 \qmlproperty bool AreaSeries::pointLabelsVisible
271 275 Defines the visibility for data point labels.
272 276
273 277 \sa pointLabelsFormat
274 278 */
275 279 /*!
276 280 \fn void QAreaSeries::pointLabelsVisibilityChanged(bool visible)
277 281 The visibility of the data point labels is changed to \a visible.
278 282 */
279 283 /*!
280 284 \qmlsignal AreaSeries::onPointLabelsVisibilityChanged(bool visible)
281 285 The visibility of the data point labels is changed to \a visible.
282 286 */
283 287
284 288 /*!
285 289 \property QAreaSeries::pointLabelsFont
286 290 Defines the font used for data point labels.
287 291
288 292 \sa QAreaSeries::pointLabelsFormat
289 293 */
290 294 /*!
291 295 \qmlproperty font AreaSeries::pointLabelsFont
292 296 Defines the font used for data point labels.
293 297
294 298 \sa pointLabelsFormat
295 299 */
296 300 /*!
297 301 \fn void QAreaSeries::pointLabelsFontChanged(const QFont &font);
298 302 The font used for data point labels is changed to \a font.
299 303 */
300 304 /*!
301 305 \qmlsignal AreaSeries::onPointLabelsFontChanged(Font font)
302 306 The font used for data point labels is changed to \a font.
303 307 */
304 308
305 309 /*!
306 310 \property QAreaSeries::pointLabelsColor
307 311 Defines the color used for data point labels. By default, the color is the color of the brush
308 312 defined in theme for labels.
309 313
310 314 \sa QAreaSeries::pointLabelsFormat
311 315 */
312 316 /*!
313 317 \qmlproperty font AreaSeries::pointLabelsColor
314 318 Defines the color used for data point labels. By default, the color is the color of the brush
315 319 defined in theme for labels.
316 320
317 321 \sa pointLabelsFormat
318 322 */
319 323 /*!
320 324 \fn void QAreaSeries::pointLabelsColorChanged(const QColor &color);
321 325 The color used for data point labels is changed to \a color.
322 326 */
323 327 /*!
324 328 \qmlsignal AreaSeries::onPointLabelsColorChanged(Color color)
325 329 The color used for data point labels is changed to \a color.
326 330 */
327 331
328 332 /*!
329 333 Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a
330 334 upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead.
331 335 When series object is added to QChartView or QChart instance ownerships is transferred.
332 336 */
333 337 QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries)
334 338 : QAbstractSeries(*new QAreaSeriesPrivate(upperSeries, lowerSeries, this), upperSeries)
335 339 {
336 340 }
337 341
338 342 /*!
339 343 Constructs area series object without upper or lower series with \a parent object.
340 344 */
341 345 QAreaSeries::QAreaSeries(QObject *parent)
342 346 : QAbstractSeries(*new QAreaSeriesPrivate(0, 0, this), parent)
343 347 {
344 348 }
345 349
346 350 /*!
347 351 Destroys the object.
348 352 */
349 353 QAreaSeries::~QAreaSeries()
350 354 {
351 355 Q_D(QAreaSeries);
352 356 if (d->m_chart)
353 357 d->m_chart->removeSeries(this);
354 358 }
355 359
356 360 /*!
357 361 Returns QAbstractSeries::SeriesTypeArea.
358 362 */
359 363 QAbstractSeries::SeriesType QAreaSeries::type() const
360 364 {
361 365 return QAbstractSeries::SeriesTypeArea;
362 366 }
363 367
364 368 /*!
365 369 Sets the \a series that is to be used as the area chart upper series.
366 370 */
367 371 void QAreaSeries::setUpperSeries(QLineSeries *series)
368 372 {
369 373 Q_D(QAreaSeries);
370 374 if (d->m_upperSeries != series)
371 375 d->m_upperSeries = series;
372 376 }
373 377
374 378 QLineSeries *QAreaSeries::upperSeries() const
375 379 {
376 380 Q_D(const QAreaSeries);
377 381 return d->m_upperSeries;
378 382 }
379 383
380 384 /*!
381 385 Sets the \a series that is to be used as the area chart lower series.
382 386 */
383 387 void QAreaSeries::setLowerSeries(QLineSeries *series)
384 388 {
385 389 Q_D(QAreaSeries);
386 390 d->m_lowerSeries = series;
387 391 }
388 392
389 393 QLineSeries *QAreaSeries::lowerSeries() const
390 394 {
391 395 Q_D(const QAreaSeries);
392 396 return d->m_lowerSeries;
393 397 }
394 398
395 399 /*!
396 400 Sets \a pen used for drawing area outline.
397 401 */
398 402 void QAreaSeries::setPen(const QPen &pen)
399 403 {
400 404 Q_D(QAreaSeries);
401 405 if (d->m_pen != pen) {
402 406 d->m_pen = pen;
403 407 emit d->updated();
404 408 }
405 409 }
406 410
407 411 QPen QAreaSeries::pen() const
408 412 {
409 413 Q_D(const QAreaSeries);
410 414 if (d->m_pen == QChartPrivate::defaultPen())
411 415 return QPen();
412 416 else
413 417 return d->m_pen;
414 418 }
415 419
416 420 /*!
417 421 Sets \a brush used for filling the area.
418 422 */
419 423 void QAreaSeries::setBrush(const QBrush &brush)
420 424 {
421 425 Q_D(QAreaSeries);
422 426 if (d->m_brush != brush) {
423 427 bool emitColorChanged = brush.color() != d->m_brush.color();
424 428 d->m_brush = brush;
425 429 emit d->updated();
426 430 if (emitColorChanged)
427 431 emit colorChanged(brush.color());
428 432 }
429 433 }
430 434
431 435 QBrush QAreaSeries::brush() const
432 436 {
433 437 Q_D(const QAreaSeries);
434 438 if (d->m_brush == QChartPrivate::defaultBrush())
435 439 return QBrush();
436 440 else
437 441 return d->m_brush;
438 442 }
439 443
440 444 void QAreaSeries::setColor(const QColor &color)
441 445 {
442 446 QBrush b = brush();
443 447 if (b == QBrush())
444 448 b.setStyle(Qt::SolidPattern);
445 449 b.setColor(color);
446 450 setBrush(b);
447 451 }
448 452
449 453 QColor QAreaSeries::color() const
450 454 {
451 455 return brush().color();
452 456 }
453 457
454 458 void QAreaSeries::setBorderColor(const QColor &color)
455 459 {
456 460 QPen p = pen();
457 461 if (p.color() != color) {
458 462 p.setColor(color);
459 463 setPen(p);
460 464 emit borderColorChanged(color);
461 465 }
462 466 }
463 467
464 468 QColor QAreaSeries::borderColor() const
465 469 {
466 470 return pen().color();
467 471 }
468 472
469 473 /*!
470 474 Sets if data points are \a visible and should be drawn on line.
471 475 */
472 476 void QAreaSeries::setPointsVisible(bool visible)
473 477 {
474 478 Q_D(QAreaSeries);
475 479 if (d->m_pointsVisible != visible) {
476 480 d->m_pointsVisible = visible;
477 481 emit d->updated();
478 482 }
479 483 }
480 484
481 485 /*!
482 486 Returns if the points are drawn for this series.
483 487 \sa setPointsVisible()
484 488 */
485 489 bool QAreaSeries::pointsVisible() const
486 490 {
487 491 Q_D(const QAreaSeries);
488 492 return d->m_pointsVisible;
489 493 }
490 494
491 495 void QAreaSeries::setPointLabelsFormat(const QString &format)
492 496 {
493 497 Q_D(QAreaSeries);
494 498 if (d->m_pointLabelsFormat != format) {
495 499 d->m_pointLabelsFormat = format;
496 500 emit pointLabelsFormatChanged(format);
497 501 }
498 502 }
499 503
500 504 QString QAreaSeries::pointLabelsFormat() const
501 505 {
502 506 Q_D(const QAreaSeries);
503 507 return d->m_pointLabelsFormat;
504 508 }
505 509
506 510 void QAreaSeries::setPointLabelsVisible(bool visible)
507 511 {
508 512 Q_D(QAreaSeries);
509 513 if (d->m_pointLabelsVisible != visible) {
510 514 d->m_pointLabelsVisible = visible;
511 515 emit pointLabelsVisibilityChanged(visible);
512 516 }
513 517 }
514 518
515 519 bool QAreaSeries::pointLabelsVisible() const
516 520 {
517 521 Q_D(const QAreaSeries);
518 522 return d->m_pointLabelsVisible;
519 523 }
520 524
521 525 void QAreaSeries::setPointLabelsFont(const QFont &font)
522 526 {
523 527 Q_D(QAreaSeries);
524 528 if (d->m_pointLabelsFont != font) {
525 529 d->m_pointLabelsFont = font;
526 530 emit pointLabelsFontChanged(font);
527 531 }
528 532 }
529 533
530 534 QFont QAreaSeries::pointLabelsFont() const
531 535 {
532 536 Q_D(const QAreaSeries);
533 537 return d->m_pointLabelsFont;
534 538 }
535 539
536 540 void QAreaSeries::setPointLabelsColor(const QColor &color)
537 541 {
538 542 Q_D(QAreaSeries);
539 543 if (d->m_pointLabelsColor != color) {
540 544 d->m_pointLabelsColor = color;
541 545 emit pointLabelsColorChanged(color);
542 546 }
543 547 }
544 548
545 549 QColor QAreaSeries::pointLabelsColor() const
546 550 {
547 551 Q_D(const QAreaSeries);
548 552 if (d->m_pointLabelsColor == QChartPrivate::defaultPen().color())
549 553 return QPen().color();
550 554 else
551 555 return d->m_pointLabelsColor;
552 556 }
553 557
554 558 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
555 559
556 560 QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries, QAreaSeries *q)
557 561 : QAbstractSeriesPrivate(q),
558 562 m_brush(QChartPrivate::defaultBrush()),
559 563 m_pen(QChartPrivate::defaultPen()),
560 564 m_upperSeries(upperSeries),
561 565 m_lowerSeries(lowerSeries),
562 566 m_pointsVisible(false),
563 567 m_pointLabelsFormat(QLatin1String("@xPoint, @yPoint")),
564 568 m_pointLabelsVisible(false),
565 569 m_pointLabelsFont(QChartPrivate::defaultFont()),
566 570 m_pointLabelsColor(QChartPrivate::defaultPen().color())
567 571 {
568 572 }
569 573
570 574 void QAreaSeriesPrivate::initializeDomain()
571 575 {
572 576 Q_Q(QAreaSeries);
573 577
574 578 qreal minX(domain()->minX());
575 579 qreal minY(domain()->minY());
576 580 qreal maxX(domain()->maxX());
577 581 qreal maxY(domain()->maxY());
578 582
579 583 QLineSeries *upperSeries = q->upperSeries();
580 584 QLineSeries *lowerSeries = q->lowerSeries();
581 585
582 586 if (upperSeries) {
583 587 const QList<QPointF>& points = upperSeries->points();
584 588
585 589 for (int i = 0; i < points.count(); i++) {
586 590 qreal x = points[i].x();
587 591 qreal y = points[i].y();
588 592 minX = qMin(minX, x);
589 593 minY = qMin(minY, y);
590 594 maxX = qMax(maxX, x);
591 595 maxY = qMax(maxY, y);
592 596 }
593 597 }
594 598 if (lowerSeries) {
595 599
596 600 const QList<QPointF>& points = lowerSeries->points();
597 601
598 602 for (int i = 0; i < points.count(); i++) {
599 603 qreal x = points[i].x();
600 604 qreal y = points[i].y();
601 605 minX = qMin(minX, x);
602 606 minY = qMin(minY, y);
603 607 maxX = qMax(maxX, x);
604 608 maxY = qMax(maxY, y);
605 609 }
606 610 }
607 611
608 612 domain()->setRange(minX, maxX, minY, maxY);
609 613 }
610 614
611 615 void QAreaSeriesPrivate::initializeGraphics(QGraphicsItem* parent)
612 616 {
613 617 Q_Q(QAreaSeries);
614 618 AreaChartItem *area = new AreaChartItem(q,parent);
615 619 m_item.reset(area);
616 620 QAbstractSeriesPrivate::initializeGraphics(parent);
617 621 }
618 622 void QAreaSeriesPrivate::initializeAnimations(QChart::AnimationOptions options)
619 623 {
620 624 Q_Q(QAreaSeries);
621 625 AreaChartItem *area = static_cast<AreaChartItem *>(m_item.data());
622 626
623 627 if (q->upperSeries() && area->upperLineItem()->animation())
624 628 area->upperLineItem()->animation()->stopAndDestroyLater();
625 629 if (q->lowerSeries() && area->lowerLineItem()->animation())
626 630 area->lowerLineItem()->animation()->stopAndDestroyLater();
627 631
628 632 if (options.testFlag(QChart::SeriesAnimations)) {
629 633 area->upperLineItem()->setAnimation(new XYAnimation(area->upperLineItem()));
630 634 if (q->lowerSeries())
631 635 area->lowerLineItem()->setAnimation(new XYAnimation(area->lowerLineItem()));
632 636 } else {
633 637 if (q->upperSeries())
634 638 area->upperLineItem()->setAnimation(0);
635 639 if (q->lowerSeries())
636 640 area->lowerLineItem()->setAnimation(0);
637 641 }
638 642 QAbstractSeriesPrivate::initializeAnimations(options);
639 643 }
640 644
641 645 QList<QLegendMarker*> QAreaSeriesPrivate::createLegendMarkers(QLegend* legend)
642 646 {
643 647 Q_Q(QAreaSeries);
644 648 QList<QLegendMarker*> list;
645 649 return list << new QAreaLegendMarker(q,legend);
646 650 }
647 651
648 652
649 653 void QAreaSeriesPrivate::initializeAxes()
650 654 {
651 655
652 656 }
653 657
654 658 QAbstractAxis::AxisType QAreaSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const
655 659 {
656 660 Q_UNUSED(orientation);
657 661 return QAbstractAxis::AxisTypeValue;
658 662 }
659 663
660 664 QAbstractAxis* QAreaSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const
661 665 {
662 666 Q_UNUSED(orientation);
663 667 return new QValueAxis;
664 668 }
665 669
666 670 void QAreaSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forced)
667 671 {
668 672 Q_Q(QAreaSeries);
669 673
670 674 const QList<QGradient> gradients = theme->seriesGradients();
671 675 const QList<QColor> colors = theme->seriesColors();
672 676
673 677 if (forced || QChartPrivate::defaultPen() == m_pen) {
674 678 QPen pen;
675 679 pen.setColor(ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0.0));
676 680 pen.setWidthF(2);
677 681 q->setPen(pen);
678 682 }
679 683
680 684 if (forced || QChartPrivate::defaultBrush() == m_brush) {
681 685 QBrush brush(colors.at(index % colors.size()));
682 686 q->setBrush(brush);
683 687 }
684 688
685 689 if (forced || QChartPrivate::defaultPen().color() == m_pointLabelsColor) {
686 690 QColor color = theme->labelBrush().color();
687 691 q->setPointLabelsColor(color);
688 692 }
689 693 }
690 694
691 695
692 696 #include "moc_qareaseries.cpp"
693 697 #include "moc_qareaseries_p.cpp"
694 698
695 699 QT_CHARTS_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now