Timeline documentation

Overview

The Timeline is an interactive visualization chart to visualize data in time. The data items can take place on a single date, or have a start and end date (a range). You can freely move and zoom in the timeline by dragging and scrolling in the Timeline. Items can be created, edited, and deleted in the timeline. The time scale on the axis is adjusted automatically, and supports scales ranging from milliseconds to years.

Timeline uses regular HTML DOM to render the timeline and items put on the timeline. This allows for flexible customization using css styling.

Contents

Example

The following code shows how to create a Timeline and provide it with data. More examples can be found in the examples directory.

<!DOCTYPE HTML>
<html>
<head>
  <title>Timeline | Basic demo</title>

  <style type="text/css">
    body, html {
      font-family: sans-serif;
    }
  </style>

  <script src="../../dist/vis.js"></script>
  <link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="visualization"></div>

<script type="text/javascript">
  // DOM element where the Timeline will be attached
  var container = document.getElementById('visualization');

  // Create a DataSet (allows two way data-binding)
  var items = new vis.DataSet([
    {id: 1, content: 'item 1', start: '2013-04-20'},
    {id: 2, content: 'item 2', start: '2013-04-14'},
    {id: 3, content: 'item 3', start: '2013-04-18'},
    {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
    {id: 5, content: 'item 5', start: '2013-04-25'},
    {id: 6, content: 'item 6', start: '2013-04-27'}
  ]);

  // Configuration for the Timeline
  var options = {};

  // Create a Timeline
  var timeline = new vis.Timeline(container, items, options);
</script>
</body>
</html>

Loading

Install or download the vis.js library. in a subfolder of your project. Include the libraries script and css files in the head of your html code:

<script src="vis/dist/vis.js"></script>
<link href="vis/dist/vis.css" rel="stylesheet" type="text/css" />
The constructor of the Timeline is vis.Timeline
var timeline = new vis.Timeline(container, items, options);
or when using groups:
var timeline = new vis.Timeline(container, items, groups, options);
The constructor accepts four parameters:

Data Format

The timeline can be provided with two types of data:

Items

The Timeline uses regular Arrays and Objects as data format. Data items can contain the properties start, end (optional), content, group (optional), className (optional), and style (optional).

A table is constructed as:

var items = [
  {
    start: new Date(2010, 7, 15),
    end: new Date(2010, 8, 2),  // end is optional
    content: 'Trajectory A'
    // Optional: fields 'id', 'type', 'group', 'className', 'style'
  }
  // more items...
]);

The item properties are defined as:

Name Type Required Description
className String no This field is optional. A className can be used to give items an individual css style. For example, when an item has className 'red', one can define a css style like:
.vis.timeline .red {
  color: white;
  background-color: red;
  border-color: darkred;
}
More details on how to style items can be found in the section Styles.
content String yes The contents of the item. This can be plain text or html code.
end Date | number | string | Moment no The end date of the item. The end date is optional, and can be left null. If end date is provided, the item is displayed as a range. If not, the item is displayed as a box.
group any type no This field is optional. When the group column is provided, all items with the same group are placed on one line. A vertical axis is displayed showing the groups. Grouping items can be useful for example when showing availability of multiple people, rooms, or other resources next to each other.
id String | Number no An id for the item. Using an id is not required but highly recommended. An id is needed when dynamically adding, updating, and removing items in a DataSet.
start Date | number | string | Moment yes The start date of the item, for example new Date(2010,9,23).
style String no A css text string to apply custom styling for an individual item, for example "color: red; background-color: pink;".
subgroup String | Number none The id of a subgroup. Groups all items within a group per subgroup, and positions them on the same height instead of staking them on top of each other. can be ordered by specifying the option subgroupOrder of a group.
title String none Add a title for the item, displayed when holding the mouse on the item. The title can only contain plain text.
type String 'box' The type of the item. Can be 'box' (default), 'point', 'range', or 'background'. Types 'box' and 'point' need a start date, the types 'range' and 'background' needs both a start and end date.

Groups

Like the items, groups are regular JavaScript Arrays and Objects. Using groups, items can be grouped together. Items are filtered per group, and displayed as Group items can contain the properties id, content, and className (optional).

Groups can be applied to a timeline using the method setGroups or supplied in the constructor. A table with groups can be created like:

var groups = [
  {
    id: 1,
    content: 'Group 1'
    // Optional: a field 'className', 'style'
  }
  // more groups...
]);

Groups can have the following properties:

Name Type Required Description
className String no This field is optional. A className can be used to give groups an individual css style. For example, when a group has className 'red', one can define a css style .red { color: red; } . More details on how to style groups can be found in the section Styles.
content String yes The contents of the group. This can be plain text or html code.
id String | Number yes An id for the group. The group will display all items having a property group which matches the id of the group.
style String no A css text string to apply custom styling for an individual group label, for example "color: red; background-color: pink;".
subgroupOrder String | Function none Order the subgroups by a field name or custom sort function. By default, groups are ordered by first-come, first-show.
title String none A title for the group, displayed when holding the mouse on the groups label. The title can only contain plain text.

Configuration Options

Options can be used to customize the timeline. Options are defined as a JSON object. All options are optional.

var options = {
  width: '100%',
  height: '30px',
  margin: {
    item: 20
  }
};

The following options are available.

Name Type Default Description
align String "center" Alignment of items with type 'box', 'range', and 'background'. Available values are 'auto' (default), 'center', 'left', or 'right'. For 'box' items, the 'auto' alignment is 'center'. For 'range' items, the auto alignment is dynamic: positioned left and shifted such that the contents is always visible on screen.
autoResize boolean true If true, the Timeline will automatically detect when its container is resized, and redraw itself accordingly. If false, the Timeline can be forced to repaint after its container has been resized using the function redraw().
clickToUse boolean false When a Timeline is configured to be clickToUse, it will react to mouse and touch events only when active. When active, a blue shadow border is displayed around the Timeline. The Timeline is set active by clicking on it, and is changed to inactive again by clicking outside the Timeline or by pressing the ESC key.
dataAttributes Array[String] | 'all' false An array of fields optionally defined on the timeline items that will be appended as data- attributes to the DOM element of the items.
If value is 'all' then each field defined on the timeline item will become a data- attribute.
editable Boolean | Object false If true, the items in the timeline can be manipulated. Only applicable when option selectable is true. See also the callbacks onAdd, onUpdate, onMove, and onRemove. When editable is an object, one can enable or disable individual manipulation actions. See section Editing Items for a detailed explanation.
editable.add Boolean false If true, new items can be created by double tapping an empty space in the Timeline. See section Editing Items for a detailed explanation.
editable.remove Boolean false If true, items can be deleted by first selecting them, and then clicking the delete button on the top right of the item. See section Editing Items for a detailed explanation.
editable.updateGroup Boolean false If true, items can be dragged from one group to another. Only applicable when the Timeline has groups. See section Editing Items for a detailed explanation.
editable.updateTime Boolean false If true, items can be dragged to another moment in time. See section Editing Items for a detailed explanation.
end Date | Number | String | Moment none The initial end date for the axis of the timeline. If not provided, the latest date present in the items set is taken as end date.
format Object none Apply custom date formatting of the labels on the time axis. The default value of format is:
{
  minorLabels: {
    millisecond:'SSS',
    second:     's',
    minute:     'HH:mm',
    hour:       'HH:mm',
    weekday:    'ddd D',
    day:        'D',
    month:      'MMM',
    year:       'YYYY'
  },
  majorLabels: {
    millisecond:'HH:mm:ss',
    second:     'D MMMM HH:mm',
    minute:     'ddd D MMMM',
    hour:       'ddd D MMMM',
    weekday:    'MMMM YYYY',
    day:        'MMMM YYYY',
    month:      'YYYY',
    year:       ''
  }
}
For values which not provided in the customized options.format, the default values will be used. All available formatting syntax is described in the docs of moment.js.
groupOrder String | Function none Order the groups by a field name or custom sort function. By default, groups are not ordered.
height Number | String none The height of the timeline in pixels or as a percentage. When height is undefined or null, the height of the timeline is automatically adjusted to fit the contents. It is possible to set a maximum height using option maxHeight to prevent the timeline from getting too high in case of automatically calculated height.
hiddenDates Object none This option allows you to hide specific timespans from the time axis. The dates can be supplied as an object: {start: '2014-03-21 00:00:00', end: '2014-03-28 00:00:00', [repeat:'daily']} or as an Array of these objects. The repeat argument is optional. The possible values are (case-sensitive): daily, weekly, monthly, yearly. To hide a weekend, pick any Saturday as start and the following Monday as end and set repeat to weekly.
locale String none Select a locale for the Timeline. See section Localization for more information.
locales Object none A map with i18n locales. See section Localization for more information.
margin Number | Object Object When a number, applies the margin to margin.axis, margin.item.horizontal, and margin.item.vertical.
margin.axis Number 20 The minimal margin in pixels between items and the time axis.
margin.item Number 10 The minimal margin in pixels between items in both horizontal and vertical direction.
margin.item.horizontal Number 10 The minimal horizontal margin in pixels between items.
margin.item.vertical Number 10 The minimal vertical margin in pixels between items.
max Date | Number | String | Moment none Set a maximum Date for the visible range. It will not be possible to move beyond this maximum.
maxHeight Number | String none Specifies the maximum height for the Timeline. Can be a number in pixels or a string like "300px".
min Date | Number | String | Moment none Set a minimum Date for the visible range. It will not be possible to move beyond this minimum.
minHeight Number | String none Specifies the minimum height for the Timeline. Can be a number in pixels or a string like "300px".
moveable Boolean true Specifies whether the Timeline can be moved and zoomed by dragging the window. See also option zoomable.
onAdd Function none Callback function triggered when an item is about to be added: when the user double taps an empty space in the Timeline. See section Editing Items for more information. Only applicable when both options selectable and editable.add are set true.
onUpdate Function none Callback function triggered when an item is about to be updated, when the user double taps an item in the Timeline. See section Editing Items for more information. Only applicable when both options selectable and editable.updateTime or editable.updateGroup are set true.
onMove Function none Callback function triggered when an item has been moved: after the user has dragged the item to an other position. See section Editing Items for more information. Only applicable when both options selectable and editable.updateTime or editable.updateGroup are set true.
onMoving Function none Callback function triggered repeatedly when an item is being moved. See section Editing Items for more information. Only applicable when both options selectable and editable.updateTime or editable.updateGroup are set true.
onRemove Function none Callback function triggered when an item is about to be removed: when the user tapped the delete button on the top right of a selected item. See section Editing Items for more information. Only applicable when both options selectable and editable.remove are set true.
order Function none

Provide a custom sort function to order the items. The order of the items is determining the way they are stacked. The function order is called with two arguments containing the data of two items to be compared.

WARNING: Use with caution. Custom ordering is not suitable for large amounts of items. On load, the Timeline will render all items once to determine their width and height. Keep the number of items in this configuration limited to a maximum of a few hundred items.

orientation String | Object 'bottom' Orientation of the timelines axis and items. When orientation is a string, the value is applied to both items and axis. Can be 'top', 'bottom' (default), or 'both'.
orientation.axis String 'bottom' Orientation of the timeline axis: 'top', 'bottom' (default), or 'both'. If orientation is 'bottom', the time axis is drawn at the bottom. When 'top', the axis is drawn on top. When 'both', two axes are drawn, both on top and at the bottom.
orientation.item String 'bottom' Orientation of the timeline items: 'top' or 'bottom' (default). Determines whether items are aligned to the top or bottom of the Timeline.
padding Number 5 The padding of items, needed to correctly calculate the size of item ranges. Must correspond with the css of items, for example when setting options.padding=10, corresponding css is:
.vis.timeline .item {
  padding: 10px;
}
selectable Boolean true If true, the items on the timeline can be selected. Multiple items can be selected by long pressing them, or by using ctrl+click or shift+click. The event select is fired each time the selection has changed (see section Events).
showCurrentTime boolean true Show a vertical bar at the current time.
showCustomTime boolean false Show a vertical bar displaying a custom time. This line can be dragged by the user. The custom time can be utilized to show a state in the past or in the future. When the custom time bar is dragged by the user, the event timechange is fired repeatedly. After the bar is dragged, the event timechanged is fired once.
showMajorLabels boolean true By default, the timeline shows both minor and major date labels on the time axis. For example the minor labels show minutes and the major labels show hours. When showMajorLabels is false, no major labels are shown.
showMinorLabels boolean true By default, the timeline shows both minor and major date labels on the time axis. For example the minor labels show minutes and the major labels show hours. When showMinorLabels is false, no minor labels are shown. When both showMajorLabels and showMinorLabels are false, no horizontal axis will be visible.
stack Boolean true If true (default), items will be stacked on top of each other such that they do not overlap.
snap function | null function When moving items on the Timeline, they will be snapped to nice dates like full hours or days, depending on the current scale. The snap function can be replaced with a custom function, or can be set to null to disable snapping. The signature of the snap function is:
function snap(date: Date, scale: string, step: number) : Date | number
The parameter scale can be can be 'millisecond', 'second', 'minute', 'hour', 'weekday, 'day, 'month, or 'year'. The parameter step is a number like 1, 2, 4, 5.
start Date | Number | String | Moment none The initial start date for the axis of the timeline. If not provided, the earliest date present in the events is taken as start date.
template Function none A template function used to generate the contents of the items. The function is called by the Timeline with an items data as argument, and must return HTML code as result. When the option template is specified, the items do not need to have a field content. See section Templates for a detailed explanation.
timeAxis.scale string none Set a fixed scale for the time axis of the Timeline. Choose from 'millisecond', 'second', 'minute', 'hour', 'weekday', 'day', 'month', 'year'. Example usage:
var options = {
  timeAxis: {scale: 'minute', step: 5}
}
timeAxis.step number 1 Set a fixed step size for the time axis. Only applicable when used together with timeAxis.scale. Choose for example 1, 2, 5, or 10.
type String none Specifies the default type for the timeline items. Choose from 'box', 'point', 'range', and 'background'. Note that individual items can override this default type. If undefined, the Timeline will auto detect the type from the items data: if a start and end date is available, a 'range' will be created, and else, a 'box' is created. Items of type 'background' are not editable.
width String '100%' The width of the timeline in pixels or as a percentage.
zoomable Boolean true Specifies whether the Timeline can be zoomed by pinching or scrolling in the window. Only applicable when option moveable is set true.
zoomMax Number 315360000000000 Set a maximum zoom interval for the visible range in milliseconds. It will not be possible to zoom out further than this maximum. Default value equals about 10000 years.
zoomMin Number 10 Set a minimum zoom interval for the visible range in milliseconds. It will not be possible to zoom in further than this minimum.

Methods

The Timeline supports the following methods.

Method Return Type Description
addCustomTime(time[, id]) Number | String Only applicable when the option showCustomTime is true.
Add new vertical bar representing custom time that can be dragged by the user. Parameter time can be a Date, Number, or String. Parameter id can be Number or String. If id is provided, it will be used as ID for the new vertical bar, otherwise the ID will be auto generated.
Returns ID of the newly created bar.
clear([what]) none Clear the Timeline. An object can be passed specifying which sections to clear: items, groups, and/or options. By Default, items, groups and options are cleared, i.e. what = {items: true, groups: true, options: true}. Example usage:
timeline.clear();                // clear items, groups, and options
timeline.clear({options: true}); // clear options only
destroy() none Destroy the Timeline. The timeline is removed from memory. all DOM elements and event listeners are cleaned up.
fit([options]) none Adjust the visible window such that it fits all items. See also function focus(id). Available options:
  • animate: boolean | number
    If true (default), the range is animated smoothly to the new window. If a number, the number is taken as duration for the animation. Default duration is 500 ms.
focus(id | ids [, options]) none Adjust the visible window such that the selected item (or multiple items) are centered on screen. See also function fit(). Available options:
  • animate: boolean | number
    If true (default), the range is animated smoothly to the new window. If a number, the number is taken as duration for the animation. Default duration is 500 ms.
getCurrentTime() Date Get the current time. Only applicable when option showCurrentTime is true.
getCustomTime([id]) Date Retrieve the custom time. Only applicable when the option showCustomTime is true. If parameter id is provided, time of the custom time bar under that ID is returned.
getEventProperties(event) Object Returns an Object with relevant properties from an event:
  • group (Number | null): the id of the clicked group.
  • item (Number | null): the id of the clicked item.
  • pageX (Number): absolute horizontal position of the click event.
  • pageY (Number): absolute vertical position of the click event.
  • x (Number): relative horizontal position of the click event.
  • y (Number): relative vertical position of the click event.
  • time (Date): Date of the clicked event.
  • snappedTime (Date): Date of the clicked event, snapped to a nice value.
  • what (String | null): name of the clicked thing: item, background, axis, group-label, custom-time, or current-time.
  • event (Object): the original click event.
getSelection() Number[] Get an array with the ids of the currently selected items.
getVisibleItems() Number[] Get an array with the ids of the currently visible items.
getWindow() Object Get the current visible window. Returns an object with properties start: Date and end: Date.
moveTo(time [, options]) none Move the window such that given time is centered on screen. Parameter time can be a Date, Number, or String. Available options:
  • animate: boolean | number
    If true (default), the range is animated smoothly to the new window. If a number, the number is taken as duration for the animation. Default duration is 500 ms.
on(event, callback) none Create an event listener. The callback function is invoked every time the event is triggered. Avialable events: rangechange, rangechanged, select. The callback function is invoked as callback(properties), where properties is an object containing event specific properties. See section Events for more information.
off(event, callback) none Remove an event listener created before via function on(event, callback). See section Events for more information.
redraw() none Force a redraw of the Timeline. The size of all items will be recalculated. Can be useful to manually redraw when option autoResize=false and the window has been resized, or when the items CSS has been changed.
removeCustomTime(id) none Remove vertical bars previously added to the timeline via addCustomTime method. Parameter id is the ID of the custom vertical bar returned by addCustomTime method.
setCurrentTime(time) none Set a current time. This can be used for example to ensure that a client's time is synchronized with a shared server time. time can be a Date object, numeric timestamp, or ISO date string. Only applicable when option showCurrentTime is true.
setCustomTime(time [, id]) none Adjust the custom time bar. Only applicable when the option showCustomTime is true. Parameter time can be a Date object, numeric timestamp, or ISO date string. Parameter id represents ID of the custom time bar, provided by addCustomTime method and can be a Number or String.
setGroups(groups) none Set a data set with groups for the Timeline. groups can be an Array with Objects, a DataSet, or a DataView. For each of the groups, the items of the timeline are filtered on the property group, which must correspond with the id of the group.
setItems(items) none Set a data set with items for the Timeline. items can be an Array with Objects, a DataSet, or a DataView.
setOptions(options) none Set or update options. It is possible to change any option of the timeline at any time. You can for example switch orientation on the fly.
setSelection(id | ids [, options]) none Select one or multiple items by their id. The currently selected items will be unselected. To unselect all selected items, call `setSelection([])`. Available options:
  • focus: boolean
    If true, focus will be set to the selected item(s)
  • animate: boolean | number
    If true (default), the range is animated smoothly to the new window. If a number, the number is taken as duration for the animation. Default duration is 500 ms. Only applicable when option focus is true.
setWindow(start, end [, options]) none Set the current visible window. The parameters start and end can be a Date, Number, or String. If the parameter value of start or end is null, the parameter will be left unchanged. Available options:
  • animate: boolean | number
    If true (default), the range is animated smoothly to the new window. If a number, the number is taken as duration for the animation. Default duration is 500 ms.

Events

Timeline fires events when changing the visible window by dragging, when selecting items, and when dragging the custom time bar.

Here an example on how to listen for a select event.

timeline.on('select', function (properties) {
  alert('selected items: ' + properties.nodes);
});

A listener can be removed via the function off:

function onSelect (properties) {
  alert('selected items: ' + properties.nodes);
}

// add event listener
timeline.on('select', onSelect);

// do stuff...

// remove event listener
timeline.off('select', onSelect);

The following events are available.

name Description Properties
click Fired when clicked inside the Timeline. Passes a properties object as returned by the method Timeline.getEventProperties(event).
contextmenu Fired when right-clicked inside the Timeline. Note that in order to prevent the context menu from showing up, default behavior of the event must be stopped:
timeline.on('contextmenu', function (props) {
  alert('Right click!');
  props.event.preventDefault();
});
Passes a properties object as returned by the method Timeline.getEventProperties(event).
doubleClick Fired when double clicked inside the Timeline. Passes a properties object as returned by the method Timeline.getEventProperties(event).
finishedRedraw Fired after a redraw is complete. When moving the timeline around, this could be fired frequently. none.
rangechange Fired repeatedly when the timeline window is being changed.
  • start (Number): timestamp of the current start of the window.
  • end (Number): timestamp of the current end of the window.
  • byUser (Boolean): change happened because of user drag/zoom.
rangechanged Fired once after the timeline window has been changed.
  • start (Number): timestamp of the current start of the window.
  • end (Number): timestamp of the current end of the window.
  • byUser (Boolean): change happened because of user drag/zoom.
select Fired after the user selects or deselects items by tapping or holding them. When a use taps an already selected item, the select event is fired again. Not fired when the method setSelectionis executed.
  • items: an array with the ids of the selected items
timechange Fired repeatedly when the user is dragging the custom time bar. Only available when the custom time bar is enabled.
  • id (Number | String): Vertical bar ID.
  • time (Date): the current time.
timechanged Fired once after the user has dragged the custom time bar. Only available when the custom time bar is enabled.
  • id (Number | String): Vertical bar ID.
  • time (Date): the current time.

Editing Items

When the Timeline is configured to be editable (both options selectable and editable are true), the user can:

Option editable accepts a boolean or an object. When editable is a boolean, all manipulation actions will be either enabled or disabled. When editable is an object, one can enable individual manipulation actions:

// enable or disable all manipulation actions
var options = {
  editable: true       // true or false
};

// enable or disable individual manipulation actions
var options = {
  editable: {
    add: true,         // add new items by double tapping
    updateTime: true,  // drag items horizontally
    updateGroup: true, // drag items from one group to another
    remove: true       // delete an item by tapping the delete button top right
  }
};

One can specify callback functions to validate changes made by the user. There are a number of callback functions for this purpose:

Each of the callbacks is invoked with two arguments:

Example code:

var options = {
  onUpdate: function (item, callback) {
    item.content = prompt('Edit items text:', item.content);
    if (item.content != null) {
      callback(item); // send back adjusted item
    }
    else {
      callback(null); // cancel updating the item
    }
  }
};
A full example is available here: 08_edit_items.html.

Templates

Timeline supports templates to format item contents. Any template engine (such as handlebars or mustache) can be used, and one can also manually build HTML. In the options, one can provide a template handler. This handler is a function accepting an items data as argument, and outputs formatted HTML:

var options = {
  template: function (item) {
    var html = ... // generate HTML markup for this item
    return html;
  }
};

Create HTML manually

The HTML for an item can be created manually:
var options = {
  template: function (item) {
    return '<h1>' + item.header + '</h1><p>' + item.description + '</p>';
  }
};

Using a template engine

Using handlebars, one can write the template in HTML:
<script id="item-template" type="text/x-handlebars-template">
  <h1>{{header}}</h1>
  <p>{{description}}</p>
</script>
Compile the template:
var source = document.getElementById('item-template').innerHTML;
var template = Handlebars.compile(source);
And then specify the template in the Timeline options
var options = {
  template: template
};

Multiple templates

In order to support multiple templates, the template handler can be extended to switch between different templates, depending on a specific item property:
var templates = {
  template1: Handlebars.compile(...),
  template2: Handlebars.compile(...),
  template2: Handlebars.compile(...),
  ...
};

var options = {
  template: function (item) {
    var template = templates[item.template];  // choose the right template
    return template(item);                    // execute the template
  }
};
Now the items can be extended with a property template, specifying which template to use for the item.

Localization

Timeline can be localized. For localization, Timeline depends largely on the localization of moment.js. Locales are not included in vis.js by default. To enable localization, moment.js must be loaded with locales. Moment.js offers a bundle named "moment-with-locales.min.js" for this and there are various alternative ways to load locales.

To set a locale for the Timeline, specify the option locale:

var options = {
  locale: 'nl'
};

Create a new locale

To load a locale into the Timeline not supported by default, one can add a new locale to the option locales:
var options = {
  locales: {
    // create a new locale (text strings should be replaced with localized strings)
    mylocale: {
      current: 'current',
      time: 'time',
    }
  },

  // use the new locale
  locale: 'mylocale'
};

Available locales

Timeline comes with support for the following locales:

LanguageCode
English en
en_EN
en_US
Dutch nl
nl_NL
nl_BE

Styles

All parts of the Timeline have a class name and a default css style. The styles can be overwritten, which enables full customization of the layout of the Timeline.

For example, to change the border and background color of all items, include the following code inside the head of your html code or in a separate stylesheet.

<style>
  .vis.timeline .item {
    border-color: orange;
    background-color: yellow;
  }
</style>

Grid Backgrounds

The background grid of the time axis can be styled, for example to highlight weekends or to create grids with an alternating white/lightgray background.

Depending on the zoom level, the grids get certain css classes attached. The following classes are available:

Descriptionvalues
Alternating columnseven, odd
Current datetoday, tomorrow, yesterday, current-week, current-month, current-year
Hours0h, 1h, ..., 23h
Grouped hours0-4h to 20-24h
Weekdaymonday, tuesday, wednesday, thursday, friday, saturday, sunday
Daysdate1, date2, ..., date31
Monthsjanuari, februari, march, april, may, june, july, august, september, october, november, december
Yearsyear2014, year2015, ...

Examples:

<style>
  /* alternating column backgrounds */
  .vis.timeline .timeaxis .grid.odd {
    background: #f5f5f5;
  }

  /* gray background in weekends, white text color */
  .vis.timeline .timeaxis .grid.saturday,
  .vis.timeline .timeaxis .grid.sunday {
    background: gray;
  }
  .vis.timeline .timeaxis .text.saturday,
  .vis.timeline .timeaxis .text.sunday {
    color: white;
  }
</style>

Data Policy

All code and data is processed and rendered in the browser. No data is sent to any server.