Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Tinderbox applications >> Dashboards
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1237407056

Message started by Mark Bernstein on Mar 18th, 2009, 4:10pm

Title: Dashboards
Post by Mark Bernstein on Mar 18th, 2009, 4:10pm

I've been discussing Tinderbox dashboards on my blog

 http://www.markbernstein.org/Mar09/DashboardProgressBar.html

Happy to answer questions!  More usefully: how do you summarize Tinderbox information so you can see critical items at a glance?



Title: Re: Dashboards
Post by Amafortas on Mar 19th, 2009, 9:35pm

Mark,

I've been trying to make the example you posted on your blog for making a running word count work, and I've run into a problem.

I've pasted the following text into the Rule area on a new note:
"Rule: Text=sum_if(descendant(/BOOK),1,$WordCount);)

I copied the text directly from your blog, includeing the opening quotation mark.

I have also created a container called "BOOK" and put some notes in it with text.

Could you please provide me with some advice for how to proceed?

Thanks,

~A

Title: Re: Dashboards
Post by Mark Anderson on Mar 20th, 2009, 5:15am

[post-edited for correction]
It looks like you've confused the sum_if parameters. It should be sum_if(which notes, condition to test, increment to add). You're not providing a test, just a value 1 - oops, not strictly true, see Mark B's next post. You actually want to test WordCount is > 0. So you need (checked in v4.6.1):

$Text=sum_if(descendant(/BOOK),$WordCount>0,$WordCount)

Actually, this more concise syntax also works and is simpler:

$Text=sum_if(descendant(/BOOK),$WordCount,$WordCount)

OK, in the latter version the test is effectively "does WordCount have a value?" as a count of zero equates to no value, so a test of '$WordCount' is always true for any other value than 0; as we can't have a negative word count the test will be true - and cause that note to be counted - wherever a note in the searched group has 1 or more words. There's no harm in using the first form - it's only two more characters - and sometimes writing things out more explicitly helps when you come to trouble shoot days or weeks later.

See more on sum_if().

Title: Re: Dashboards
Post by Amafortas on Mar 20th, 2009, 10:57am

Mark,

Thanks for the help. You may want to change rule in the blog posting. (Follow the link in the first post.) Unless I'm missing something the rule posted there is not working.

Have a good one,

~A

Title: Re: Dashboards
Post by Mark Bernstein on Mar 20th, 2009, 11:24am

Actually, I believe the rule *does* work.  Mark Anderson's rule

  $Text=sum_if(descendant(/BOOK),$WordCount>0,$WordCount)

is fine; it sums up all the word counts that are greater than zero.  But it does no harm to add in all the zero word counts too!

    $Text=sum_if(descendant(/BOOK),1,$WordCount)

Since "1" is always true, this will add up everything.

(

Title: Re: Dashboards
Post by Mark Anderson on Mar 20th, 2009, 12:03pm

Mea culpa, I've rechecked. If I set both the condition and increment parameters to 1 I get a count of matching notes and - as Mark B says - I get a count of all notes in scope regardless of whether they have a WordCount or not. If I set the condition to back to '$'WordCount' and leave the increment as 1 I get a count of only those items with a count >0.

My mistake was not to start my test with the OP's 'bad' code.  Now I see that this Text=sum_if(descendant(/BOOK),1,$WordCount);) rule does work - at least in v4.6.1.  I can only assume the OP's problem lay elsewhere or was an undetected typo (i.e. the rule wasn't exactly as posted).

Title: Re: Dashboards
Post by peter lindsay on Mar 20th, 2009, 12:54pm

Mark
how do you get the coloured font in the labels in map view ?
Peter

Title: Re: Dashboards
Post by Amafortas on Mar 20th, 2009, 1:19pm

Marks,

I've tried recopying and pasting your code and I'm now getting a word count.

~A

Title: Re: Dashboards
Post by Mark Bernstein on Mar 20th, 2009, 1:54pm

Peter Lindsay --

The color of the body text is set by MapBodyTextColor, and its size is MapBodyTextSize.  (I'm using "green", which I redefined as "#c2d841".  36pt Futura Condensed.  But I encourage you to experiment!)

Title: Re: Dashboards
Post by Mark Anderson on Mar 21st, 2009, 5:29am

Was MapBodyTextColor added in v4.6 or v4.6.1?

Also, if one is doing a word count of all notes in group regardless of whether they have any words, it might be easier to just us a non-conditional sum:

$Text=sum(descendant(/BOOK),$WordCount)

instead of

Text=sum_if(descendant(/BOOK),1,$WordCount)

Title: Re: Dashboards
Post by Hugh Akston on Mar 21st, 2009, 9:09pm

Mark,

Love the dashboard idea in your blog.  I'm playing with one of my own.  I was successful using your word count example.   Can you describe how you did the progress bar?  I'm also intrigued by your idea to use the hue function to change color based on progress toward a goal.  

Many thanks!!

Title: Re: Dashboards
Post by Mark Anderson on Mar 22nd, 2009, 9:08am

A progress bar is set using the horizontal bar() pattern, or the vertical vbar() pattern. note that in v4.6+ the pattern must be written as a string, i.e. $Pattern="bar(20)" or $Pattern="bar($MyProgress)" not as Pattern=bar(50) as previously.

In the above the 'progress' color is drawn in Color2. The hue of a colour can be controlled via the hue operator.

Title: Re: Dashboards
Post by Hugh Akston on Mar 22nd, 2009, 10:13am

Many thanks, Mark!   I'll give it a try.

Edit:   It worked perfectly.   Thanks again!  Next I'll try messing around with the hue.  Maybe light green to dark green as I make progress toward the goal.

Title: Re: Dashboards
Post by Mark Anderson on Mar 22nd, 2009, 10:58am

Here's a stab at the hue issue, you'll need a custom colour attribute and this rule:

$MyColor=rgb(201,102,102);if($MyProgress<33){$Color2=$MyColor};if(($MyProgress>33)&($MyProgress<67)){$Color2=hue($MyColor,200)};if($MyProgress>67){$Color2=hue($MyColor,150)};$Pattern="bar($MyProgress)";

Breaking out the individual terms out a bit onto separate lines we get:

$MyColor=rgb(201,102,102);
if($MyProgress<33){$Color2=$MyColor};
if(($MyProgress>33)&($MyProgress<67)){$Color2=hue($MyColor,200)};
if($MyProgress>67){$Color2=hue($MyColor,150)};
$Pattern="bar($MyProgress)";


So, how does it work? First, we define a colour,$MyColor, that we won't modify further but rather use it as a reference to make hue-shifted colours from that we apply to $Color2 which draws the progress bar. Depending on the value of $ProgressBar, $Color2 is changed  In the above example, below 33% complete the fill colour is red, 33%-67% it is blue and above 67% it is green. Play with the base colour and hue offsets to get different colour combos. Clearly, if you want more variation in colour, you'll need more 'if' clauses.

One thing I do note is that despite setting $Pattern last in the Rule, when I change $MyProgress the bar updates immediately but $Color2 does not - it appears to wait until the next agent/action/rule update cycle. That strikes me as unexpected but it's probably flaky syntax on my part rather than an error in TB's rule resolution.

Title: Re: Dashboards
Post by Mark Bernstein on Mar 22nd, 2009, 12:42pm

Mark Anderson's approach is great.  Here's another one.

Let's suppose we have a numeric variable we want to reflect as a dashboard color.  We'll call it $MyNumber assume it's in the range from 0 to 100.

Using a Rule, we say

     $Color=saturation(green,$MyNumber);

where we've been using a custom green of #c2d841 in all our examples.  Here's what we get:



Or, perhaps we leave the Color of the note unchanged by vary the brightness of the label:

      $NameColor=$NameColor=brightness(green,$MyNumber);

Now, low values are dark, and high values are bright:



Another trick: play with the drop shadow. Setting ShadowBlur to 30 and ShadowDistance to 0, our rule becomes

$ShadowColor=brightness(white,$Name);

and now high-value notes glow:



Title: Re: Dashboards
Post by highapostle on Mar 22nd, 2009, 6:31pm

I'm really interested in the Dashboard idea, but I'm running into trouble with setting up the "Random word" note. I've set everything up as suggested in the "Random word of the day" post on the blog, and it will grab the text ... and then change it every second, even though by the code it shouldn't change it if the date of the note is set to today (which it is). Any idea what's going on here? Running Tinderbox 4.6.1.

Title: Re: Dashboards
Post by Mark Bernstein on Mar 22nd, 2009, 6:49pm

Looking back at http://www.markbernstein.org/Mar09/RandomWordOfTheDay.html, the  suggested rule says:

Quote:
if($Date!="today"){$Text=runCommand($command);$Date="today"}



This relies on a user attribute called $Date -- a place where we store the date of the most recent random word.  

Did you create an attribute called $Date?  Is it in fact a date attribute?  That's the most likely source of the problem.

Title: Re: Dashboards
Post by highapostle on Mar 22nd, 2009, 9:52pm

Yep, the variable's called Date (can't name it with a $, though I use it in the if statement), and my code is identical to the one you posted here. The if statement does change the value of Date to the current date and time, but it seems like the first part is being ignored.

Title: Re: Dashboards
Post by Mark Anderson on Mar 23rd, 2009, 4:33am

The '$' is a code syntax to show Date is an attribute, it is not part of the name and you should not be able to use it as the start of an attribute name nor (not tested) in a name.

The default data type for new attributes is 'string'. IOW, if you create a user attribute and just give it a name it will be string type unless you also set a different type. It's worth double-checking your 'Date' attribute is of 'date' type as you don't specifically reply to that question say in your last message. If it is string type, your random word's Date attribute value will likely be 'today' and not an actual date.

Title: Re: Dashboards
Post by highapostle on Mar 23rd, 2009, 10:44am

Sorry, forgot to mention that in my previous post - Date is indeed a "date" type attribute. I tried this out in a new Tinderbox file, just to be on the safe side, got the same behaviour.

Title: Re: Dashboards
Post by Mark Bernstein on Mar 23rd, 2009, 11:03am

Why don't you send us your file?

Title: Re: Dashboards
Post by BrianH on Mar 23rd, 2009, 2:59pm

Email sent, thanks for your help!

Title: Re: Dashboards: The Answe
Post by Mark Bernstein on Mar 23rd, 2009, 5:27pm

In 4.6.1, != is subtly different from = with respect to dates

What you want is

     if(!($Date="today")) {....

which is true if the current value of $Date is not the same day as today.  In 4.6.1, "=" is true for dates on the same calendar say, but "!=" didn't get the memo and is still taking time into account.

Starting in 4.6.2, you'll be able to use != with the expected result.

Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.