From: Sebastien GODARD Date: Wed, 7 Feb 2018 10:36:16 +0000 (+0100) Subject: SVG: Make sure that "No data" is displayed when no graphs are created X-Git-Tag: v11.7.2~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=14df27d5bf5d25751f10fc8c832a02ec40f0d534;p=sysstat SVG: Make sure that "No data" is displayed when no graphs are created If no graphs are detected (e.g. the file contains only a LINUX RESTART message) then SVG file is empty and an error is displayed by the browser. Make sure that "No data" is displayed in the browser window instead. Signed-off-by: Sebastien GODARD --- diff --git a/sadf.c b/sadf.c index 396d209..82ac15f 100644 --- a/sadf.c +++ b/sadf.c @@ -447,6 +447,7 @@ void seek_file_position(int ifd, int action) * RETURNS: * Number of rows containing views, taking into account only activities * to be displayed, and selected period of time (options -s/-e). + * Result may be 0. *************************************************************************** */ int get_svg_graph_nr(int ifd, char *file, struct file_magic *file_magic, @@ -1221,21 +1222,21 @@ void logic3_display_loop(int ifd, struct file_activity *file_actlst, /* Use a decimal point to make SVG code locale independent */ setlocale(LC_NUMERIC, "C"); - /* Calculate the number of rows and the max number of views per row to display */ + /* + * Calculate the number of rows and the max number of views per row to display. + * Result may be 0. In this case, "No data" will be displayed instead of the graphs. + */ graph_nr = get_svg_graph_nr(ifd, file, file_magic, file_actlst, rectime, loctime, &views_per_row); if (SET_CANVAS_HEIGHT(flags)) { /* - * Option "-O height=..." used: This is not a number + * Option "-O height=..." used: @graph_nr is NO LONGER a number * of graphs but the SVG canvas height set on the command line. */ graph_nr = canvas_height; } - if (!graph_nr) - /* No graph to display */ - return; parm.graph_nr = graph_nr; parm.views_per_row = PACK_VIEWS(flags) ? views_per_row : 1;