From 8498ea3dec08e3e85edb751920d2dbc1b3108468 Mon Sep 17 00:00:00 2001 From: oetiker Date: Sun, 7 May 2006 10:46:24 +0000 Subject: [PATCH] make legend spacing more reliable. handle the fact that some graph comands do not contribute to the legend -- tobi git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2@822 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/src/rrd_graph.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/program/src/rrd_graph.c b/program/src/rrd_graph.c index 37a313ba..201ee4c6 100644 --- a/program/src/rrd_graph.c +++ b/program/src/rrd_graph.c @@ -1399,6 +1399,7 @@ leg_place(image_desc_t *im) int fill=0, fill_last; int leg_c = 0; int leg_x = border, leg_y = im->yimg; + int leg_y_prev = im->yimg; int leg_cc; int glue = 0; int i,ii, mark = 0; @@ -1507,14 +1508,22 @@ leg_place(image_desc_t *im) + legspace[ii] + glue; } - leg_y += im->text_prop[TEXT_PROP_LEGEND].size*1.8; - if (prt_fctn == 's') leg_y -= im->text_prop[TEXT_PROP_LEGEND].size; + leg_y_prev = leg_y; + /* only add y space if there was text on the line */ + if (leg_x > border || prt_fctn == 's') + leg_y += im->text_prop[TEXT_PROP_LEGEND].size*1.8; + if (prt_fctn == 's') + leg_y -= im->text_prop[TEXT_PROP_LEGEND].size; fill = 0; leg_c = 0; mark = ii; } } - im->yimg = leg_y; + im->yimg = leg_y_prev; + /* if we did place some legends we have to add vertical space */ + if (leg_y != im->yimg){ + im->yimg += im->text_prop[TEXT_PROP_LEGEND].size*1.8; + } free(legspace); } return 0; -- 2.30.2