1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include <QtCharts/QAreaSeries>
5#include <private/qareaseries_p.h>
6#include <QtCharts/QLineSeries>
7#include <private/areachartitem_p.h>
8#include <private/abstractdomain_p.h>
9#include <private/chartdataset_p.h>
10#include <private/charttheme_p.h>
11#include <QtCharts/QValueAxis>
12#include <QtCharts/QAreaLegendMarker>
13#include <private/qchart_p.h>
14
15QT_BEGIN_NAMESPACE
16
17/*!
18 \class QAreaSeries
19 \inmodule QtCharts
20 \brief The QAreaSeries class presents data in area charts.
21
22 An area series is used to show quantitative data. It is based on a line series, in the way that
23 the area between the boundary lines is emphasized with color. Since the area series is based on
24 the line series, the QAreaSeries constructor needs a QLineSeries instance, which defines the
25 \e upper boundary of the area. The area chart is drawn using the bottom of the plot area as the
26 \e lower boundary by default. Instead of the bottom of the plot area, the lower boundary can be
27 specified by another line. In that case, QAreaSeries should be initialized with two QLineSeries
28 instances.
29
30 \note The terms \e upper and \e lower boundary can be misleading in cases where the value of the
31 lower boundary is greater than that of the upper boundary. The main point is that the
32 area between these two boundary lines will be filled.
33
34 See the \l {Charts with Widgets Gallery} to learn how to create a simple area chart.
35 \image examples_areachart.png
36*/
37
38/*!
39 \qmltype AreaSeries
40 \instantiates QAreaSeries
41 \inqmlmodule QtCharts
42
43 \inherits AbstractSeries
44
45 \brief Presents data in area charts.
46
47 An area series is used to show quantitative data. It is based on a line
48 series, in the way that the area between the boundary lines is emphasized
49 with color. The LineSeries type defines the \e upper boundary of the
50 area. The area chart is drawn using the bottom of the plot area as the
51 \e lower boundary by default. Instead of the bottom of the plot area, the
52 lower boundary can be specified by another line. In that case, the
53 AreaSeries should use two LineSeries types.
54
55 \note The terms \e upper and \e lower boundary can be misleading in cases
56 where the value of the lower boundary is greater than that of the upper
57 boundary. The main point is that the area between these two boundary lines
58 will be filled.
59
60 \image examples_qmlchart4.png
61
62 The following QML shows how to create a simple area chart:
63 \snippet qmlchartsgallery/qml/AreaSeries.qml 1
64
65 \note Adding the same line series to a chart and area series is not supported. The series used as
66 boundary lines should be defined only for the area series.
67*/
68
69/*!
70 \qmlproperty AbstractAxis AreaSeries::axisX
71 The x-axis used for the series. If you leave both axisX and axisXTop
72 undefined, a value axis is created for the series.
73 \sa axisXTop, ValueAxis
74*/
75
76/*!
77 \qmlproperty AbstractAxis AreaSeries::axisY
78 The y-axis used for the series. If you leave both axisY and axisYRight
79 undefined, a value axis is created for the series.
80 \sa axisYRight, ValueAxis
81*/
82
83/*!
84 \qmlproperty AbstractAxis AreaSeries::axisXTop
85 The x-axis used for the series, drawn on top of the chart view.
86
87 \note You can only provide either axisX or axisXTop, not both.
88 \sa axisX
89*/
90
91/*!
92 \qmlproperty AbstractAxis AreaSeries::axisYRight
93 The y-axis used for the series, drawn to the right on the chart view.
94
95 \note You can only provide either axisY or axisYRight, not both.
96 \sa axisY
97*/
98
99/*!
100 \qmlproperty AbstractAxis AreaSeries::axisAngular
101 The angular axis used for the series, drawn around the polar chart view.
102 \sa axisX, PolarChartView
103*/
104
105/*!
106 \qmlproperty AbstractAxis AreaSeries::axisRadial
107 The radial axis used for the series, drawn inside the polar chart view.
108 \sa axisY, PolarChartView
109*/
110
111/*!
112 \property QAreaSeries::upperSeries
113 \brief The upper one of the two line series used to define area series boundaries.
114*/
115/*!
116 \qmlproperty LineSeries AreaSeries::upperSeries
117 The upper one of the two line series used to define area series boundaries.
118*/
119
120/*!
121 \property QAreaSeries::lowerSeries
122 \brief The lower one of the two line series used to define area series boundaries.
123
124 \note If QAreaSeries was constructed without a\ lowerSeries, this is null.
125*/
126/*!
127 \qmlproperty LineSeries AreaSeries::lowerSeries
128 The lower one of the two line series used to define area series boundaries.
129
130 \note If AreaSeries was constructed without a\ lowerSeries, this is null.
131*/
132
133/*!
134 \property QAreaSeries::color
135 \brief The fill (brush) color of the series. This is a convenience property for modifying the
136 color of the brush.
137 \sa QAreaSeries::brush()
138*/
139/*!
140 \qmlproperty color AreaSeries::color
141 Fill (brush) color of the series.
142*/
143
144/*!
145 \property QAreaSeries::borderColor
146 \brief The line (pen) color of the series. This is a convenience property for modifying the
147 color of the pen.
148 \sa QAreaSeries::pen()
149*/
150/*!
151 \qmlproperty color AreaSeries::borderColor
152 Line (pen) color of the series.
153*/
154
155/*!
156 \qmlproperty real AreaSeries::borderWidth
157 The width of the border line. By default, the width is 2.0.
158*/
159
160/*!
161 \fn QPen QAreaSeries::pen() const
162 \brief Returns the pen used to draw the line for this series.
163 \sa setPen()
164*/
165
166/*!
167 \fn QPen QAreaSeries::brush() const
168 \brief Returns the brush used to draw the line for this series.
169 \sa setBrush()
170*/
171
172/*!
173 \qmlproperty brush AreaSeries::brush
174 The brush used to draw to draw the line for this series.
175*/
176
177/*!
178 \qmlproperty QString AreaSeries::brushFilename
179 The name of the file used as a brush image for the series.
180*/
181
182/*!
183 \fn void QAreaSeries::colorChanged(QColor color)
184 \brief This signal is emitted when the fill (brush) color changes to \a color.
185*/
186
187/*!
188 \fn void QAreaSeries::borderColorChanged(QColor color)
189 \brief This signal is emitted when the line (pen) color changes to \a color.
190*/
191
192/*!
193 \fn void QAreaSeries::clicked(const QPointF& point)
194 \brief This signal is emitted when the user triggers a press on \a point by clicking it in an
195 area chart.
196 \sa pressed, released, doubleClicked
197*/
198/*!
199 \qmlsignal AreaSeries::clicked(point point)
200 This signal is emitted when the user triggers a press on \a point by clicking it in an
201 area chart.
202
203 The corresponding signal handler is \c {onClicked}.
204
205 \sa pressed, released, doubleClicked
206*/
207
208/*!
209 \fn void QAreaSeries::hovered(const QPointF &point, bool state)
210 This signal is emitted when the user hovers the mouse cursor over a series or moves it away from
211 the series. \a point shows the origin (coordinate) of the hover event. \a state is \c true when
212 the cursor hovers over the series and turns \e false when it moves away from the series.
213*/
214/*!
215 \qmlsignal AreaSeries::hovered(point point, bool state)
216 This signal is emitted when the user hovers the mouse cursor over a series or moves it away from
217 the series. \a point shows the origin (coordinate) of the hover event. \a state is \c true when
218 the cursor hovers over the series and turns \e false when it moves away from the series.
219
220 The corresponding signal handler is \c {onHovered}.
221*/
222
223/*!
224 \fn void QAreaSeries::pressed(const QPointF& point)
225 \brief This signal is emitted when the user presses the point specified by \a point
226 in an area chart.
227 \sa clicked, released, doubleClicked
228*/
229/*!
230 \qmlsignal AreaSeries::pressed(point point)
231 This signal is emitted when the user presses the point specified by \a point in an area chart.
232
233 The corresponding signal handler is \c {onPressed}.
234
235 \sa clicked, released, doubleClicked
236*/
237
238/*!
239 \fn void QAreaSeries::released(const QPointF& point)
240 \brief This signal is emitted when the user releases a press that was triggered on
241 \a point in an area chart.
242 \sa pressed, clicked, doubleClicked
243*/
244/*!
245 \qmlsignal AreaSeries::released(point point)
246 This signal is emitted when the user releases a press that was triggered on
247 \a point in an area chart.
248
249 The corresponding signal handler is \c {onReleased}.
250
251 \sa pressed, clicked, doubleClicked
252*/
253
254/*!
255 \fn void QAreaSeries::doubleClicked(const QPointF& point)
256 \brief This signal is emitted when the user triggers the first press in an area chart
257 by doubleclicking \a point.
258 \sa pressed, released, clicked
259*/
260/*!
261 \qmlsignal AreaSeries::doubleClicked(point point)
262 This signal is emitted when the user triggers the first press in an area chart
263 by doubleclicking \a point.
264
265 The corresponding signal handler is \c {onDoubleClicked}.
266
267 \sa pressed, released, clicked
268*/
269
270/*!
271 \fn void QAreaSeries::selected()
272 \internal
273*/
274
275/*!
276 \fn void QAreaSeriesPrivate::updated()
277 \internal
278*/
279
280/*!
281 \property QAreaSeries::pointLabelsFormat
282 \brief The format used for showing labels with series points.
283
284 QAreaSeries supports the following format tags:
285 \table
286 \row
287 \li @xPoint \li The x value of the data point
288 \row
289 \li @yPoint \li The y value of the data point
290 \endtable
291
292 For example, the following usage of the format tags would produce labels that have the data
293 point (x, y) shown inside brackets separated by a comma:
294 \code
295 series->setPointLabelsFormat("(@xPoint, @yPoint)");
296 \endcode
297
298 By default, the label format is set to \c{@xPoint, @yPoint}. The labels are shown on the plot
299 area, whereas labels on the edge of the plot area are cut. If the points are close to each
300 other, the labels may overlap.
301
302 \sa QAreaSeries::pointLabelsVisible, QAreaSeries::pointLabelsFont, QAreaSeries::pointLabelsColor
303*/
304/*!
305 \qmlproperty string AreaSeries::pointLabelsFormat
306 The format used for showing labels with series points.
307
308 \sa QAreaSeries::pointLabelsFormat, pointLabelsVisible, pointLabelsFont, pointLabelsColor
309*/
310/*!
311 \fn void QAreaSeries::pointLabelsFormatChanged(const QString &format)
312 This signal is emitted when the \a format of data point labels is changed.
313*/
314
315/*!
316 \property QAreaSeries::pointLabelsVisible
317 \brief The visibility of data point labels. False by default.
318
319 \sa QAreaSeries::pointLabelsFormat, QAreaSeries::pointLabelsClipping
320*/
321/*!
322 \qmlproperty bool AreaSeries::pointLabelsVisible
323 Defines the visibility of data point labels.
324
325 \sa pointLabelsFormat, pointLabelsClipping
326*/
327/*!
328 \fn void QAreaSeries::pointLabelsVisibilityChanged(bool visible)
329 This signal is emitted when the visibility of the data point labels changes to \a visible.
330*/
331
332/*!
333 \property QAreaSeries::pointLabelsFont
334 \brief The font used for data point labels.
335
336 \sa QAreaSeries::pointLabelsFormat
337*/
338/*!
339 \qmlproperty font AreaSeries::pointLabelsFont
340 Defines the font used for data point labels.
341
342 \sa pointLabelsFormat
343*/
344/*!
345 \fn void QAreaSeries::pointLabelsFontChanged(const QFont &font);
346 This signal is emitted when the font used for data point labels changes to \a font.
347*/
348
349/*!
350 \property QAreaSeries::pointLabelsColor
351 \brief The color used for data point labels. By default, the color is the color of the brush
352 defined for labels in the theme.
353
354 \sa QAreaSeries::pointLabelsFormat
355*/
356/*!
357 \qmlproperty font AreaSeries::pointLabelsColor
358 Defines the color used for data point labels. By default, the color is the color of the brush
359 defined for labels in the theme.
360
361 \sa pointLabelsFormat
362*/
363/*!
364 \fn void QAreaSeries::pointLabelsColorChanged(const QColor &color);
365 This signal is emitted when the color used for data point labels changes to \a color.
366*/
367
368/*!
369 \property QAreaSeries::pointLabelsClipping
370 \brief The clipping for data point labels. True by default. The labels on the edge of the plot
371 area are cut when clipping is enabled.
372
373 \sa pointLabelsVisible
374*/
375/*!
376 \qmlproperty bool AreaSeries::pointLabelsClipping
377 Defines the clipping for data point labels. True by default. The labels on the edge of the plot
378 area are cut when clipping is enabled.
379
380 \sa pointLabelsVisible
381*/
382/*!
383 \fn void QAreaSeries::pointLabelsClippingChanged(bool clipping)
384 This signal is emitted when the clipping of the data point labels changes to \a clipping.
385*/
386
387/*!
388 Constructs an area series object that will be spanned between an \a upperSeries line and a
389 \a lowerSeries line. If no \a lowerSeries is passed to the constructor, the x-axis is used
390 as the lower bound instead.
391
392 The QAreaSeries does not own the upper or lower series, but the ownership stays with the caller.
393 When the series object is added to QChartView or QChart, the instance ownership is transferred.
394*/
395QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries)
396 : QAbstractSeries(*new QAreaSeriesPrivate(upperSeries, lowerSeries, this), upperSeries)
397{
398 if (upperSeries)
399 upperSeries->d_ptr->setBlockOpenGL(true);
400 if (lowerSeries)
401 lowerSeries->d_ptr->setBlockOpenGL(true);
402}
403
404/*!
405 Constructs an area series object without an upper or a lower series with the \a parent object.
406*/
407QAreaSeries::QAreaSeries(QObject *parent)
408 : QAbstractSeries(*new QAreaSeriesPrivate(0, 0, this), parent)
409{
410}
411
412/*!
413 Destroys the object.
414*/
415QAreaSeries::~QAreaSeries()
416{
417 Q_D(QAreaSeries);
418 if (d->m_chart)
419 d->m_chart->removeSeries(series: this);
420}
421
422/*!
423 Returns QAbstractSeries::SeriesTypeArea.
424*/
425QAbstractSeries::SeriesType QAreaSeries::type() const
426{
427 return QAbstractSeries::SeriesTypeArea;
428}
429
430/*!
431 Sets the \a series that is to be used as the area chart upper series.
432 If the upper series is null, the area chart is not drawn, even if it has a lower series.
433*/
434void QAreaSeries::setUpperSeries(QLineSeries *series)
435{
436 Q_D(QAreaSeries);
437
438 if (d->m_upperSeries != series) {
439 if (series)
440 series->d_ptr->setBlockOpenGL(true);
441 d->m_upperSeries = series;
442 if (d->m_item)
443 static_cast<AreaChartItem *>(d->m_item.get())->setUpperSeries(series);
444 }
445}
446
447QLineSeries *QAreaSeries::upperSeries() const
448{
449 Q_D(const QAreaSeries);
450 return d->m_upperSeries;
451}
452
453/*!
454 Sets the \a series that is to be used as the area chart lower series.
455*/
456void QAreaSeries::setLowerSeries(QLineSeries *series)
457{
458 Q_D(QAreaSeries);
459 if (d->m_lowerSeries != series) {
460 if (series)
461 series->d_ptr->setBlockOpenGL(true);
462 d->m_lowerSeries = series;
463 if (d->m_item)
464 static_cast<AreaChartItem *>(d->m_item.get())->setLowerSeries(series);
465 }
466}
467
468QLineSeries *QAreaSeries::lowerSeries() const
469{
470 Q_D(const QAreaSeries);
471 return d->m_lowerSeries;
472}
473
474/*!
475 Sets the \a pen used for drawing the area outline.
476*/
477void QAreaSeries::setPen(const QPen &pen)
478{
479 Q_D(QAreaSeries);
480 if (d->m_pen != pen) {
481 bool emitColorChanged = pen.color() != d->m_pen.color();
482 d->m_pen = pen;
483 emit d->updated();
484 if (emitColorChanged)
485 emit borderColorChanged(color: pen.color());
486 }
487}
488
489QPen QAreaSeries::pen() const
490{
491 Q_D(const QAreaSeries);
492 if (d->m_pen == QChartPrivate::defaultPen())
493 return QPen();
494 else
495 return d->m_pen;
496}
497
498/*!
499 Sets the \a brush used for filling the area.
500*/
501void QAreaSeries::setBrush(const QBrush &brush)
502{
503 Q_D(QAreaSeries);
504 if (d->m_brush != brush) {
505 bool emitColorChanged = brush.color() != d->m_brush.color();
506 d->m_brush = brush;
507 emit d->updated();
508 if (emitColorChanged)
509 emit colorChanged(color: brush.color());
510 }
511}
512
513QBrush QAreaSeries::brush() const
514{
515 Q_D(const QAreaSeries);
516 if (d->m_brush == QChartPrivate::defaultBrush())
517 return QBrush();
518 else
519 return d->m_brush;
520}
521
522void QAreaSeries::setColor(const QColor &color)
523{
524 QBrush b = brush();
525 if (b == QBrush())
526 b.setStyle(Qt::SolidPattern);
527 b.setColor(color);
528 setBrush(b);
529}
530
531QColor QAreaSeries::color() const
532{
533 return brush().color();
534}
535
536void QAreaSeries::setBorderColor(const QColor &color)
537{
538 QPen p = pen();
539 p.setColor(color);
540 setPen(p);
541}
542
543QColor QAreaSeries::borderColor() const
544{
545 return pen().color();
546}
547
548/*!
549 Determines whether data points are \a visible and should be drawn on the line.
550*/
551void QAreaSeries::setPointsVisible(bool visible)
552{
553 Q_D(QAreaSeries);
554 if (d->m_pointsVisible != visible) {
555 d->m_pointsVisible = visible;
556 emit d->updated();
557 }
558}
559
560/*!
561 Returns whether the points are drawn for this series.
562 \sa setPointsVisible()
563*/
564bool QAreaSeries::pointsVisible() const
565{
566 Q_D(const QAreaSeries);
567 return d->m_pointsVisible;
568}
569
570void QAreaSeries::setPointLabelsFormat(const QString &format)
571{
572 Q_D(QAreaSeries);
573 if (d->m_pointLabelsFormat != format) {
574 d->m_pointLabelsFormat = format;
575 emit pointLabelsFormatChanged(format);
576 }
577}
578
579QString QAreaSeries::pointLabelsFormat() const
580{
581 Q_D(const QAreaSeries);
582 return d->m_pointLabelsFormat;
583}
584
585void QAreaSeries::setPointLabelsVisible(bool visible)
586{
587 Q_D(QAreaSeries);
588 if (d->m_pointLabelsVisible != visible) {
589 d->m_pointLabelsVisible = visible;
590 emit pointLabelsVisibilityChanged(visible);
591 }
592}
593
594bool QAreaSeries::pointLabelsVisible() const
595{
596 Q_D(const QAreaSeries);
597 return d->m_pointLabelsVisible;
598}
599
600void QAreaSeries::setPointLabelsFont(const QFont &font)
601{
602 Q_D(QAreaSeries);
603 if (d->m_pointLabelsFont != font) {
604 d->m_pointLabelsFont = font;
605 emit pointLabelsFontChanged(font);
606 }
607}
608
609QFont QAreaSeries::pointLabelsFont() const
610{
611 Q_D(const QAreaSeries);
612 return d->m_pointLabelsFont;
613}
614
615void QAreaSeries::setPointLabelsColor(const QColor &color)
616{
617 Q_D(QAreaSeries);
618 if (d->m_pointLabelsColor != color) {
619 d->m_pointLabelsColor = color;
620 emit pointLabelsColorChanged(color);
621 }
622}
623
624QColor QAreaSeries::pointLabelsColor() const
625{
626 Q_D(const QAreaSeries);
627 if (d->m_pointLabelsColor == QChartPrivate::defaultPen().color())
628 return QPen().color();
629 else
630 return d->m_pointLabelsColor;
631}
632
633void QAreaSeries::setPointLabelsClipping(bool enabled)
634{
635 Q_D(QAreaSeries);
636 if (d->m_pointLabelsClipping != enabled) {
637 d->m_pointLabelsClipping = enabled;
638 emit pointLabelsClippingChanged(clipping: enabled);
639 }
640}
641
642bool QAreaSeries::pointLabelsClipping() const
643{
644 Q_D(const QAreaSeries);
645 return d->m_pointLabelsClipping;
646}
647
648////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
649
650QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries, QAreaSeries *q)
651 : QAbstractSeriesPrivate(q),
652 m_brush(QChartPrivate::defaultBrush()),
653 m_pen(QChartPrivate::defaultPen()),
654 m_upperSeries(upperSeries),
655 m_lowerSeries(lowerSeries),
656 m_pointsVisible(false),
657 m_pointLabelsFormat(QLatin1String("@xPoint, @yPoint")),
658 m_pointLabelsVisible(false),
659 m_pointLabelsFont(QChartPrivate::defaultFont()),
660 m_pointLabelsColor(QChartPrivate::defaultPen().color()),
661 m_pointLabelsClipping(true)
662{
663}
664
665void QAreaSeriesPrivate::initializeDomain()
666{
667 Q_Q(QAreaSeries);
668
669 qreal minX(0.0);
670 qreal minY(0.0);
671 qreal maxX(1.0);
672 qreal maxY(1.0);
673
674 QLineSeries *upperSeries = q->upperSeries();
675 QLineSeries *lowerSeries = q->lowerSeries();
676
677 if (upperSeries) {
678 const auto &points = upperSeries->points();
679
680 if (!points.isEmpty()) {
681 minX = points[0].x();
682 minY = points[0].y();
683 maxX = minX;
684 maxY = minY;
685
686 for (int i = 0; i < points.size(); i++) {
687 qreal x = points[i].x();
688 qreal y = points[i].y();
689 minX = qMin(a: minX, b: x);
690 minY = qMin(a: minY, b: y);
691 maxX = qMax(a: maxX, b: x);
692 maxY = qMax(a: maxY, b: y);
693 }
694 }
695 }
696 if (lowerSeries) {
697 const auto &points = lowerSeries->points();
698
699 if (!points.isEmpty()) {
700 if (!upperSeries) {
701 minX = points[0].x();
702 minY = points[0].y();
703 maxX = minX;
704 maxY = minY;
705 }
706
707 for (int i = 0; i < points.size(); i++) {
708 qreal x = points[i].x();
709 qreal y = points[i].y();
710 minX = qMin(a: minX, b: x);
711 minY = qMin(a: minY, b: y);
712 maxX = qMax(a: maxX, b: x);
713 maxY = qMax(a: maxY, b: y);
714 }
715 }
716 }
717
718 domain()->setRange(minX, maxX, minY, maxY);
719}
720
721void QAreaSeriesPrivate::initializeGraphics(QGraphicsItem* parent)
722{
723 Q_Q(QAreaSeries);
724 AreaChartItem *area = new AreaChartItem(q,parent);
725 m_item.reset(p: area);
726 QAbstractSeriesPrivate::initializeGraphics(parent);
727}
728void QAreaSeriesPrivate::initializeAnimations(QChart::AnimationOptions options, int duration,
729 QEasingCurve &curve)
730{
731 Q_Q(QAreaSeries);
732 AreaChartItem *area = static_cast<AreaChartItem *>(m_item.get());
733
734 if (q->upperSeries() && area->upperLineItem()->animation())
735 area->upperLineItem()->animation()->stopAndDestroyLater();
736 if (q->lowerSeries() && area->lowerLineItem()->animation())
737 area->lowerLineItem()->animation()->stopAndDestroyLater();
738
739 if (options.testFlag(flag: QChart::SeriesAnimations)) {
740 area->upperLineItem()->setAnimation(new XYAnimation(area->upperLineItem(), duration,
741 curve));
742 if (q->lowerSeries())
743 area->lowerLineItem()->setAnimation(new XYAnimation(area->lowerLineItem(), duration,
744 curve));
745 } else {
746 if (q->upperSeries())
747 area->upperLineItem()->setAnimation(0);
748 if (q->lowerSeries())
749 area->lowerLineItem()->setAnimation(0);
750 }
751 QAbstractSeriesPrivate::initializeAnimations(options, duration, curve);
752}
753
754QList<QLegendMarker*> QAreaSeriesPrivate::createLegendMarkers(QLegend* legend)
755{
756 Q_Q(QAreaSeries);
757 QList<QLegendMarker*> list;
758 return list << new QAreaLegendMarker(q,legend);
759}
760
761
762void QAreaSeriesPrivate::initializeAxes()
763{
764
765}
766
767QAbstractAxis::AxisType QAreaSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const
768{
769 Q_UNUSED(orientation);
770 return QAbstractAxis::AxisTypeValue;
771}
772
773QAbstractAxis* QAreaSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const
774{
775 Q_UNUSED(orientation);
776 return new QValueAxis;
777}
778
779void QAreaSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forced)
780{
781 Q_Q(QAreaSeries);
782
783 const QList<QGradient> gradients = theme->seriesGradients();
784 const QList<QColor> colors = theme->seriesColors();
785
786 if (forced || QChartPrivate::defaultPen() == m_pen) {
787 QPen pen;
788 pen.setColor(ChartThemeManager::colorAt(gradient: gradients.at(i: index % gradients.size()), pos: 0.0));
789 pen.setWidthF(2);
790 q->setPen(pen);
791 }
792
793 if (forced || QChartPrivate::defaultBrush() == m_brush) {
794 QBrush brush(colors.at(i: index % colors.size()));
795 q->setBrush(brush);
796 }
797
798 if (forced || QChartPrivate::defaultPen().color() == m_pointLabelsColor) {
799 QColor color = theme->labelBrush().color();
800 q->setPointLabelsColor(color);
801 }
802}
803
804QT_END_NAMESPACE
805
806#include "moc_qareaseries.cpp"
807#include "moc_qareaseries_p.cpp"
808

source code of qtcharts/src/charts/areachart/qareaseries.cpp