| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QABSTRACTSERIES_H |
| 5 | #define QABSTRACTSERIES_H |
| 6 | |
| 7 | #include <QtCharts/QChartGlobal> |
| 8 | #include <QtCharts/QAbstractAxis> |
| 9 | #include <QtCore/QObject> |
| 10 | #include <QtGui/QPen> |
| 11 | |
| 12 | QT_BEGIN_NAMESPACE |
| 13 | |
| 14 | class QAbstractSeriesPrivate; |
| 15 | class QChart; |
| 16 | |
| 17 | class Q_CHARTS_EXPORT QAbstractSeries : public QObject |
| 18 | { |
| 19 | Q_OBJECT |
| 20 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) |
| 21 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) |
| 22 | Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) |
| 23 | Q_PROPERTY(SeriesType type READ type) |
| 24 | Q_PROPERTY(bool useOpenGL READ useOpenGL WRITE setUseOpenGL NOTIFY useOpenGLChanged) |
| 25 | Q_ENUMS(SeriesType) |
| 26 | |
| 27 | public: |
| 28 | enum SeriesType { |
| 29 | SeriesTypeLine, |
| 30 | SeriesTypeArea, |
| 31 | SeriesTypeBar, |
| 32 | SeriesTypeStackedBar, |
| 33 | SeriesTypePercentBar, |
| 34 | SeriesTypePie, |
| 35 | SeriesTypeScatter, |
| 36 | SeriesTypeSpline, |
| 37 | SeriesTypeHorizontalBar, |
| 38 | SeriesTypeHorizontalStackedBar, |
| 39 | SeriesTypeHorizontalPercentBar, |
| 40 | SeriesTypeBoxPlot, |
| 41 | SeriesTypeCandlestick |
| 42 | }; |
| 43 | |
| 44 | protected: |
| 45 | QAbstractSeries(QAbstractSeriesPrivate &d, QObject *parent = nullptr); |
| 46 | |
| 47 | public: |
| 48 | ~QAbstractSeries(); |
| 49 | virtual SeriesType type() const = 0; |
| 50 | |
| 51 | void setName(const QString &name); |
| 52 | QString name() const; |
| 53 | void setVisible(bool visible = true); |
| 54 | bool isVisible() const; |
| 55 | qreal opacity() const; |
| 56 | void setOpacity(qreal opacity); |
| 57 | void setUseOpenGL(bool enable = true); |
| 58 | bool useOpenGL() const; |
| 59 | |
| 60 | QChart *chart() const; |
| 61 | |
| 62 | bool attachAxis(QAbstractAxis *axis); |
| 63 | bool detachAxis(QAbstractAxis *axis); |
| 64 | QList<QAbstractAxis*> attachedAxes(); |
| 65 | |
| 66 | void show(); |
| 67 | void hide(); |
| 68 | |
| 69 | Q_SIGNALS: |
| 70 | void nameChanged(); |
| 71 | void visibleChanged(); |
| 72 | void opacityChanged(); |
| 73 | void useOpenGLChanged(); |
| 74 | |
| 75 | protected: |
| 76 | QScopedPointer<QAbstractSeriesPrivate> d_ptr; |
| 77 | friend class ChartDataSet; |
| 78 | friend class ChartPresenter; |
| 79 | friend class ChartThemeManager; |
| 80 | friend class QLegendPrivate; |
| 81 | friend class DeclarativeChart; |
| 82 | friend class QAreaSeries; |
| 83 | friend class GLWidget; |
| 84 | }; |
| 85 | |
| 86 | QT_END_NAMESPACE |
| 87 | |
| 88 | #endif // QABSTRACTSERIES_H |
| 89 | |