Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Creating a calendar view using time & height (Read 2564 times)
Mel
Full Member
*
Offline



Posts: 28

Creating a calendar view using time & height
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.
Back to top
 
« Last Edit: Nov 04th, 2015, 3:01am by Mel »  
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Creating a calendar view using time & height
Reply #1 - 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)
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Scott Heftler
Full Member
*
Offline



Posts: 33

Re: Creating a calendar view using time & height
Reply #2 - 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.
Back to top
 
« Last Edit: Nov 19th, 2015, 11:51pm by Scott Heftler »  
  IP Logged
Scott Heftler
Full Member
*
Offline



Posts: 33

Re: Creating a calendar view using time & height
Reply #3 - 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.
Back to top
 
 
  IP Logged
Scott Heftler
Full Member
*
Offline



Posts: 33

Re: Creating a calendar view using time & height
Reply #4 - 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
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Creating a calendar view using time & height
Reply #5 - Nov 21st, 2015, 9:17am
 
An alternative approach might be to use one big adornment with a grid. Just thinking!
Back to top
 
 
WWW   IP Logged
andreas grimm
Full Member
*
Offline



Posts: 39

Re: Creating a calendar view using time & height
Reply #6 - 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!

Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print