From ae1c12f482908332e66ecd8d8945fb36b28872d1 Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan@dynare.org>
Date: Mon, 19 May 2014 12:29:54 +0200
Subject: [PATCH] =?UTF-8?q?reporting:=20add=20option=20=E2=80=98graphLegen?=
 =?UTF-8?q?dName=E2=80=99=20to=20addSeries?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 doc/dynare.texi                               | 7 ++++++-
 matlab/reports/@report_series/report_series.m | 6 ++++++
 tests/reporting/runDynareReport.m             | 6 ++++--
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/doc/dynare.texi b/doc/dynare.texi
index ec7ab1a248..7655304038 100644
--- a/doc/dynare.texi
+++ b/doc/dynare.texi
@@ -11189,6 +11189,7 @@ The height of the graph, in inches. Default: @code{4.5}
 Whether or not to display the major grid on the graph. Default:
 @code{true}
 
+@anchor{showLegend}
 @item showLegend, @code{BOOLEAN}
 Whether or not to display the legend. Default: @code{false}
 
@@ -11331,7 +11332,7 @@ Whether or not to show vertical lines separating the columns. Default: @code{fal
 @end defmethod
 
 @anchor{addSeries}
-@defmethod Report addSeries data, graphLineColor, graphLineStyle, graphLineWidth, graphMarker, graphMarkerEdgeColor, graphMarkerFaceColor, graphMarkerSize, tableDataRhs, tableRowColor, tableRowIndent, tableShowMarkers, tableAlignRight, tableNegColor, tablePosColor, tableSubSectionHeader, zeroTol
+@defmethod Report addSeries data, graphLegendName, graphLineColor, graphLineStyle, graphLineWidth, graphMarker, graphMarkerEdgeColor, graphMarkerFaceColor, graphMarkerSize, tableDataRhs, tableRowColor, tableRowIndent, tableShowMarkers, tableAlignRight, tableNegColor, tablePosColor, tableSubSectionHeader, zeroTol
 Adds a @code{Series} to a @code{Graph} or a @code{Table}.
 @optionshead
 @table @code
@@ -11339,6 +11340,10 @@ Adds a @code{Series} to a @code{Graph} or a @code{Table}.
 @item data, @code{dseries}
 @xref{data}.
 
+@item graphLegendName, @code{STRING}
+The name to display in the legend for this series. Will be displayed only if
+the @ref{data} option has been set. Default: the @code{tex} name of the series
+
 @item graphLineColor, @code{`red'} | @code{`green'} | @code{`blue'} | @code{`cyan'} | @code{`magenta'} | @code{`yellow'} | @code{`black'} | @code{`gray'} | @code{`darkgray'} | @code{`lightgray'} | @code{`brown'} | @code{`lime'} | @code{`olive'} | @code{`orange'} | @code{`pink'} | @code{`purple'} | @code{`teal'} | @code{`violet'} | @code{`white'}
 Color to use for the series in a graph. Default: @code{`black'}
 
diff --git a/matlab/reports/@report_series/report_series.m b/matlab/reports/@report_series/report_series.m
index 41d6286b0c..4adf75409e 100644
--- a/matlab/reports/@report_series/report_series.m
+++ b/matlab/reports/@report_series/report_series.m
@@ -35,6 +35,8 @@ o = struct;
 
 o.data = '';
 
+o.graphLegendName = '';
+
 o.graphLineColor = 'black';
 o.graphLineStyle = 'solid';
 o.graphLineWidth = 0.5;
@@ -84,6 +86,10 @@ elseif nargin > 1
     end
 end
 
+if ~isempty(o.graphLegendName)
+    o.data = o.data.tex_rename(o.graphLegendName);
+end
+
 % Create report_series object
 o = class(o, 'report_series');
 end
\ No newline at end of file
diff --git a/tests/reporting/runDynareReport.m b/tests/reporting/runDynareReport.m
index 5a08c73d63..afdff04472 100644
--- a/tests/reporting/runDynareReport.m
+++ b/tests/reporting/runDynareReport.m
@@ -239,11 +239,13 @@ rep = rep.addGraph('title', 'Equilibrium World Real Food Price', ...
                    'xTickLabelRotation', 0);
 rep = rep.addSeries('data', db_q{'LRPFOOD_BAR_WORLD'}, ...
                     'graphLineColor', 'blue', ...
-                    'graphLineWidth', 1.5);
+                    'graphLineWidth', 1.5, ...
+                    'graphLegendName', 'baseline');
 rep = rep.addSeries('data', dc_q{'LRPFOOD_BAR_WORLD'}, ...
                     'graphLineColor', 'blue', ...
                     'graphLineStyle', 'dashed', ...
-                    'graphLineWidth', 1.5);
+                    'graphLineWidth', 1.5, ...
+                    'graphLegendName', 'control');
 
 %% Write & Compile Report
 rep.write();
-- 
GitLab