Code Documentation 3.1
Social Network Visualizer
Loading...
Searching...
No Matches
chart.h
Go to the documentation of this file.
1/***************************************************************************
2 SocNetV: Social Network Visualizer
3 version: 3.2
4 Written in Qt
5
6 chart.h - description
7 -------------------
8 copyright : (C) 2005-2023 by Dimitris B. Kalamaras
9 project site : https://socnetv.org
10
11 ***************************************************************************/
12
13/*******************************************************************************
14* This program is free software: you can redistribute it and/or modify *
15* it under the terms of the GNU General Public License as published by *
16* the Free Software Foundation, either version 3 of the License, or *
17* (at your option) any later version. *
18* *
19* This program is distributed in the hope that it will be useful, *
20* but WITHOUT ANY WARRANTY; without even the implied warranty of *
21* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22* GNU General Public License for more details. *
23* *
24* You should have received a copy of the GNU General Public License *
25* along with this program. If not, see <http://www.gnu.org/licenses/>. *
26********************************************************************************/
27
28#ifndef CHART_H
29#define CHART_H
30
31#include <QObject>
32#include <QtCharts/QChartGlobal>
33#include <QtCharts/QChartView>
34
35
36class QSplineSeries;
37class QChart;
38class QAbstractAxis;
39
40class Chart : public QChartView
41{
42 Q_OBJECT
43public:
44 explicit Chart (QWidget *parent = Q_NULLPTR );
45 //explicit Chart ( QChart *ch = Q_NULLPTR, QWidget *parent = Q_NULLPTR );
46 ~Chart();
47
48 void setTitle(const QString &title = QString(), const QFont &font=QFont());
49 void addSeries(QAbstractSeries *series = Q_NULLPTR );
50 void appendToSeries (const QPointF &p);
51 void removeAllSeries();
52
53 void createDefaultAxes();
54 QList<QAbstractAxis*> axes(Qt::Orientations orientation = Qt::Horizontal|Qt::Vertical,
55 QAbstractSeries *series = Q_NULLPTR) const;
56 void removeAllAxes();
57
58 void addAxis(QAbstractAxis *axis, Qt::Alignment alignment);
59
60 void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = Q_NULLPTR);
61 void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = Q_NULLPTR);
62
63 void setAxisXRange(const QVariant &min, const QVariant &max);
64 void setAxisXMin(const QVariant &min);
65 void setAxisYRange(const QVariant &min, const QVariant &max);
66 void setAxisYMin(const QVariant &min);
67
68 void setAxesThemeDefault ();
69
70 void setAxisXLabelsAngle (const int &angle);
71
72 void setAxisXLabelFont(const QFont &font=QFont("Helvetica", 6 ));
73 void setAxisYLabelFont(const QFont &font=QFont("Helvetica", 6 ));
74
75 void setAxisXLinePen(const QPen &pen = QPen(QColor("#d0d0d0"), 1,Qt::SolidLine) );
76 void setAxisYLinePen(const QPen &pen = QPen(QColor("#d0d0d0"), 1,Qt::SolidLine) );
77
78 void setAxisXGridLinePen(const QPen &pen = QPen(QColor("#e0e0e0"), 1,Qt::DotLine) );
79 void setAxisYGridLinePen(const QPen &pen = QPen(QColor("#e0e0e0"), 1,Qt::DotLine) );
80
81
82 void setTheme(QChart::ChartTheme theme=QChart::ChartThemeLight);
83 void setThemeSmallWidget(const int minWidth, const int minHeight);
84
85 void setChartBackgroundBrush(const QBrush & brush = QBrush(Qt::transparent));
86 void setChartBackgroundPen(const QPen & pen = QPen(Qt::transparent));
87 void setMargins(const QMargins &margins = QMargins());
88 void toggleLegend(const bool &toggle = false);
89
90 void resetToTrivial();
91
92private:
93 QChart *m_chart;
94 QSplineSeries *m_series;
95};
96
97#endif // CHART_H
Definition chart.h:41
void setThemeSmallWidget(const int minWidth, const int minHeight)
Set the theme for when our chart widget is small.
Definition chart.cpp:390
void setAxisXLinePen(const QPen &pen=QPen(QColor("#d0d0d0"), 1, Qt::SolidLine))
Set the line pen of the horizontal axis.
Definition chart.cpp:295
void setAxisYLinePen(const QPen &pen=QPen(QColor("#d0d0d0"), 1, Qt::SolidLine))
Set the line pen of the vertical axis.
Definition chart.cpp:306
void removeAllSeries()
Removes and deletes all series objects that have been added to the chart.
Definition chart.cpp:108
void setAxisYRange(const QVariant &min, const QVariant &max)
Set the range of the vertical axis.
Definition chart.cpp:244
void setAxisXLabelFont(const QFont &font=QFont("Helvetica", 6))
Set the label font of the horizontal axis.
Definition chart.cpp:272
void appendToSeries(const QPointF &p)
Adds the data point p(qreal,qreal) to the series.
Definition chart.cpp:99
QChart * m_chart
Definition chart.h:93
void setAxesThemeDefault()
Applies a simple theme to axes (default label fonts, line and grid line pen). WARNING: Axes must be a...
Definition chart.cpp:433
QSplineSeries * m_series
Definition chart.h:94
void setAxisYMin(const QVariant &min)
Sets the minimum value shown on the vertical axis.
Definition chart.cpp:255
void setMargins(const QMargins &margins=QMargins())
Set the margins of the QChart.
Definition chart.cpp:412
void setChartBackgroundBrush(const QBrush &brush=QBrush(Qt::transparent))
Sets the background brush of the QChart If no brush defined, it uses a transparent brush.
Definition chart.cpp:359
~Chart()
Definition chart.cpp:59
void setAxisY(QAbstractAxis *axis, QAbstractSeries *series=Q_NULLPTR)
Adds the axis axis to the chart and attaches it to the series series as a left-aligned horizontal axi...
Definition chart.cpp:193
void setAxisXRange(const QVariant &min, const QVariant &max)
Set the range of the (first) horizontal axis.
Definition chart.cpp:222
void setAxisX(QAbstractAxis *axis, QAbstractSeries *series=Q_NULLPTR)
Adds the axis axis to the chart and attaches it to the series series as a bottom-aligned horizontal a...
Definition chart.cpp:178
void setAxisXGridLinePen(const QPen &pen=QPen(QColor("#e0e0e0"), 1, Qt::DotLine))
Set the grid line pen of the horizontal axis.
Definition chart.cpp:319
void removeAllAxes()
Removes all previously attached X,Y axes from the QChart.
Definition chart.cpp:148
void setChartBackgroundPen(const QPen &pen=QPen(Qt::transparent))
Sets the background pen of the QChart If no pen defined, it uses a transparent pen.
Definition chart.cpp:370
void addAxis(QAbstractAxis *axis, Qt::Alignment alignment)
Add Axis axis to the QChart. Does not delete previously attached axis.
Definition chart.cpp:208
void setAxisXMin(const QVariant &min)
Sets the minimum value shown on the horizontal axis.
Definition chart.cpp:232
void createDefaultAxes()
Creates default axes. Must be called AFTER loading a series to the chart.
Definition chart.cpp:124
void setAxisYGridLinePen(const QPen &pen=QPen(QColor("#e0e0e0"), 1, Qt::DotLine))
Set the grid line pen of the vertical axis.
Definition chart.cpp:330
void setTitle(const QString &title=QString(), const QFont &font=QFont())
Set the title of the QChart.
Definition chart.cpp:422
void setTheme(QChart::ChartTheme theme=QChart::ChartThemeLight)
Set the theme of the QChart.
Definition chart.cpp:380
void setAxisXLabelsAngle(const int &angle)
Definition chart.cpp:262
QList< QAbstractAxis * > axes(Qt::Orientations orientation=Qt::Horizontal|Qt::Vertical, QAbstractSeries *series=Q_NULLPTR) const
Definition chart.cpp:131
void resetToTrivial()
Definition chart.cpp:447
void addSeries(QAbstractSeries *series=Q_NULLPTR)
Adds QAbstractSeries series to chart If no series are passed, a new QSplineSeries is created with 1 p...
Definition chart.cpp:74
void toggleLegend(const bool &toggle=false)
Toggle the legend of the QChart.
Definition chart.cpp:344
void setAxisYLabelFont(const QFont &font=QFont("Helvetica", 6))
Set the label font of the vertical axis.
Definition chart.cpp:283