1 #include "statsweekdaycongestion.h"
3 StatsWeekdayCongestion::StatsWeekdayCongestion(JourneyModel
* journeys
) :
6 title
= "Congestion by day (cycles per hour)";
8 labels
= QStringList
{"M", "T", "W", "Th", "F", "S", "Su"};
11 void StatsWeekdayCongestion::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;
26 double duration
= journey
.getDuration() / (60.0 * 60.0);
28 passed
[dayofweek
] += (journey
.getOvertook() + journey
.getOvertakenBy()) / duration
;
34 for (pos
= 0; pos
< 7; pos
++) {
37 result
= ((double)passed
[pos
] / (double)count
[pos
]);
39 if (result
> maxval
) {
45 step
= maxval
> 5.0 ? qRound(maxval
/ 5.0) : (maxval
/ 5.0);