Sunday, 24 August 2014

Creating RRD graphs for TME Ethernet thermometer TME_C_EU pt2

 Ok, so last post I created the graphs, but they don't look that good. They don't seem to scale right. They scale from 0 to about 30oC


So it's showing values 0-30oC, which doesn't show the zoomed in detail, as the fluctuations are only 27oC +- 3oC. This is to do with auto-scaling and that stacked area graphs start from 0.
The detail we need is actually in the 25-30 range.

So I've had to change the index.php script so that it auto scales. It doesn't look as fancy, but at least you can see the temperatures better.
    "--slope-mode",
    "--start", $start,
    "--title=$title",
    "--vertical-label=Temperature in oC",
    "DEF:temp=/mnt/ramdisk/temp.rrd:temp:AVERAGE",
    "DEF:tempmin=/mnt/ramdisk/temp.rrd:temp:MIN",
    "CDEF:ttemp=temp,1,*",
    "LINE:ttemp#E54400::",
    "COMMENT:\\n",
    "--alt-autoscale",
    "--alt-y-grid",
    #"--rigid",
    "GPRINT:temp:MAX:Max temp %6.2lf",
    "GPRINT:temp:MIN:Min temp %6.2lf",
    "GPRINT:temp:AVERAGE:Avg temp %6.2lf",

To make this prettier, you could also define the max/min values for the entire graph
$options = array(
    "--slope-mode",
    "--start", $start,
    "--title=$title",
    "--vertical-label=Temperature in oC",
    "DEF:temp=/mnt/ramdisk/temp.rrd:temp:AVERAGE",
    "DEF:tempmin=/mnt/ramdisk/temp.rrd:temp:MIN",
    "DEF:tempmax=/mnt/ramdisk/temp.rrd:temp:MAX",
    "CDEF:ttemp=temp,1,*",
    "VDEF:ttempmin=tempmin,MINIMUM",
    "VDEF:ttempmax=tempmax,MAXIMUM",
    "HRULE:ttempmin#4444FF::dashes=2,2",
    "HRULE:ttempmax#FF5500::dashes=2,2",
    "LINE:ttemp#000000::",
    "COMMENT:\\n",
    "--alt-autoscale",
    "--alt-y-grid",
    #"--rigid",
    "GPRINT:temp:MAX:Max temp %6.2lf",
    "GPRINT:temp:MIN:Min temp %6.2lf",
    "GPRINT:temp:AVERAGE:Avg temp %6.2lf",
        );
This will draw a horizontal ruler at the min and max values with blue and red dashed lines, respectively.

No comments:

Post a Comment