Skip to content

Commit

Permalink
adjust 95th percentile image legend and x axis number spacing to matc…
Browse files Browse the repository at this point in the history
…h those used in the 5 minute graph
  • Loading branch information
vergoh committed Jan 5, 2024
1 parent 919de4d commit e47a12f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,7 @@ void drawpercentile(IMAGECONTENT *ic, const int mode, const int xpos, const int
d = localtime(&current);
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;
Expand All @@ -1264,7 +1264,7 @@ void drawpercentile(IMAGECONTENT *ic, const int mode, const int xpos, const int
d = localtime(&current);
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;
}

Expand Down Expand Up @@ -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);
}
9 changes: 5 additions & 4 deletions src/image_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand Down

0 comments on commit e47a12f

Please sign in to comment.