-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchartdata.cpp
More file actions
48 lines (37 loc) · 913 Bytes
/
chartdata.cpp
File metadata and controls
48 lines (37 loc) · 913 Bytes
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
38
39
40
41
42
43
44
45
46
47
48
#include "chartdata.h"
void ChartData::addPoint(const Point& p)
{
points.append(p);
}
void ChartData::setTitle(const QString& t)
{
title = t;
}
void BarChart::update(QChart* chart, const ChartData& data)
{
chart->removeAllSeries();
for (auto axis : chart->axes())
chart->removeAxis(axis);
auto series = new QBarSeries();
for (auto point : data.points)
{
auto ok = true;
auto value = point.value.toFloat(&ok);
if (ok)
{
auto barSet = new QBarSet(point.key);
barSet->append(value);
series->append(barSet);
}
else
return;
}
auto valueAxis = new QValueAxis();
chart->legend()->show();
chart->addSeries(series);
chart->addAxis(valueAxis, Qt::AlignLeft);
series->attachAxis(valueAxis);
}
void PieChart::update(QChart* chart, const ChartData& data)
{
}