mirror of
https://github.com/openwrt/packages.git
synced 2025-01-31 03:41:44 +00:00
edc41b26ab
The y-axis graph labels in logarithmic mode display in 'scientific' notation eg: '1e+00' for 0, '1e+01' for 10, '1e+02' for 100 and so on. This IMO is a pain in the backside for non scientific humans to read. Modified output to display numbers up to 99,999 in conventional decimal format and to revert to scientific notation for larger, thus the same display space is taken. Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
28 lines
1000 B
Diff
28 lines
1000 B
Diff
--- a/src/rrd_graph.c
|
|
+++ b/src/rrd_graph.c
|
|
@@ -2049,7 +2049,7 @@ horizontal_log_grid(gdImagePtr gif, imag
|
|
char graph_label[100];
|
|
gdPoint polyPoints[4];
|
|
int styleMinor[2],styleMajor[2];
|
|
- double value, pixperstep, minstep;
|
|
+ double value, pixperstep, minstep, yval;
|
|
|
|
/* find grid spaceing */
|
|
pixpex= (double)im->ysize / (log10(im->maxval) - log10(im->minval));
|
|
@@ -2118,7 +2118,14 @@ horizontal_log_grid(gdImagePtr gif, imag
|
|
|
|
gdImageLine(gif, polyPoints[0].x,polyPoints[0].y,
|
|
polyPoints[1].x,polyPoints[0].y,gdStyled);
|
|
- sprintf(graph_label,"%3.0e",value * yloglab[majoridx][i]);
|
|
+ yval = value * yloglab[majoridx][i];
|
|
+ if (yval >= 100000) {
|
|
+ sprintf(graph_label,"%3.0e", yval);
|
|
+ } else {
|
|
+ if (yval == 1) /* prints as 1e+00 */
|
|
+ yval = 0;
|
|
+ sprintf(graph_label,"%5.0f", yval);
|
|
+ }
|
|
gdImageString(gif, SmallFont,
|
|
(polyPoints[0].x - (strlen(graph_label) *
|
|
SmallFont->w)-7),
|