Re: Temperature diff colors

Simon Hobson <[email protected]>
Newsgroups gmane.comp.db.rrdtool.user
Message-ID <[email protected]>
Martin <[email protected]> wrote:

> I´m wondering if anyone has a code example for showing diffrent colors in a graph depending on temperatue like this, if it above +0 and up the color is red and if its below -0 its blue ?

Here's one I did that does "light red" when things are close to the limit, and "full on red" when above the limit (it's part of a Bash script) :

>   echo "${RRDHead}
> 
>         DEF:op_pc_ave=${RRDPath}/${RRDName}:op_pc:AVERAGE
>         DEF:op_pc_min=${RRDPath}/${RRDName}:op_pc:MIN
>         DEF:op_pc_max=${RRDPath}/${RRDName}:op_pc:MAX
>         CDEF:op_pc_spread=op_pc_max,op_pc_min,-
>         VDEF:v_op_pc_ave=op_pc_ave,AVERAGE
>         VDEF:v_op_pc_max=op_pc_max,MAXIMUM
>         VDEF:v_op_pc_min=op_pc_min,MINIMUM
>         VDEF:v_op_pc_lst=op_pc_ave,LAST
> 
>         CDEF:alarm1=op_pc_max,${Plimit},100,LIMIT
>         AREA:alarm1#FFBFBF:
>         CDEF:alarm2=op_pc_max,99,10000,LIMIT
>         AREA:alarm2#FF0000:
> 
>         COMMENT:\"                  min      ave      max      last\n\"
>         HRULE:${Plimit}#7F0000
>         AREA:op_pc_min#FFFFFF00:
>         AREA:op_pc_spread#BFBFFF::STACK
>         LINE1:op_pc_ave#0000FF:\"%age Power\"
>         GPRINT:v_op_pc_min:\"%6.0lf \"
>         GPRINT:v_op_pc_ave:\"%6.0lf \"
>         GPRINT:v_op_pc_max:\"%6.0lf \"
>         GPRINT:v_op_pc_lst:\"%6.0lf\"
> 
> 
>         COMMENT:\"  Data to ${PrintedTime}\n\"
>         >

For yours' what I'd suggest is two CDEFs, one which is X when X < 0 and UNKN when X >= 0, the other which is X when X is >= 0 and UNKN when X < 0. Then plot the first CDEF in blue, and the second one in red.

So something like :
CDEF:xb=x,unkn,x,0,lt,if
CDEF:xr=x,unkn,x,0,ge,if
should (if I've got my RPN right from memory) give you the two series to draw.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.