Skip to content

Commit 6c6259a

Browse files
committed
#319 v2.6.2
1 parent 9d77931 commit 6c6259a

File tree

6 files changed

+114
-108
lines changed

6 files changed

+114
-108
lines changed

dist/jsgantt.js

Lines changed: 52 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ var draw_utils_1 = require("./utils/draw_utils");
1818
var draw_dependencies_1 = require("./draw_dependencies");
1919
var options_1 = require("./options");
2020
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+
*/
2426
exports.GanttChart = function (pDiv, pFormat) {
2527
this.vDiv = pDiv;
2628
this.vFormat = pFormat;
@@ -287,6 +289,11 @@ exports.GanttChart = function (pDiv, pFormat) {
287289
vTmpContentTabWrapper: vTmpContentTabWrapper
288290
};
289291
};
292+
/**
293+
*
294+
* DRAW CHAR HEAD
295+
*
296+
*/
290297
this.drawChartHead = function (vMinDate, vMaxDate, vColWidth, vNumRows) {
291298
var vRightHeader = document.createDocumentFragment();
292299
var vTmpDiv = draw_utils_1.newNode(vRightHeader, 'div', this.vDivId + 'gcharthead', 'gchartlbl gcontainercol');
@@ -431,14 +438,16 @@ exports.GanttChart = function (pDiv, pFormat) {
431438
vTmpTab.style.width = vTaskLeftPx + 'px'; // Ensure that the headings has exactly the same width as the chart grid
432439
var vTaskPlanLeftPx = (vNumCols * (vColWidth + 3)) + 1;
433440
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;
436443
draw_utils_1.newNode(vTmpDiv, 'div', null, 'rhscrpad', null, null, vTaskLeftPx + 1);
437444
vTmpDiv = draw_utils_1.newNode(vRightHeader, 'div', null, 'glabelfooter');
438445
return { gChartLbl: gChartLbl, vTaskLeftPx: vTaskLeftPx, vSingleCell: vSingleCell, vDateRow: vDateRow, vRightHeader: vRightHeader, vNumCols: vNumCols };
439446
};
440447
/**
448+
*
441449
* DRAW CHART BODY
450+
*
442451
*/
443452
this.drawCharBody = function (vTaskLeftPx, vTmpContentTabWrapper, gChartLbl, gListLbl, vMinDate, vSingleCell, vNumCols, vColWidth, vDateRow) {
444453
var vRightTable = document.createDocumentFragment();
@@ -485,8 +494,8 @@ exports.GanttChart = function (pDiv, pFormat) {
485494
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));
486495
this.vTaskList[i].setChildRow(vTmpRow);
487496
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);
490499
vTmpDiv_1 = draw_utils_1.newNode(vTmpCell, 'div', null, 'gtaskcelldiv', '\u00A0\u00A0');
491500
vTmpDiv_1 = draw_utils_1.newNode(vTmpDiv_1, 'div', this.vDivId + 'bardiv_' + vID, 'gtaskbarcontainer', null, 12, vTaskLeftPx_1 + vTaskRightPx - 6);
492501
this.vTaskList[i].setBarDiv(vTmpDiv_1);
@@ -500,15 +509,9 @@ exports.GanttChart = function (pDiv, pFormat) {
500509
draw_utils_1.newNode(vTmpDiv2, 'div', null, 'gmdbottom');
501510
}
502511
vCaptClass = 'gmilecaption';
512+
console.log(vSingleCell, vComb);
503513
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);
512515
}
513516
}
514517
else {
@@ -521,8 +524,8 @@ exports.GanttChart = function (pDiv, pFormat) {
521524
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));
522525
this.vTaskList[i].setChildRow(vTmpRow);
523526
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);
526529
vTmpDiv_1 = draw_utils_1.newNode(vTmpCell, 'div', null, 'gtaskcelldiv', '\u00A0\u00A0');
527530
this.vTaskList[i].setCellDiv(vTmpDiv_1);
528531
if (this.vTaskList[i].getGroup() == 1) {
@@ -537,14 +540,7 @@ exports.GanttChart = function (pDiv, pFormat) {
537540
vCaptClass = 'ggroupcaption';
538541
}
539542
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);
548544
}
549545
}
550546
else {
@@ -561,7 +557,8 @@ exports.GanttChart = function (pDiv, pFormat) {
561557
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));
562558
this.vTaskList[i].setChildRow(vTmpRow);
563559
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);
565562
vTmpDivCell = vTmpDiv_1 = draw_utils_1.newNode(vTmpCell, 'div', null, 'gtaskcelldiv', '\u00A0\u00A0');
566563
}
567564
// DRAW TASK BAR
@@ -594,14 +591,8 @@ exports.GanttChart = function (pDiv, pFormat) {
594591
vCaptClass = 'gcaption';
595592
// Background cells
596593
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);
605596
}
606597
}
607598
}
@@ -638,34 +629,35 @@ exports.GanttChart = function (pDiv, pFormat) {
638629
events_1.addTooltipListeners(this, this.vTaskList[i].getPlanTaskDiv(), vTmpDiv2, callback);
639630
}
640631
}
641-
// if (!vSingleCell) {
632+
// Include the footer with the days/week/month...
642633
vTmpTBody.appendChild(vDateRow.cloneNode(true));
643-
// }
644-
// else if (this.vFormat == 'day') {
645-
// vTmpTBody.appendChild(document.createElement('tr'));
646-
// }
647634
return { vRightTable: vRightTable };
648635
};
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+
};
649646
/**
650647
*
651648
*
652-
* DRAW GANTT
653-
*
649+
* DRAWING PROCESS
654650
*
651+
* vTaskRightPx,vTaskWidth,vTaskPlanLeftPx,vTaskPlanRightPx,vID
655652
*/
656653
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;
665654
var vMaxDate = new Date();
666655
var vMinDate = new Date();
667656
var vColWidth = 0;
668657
var bd;
658+
if (this.vEvents && this.vEvents.beforeDraw) {
659+
this.vEvents.beforeDraw();
660+
}
669661
if (this.vDebug) {
670662
bd = new Date();
671663
console.info('before draw', bd);
@@ -735,7 +727,7 @@ exports.GanttChart = function (pDiv, pFormat) {
735727
}
736728
vTmpDiv2.style.visibility = 'hidden';
737729
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
739731
let tmpGenSrc=document.createElement('textarea');
740732
tmpGenSrc.appendChild(document.createTextNode(vTmpDiv.innerHTML));
741733
vDiv.appendChild(tmpGenSrc);
@@ -782,6 +774,7 @@ exports.GanttChart = function (pDiv, pFormat) {
782774
}
783775
this.DrawDependencies(this.vDebug);
784776
events_1.addListenerDependencies(this.vLineOptions);
777+
// EVENTS
785778
if (this.vEvents && typeof this.vEvents.afterLineDraw === 'function') {
786779
this.vEvents.afterLineDraw();
787780
}
@@ -790,7 +783,10 @@ exports.GanttChart = function (pDiv, pFormat) {
790783
console.info('after DrawDependencies', ad, (ad.getTime() - bdd.getTime()));
791784
}
792785
this.drawComplete(vMinDate, vColWidth, bd);
793-
}; //this.draw
786+
};
787+
/**
788+
* Actions after all the render process
789+
*/
794790
this.drawComplete = function (vMinDate, vColWidth, bd) {
795791
if (this.vDebug) {
796792
var ad = new Date();
@@ -4059,9 +4055,12 @@ exports.parseDateFormatStr = function (pFormatStr) {
40594055
}
40604056
return vDateFormatArray;
40614057
};
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+
*/
40624063
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
40654064
var dayMiliseconds = 86400000;
40664065
var keyDay = new Date(pDate.getFullYear(), 0, 4, 0, 0, 0);
40674066
var keyDayOfWeek = (keyDay.getDay() == 0) ? 6 : keyDay.getDay() - 1; // define monday as 0

docs/demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ <h3 class="row">Hide and Show Properties</h3>
153153

154154
Delay for tooltip to hide (in ms): <input id="delay" onchange="start(event)" value="150" type="number">
155155

156-
UseSingleCell: <input id="useSingleCell" onchange="start(event)" value="1000" type="number">
156+
UseSingleCell: <input id="useSingleCell" onchange="start(event)" value="100000" type="number">
157157

158158

159159
<br />

docs/demobigdata.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ <h3 class="row">Hide and Show Properties</h3>
136136

137137
Delay for tooltip to hide (in ms): <input id="delay" onchange="start(event)" value="150" type="number">
138138

139-
UseSingleCell: <input id="useSingleCell" onchange="start(event)" value="1000" type="number">
139+
UseSingleCell: <input id="useSingleCell" onchange="start(event)" value="100000" type="number">
140140

141141
<br />
142142
* Click events in table are binded to console.log for testing

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jsgantt-improved",
3-
"version": "2.6.1",
3+
"version": "2.6.2",
44
"description": "jsgantt-improved",
55
"main": "dist/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)