d3-x3d
d3-x3d copied to clipboard
Get events working on X3DOM Scatterplot
In the scatterplot chart example for 3xdom an event handler is defined for the onclick, onmouseover and onmouseout events. The event handler is not executed because:
-
In the componentBubbles no event listener is attached to a bubble
-
In chartScatterplot the data structure passed to the event handler is different from the one required by the component to which data must be passed (componentCrosshair for the onclick event and componetLabel for the mouseover).
I could execute the event handler:
-
In componentBubbles I selected the “Shape” elements and attached them the event listener: attachEventListners(shapeSelection)
-
In chartScatterplot I used the mappings function to read each data field and then I created a new data with a structure used by componentCrosshair and componentLabel
var d1= d3.select(e.target).datum();
var colorVal = d1.values.find(function (v) {
return v.key === mappings.color;
}).value;
var xVal = d1.values.find(function (v) {
return v.key === mappings.x;
}).value;
var yVal = d1.values.find(function (v) {
return v.key === mappings.y;
}).value;
var zVal = d1.values.find(function (v) {
return v.key === mappings.z;
}).value;
var d = {key:d1.key,value:colorVal,x:xVal,y:yVal,z:zVal}
Hi, Thank you for raising this. As you have probably noticed the events code in d3-x3d is very much WIP. I would very much welcome any contributions in this area :-) You will see I have tried to put all events code in events.js if any help for you.
Thanks, Jim