1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 or (at your option) any later version |
20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by |
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 |
22 | ** included in the packaging of this file. Please review the following |
23 | ** information to ensure the GNU General Public License requirements will |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
25 | ** |
26 | ** $QT_END_LICENSE$ |
27 | ** |
28 | ****************************************************************************/ |
29 | |
30 | #ifndef QCATEGORYAXIS_H |
31 | #define QCATEGORYAXIS_H |
32 | |
33 | #include <QtCharts/QAbstractAxis> |
34 | #include <QtCharts/QValueAxis> |
35 | |
36 | QT_CHARTS_BEGIN_NAMESPACE |
37 | |
38 | class QCategoryAxisPrivate; |
39 | |
40 | class Q_CHARTS_EXPORT QCategoryAxis : public QValueAxis |
41 | { |
42 | Q_OBJECT |
43 | Q_PROPERTY(qreal startValue READ startValue WRITE setStartValue) |
44 | Q_PROPERTY(int count READ count) |
45 | Q_PROPERTY(QStringList categoriesLabels READ categoriesLabels) |
46 | Q_PROPERTY(AxisLabelsPosition labelsPosition READ labelsPosition WRITE setLabelsPosition NOTIFY labelsPositionChanged) |
47 | Q_ENUMS(AxisLabelsPosition) |
48 | |
49 | public: |
50 | |
51 | enum AxisLabelsPosition { |
52 | AxisLabelsPositionCenter = 0x0, |
53 | AxisLabelsPositionOnValue = 0x1 |
54 | }; |
55 | |
56 | explicit QCategoryAxis(QObject *parent = nullptr); |
57 | ~QCategoryAxis(); |
58 | |
59 | protected: |
60 | QCategoryAxis(QCategoryAxisPrivate &d, QObject *parent = nullptr); |
61 | |
62 | public: |
63 | AxisType type() const; |
64 | |
65 | void append(const QString &label, qreal categoryEndValue); |
66 | void remove(const QString &label); |
67 | void replaceLabel(const QString &oldLabel, const QString &newLabel); |
68 | |
69 | qreal startValue(const QString &categoryLabel = QString()) const; |
70 | void setStartValue(qreal min); |
71 | |
72 | qreal endValue(const QString &categoryLabel) const; |
73 | |
74 | QStringList categoriesLabels(); |
75 | int count() const; |
76 | |
77 | QCategoryAxis::AxisLabelsPosition labelsPosition() const; |
78 | void setLabelsPosition(QCategoryAxis::AxisLabelsPosition position); |
79 | |
80 | Q_SIGNALS: |
81 | void categoriesChanged(); |
82 | void labelsPositionChanged(QCategoryAxis::AxisLabelsPosition position); |
83 | |
84 | private: |
85 | Q_DECLARE_PRIVATE(QCategoryAxis) |
86 | Q_DISABLE_COPY(QCategoryAxis) |
87 | }; |
88 | |
89 | QT_CHARTS_END_NAMESPACE |
90 | |
91 | #endif // QCATEGORYAXIS_H |
92 | |