From 73f23e7eea481eafe3eb81d16f19fd24b9a3df2e Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Fri, 6 Jul 2018 14:15:51 +0200 Subject: [PATCH] sadf: SVG: Don't insert id tag if activity not displayed When using both "showtoc" and "skipempty" options, e.g.: $ sadf -g -O showtoc,skipempty -- -A > output.svg clicking on the link pointing at an activity with no graphs displayed (because all its statistics were zero) would move to the first following graph... which is not the graph corresponding to the link! This was because even if the graphs don't get displayed, sadf inserted the id tag in the SVG file, e.g.: In the example above, clicking on the link to display graph whose id is "g34-0" would display graph with id "g8-0" instead. This patch fixes the problem. Signed-off-by: Sebastien GODARD --- svg_stats.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/svg_stats.c b/svg_stats.c index 12de173..086a6f4 100644 --- a/svg_stats.c +++ b/svg_stats.c @@ -868,20 +868,13 @@ void draw_activity_graphs(int g_nr, int g_type[], char *title[], char *g_title[] unsigned int id, unsigned int xid) { char *out_p; - int i, j, dp, pos = 0, views_nr = 0; + int i, j, dp, pos = 0, views_nr = 0, displayed = FALSE; int v_gridnr, xv, yv; unsigned int asfactor[16]; long int xpos; double lmax, xfactor, yfactor, ypos, gmin, gmax; char val[32], cur_date[TIMESTAMP_LEN]; - /* Translate to proper position for current activity */ - printf("\n", - id, xid, - SVG_H_YSIZE + - SVG_C_YSIZE * (DISPLAY_TOC(flags) ? svg_p->nr_act_dispd : 0) + - SVG_T_YSIZE * svg_p->graph_no); - /* For each view which is part of current activity */ for (i = 0; i < g_nr; i++) { @@ -897,6 +890,16 @@ void draw_activity_graphs(int g_nr, int g_type[], char *title[], char *g_title[] if (skip_void && ((*(spmin + pos) == DBL_MAX) || (*(spmax + pos) == -DBL_MIN))) continue; + if (!displayed) { + /* Translate to proper position for current activity */ + printf("\n", + id, xid, + SVG_H_YSIZE + + SVG_C_YSIZE * (DISPLAY_TOC(flags) ? svg_p->nr_act_dispd : 0) + + SVG_T_YSIZE * svg_p->graph_no); + displayed = TRUE; + } + /* Increment number of views actually displayed */ views_nr++; @@ -1052,7 +1055,9 @@ void draw_activity_graphs(int g_nr, int g_type[], char *title[], char *g_title[] printf("\n"); pos += group[i]; } - printf("\n"); + if (displayed) { + printf("\n"); + } /* For next row of views */ (svg_p->graph_no) += PACK_VIEWS(flags) ? 1 : views_nr; -- 2.40.0