|
Timeline_EventSources
Information about Event Attributes and Data formats XML, JSON and SPARQL
Event Attributes and Data FormatsTimeline Event data can use any of the following popular formats:
An Event Source controls the loading of data sources into a timeline. Also see loading events dynamically. Event attributes and data formatsThere is only one underlying meaning of Timeline event attributes. But the event attributes are arranged slightly differently in the different data transport formats. Each format's adapter reads the incoming data and stores it in the Timeline. For example, in the XML format, the events are a series of elements under the root element. In JSON, the root hash has an events array, whose order is not important. In the sections below, the data attributes are described. The placement of the attributes is described in the XML and JSON Data Formats sections. Event attributesDefaults are used if an event does not specify an attribute value. start attribute is required. See Event Display options for examples of the different ways to display an event on a Timeline Basic Event Attributes
Date Time FormatsThe default date time parser uses the Javascript Date parser built into the browser. Recommended formats
Formats that are not recommended
Programming tips for proper date time formats
Additional Event Attributes
Notes:
Event Attributes for Developers
Organizing event typesYou have two options for translating your event types to the user. For example, suppose most of your events are of type 'regular,' and some are of type 'special.' You want the special events to be visually distinct on the Timeline. Two options:
Deprecated Event attributesThe following event attributes are still supported, but you should not use them for new event sources. Support may be removed at the next major release.
Timeline attributesThese attributes are specified once per Timeline. They are then used for all events in the Timeline. They are optional.
Which Data Format?If another department will be creating the data file for you, your choices may be limited. For example, XML may be the preferred data exchange format for your organization. If you have more control over the data source, you may wish to try the JSON format with calls to the Date object. This format will give you the fastest load times. You can also write a Javascript adapter (similar to the existing XML, JSON and SPARCL adapters) to directly interpret a different data format. XML Data FormatThe XML format used for Timeline includes the above attributes in the following format: Everything is contained within a <data> element. The <data> element can have the Timeline attributes listed above:
The data element contains one or more child elements of type <event>, the order is not significant. Each <event> element can include any of the event attributes listed above. For example:
The xml document must be served with a content-type that the browser thinks is xml: "text/xml, application/xml or ends in +xml" (per the XMLHttpRequest spec). If it's not, you could get this cryptic error, which I include here as search bait: TypeError: xml has no properties "XmlHttp: Error handling onReadyStateChange" \[Exception... "'XmlHttp: Error handling onReadyStateChange' when calling method: \[nsIOnReadyStateChangeHandler::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "<unknown>" data: no] fDone(XMLHttpRequest readyState=4 status=200)timeplot-bundle.j... (line 177) _onReadyStateChange(XMLHttpRequest readyState=4 status=200, function(), function())simile-ajax-bundl... (line 2429) onreadystatechange() XML Examples<data
wiki-url="http://simile.mit.edu/shelf/"
wiki-section="Simile JFK Timeline">
<event
start="Sat May 20 1961 00:00:00 GMT-0600"
title="'Bay of Pigs' Invasion">
</event>
<event
start="Wed May 01 1963 00:00:00 GMT-0600"
end="Sat Jun 01 1963 00:00:00 GMT-0600"
isDuration="true"
title="Oswald moves to New Orleans">
Oswald moves to New Orleans, and finds employment at the William <!-- The event's description -->
B. Riley Coffee Company. <i>ref. Treachery in Dallas, p 320</i>
</event>
<event>
...
</event>
</data>JSON Data FormatSee http://json.org for general information about JSON. The JSON format used for Timeline includes the above attributes in the following format: Everything is contained in a single base object {} The base object can include the Timeline attributes:
Each event object can include the event attributes listed above as key : value pairs. For example:
As noted in the Event attributes section above, the Timeline JSON data format will accept references to the Javascript Date object as an alternative to date strings. Note that your data set will no longer strictly qualify as JSON if you include Date objects in it. (But it will load faster!) CaveatsJSON true, false values must not include quotes. See durationEvent, below. JSON arrays and objects should not have trailing commas before closing brackets or braces. If present, they will cause problems with some JS engines. Eg, the one in Internet Explorer. JSON Examples{
'wiki-url':"http://simile.mit.edu/shelf/",
'wiki-section':"Simile JFK Timeline",
'dateTimeFormat': 'Gregorian',
'events': [
{
'start':"Sat May 20 1961 00:00:00 GMT-0600",
'title':"'Bay of Pigs' Invasion",
'durationEvent':false // Notes: not "false". And no trailing comma.
}, {
'start':"Wed May 01 1963 00:00:00 GMT-0600" ,
'end':"Sat Jun 01 1963 00:00:00 GMT-0600" ,
'durationEvent':true,
'title':"Oswald moves to New Orleans",
'description':"Oswald moves to New Orleans, and finds employment at the
William B. Riley Coffee Company. <i>ref. Treachery in Dallas, p 320</i>"
}, {
...
} ] // Note: Do NOT include a trailing comma! (Breaks on IE)
}
Please do not leave comments here, they are not read. Use the mailing list. Thanks. |
Sign in to add a comment