-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlineChart.cpp
37 lines (34 loc) · 1.15 KB
/
lineChart.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
#include "lineChart.h"
LineChart::LineChart(QString _title, Matrix* dataSet, const QVector<int>& numericIndexes) : title(_title)
{
int i = 0;
for(unsigned int col = 0; col < dataSet->getDataMatrixWidth(); col++){
if(numericIndexes.contains(col)){
numericData.append(new QVector<double>);
for(unsigned int y = 0; y < dataSet->getDataMatrixHeigth(); y++)
numericData.at(i)->append(static_cast<NumericData*>(dataSet->getDataAt(col,y))->getData());
i++;
columnsTitles.append(dataSet->getTitle(col));
}
}
}
LineChart::~LineChart()
{
for(int x = 0; x < numericData.size(); x++)
delete numericData.at(x);
}
QChart* LineChart::draw()
{
QChart* chart = new QChart();
for(int i = 0; i < numericData.size(); i++){
QLineSeries* line = new QLineSeries();
line->setName(columnsTitles.at(i));
for(int y = 0; y < numericData.at(0)->size(); y++)
line->append(y, numericData.at(i)->at(y));
chart->addSeries(line);
}
chart->createDefaultAxes();
chart->setTitle(title);
chart->legend()->setVisible(true);
return chart;
}