summaryrefslogtreecommitdiff
path: root/src/charts/PieChartScene.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 /src/charts/PieChartScene.cpp
Initial mirror commitHEADmaster
Diffstat (limited to 'src/charts/PieChartScene.cpp')
-rw-r--r--src/charts/PieChartScene.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/charts/PieChartScene.cpp b/src/charts/PieChartScene.cpp
new file mode 100644
index 0000000..135a0e4
--- /dev/null
+++ b/src/charts/PieChartScene.cpp
@@ -0,0 +1,30 @@
+#include <cstdlib>
+#include <cmath>
+#include "PieChartScene.h"
+#include "PieRound.h"
+#include "PieLegend.h"
+
+const QSizeF PieChartScene::Margin(20, 20);
+const QSizeF PieChartScene::Size(500, 230);
+
+PieChartScene::PieChartScene(PieChart* chart):
+ QGraphicsScene(chart), chart(chart)
+{
+ setSceneRect(0, 0, Size.width(), Size.height());
+}
+
+void PieChartScene::setDataSet(const QList<DataPoint>& dataSet)
+{
+ clear();
+ this->dataSet = dataSet;
+ int centerPos = PieRound::Margin + PieRound::Radius;
+ QPointF roundPos(QPointF(Margin.width(), Margin.height()) +
+ QPointF(centerPos, centerPos));
+ addItem(new PieRound(roundPos, this));
+ addItem(new PieLegend(roundPos + QPointF(LegendDistance, 0), this));
+}
+
+void PieChartScene::setColors(const QStringList& colors)
+{
+ this->colors = colors;
+}