]> granicus.if.org Git - sysstat/commitdiff
SVG: Handle integer values in graph caption
authorSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 1 Apr 2016 12:33:22 +0000 (14:33 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 1 Apr 2016 12:33:22 +0000 (14:33 +0200)
Some metrics are integer values: Their min/max values should then be
displayed as integer values (xxxx and not xxxx.00).
Such a metric will be identified by a leading ~ character in its name.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
svg_stats.c

index 8ce6449911af152909f01c93332956d2e41e38d1..669456ec8dbde8169c62b948e733835d022aa5dc 100644 (file)
@@ -601,11 +601,13 @@ void draw_activity_graphs(int g_nr, int g_type, char *title[], char *g_title[],
 
                /* Caption */
                for (j = 0; j < group[i]; j++) {
+                       /* Set dp to TRUE (1) if current metric is based on integer values */
+                       dp = (g_title[pos + j][0] == '~');
                        printf("<text x=\"%d\" y=\"%d\" style=\"fill: #%06x; stroke: none; font-size: 12px\">"
-                              "%s (%.2f, %.2f)</text>\n",
+                              "%s (%.*f, %.*f)</text>\n",
                               5 + SVG_M_XSIZE + SVG_G_XSIZE, SVG_M_YSIZE + i * SVG_T_YSIZE + j * 15,
-                              svg_colors[(pos + j) & SVG_COLORS_IDX_MASK], g_title[pos + j],
-                      *(spmin + pos + j), *(spmax + pos + j));
+                              svg_colors[(pos + j) & SVG_COLORS_IDX_MASK], g_title[pos + j] + dp,
+                              !dp * 2, *(spmin + pos + j), !dp * 2, *(spmax + pos + j));
                }
 
                /* Get global min and max value for current set of graphs */