reporting: factorize max range code for eventual use with @table
parent
0d33a12d5b
commit
1f988bcdf4
|
@ -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;
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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
|
|
@ -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;
|
Loading…
Reference in New Issue