X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_graph_helper.c;h=6028b01b6f4bbe6c6443891aa874f39090384e9c;hb=361a0fd38d7adf95847508f54c0bde9b3f98662e;hp=375521c25137250b8a0d1fd1d1960c331291e55a;hpb=554df7224e8b3fec9ec5981812b453c43072f150;p=rrdtool.git diff --git a/src/rrd_graph_helper.c b/src/rrd_graph_helper.c index 375521c..6028b01 100644 --- a/src/rrd_graph_helper.c +++ b/src/rrd_graph_helper.c @@ -1,5 +1,5 @@ /**************************************************************************** - * RRDtool 1.2.4 Copyright by Tobi Oetiker, 1997-2005 + * RRDtool 1.2.8 Copyright by Tobi Oetiker, 1997-2005 **************************************************************************** * rrd_graph_helper.c commandline parser functions * this code initially written by Alex van den Bogaerdt @@ -295,6 +295,21 @@ rrd_parse_PVHLAST(char *line, unsigned int *eaten, graph_desc_t *gdp, image_desc int i,j,k; int colorfound=0; char tmpstr[MAX_VNAME_LEN + 10]; /* vname#RRGGBBAA\0 */ + static int spacecnt = 0; + + if (spacecnt == 0) { + float one_space = gfx_get_text_width(im->canvas, 0, + im->text_prop[TEXT_PROP_LEGEND].font, + im->text_prop[TEXT_PROP_LEGEND].size, + im->tabwidth," ", 0) / 4.0; + float target_space = gfx_get_text_width(im->canvas, 0, + im->text_prop[TEXT_PROP_LEGEND].font, + im->text_prop[TEXT_PROP_LEGEND].size, + im->tabwidth,"oo", 0); + spacecnt = target_space / one_space; + dprintf("- spacecnt: %i onespace: %f targspace: %f\n",spacecnt,one_space,target_space); + } + dprintf("- parsing '%s'\n",&line[*eaten]); @@ -399,16 +414,15 @@ rrd_parse_PVHLAST(char *line, unsigned int *eaten, graph_desc_t *gdp, image_desc dprintf("- examining '%s'\n",&line[*eaten]); if (linecp[*eaten] != '\0' && linecp[*eaten] != ':') { - /* If the legend is not empty, it has to be prefixed with "m ". This then gets + int spi; + /* If the legend is not empty, it has to be prefixed with spacecnt ' ' characters. This then gets * replaced by the color box later on. */ - (*eaten)--; - linecp[*eaten]=' '; - (*eaten)--; - linecp[*eaten]='m'; + for (spi=0;spi 1;spi++){ + linecp[--(*eaten)]=' '; + } } if (rrd_parse_legend(linecp, eaten, gdp)) err=1; - free(linecp); if (err) return 1;