jsGantt Improved
Description: FREE javascript gantt - jsGantt Improved HTML, CSS and AJAX only
Keywords: jsgantt-improved free javascript gantt-chart html css ajax

# jsGanttImproved

## latest v1.7.5.4

Download View on GitHub

100% HTML + CSS + JavaScript Gantt Chart

Completely FREE

Open source

# Demo

Embedded Code External XML File

# Features

jsGanttImproved is a fully featured gantt chart component built entirely in Javascript, CSS and AJAX. It is lightweight and there is no need of external libraries or additional images.

## Basic Features

- Tasks & Collapsible Task Groups
- Multiple Dependencies
- Task Completion
- Task Style
- Milestones
- Resources

## Advanced Features

- Dynamic Loading of Tasks
- Dynamic change of format: Hour, Day, Week, Month, Quarter
- Load Gantt from:
  - External XML files (including experimental support for Microsoft Project XML files)
  - JavaScript strings
- Export Gantt as XML string
- Support for internationalization

## Current Known Issues:

- If the browser is viewing the page at anything other than 100% zoom then bars may not be sized or positioned correctly.

## Changelog:

Check the full list of changes on GitHub releases page.

### v1.7.5.4:

- Left part of the chart is now created first on JavaScript and establishes the left floating reference
- Minimum width updated to 632px so that the left part of the chart has a fixed width of 532px and the right part fills out the rest with a minimum of 100px

### v1.7.5.3:

- Fixed group completion percentage that now is a weighted average
- Start and end dates specified on standard group tasks will now be respected if they fall outside of the calculated group date range
- Fixed problem that would occur if Tool Tips were disabled
- Moved example dates forward so the current date marker is visible

### v1.7.5:

- Project Migrated to GitHub
- Instantiating a new JSGantt.TaskItem will now also accept Date objects for start and end dates
- Fixed old Internet Explorer compatibilty broken by v1.7
- Fixed bug in Iso week date format
- Changed to solid arrows on dependency lines to be more printer friendly
- Code refactoring and clean up

### v1.7:

- Fixed nasty long-standing bug where the first Gantt chart created must be stored in a javascript variable named "g"
  - NOTE: This required a change in the method to instatiate a JSGantt.TaskItem object to pass the related chart.
  - A temporary fix is included that still assumes the use of "g" for the chart if the chart object is not passed, this will be removed in v1.8
- Altered XML export functionality so that dates are output in the specified input format for the chart
- Added method to read XML directly from an input string
- Prevented creation of a task with a duplicate "unique" ID
- Fixed bug where attempting to remove the first task defined would prevent the chart from redrawing
- Some general code clean up

# Usage

Following the steps below you will be able to get create a basic Gantt Chart. If you notice any bugs, please post them to GitHub issues.

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 type="text/javascript">

4. Instantiate JSGantt using GanttChart()

       var g = new JSGantt.GanttChart(document.getElementById('GanttChartDIV'), 'day');

   Method definition: GanttChart(pDiv, pFormat)

   pDiv: | (required) this is a DIV object created in HTML
   pFormat: | (required) - used to indicate whether chart should be drawn in "hour", "day", "week", "month", or "quarter" format

5. Customize the look and feel using configuration methods (see Configuration Options)

6. Add Tasks
   - using AddTaskItem()

         g.AddTaskItem(new JSGantt.TaskItem(1, 'Define Chart API','',          '',          'ggroupblack','', 0, 'Brian', 0,  1,0,1,'','','Some Notes text',g));
         g.AddTaskItem(new JSGantt.TaskItem(11,'Chart Object',    '2016-02-20','2016-02-20','gmilestone', '', 1, 'Shlomy',100,0,1,1,'','','',g));

     Method definition: TaskItem(pID, pName, pStart, pEnd, pColor, pLink, pMile, pRes, pComp, pGroup, pParent, pOpen, pDepend, pCaption, pNotes, pGantt)

     pID: | (required) a unique numeric ID used to identify each row
     pName: | (required) the task Label
     pStart: | (required) the task start date, can enter empty date ('') for groups. You can also enter specific time (2016-02-20 12:00) for additional precision.
     pEnd: | (required) the task end date, can enter empty date ('') for groups
     pClass: | (required) the css class for this task
     pLink: | (optional) any http link to be displayed in tool tip as the "More information" link.
     pMile: | (optional) indicates whether this is a milestone task - Numeric; 1 = milestone, 0 = not milestone
     pRes: | (optional) resource name
     pComp: | (required) completion percent, numeric
     pGroup: | (optional) indicates whether this is a group task (parent) - Numeric; 0 = normal task, 1 = standard group task, 2 = combined group task*
     pParent: | (required) identifies a parent pID, this causes this task to be a child of identified task. Numeric, top level tasks should have pParent set to 0
     pOpen: | (required) indicates whether a standard group task is open when chart is first drawn. Value must be set for all items but is only used by standard group tasks. Numeric, 1 = open, 0 = closed
     pDepend: | (optional) comma separated list of id's this task is dependent on. A line will be drawn from each listed task to this item Each id can optionally be followed by a dependency type suffix. Valid values are: 'FS' - Finish to Start (default if suffix is omitted) 'SF' - Start to Finish 'SS' - Start to Start 'FF' - Finish to Finish If present the suffix must be added directly to the id e.g. '123SS'
     pCaption: | (optional) caption that will be added after task bar if CaptionType set to "Caption"
     pNotes: | (optional) Detailed task information that will be displayed in tool tip for this task
     pGantt: | (required) javascript JSGantt.GanttChart object from which to take settings. Defaults to "g" for backwards compatibility

     * Combined group tasks show all sub-tasks on one row. The information displayed in the task list and row caption are taken from the parent task. Tool tips are generated individually for each sub-task from its own information. Milestones are not valid as sub-tasks of a combined group task and will not be displayed. No bounds checking of start and end dates of sub-tasks is performed therefore it is possible for these task bars to overlap. Dependencies can be set to and from sub-tasks only.

   - using parseXML() with an external XML file

         JSGantt.parseXML("project.xml",g);

     Method definition: JSGantt.parseXML(pFile, pGanttObj)

     pFile: | (required) this is the filename of the XML
     pGanttObj: | (required) a GanttChart object returned by a call to JSGantt.GanttChart()

     The structure of the native XML file:

         <project>
           <task>
             <pID>25</pID>
             <pName>WCF Changes</pName>
             <pStart></pStart>
             <pEnd></pEnd>
             <pClass>gtaskred</pClass>
             <pLink></pLink>
             <pMile>0</pMile>
             <pRes></pRes>
             <pComp>0</pComp>
             <pGroup>1</pGroup>
             <pParent>2</pParent>
             <pOpen>1</pOpen>
             <pDepend>2,24</pDepend>
             <pCaption>A caption</pCaption>
             <pNotes>Text - can include limited HTML</pNotes>
           </task>
         </project>

     Field definitions are as described for the parameters to TaskItem above. The pClass element is optional in XML files and will default to "ggroupblack" for group tasks, "gtaskblue" for normal tasks and "gmilestone" for milestones. The pGantt element is not required for XML import.

     JSGannt Improved will also test the provided XML file to see if it appears to be in Microsoft Project XML format. If so an attempt will be made to load up the project. This feature is experimental, the import is best effort and not guaranteed. Once loaded the project as interpreted by JSGantt Improved can be extracted using the XML Export methods provided.

   - using parseXMLString() with XML held in a javascript string object

         JSGantt.parseXMLString("<project><task>...</task></project>",g);

     Method definition: JSGantt.parseXMLString(pStr, pGanttObj)

     pStr: | (required) this is a javascript String containing XML
     pGanttObj: | (required) a GanttChart object returned by a call to JSGantt.GanttChart()

     The XML provided will be parsed in exactly the same way as the contents of an external XML file and hence must match the format as described for JSGantt.parseXML() above

7. Call Draw()

       g.Draw();

8. Close the <script> block

       </script>

It is possible to add items to the chart in realtime via javascript using either direct method calls or additional XML files. It is also possible to delete tasks using RemoveTaskItem() method.

    g.RemoveTaskItem(11);

Method definition: RemoveTaskItem(pID)

pID: | (required) the unique numeric ID of the item to be removed

If the task removed is a group item, all child tasks will also be removed.

After adding or removing tasks a call to "g.Draw()" must be made to redraw the chart.

## Configuration Options

### Switches

Many of the features of jsGanttImproved can be customised through the use of setter methods available on the GanttChart object returned by a call to JSGantt.GanttChart()

The following options take a single numeric parameter; a value of 1 will enable the describe functionality, 0 will disable it

setUseToolTip(): | Controls the display of tool tip boxes, defaults to 1 (enabled)
setUseFade(): | Controls use of the fade effect when showing/hiding tool tips, defaults to 1 (enabled)
setUseMove(): | Controls use of the sliding effect when changing between different task tool tips, defaults to 1 (enabled)
setUseRowHlt(): | Controls the use of row mouseover highlighting, defaults to 1 (enabled)
setUseSort(): | Controls whether the task list is sorted into parent task / start time order or is simply displayed in the order created, defaults to 1 (sort enabled)
setShowRes(): | Controls whether the Resource column is displayed in the task list, defaults to 1 (show column)
setShowDur(): | Controls whether the Task Duration column is displayed in the task list, defaults to 1 (show column)
setShowComp(): | Controls whether the Percentage Complete column is displayed in the task list, defaults to 1 (show column)
setShowStartDate(): | Controls whether the Task Start Date column is displayed in the task list, defaults to 1 (show column)
setShowEndDate(): | Controls whether the Task End Date column is displayed in the task list, defaults to 1 (show column)
setShowTaskInfoRes(): | Controls whether the Resource information is displayed in the task tool tip, defaults to 1 (show information)
setShowTaskInfoDur(): | Controls whether the Task Duration information is displayed in the task tool tip, defaults to 1 (show information)
setShowTaskInfoComp(): | Controls whether the Percentage Complete information is displayed in the task tool tip, defaults to 1 (show information)
setShowTaskInfoStartDate(): | Controls whether the Task Start Date information is displayed in the task tool tip, defaults to 1 (show information)
setShowTaskInfoEndDate(): | Controls whether the Task End Date information is displayed in the task tool tip, defaults to 1 (show information)
setShowTaskInfoLink(): | Controls whether the More Information link is displayed in the task tool tip, defaults to 0 (do NOT show link)
setShowTaskInfoNotes(): | Controls whether the Additional Notes data is displayed in the task tool tip, defaults to 1 (show notes)
setShowEndWeekDate(): | Controls whether the major heading in "Day" view displays the week end-date in the appropriate format (see below), defaults to 1 (show date)
setShowDeps(): | Controls display of dependancy lines, defaults to 1 (show dependencies)

### Key Values

The following options enable functionality using a set of specific key values

setShowSelector(): | Controls where the format selector is displayed, accepts multiple parameters. Valid parameter values are "Top", "Bottom". Defaults to "Top".
setFormatArr(): | Controls which format options are shown in the format selector, accepts multiple parameters. Valid parameter values are "Hour", "Day", "Week", "Month", "Quarter". Defaults to all valid values.
setCaptionType(): | Controls which task field to use as a caption on the Gantt Chart task bar, accepts a single parameter. Valid parameter values are "None", "Caption", "Resource", "Duration", "Complete". Defaults to "None"
setDateInputFormat(): | Defines the input format used for dates in task creation, accepts a single parameter. Valid parameter values are "yyyy-mm-dd", "dd/mm/yyyy", "mm/dd/yyyy". Defaults to "yyyy-mm-dd"
setScrollTo(): | Sets the date the Gantt Chart will be scrolled to, specified in the date input format set by setDateInputFormat() above. Also accepts the special value "today" Defaults to minimum display date
setUseSingleCell(): | Sets the threshold total number of cells at which the task list will use a single table cell for each row rather than one cell per period. Useful to improve performance on large charts. A value of 0 disables this functionality (always use multiple cells), defaults to 25000
setLang(): | Sets translation to use when drawing the chart. Defaults to "en" as this is the only language provided in the base installation (see internationalization below for details on how to add more translations.)

### Layout

Most of the look and feel of the Gantt Chart can be controlled using CSS however, as the length of a task bar is determined by column width, the following methods take a single numeric parameter that defines the appropriate column width in pixels.

Note that the task bar sizing code assumes the use of collapsed table borders 1px wide.

setHourColWidth(): | Width of Gantt Chart columns in pixels when drawn in "Hour" format. Defaults to 18.
setDayColWidth(): | Width of Gantt Chart columns in pixels when drawn in "Day" format. Defaults to 18.
setWeekColWidth(): | Width of Gantt Chart columns in pixels when drawn in "Week" format. Defaults to 36.
setMonthColWidth(): | Width of Gantt Chart columns in pixels when drawn in "Month" format. Defaults to 36.
setQuarterColWidth(): | Width of Gantt Chart columns in pixels when drawn in "Quarter" format, although not mandatory it is recommended that this be set to a value divisible by 3. Defaults to 18.
setRowHeight(): | Height of Gantt Chart rows in pixels. Used to route dependency lines near end points. Defaults to 20.
setMinGpLen(): | Group tasks have their task bars embellished with end points, this value specifies the width of one of these end points in pixels. A short task bar's length will be rounded up to display either a single or both endpoints correctly. Defaults to 8.

### Display Date Formats

Date display formats can be individually controlled. The methods used to set these display formats each take a single format string parameter. The format string can be made up of the following components (case sensitive)

> h: | Hour (1-12)
> hh: | Hour (01-12)
> pm: | am/pm indicator
> PM: | AM/PM indicator
> H: | Hour (0-23)
> HH: | Hour (01-23)
> mi: | Minutes (1-59)
> MI: | Minutes (01-59)
> d: | Day (1-31)
> dd: | Day (01-31)
> day: | Abbreviated day of week
> DAY: | Day of week
> m: | Month (1-12)
> mm: | Month (01-12)
> mon: | Abbreviated month text
> month: | Full month text
> yy: | Year, excluding century
> yyyy: | Year
> q: | Quarter (1-4)
> qq: | Quarter (Q1-Q4)
> w: | ISO Week number (1-53)
> ww: | ISO Week number (01-53)
> week: | Full ISO Week date format

> separated by one of the following characters: "/\-.,'<space>:

> Any text between separators that does not match one of the components above will be checked using a case insensitive match for a valid internationalized string (see internationalization below). If the value is still not found the text will be output unchanged.

The available date display methods are

setDateTaskTableDisplayFormat(): | Date format used for start and end dates in the main task list. Defaults to 'dd/mm/yyyy'.
setDateTaskDisplayFormat(): | Date format used for start and end dates in task tool tips. Defaults to 'dd month yyyy'.
setHourMajorDateDisplayFormat(): | Date format used for Gantt Chart major date headings displayed in "Hour" format. Defaults to 'day dd month yyyy'.
setDayMajorDateDisplayFormat(): | Date format used for Gantt Chart major date headings displayed in "Day" format. Defaults to 'dd/mm/yyyy'.
setWeekMajorDateDisplayFormat(): | Date format used for Gantt Chart major date headings displayed in "Week" format. Defaults to 'yyyy'.
setMonthMajorDateDisplayFormat(): | Date format used for Gantt Chart major date headings displayed in "Month" format. Defaults to 'yyyy'.
setQuarterMajorDateDisplayFormat(): | Date format used for Gantt Chart major date headings displayed in "Year" format. Defaults to 'yyyy'.
setHourMinorDateDisplayFormat(): | Date format used for Gantt Chart minor date headings displayed in "Hour" format. Defaults to 'HH'.
setDayMinorDateDisplayFormat(): | Date format used for Gantt Chart minor date headings displayed in "Day" format. Defaults to 'dd'.
setWeekMinjorDateDisplayFormat(): | Date format used for Gantt Chart minor date headings displayed in "Week" format. Defaults to 'dd/mm'.
setMonthMinorDateDisplayFormat(): | Date format used for Gantt Chart minor date headings displayed in "Month" format. Defaults to 'mon'.
setQuarterMinorDateDisplayFormat(): | Date format used for Gantt Chart minor date headings displayed in "Year" format. Defaults to 'qq'.

### Internationalization

jsGanttImproved only provides English text however all hard coded strings can be replaced by calling the addLang() method available on the GanttChart object returned by a call to JSGantt.GanttChart()

The addLang() method takes two parameters. The first is a string identifier for the language, the second is a javascript object containing all the replacement text pairs, the default English settings are:

> january: | January
> february: | February
> march: | March
> april: | April
> maylong: | May
> june: | June
> july: | July
> august: | August
> september: | September
> october: | October
> november: | November
> december: | December
> jan: | Jan
> feb: | Feb
> mar: | Mar
> apr: | Apr
> may: | May
> jun: | Jun
> jul: | Jul
> aug: | Aug
> sep: | Sep
> oct: | Oct
> nov: | Nov
> dec: | Dec
> sunday: | Sunday
> monday: | Monday
> tuesday: | Tuesday
> wednesday: | Wednesday
> thursday: | Thursday
> friday: | Friday
> saturday: | Saturday
> sun: | Sun
> mon: | Mon
> tue: | Tue
> wed: | Wed
> thu: | Thu
> fri: | Fri
> sat: | Sat
> resource: | Resource
> duration: | Duration
> comp: | % Comp.
> completion: | Completion
> startdate: | Start Date
> enddate: | End Date
> moreinfo: | More Information
> notes: | Notes
> format: | Format
> hour: | Hour
> day: | Day
> week: | Week
> month: | Month
> quarter: | Quarter
> hours: | Hours
> days: | Days
> weeks: | Weeks
> months: | Months
> quarters: | Quarters
> hr: | Hr
> dy: | Day
> wk: | Wk
> mth: | Mth
> qtr: | Qtr
> hrs: | Hrs
> dys: | Days
> wks: | Wks
> mths: | Mths
> qtrs: | Qtrs

When adding a language any translations that are not provided will use the default English language value. This provides a simple way to override default strings e.g.

    g.addLang('en2', {'format':'Select', 'comp':'Complete'});

would create a language called 'en2' where the text in the format selector was "Select" rather than "Format" and the header for the Percentage Complete column in the task list is "Complete" rather than "% Comp."

Once a translation has been added a call must be made to setLang() with the appropriate langage identifier before calling Draw().

### Example Options

The configuration options used in the example chart above are:

    g.setCaptionType('Complete');  // Set to Show Caption (None,Caption,Resource,Duration,Complete)
    g.setQuarterColWidth(36);
    g.setDateTaskDisplayFormat('day dd month yyyy'); // Shown in tool tip box
    g.setDayMajorDateDisplayFormat('mon yyyy - Week ww'); // Set format to display dates in the "Major" header of the "Day" view
    g.setWeekMinorDateDisplayFormat('dd mon'); // Set format to display dates in the "Minor" header of the "Week" view
    g.setShowTaskInfoLink(1); //Show link in tool tip (0/1)
    g.setShowEndWeekDate(0); // Show/Hide the date for the last day of the week in header for daily view (1/0)
    g.setUseSingleCell(10000); // Set the threshold at which we will only use one cell per table row (0 disables).  Helps with rendering performance for large charts.
    g.setFormatArr('Day', 'Week', 'Month', 'Quarter'); // Even with setUseSingleCell using Hour format on such a large chart can cause issues in some browsers

Putting all this information together the final code to produce the chart above is as follows:

    <link rel="stylesheet" type="text/css" href="jsgantt.css" />
    <script language="javascript" src="jsgantt.js"></script>
    <div style="position:relative" class="gantt" id="GanttChartDIV"></div>
    <script>

    var g = new JSGantt.GanttChart('g',document.getElementById('GanttChartDIV'), 'day');

    if( g.getDivId() != null ) {
    g.setCaptionType('Complete');
    g.setQuarterColWidth(36);
    g.setDateTaskDisplayFormat('day dd month yyyy');
    g.setDayMajorDateDisplayFormat('mon yyyy - Week ww');
    g.setWeekMinorDateDisplayFormat('dd mon');
    g.setShowTaskInfoLink(1);
    g.setShowEndWeekDate(0);
    g.setUseSingleCell(10000);
    g.setFormatArr('Day', 'Week', 'Month', 'Quarter');

    g.AddTaskItem(new JSGantt.TaskItem(1,   'Define Chart API',     '',           '',          'ggroupblack',  '',       0, 'Brian',    0,   1, 0,  1, '',      '',      'Some Notes text', g ));
    g.AddTaskItem(new JSGantt.TaskItem(11,  'Chart Object',         '2016-02-20','2016-02-20', 'gmilestone',   '',       1, 'Shlomy',   100, 0, 1,  1, '',      '',      '',      g));
    g.AddTaskItem(new JSGantt.TaskItem(12,  'Task Objects',         '',           '',          'ggroupblack',  '',       0, 'Shlomy',   40,  1, 1,  1, '',      '',      '',      g));
    g.AddTaskItem(new JSGantt.TaskItem(121, 'Constructor Proc',     '2016-02-21','2016-03-09', 'gtaskblue',    '',       0, 'Brian T.', 60,  0, 12, 1, '',      '',      '',      g));
    g.AddTaskItem(new JSGantt.TaskItem(122, 'Task Variables',       '2016-03-06','2016-03-11', 'gtaskred',     '',       0, 'Brian',    60,  0, 12, 1, 121,     '',      '',      g));
    g.AddTaskItem(new JSGantt.TaskItem(123, 'Task by Minute/Hour',  '2016-03-09','2016-03-14 12:00', 'gtaskyellow', '',  0, 'Ilan',     60,  0, 12, 1, '',      '',      '',      g));
    g.AddTaskItem(new JSGantt.TaskItem(124, 'Task Functions',       '2016-03-09','2016-03-29', 'gtaskred',     '',       0, 'Anyone',   60,  0, 12, 1, '123SS', 'This is a caption', null, g));
    g.AddTaskItem(new JSGantt.TaskItem(2,   'Create HTML Shell',    '2016-03-24','2016-03-24', 'gtaskyellow',  '',       0, 'Brian',    20,  0, 0,  1, 122,     '',      '',      g));
    g.AddTaskItem(new JSGantt.TaskItem(3,   'Code Javascript',      '',           '',          'ggroupblack',  '',       0, 'Brian',    0,   1, 0,  1, '',      '',      '',      g));
    g.AddTaskItem(new JSGantt.TaskItem(31,  'Define Variables',     '2016-02-25','2016-03-17', 'gtaskpurple',  '',       0, 'Brian',    30,  0, 3,  1, '',      'Caption 1','',   g));
    g.AddTaskItem(new JSGantt.TaskItem(32,  'Calculate Chart Size', '2016-03-15','2016-03-24', 'gtaskgreen',   '',       0, 'Shlomy',   40,  0, 3,  1, '',      '',      '',      g));
    g.AddTaskItem(new JSGantt.TaskItem(33,  'Draw Task Items',      '',           '',          'ggroupblack',  '',       0, 'Someone',  40,  2, 3,  1, '',      '',      '',      g));
    g.AddTaskItem(new JSGantt.TaskItem(332, 'Task Label Table',     '2016-03-06','2016-03-09', 'gtaskblue',    '',       0, 'Brian',    60,  0, 33, 1, '',      '',      '',      g));
    g.AddTaskItem(new JSGantt.TaskItem(333, 'Task Scrolling Grid',  '2016-03-11','2016-03-20', 'gtaskblue',    '',       0, 'Brian',    0,   0, 33, 1, '332',   '',      '',      g));
    g.AddTaskItem(new JSGantt.TaskItem(34,  'Draw Task Bars',       '',           '',          'ggroupblack',  '',       0, 'Anybody',  60,  1, 3,  0, '',      '',      '',      g));
    g.AddTaskItem(new JSGantt.TaskItem(341, 'Loop each Task',       '2016-03-26','2016-04-11', 'gtaskred',     '',       0, 'Brian',    60,  0, 34, 1, '',      '',      '',      g));
    g.AddTaskItem(new JSGantt.TaskItem(342, 'Calculate Start/Stop', '2016-04-12','2016-05-18', 'gtaskpink',    '',       0, 'Brian',    60,  0, 34, 1, '',      '',      '',      g));
    g.AddTaskItem(new JSGantt.TaskItem(343, 'Draw Task Div',        '2016-05-13','2016-05-17', 'gtaskred',     '',       0, 'Brian',    60,  0, 34, 1, '',      '',      '',      g));
    g.AddTaskItem(new JSGantt.TaskItem(344, 'Draw Completion Div',  '2016-05-17','2016-06-04', 'gtaskred',     '',       0, 'Brian',    60,  0, 34, 1, "342,343",'',     '',      g));
    g.AddTaskItem(new JSGantt.TaskItem(35,  'Make Updates',         '2016-07-17','2017-09-04', 'gtaskpurple',  '',       0, 'Brian',    30,  0, 3,  1, '333',   '',      '',      g));

    g.Draw();
    }
    else
    {
    alert("Error, unable to create Gantt Chart");
    }

    </script>

## XML Export

The following methods can be used to extract details of tasks in the project in XML format

Method definition: getXMLProject()

Returns a string containing the entire project in JSGantt Improved XML format. Dates will be exported in the currently defined input format as set by setDateInputFormat()

Method definition: getXMLTask(pID, pIdx)

pID: | (required) the numeric ID that identifies the task to extract
pIdx: | (optional) Boolean - if present and set to "true" the number passed in the pID parameter is treated as an array index for the task list rather than an ID

Returns a string containing the specified task item in JSGantt Improved XML format. Dates will be exported in the currently defined input format as set by setDateInputFormat()

# Credits

#### Eduardo Rodrigues

Developer

#### Ricardo Cardoso

Developer