diff --git a/src/image.c b/src/image.c index 878c2fe..ec88644 100644 --- a/src/image.c +++ b/src/image.c @@ -1142,7 +1142,7 @@ void draw95thpercentilegraph(IMAGECONTENT *ic, const int mode) // TODO: rearrange debug prints void drawpercentile(IMAGECONTENT *ic, const int mode, const int xpos, const int ypos, const int height) { - int i, l, x = xpos, y = ypos, s = 0, step = 0, prev = 0; + int i, l, x = xpos, y = ypos, s = 0, step = 0, prev = 0, color; uint64_t scaleunit, max, percentile; double ratediv, percentileratediv; struct tm *d; @@ -1194,12 +1194,15 @@ void drawpercentile(IMAGECONTENT *ic, const int mode, const int xpos, const int } if (mode == 0) { + color = ic->crx; percentile = pdata.rxpercentile; max = (uint64_t)((double)datainfo.maxrx / ratediv); } else if (mode == 1) { + color = ic->ctx; percentile = pdata.txpercentile; max = (uint64_t)((double)datainfo.maxtx / ratediv); } else { + color = ic->cpercentile; percentile = pdata.sumpercentile; max = (uint64_t)((double)datainfo.max / ratediv); } @@ -1273,7 +1276,7 @@ void drawpercentile(IMAGECONTENT *ic, const int mode, const int xpos, const int } else { l = (int)lrint(((double)(datalist_i->rx + datalist_i->tx) / (double)ratediv / (double)max) * height); } - drawpole(ic, x + i, y, l, 1, ic->cpercentile); + drawpole(ic, x + i, y, l, 1, color); datalist_i = datalist_i->next; } @@ -1289,6 +1292,9 @@ void drawpercentile(IMAGECONTENT *ic, const int mode, const int xpos, const int } gdImageLine(ic->im, x, y - l, x + (744 + FIVEMINWIDTHPADDING), y - l, ic->cpercentileline); + // TODO: would it look better to draw the percentile line only up to the point where data ends? + // TODO: would it look better to end the x axis arrow where the data ends? + if (debug) { printf("s: %d\n", s); printf("l: %d\n", l); diff --git a/src/image_support.c b/src/image_support.c index 99994e2..affaf05 100644 --- a/src/image_support.c +++ b/src/image_support.c @@ -197,20 +197,24 @@ 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; char modetext[6], percentiletext[64]; if (mode == 0) { snprintf(modetext, 6, "rx"); + color = ic->crx; } else if (mode == 1) { snprintf(modetext, 6, "tx"); + color = ic->ctx; } else { snprintf(modetext, 6, "total"); + color = ic->cpercentile; } snprintf(percentiletext, 64, "%-5s 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, ic->cpercentile); + 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);