1classdef report_series < handle 2 % report_series Class to write a page to the report 3 % 4 % Copyright (C) 2013-2019 Dynare Team 5 % 6 % This file is part of Dynare. 7 % 8 % Dynare is free software: you can redistribute it and/or modify 9 % it under the terms of the GNU General Public License as published by 10 % the Free Software Foundation, either version 3 of the License, or 11 % (at your option) any later version. 12 % 13 % Dynare is distributed in the hope that it will be useful, 14 % but WITHOUT ANY WARRANTY; without even the implied warranty of 15 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 % GNU General Public License for more details. 17 % 18 % You should have received a copy of the GNU General Public License 19 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 20 properties (SetAccess = private) 21 data = '' % The dseries that provides the data for the graph. Default: none. 22 graphFanShadeColor = '' % The shading color to use between a series and the previously-added series in a graph. Useful for making fan charts. Default: empty. 23 graphFanShadeOpacity = 50 % The opacity of the color passed in graphFanShadeColor. Default: 50. 24 graphLegendName = '' % The name to display in the legend for this series, passed as valid LATEX (e.g., GDP_{US}, $\alpha$, \color{red}GDP\color{black}). Will be displayed only if the data and showLegend options have been passed. Default: the tex name of the series. 25 graphLineColor = 'black' % Color to use for the series in a graph. See the explanation in shadeColor for how to use colors with reports. Default: `black' 26 graphLineStyle = 'solid' % Line style for this series in a graph. Default: `solid'. 27 graphLineWidth = 0.5 % Line width for this series in a graph. Default: 0.5. 28 graphShowInLegend = true % Whether or not to show this series in the legend, given that the showLegend option was passed to addGraph. Default: true. 29 graphMarker = '' % The Marker to use on this series in a graph. Default: none. 30 graphMarkerEdgeColor = '' % The edge color of the graph marker. See the explanation in shadeColor for how to use colors with reports. Default: graphLineColor. 31 graphMarkerFaceColor = '' % The face color of the graph marker. See the explanation in shadeColor for how to use colors with reports. Default: graphLineColor. 32 graphMarkerSize = 1 % The size of the graph marker. Default: 1. 33 graphMiscTikzAddPlotOptions = '' % If you are comfortable with PGFPLOTS/TikZ, you can use this option to pass arguments di- rectly to the PGFPLOTS/TikZ addPlots command. (e.g., Instead of passing the marker options above, you can pass a string such as the following to this option: `mark=halfcircle*,mark options={rotate=90,scale=3}'). Specifically to be used for desired PGFPLOTS/TikZ options that have not been incorporated into Dynare Reproting. Default: empty. 34 graphHline = {} % Use this option to draw a horizontal line at the given value. Default: empty. 35 graphVline = dates() % Use this option to draw a vertical line at a given date. Default: empty. 36 graphBar = false % Whether or not to display this series as a bar graph as oppsed to the default of displaying it as a line graph. Default: false. 37 graphBarColor = 'black' % The outline color of each bar in the bar graph. Only active if graphBar is passed. Default: `black'. 38 graphBarFillColor = 'black' % The fill color of each bar in the bar graph. Only active if graphBar is passed. Default: `black'. 39 graphBarWidth = 2 % The width of each bar in the bar graph. Only active if graphBar is passed. Default: 2. 40 tableShowMarkers = false % In a Table, if true, surround each cell with brackets and color it according to tableNegColor and tablePosColor. No effect for graphs. Default: false. 41 tableNegColor = 'red' % The color to use when marking Table data that is less than zero. Default: `red' 42 tablePosColor = 'blue' % The color to use when marking Table data that is greater than zero. Default: `blue' 43 tableMarkerLimit = 1e-4 % For values less than ?1 * tableMarkerLimit, mark the cell with the color denoted by tableNeg- Color. For those greater than tableMarkerLimit, mark the cell with the color denoted by table- PosColor. Default: 1e-4. 44 tableSubSectionHeader = '' % A header for a subsection of the table. No data will be associated with it. It is equivalent to adding an empty series with a name. Default: '' 45 tableAlignRight = false % Whether or not to align the series name to the right of the cell. Default: false. 46 tableRowColor = 'white' % The color that you want the row to be. Predefined values include LightCyan and Gray. Default: white. 47 tableRowIndent = 0 % The number of times to indent the name of the series in the table. Used to create subgroups of series. Default: 0. 48 tableDataRhs = '' % A series to be added to the right of the current series. Usefull for displaying aggregate data for a series. e.g if the series is quarterly tableDataRhs could point to the yearly averages of the quarterly series. This would cause quarterly data to be displayed followed by annual data. Default: empty. 49 tableNaNSymb = 'NaN' % Replace NaN values with the text in this option. Default: NaN. 50 tablePrecision = '' % The number of decimal places to report in the table data. Default: the value set by precision. 51 zeroTol = 1e-6 % The zero tolerance. Anything smaller than zeroTol and larger than -zeroTol will be set to zero before being graphed or written to the table. Default: 1e-6. 52 end 53 methods 54 function o = report_series(varargin) 55 %function o = report_series(varargin) 56 % Report_Series Class Constructor 57 % 58 % INPUTS 59 % varargin 0 args : empty report_series object 60 % 1 arg : must be report_series object (return a copy of arg) 61 % > 1 args: option/value pairs (see structure below for options) 62 % 63 % OUTPUTS 64 % o [report_series] report_series object 65 % 66 % SPECIAL REQUIREMENTS 67 % none 68 if nargin == 0 69 return 70 elseif nargin == 1 71 assert(isa(varargin{1}, 'report_series'), ... 72 '@report_series.report_series: with one arg you must pass a report_series object'); 73 o = varargin{1}; 74 return 75 end 76 77 if round(nargin/2) ~= nargin/2 78 error('@report_series.report_series: options must be supplied in name/value pairs.'); 79 end 80 81 % Octave 5.1.0 has not implemented `properties` and issues a warning when using `fieldnames` 82 warning('off') 83 optNames = fieldnames(o); 84 warning('on') 85 86 % overwrite default values 87 for pair = reshape(varargin, 2, []) 88 ind = find(strcmpi(optNames, pair{1})); 89 assert(isempty(ind) || length(ind) == 1); 90 if ~isempty(ind) 91 o.(optNames{ind}) = pair{2}; 92 else 93 error('@report_series.report_series: %s is not a recognized option.', pair{1}); 94 end 95 end 96 if ~isempty(o.graphLegendName) 97 o.data = o.data.tex_rename(o.graphLegendName); 98 end 99 end 100 end 101 methods (Hidden = true) 102 s = getNameForLegend(o) 103 writeSeriesForGraph(o, fid, xrange, series_num) 104 end 105 methods (Hidden = true) 106 writeSeriesForTable(o, fid, dates, precision, ncols, rowcolor) 107 end 108 methods (Hidden = true) 109 tf = isZero(o) 110 end 111 methods (Access = private) 112 dd = getRange(o) 113 s = getTexName(o) 114 o = printSeries(o, fid, dser, dates, precision) 115 d = setDataToZeroFromZeroTol(o, ds) 116 ymax = ymax(o, dd) 117 ymin = ymin(o, dd) 118 end 119end 120