d3-x3d icon indicating copy to clipboard operation
d3-x3d copied to clipboard

Get events working on X3DOM Scatterplot

Open emipgit opened this issue 3 years ago • 1 comments

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:

  1.  In the componentBubbles no event listener is attached to a bubble
    
  2.  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:

  1.  In componentBubbles I selected the “Shape” elements and attached them the event listener: attachEventListners(shapeSelection)
    
  2.  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}

emipgit avatar Jan 27 '21 07:01 emipgit

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

jamesleesaunders avatar Jan 27 '21 08:01 jamesleesaunders