HTML5 Dnd on SimplePlot

22 views
Skip to first unread message

Sylvain Boulard

unread,
Oct 14, 2013, 8:51:45 AM10/14/13
to gf...@googlegroups.com
Hello,

I added HTML5 Dnd on SimplePlot object (plot.addDomHandler(new DragStartHandler() {...). etc....  It works fine.

But I would like to perform Dnd directly from "PlotItem" (dataPoint)... And I cannot find "elegant" solution... Is there a way to perform it ?

Best Regards
Sylvain

Nicolas Morel

unread,
Oct 14, 2013, 10:03:17 AM10/14/13
to gf...@googlegroups.com
Hi,

Maybe you could keep your dragstart on the plot, get the position of the mouse from the event and find the corresponding datapoint. There are methods available on flot to get a point from coordinates. From flot API :
  • getAxes()

    Gets an object with the axes. The axes are returned as the attributes of the object, so for instance getAxes().xaxis is the x axis.

    Various things are stuffed inside an axis object, e.g. you could use getAxes().xaxis.ticks to find out what the ticks are for the xaxis. Two other useful attributes are p2c and c2p, functions for transforming from data point space to the canvas plot space and back. Both returns values that are offset with the plot offset. Check the Flot source code for the complete set of attributes (or output an axis with console.log() and inspect it).

    With multiple axes, the extra axes are returned as x2axis, x3axis, etc., e.g. getAxes().y2axis is the second y axis. You can check y2axis.used to see whether the axis is associated with any data points and y2axis.show to see if it is currently shown.

Or on hovering datapoint, you add an invisible html element at the datapoint element and you listen dragstart to this element.

Or tweak flot. There is listener for click and hover so maybe it's possible to add other event. 

This is just suggestions as I never tried DnD with gflot or flot.

Sylvain Boulard

unread,
Oct 15, 2013, 11:44:42 AM10/15/13
to gf...@googlegroups.com
Thanks Nicolas,

I'll try to add an invisible html element while listening MouseOver (hovering). I already use this service. I'll let you inform.

Thanks and great job for gflot.
Best Regards, Cordialement
Sylvain
Reply all
Reply to author
Forward
0 new messages