[rrd-users] Order of legend-items in a stack

Simon Hobson linux at thehobsons.co.uk
Thu Jan 25 22:53:10 CET 2007

Wolfgang Powisch (privat) wrote:

>When using STACKs, the order of the AREA definitions is mandatory.
>But the order of this definition forces the legend-items also to be in
>this order. I would need some solution to change the order/position of
>the legend-items ... is this possible.
>For better understanding, what I need in detail, in a fancy ascii-graph:
>^     out_c
>|     out_b    <-- stacked
>|     out_a
>|-------------------------------- <--HRULE (zero-line)
>|     in_a
>|     in_b     <-- stacked (negative values)
>|     in_c
>   # in_a       # out_a
>   # in_b       # out_b
>   # in_c       # out_c
>so the stack-order is:
>    in_a,in_b,in_c,out_a,out_b,out_c
>but the legend order should be:
>    in_a,out_a,in_b,out_b,in_c,out_c

Simple, do all the legends as part of the out stack. I do graphs 
exactly like this at work and effectively do something like this :

for var in a b c
   CDEF ... (calculate out value for $var)
   CDEF ... (calculate in value for $var)

for var in a b c
   area out_$var ...
   gprint in_$var out_$var

for var in a b c
   area in_$var ...

You could actually combine the first two loops, but I felt it made 
things more understandable to keep them separate. As it happens, 
there's been a similar thread over on teh Shorewall lists, you might 
gives you some ideas.

More information about the rrd-users mailing list