1 #include "statsweekdayave.h"
3 StatsWeekdayAve::StatsWeekdayAve(JourneyModel
* journeys
) :
6 title
= "Average journey time (mins)";
8 labels
= QStringList
{"M", "T", "W", "Th", "F", "S", "Su"};
11 void StatsWeekdayAve::update() {
13 unsigned int count
[7];
18 for (pos
= 0; pos
< 7; pos
++) {
23 foreach (Journey
const &journey
, journeys
->getData()) {
24 QDate date
= journey
.getStartDate();
25 int dayofweek
= date
.dayOfWeek() - 1;
27 duration
[dayofweek
] += journey
.getDuration();
33 for (pos
= 0; pos
< 7; pos
++) {
36 result
= ((duration
[pos
] / 60.0) / (double)count
[pos
]);
38 if (result
> maxval
) {
44 step
= maxval
> 5.0 ? qRound(maxval
/ 5.0) : (maxval
/ 5.0);