summaryrefslogtreecommitdiff
path: root/tests/fute/charts/charts_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/fute/charts/charts_test.cpp')
-rw-r--r--tests/fute/charts/charts_test.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/fute/charts/charts_test.cpp b/tests/fute/charts/charts_test.cpp
new file mode 100644
index 0000000..0870027
--- /dev/null
+++ b/tests/fute/charts/charts_test.cpp
@@ -0,0 +1,52 @@
+#include "charts_test.h"
+#include "../../../src/charts/Chart.h"
+
+#include <cstdlib>
+#include <time.h>
+
+ChartsTest::ChartsTest()
+{
+ srand(time(NULL));
+ createUi();
+ changeDataSet();
+}
+
+void ChartsTest::changeDataSet()
+{
+ const int daysNum = 7;
+ yValuesStr = "Values: ";
+ dataSet.clear();
+ for (int i = 0; i < daysNum; i++)
+ addDataPoint(i);
+ chart->setDataSet(dataSet);
+ valuesLabel->setText(yValuesStr);
+}
+
+void ChartsTest::addDataPoint(int index)
+{
+ const int firstDay = 15;
+ QString xLabel = QString::number(firstDay + index) + ".11";
+ int yValue = rand() % 70;
+ dataSet << DataPoint(xLabel, yValue, xLabel);
+ yValuesStr += QString::number(yValue) + ", ";
+}
+
+void ChartsTest::createUi()
+{
+ QPushButton* newBtn = new QPushButton(tr("New chart"));
+ connect(newBtn, SIGNAL(clicked()), SLOT(changeDataSet()));
+
+ valuesLabel = new QLabel;
+ chart = new Chart;
+ chart->setLabels("Date", "Value");
+
+ QHBoxLayout* controlLt = new QHBoxLayout;
+ controlLt->addWidget(valuesLabel);
+ controlLt->addWidget(newBtn);
+
+ QVBoxLayout* mainLt = new QVBoxLayout;
+ mainLt->addLayout(controlLt);
+ mainLt->addWidget(chart);
+ setLayout(mainLt);
+ resize(800, 500);
+}