b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | --- a/src/rrd_graph.c |
| 2 | +++ b/src/rrd_graph.c |
| 3 | @@ -2049,7 +2049,7 @@ horizontal_log_grid(gdImagePtr gif, imag |
| 4 | char graph_label[100]; |
| 5 | gdPoint polyPoints[4]; |
| 6 | int styleMinor[2],styleMajor[2]; |
| 7 | - double value, pixperstep, minstep; |
| 8 | + double value, pixperstep, minstep, yval; |
| 9 | |
| 10 | /* find grid spaceing */ |
| 11 | pixpex= (double)im->ysize / (log10(im->maxval) - log10(im->minval)); |
| 12 | @@ -2118,7 +2118,14 @@ horizontal_log_grid(gdImagePtr gif, imag |
| 13 | |
| 14 | gdImageLine(gif, polyPoints[0].x,polyPoints[0].y, |
| 15 | polyPoints[1].x,polyPoints[0].y,gdStyled); |
| 16 | - sprintf(graph_label,"%3.0e",value * yloglab[majoridx][i]); |
| 17 | + yval = value * yloglab[majoridx][i]; |
| 18 | + if (yval >= 100000) { |
| 19 | + sprintf(graph_label,"%3.0e", yval); |
| 20 | + } else { |
| 21 | + if (yval == 1) /* prints as 1e+00 */ |
| 22 | + yval = 0; |
| 23 | + sprintf(graph_label,"%5.0f", yval); |
| 24 | + } |
| 25 | gdImageString(gif, SmallFont, |
| 26 | (polyPoints[0].x - (strlen(graph_label) * |
| 27 | SmallFont->w)-7), |