| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
#ifndef CHARTWIDGET_H |
| 5 |
#define CHARTWIDGET_H |
| 6 |
|
| 7 |
#include <QtWidgets/QHBoxLayout> |
| 8 |
#include <QtCharts/QChart> |
| 9 |
#include <QtCharts/QChartView> |
| 10 |
#include <QtCharts/QValueAxis> |
| 11 |
#include <QtCharts/QBarSeries> |
| 12 |
#include <QtCharts/QBarSet> |
| 13 |
#include <QtCore/QTimer> |
| 14 |
#include <QtCore/QElapsedTimer> |
| 15 |
|
| 16 |
QT_USE_NAMESPACE |
| 17 |
|
| 18 |
|
| 19 |
class ChartWidget : public QWidget |
| 20 |
{ |
| 21 |
Q_OBJECT |
| 22 |
|
| 23 |
public: |
| 24 |
explicit ChartWidget(QWidget *parent = 0); |
| 25 |
~ChartWidget(); |
| 26 |
|
| 27 |
public slots: |
| 28 |
void handleTimeout(); |
| 29 |
|
| 30 |
private: |
| 31 |
void createChart(); |
| 32 |
void addSeriesToChart(QAbstractBarSeries *series); |
| 33 |
|
| 34 |
private: |
| 35 |
QChart *m_chart; |
| 36 |
QChartView *m_chartView; |
| 37 |
QAbstractAxis *m_barAxis; |
| 38 |
QAbstractAxis *m_valueAxis; |
| 39 |
QList<QAbstractBarSeries *> m_series; |
| 40 |
QMap<const QAbstractBarSeries *, QList<QBarSet *>> m_sets; |
| 41 |
QTimer m_timer; |
| 42 |
QElapsedTimer m_elapsedTimer; |
| 43 |
QHBoxLayout *m_horizontalLayout; |
| 44 |
int m_setCount; |
| 45 |
int m_seriesCount; |
| 46 |
qreal m_extraScroll; |
| 47 |
}; |
| 48 |
|
| 49 |
#endif // CHARTWIDGET_H |