1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QABSTRACTBARSERIES_H
5#define QABSTRACTBARSERIES_H
6
7#include <QtCharts/QAbstractSeries>
8#include <QtCore/QStringList>
9
10QT_BEGIN_NAMESPACE
11
12class QBarSet;
13class QAbstractBarSeriesPrivate;
14
15// Container for series
16class Q_CHARTS_EXPORT QAbstractBarSeries : public QAbstractSeries
17{
18 Q_OBJECT
19 Q_PROPERTY(qreal barWidth READ barWidth WRITE setBarWidth)
20 Q_PROPERTY(int count READ count NOTIFY countChanged)
21 Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
22 Q_PROPERTY(QString labelsFormat READ labelsFormat WRITE setLabelsFormat NOTIFY labelsFormatChanged)
23 Q_PROPERTY(LabelsPosition labelsPosition READ labelsPosition WRITE setLabelsPosition NOTIFY labelsPositionChanged)
24 Q_PROPERTY(qreal labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged)
25 Q_PROPERTY(int labelsPrecision READ labelsPrecision WRITE setLabelsPrecision NOTIFY labelsPrecisionChanged)
26 Q_ENUMS(LabelsPosition)
27
28public:
29 enum LabelsPosition {
30 LabelsCenter = 0,
31 LabelsInsideEnd,
32 LabelsInsideBase,
33 LabelsOutsideEnd
34 };
35
36public:
37 virtual ~QAbstractBarSeries();
38
39 void setBarWidth(qreal width);
40 qreal barWidth() const;
41
42 bool append(QBarSet *set);
43 bool remove(QBarSet *set);
44 bool take(QBarSet *set);
45 bool append(const QList<QBarSet *> &sets);
46 bool insert(int index, QBarSet *set);
47 int count() const;
48 QList<QBarSet *> barSets() const;
49 void clear();
50
51 void setLabelsVisible(bool visible = true);
52 bool isLabelsVisible() const;
53
54 void setLabelsFormat(const QString &format);
55 QString labelsFormat() const;
56
57 void setLabelsAngle(qreal angle);
58 qreal labelsAngle() const;
59
60 void setLabelsPosition(QAbstractBarSeries::LabelsPosition position);
61 QAbstractBarSeries::LabelsPosition labelsPosition() const;
62
63 void setLabelsPrecision(int precision);
64 int labelsPrecision() const;
65
66protected:
67 explicit QAbstractBarSeries(QAbstractBarSeriesPrivate &d, QObject *parent = nullptr);
68
69Q_SIGNALS:
70 void clicked(int index, QBarSet *barset);
71 void hovered(bool status, int index, QBarSet *barset);
72 void pressed(int index, QBarSet *barset);
73 void released(int index, QBarSet *barset);
74 void doubleClicked(int index, QBarSet *barset);
75 void countChanged();
76 void labelsVisibleChanged();
77 void labelsFormatChanged(const QString &format);
78 void labelsPositionChanged(QAbstractBarSeries::LabelsPosition position);
79 void labelsAngleChanged(qreal angle);
80 void labelsPrecisionChanged(int precision);
81
82 void barsetsAdded(const QList<QBarSet *> &sets);
83 void barsetsRemoved(const QList<QBarSet *> &sets);
84
85protected:
86 Q_DECLARE_PRIVATE(QAbstractBarSeries)
87 friend class AbstractBarChartItem;
88 friend class PercentBarChartItem;
89 friend class StackedBarChartItem;
90 friend class BoxPlotChartItem;
91 friend class BarChartItem;
92 friend class HorizontalBarChartItem;
93 friend class HorizontalStackedBarChartItem;
94 friend class HorizontalPercentBarChartItem;
95 friend class BarSet;
96};
97
98QT_END_NAMESPACE
99
100#endif // QABSTRACTBARSERIES_H
101

source code of qtcharts/src/charts/barchart/qabstractbarseries.h