-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsgantt_exExternalXML.html
executable file
·697 lines (655 loc) · 37.6 KB
/
jsgantt_exExternalXML.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>FREE javascript gantt - jsGantt Improved HTML and CSS only</title>
<script type="text/javascript" src="jsgantt.js"></script>
<link rel="stylesheet" type="text/css" href="jsgantt.css"/>
<style type="text/css">
<!--
body { font-size: 0.8em; font-family:tahoma, arial, verdana, Sans-serif; color: #656565;}
h3 { margin: 0px; font-size: 1em; }
h4 { margin: 0px; margin-left: 10px; font-size: 1em; }
.style1 {color: #0000FF}
.roundedCornerfg{
padding: 5px 5px 5px 15px;
border-radius: 5px;
width:400px;
font-size: 1.3em;
font-weight: bold;
font-style: italic;
font-family: arial,helvetica;
text-transform: uppercase;
background: rgb(204,204,204);
background: linear-gradient(to bottom, rgba(204,204,204,1) 0%,rgba(238,238,238,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cccccc', endColorstr='#eeeeee',GradientType=0 );
}
dt { float: left;
clear: left;
width: 60px;
text-align: right;
font-style: italic; }
dt:after { content: ":"; }
dd { margin: 0 0 0 70px;
padding: 0 0 0.5em 0; }
.configlist dt {width: 170px;}
.configlist dd {margin: 0 0 0 180px;}
.dateconfiglist dt {width: 240px;}
.dateconfiglist dd {margin: 0 0 0 250px;}
.lang {width: 150px; min-width: 150px; max-width: 150px; vertical-align: top;}
.header {border-top: #bbbbbb 3px solid;
border-bottom: #cfcfcf 3px solid;
padding:5px 12px 5px 12px;
font-size: 1.8em;
font-weight: bold;
font-style: italic;
background: rgb(204,204,204);
background: linear-gradient(to bottom, rgba(204,204,204,1) 0%,rgba(238,238,238,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cccccc', endColorstr='#eeeeee',GradientType=0 );
}
.nav {border-bottom: #cfcfcf 1px solid;
background-color: #ffffff;
padding:2px 5px 2px 5px;
font-size: 1.1em;
font-weight: bold;
font-style: italic;}
.nav ul { list-style-type:none;
margin:0;
padding:0;
overflow:hidden; }
.nav li { float:left; }
.nav a { display:block; padding-right: 20px;color: #656565;}
a.footnote:link {text-decoration:none;color: red;}
a.footnote:visited {text-decoration:none;color: red;}
a.footnote:hover {text-decoration:underline;color: red;}
a.footnote:active {text-decoration:underline;color: red;}
-->
</style>
</head>
<body>
<div style="position:absolute; z-index: 5; top:0; left:0; width: 100%;">
<div class="header">jsGanttImproved - 1.7.5.2</div>
<div class="nav">
<ul>
<li><a href="#tBugs">Bugs/Issues</a></li>
<li><a href="#tDownload">Download</a></li>
<li><a href="#tLicense">License</a></li>
<li><a href="#tUsage">Usage</a></li>
<li><a href="#tOptions">Options</a></li>
<li><a href="#tExamples">Examples</a></li>
<li><a href="#tXMLExport">XML Export</a></li>
<li><a href="#tCredits">Credits</a></li>
</ul>
</div>
</div>
<p id="tTop" style="padding-top: 70px;"> 100% Free Javascript / CSS/ HTML Gantt chart control. Completely buzzword compliant including AJAX !</p>
<div style="position:relative; " class="gantt" id="GanttChartDIV" ></div>
<script type="text/javascript">
var g = new JSGantt.GanttChart(document.getElementById('GanttChartDIV'), 'hour' );
if( g.getDivId() != null ) {
g.setCaptionType('Resource'); // Set to Show Caption (None,Caption,Resource,Duration,Complete)
g.setShowTaskInfoLink(1); //Show link in tool tip (0/1)
g.setDayMajorDateDisplayFormat('dd mon');
g.setDateTaskDisplayFormat('dd month yyyy HH:MI');
// use the XML file parser
JSGantt.parseXML('project.xml',g)
g.Draw();
} else {
alert("Error, unable to create Gantt Chart");
}
</script>
<h3>Basic Features</h3>
<ul>
<li>Tasks & Collapsible Task Groups</li>
<li>Multiple Dependencies</li>
<li>Task Completion</li>
<li>Task Style</li>
<li>Milestones</li>
<li>Resources</li>
<li>No images needed</li>
</ul>
<h3>Advanced Features</h3>
<ul>
<li>Dynamic Loading of Tasks</li>
<li>Dynamic change of format
<ul>
<li>Hour</li>
<li>Day</li>
<li>Week</li>
<li>Month</li>
<li>Quarter</li>
</ul>
</li>
<li>Load Gantt from XML using
<ul>
<li>External XML files (including experimental support for Microsoft Project XML files)</li>
<li>JavaScript strings</li>
</ul>
</li>
<li>Export Gantt as XML string</li>
<li>Support for internationalisation</li>
</ul>
<h2 class="roundedCornerfg" id="tBugs">Bugs/Issues</h2>
<br/>
<h3>Current Issues:</h3>
<ol>
<li>If the browser is viewing the page at anything other than 100% zoom then bars may not be sized or positioned correctly. </li>
</ol><br/>
<h3>Changes/fixes in jsGanttImproved:</h3>
<h4>v1.7.5.2:</h4>
<ul>
<li>Fixed problem that would occur if Tool Tips were disabled</li>
<li>Start and end dates specified on standard group tasks will now be respected if they fall outside of the calculated group date range</li>
</ul>
<h4>v1.7.5:</h4>
<ul>
<li>Project Migrated to GitHub</li>
<li>Instantiating a new JSGantt.TaskItem will now also accept Date objects for start and end dates</li>
<li>Fixed old Internet Explorer compatibilty broken by v1.7</li>
<li>Fixed bug in Iso week date format</li>
<li>Changed to solid arrows on dependency lines to be more printer friendly</li>
<li>Code refactoring and clean up</li>
</ul>
<h4>v1.7:</h4>
<ul>
<li>Fixed nasty long-standing bug where the first Gantt chart created must be stored in a javascript variable named "g"
<ul>
<li>NOTE: This required a change in the method to instatiate a JSGantt.TaskItem object to pass the related chart.</li>
<li>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</li>
</ul>
</li>
<li>Altered XML export functionality so that dates are output in the specified input format for the chart</li>
<li>Added method to read XML directly from an input string</li>
<li>Prevented creation of a task with a duplicate "unique" ID</li>
<li>Fixed bug where attempting to remove the first task defined would prevent the chart from redrawing</li>
<li>Some general code clean up</li>
</ul>
<h4>v1.6:</h4>
<ul>
<li>Allow use of Internationalisation strings in custom date formats</li>
<li>Modified how tooltip is hidden and revealed to make it more compatible with CSS transitions</li>
<li>Added experimental support for importing Microsoft Project XML files</li>
<li>Added methods to generate JGI XML from current task list</li>
</ul>
<h4>v1.5:</h4>
<ul>
<li>Added support for Internationalisation</li>
<li>Task duration now calculated using the same method as is used to size and position task bars</li>
<li>Milestones owned by combined group items are now ignored completely rather than hidden</li>
<li>Fixed positioning bug in day format where charts spanned a DST clock change (only noticeable if column width set to large value)</li>
<li>Fixed a number of minor bugs
<ul>
<li>Dependencies on the first task in the list did not display</li>
<li>Combined group task rows are now styled like standard tasks</li>
<li>Disabling the tool tip caused problems with scrolling</li>
</ul>
</li>
</ul>
<h4>v1.4:</h4>
<ul>
<li>Reintroduced hour view</li>
<li>Changed definition of "<a href="#setUseSingleCell">setUseSingleCell</a>" to try and prevent huge charts causing issues</li>
</ul>
<h4>v1.3:</h4>
<ul>
<li>Code refactored to:
<ul>
<li>Move the last non-structural style information from javascript to css file</li>
<li>Restructure the Tooltip DIV slightly to allow styling rather than relying on line breaks for layout</li>
<li>Create the chart using createElement() and appendChild() rather than innerHTML to enable...</li>
</ul></li>
<li>New "Combined Group" element created. Combined groups show all child task information on one row</li>
</ul>
<blockquote><p>
Please see the differences for the CSS file in commit <a href="https://github.com/jsGanttImproved/jsgantt-improved/commit/ea9890e210d3d02d0cc3e09014c0160de264f9cc">ea9890e</a> for details of CSS structural changes.
</p></blockquote>
<h4>v1.2:</h4>
<ul>
<li>Multiple gantt charts per page are now supported</li>
<li>Charts are now more printer friendly</li>
</ul>
<blockquote><p>Both these updates required changes to existing element IDs and style classes. Custom stylesheets will most likely need to be updated.
</p><p>
All chart element ids are now prefixed with the id of the master DIV containing the chart. As a result the default stylesheet has been updated to no longer use any element ids to apply styles.
</p><p>
Please see the notes for commit <a href="https://github.com/jsGanttImproved/jsgantt-improved/commit/b4bf8eaa959de11f6a6f671af167a1268a59919f">b4bf8ea</a> for details of CSS structural changes.
</p></blockquote>
<h4>v1.1:</h4>
<ul>
<li>Added support for additional dependency types</li>
<li>Altered date parsing so specifying time works in all browsers</li>
<li>Fixed bug in calculating end date when time is specified</li>
<li>Updated CSS to prevent growing DIV bug in IE9</li>
</ul>
<h4>v1.0:</h4>
<ul>
<li>Multiple new display configuration options (see <a href="#tOptions">Configuration Options</a>)</li>
<li>Hour/Minute format removed</li>
<li>Width/positioning calculations for Month and Quarter views no longer assume 30/90 day periods</li>
<li>Vast majority of look and feel now controllable via CSS</li>
<li>Tool tips added to gantt chart bars</li>
<li>New "Notes" field added for detailed task information to be displayed in tool tips</li>
<li>Tasks can now be removed from as well as added to chart</li>
<li>Tasks can now be sorted by parent task & start time</li>
<li>Dependencies no longer draw when the parent task is hidden</li>
<li>Min/Max date calculations now correctly identify the date of first and last periods</li>
<li>Current date/time now shown as a vertical blue line rather than period highlight</li>
<li>Optimised chart structure to reduce number of elements required / ensure positioning match</li>
<li>Chart pane width will change dynamically with containing element</li>
</ul>
<h2 class="roundedCornerfg" id="tDownload">Download</h2>
<a href="https://github.com/jsGanttImproved/jsgantt-improved/releases">Click here to download the current version of jsGantt Improved</a> <br/>
You can download the latest bleeding edge version, request features and report issues at <a href="https://github.com/jsGanttImproved/jsgantt-improved/">https://github.com/jsGanttImproved/jsgantt-improved/</a>
<h2 class="roundedCornerfg" id="tLicense">License</h2>
JSGanttImproved is released under BSD license.<br/>
If you plan to use it in a commercial product please consider donating the first sale to charity.
<br/><br/>
<textarea cols="80" rows="5">
* Copyright (c) 2013-2015, Paul Geldart.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Paul Geldart nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY PAUL GELDART. ''AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL PAUL GELDART BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This project is based on jsGantt 1.2 the original project license follows:
* Copyright (c) 2008, Shlomy Gantz/BlueBrick Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Shlomy Gantz or BlueBrick Inc. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY SHLOMY GANTZ/BLUEBRICK INC. ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL SHLOMY GANTZ/BLUEBRICK INC. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</textarea>
<h2 class="roundedCornerfg" id="tUsage">Usage</h2>
<p>Creating a basic Gantt Chart</p>
<ol>
<li>Include JSGantt CSS and Javascript
<pre class="style1">
<link rel="stylesheet" type="text/css" href="jsgantt.css" />
<script language="javascript" src="jsgantt.js"></script>
</pre>
</li>
<li>Create a div element to hold the gantt chart
<pre class="style1"><div style="position:relative" class="gantt" id="GanttChartDIV"></div></pre>
</li>
<li>Start a <script> block
<pre class="style1"><script type="text/javascript"></pre>
</li>
<li>Instantiate JSGantt using GanttChart()
<pre class="style1">var g = new JSGantt.GanttChart(document.getElementById('GanttChartDIV'), 'day');
</pre>
<p>Method definition:
<strong>GanttChart(<em>pDiv, pFormat</em>)</strong></p>
<dl>
<dt>pDiv</dt><dd>(required) this is a DIV object created in HTML</dd>
<dt>pFormat</dt><dd>(required) - used to indicate whether chart should be drawn in "hour", "day", "week", "month", or "quarter" format</dd>
</dl>
</li>
<li><p>Customize the look and feel using configuration methods (see <a href="#tOptions">Configuration Options</a>)</p></li>
<li>Add Tasks
<ol type="a"><li>using AddTaskItem()
<pre class="style1">
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', '2014-02-20','2014-02-20','gmilestone', '', 1, 'Shlomy',100,0,1,1,'','','',g));
</pre>
<p>Method definition:
<strong>TaskItem(<em>pID, pName, pStart, pEnd, pColor, pLink, pMile, pRes, pComp, pGroup, pParent, pOpen, pDepend, pCaption, pNotes, pGantt</em>)</strong></p>
<dl>
<dt>pID</dt><dd>(required) a unique numeric ID used to identify each row</dd>
<dt>pName</dt><dd>(required) the task Label</dd>
<dt>pStart</dt><dd>(required) the task start date, can enter empty date ('') for groups. You can also enter specific time (2014-02-20 12:00) for additional precision.</dd>
<dt>pEnd</dt><dd>(required) the task end date, can enter empty date ('') for groups</dd>
<dt>pClass</dt><dd>(required) the css class for this task</dd>
<dt>pLink</dt><dd>(optional) any http link to be displayed in tool tip as the "More information" link.</dd>
<dt>pMile</dt><dd>(optional) indicates whether this is a milestone task - Numeric; 1 = milestone, 0 = not milestone</dd>
<dt>pRes</dt><dd>(optional) resource name</dd>
<dt>pComp</dt><dd>(required) completion percent, numeric</dd>
<dt>pGroup</dt><dd>(optional) indicates whether this is a group task (parent) - Numeric; 0 = normal task, 1 = standard group task, 2 = combined group task<a href='#combinedtasks' class="footnote">*</a></dd>
<dt>pParent</dt><dd>(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</dd>
<dt>pOpen</dt><dd>(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</dd>
<dt>pDepend</dt><dd>(optional) comma separated list of id's this task is dependent on. A line will be drawn from each listed task to this item<br />Each id can optionally be followed by a dependency type suffix. Valid values are:<blockquote>'FS' - Finish to Start (default if suffix is omitted)<br />'SF' - Start to Finish<br />'SS' - Start to Start<br />'FF' - Finish to Finish</blockquote>If present the suffix must be added directly to the id e.g. '123SS'</dd>
<dt>pCaption</dt><dd>(optional) caption that will be added after task bar if CaptionType set to "Caption"</dd>
<dt>pNotes</dt><dd>(optional) Detailed task information that will be displayed in tool tip for this task</dd>
<dt>pGantt</dt><dd>(required) javascript JSGantt.GanttChart object from which to take settings. Defaults to "g" for backwards compatibility</dd>
</dl>
<p id='combinedtasks'><span style="color: red;">*</span> 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.</p>
</li>
<li>using parseXML() with an external XML file
<pre class="style1">
JSGantt.parseXML("project.xml",g);
</pre>
<p>Method definition:
<strong>JSGantt.parseXML(<em>pFile, pGanttObj</em>)</strong></p>
<dl>
<dt>pFile</dt><dd>(required) this is the filename of the XML</dd>
<dt>pGanttObj</dt><dd>(required) a GanttChart object returned by a call to JSGantt.GanttChart()</dd>
</dl>
<p>The structure of the native XML file:</p>
<blockquote>
<textarea name="textarea" cols="60" rows="10">
<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>
</textarea>
</blockquote>
<p>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.</p>
<p>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 <a href="#tXMLExport">XML Export methods</a> provided.</p>
</li>
<li>using parseXMLString() with XML held in a javascript string object
<pre class="style1">
JSGantt.parseXMLString("<project><task>...</task></project>",g);
</pre>
<p>Method definition:
<strong>JSGantt.parseXMLString(<em>pStr, pGanttObj</em>)</strong></p>
<dl>
<dt>pStr</dt><dd>(required) this is a javascript String containing XML</dd>
<dt>pGanttObj</dt><dd>(required) a GanttChart object returned by a call to JSGantt.GanttChart()</dd>
</dl>
<p>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</p>
</li></ol></li>
<li><p>Call Draw()</p><pre class="style1">g.Draw();</pre>
</li>
<li><p>Close the <script> block</p><pre class="style1"></script></pre>
</li>
</ol>
<p>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.</p>
<pre class="style1">g.RemoveTaskItem(11);</pre>
<p>Method definition:
<strong>RemoveTaskItem(<em>pID</em>)</strong></p>
<dl>
<dt>pID</dt><dd>(required) the unique numeric ID of the item to be removed</dd>
</dl>
<p>If the task removed is a group item, all child tasks will also be removed. </p>
<p>After adding or removing tasks a call to "g.Draw()" must be made to redraw the chart.</p>
<h2 class="roundedCornerfg" id="tOptions">Configuration Options</h2>
<h3 id="tOptionsSwitches">Switches</h3>
<p>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()</p>
<p>The following options take a single numeric parameter; a value of 1 will enable the describe functionality, 0 will disable it</p>
<dl class="configlist">
<dt id="setUseToolTip">setUseToolTip()</dt><dd>Controls the display of tool tip boxes, defaults to 1 (enabled)</dd>
<dt id="setUseFade">setUseFade()</dt><dd>Controls use of the fade effect when showing/hiding tool tips, defaults to 1 (enabled)</dd>
<dt id="setUseMove">setUseMove()</dt><dd>Controls use of the sliding effect when changing between different task tool tips, defaults to 1 (enabled)</dd>
<dt id="setUseRowHlt">setUseRowHlt()</dt><dd>Controls the use of row mouseover highlighting, defaults to 1 (enabled)</dd>
<dt id="setUseSort">setUseSort()</dt><dd>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)</dd>
<dt id="setShowRes">setShowRes()</dt><dd>Controls whether the Resource column is displayed in the task list, defaults to 1 (show column)</dd>
<dt id="setShowDur">setShowDur()</dt><dd>Controls whether the Task Duration column is displayed in the task list, defaults to 1 (show column)</dd>
<dt id="setShowComp">setShowComp()</dt><dd>Controls whether the Percentage Complete column is displayed in the task list, defaults to 1 (show column)</dd>
<dt id="setShowStartDate">setShowStartDate()</dt><dd>Controls whether the Task Start Date column is displayed in the task list, defaults to 1 (show column)</dd>
<dt id="setShowEndDate">setShowEndDate()</dt><dd>Controls whether the Task End Date column is displayed in the task list, defaults to 1 (show column)</dd>
<dt id="setShowTaskInfoRes">setShowTaskInfoRes()</dt><dd>Controls whether the Resource information is displayed in the task tool tip, defaults to 1 (show information)</dd>
<dt id="setShowTaskInfoDur">setShowTaskInfoDur()</dt><dd>Controls whether the Task Duration information is displayed in the task tool tip, defaults to 1 (show information)</dd>
<dt id="setShowTaskInfoComp">setShowTaskInfoComp()</dt><dd>Controls whether the Percentage Complete information is displayed in the task tool tip, defaults to 1 (show information)</dd>
<dt id="setShowTaskInfoStartDate">setShowTaskInfoStartDate()</dt><dd>Controls whether the Task Start Date information is displayed in the task tool tip, defaults to 1 (show information)</dd>
<dt id="setShowTaskInfoEndDate">setShowTaskInfoEndDate()</dt><dd>Controls whether the Task End Date information is displayed in the task tool tip, defaults to 1 (show information)</dd>
<dt id="setShowTaskInfoLink">setShowTaskInfoLink()</dt><dd>Controls whether the More Information link is displayed in the task tool tip, defaults to 0 (do NOT show link)</dd>
<dt id="setShowTaskInfoNotes">setShowTaskInfoNotes()</dt><dd>Controls whether the Additional Notes data is displayed in the task tool tip, defaults to 1 (show notes)</dd>
<dt id="setShowEndWeekDate">setShowEndWeekDate()</dt><dd>Controls whether the major heading in "Day" view displays the week end-date in the appropriate format (see <a href="#setDayMajorDateDisplayFormat">below</a>), defaults to 1 (show date)</dd>
<dt id="setShowDeps">setShowDeps()</dt><dd>Controls display of dependancy lines, defaults to 1 (show dependencies)</dd>
</dl>
<h3 id="tOptionsKeys">Key Values</h3>
<p>The following options enable functionality using a set of specific key values</p>
<dl class="configlist">
<dt id="setShowSelector">setShowSelector()</dt><dd>Controls where the format selector is displayed, accepts multiple parameters.<br/>Valid parameter values are "Top", "Bottom".<br/>Defaults to "Top".</dd>
<dt id="setFormatArr">setFormatArr()</dt><dd>Controls which format options are shown in the format selector, accepts multiple parameters.<br/>Valid parameter values are "Hour", "Day", "Week", "Month", "Quarter".<br/>Defaults to all valid values.</dd>
<dt id="setCaptionType">setCaptionType()</dt><dd>Controls which task field to use as a caption on the Gantt Chart task bar, accepts a single parameter.<br/>Valid parameter values are "None", "Caption", "Resource", "Duration", "Complete".<br/>Defaults to "None"</dd>
<dt id="setDateInputFormat">setDateInputFormat()</dt><dd>Defines the input format used for dates in task creation, accepts a single parameter.<br/>Valid parameter values are "yyyy-mm-dd", "dd/mm/yyyy", "mm/dd/yyyy".<br/>Defaults to "yyyy-mm-dd"</dd>
<dt id="setScrollTo">setScrollTo()</dt><dd>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"<br/>Defaults to minimum display date</dd>
<dt id="setUseSingleCell">setUseSingleCell()</dt><dd>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</dd>
<dt id="setLang">setLang()</dt><dd>Sets translation to use when drawing the chart. Defaults to "en" as this is the only language provided in the base installation (see <a href="#tOptionsLanguage">Internationalisation</a> below for details on how to add more translations.)</dd>
</dl>
<h3 id="tOptionsLayout">Layout</h3>
<p>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.</p>
<p>Note that the task bar sizing code assumes the use of collapsed table borders 1px wide.</p>
<dl class="configlist">
<dt id="setHourColWidth">setHourColWidth()</dt><dd>Width of Gantt Chart columns in pixels when drawn in "Hour" format. Defaults to 18.</dd>
<dt id="setDayColWidth">setDayColWidth()</dt><dd>Width of Gantt Chart columns in pixels when drawn in "Day" format. Defaults to 18.</dd>
<dt id="setWeekColWidth">setWeekColWidth()</dt><dd>Width of Gantt Chart columns in pixels when drawn in "Week" format. Defaults to 36.</dd>
<dt id="setMonthColWidth">setMonthColWidth()</dt><dd>Width of Gantt Chart columns in pixels when drawn in "Month" format. Defaults to 36.</dd>
<dt id="setQuarterColWidth">setQuarterColWidth()</dt><dd>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.</dd>
<dt id="setRowHeight">setRowHeight()</dt><dd>Height of Gantt Chart rows in pixels. Used to route dependency lines near end points. Defaults to 20.</dd>
<dt id="setMinGpLen">setMinGpLen()</dt><dd>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.</dd>
</dl>
<h3 id="tOptionsFormatSpecifiers">Display Date Formats</h3>
<p>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)</p>
<blockquote>
<dl>
<dt>h</dt><dd>Hour (1-12)</dd>
<dt>hh</dt><dd>Hour (01-12)</dd>
<dt>pm</dt><dd>am/pm indicator</dd>
<dt>PM</dt><dd>AM/PM indicator</dd>
<dt>H</dt><dd>Hour (0-23)</dd>
<dt>HH</dt><dd>Hour (01-23)</dd>
<dt>mi</dt><dd>Minutes (1-59)</dd>
<dt>MI</dt><dd>Minutes (01-59)</dd>
<dt>d</dt><dd>Day (1-31)</dd>
<dt>dd</dt><dd>Day (01-31)</dd>
<dt>day</dt><dd>Abbriviated day of week</dd>
<dt>DAY</dt><dd>Day of week</dd>
<dt>m</dt><dd>Month (1-12)</dd>
<dt>mm</dt><dd>Month (01-12)</dd>
<dt>mon</dt><dd>Abbriviated month text</dd>
<dt>month</dt><dd>Full month text</dd>
<dt>yy</dt><dd>Year, excluding century</dd>
<dt>yyyy</dt><dd>Year</dd>
<dt>q</dt><dd>Quarter (1-4)</dd>
<dt>qq</dt><dd>Quarter (Q1-Q4)</dd>
<dt>w</dt><dd>ISO Week number (1-53)</dd>
<dt>ww</dt><dd>ISO Week number (01-53)</dd>
<dt>week</dt><dd>Full ISO Week date format</dd>
</dl>
<p>separated by one of the following characters: <strong>"/\-.,'<space>:</strong></p>
<p>Any text between separators that does not match one of the components above will be checked using a case insensitive match for a valid internationalised string (see <a href="#tOptionsLanguage">Internationalisation</a> below). If the value is still not found the text will be output unchanged.</p>
</blockquote>
<p id="tOptionsDateFormats"The available date display methods are</p>
<dl class="dateconfiglist">
<dt id="setDateTaskTableDisplayFormat">setDateTaskTableDisplayFormat()</dt><dd>Date format used for start and end dates in the main task list. Defaults to 'dd/mm/yyyy'.</dd>
<dt id="setDateTaskDisplayFormat">setDateTaskDisplayFormat()</dt><dd>Date format used for start and end dates in task tool tips. Defaults to 'dd month yyyy'.</dd>
<dt id="setHourMajorDateDisplayFormat">setHourMajorDateDisplayFormat()</dt><dd>Date format used for Gantt Chart major date headings displayed in "Hour" format. Defaults to 'day dd month yyyy'.</dd>
<dt id="setDayMajorDateDisplayFormat">setDayMajorDateDisplayFormat()</dt><dd>Date format used for Gantt Chart major date headings displayed in "Day" format. Defaults to 'dd/mm/yyyy'.</dd>
<dt id="setWeekMajorDateDisplayFormat">setWeekMajorDateDisplayFormat()</dt><dd>Date format used for Gantt Chart major date headings displayed in "Week" format. Defaults to 'yyyy'.</dd>
<dt id="setMonthMajorDateDisplayFormat">setMonthMajorDateDisplayFormat()</dt><dd>Date format used for Gantt Chart major date headings displayed in "Month" format. Defaults to 'yyyy'.</dd>
<dt id="setQuarterMajorDateDisplayFormat">setQuarterMajorDateDisplayFormat()</dt><dd>Date format used for Gantt Chart major date headings displayed in "Year" format. Defaults to 'yyyy'.</dd>
<dt id="setHourMinorDateDisplayFormat">setHourMinorDateDisplayFormat()</dt><dd>Date format used for Gantt Chart minor date headings displayed in "Hour" format. Defaults to 'HH'.</dd>
<dt id="setDayMinorDateDisplayFormat">setDayMinorDateDisplayFormat()</dt><dd>Date format used for Gantt Chart minor date headings displayed in "Day" format. Defaults to 'dd'.</dd>
<dt id="setWeekMinjorDateDisplayFormat">setWeekMinjorDateDisplayFormat()</dt><dd>Date format used for Gantt Chart minor date headings displayed in "Week" format. Defaults to 'dd/mm'.</dd>
<dt id="setMonthMinorDateDisplayFormat">setMonthMinorDateDisplayFormat()</dt><dd>Date format used for Gantt Chart minor date headings displayed in "Month" format. Defaults to 'mon'.</dd>
<dt id="setQuarterMinorDateDisplayFormat">setQuarterMinorDateDisplayFormat()</dt><dd>Date format used for Gantt Chart minor date headings displayed in "Year" format. Defaults to 'qq'.</dd>
</dl>
<h3 id="tOptionsLanguage">Internationalisation</h3>
<p>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()</p>
<p>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:</p>
<blockquote>
<table>
<tbody>
<tr>
<td class="lang">
<dl>
<dt>january</dt><dd>January</dd>
<dt>february</dt><dd>February</dd>
<dt>march</dt><dd>March</dd>
<dt>april</dt><dd>April</dd>
<dt>maylong</dt><dd>May</dd>
<dt>june</dt><dd>June</dd>
<dt>july</dt><dd>July</dd>
<dt>august</dt><dd>August</dd>
<dt>september</dt><dd>September</dd>
<dt>october</dt><dd>October</dd>
<dt>november</dt><dd>November</dd>
<dt>december</dt><dd>December</dd>
<dt>jan</dt><dd>Jan</dd>
<dt>feb</dt><dd>Feb</dd>
<dt>mar</dt><dd>Mar</dd>
<dt>apr</dt><dd>Apr</dd>
<dt>may</dt><dd>May</dd>
<dt>jun</dt><dd>Jun</dd>
<dt>jul</dt><dd>Jul</dd>
<dt>aug</dt><dd>Aug</dd>
<dt>sep</dt><dd>Sep</dd>
<dt>oct</dt><dd>Oct</dd>
<dt>nov</dt><dd>Nov</dd>
<dt>dec</dt><dd>Dec</dd>
</dl>
</td>
<td class="lang">
<dl>
<dt>sunday</dt><dd>Sunday</dd>
<dt>monday</dt><dd>Monday</dd>
<dt>tuesday</dt><dd>Tuesday</dd>
<dt>wednesday</dt><dd>Wednesday</dd>
<dt>thursday</dt><dd>Thursday</dd>
<dt>friday</dt><dd>Friday</dd>
<dt>saturday</dt><dd>Saturday</dd>
<dt>sun</dt><dd>Sun</dd>
<dt>mon</dt><dd>Mon</dd>
<dt>tue</dt><dd>Tue</dd>
<dt>wed</dt><dd>Wed</dd>
<dt>thu</dt><dd>Thu</dd>
<dt>fri</dt><dd>Fri</dd>
<dt>sat</dt><dd>Sat</dd>
<dt>resource</dt><dd>Resource</dd>
<dt>duration</dt><dd>Duration</dd>
<dt>comp</dt><dd>% Comp.</dd>
<dt>completion</dt><dd>Completion</dd>
<dt>startdate</dt><dd>Start Date</dd>
<dt>enddate</dt><dd>End Date</dd>
<dt>moreinfo</dt><dd>More Information</dd>
<dt>notes</dt><dd>Notes</dd>
</dl>
</td>
<td class="lang">
<dl>
<dt>format</dt><dd>Format</dd>
<dt>hour</dt><dd>Hour</dd>
<dt>day</dt><dd>Day</dd>
<dt>week</dt><dd>Week</dd>
<dt>month</dt><dd>Month</dd>
<dt>quarter</dt><dd>Quarter</dd>
<dt>hours</dt><dd>Hours</dd>
<dt>days</dt><dd>Days</dd>
<dt>weeks</dt><dd>Weeks</dd>
<dt>months</dt><dd>Months</dd>
<dt>quarters</dt><dd>Quarters</dd>
<dt>hr</dt><dd>Hr</dd>
<dt>dy</dt><dd>Day</dd>
<dt>wk</dt><dd>Wk</dd>
<dt>mth</dt><dd>Mth</dd>
<dt>qtr</dt><dd>Qtr</dd>
<dt>hrs</dt><dd>Hrs</dd>
<dt>dys</dt><dd>Days</dd>
<dt>wks</dt><dd>Wks</dd>
<dt>mths</dt><dd>Mths</dd>
<dt>qtrs</dt><dd>Qtrs</dd>
</dl>
</td>
</tbody>
</table>
</blockquote>
<p>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.</p>
<pre class="style1">
g.addLang('en2', {'format':'Select', 'comp':'Complete'});
</pre>
<p>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."</p>
<p>Once a translation has been added a call must be made to <a href="#setLang">setLang()</a> with the appropriate langage identifier before calling Draw().</p>
<h3 id="tOptionsExamples">Example Options</h3>
<p>The configuration options used in the example chart above are:</p>
<pre class="style1">
g.setCaptionType('Resource');
g.setShowTaskInfoLink(1);
g.setDayMajorDateDisplayFormat('dd mon');
g.setDateTaskDisplayFormat('dd month yyyy HH:MI');
</pre>
<p>Putting all this information together the final code to produce the chart above is as follows:</p>
<textarea name="textarea2" cols="100" rows="20">
<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'), 'hour');
if( g.getDivId() != null ) {
g.setCaptionType('Resource');
g.setShowTaskInfoLink(1);
g.setDayMajorDateDisplayFormat('dd mon');
g.setDateTaskDisplayFormat('dd month yyyy HH:MI');
JSGantt.parseXML('project.xml',g)
g.Draw();
}
else
{
alert("Error, unable to create Gantt Chart");
}
</script>
</textarea>
<h2 class="roundedCornerfg" id="tXMLExport">XML Export</h2>
<p>The following methods can be used to extract details of tasks in the project in XML format</p>
<p id="getXMLProject">Method definition: <strong>getXMLProject()</strong></p>
<p>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()</p>
<p id="getXMLProject">Method definition: <strong>getXMLTask(<em>pID, pIdx</em>)</strong></p>
<dl>
<dt>pID</dt><dd>(required) the numeric ID that identifies the task to extract</dd>
<dt>pIdx</dt><dd>(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</dd>
</dl>
<p>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()</p>
<h2 class="roundedCornerfg" id="tExamples">Additional Demos</h2>
<ul>
<li><a href="index.html">jsGantt</a></li>
<li><a href="jsgantt_exExternalXML.html">jsGantt with external XML file</a></li>
</ul>
<h2 class="roundedCornerfg" id="tCredits">Credits</h2>
<p>Developed by Paul Geldart</p>
<p>Based on jsGantt 1.2 developed by Shlomy Gantz and Brian Twidt<br/>
Contributed: Paul Labuschagne, Kevin Badgett, Ilan Admon<br/>
</p>
</body>
</html>