Date range not displayed correctly in weeks view

236 views
Skip to first unread message

qfl...@gmail.com

unread,
Jan 30, 2013, 12:25:30 AM1/30/13
to jquer...@googlegroups.com
Hello,

I have the data presented below (3 date ranges on the same line), but the 3rd range is not displayed correctly in the weeks view. However, if I zoom in or out (days view or months view), the range is displayed correctly. Does anyone have any idea how to fix the weeks view?

Thank you,
Flavius.


"values": [              
{
        "from": "/Date(1349049600000)/",              
"to": "/Date(1358121600000)/",              
"label": "Label 1",              
"customClass": "ganttYellow"
},              
{
"from": "/Date(1358121600000)/",              
"to": "/Date(1364601600000)/",              
"label": "Label 2",              
"customClass": "ganttBlue"
},              
{
"from": "/Date(1364601600000)/",              
"to": "/Date(1388448000000)/",              
"label": "Label 3",              
"customClass": "ganttGreen"
}            
]
}]
weeks_view.jpg
Message has been deleted
Message has been deleted

qfl...@gmail.com

unread,
Feb 10, 2013, 1:22:26 AM2/10/13
to jquer...@googlegroups.com
It looks like the source of the problem is with the calculation of the week number. I have replaced the original function from "jquery.fn.gantt.js" with the following one and that seems to fix the problem:


Date.prototype.getWeekOfYear = function () {
var ys = new Date(this.getFullYear(), 0, 1);
var sd = new Date(this.getTime());

// Find Thursday of this week starting on Monday
sd.setDate(sd.getDate() + 4 - (sd.getDay() || 7));

return Math.floor(Math.round((sd - ys) / 86400000) / 7) + 1;
};

kichawa

unread,
Dec 18, 2013, 6:27:34 PM12/18/13
to jquer...@googlegroups.com
it's the same problem probably.

http://jsfiddle.net/GySEg/407/

kichawa

unread,
Dec 18, 2013, 7:07:44 PM12/18/13
to jquer...@googlegroups.com
The fix above my two posts works. I pull request to the main repo.

https://github.com/mbielanczuk/jQuery.Gantt/pull/42
Reply all
Reply to author
Forward
0 new messages