trying to use d3 mouse events with x3dom

258 views
Skip to first unread message

Harry Voorhees

unread,
Apr 13, 2013, 12:12:34 AM4/13/13
to d3...@googlegroups.com
I'm starting to use d3 with x3dom but am having no luck using d3's mouse event handlers (e.g., on('click',...)) on x3dom elements.  Regular html mouse event handlers ("onclick") work fine, as demonstrated here: http://bl.ocks.org/hlvoorhees/5376764 . Ideas anyone?

Harry Voorhees

Harry Voorhees

unread,
Apr 17, 2013, 9:45:17 PM4/17/13
to d3...@googlegroups.com
I updated the gist with a workaround. Still, it would be nice if d3 events "just worked" with x3dom elements.

Marc Fawzi

unread,
Apr 17, 2013, 9:48:41 PM4/17/13
to d3...@googlegroups.com, d3...@googlegroups.com
d3.select(some element).on(...)

?

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "d3-js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to d3-js+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Harry Voorhees

unread,
Apr 17, 2013, 10:22:10 PM4/17/13
to d3...@googlegroups.com
It would be nice if .on('click',...) worked, as well as d3.mouse(...) when applied to x3dom elements.

As shown in the example code, the x3dom canvas's 'onclick' event handler fires instead, with an event that contains 3d and 2d coordinate information, so a workaround is to handle 'onclick' and to call .on('click').

In any case, the 'onclick' event is not of the type that d3.mouse(...) expects. I took at look at the d3 implementation, but I'm not yet sufficiently expert in javascript event handling to propose a change to d3.js. The commented-out event creation code the example .xhtml file might point in the direction of a solution.


--
You received this message because you are subscribed to a topic in the Google Groups "d3-js" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/d3-js/68UepBoSfMo/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to d3-js+un...@googlegroups.com.
Message has been deleted

Harry Voorhees

unread,
Feb 13, 2014, 10:00:39 AM2/13/14
to d3...@googlegroups.com
Hi Coleman,

Thanks for your message, glad my posting helped, and sorry for not replying sooner!

Yes, .node().addEventListener() seemed to be the most straightforward approach that worked. Did it work for you? If I find a better solution I'll post an update.

Harry


On Thu, Feb 6, 2014 at 6:54 PM, Coleman Foley <colema...@gmail.com> wrote:
Hey, Harry. Thanks a lot for posting the example. It saved me a ton of time. So, did you call .node on the selections to kind of get at the underlying element, so you could use addEventListener on it?

--
You received this message because you are subscribed to a topic in the Google Groups "d3-js" group.

John Carlson

unread,
Aug 29, 2015, 1:29:10 PM8/29/15
to d3-js, h...@alum.mit.edu
As documented in http://stackoverflow.com/questions/32286284/iterate-over-x3dom-nodes-in-d3-js I couldn't get .node().addEventListener() to work.  Help would be nice!  I think it might be because some of my data has no view (I don't know how this happened).

John
Reply all
Reply to author
Forward
0 new messages