From e47a12f4cbc563cda85d95eab9f02645db555d45 Mon Sep 17 00:00:00 2001 From: Teemu Toivola Date: Fri, 5 Jan 2024 16:44:04 +0200 Subject: [PATCH] adjust 95th percentile image legend and x axis number spacing to match those used in the 5 minute graph --- src/image.c | 6 +++--- src/image_support.c | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/image.c b/src/image.c index 2d9161a..da028ad 100644 --- a/src/image.c +++ b/src/image.c @@ -1254,7 +1254,7 @@ void drawpercentile(IMAGECONTENT *ic, const int mode, const int xpos, const int d = localtime(¤t); strftime(datebuff, DATEBUFFLEN, "%d", d); drawpole(ic, x + i, y, height, 1, ic->cbgoffset); - gdImageString(ic->im, font, x + i - 4 - (ic->large), y + 4 - (ic->large), (unsigned char *)datebuff, ic->cline); + gdImageString(ic->im, font, x + i - 4 - (ic->large), y + 5, (unsigned char *)datebuff, ic->cline); prev = i; } continue; @@ -1264,7 +1264,7 @@ void drawpercentile(IMAGECONTENT *ic, const int mode, const int xpos, const int d = localtime(¤t); strftime(datebuff, DATEBUFFLEN, "%d", d); drawpole(ic, x + i, y, height, 1, ic->cbgoffset); - gdImageString(ic->im, font, x + i - 4 - (ic->large), y + 4 - (ic->large), (unsigned char *)datebuff, ic->ctext); + gdImageString(ic->im, font, x + i - 4 - (ic->large), y + 5, (unsigned char *)datebuff, ic->ctext); prev = i; } @@ -1306,5 +1306,5 @@ void drawpercentile(IMAGECONTENT *ic, const int mode, const int xpos, const int } /* finally add legend with percentile text */ - drawpercentilelegend(ic, x + 300 - (ic->large * 50), y + 15 + (ic->large * 5), mode, percentile); + drawpercentilelegend(ic, x + 300 - (ic->large * 50), y + 14 + (ic->large * 6), mode, percentile); } diff --git a/src/image_support.c b/src/image_support.c index ded9839..131cd8a 100644 --- a/src/image_support.c +++ b/src/image_support.c @@ -195,7 +195,7 @@ void drawlegend(IMAGECONTENT *ic, const int x, const int y, const short israte) void drawpercentilelegend(IMAGECONTENT *ic, const int x, const int y, const int mode, const uint64_t percentile) { - int color; + int color, xoffset = 0; char modetext[6], percentiletext[64]; if (mode == 0) { @@ -207,16 +207,17 @@ void drawpercentilelegend(IMAGECONTENT *ic, const int x, const int y, const int } else { snprintf(modetext, 6, "total"); color = ic->ctotal; + xoffset = 18 + (ic->large * 6); } - snprintf(percentiletext, 64, "%-5s 95th percentile: %s", modetext, gettrafficrate(percentile, 300, 0)); + snprintf(percentiletext, 64, "%s 95th percentile: %s", modetext, gettrafficrate(percentile, 300, 0)); gdImageString(ic->im, ic->font, x, y, (unsigned char *)percentiletext, ic->ctext); gdImageFilledRectangle(ic->im, x - 12 - (ic->large * 2), y + 4, x - 12 + ic->font->w - (ic->large * 2), y + 4 + ic->font->w, color); gdImageRectangle(ic->im, x - 12 - (ic->large * 2), y + 4, x - 12 + ic->font->w - (ic->large * 2), y + 4 + ic->font->w, ic->ctext); - gdImageFilledRectangle(ic->im, x + 42 + (ic->large * 16), y + 4, x + 42 + ic->font->w + (ic->large * 16), y + 4 + ic->font->w, ic->cpercentileline); - gdImageRectangle(ic->im, x + 42 + (ic->large * 16), y + 4, x + 42 + ic->font->w + (ic->large * 16), y + 4 + ic->font->w, ic->ctext); + gdImageFilledRectangle(ic->im, x + 30 + (ic->large * 12) + xoffset, y + 4, x + 30 + ic->font->w + (ic->large * 12) + xoffset, y + 4 + ic->font->w, ic->cpercentileline); + gdImageRectangle(ic->im, x + 30 + (ic->large * 12) + xoffset, y + 4, x + 30 + ic->font->w + (ic->large * 12) + xoffset, y + 4 + ic->font->w, ic->ctext); } void drawbar(IMAGECONTENT *ic, const int x, const int y, const int len, const uint64_t rx, const uint64_t tx, const uint64_t max, const short isestimate)