File indexing completed on 2024-05-05 16:16:43

0001 /*
0002  * SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiemstra@heimr.nl>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005  */
0006 
0007 #ifndef BARCHARTNODE_H
0008 #define BARCHARTNODE_H
0009 
0010 #include <QColor>
0011 #include <QSGGeometryNode>
0012 
0013 struct Bar {
0014     float x;
0015     float width;
0016     float value;
0017     QColor color;
0018 };
0019 
0020 class BarChartNode : public QSGNode
0021 {
0022 public:
0023     BarChartNode();
0024 
0025     void setRect(const QRectF &rect);
0026     void setBars(const QVector<Bar> &bars);
0027     void setRadius(qreal radius);
0028     void setBackgroundColor(const QColor &color);
0029     void update();
0030 
0031 private:
0032     QRectF m_rect;
0033     QVector<Bar> m_bars;
0034     qreal m_radius = 0.0;
0035     QColor m_backgroundColor = Qt::transparent;
0036 };
0037 
0038 #endif // BARCHARTNODE_H