diff --git a/src/commands/CmdChart.cpp b/src/commands/CmdChart.cpp index ae616a5e..4f3c85cf 100644 --- a/src/commands/CmdChart.cpp +++ b/src/commands/CmdChart.cpp @@ -45,7 +45,7 @@ static std::string renderDayName (const std::string&, const Rules&, Date static std::string renderTotal (const std::string&, const Rules&, time_t); static std::string renderSubTotal (const std::string&, const Rules&, int, int, time_t); static void renderExclusionBlocks (const std::string&, const Rules&, std::vector &, Palette&, const Datetime&, int, int, const std::vector &); -static void renderInterval (const std::string&, const Rules&, std::vector &, const Datetime&, const Interval&, Palette&, std::map &, time_t&); +static void renderInterval (const std::string&, const Rules&, std::vector &, const Datetime&, const Interval&, Palette&, std::map &, int, time_t&); std::string renderHolidays (const std::string&, const Rules&, const Interval&); static std::string renderSummary (const std::string&, const Rules&, const std::string&, const Interval&, const std::vector &, const std::vector &, bool); @@ -174,7 +174,7 @@ int renderChart ( for (auto& track : tracked) { time_t interval_work = 0; - renderInterval (type, rules, lines, day, track, palette, tag_colors, interval_work); + renderInterval (type, rules, lines, day, track, palette, tag_colors, first_hour, interval_work); work += interval_work; } } @@ -208,6 +208,8 @@ int renderChart ( } //////////////////////////////////////////////////////////////////////////////// +// Scan all tracked intervals, looking for the earliest and latest hour into +// which an interval extends. static void determineHourRange ( const std::string& type, const Rules& rules, @@ -217,6 +219,7 @@ static void determineHourRange ( { if (rules.get ("reports." + type + ".hours") == "auto") { + // Default to the full day. first_hour = 0; last_hour = 23; @@ -443,6 +446,7 @@ static void renderInterval ( const Interval& track, Palette& palette, std::map & tag_colors, + int first_hour, time_t& work) { auto spacing = rules.getInteger ("reports." + type + ".spacing"); @@ -457,8 +461,8 @@ static void renderInterval ( if (track.range.is_open ()) clipped.range.end = Datetime (); - auto start_mins = clipped.range.start.hour () * 60 + clipped.range.start.minute (); - auto end_mins = clipped.range.end.hour () * 60 + clipped.range.end.minute (); + auto start_mins = (clipped.range.start.hour () - first_hour) * 60 + clipped.range.start.minute (); + auto end_mins = (clipped.range.end.hour () - first_hour) * 60 + clipped.range.end.minute (); if (end_mins == 0) end_mins = (23 * 60) + 59;