# [rrd-users] Graphing data by layers

Alex van den Bogaerdt alex at vandenbogaerdt.nl
Tue Dec 22 01:09:40 CET 2009

```If one value can be higher than the next,  but a moment later it can be
lower than the rest, then it will be hard to plot the lowest value last.  It
is doable, with a lot of complicated CDEFs.  But what if they are equal? And
what if they are not equal, but they differ by such a small amount that it
results in the same amount of pixels in your graph?
One part of the graph: value 10.0000000000001 gets hidden behind value 10.
Another part of the graph: value 10 is visible, <unknown data> is not.
How do you see the difference?

Anyway, an attempt to achieve it despite my concerns:
(not tested, may be full of bugs, logic errors, and so on)

# get your data
DEF:input1=...
DEF:input2=...
DEF:input3=...
DEF:input4=...
# clean it; if data=data then it is a finite number, else substitute 0
CDEF:orig1=input1,input1,EQ,input1,0,IF
CDEF:orig2=input2,input2,EQ,input2,0,IF
CDEF:orig3=input3,input3,EQ,input3,0,IF
CDEF:orig4=input4,input4,EQ,input4,0,IF
#  test (orig1>orig2) results in 1 or 0.  Count the number of 1 and know the
position
CDEF:orig1pos1=orig1,orig2,GT,orig1,orig3,GT,orig1,orig4,GT,+,+,3,EQ,orig1,UNKN,IF
CDEF:orig1pos2=orig1,orig2,GT,orig1,orig3,GT,orig1,orig4,GT,+,+,2,EQ,orig1,UNKN,IF
CDEF:orig1pos3=orig1,orig2,GT,orig1,orig3,GT,orig1,orig4,GT,+,+,1,EQ,orig1,UNKN,IF
CDEF:orig1pos4=orig1,orig2,GT,orig1,orig3,GT,orig1,orig4,GT,+,+,0,EQ,orig1,UNKN,IF
CDEF:orig2pos1=orig2,orig1,GT,orig2,orig3,GT,orig2,orig4,GT,+,+,3,EQ,orig2,UNKN,IF
CDEF:orig2pos2=orig2,orig1,GT,orig2,orig3,GT,orig2,orig4,GT,+,+,2,EQ,orig2,UNKN,IF
CDEF:orig2pos3=orig2,orig1,GT,orig2,orig3,GT,orig2,orig4,GT,+,+,1,EQ,orig2,UNKN,IF
CDEF:orig2pos4=orig2,orig1,GT,orig2,orig3,GT,orig2,orig4,GT,+,+,0,EQ,orig2,UNKN,IF
{ repeat for orig3pos1 ... orig4pos4 }
# plot the largest value first. One of these four has defined data, the
other 3 are unknowns
AREA:orig1pos1#color1
AREA:orig2pos1#color2
AREA:orig3pos1#color3
AREA:orig4pos1#color4
# then the 2nd to largest value
AREA:orig1pos2#color1
AREA:orig2pos2#color2
AREA:orig3pos2#color3
AREA:orig4pos2#color4
# and so on
AREA:orig1pos3#color1
AREA:orig2pos3#color2
AREA:orig3pos3#color3
AREA:orig4pos3#color4
AREA:orig1pos4#color1
AREA:orig2pos4#color2
AREA:orig3pos4#color3
AREA:orig4pos4#color4

And now hope you have plenty of memory to work with.  The solution isn't
pretty, and I bet the outcome also doesn't look pretty.

Somewhat more sane suggestions, don't know if it's possible with your data:

Use the negative side of the Y-axis to display 2 values.
On each side of the Y-axis, stack one value up a fixed number, some value
that should never be reached by the other value.

DEF:orig1=...
DEF:orig2=...
DEF:orig3=...
DEF:orig4=...
CDEF:mirrored1=orig1,-1,*
CDEF:mirrored2=orig2,-1,*
AREA:mirrored1#color:legend
AREA:-100
AREA:mirrored2#color:legend:STACK
AREA:orig3#color:legend
AREA:100
AREA:orig4#color:legend:STACK

If "AREA:100" is not possible, you need to do something like this:
CDEF:hundred=100,orig1,POP
and plot that one (without a colour, thus invisible, but available to stack
upon)

There may be other solutions.

HTH
Alex

----- Original Message -----
From: "Jose Oscar Olivares Ocampo/Mexico/Contr/IBM" <oscaro at mx1.ibm.com>
To: <rrd-users at lists.oetiker.ch>
Sent: Tuesday, December 22, 2009 12:06 AM
Subject: [rrd-users] Graphing data by layers

Hello everyone, I am a beginner user of the tool.

I have 4 values on an RRD file, which I am trying to graph into a single
chart.
I want all these values to be AREAs.

My problem is that sometimes, one value is greater than the rest at
certain interval, and this value superpose at the front (making the rest
"invisible").
Changing the order is of no help, since these values are not predictable
and any of them can be greater than the rest at a given interval.

Is there a way to force the lower value to be graphed at front and the
higher at the back of a chart?
Should I use alpha on the areas for this?

The current definitions as follows:
"DEF:Connections=\$DB_PATH:Connections:AVERAGE"
"DEF:AverageRTT=\$DB_PATH:AverageRTT:AVERAGE"
"AREA:Connections#C0000F:Connections"
"AREA:AverageRTT#3333FF:AverageRTT"

Any idea will be appreciated.

Best Regards!
José Oscar Olivares Ocampo

--------------------------------------------------------------------------------

> _______________________________________________
> rrd-users mailing list
> rrd-users at lists.oetiker.ch
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
>

```