reporting: tables: add row highlighting option
parent
9c4294d0aa
commit
217ab0088d
|
@ -11503,7 +11503,7 @@ reports. Default: @code{`black'}
|
|||
@end table
|
||||
@end defmethod
|
||||
|
||||
@defmethod Report addTable data, showHlines, precision, range, seriesToUse, tableDirName, tableName, title, titleFormat, vlineAfter, vlineAfterEndOfPeriod, showVlines, writeCSV
|
||||
@defmethod Report addTable data, highlightRows, showHlines, precision, range, seriesToUse, tableDirName, tableName, title, titleFormat, vlineAfter, vlineAfterEndOfPeriod, showVlines, writeCSV
|
||||
Adds a @code{Table} to a @code{Section}.
|
||||
@optionshead
|
||||
@table @code
|
||||
|
@ -11511,6 +11511,12 @@ Adds a @code{Table} to a @code{Section}.
|
|||
@item data, @code{dseries}
|
||||
@xref{data}.
|
||||
|
||||
@item highlightRows, @code{CELL_ARRAY_STRINGS}
|
||||
A cell array containing the colors to use for row highlighting. See
|
||||
@ref{shadeColor} for how to use colors with reports. Highlighting for a
|
||||
specific row can be overridden by using the @ref{tableRowColor} option to
|
||||
@ref{addSeries}. Default: @code{empty}
|
||||
|
||||
@item showHlines, @code{BOOLEAN}
|
||||
Whether or not to show horizontal lines separating the rows. Default: @code{false}
|
||||
|
||||
|
@ -11627,6 +11633,7 @@ quarterly @code{tableDataRhs} could point to the yearly averages of
|
|||
the quarterly series. This would cause quarterly data to be displayed
|
||||
followed by annual data. Default: @code{empty}
|
||||
|
||||
@anchor{tableRowColor}
|
||||
@item tableRowColor, @code{STRING}
|
||||
The color that you want the row to be. Predefined values include
|
||||
@code{LightCyan} and @code{Gray}. Default: @code{white}.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
function o = writeSeriesForTable(o, fid, dates, precision, ncols)
|
||||
%function o = writeSeriesForTable(o, fid, dates, precision, ncols)
|
||||
function o = writeSeriesForTable(o, fid, dates, precision, ncols, rowcolor)
|
||||
%function o = writeSeriesForTable(o, fid, dates, precision, ncols, rowcolor)
|
||||
% Write Table Row
|
||||
%
|
||||
% INPUTS
|
||||
|
@ -8,6 +8,7 @@ function o = writeSeriesForTable(o, fid, dates, precision, ncols)
|
|||
% dates [dates] dates for report_series slice
|
||||
% precision [float] precision with which to print the data
|
||||
% ncols [int] total number of columns in table
|
||||
% rowcolor [string] string to color this row
|
||||
%
|
||||
%
|
||||
% OUTPUTS
|
||||
|
@ -65,7 +66,11 @@ assert(isfloat(o.tableMarkerLimit), '@report_series.writeSeriesForTable: tableMa
|
|||
|
||||
%% Write Output
|
||||
fprintf(fid, '%% Table Row (report_series)\n');
|
||||
if ~isempty(o.tableRowColor)
|
||||
if ~isempty(o.tableRowColor) && ~strcmpi(o.tableRowColor, 'white')
|
||||
fprintf(fid, '\\rowcolor{%s}', o.tableRowColor);
|
||||
elseif ~isempty(rowcolor)
|
||||
fprintf(fid, '\\rowcolor{%s}', rowcolor);
|
||||
else
|
||||
fprintf(fid, '\\rowcolor{%s}', o.tableRowColor);
|
||||
end
|
||||
if ~isempty(o.tableSubSectionHeader)
|
||||
|
|
|
@ -51,6 +51,8 @@ o.range = {};
|
|||
o.precision = 1;
|
||||
o.writeCSV = false;
|
||||
|
||||
o.highlightRows = {''};
|
||||
|
||||
if nargin == 1
|
||||
assert(isa(varargin{1}, 'report_table'),['With one arg to Report_Table constructor, ' ...
|
||||
'you must pass a report_table object']);
|
||||
|
@ -117,6 +119,7 @@ assert(iscellstr(o.titleFormat), ...
|
|||
assert(ischar(o.tableName), '@report_table.report_table: tableName must be a string');
|
||||
assert(ischar(o.tableDirName), '@report_table.report_table: tableDirName must be a string');
|
||||
assert(islogical(o.writeCSV), '@report_table.report_table: writeCSV must be either true or false');
|
||||
assert(iscellstr(o.highlightRows), '@report_table.report_table: highlightRowsmust be a cell string');
|
||||
|
||||
% using o.seriesToUse, create series objects and put them in o.series
|
||||
if ~isempty(o.data)
|
||||
|
|
|
@ -175,7 +175,7 @@ if o.writeCSV
|
|||
csvseries = dseries();
|
||||
end
|
||||
for i=1:ne
|
||||
o.series{i}.writeSeriesForTable(fid, o.range, o.precision, ncols);
|
||||
o.series{i}.writeSeriesForTable(fid, o.range, o.precision, ncols, o.highlightRows{mod(i,length(o.highlightRows))+1});
|
||||
if o.writeCSV
|
||||
if isempty(o.series{i}.tableSubSectionHeader)
|
||||
csvseries = [csvseries ...
|
||||
|
|
|
@ -44,7 +44,8 @@ notForOtherThree = {'BLT_', 'UNR_', 'UNR_BAR_', 'UNR_GAP_'};
|
|||
rep = rep.addTable('title', countryName, ...
|
||||
'range', {trange, dates('2012a'):dates('2014a')}, ...
|
||||
'vlineAfter', {vline_after dates('2014q4')}, ...
|
||||
'writeCSV', true);
|
||||
'writeCSV', true, ...
|
||||
'highlightRows', {'gray!22', 'cyan!33', 'blue!44', 'red!55'});
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -44,7 +44,8 @@ rep = rep.addVspace();
|
|||
% Table 1
|
||||
rep = rep.addTable('title', {'Real GDP Growth','subtitle 1', 'subtitle 2'}, ...
|
||||
'range', larange, ...
|
||||
'vlineAfter', dates('2011y'));
|
||||
'vlineAfter', dates('2011y'), ...
|
||||
'highlightRows', {'gray!25','white','green!22'});
|
||||
rep = AnnualTable(rep, db_a, dc_a, 'PCH_GROWTH4_', larange);
|
||||
rep = rep.addVspace('number', 2);
|
||||
|
||||
|
|
Loading…
Reference in New Issue