From 640f48193fb53de9d32e36bedde5d7eb73e92df9 Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Sun, 12 Jun 2016 10:07:24 +0200 Subject: [PATCH] SVG: Make sure graduations are properly aligned with grid Signed-off-by: Sebastien GODARD --- svg_stats.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/svg_stats.c b/svg_stats.c index 6f2976d..c072728 100644 --- a/svg_stats.c +++ b/svg_stats.c @@ -647,7 +647,7 @@ void draw_activity_graphs(int g_nr, int g_type, char *title[], char *g_title[], unsigned int asfactor[16]; long int k; double lmax, xfactor, yfactor, ypos, gmin, gmax; - char cur_time[32], val[32]; + char cur_time[32], val[32], stmp[32]; /* Translate to proper position for current activity */ printf("\n", @@ -777,9 +777,15 @@ void draw_activity_graphs(int g_nr, int g_type, char *title[], char *g_title[], while (ypos * j <= lmax); j = 0; do { + /* + * Use same rounded value for graduation numbers as for grid lines + * to make sure they are properly aligned. + */ + sprintf(stmp, "%.2f", ypos * j); + printf("%.*f.\n", - (long) (ypos * j * yfactor), dp, ypos * j); + (long) (atof(stmp) * yfactor), dp, ypos * j); j++; } while (ypos * j <= lmax); -- 2.40.0