]> granicus.if.org Git - sysstat/commitdiff
SVG: Fix background H lines when all values are zero
authorSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 19 Feb 2016 12:48:22 +0000 (13:48 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 19 Feb 2016 12:48:22 +0000 (13:48 +0100)
The default Y scale max value is 1 when all the values are zero.
Yet in this case we still want 3 horizontal lines for the background
grid.

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

index ce57c0a5c023f4c3878d108d59565d1c798ac838..829089fb0d786002d3bc14efaf4d85abecb18ae3 100644 (file)
@@ -401,6 +401,11 @@ __print_funct_t svg_print_pcsw_stats(struct activity *a, int curr, int action, s
                               *(spmin + i), *(spmax + i));
 
                        out_p = *(out + i);
+                       /* Translate to proper position for current graph within current activity */
+                       printf("<g transform=\"translate(%d,%d)\">\n",
+                              SVG_M_XSIZE, SVG_M_YSIZE + SVG_G_YSIZE + i * SVG_T_YSIZE);
+
+                       /* Grid */
                        if (*(spmax + i) == 0) {
                                /* If all values are zero then set current max value to 1 */
                                lmax = 1.0;
@@ -408,11 +413,6 @@ __print_funct_t svg_print_pcsw_stats(struct activity *a, int curr, int action, s
                        else {
                                lmax = *(spmax + i);
                        }
-                       /* Translate to proper position for current graph within current activity */
-                       printf("<g transform=\"translate(%d,%d)\">\n",
-                              SVG_M_XSIZE, SVG_M_YSIZE + SVG_G_YSIZE + i * SVG_T_YSIZE);
-                       
-                       /* Grid */
                        ypos = ygrid(*(spmax + i), &dp);
                        yfactor = (double) -SVG_G_YSIZE / lmax;
                        j = 1;
@@ -422,7 +422,7 @@ __print_funct_t svg_print_pcsw_stats(struct activity *a, int curr, int action, s
                                       ypos * j, SVG_G_XSIZE, ypos * j, yfactor);
                                j++;
                        }
-                       while (ypos * j <= *(spmax + i));
+                       while (ypos * j <= lmax);
                        j = 0;
                        do {
                                printf("<text x=\"0\" y=\"%ld\" style=\"fill: white; stroke: none; font-size: 12px; "
@@ -430,7 +430,7 @@ __print_funct_t svg_print_pcsw_stats(struct activity *a, int curr, int action, s
                                       (long) (ypos * j * yfactor), dp, ypos * j);
                                j++;
                        }
-                       while (ypos * j <= *(spmax + i));
+                       while (ypos * j <= lmax);
 
                        k = xgrid(svg_p->record_hdr->ust_time, record_hdr->ust_time);
                        xfactor = (double) SVG_G_XSIZE / (record_hdr->ust_time - svg_p->record_hdr->ust_time);