[rrd-users] Re: One area printed over another

Alex van den Bogaerdt alex at ergens.op.het.net
Sun Jan 4 12:52:49 MET 2004


On Sat, Jan 03, 2004 at 10:32:30PM -0500, David OBrien wrote:

> graphing memory usage.. But can someone write a CDEF that would
> show how to place the larger value behind the smaller value in a
> non-stack situation like this...

Algoritm:
    if (x > y) {
       area(color1) x
       area(color2) y
    } else {
       area(color2) y
       area(color1) x
    }

This cannot be done directly as you cannot use IF to draw areas or not.
The IF function *can* be used to set variables.

Rewrite:

    if (x>y) {
       x1=x
       x2=UNKN
    } else {
       x1=UNKN
       x2=x
    }
    area(color1) x1
    area(color2) y
    area(color1) x2

Now we have a situation where the first area is drawn when x is larger
than y, the second area is always drawn and the third is drawn when x
is not larger than y.

This is what you were looking for.  Note that the values can be equal,
still hiding one after another.

In CDEF there's no grouping of commands. Rewrite again:

    if (x>y) x1=x else x1=UNKN
    if (x>y) x2=UNKN else x2=x
    area(color1) x1
    area(color2) y
    area(color1) x2

Convert to RPN:

    if (x>y) then p else q ==> (x>y)?p:q ==> x,y,GT,p,q,IF

    CDEF:x1=x,y,GT,x,UNKN,IF
    CDEF:x2=x,y,GT,UNKN,x,IF
    AREA:x1#00CC00:x
    AREA:y#0000FF:y
    AREA:x2#00CC00

The labels reflect the original variables, not the intermediate.
The third AREA needs no label as it is already shown the first time.

HTH
Alex
-- 
begin  sig
http://www.googlism.com/index.htm?ism=alex+van+den+bogaerdt&type=1
This message was produced without any <iframe tags

--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-users mailing list