Using Evaluator in status bar to calculate color of bar graph?

Hi all,

I'm tinkering with my status bar and trying to get a bar graph colored via an Evaluator (which would allow me to use all kinds of conditions for the colors).

This is a simple example:
{bg+w=-1,b=n,g=0,t=n,f=3,v=du/dt,c=#666666} {du} / {dt}

Now I'm trying to change the bar color. I tried returning the whole bg code from an Evaluator:
{= "{bg+w=-1,b=n,g=0,t=n,f=3,v=du/dt,c=#666666}" =} {du} / {dt}
but that only prints out the code rather than turning it into a bar graph.

I tried returning only the actual color from the Evaluator:
{bg+w=-1,b=n,g=0,t=n,f=3,v=du/dt,c={= "#666666" =}} {du} / {dt}
but then the bar is shown with some default color instead, so my Evaluator result is ignored.

Then, just for fun, I tried inserting a variable (set to "#666666"), which also failed:
{bg+w=-1,b=n,g=0,t=n,f=3,v=du/dt,c={var:glob:my_color}} {du} / {dt}

Changing the text color with an Evaluator works perfectly, btw:
{bg+w=-1,b=n,g=0,t=n,f=3,v=du/dt,c=#666666} {= "<#FFFFFF>" =}{du} / {dt}</#>

So what am I doing wrong? I would guess that nested curly brackets aren't allowed? Do I have to escape them somehow? Is there another way of doing this? Or is it just not possible right now?

Thanks!

Not possible, but evaluator inserts can output simple HTML and change the color that way as you've discovered. There is a way to render bar graphs via HTML, but I don't have the info on hand.

We've never documented this since it's only really used internally, so you might have to play around a bit. Basically the code is <%bg> for a bar graph; it then takes a number of parameters separated by ^ symbols.

<%bg:value^total^width^color1^color2^color3^backcolor^textcolor^gradient^frame>

value: current value
total: total value
width: width in pixels
color1: fill color < 90%
color2: fill color > 90%
color3: not used (?)
backcolor: background fill
textcolor: overlay text color
gradient: gradient type (3 or 4)
frame: frame type

2 Likes

Wow, Jon, that's brilliant - thank you for sharing!!

I did play around and here's what I'm using for now (in case anybody is interested...):

{=myval=42; mytot=99; mycol="#777777"; "<%bg:" + myval + "^" + mytot + "^-1^" + mycol + "^" + mycol + "^" + mycol + "^-1^no^0^3> =} <#FFFFFF>{du} / {dt}</#>

value: myval, calculated as needed
total: mytot, calculated as needed
width: -1 (full width)
color1: mycol, calculated as needed (all colors to the same value, no gradient)
color2: mycol, calculated as needed
color3: mycol, calculated as needed
backcolor: -1 (no background)
textcolor: left out (probably illegal :wink: but seems to suppress the percentage overlay) NOPE, doesn't work, see answer below... "no" to suppress the percentage overlay, see answers below...
gradient: 0 (no gradient)
frame: 3 (fill section, enables by own text overlay)

This is the result, if configured for used disk space:

temp (1)

Evaluators are great addition to an already great product!
Thank you!

2 Likes

Sorry, my eyes deceived me: leaving out the text color does not suppress the percentage overlay. It's still printed behind my own overlay text (just in black on dark gray in the test above). Giving it the color of the bar isn't a good option either, for it only works once the bar is long enough. I'm trying to choose a color now that is just unobtrusive enough for the text to be hard to spot...

So the question remains: Is there a way to suppress the percentage output?

Specifying no for the color seems to work, as long as you also include a frame type after it. E.g.:

<%bg:75^100^70^#0000ff^#00aa00^#ffffff^#003333^no^3>
1 Like

Ooooh - I was so close... I tried "-1" and "n"... :laughing:

Thank you!

1 Like