reporting: add support for bar graphs, closes #809
parent
1b8a58fe5b
commit
0fbf99232d
|
@ -11702,7 +11702,7 @@ with the same base name as specified by @ref{tableName} with the ending
|
|||
@end defmethod
|
||||
|
||||
@anchor{addSeries}
|
||||
@defmethod Report addSeries data, graphHline, graphLegendName, graphLineColor, graphLineStyle, graphLineWidth, graphMarker, graphMarkerEdgeColor, graphMarkerFaceColor, graphMarkerSize, graphMiscTikzAddPlotOptions, graphShowInLegend, graphVline, tableDataRhs, tableRowColor, tableRowIndent, tableShowMarkers, tableAlignRight, tableNegColor, tablePosColor, tableSubSectionHeader, zeroTol
|
||||
@defmethod Report addSeries data, graphBar, graphBarColor, graphBarFillColor, graphBarWidth, graphHline, graphLegendName, graphLineColor, graphLineStyle, graphLineWidth, graphMarker, graphMarkerEdgeColor, graphMarkerFaceColor, graphMarkerSize, graphMiscTikzAddPlotOptions, graphShowInLegend, graphVline, tableDataRhs, tableRowColor, tableRowIndent, tableShowMarkers, tableAlignRight, tableNegColor, tablePosColor, tableSubSectionHeader, zeroTol
|
||||
Adds a @code{Series} to a @code{Graph} or a @code{Table}. NB: Options specific
|
||||
to graphs begin with `@code{graph}' while options specific to tables begin with
|
||||
`@code{table}'.
|
||||
|
@ -11712,6 +11712,23 @@ to graphs begin with `@code{graph}' while options specific to tables begin with
|
|||
@item data, @code{dseries}
|
||||
@xref{data}.
|
||||
|
||||
@anchor{graphBar}
|
||||
@item graphBar, @code{BOOLEAN}
|
||||
Whether or not to display this series as a bar graph as oppsed to the
|
||||
default of displaying it as a line graph. Default: @code{false}
|
||||
|
||||
@item graphBarColor, @code{STRING}
|
||||
The outline color of each bar in the bar graph. Only active if
|
||||
@ref{graphBar} is passed. Default: @code{`black'}
|
||||
|
||||
@item graphBarFillColor, @code{STRING}
|
||||
The fill color of each bar in the bar graph. Only active if
|
||||
@ref{graphBar} is passed. Default: @code{`black'}
|
||||
|
||||
@item graphBarWidth, @code{DOUBLE}
|
||||
The width of each bar in the bar graph. Only active if @ref{graphBar}
|
||||
is passed. Default: @code{2}
|
||||
|
||||
@item graphHline, @code{DOUBLE}
|
||||
Use this option to draw a horizontal line at the given value. Default:
|
||||
@code{empty}
|
||||
|
|
|
@ -53,6 +53,11 @@ o.graphMiscTikzAddPlotOptions = '';
|
|||
o.graphHline = {};
|
||||
o.graphVline = dates();
|
||||
|
||||
o.graphBar = false;
|
||||
o.graphBarColor = 'black';
|
||||
o.graphBarFillColor = 'black';
|
||||
o.graphBarWidth = 2;
|
||||
|
||||
o.tableShowMarkers = false;
|
||||
o.tableNegColor = 'red';
|
||||
o.tablePosColor = 'blue';
|
||||
|
|
|
@ -46,6 +46,13 @@ assert(ischar(o.graphLineStyle), '@report_series.writeSeriesForGraph: graphLineS
|
|||
assert(isfloat(o.graphLineWidth) && o.graphLineWidth > 0, ...
|
||||
'@report_series.writeSeriesForGraph: graphLineWidth must be a positive number');
|
||||
|
||||
% Bar
|
||||
assert(islogical(o.graphBar), '@report_series.writeSeriesForGraph: graphBar must be either true or false');
|
||||
assert(ischar(o.graphBarColor), '@report_series.writeSeriesForGraph: graphBarColor must be a string');
|
||||
assert(ischar(o.graphBarFillColor), '@report_series.writeSeriesForGraph: graphBarFillColor must be a string');
|
||||
assert(isfloat(o.graphBarWidth) && o.graphBarWidth > 0, ...
|
||||
'@report_series.writeSeriesForGraph: graphbarWidth must be a positive number');
|
||||
|
||||
% GraphMarker
|
||||
valid_graphMarker = {'x', '+', '-', '|', 'o', 'asterisk', 'star', '10-pointed star', 'oplus', ...
|
||||
'oplus*', 'otimes', 'otimes*', 'square', 'square*', 'triangle', 'triangle*', 'diamond', ...
|
||||
|
@ -113,18 +120,23 @@ fprintf(fid,'};\n');
|
|||
end
|
||||
|
||||
function writeLineOptions(o, fid)
|
||||
fprintf(fid, '[color=%s,%s,line width=%fpt,line join=round',...
|
||||
o.graphLineColor, o.graphLineStyle, o.graphLineWidth);
|
||||
if o.graphBar
|
||||
fprintf(fid, '[ybar,color=%s,fill=%s,line width=%fpt',...
|
||||
o.graphBarColor, o.graphBarFillColor, o.graphBarWidth);
|
||||
else
|
||||
fprintf(fid, '[color=%s,%s,line width=%fpt,line join=round',...
|
||||
o.graphLineColor, o.graphLineStyle, o.graphLineWidth);
|
||||
|
||||
if ~isempty(o.graphMarker)
|
||||
if isempty(o.graphMarkerEdgeColor)
|
||||
o.graphMarkerEdgeColor = o.graphLineColor;
|
||||
if ~isempty(o.graphMarker)
|
||||
if isempty(o.graphMarkerEdgeColor)
|
||||
o.graphMarkerEdgeColor = o.graphLineColor;
|
||||
end
|
||||
if isempty(o.graphMarkerFaceColor)
|
||||
o.graphMarkerFaceColor = o.graphLineColor;
|
||||
end
|
||||
fprintf(fid, ',mark=%s,mark size=%f,every mark/.append style={draw=%s,fill=%s}',...
|
||||
o.graphMarker,o.graphMarkerSize,o.graphMarkerEdgeColor,o.graphMarkerFaceColor);
|
||||
end
|
||||
if isempty(o.graphMarkerFaceColor)
|
||||
o.graphMarkerFaceColor = o.graphLineColor;
|
||||
end
|
||||
fprintf(fid, ',mark=%s,mark size=%f,every mark/.append style={draw=%s,fill=%s}',...
|
||||
o.graphMarker,o.graphMarkerSize,o.graphMarkerEdgeColor,o.graphMarkerFaceColor);
|
||||
end
|
||||
if ~isempty(o.graphMiscTikzAddPlotOptions)
|
||||
fprintf(fid, ',%s', o.graphMiscTikzAddPlotOptions);
|
||||
|
|
|
@ -175,16 +175,18 @@ rep = rep.addGraph('title', 'World Real Food Price Index', ...
|
|||
'shade', srange, ...
|
||||
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
|
||||
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
|
||||
'xTickLabelRotation', 0);
|
||||
'xTickLabelRotation', 0, ...
|
||||
'showLegend', true);
|
||||
rep = rep.addSeries('data', db_q{'LRPFOOD_BAR_WORLD'}, ...
|
||||
'graphBar', true, ...
|
||||
'graphBarColor', 'green', ...
|
||||
'graphBarFillColor', 'yellow', ...
|
||||
'graphBarWidth', 1);
|
||||
db_q = db_q.tex_rename('LRPFOOD_WORLD', 'Food Price');
|
||||
rep = rep.addSeries('data', db_q{'LRPFOOD_WORLD'}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineWidth', 1.5);
|
||||
db_q = db_q.tex_rename('LRPFOOD_BAR_WORLD', 'Equilibrium Food Price');
|
||||
rep = rep.addSeries('data', db_q{'LRPFOOD_BAR_WORLD'}, ...
|
||||
'graphLineColor', 'green', ...
|
||||
'graphLineStyle', 'solid', ...
|
||||
'graphLineWidth', 1.5);
|
||||
rep = rep.addSeries('graphVline', dates('2009q2'), ...
|
||||
'graphLineColor', 'red', ...
|
||||
'graphLineWidth', 1.5);
|
||||
|
|
Loading…
Reference in New Issue