]> granicus.if.org Git - sysstat/commitdiff
SVG: Handle files with orphan samples properly
authorSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 19 Feb 2016 13:38:36 +0000 (14:38 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 19 Feb 2016 13:38:36 +0000 (14:38 +0100)
If a file has only orphan samples then display "No data" indicating that
the graph cannot be drawn.
An orphan sample is something like:

sadc data        <-- LINUX RESTART
sadc data 1 1    <-- Create an orphan sample
sadc data        <-- LINUX RESTART

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

index 829089fb0d786002d3bc14efaf4d85abecb18ae3..35485c79e4a6d0439b2bd456e2608fa8bab5258b 100644 (file)
@@ -379,8 +379,12 @@ __print_funct_t svg_print_pcsw_stats(struct activity *a, int curr, int action, s
                               5 + SVG_M_XSIZE + SVG_G_XSIZE,
                               25 + i * SVG_T_YSIZE);
 
-                       /* At least two samples are needed */
-                       if (record_hdr->ust_time == svg_p->record_hdr->ust_time) {
+                       /*
+                        * At least two samples are needed.
+                        * And a min and max value should have been found.
+                        */
+                       if ((record_hdr->ust_time == svg_p->record_hdr->ust_time) ||
+                           (*(spmin + i) == DBL_MAX) || (*(spmax + i) == -DBL_MIN)) {
                                /* No data found */
                                printf("<text x=\"0\" y=\"%d\" style=\"fill: red; stroke: none\">No data</text>\n",
                                       SVG_M_YSIZE + i * SVG_T_YSIZE);