diff --git a/oscar/Graphs/gSessionTimesChart.cpp b/oscar/Graphs/gSessionTimesChart.cpp index 8f2dd553..53f052ed 100644 --- a/oscar/Graphs/gSessionTimesChart.cpp +++ b/oscar/Graphs/gSessionTimesChart.cpp @@ -422,11 +422,20 @@ void gSummaryChart::paint(QPainter &painter, gGraph &graph, const QRegion ®io int idx = idx_start; + // Determine how many days after the first day of the chart that this data is to begin int numDaysOffset = 0; - if (firstday > date) { + if (firstday > date) { // date = beginning date of chart; firstday = beginning date of data numDaysOffset = date.daysTo(firstday); } + // Determine how many days before the last day of the chart that this data is to end + int numDaysAfter = 0; + if (enddate > lastday) { // enddate = last date of chart; lastday = last date of data + numDaysAfter = lastday.daysTo(enddate); + } + if (numDaysAfter > days) // Nothing to do if this data is off the left edge of the chart + return; + auto ite = dayindex.find(enddate); idx_end = daylist.size()-1; if (ite != dayindex.end()) { @@ -838,11 +847,20 @@ void gSessionTimesChart::paint(QPainter &painter, gGraph &graph, const QRegion & idx = it.value(); } + // Determine how many days after the first day of the chart that this data is to begin int numDaysOffset = 0; - if (firstday > date) { + if (firstday > date) { // date = beginning date of chart; firstday = beginning date of data numDaysOffset = date.daysTo(firstday); } + // Determine how many days before the last day of the chart that this data is to end + int numDaysAfter = 0; + if (enddate > lastday) { // enddate = last date of chart; lastday = last date of data + numDaysAfter = lastday.daysTo(enddate); + } + if (numDaysAfter > days) // Nothing to do if this data is off the left edge of the chart + return; + // float lasty1 = rect.bottom(); float lastx1 = rect.left(); lastx1 += numDaysOffset * barw;