jsGantt - 1.2 |
Bugs/Issues Download License Usage Examples Credits |
1. Include JSGantt CSS and Javascript
<link rel="stylesheet" type="text/css" href="jsgantt.css" /> <script language="javascript" src="jsgantt.js"></script>
2. Create a div element to hold the gantt chart
<div style="position:relative" class="gantt" id="GanttChartDIV"></div>
3. Start a <script> block
<script language="javascript">
4. Instantiate JSGantt using GanttChart()
var g = new JSGantt.GanttChart('g',document.getElementById('GanttChartDIV'), 'day');
GanttChart(pGanttVar, pDiv, pFormat)
pGanttVar: (required) name of the variable assigned
pDiv: (required) this is a DIV object created in HTML
pFormat: (required) - used to indicate whether chart should be drawn in "day", "week", "month", or "quarter" format
Customize the look and feel using the following setters
g.setShowRes(1); // Show/Hide Responsible (0/1) g.setShowDur(1); // Show/Hide Duration (0/1) g.setShowComp(1); // Show/Hide % Complete(0/1) g.setCaptionType('Resource'); // Set to Show Caption (None,Caption,Resource,Duration,Complete) g.setShowStartDate(1); // Show/Hide Start Date(0/1) g.setShowEndDate(1); // Show/Hide End Date(0/1) g.setDateInputFormat('mm/dd/yyyy') // Set format of input dates ('mm/dd/yyyy', 'dd/mm/yyyy', 'yyyy-mm-dd') g.setDateDisplayFormat('mm/dd/yyyy') // Set format to display dates ('mm/dd/yyyy', 'dd/mm/yyyy', 'yyyy-mm-dd') g.setFormatArr("day","week","month","quarter") // Set format options (up to 4 : "minute","hour","day","week","month","quarter")
5. Add Tasks using AddTaskItem()
g.AddTaskItem(new JSGantt.TaskItem(1, 'Define Chart API', '', '', 'ff0000', 'http://help.com', 0, 'Brian', 0, 1, 0, 1)); g.AddTaskItem(new JSGantt.TaskItem(11, 'Chart Object', '2/10/2008', '2/10/2008', 'ff00ff', 'http://www.yahoo.com', 1, 'Shlomy', 100, 0, 1, 1, "121,122", "My Caption"));TaskItem(pID, pName, pStart, pEnd, pColor, pLink, pMile, pRes, pComp, pGroup, pParent, pOpen, pDepend)
5a. Another way to add tasks is to use an external XML file with parseXML()
JSGantt.parseXML("project.xml",g);The structure of the XML file:
6. Call Draw() and DrawDependencies()
g.Draw(); g.DrawDependencies();
7. Close the <script> block
</script>
Developed by Shlomy Gantz and Brian Twidt
Contributed: Paul Labuschagne, Kevin Badgett, Ilan Admon