aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>2020-04-26 21:10:43 +0100
committerKevin Darbyshire-Bryant <6500011+ldir-EDB0@users.noreply.github.com>2020-05-05 11:58:49 +0100
commitedc41b26ab1e78d55e87c79562d8430b87d314a7 (patch)
tree747094640fbd4d473980c6179d8ff080834524b9
parentd6caf776aeaba806f0d528d9504fc19e13e8211b (diff)
rrdtool1: modify logarithmic scale labelling
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>
-rw-r--r--utils/rrdtool1/Makefile2
-rw-r--r--utils/rrdtool1/patches/040-no-e-notation-on-log-display.patch27
2 files changed, 28 insertions, 1 deletions
diff --git a/utils/rrdtool1/Makefile b/utils/rrdtool1/Makefile
index 49da89fc1..a031c17d5 100644
--- a/utils/rrdtool1/Makefile
+++ b/utils/rrdtool1/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=rrdtool1
PKG_VERSION:=1.0.50
-PKG_RELEASE:=2
+PKG_RELEASE:=3
PKG_BUILD_DIR:=$(BUILD_DIR)/rrdtool-$(PKG_VERSION)
PKG_SOURCE:=rrdtool-$(PKG_VERSION).tar.gz
diff --git a/utils/rrdtool1/patches/040-no-e-notation-on-log-display.patch b/utils/rrdtool1/patches/040-no-e-notation-on-log-display.patch
new file mode 100644
index 000000000..45551670c
--- /dev/null
+++ b/utils/rrdtool1/patches/040-no-e-notation-on-log-display.patch
@@ -0,0 +1,27 @@
+--- 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),