Discuss anything related to web development but no technical support questions


Post by afiume »

Hi guys,

i find this code example to get left pixel coordinate from date:
this.ganttView.getXYFromDate(DT.max(taskStart, viewStart))[0]
I testing with firebug to but i dont undertand wich method call.
My Gant panel is called 'g'.

If i try g.getXYFromDate, the method not exist.
If i try g.getCoordinateFromDate, the method not exist.

Where is the error?

I using a 2.1.6 version.

Thanks,

Tony

Post by nickolay »

Try "gantt.getSchedulingView().getXYFromDate()"

Post by afiume »

nickolay wrote:Try "gantt.getSchedulingView().getXYFromDate()"
Thanks nickolay, now work fine :)

If i can ask you, i have a Gantt with windows startDate = '2012-01-01' and end windows end date = '2013-7-4'

If with firebug call this method:
>>> g.getSchedulingView().getXYFromDate(new Date(2012,01,01),new Date(2012,01,01))[0];
return 34.08153916628493.
I think this number is the left pixel to start the date. But is wrong.
If my chart start from 2012-01-01 end i get data from 2012-01-01, the left result should be 0 right?

Why return 34.08153916628493?

Thanks

Post by arcady »

>>> g.getSchedulingView().getXYFromDate(new Date(2012,01,01),new Date(2012,01,01))[0];
First of all getXYFromDate is deprecated method please use getCoordinateFromDate instead.

getCoordinateFromDate (or deprecated getXYFromDate) accepts 2 arguments: 1st is date and 2nd is boolean flag (wheter absolute or relative coordinate to return). So your code should look like this:
g.getSchedulingView().getCoordinateFromDate(new Date(2012, 1, 1))[0];
...the left result should be 0 right?
In javascript "new Date(2012,1,1)" means February 1st 2012. And if you want to get coordinate for January 1st you should write:
g.getSchedulingView().getCoordinateFromDate(new Date(2012, 0, 1))[0];

Post by afiume »

arcady wrote:
>>> g.getSchedulingView().getXYFromDate(new Date(2012,01,01),new Date(2012,01,01))[0];
First of all getXYFromDate is deprecated method please use getCoordinateFromDate instead.

getCoordinateFromDate (or deprecated getXYFromDate) accepts 2 arguments: 1st is date and 2nd is boolean flag (wheter absolute or relative coordinate to return). So your code should look like this:
g.getSchedulingView().getCoordinateFromDate(new Date(2012, 1, 1))[0];
...the left result should be 0 right?
In javascript "new Date(2012,1,1)" means February 1st 2012. And if you want to get coordinate for January 1st you should write:
g.getSchedulingView().getCoordinateFromDate(new Date(2012, 0, 1))[0];
Thanks!!
Right, is February sorry :lol:

So, whit my Gantt version, the method getXYFromDate work fine :)

Post Reply