1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QCATEGORYAXIS_H |
5 | #define QCATEGORYAXIS_H |
6 | |
7 | #include <QtCharts/QAbstractAxis> |
8 | #include <QtCharts/QValueAxis> |
9 | |
10 | QT_BEGIN_NAMESPACE |
11 | |
12 | class QCategoryAxisPrivate; |
13 | |
14 | class Q_CHARTS_EXPORT QCategoryAxis : public QValueAxis |
15 | { |
16 | Q_OBJECT |
17 | Q_PROPERTY(qreal startValue READ startValue WRITE setStartValue) |
18 | Q_PROPERTY(int count READ count) |
19 | Q_PROPERTY(QStringList categoriesLabels READ categoriesLabels) |
20 | Q_PROPERTY(AxisLabelsPosition labelsPosition READ labelsPosition WRITE setLabelsPosition NOTIFY labelsPositionChanged) |
21 | Q_ENUMS(AxisLabelsPosition) |
22 | |
23 | public: |
24 | |
25 | enum AxisLabelsPosition { |
26 | AxisLabelsPositionCenter = 0x0, |
27 | AxisLabelsPositionOnValue = 0x1 |
28 | }; |
29 | |
30 | explicit QCategoryAxis(QObject *parent = nullptr); |
31 | ~QCategoryAxis(); |
32 | |
33 | protected: |
34 | QCategoryAxis(QCategoryAxisPrivate &d, QObject *parent = nullptr); |
35 | |
36 | public: |
37 | AxisType type() const override; |
38 | |
39 | void append(const QString &label, qreal categoryEndValue); |
40 | void remove(const QString &label); |
41 | void replaceLabel(const QString &oldLabel, const QString &newLabel); |
42 | |
43 | qreal startValue(const QString &categoryLabel = QString()) const; |
44 | void setStartValue(qreal min); |
45 | |
46 | qreal endValue(const QString &categoryLabel) const; |
47 | |
48 | QStringList categoriesLabels(); |
49 | int count() const; |
50 | |
51 | QCategoryAxis::AxisLabelsPosition labelsPosition() const; |
52 | void setLabelsPosition(QCategoryAxis::AxisLabelsPosition position); |
53 | |
54 | Q_SIGNALS: |
55 | void categoriesChanged(); |
56 | void labelsPositionChanged(QCategoryAxis::AxisLabelsPosition position); |
57 | |
58 | private: |
59 | Q_DECLARE_PRIVATE(QCategoryAxis) |
60 | Q_DISABLE_COPY(QCategoryAxis) |
61 | }; |
62 | |
63 | QT_END_NAMESPACE |
64 | |
65 | #endif // QCATEGORYAXIS_H |
66 |