diff --git a/matlab/reporting/@graph/createGraph.m b/matlab/reporting/@graph/createGraph.m index 41ff3ea9ed990daba772f5dd52d01b6f31d3e6d3..22ff418f3ef1fdb781cb94286feea56a0c7bd9b8 100644 --- a/matlab/reporting/@graph/createGraph.m +++ b/matlab/reporting/@graph/createGraph.m @@ -47,20 +47,15 @@ if o.grid set(gca, 'GridLineStyle', '--'); end +if isempty(o.xrange) + dd = o.seriesElements.getMaxRange(); +else + dd = o.xrange; +end + ne = o.seriesElements.numElements(); -dd = dynDates(); for i=1:ne - ddt = o.seriesElements(i).getLine(o.xrange); - if isempty(dd) - dd = ddt; - else - if ddt(1) < dd(1) - dd = union(ddt(1):dd(1), dd); - end - if ddt(ddt.ndat) > dd(dd.ndat) - dd = union(dd, dd(dd.ndat):ddt(ddt.ndat)); - end - end + o.seriesElements(i).getLine(dd); end x = 1:1:dd.ndat; diff --git a/matlab/reporting/@series/getLine.m b/matlab/reporting/@series/getLine.m index cd06faa26cc86089e7dfede0e79b9e3157b33e36..751f7487b594a7f0f42ab35945c4f913517c12e0 100644 --- a/matlab/reporting/@series/getLine.m +++ b/matlab/reporting/@series/getLine.m @@ -1,5 +1,5 @@ -function dd = getLine(o, xrange) -%function dd = getLine(o, xrange) +function o = getLine(o, xrange) +%function o = getLine(o, xrange) % Create the series % % INPUTS @@ -7,7 +7,7 @@ function dd = getLine(o, xrange) % xrange [dynDates] range of x values for line % % OUTPUTS -% dd [dynDates] dynDates representing the range of the line +% o [series] series object % % SPECIAL REQUIREMENTS % none @@ -61,11 +61,11 @@ assert(~(strcmp(o.line_style, 'none') && isempty(o.marker)), ['@series.series: ' assert(isempty(xrange) || isa(xrange, 'dynDates')); %% -ds = o.data; -if ~isempty(xrange) +if isempty(xrange) || xrange == o.data.time + ds = o.data; +else ds = o.data(xrange); end -dd = ds.time; opt = {'XData', 1:length(ds.data)}; opt = {opt{:}, 'YData', ds.data}; diff --git a/matlab/reporting/@series/getRange.m b/matlab/reporting/@series/getRange.m new file mode 100644 index 0000000000000000000000000000000000000000..0b941c4e7d71cc00144653965cdfc3f28c24bab4 --- /dev/null +++ b/matlab/reporting/@series/getRange.m @@ -0,0 +1,23 @@ +function dd = getRange(o) +%function dd = getRange(o) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +assert(~isempty(o.data) && size(o.data, 2) == 1); +dd = o.data.time; +end \ No newline at end of file diff --git a/matlab/reporting/@seriesElements/getMaxRange.m b/matlab/reporting/@seriesElements/getMaxRange.m new file mode 100644 index 0000000000000000000000000000000000000000..d745e389a008d9d45a337044318264b61f3cd166 --- /dev/null +++ b/matlab/reporting/@seriesElements/getMaxRange.m @@ -0,0 +1,35 @@ +function dd = getMaxRange(o) +% function dd = getMaxRange(o) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +ne = numElements(o); +ddmin = dynDate(); +ddmax = dynDate(); +for i=1:ne + a = getSeriesElements(o, 1); + ddt = a.getRange(); + if isempty(ddmin) + ddmin = ddt(1); + ddmax = ddt(size(ddt)); + else + ddmin = min(ddt(1), ddmin); + ddmax = max(ddt(size(ddt)), ddmax); + end +end +dd = ddmin:ddmax; \ No newline at end of file