@@ -18,9 +18,11 @@ var draw_utils_1 = require("./utils/draw_utils");
18
18
var draw_dependencies_1 = require ( "./draw_dependencies" ) ;
19
19
var options_1 = require ( "./options" ) ;
20
20
var date_utils_1 = require ( "./utils/date_utils" ) ;
21
- // function that loads the main gantt chart properties and functions
22
- // pDiv: (required) this is a div object created in HTML
23
- // pFormat: (required) - used to indicate whether chart should be drawn in "hour", "day", "week", "month", or "quarter" format
21
+ /**
22
+ * function that loads the main gantt chart properties and functions
23
+ * @param pDiv (required) this is a div object created in HTML
24
+ * @param pFormat (required) - used to indicate whether chart should be drawn in "hour", "day", "week", "month", or "quarter" format
25
+ */
24
26
exports . GanttChart = function ( pDiv , pFormat ) {
25
27
this . vDiv = pDiv ;
26
28
this . vFormat = pFormat ;
@@ -287,6 +289,11 @@ exports.GanttChart = function (pDiv, pFormat) {
287
289
vTmpContentTabWrapper : vTmpContentTabWrapper
288
290
} ;
289
291
} ;
292
+ /**
293
+ *
294
+ * DRAW CHAR HEAD
295
+ *
296
+ */
290
297
this . drawChartHead = function ( vMinDate , vMaxDate , vColWidth , vNumRows ) {
291
298
var vRightHeader = document . createDocumentFragment ( ) ;
292
299
var vTmpDiv = draw_utils_1 . newNode ( vRightHeader , 'div' , this . vDivId + 'gcharthead' , 'gchartlbl gcontainercol' ) ;
@@ -431,14 +438,16 @@ exports.GanttChart = function (pDiv, pFormat) {
431
438
vTmpTab . style . width = vTaskLeftPx + 'px' ; // Ensure that the headings has exactly the same width as the chart grid
432
439
var vTaskPlanLeftPx = ( vNumCols * ( vColWidth + 3 ) ) + 1 ;
433
440
var vSingleCell = false ;
434
- if ( this . vUseSingleCell != 0 && this . vUseSingleCell < ( vNumCols * vNumRows ) )
435
- vSingleCell = true ;
441
+ console . log ( ( vNumCols * vNumRows ) , this . vUseSingleCell , vNumCols , vNumRows ) ;
442
+ // if (this.vUseSingleCell !== 0 && this.vUseSingleCell < (vNumCols * vNumRows)) vSingleCell = true;
436
443
draw_utils_1 . newNode ( vTmpDiv , 'div' , null , 'rhscrpad' , null , null , vTaskLeftPx + 1 ) ;
437
444
vTmpDiv = draw_utils_1 . newNode ( vRightHeader , 'div' , null , 'glabelfooter' ) ;
438
445
return { gChartLbl : gChartLbl , vTaskLeftPx : vTaskLeftPx , vSingleCell : vSingleCell , vDateRow : vDateRow , vRightHeader : vRightHeader , vNumCols : vNumCols } ;
439
446
} ;
440
447
/**
448
+ *
441
449
* DRAW CHART BODY
450
+ *
442
451
*/
443
452
this . drawCharBody = function ( vTaskLeftPx , vTmpContentTabWrapper , gChartLbl , gListLbl , vMinDate , vSingleCell , vNumCols , vColWidth , vDateRow ) {
444
453
var vRightTable = document . createDocumentFragment ( ) ;
@@ -485,8 +494,8 @@ exports.GanttChart = function (pDiv, pFormat) {
485
494
var vTmpRow = draw_utils_1 . newNode ( vTmpTBody , 'tr' , this . vDivId + 'childrow_' + vID , 'gmileitem gmile' + this . vFormat , null , null , null , ( ( this . vTaskList [ i ] . getVisible ( ) == 0 ) ? 'none' : null ) ) ;
486
495
this . vTaskList [ i ] . setChildRow ( vTmpRow ) ;
487
496
events_1 . addThisRowListeners ( this , this . vTaskList [ i ] . getListChildRow ( ) , vTmpRow ) ;
488
- var vTmpCell = draw_utils_1 . newNode ( vTmpRow , 'td' , null , 'gtaskcell s4443' , null , null , null , null , vNumCols ) ;
489
- console . log ( 'T ----->' , vNumCols ) ;
497
+ // console.log('T ----->', vNumCols)
498
+ var vTmpCell = draw_utils_1 . newNode ( vTmpRow , 'td' , null , 'gtaskcell gtaskcellmile' , null , vColWidth , null , null , null ) ;
490
499
vTmpDiv_1 = draw_utils_1 . newNode ( vTmpCell , 'div' , null , 'gtaskcelldiv' , '\u00A0\u00A0' ) ;
491
500
vTmpDiv_1 = draw_utils_1 . newNode ( vTmpDiv_1 , 'div' , this . vDivId + 'bardiv_' + vID , 'gtaskbarcontainer' , null , 12 , vTaskLeftPx_1 + vTaskRightPx - 6 ) ;
492
501
this . vTaskList [ i ] . setBarDiv ( vTmpDiv_1 ) ;
@@ -500,15 +509,9 @@ exports.GanttChart = function (pDiv, pFormat) {
500
509
draw_utils_1 . newNode ( vTmpDiv2 , 'div' , null , 'gmdbottom' ) ;
501
510
}
502
511
vCaptClass = 'gmilecaption' ;
512
+ console . log ( vSingleCell , vComb ) ;
503
513
if ( ! vSingleCell && ! vComb ) {
504
- vCellFormat = '' ;
505
- for ( j = 0 ; j < vNumCols - 1 ; j ++ ) {
506
- if ( this . vShowWeekends !== false && this . vFormat == 'day' && ( ( j % 7 == 4 ) || ( j % 7 == 5 ) ) )
507
- vCellFormat = 'gtaskcellwkend' ;
508
- else
509
- vCellFormat = 'gtaskcell' ;
510
- draw_utils_1 . newNode ( vTmpRow , 'td' , null , vCellFormat , '\u00A0\u00A0' , taskCellWidth ) ;
511
- }
514
+ this . drawColsChart ( vNumCols , vTmpRow , taskCellWidth ) ;
512
515
}
513
516
}
514
517
else {
@@ -521,8 +524,8 @@ exports.GanttChart = function (pDiv, pFormat) {
521
524
var vTmpRow = draw_utils_1 . newNode ( vTmpTBody , 'tr' , this . vDivId + 'childrow_' + vID , ( ( this . vTaskList [ i ] . getGroup ( ) == 2 ) ? 'glineitem gitem' : 'ggroupitem ggroup' ) + this . vFormat , null , null , null , ( ( this . vTaskList [ i ] . getVisible ( ) == 0 ) ? 'none' : null ) ) ;
522
525
this . vTaskList [ i ] . setChildRow ( vTmpRow ) ;
523
526
events_1 . addThisRowListeners ( this , this . vTaskList [ i ] . getListChildRow ( ) , vTmpRow ) ;
524
- console . log ( 'F ----->' , vNumCols ) ;
525
- var vTmpCell = draw_utils_1 . newNode ( vTmpRow , 'td' , null , 'gtaskcell' , null , null , null , null , vNumCols ) ;
527
+ // console.log('F ----->', vNumCols)
528
+ var vTmpCell = draw_utils_1 . newNode ( vTmpRow , 'td' , null , 'gtaskcell gtaskcellbar ' , null , vColWidth , null , null ) ;
526
529
vTmpDiv_1 = draw_utils_1 . newNode ( vTmpCell , 'div' , null , 'gtaskcelldiv' , '\u00A0\u00A0' ) ;
527
530
this . vTaskList [ i ] . setCellDiv ( vTmpDiv_1 ) ;
528
531
if ( this . vTaskList [ i ] . getGroup ( ) == 1 ) {
@@ -537,14 +540,7 @@ exports.GanttChart = function (pDiv, pFormat) {
537
540
vCaptClass = 'ggroupcaption' ;
538
541
}
539
542
if ( ! vSingleCell && ! vComb ) {
540
- vCellFormat = '' ;
541
- for ( j = 0 ; j < vNumCols - 1 ; j ++ ) {
542
- if ( this . vShowWeekends !== false && this . vFormat == 'day' && ( ( j % 7 == 4 ) || ( j % 7 == 5 ) ) )
543
- vCellFormat = 'gtaskcellwkend' ;
544
- else
545
- vCellFormat = 'gtaskcell' ;
546
- draw_utils_1 . newNode ( vTmpRow , 'td' , null , vCellFormat , '\u00A0\u00A0' , taskCellWidth ) ;
547
- }
543
+ this . drawColsChart ( vNumCols , vTmpRow , taskCellWidth ) ;
548
544
}
549
545
}
550
546
else {
@@ -561,7 +557,8 @@ exports.GanttChart = function (pDiv, pFormat) {
561
557
vTmpRow = draw_utils_1 . newNode ( vTmpTBody , 'tr' , this . vDivId + 'childrow_' + vID , 'glineitem gitem' + this . vFormat , null , null , null , ( ( this . vTaskList [ i ] . getVisible ( ) == 0 ) ? 'none' : null ) ) ;
562
558
this . vTaskList [ i ] . setChildRow ( vTmpRow ) ;
563
559
events_1 . addThisRowListeners ( this , this . vTaskList [ i ] . getListChildRow ( ) , vTmpRow ) ;
564
- var vTmpCell = draw_utils_1 . newNode ( vTmpRow , 'td' , null , 'gtaskcell' , null , taskCellWidth , null , null , vNumCols ) ;
560
+ // console.log('F ----->', vNumCols)
561
+ var vTmpCell = draw_utils_1 . newNode ( vTmpRow , 'td' , null , 'gtaskcell gtaskcellcolorbar' , null , taskCellWidth , null , null ) ;
565
562
vTmpDivCell = vTmpDiv_1 = draw_utils_1 . newNode ( vTmpCell , 'div' , null , 'gtaskcelldiv' , '\u00A0\u00A0' ) ;
566
563
}
567
564
// DRAW TASK BAR
@@ -594,14 +591,8 @@ exports.GanttChart = function (pDiv, pFormat) {
594
591
vCaptClass = 'gcaption' ;
595
592
// Background cells
596
593
if ( ! vSingleCell && ! vComb ) {
597
- vCellFormat = '' ;
598
- for ( j = 0 ; j < vNumCols - 1 ; j ++ ) {
599
- if ( this . vShowWeekends !== false && this . vFormat == 'day' && ( ( j % 7 == 4 ) || ( j % 7 == 5 ) ) )
600
- vCellFormat = 'gtaskcellwkend' ;
601
- else
602
- vCellFormat = 'gtaskcell' ;
603
- draw_utils_1 . newNode ( vTmpRow , 'td' , null , vCellFormat , '\u00A0\u00A0' ) ;
604
- }
594
+ if ( vTmpRow )
595
+ this . drawColsChart ( vNumCols , vTmpRow , taskCellWidth ) ;
605
596
}
606
597
}
607
598
}
@@ -638,34 +629,35 @@ exports.GanttChart = function (pDiv, pFormat) {
638
629
events_1 . addTooltipListeners ( this , this . vTaskList [ i ] . getPlanTaskDiv ( ) , vTmpDiv2 , callback ) ;
639
630
}
640
631
}
641
- // if (!vSingleCell) {
632
+ // Include the footer with the days/week/month...
642
633
vTmpTBody . appendChild ( vDateRow . cloneNode ( true ) ) ;
643
- // }
644
- // else if (this.vFormat == 'day') {
645
- // vTmpTBody.appendChild(document.createElement('tr'));
646
- // }
647
634
return { vRightTable : vRightTable } ;
648
635
} ;
636
+ this . drawColsChart = function ( vNumCols , vTmpRow , taskCellWidth ) {
637
+ var vCellFormat = '' ;
638
+ for ( var j = 0 ; j < vNumCols - 1 ; j ++ ) {
639
+ if ( this . vShowWeekends !== false && this . vFormat == 'day' && ( ( j % 7 == 4 ) || ( j % 7 == 5 ) ) )
640
+ vCellFormat = 'gtaskcellwkend' ;
641
+ else
642
+ vCellFormat = 'gtaskcell gtaskcellcols' ;
643
+ draw_utils_1 . newNode ( vTmpRow , 'td' , null , vCellFormat , '\u00A0\u00A0' , taskCellWidth ) ;
644
+ }
645
+ } ;
649
646
/**
650
647
*
651
648
*
652
- * DRAW GANTT
653
- *
649
+ * DRAWING PROCESS
654
650
*
651
+ * vTaskRightPx,vTaskWidth,vTaskPlanLeftPx,vTaskPlanRightPx,vID
655
652
*/
656
653
this . Draw = function ( ) {
657
- if ( this . vEvents && this . vEvents . beforeDraw ) {
658
- this . vEvents . beforeDraw ( ) ;
659
- }
660
- // let vTaskRightPx = 0;
661
- // let vTaskWidth = 1;
662
- // let vTaskPlanLeftPx = 0;
663
- // let vTaskPlanRightPx = 0;
664
- // let vID = 0;
665
654
var vMaxDate = new Date ( ) ;
666
655
var vMinDate = new Date ( ) ;
667
656
var vColWidth = 0 ;
668
657
var bd ;
658
+ if ( this . vEvents && this . vEvents . beforeDraw ) {
659
+ this . vEvents . beforeDraw ( ) ;
660
+ }
669
661
if ( this . vDebug ) {
670
662
bd = new Date ( ) ;
671
663
console . info ( 'before draw' , bd ) ;
@@ -735,7 +727,7 @@ exports.GanttChart = function (pDiv, pFormat) {
735
727
}
736
728
vTmpDiv2 . style . visibility = 'hidden' ;
737
729
this . setLines ( vTmpDiv2 ) ;
738
- /* Quick hack to show the generated HTML on older browsers - add a '/' to the begining of this line to activate
730
+ /* Quick hack to show the generated HTML on older browsers
739
731
let tmpGenSrc=document.createElement('textarea');
740
732
tmpGenSrc.appendChild(document.createTextNode(vTmpDiv.innerHTML));
741
733
vDiv.appendChild(tmpGenSrc);
@@ -782,6 +774,7 @@ exports.GanttChart = function (pDiv, pFormat) {
782
774
}
783
775
this . DrawDependencies ( this . vDebug ) ;
784
776
events_1 . addListenerDependencies ( this . vLineOptions ) ;
777
+ // EVENTS
785
778
if ( this . vEvents && typeof this . vEvents . afterLineDraw === 'function' ) {
786
779
this . vEvents . afterLineDraw ( ) ;
787
780
}
@@ -790,7 +783,10 @@ exports.GanttChart = function (pDiv, pFormat) {
790
783
console . info ( 'after DrawDependencies' , ad , ( ad . getTime ( ) - bdd . getTime ( ) ) ) ;
791
784
}
792
785
this . drawComplete ( vMinDate , vColWidth , bd ) ;
793
- } ; //this.draw
786
+ } ;
787
+ /**
788
+ * Actions after all the render process
789
+ */
794
790
this . drawComplete = function ( vMinDate , vColWidth , bd ) {
795
791
if ( this . vDebug ) {
796
792
var ad = new Date ( ) ;
@@ -4059,9 +4055,12 @@ exports.parseDateFormatStr = function (pFormatStr) {
4059
4055
}
4060
4056
return vDateFormatArray ;
4061
4057
} ;
4058
+ /**
4059
+ * We have to compare against the monday of the first week of the year containing 04 jan *not* 01/01
4060
+ * 60*60*24*1000=86400000
4061
+ * @param pDate
4062
+ */
4062
4063
exports . getIsoWeek = function ( pDate ) {
4063
- // We have to compare against the monday of the first week of the year containing 04 jan *not* 01/01
4064
- // 60*60*24*1000=86400000
4065
4064
var dayMiliseconds = 86400000 ;
4066
4065
var keyDay = new Date ( pDate . getFullYear ( ) , 0 , 4 , 0 , 0 , 0 ) ;
4067
4066
var keyDayOfWeek = ( keyDay . getDay ( ) == 0 ) ? 6 : keyDay . getDay ( ) - 1 ; // define monday as 0
0 commit comments