From: Teemu Toivola Date: Wed, 10 Jul 2019 14:00:38 +0000 (+0300) Subject: fix height allocation and spacing of some image outputs being a little bit too small... X-Git-Tag: v2.3~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=219360d627bc2ecd95c335cf7b1c7aa06f7a72b5;p=vnstat fix height allocation and spacing of some image outputs being a little bit too small than intended --- diff --git a/CHANGES b/CHANGES index 78952c0..7629ba3 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,8 @@ - Interfaces could end up staying marked as 'disabled' in the database even after becoming back active and monitored, only the shown status was wrong without resulting in any data loss + - Some image outputs didn't allocate enough height for the image resulting + in the last row having less space below it than intended - New - Automatic interface selection when the Interface configuration setting is left empty (new default) diff --git a/src/image.c b/src/image.c index 332ff09..3b665ea 100644 --- a/src/image.c +++ b/src/image.c @@ -34,10 +34,10 @@ void drawimage(IMAGECONTENT *ic) drawsummary(ic, 0, 0); break; case 51: - drawsummary(ic, 1, cfg.hourlyrate); + drawsummary(ic, 1, cfg.hourlyrate); // horizontal break; case 52: - drawsummary(ic, 2, cfg.hourlyrate); + drawsummary(ic, 2, cfg.hourlyrate); // vertical break; case 7: drawhourly(ic, cfg.hourlyrate); @@ -574,14 +574,23 @@ void drawlist(IMAGECONTENT *ic, const char *listname) rowcount += datainfo.count; width = 500; - if ((listtype == LT_Day || listtype == LT_Month || listtype == LT_Year || listtype == LT_Top) && (datainfo.count < 2 || strlen(ic->dataend) == 0 || listtype == LT_Top)) { // less space needed when no estimate or sum is shown + height = 98; + + // less space needed when no estimate or sum is shown (Top, 5min and Hour never have estimate) + if ((listtype == LT_Day || listtype == LT_Month || listtype == LT_Year || listtype == LT_Top || listtype == LT_5min || listtype == LT_Hour) && + (datainfo.count < 2 || listtype == LT_Top || listtype == LT_5min || listtype == LT_Hour)) { height = 86; offsety = -16; - } else { + } + // exception for 5min and Hour when having sum shown + if ((listtype == LT_5min || listtype == LT_Hour) && datainfo.count > 1 && strlen(ic->dataend) > 0) { height = 98; + offsety = 0; } + height += 12 * rowcount; + // "no data available" if (!datainfo.count) { height = 98; offsety = -24; @@ -823,14 +832,17 @@ void drawsummary(IMAGECONTENT *ic, int type, int rate) dbdatalistinfo datainfo; switch (type) { + // horizontal case 1: width = 980; height = 200; break; + // vertical case 2: width = 500; height = 370; break; + // no hours default: width = 500; height = 200; @@ -1026,10 +1038,10 @@ void drawsummary(IMAGECONTENT *ic, int type, int rate) offset = 0; } - drawdonut(ic, 150 + offset, 163 - headermod, rxp, txp); + drawdonut(ic, 150 + offset, 158 - headermod, rxp, txp); textx = 100 + offset; - texty = 118 - headermod; + texty = 113 - headermod; d = localtime(&data_current->timestamp); strftime(daytemp, 16, cfg.mformat, d); @@ -1070,10 +1082,10 @@ void drawsummary(IMAGECONTENT *ic, int type, int rate) txp = txp * mod; } - drawdonut(ic, 330, 163 - headermod, rxp, txp); + drawdonut(ic, 330, 158 - headermod, rxp, txp); textx = 280; - texty = 118 - headermod; + texty = 113 - headermod; d = localtime(&data_previous->timestamp); strftime(daytemp, 16, cfg.mformat, d); @@ -1127,9 +1139,11 @@ void drawsummary(IMAGECONTENT *ic, int type, int rate) /* hours if requested */ switch (type) { + // horizontal case 1: drawhours(ic, 500, 46 - headermod, rate); break; + // vertical case 2: drawhours(ic, 12, 215 - headermod, rate); break;