51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
#ifndef COALDISTRIBUTBARCHARTWIDGET_H
|
||
#define COALDISTRIBUTBARCHARTWIDGET_H
|
||
|
||
#include <QDateTime>
|
||
#include <QObject>
|
||
#include <QTimer>
|
||
#include <QWidget>
|
||
|
||
#include <QDateTimeAxis>
|
||
#include <QtCharts/QBarSeries>
|
||
#include <QtCharts/QBarSet>
|
||
#include <QtCharts/QCategoryAxis>
|
||
#include <QtCharts/QChartView>
|
||
#include <QtCharts/QValueAxis>
|
||
|
||
QT_CHARTS_USE_NAMESPACE
|
||
|
||
class CoalDistributBarChartWidget : public QWidget {
|
||
Q_OBJECT
|
||
public:
|
||
explicit CoalDistributBarChartWidget(QWidget* parent = nullptr);
|
||
|
||
private slots:
|
||
void updateChart();
|
||
|
||
private:
|
||
void initializeChart();
|
||
|
||
void setupTimer();
|
||
|
||
private:
|
||
QChart* m_chart;
|
||
QChartView* m_chartView;
|
||
QBarSeries* m_series;
|
||
QTimer* m_timer;
|
||
|
||
QDateTimeAxis* m_axisX;
|
||
|
||
int currentIndex; // 当前更新的柱子的索引
|
||
|
||
static const int MaxDataPoints = 300; // 最大数据点数(5分钟,每秒1条)
|
||
QBarSet* m_set;
|
||
// QList<QString> m_timeLabels;
|
||
QList<QDateTime> m_timeLabels; // 存储时间标签
|
||
QList<double> m_values; // 存储比例值
|
||
|
||
// QList<QDateTime> timestamps; // 存储时间戳
|
||
};
|
||
|
||
#endif // COALDISTRIBUTBARCHARTWIDGET_H
|