1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4// W A R N I N G
5// -------------
6//
7// This file is not part of the Qt Chart API. It exists purely as an
8// implementation detail. This header file may change from version to
9// version without notice, or even be removed.
10//
11// We mean it.
12
13#ifndef QXYSERIES_P_H
14#define QXYSERIES_P_H
15
16#include <private/qabstractseries_p.h>
17#include <private/qxyseries_p.h>
18#include <QtCharts/private/qchartglobal_p.h>
19#include <QtCore/qvariant.h>
20#include <QtCore/qhash.h>
21#include <QtCore/qset.h>
22#include <QtGui/qcolor.h>
23#include <QtGui/qpen.h>
24#include <QtCore/qlist.h>
25
26QT_BEGIN_NAMESPACE
27
28class QAbstractAxis;
29
30class Q_CHARTS_PRIVATE_EXPORT QXYSeriesPrivate: public QAbstractSeriesPrivate
31{
32 Q_OBJECT
33
34public:
35 QXYSeriesPrivate(QXYSeries *q);
36
37 void initializeDomain() override;
38 void initializeAxes() override;
39 void initializeAnimations(QChart::AnimationOptions options, int duration,
40 QEasingCurve &curve) override;
41
42 QList<QLegendMarker*> createLegendMarkers(QLegend* legend) override;
43
44 QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const override;
45 QAbstractAxis* createDefaultAxis(Qt::Orientation orientation) const override;
46
47 void drawPointLabels(QPainter *painter, const QList<QPointF> &allPoints, const int offset = 0);
48 void drawSeriesPointLabels(QPainter *painter, const QList<QPointF> &points,
49 const int offset = 0, const QHash<int, int> &offsets = {},
50 const QList<int> &indexesToSkip = {},
51 const QHash<int, QString> &customLabels = {});
52
53 void drawBestFitLine(QPainter *painter, const QRectF &clipRect);
54 QPair<qreal, qreal> bestFitLineEquation(bool &ok) const;
55
56 void setPointSelected(int index, bool selected, bool &callSignal);
57 bool isPointSelected(int index);
58
59 bool isMarkerSizeDefault();
60 void setMarkerSize(qreal markerSize);
61
62 QList<qreal> colorByData() const;
63
64 bool setPointConfiguration(const int index, const QXYSeries::PointConfiguration key,
65 const QVariant &value);
66
67
68Q_SIGNALS:
69 void seriesUpdated();
70
71protected:
72 QList<QPointF> m_points;
73 QSet<int> m_selectedPoints;
74 QPen m_pen;
75 QColor m_selectedColor;
76 QBrush m_brush;
77 bool m_pointsVisible;
78 QString m_pointLabelsFormat;
79 bool m_pointLabelsVisible;
80 QFont m_pointLabelsFont;
81 QColor m_pointLabelsColor;
82 bool m_pointLabelsClipping;
83 QImage m_lightMarker;
84 QImage m_selectedLightMarker;
85 QPen m_bestFitLinePen;
86 bool m_bestFitLineVisible;
87 qreal m_markerSize;
88 bool m_markerSizeDefault = true;
89
90 QHash<int, QHash<QXYSeries::PointConfiguration, QVariant>> m_pointsConfiguration;
91 QList<qreal> m_colorByData;
92
93private:
94 Q_DECLARE_PUBLIC(QXYSeries)
95 friend class QScatterSeries;
96};
97
98QT_END_NAMESPACE
99
100#endif
101

source code of qtcharts/src/charts/xychart/qxyseries_p.h