summaryrefslogtreecommitdiff
path: root/tests/fute/pieCharts/pieCharts_test.cpp
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2021-07-14 11:49:10 +1200
committerJedidiah Barber <contact@jedbarber.id.au>2021-07-14 11:49:10 +1200
commitd24f813f3f2a05c112e803e4256b53535895fc98 (patch)
tree601e6ae9a1cd44bcfdcf91739a5ca36aedd827c9 /tests/fute/pieCharts/pieCharts_test.cpp
Initial mirror commitHEADmaster
Diffstat (limited to 'tests/fute/pieCharts/pieCharts_test.cpp')
-rw-r--r--tests/fute/pieCharts/pieCharts_test.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/fute/pieCharts/pieCharts_test.cpp b/tests/fute/pieCharts/pieCharts_test.cpp
new file mode 100644
index 0000000..d88981a
--- /dev/null
+++ b/tests/fute/pieCharts/pieCharts_test.cpp
@@ -0,0 +1,52 @@
+#include "pieCharts_test.h"
+#include "../../../src/charts/PieChart.h"
+
+#include <cstdlib>
+#include <time.h>
+
+const QStringList PieChartsTest::Labels =
+ {"Studied", "Scheduled for today", "New"};
+
+PieChartsTest::PieChartsTest()
+{
+ srand(time(NULL));
+ createUi();
+ changeDataSet();
+}
+
+void PieChartsTest::changeDataSet()
+{
+ yValuesStr = "Values: ";
+ dataSet.clear();
+ for (int i = 0; i < 3; i++)
+ addDataPoint(i);
+ chart->setDataSet(dataSet);
+ valuesLabel->setText(yValuesStr);
+}
+
+void PieChartsTest::addDataPoint(int index)
+{
+ int yValue = rand() % 200;
+ dataSet << DataPoint(Labels[index], yValue, "");
+ yValuesStr += QString::number(yValue) + ", ";
+}
+
+void PieChartsTest::createUi()
+{
+ QPushButton* newBtn = new QPushButton(tr("New chart"));
+ connect(newBtn, SIGNAL(clicked()), SLOT(changeDataSet()));
+
+ valuesLabel = new QLabel;
+ chart = new PieChart;
+ chart->setColors({"#39c900", "#ece900", "#ff0000"});
+
+ 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);
+}