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 >> Creating a calendar view using time & height
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1446624068

Message started by Mel on Nov 4th, 2015, 3:01am

Title: Creating a calendar view using time & height
Post by Mel on Nov 4th, 2015, 3:01am

I'd like to implement a system within Tinderbox that will help me see what I should spend my time on and how my time spent compares to my goals for different categories.

I'm currently trying to create a map representing a day that has different time slices on it. What I would like is that the height and position of a note adjusts according to the start time and end time.

What I'm struggling with is using 'time' - in particular to add and subtract. I know there's a bunch of date related attributes that have time as a component. But I would like to be able to enter a start time and an end time (e.g. 8:30am - 9:30am) and from that calculate an x-height and also calculate a duration.

Title: Re: Creating a calendar view using time & height
Post by Mark Anderson on Nov 4th, 2015, 6:11am

x-height? In TB maps a length on the X axis is $Width, whilst $Height relates to extent on the Y axis. Under the hood, all TB dates are actually a date+time (even if the time part is not used/displayed). Date-times are simply milliseconds before or after a particular reference date. This allows date arithmetic to be done, whilst the app takes care of showing the milliseconds as actual days.

My hunch is you're wanting to do something like days on the Y axis and time of day on the X axis. Is that so?

It's most likely you'll also want to look at TB 'intervals', new to v6.3.1. Take a look at theses articles for the interval() function and the Interval data type. These tools allow you to calculate time-based durations without having to figure out mins>hrs>days ratios, etc. Intervals are presumed to be primarily for time (hours/minutes  - and even seconds) but do also support days - see the link above.

Interval calculation can give you the duration of a lesson. Let's assume you've put the lesson start/end in $StartDate and $EndDate as 4 Nov 2015 08:30:00 and 4 Nov 2015 09:30:00, then:

  $MyInterval = interval($StartDate,$EndDate);

Results in an interval value (when displayed in KA) of 01:00:00, i.e. 1 hours zero minutes//seconds. This can give you info on which to do your $Xpos, $Ypos, $Width and $Height calculations.

(tested in v6.3.2b174)

Title: Re: Creating a calendar view using time & height
Post by Scott Heftler on Nov 19th, 2015, 11:51pm

Here are the settings for your iCal_note prototype:

$DisplayExpression = if($StartDate) {time($StartDate) + " – " + time($EndDate) + ": " + $Name}

$KeyAttributes = $StartDate; $EndDate;

$Rule = if($StartDate) {$Ypos=($StartDate.hour + ($StartDate.minute / 60) - 11) * 1.5; $Height=(minutes($StartDate,$EndDate) / 60) * 1.5;}

Make a container note.  Set its $OnAdd to $Prototype=iCal_note; $Width=4;.  Open it in Map View.  Make seven Adornment columns 4.5 x 19 named "Sun" thru "Sat."  Then make a new note in the proper day column.  You can ignore Y-position, just horizontally center it.  When you type-in the $StartDate, this positions the top; $EndDate, the bottom.

Title: Re: Creating a calendar view using time & height
Post by Scott Heftler on Nov 20th, 2015, 12:48am

I should add that in cases like this, where notes get fancy with their display expression, it's often a good idea to set the $DisplayExpressionDisabled of the prototype to true.  Otherwise you'll have a bunch of long-named prototypes with "never" in their name (when the $DisplayExpression contains dates, as it does here). And since the $Rule here causes the note to jump around, you should set this to true as well.

Title: Re: Creating a calendar view using time & height
Post by Scott Heftler on Nov 20th, 2015, 2:18am

My size estimates were a bit off.  These are better and I just tried them out.

Set the adornments to 4.5 x 22.  This comfortably fits appointments from 0700-2230.

Set the $Rule of your iCal_note prototype to:

if($StartDate) {$Ypos=($StartDate.hour + ($StartDate.minute / 60) - 11) * 1.25; $Height=(minutes($StartDate,$EndDate) / 60) * 1.25;}; if($Height<1){$Height=1}

And here's a better $DisplayExpression:

if($StartDate){time($StartDate) + " - " + if($EndDate){time($EndDate) + ": " + $Name}}else{$Name}

Here's what it looks like:



You can download a demo here:

http://mapself.com/tb/updates/iCal.zip

Title: Re: Creating a calendar view using time & height
Post by Mark Bernstein on Nov 21st, 2015, 9:17am

An alternative approach might be to use one big adornment with a grid. Just thinking!

Title: Re: Creating a calendar view using time & height
Post by andreas grimm on Oct 22nd, 2016, 1:44pm

Good job, Scott. Thanks!

Any chance that you add the $Y-parameter so one could use this as a full-blown monthly calendar.


Cheers!


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.