From d6b30466c13eb45b73f70b13f6178f9b751fc44f Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 1 Nov 2008 15:44:25 -0400 Subject: [PATCH] - "task ghistory" now displays a differently aligned graph, allowing easier comparison by month of tasks added versus completed and deleted. --- ChangeLog | 2 ++ html/task.html | 2 ++ src/report.cpp | 34 +++++++++++++++++++++++----------- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 52f729398..396fd1785 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,8 @@ + Removed "usage" command, and support for "command.logging" configuration variable. + "task stop" can now remove the start time from a started task. + + "task ghistory" now displays a differently aligned graph, allowing + easier comparison by month of tasks added versus completed and deleted. ------ old releases ------------------------------ diff --git a/html/task.html b/html/task.html index 57083e0a7..ccbbd3274 100644 --- a/html/task.html +++ b/html/task.html @@ -96,6 +96,8 @@
  • Removed "usage" command, and support for "command.logging" configuration variable.
  • "task stop" can remove the start time from a started task. +
  • "task ghistory" now displays a differently aligned graph, allowing + easier comparison by month of tasks added versus completed and deleted.

    diff --git a/src/report.cpp b/src/report.cpp index 2e60e498e..eb3a03de0 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -1380,7 +1380,7 @@ void handleReportGHistory (TDB& tdb, T& task, Config& conf) endwin (); } #endif - int widthOfBar = width - 15; // strlen ("2008 September ") + int widthOfBar = width - 15; // 15 == strlen ("2008 September ") std::map groups; std::map addedGroup; @@ -1480,18 +1480,24 @@ void handleReportGHistory (TDB& tdb, T& task, Config& conf) else table.setTableDashedUnderline (); - // Determine the longest line. - int maxLine = 0; + // Determine the longest line, and the longest "added" line. + int maxAddedLine = 0; + int maxRemovedLine = 0; foreach (i, groups) { - int line = addedGroup[i->first] + completedGroup[i->first] + deletedGroup[i->first]; + if (completedGroup[i->first] + deletedGroup[i->first] > maxRemovedLine) + maxRemovedLine = completedGroup[i->first] + deletedGroup[i->first]; - if (line > maxLine) - maxLine = line; + if (addedGroup[i->first] > maxAddedLine) + maxAddedLine = addedGroup[i->first]; } + int maxLine = maxAddedLine + maxRemovedLine; + if (maxLine > 0) { + unsigned int leftOffset = (widthOfBar * maxAddedLine) / maxLine; + int totalAdded = 0; int totalCompleted = 0; int totalDeleted = 0; @@ -1521,7 +1527,7 @@ void handleReportGHistory (TDB& tdb, T& task, Config& conf) unsigned int completedBar = (widthOfBar * completedGroup[i->first]) / maxLine; unsigned int deletedBar = (widthOfBar * deletedGroup[i->first]) / maxLine; - std::string bar; + std::string bar = ""; if (conf.get ("color", true)) { char number[24]; @@ -1552,9 +1558,12 @@ void handleReportGHistory (TDB& tdb, T& task, Config& conf) dBar = " " + dBar; } - bar = Text::colorize (Text::black, Text::on_red, aBar); - bar += Text::colorize (Text::black, Text::on_green, cBar); - bar += Text::colorize (Text::black, Text::on_yellow, dBar); + while (bar.length () < leftOffset - aBar.length ()) + bar += " "; + + bar += Text::colorize (Text::black, Text::on_red, aBar); + bar += Text::colorize (Text::black, Text::on_green, cBar); + bar += Text::colorize (Text::black, Text::on_yellow, dBar); } else { @@ -1562,7 +1571,10 @@ void handleReportGHistory (TDB& tdb, T& task, Config& conf) std::string cBar = ""; while (cBar.length () < completedBar) cBar += "X"; std::string dBar = ""; while (dBar.length () < deletedBar) dBar += "-"; - bar = aBar + cBar + dBar; + while (bar.length () < leftOffset - aBar.length ()) + bar += " "; + + bar += aBar + cBar + dBar; } table.addCell (row, 2, bar);