- "task ghistory" now displays a differently aligned graph, allowing

easier comparison by month of tasks added versus completed and deleted.
This commit is contained in:
Paul Beckingham 2008-11-01 15:44:25 -04:00
parent c44baf913d
commit d6b30466c1
3 changed files with 27 additions and 11 deletions

View file

@ -6,6 +6,8 @@
+ Removed "usage" command, and support for "command.logging" configuration + Removed "usage" command, and support for "command.logging" configuration
variable. variable.
+ "task stop" can now remove the start time from a started task. + "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 ------------------------------ ------ old releases ------------------------------

View file

@ -96,6 +96,8 @@
<li>Removed "usage" command, and support for "command.logging" configuration <li>Removed "usage" command, and support for "command.logging" configuration
variable. variable.
<li>"task stop" can remove the start time from a started task. <li>"task stop" can remove the start time from a started task.
<li>"task ghistory" now displays a differently aligned graph, allowing
easier comparison by month of tasks added versus completed and deleted.
</ul> </ul>
<p> <p>

View file

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