blob: 135a0e44d0707d5d35d5a66184d6bb7755a6df76 (
plain)
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
|
#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;
}
|