TimelineJS JSON data format
Every timeline needs data about the events it is to show. Most people are happy to just use a Google spreadsheet to configure their Timeline, but if you want to write code to dynamically create or update your timeline, you'll need to understand how to format the data.
If you just want to dive in, you can probably copy from one of our examples (like the one about Whitney Houston). Otherwise, complete documentation is below.
After you have worked out how to create JSON data for a Timeline, you'll also need to put it on the page.
The TimelineJS JSON format consists of a single JSON object with the following properties:
events
title
eras
scale
human
or cosmological
. If no scale is specified, the default is human
. The cosmological
scale is required to handle dates in the very distant past or future. (Before Tuesday, April 20th, 271,821 BCE after Saturday, September 13 275,760 CE) For the cosmological
scale, only the year is considered, but it's OK to have a cosmological
timeline with years between 271,821 BCE and 275,760 CE.
Slide objects are JSON objects with the following properties:
start_date
title
slides
end_date
text
media
group
group
to be in the same row or adjacent rows, separate from events in other groups. The common value for the group will be shown as a label at the left edge of the navigation.
display_date
background
url
: the fully-qualified URL pointing to an image which will be used as the background
alt
: alternative text that describes the image provided by the url
property
color
: a CSS color, in hexadecimal (e.g. #0f9bd1
) or a valid CSS color keyword.
autolink
true
or false
). Defaults to true
, which means that Timeline will scan text fields and automatically add
<a>
tags so that links and email addresses are "clickable." If set to false, you may still manually apply the tags in the appropriate fields when
you want links. Autolinking applies to the text
field in
a text
object and the caption
and credit
fields in
a media
object.
unique_id
hash_bookmark
option is used, and can also be used with the timeline.goToId()
method to programmatically move the timeline to a specific slide.
Era objects are JSON objects which are used to label a span of time on the timeline navigation component. In structure, they are essentially very restricted "slide" objects.
start_date
end_date
text
Date objects are JSON objects with the following properties:
year
month
day
hour
minute
second
millisecond
display_date
year
property, at a minimum, must still be provided so that TimelineJS can properly position the event on the actual timeline.
format
display_date
(above), without needing to master the complexity of the date format strings.
Text objects are JSON objects with the following properties. For each slide, text objects are optional.
headline
text
Media objects are JSON objects with the following properties. For each slide, media objects are optional.
url
caption
credit
thumbnail
title
slides, because they do not have a marker.
alt
title
link
link_target