Easy Horizontal Timeline Generator With jQuery - Timeline.js

Easy Horizontal Timeline Generator With jQuery - Timeline.js
File Size: 517 KB
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.

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 datatime
  startDatetime   : "currently",

  // prefix of the date and time
  datetimePrefix  : "", 

  // displays headline
  showHeadline    : true, 

  // custom datetime format
  datetimeFormat  : {
    full          : "j M Y", // or "Y/m/d" etc.
    year          : "Y",
    month         : "M Y", // or "F" etc.
    day           : "D, j M", // or "j" etc.
    years         : "Y", 
    months        : "F", 
    days          : "j",
    meta          : "Y/m/d H:i", // start datetime in meta of Event Detail; or "g:i A, D F j, Y"
    metato        : "" // end datetime in meta of Event Detail; default is same to meta
  },

  // "0099" if true
  // "99" if false
  zerofillYear    : false, 

  // default view range
  range           : 3, 

  // numer of timeline rows
  rows            : 5, 

  // height of row
  rowHeight       : 40, 

  // height of timeline
  height          : "auto",

  // min grid
  minGridPer      : 2,

  // min size of grid
  minGridSize     : 30, 

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

  // for nav icons
  naviIcon        : { 
    left          : "jqtl-circle-left",
    right         : "jqtl-circle-right"
  },

  // displays points
  showPointer     : true,

  // i18n
  i18n            : {
    month         : { 'Jan': 'January', 'Feb': 'February', 'Mar': 'March', 'Apr': 'April', 'May': 'May', 'Jun': 'June', 'Jul': 'July', 'Aug': 'August', 'Sep': 'September', 'Oct': 'October', 'Nov': 'November', 'Dec': 'December' },
    day           : { 'Sun': 'Sunday', 'Mon': 'Monday', 'Tue': 'Tuesday', 'Wed': 'Wednesday', 'Thu': 'Thurseday', 'Fri': 'Friday', 'Sat': 'Saturday' },
    ma            : [ 'am', 'pm' ]
  },

  langsDir        : "./langs/",
  httpLnaguage    : false
  
});

6. API methods.

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

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

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

// back to the past
$("#myTimeline").timeline('dateback');

// go forth the future
$("#myTimeline").timeline('dateforth');

// align the timeline
$("#myTimeline").timeline('alignment', 'left');

// get all option values
$("#myTimeline").timeline('getoptions');

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

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

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

7. Events.

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

Change log:

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.