reporting: add option 'ALL' to xTickLabels

time-shift
Houtan Bastani 2014-02-20 16:35:05 +01:00
parent 5899a19e79
commit daf6189e9c
4 changed files with 15 additions and 9 deletions

View File

@ -10882,7 +10882,7 @@ last dates of the @code{dseries} and, if passed, the index associated
with the first date of the @ref{shade} option.
@anchor{xTickLabels}
@item xTickLabels, @code{CELL_ARRAY_STRINGS}
@item xTickLabels, @code{CELL_ARRAY_STRINGS} | `ALL'
The labels to be mapped to the ticks provided by
@ref{xTicks}. Default: the first and last dates of the @code{dseries}
and, if passed, the date first date of the @ref{shade} option.

View File

@ -161,10 +161,13 @@ assert(isempty(o.graphSize) || ((isfloat(o.graphSize) && length(o.graphSize) ==
'entries, [width height]']);
assert(isempty(o.xTicks) || isfloat(o.xTicks),...
'@graph.graph: xTicks must be a numerical array');
assert(iscellstr(o.xTickLabels), ...
'@graph.graph: xTickLabels must be a cell array of strings');
assert(iscellstr(o.xTickLabels) || (ischar(o.xTickLabels) && strcmpi(o.xTickLabels, 'ALL')), ...
['@graph.graph: xTickLabels must be a cell array of strings or ' ...
'equivalent to the string ''ALL''']);
if ~isempty(o.xTickLabels)
assert(~isempty(o.xTicks), '@graph.graph: if you set xTickLabels, you must set xTicks');
assert((ischar(o.xTickLabels) && strcmpi(o.xTickLabels, 'ALL')) || ...
~isempty(o.xTicks), ['@graph.graph: if you set xTickLabels and ' ...
'it''s not equal to ''ALL'', you must set xTicks']);
end
if ~isempty(o.xTicks)
assert(~isempty(o.xTickLabels), '@graph.graph: if you set xTicks, you must set xTickLabels');

View File

@ -56,11 +56,11 @@ if isempty(o.xrange)
else
dd = o.xrange;
end
stringsdd = strings(dd);
fprintf(fid, '\\begin{axis}[%%\n');
% set tick labels
if isempty(o.xTickLabels)
stringsdd = strings(dd);
if ~isempty(o.shade)
x1 = find(strcmpi(date2string(o.shade(1)), stringsdd));
x = [1 x1 dd.ndat];
@ -70,10 +70,13 @@ if isempty(o.xTickLabels)
xTickLabels = [stringsdd(1) stringsdd(end)];
end
fprintf(fid, 'xminorticks=true,\nyminorticks=true,\n');
else
elseif iscell(o.xTickLabels)
fprintf(fid,'minor xtick,\n');
x = o.xTicks;
xTickLabels = o.xTickLabels;
else
x = [1:dd.ndat];
xTickLabels = strings(dd);
end
fprintf(fid, 'xticklabels={');
xlen = length(x);
@ -167,6 +170,7 @@ for i=1:ne
end
if ~isempty(o.shade)
stringsdd = strings(dd);
x1 = find(strcmpi(date2string(o.shade(1)), stringsdd));
x2 = find(strcmpi(date2string(o.shade(end)), stringsdd));
assert(~isempty(x1) && ~isempty(x2), ['@graph.writeGraphFile: either ' ...

View File

@ -222,9 +222,8 @@ rep = rep.addSeries('data', dc_q{'LRPOIL_BAR_WORLD'}, ...
rep = rep.addGraph('title', 'World Real Food Price', ...
'xrange', prange, ...
'shade', srange, ...
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
'xTickLabelRotation', 0,...
'xTickLabels','ALL',...
'xTickLabelRotation', 45,...
'xAxisTight',false,...
'yAxisTight',true);
rep = rep.addSeries('data', db_q{'LRPFOOD_WORLD'}, ...