X-Git-Url: https://www.flypig.org.uk/git/?p=harbour-pedalo.git;a=blobdiff_plain;f=src%2Fstatsweekdaycongestion.cpp;fp=src%2Fstatsweekdaycongestion.cpp;h=c4842b3742ceab4be4f0872c2f47d9f47185215c;hp=685e17540876eea8322df79d8247452dfabb11b0;hb=e6c4099f5bb1565a770e55d1dd671d846dcbd68b;hpb=dc14479d561196e19417c4ecf78e847ec4b43b7c diff --git a/src/statsweekdaycongestion.cpp b/src/statsweekdaycongestion.cpp index 685e175..c4842b3 100644 --- a/src/statsweekdaycongestion.cpp +++ b/src/statsweekdaycongestion.cpp @@ -5,13 +5,13 @@ StatsWeekdayCongestion::StatsWeekdayCongestion(JourneyModel * journeys) : journeys(journeys) { - title = "Congested days (cycles passed)"; + title = "Congestion by day (cycles per hour)"; units = ""; labels = QStringList{"M", "T", "W", "Th", "F", "S", "Su"}; } void StatsWeekdayCongestion::update() { - quint32 passed[7]; + double passed[7]; unsigned int count[7]; int pos; @@ -26,8 +26,9 @@ void StatsWeekdayCongestion::update() { foreach (Journey const &journey, journeys->getData()) { QDate date = journey.getStartDate(); int dayofweek = date.dayOfWeek() - 1; + double duration = journey.getDuration() / (60.0 * 60.0); if (dayofweek >= 0) { - passed[dayofweek] += journey.getOvertook() + journey.getOvertakenBy(); + passed[dayofweek] += (journey.getOvertook() + journey.getOvertakenBy()) / duration; count[dayofweek]++; } } @@ -44,7 +45,7 @@ void StatsWeekdayCongestion::update() { values << result; } - step = qRound(maxval / 5.0); + step = maxval > 5.0 ? qRound(maxval / 5.0) : (maxval / 5.0); qDebug() << "Calculated values"; }