Easy Horizontal Timeline Generator With jQuery - Timeline.js

Easy Horizontal Timeline Generator With jQuery - Timeline.js
File Size: 2.73 MB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Timeline.js is a jQuery timeline generator which helps you render horizontal, scrolling, responsive bar & point/line style timelines (with event details) from dynamic data arrays/objects.

See also:

How to use it:

1. To use this plugin, you need to load the following JavaScript and CSS files into the document.

<link rel="stylesheet" href="dist/timeline.min.css">
<script src="//code.jquery.com/jquery.min.js"></script>
<script src="dist/timeline.min.js"></script>

2. Add your own events to the timeline using the data-timeline-node attribute and insert the event group into a normal html list as these:

<div id="myTimeline">
  <ul class="timeline-events">
    <li data-timeline-node="{ start:'2017-05-28 10:00',end:'2017-05-28 13:00',content:'Event Here' }">Event Label</li>
    <li data-timeline-node="{ start:'2017-05-29 23:10',end:'2017-05-29 1:30',content:'<p>Event Here</p>' }">Event Label</li>
  </ul>
</div>

3. Create an empty container to display the event details:

<div class="timeline-event-view"></div>

4. Initialize the plugin to generate a default timeline from the html list.

$("#myTimeline").timeline({
  // options here
});

5. To customize the timeline, just pass the following options as an object to the timeline() method on init.

$("#myTimeline").timeline({

  // "bar" or "point"
  type            : "bar",

  // "years" or "months" or "days"
  scale           : "days", 

  // start date time
  startDatetime   : "currently",

  // end date time
  endDatetime     : "auto",

  // displays headline
  headline        : {
    display     : true,
    title       : "",
    range       : true,
    locale      : "en-US",
    format      : { hour12: false }
  }, 

  // displays sidebar
  sidebar         : {
    sticky      : false,
    overlay     : false,
    list        : [], //  an array of items
  },

  // displays ruler
  ruler           : {
    top         : {
      lines      : [],
      height     : 30,
      fontSize   : 14,
      color      : "#777777",
      background : "#FFFFFF",
      locale     : "en-US",
      format     : { hour12: false }
    },
  },

  // displays footer
  footer          : {
    display     : true,
    content     : "",
    range       : false,
    locale      : "en-US",
    format      : { hour12: false }
  },

  // displays event meta
  eventMeta       : {
    display     : false,
    scale       : "day",
    locale      : "en-US",
    format      : { hour12: false },
    content     : ""
  },

  // enables/disables effects
  effects         : {
    presentTime : true,
    hoverEvent  : true,
  },

  // default view range
  range           : 3, 

  // numer of timeline rows
  rows            : 5, 

  // height of row
  rowHeight       : 40, 

  // width of timeline
  width           : "auto",

  // height of timeline
  height          : "auto",

  // min size of grid
  minGridSize     : 30, 

  // margin size
  marginHeight    : 2,

  // "left", "center", "right", "current", "latest" or specific event id
  rangeAlign      : "latest",

  // "default", false and selector
  loader          : "default",

  // hides scrollbar
  hideScrollbar   : false,

  // "session" or "local"
  storage         : "session",

  // loads cached events during reloading
  reloadCacheKeep : true,

  // zooms the scale of the timeline by double clicking
  zoom            : false,

  // wraps new scale in the timeline container when zooming
  wrapScale       : true,

  // "canvas" or "d3.js"
  engine          : "canvas",

  // debug mode
  debug           : false
  
});

6. API methods.

// show
$("#myTimeline").timeline('show');

// hide
$("#myTimeline").timeline('hide');

// destroy
$("#myTimeline").timeline('destroy');

// align the timeline
// position: "left" or "begin", "center", "right" or "end", "latest", "current" or "currently", Event ID
// duration: "fast", "normal", "slow" or milliseconds
$("#myTimeline").timeline('alignment', position, duration);

// add new events
$("#myTimeline").timeline('addEvent', eventdata, CALLBACK, userdata);

// remove events
$("#myTimeline").timeline('removeEvent', condition, CALLBACK, userdata);

// update events
$("#myTimeline").timeline('updateEvent', eventdata, CALLBACK, userdata);

// update events
$("#myTimeline").timeline('updateEvent', eventdata, CALLBACK, userdata);

// reload the timeline
$("#myTimeline").timeline('reload', options, CALLBACK, userdata);

// show the loader
$('#myTimeline').Timeline('showLoader');

7. Events.

$("#myTimeline").timeline({
  // options here
});

Changelog:

v2.0.0b1 (2019-05-22)

  • Added tasks into gulp for deploying on production.
  • Added new methods named "dateback" and "dateforth".
  • Added new option named "effects" for timeline UI enhancement.
  • Fixed a bug that does not remove specific events on "removeEvent" method.
  • Fixed a bug that the vertical position of the relation line deviates in multiple rows of containers.
  • Fixed a bug that method chain did not work due to asynchronous initialization.

2018-12-12

  • Fixed a bug that does not open event detail when clicked event on the timeline.

2017-09-20

  • Added handling event of "afterRender".

2017-06-12

  • Updated algorithm of httpLanguage option

2017-06-11

  • Added feature that multilingualization support

2017-06-08

  • Adjusted that the display position of events on the point type timeline

This awesome jQuery plugin is developed by ka215. For more Advanced Usages, please check the demo page or visit the official website.