Add drag n drop to the Gantt chart

Share RGraph:   Share or Like RGraph on Facebook!

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Henadzi on 9th April 2014
Hi there,

Fisrt of all, thanks a lot for your library!:)

And I have a question. I'm investigating RGraph.Gantt control and need to add drag-n-drop feature to it. Does any way exist to add listeners for 'mouseDown' & 'mouseUp' events apart from manual jQuery subscribing?

Could I redraw just only part of RGraph.Gantt during 'dragging'? Is it neccessary to refer to canvas directly in this case?

Thanks,
Henadzi
Posted by Richard on 9th April 2014
Hi there,

If you make an object like this:

obj = new RGraph.Gantt('cvs', ...)

Then the canvas can be found here:

obj.canvas

And you could do this to add a jQuery event (IIRC):



$(obj.canvas).on('mouseup', function (e)
{
     // ...
}).on('mousedown', function (e)
{
     // ...
})

That's with jQuery 1.10.x BTW.

There is an RGraph facility for click and mousemove events. These are fired when the bars are clicked/hovered:

gantt.on('click', function (e, obj)
{
     // ...
}).on('mousemove', function (e, obj)
{
     // ...
})

And for redrawing - the RGraph.redraw redraws the whole canvas - and all of the RGraph canvas tags on the page. And that may mean that multiple object need to be redrawn for each canvas. There is a RGraph.redrawCanvas function which limits the redraw to just the canvas you pass it - though that may still mean redrawing multiple charts if there's multiple charts on that canvas.

Richard
Posted by Henadzi on 10th April 2014
Thanks a lot. Your answer is very helpful.

-Henadzi
Posted by Ileven on 14th April 2014
hi,Richard
    thanks for your help.
you see :

$(obj.canvas).on('mouseup', function (e)
{
      // ...
}).on('mousedown', function (e)
{
      // ...
})


but I want get the data of obj ; you know, th obj has the information about which label I clicked! but the upper code you offered can not get the data of obj, so, could you give me some advices? tks
Posted by Richard on 14th April 2014
Hi there,

You can either just use obj (the easiest) or e.target.__object__




Richard

Add a reply




« Back to message list