(all you people with big enough screens to open multiple windows! (jealous rage emoji) )
I’ve managed to butcher a rudimentary bit of code to map(verb) dates and timeline bands back into map(noun) layouts.
What I’m trying to do is build not just a timeline of events, but show interconnections between them and overarching durations (documenting an enormously protracted piece of academic due process, and the events that have impacted it and my research areas). This is why I need to be able to use adornments, add non-timeline items (to explain and annotate events and impact), and have cause and effect arrows flying asunder.
I’ll stick the code at the end - it’s absolutely a rough first draft - because what I need to think about now is how to handle the situation of notes occupying the same space or overlapping.
I’m using this as a stamp - I pick a note that is set up as a timeline container, with items within it with start, optional end times, and possibly timelinebands. It then butchers their XPos, YPos and Widths, based on the dates it extracts. Though you can nest groups in a timeline (which is great for setting them up in an outline view), this makes zero sense in a map view. I’d have loved to be able to alias the notes into a new container (particularly to handle this nesting scenatio), but realised that aliases cannot be programmatically constructed. I also thought about cloning notes into a new flattened container, but nothing of the language dictionary (as documented extensively in ATbRef) suggested that this was something that should be attempted with code - as I understood it, I’d have to create new notes, then hunt through attribute lists, separate which were intrinsic, prototype, user-changed, or added arbitrarily, which seemed so fussy that I took it as a cue that I should be considering the data modelling issue differently.
// customise the following for layout control
var:number mappingXScale = 6;
var:number mappingYScale = 2;
//var:string destinationName = "Timeline Map";
//var:string destinationContainer = "";
// set up logging
create('/log');
$Text('/log')="";
// variables we will reuse
var:string toEpoch=".format('U').toNumber()";
// get notes we're mapping
var notes = collect(descendants,$IDString);
// get timeline bounds
var timeStartAtt = "$"+$TimelineStartAttribute;
var timeEndAtt = "$"+$TimelineEndAttribute;
var timeStart = $TimelineStart;
var timeEnd = $TimelineEnd;
var timeStartE = timeStart.format("U").toNumber();
var timeEndE = timeEnd.format("U").toNumber();
// timeEnd may be the string "never" - in this case,
// we should pull the highest date from start/end
// of all child nodes
//
if(timeEnd == "never") {
timeEnd = timeStart;
timeEndU = timeStartU;
notes.each(n){
var noteRef = "("+n+")";
var testDate = eval(timeStartAtt+noteRef);
var testDateE = eval(timeStartAtt+noteRef+toEpoch);
if(testDate!="never") {
if(testDateE>timeEndE) {
timeEnd = testDate;
timeEndE = testDateE;
}
} else {
testDate = eval(timeEndtAtt+noteRef);
testDateE = eval(timeEndAtt+noteRef+toEpoch);
if(testDate!="never") {
if(testDate>timeEndU) {
timeEnd = testDate;
timeEndE = testDateE;
}
}
}
}
}
//dolog("start = "+timeStart+", end = "+timeEnd);
var:number timelineTemporalWidth = timeEndE - timeStartE;
//dolog("timeline start = " + timeStart + ", end = " + timeEnd);
//dolog("seconds = " + timelineTemporalWidth);
// rewrite X, Y, Width of notes
//
notes = collect(descendants,$IDString);
notes.each(n){
var noteRef = "("+n+")";
var startDateS = eval(timeStartAtt+noteRef);
if(startDateS! ="never") {
// only touch notes with a start date!
var startDateE = eval(timeStartAtt+noteRef+toEpoch);
$Xpos(n) = (startDateE-timeStartE) / timelineTemporalWidth * mappingXScale;
var endDateS = eval(timeEndAtt+noteRef);
if(endDateS!="never") {
var endDateE = eval(timeEndAtt+noteRef+toEpoch);
// only set widths for notes with end dates
$Width(n) = endDateE / timelineTemporalWidth * mappingXScale;
}
// set a vertical position
$Ypos(n) = $TimelineBand(n) * mappingYScale;
}
}
//----
function dolog(msg) {
$Text('/log') = $Text('/log') + msg + "\n\n";
}
//----