How To Create Gantt Chart

Posted By : Sagar Watts | 27-Nov-2017

We can represent the project schedule using the Gantt chart. To draw Gantt chart we can use a simple plugin jsGantt. It is a basic plugin which provides us most of the features which are required for gantt chart. Here is the list of some feature that are provided by the plugin : -

 

  1. Show multiple Dependencies.

  2. Show task completion percentage.

  3. Different colors for Different Tasks.

  4. Create task groups.

  5. Different time duration for tasks.

 

To create a gantt chart , we need to  follow these steps :

 

  1. Include the required JS and CSS in page.

         jsgantt.js
         path/jsgantt.css

         These are the two important files which needs to be included in your page to draw the chart effectively. 

 

     2.    Create a div for gantt chart.     


 
 

      

     3.  Write script for Gantt chart. We need to create a script block for Gantt Chart.The processing of data and chart creation will be done in script block, which will be rendered in above created div.

    4. The initiation of Gantt chart is done in script block we have created in 3rd step.

     GanttChart(pGanttVar, pDiv, pFormat)

pGanttVar: variable name.

pDiv: DIV in HTML

    pFormat: duration format for chart.

   All the three properties are required. Format could be "day", "week", "month", or "quarter".The complete code will look like this.

var chart = new JSGantt.GanttChart('chart ',document.getElementById(GanttChart), 'week');
    5.   Now that we have created an instance of gantt chart, we are left with add of task. We can add task using the following block of code.
chart .AddTaskItem(new JSGantt.TaskItem(pID, pName, pStart, pEnd, pColor, pLink, pMile, pRes, pComp, pGroup, pParent, pOpen, pDepend));

pID, pName, pStart, pEnd, pColor, pComp and pParent are the required properties and rest are the optional properties.  pStart and  pEnd is for date.

 

Thanks

 

About Author

Author Image
Sagar Watts

Sagar is a bright Web App Lead Developer , he has great knowledge of core Java and advance Java. His hobbies are Net Surfing, Listen Music and Reading Books.

Request for Proposal

Name is required

Comment is required

Sending message..