reporting: new table option vlineAfterEndOfPeriod

time-shift
Houtan Bastani 2013-09-25 15:25:34 +02:00
parent 4522c011d6
commit 6a9e9dfdea
3 changed files with 22 additions and 7 deletions

View File

@ -8421,7 +8421,7 @@ Display a solid black line at @math{y = 0}. Default: @code{false}
@end table
@end defmethod
@defmethod Report addTable data, showHlines, precision, range, seriesToUse, title, titleSize, vlineAfter, showVlines
@defmethod Report addTable data, showHlines, precision, range, seriesToUse, title, titleSize, vlineAfter, vlineAfterEndOfPeriod, showVlines
Adds a @code{Table} to a @code{Section}.
@optionshead
@table @code
@ -8450,6 +8450,10 @@ Title for the table. Default: @code{none}
@item vlineAfter, @code{dynDate}
Show a vertical line after the specified date. Default: @code{empty}
@item vlineAfterEndOfPeriod, @code{BOOLEAN}
Show a vertical line after the end of every period (@i{i.e.} after
every year, after the fourth quarter, etc.). Default: @code{false}
@item showVlines, @code{BOOLEAN}
Whether or not to show vertical lines separating the columns. Default: @code{false}
@end table

View File

@ -39,6 +39,7 @@ o.titleSize = 'large';
o.showHlines = false;
o.showVlines = false;
o.vlineAfter = '';
o.vlineAfterEndOfPeriod = false;
o.data = '';
o.seriesToUse = '';
@ -87,6 +88,8 @@ assert(isempty(o.vlineAfter) || isa(o.vlineAfter, 'dynDate'), ...
if o.showVlines
o.vlineAfter = '';
end
assert(islogical(o.vlineAfterEndOfPeriod), ...
'@table.table: vlineAfterEndOfPeriod must be true or false');
valid_title_sizes = {'Huge', 'huge', 'LARGE', 'Large', 'large', 'normalsize', ...
'small', 'footnotesize', 'scriptsize', 'tiny'};
assert(any(strcmp(o.titleSize, valid_title_sizes)), ...

View File

@ -55,12 +55,20 @@ fprintf(fid, '\\begin{tabular}{@{}l');
for i=1:ndates
if o.showVlines
fprintf(fid, '|');
end
fprintf(fid, 'r');
if ~isempty(o.vlineAfter)
if dates(i) == o.vlineAfter
fprintf(fid, '|');
fprintf(fid, 'r|');
else
fprintf(fid, 'r');
if o.vlineAfterEndOfPeriod
if dates(i).time(2) == dates(i).freq
fprintf(fid, '|');
end
end
if ~isempty(o.vlineAfter)
if dates(i) == o.vlineAfter
if ~(o.vlineAfterEndOfPeriod && dates(i).time(2) == dates(i).freq)
fprintf(fid, '|');
end
end
end
end
end