Added GeoJSON and DEM files info.
[GPXSee.git] / src / GUI / heartrategraphitem.cpp
blob7b5e77d0ac3661247dabee0d0cd52c38c7fe85e2
1 #include <QLocale>
2 #include "tooltip.h"
3 #include "heartrategraphitem.h"
6 HeartRateGraphItem::HeartRateGraphItem(const Graph &graph, GraphType type,
7 QGraphicsItem *parent) : GraphItem(graph, type, parent)
9 qreal sum = 0;
10 _max = graph.first().y();
12 for (int i = 1; i < graph.size(); i++) {
13 qreal y = graph.at(i).y();
14 sum += y * (graph.at(i).s() - graph.at(i-1).s());
15 if (y > _max)
16 _max = y;
18 _avg = sum/graph.last().s();
20 setToolTip(toolTip());
23 QString HeartRateGraphItem::toolTip() const
25 ToolTip tt;
26 QLocale l(QLocale::system());
28 tt.insert(tr("Maximum"), l.toString(max(), 'f', 0)
29 + UNIT_SPACE + tr("bpm"));
30 tt.insert(tr("Average"), l.toString(avg(), 'f', 0)
31 + UNIT_SPACE + tr("bpm"));
33 return tt.toString();