-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotter.cpp
41 lines (34 loc) · 1.14 KB
/
plotter.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "plotter.h"
plotter::plotter(QString s, QList<int> mylist)
{
customPlot = new QCustomPlot();
game_name = new QLabel("Game name: "+s);
sorry = new QLabel("Sorry there is no available history for this game");
QVector<double> x(101), y(101); // initialize with entries 0..100
for (int i=0; i<mylist.size(); ++i)
{
x[i] = i; // x goes from -1 to 1
y[i] = mylist.at(i); // let's plot a quadratic function
}
// create graph and assign data to it:
customPlot->addGraph();
customPlot->graph(0)->setData(x, y);
// give the axes some labels:
customPlot->xAxis->setLabel("Played times");
customPlot->yAxis->setLabel("Player Score");
// set axes ranges, so we see all data:
customPlot->xAxis->setRange(0, mylist.size());
customPlot->yAxis->setRange(0, 100);
customPlot->replot();
QWidget *temp_lay = dynamic_cast<QWidget *>(customPlot);
Vlayout = new QVBoxLayout;
//Vlayout->addWidget(game_name);
if(mylist.size()!=0){
Vlayout->addWidget(temp_lay);
}
else{
Vlayout->addWidget(sorry);
}
setFixedSize(600,500);
setLayout(Vlayout);
}