Timeline
The Timeline is an interactive visualization chart to visualize the data in timeline.
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.
The timeline can be provided with two types of data:
Items - containing a set of items to be displayed in time.
Groups - containing a set of groups used to group items together.
To use the Timeline component, refer to the following steps:
On the Widget, navigate to List > Timeline/Gantt and drag Timeline to the UI.
Write one JavaScript to get the timeline data (this JavaScript contains
groupsanditems) and drag it to the model of the Widget.Sample code:
varresult = {groups: [],items: [],};varnum = 0;vartypes = ["item","background","point"];varclasses = ["bg-red text-white","bg-blue text-white","bg-green text-white","bg-grey text-white",];for(g = 0; g < 5; g++) {vargroup = {id:"G-"+ g,name:"Group "+ g,groupClass:"bg-transparent text-black",};result.groups.push(group);for(i = 0; i < 5; i++) {num = num + 1;varnow = utils.getCurrentTimestamp().getTime() + 300000 * i * (Math.random() * 10);varitem = {id:"I-"+ g +"-"+ i,name:"Item "+ g +"-"+ i,start: now,end: now + 120000 + Math.random() * 600000,groupId: group.id,itemType: types[num % 3],itemClass: classes[num % 4],};result.items.push(item);}}result = utils.getMapFromJson(JSON.stringify(result));Right-click on Timeline to open the Property Panel and set the following properties:
Navigate to Properties > DataMapping:
DataLoader -
<JavaScript name>DataBean Path - any path value (for example,
timelinedata)Auto Load -
OnItems Data Path -
DataBean Path.items(for example,timelinedata.items)Item Id Field -
idItem Content Field -
nameItem StartField -
startItem End Field -
endItem Class Field -
itemClassItem Display Type -
itemTypeItem Group Id Field -
groupIdGroups Data Path -
DataBean Path.groups(for example,timelinedata.groups)Group Id Field -
idGroup Content Field -
nameGroup Class Field -
groupClass
Timeline can be customized using Vis.js Timeline API. Navigate to Properties > UI Properties > Timeline Options and set your custom script.
Sample script for reference:
{orientation:'both',maxHeight: 500,minHeight: 200,sowCurrentTime:false,getstart() {vartoday = newDate();varyear = today.getFullYear();varstartdate = newDate(year, 1, 1);returnutils.getDateString(startdate,'YYYY/MM/DD');},getend() {vartoday = newDate();varyear = today.getFullYear();varenddate = newDate(year + 1, 12, 31);returnutils.getDateString(enddate,'YYYY/MM/DD');}}API Link for reference: https://visjs.github.io/vis-timeline/docs/timeline/#Configuration_Options