API

Options

Options described here are the options for the controller constructor. Everything you need to customize your timeline happens here.

NameDescriptionTypeDefault
startThe date from which the timeline will start. If undefined it will take the minimum date from the input nodes/edgesnumber | Dateundefined
endThe date from which the timeline will end. If undefined it will take the maximum date from the input nodes/edgesnumber | Dateundefined
showBarchartWhether to show the barchart by default. Has no effect if switchOnZoom is true, as it will pick the most appropriate view depending on the number of elements.booleanfalse
switchOnZoomWhether the timeline should automatically switch between barchart and timeline mode during zoom in/out.booleantrue
nodeStartPathThe path to retrieve start dates from nodes data. Use dotted notation if it is nested.stringstart
nodeEndPathThe path to retrieve end dates from nodes data.stringend
edgeStartPathThe path to retrieve start dates from edges data.stringstart
edgeEndPathThe path to retrieve end dates from edges data.stringend
timebarsThe "blue bars", shown on the timeline. They are used for filtering. See Timebar.Timebar[]
edgeFilterOptions for edge filtering. See FitlerOptionsFitlerOptions
nodeFilterOptions for node filtering. See FitlerOptionsFitlerOptions
barchartOptions for barchart. See barchartOptions.BarchartOptions
timelineOptions for timeline. See timelineOptions.TimelineOptions

FilterOptions

NameDescriptionTypeDefault
enabledWhether the filter is enabled or not.booleantrue
strategyWhich strategy to apply for filtering. See Filtering for further details. Possible values are before, after, between, outsidestringundefined
toleranceWhich tolerance to apply for filtering. See Filtering for further details. Possible values are strict, loosestringloose

Timebar

Timebars can be an object: { fixed?: boolean; date: Date } a number or a Date. If you specify a number or a date, the timebar will not be fixed.

NameDescriptionTypeDefault
fixedWhheter or not the timebar remains at the same position on screen while dragging the timeline.booleanfalse
dateThe date of the timebarstringundefined

TimelineOptions

NameDescriptionTypeDefault
nodeGroupIdFunctionSimilar to Ogma groupsopen in new window, pass a function that takes a node as an argument and returns a string representing in which group the node belongs.(node: Node) => stringnode => nodes
nodeGroupContentA function that takes the groupId returned by groupIdFunction, the nodes in the group and returns the title to display for this group in the timeline.(groupId: string, nodes: NodeList) => stringgroupid => groupid
nodeItemGeneratorA function that takes a node and its groupid, which returns a DataItemopen in new window Object.(node: Node, groupId: string) => DataItemopen in new window
edgeGroupIdFunctionSimilar to Ogma groupsopen in new window , pass a function that takes an edge as an argument and returns a string representing in which group the edge belongs.(edge: Edge) => stringedge => edges
edgeGroupContentA function that takes the groupId returned by groupIdFunction, the nodes in the group and returns the title to display for this group in the timeline.groupid => groupidstart
edgeItemGeneratorA function that takes an edge and its groupid, which returns a DataItemopen in new window Object.(edge: Edge, groupId: string) => DataItemopen in new window
timelineOptionsOptions to pass to vis-js timeline. See Visjs Timeline Optionsopen in new windowTimelineOptionsopen in new window

BarchartOptions

NameDescriptionTypeDefault
nodeGroupIdFunctionSame as in TimelineOptions(nodes: Node) => stringnode => nodes
nodeGroupContentSame as in TimelineOptions(groupId: string, nodes: NodeList) => stringgroupid => groupid
nodeItemGeneratorA function that takes a nodeList and its groupid, which returns a Graph2dItemopen in new window Object.(nodes: NodeList, groupId: string) => Graph2dItemopen in new window
edgeGroupIdFunctionSame as in timelineOptions(edge: Edge) => stringedge => edges
edgeGroupContentSame as in timelineOptionsgroupid => groupid
edgeItemGeneratorA function that takes an edgeList and its groupid, which returns a Graph2dItemopen in new window Object.(edges: EdgeList, groupId: string) => Graph2dItemopen in new window
graph2dOptionsOptions to pass to vis-js barchart. See Visjs Graph2d Optionsopen in new windowGraph2dOptionsopen in new window

Events

The timeline plugin is an event emmitter, to hook to the events it fires, just type plugin.on(myevent, () => }{})

NameDescriptionType
timechangeEvent triggered when a timebar has changed position. When user drags a timebar for instance.void
selectEvent triggered when selection in the barchart/timeline changes. This event contains the nodes/edges that are related to the selection in the timeline.{nodes?: NodeList, edges?: EdgeList, evt: MouseEvent}

Methods

NamesetDescriptionArgumentsReturns
constructorCreates a new timeline plugin.OptionsController
showTimelineDisplays the timeline instead of the barchart.voidvoid
showBarchartDisplays the barchart instead of the timeline.voidvoid
addTimeBarAdd a timebar to the timeline.timebarOptionsvoid
removeTimeBarRemove a timebar from the timeline at index i.numbervoid
getTimebarsGet all the timebars from the timeline.groupid => groupidvoid
setTimebarsSet timebars for the timeline.timebarOptions[]void
setWindowSet the start and end dates of the timeline. See setWindowopen in new window on visjs.start:number, end: number, optionsvoid
getWindowGet the start and end dates of the timeline.string{start: number; end: number}
setOptionsSet the options for the timeline.Optionsvoid