在d3可视化(clustergrammer)上模拟单击和平移/其他鼠标事件

5ssjco0h  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(181)

非常感谢你抽出时间。
太长,读不下去了
完成操作后,图形无法刷新。为了解决这个问题,我尝试模拟用户的行为:
单击并拖动至少一个像素以平移可视化。
缩小至少一个滚轮凹口以缩放可视化效果。
右键单击可视化,然后左键单击页面上的任意位置以关闭关联菜单。
但是,使用jquery.trigger()模拟这些事件中的任何一个都不能像实际执行它们一样解决我的问题。示例如下:

// AFTER SEARCH FINISHES...
setTimeout(function(){
  // Acquiring an element in the center of the screen/visualization to perform my simulated events on.
  // This fails to resolve my problem, though manually performing the same actions on the same element will.

  var elem = document.elementFromPoint($(window).width()/2, $(window).height()/2);

  // Press down on the middle mouse button and move 1px before releasing.
  $(elem).trigger({type: 'pointerdown', which: 2});
  $(elem).trigger({type: 'mousedown', which: 2});
  $(elem).trigger({type: 'pointermove', movementX: 1, movementY: 1, which: 2});
  $(elem).trigger({type: 'mousemove', movementX: 1, movementY: 1, which: 2});
  $(elem).trigger({type: 'auxclick', which: 2});
  console.log("Hopefully the graphic has updated?");
}, 3000);

背景
我正在利用ClusterGrammar可视化库进行一个项目(https://github.com/maayanlab/clustergrammer). 可在此处找到正在运行的库的示例:https://maayanlab.cloud/clustergrammer/viz_sim_mats/58a492b4a63cb826f0be6476/rc_two_cats.txt
我正在编辑的代码可以在存储库根目录下的clustergrammer.js中查看,尽管这可能与此无关。与搜索相关的功能出现在~24704行附近(https://github.com/maayanlab/clustergrammer/blob/master/clustergrammer.js#l24704)
问题
我负责解决的问题涉及此库的搜索功能无法刷新可视化。但是,通过平移/缩放等方式改变可视化效果会迅速解决问题。在我的一生中,我无法在库中找到它捕获和响应这些平移/缩放输入的位置,我只能将我的更改复制到相关函数中。所以我一直在尝试模拟鼠标事件,但运气不好。
我们将非常感谢您提供的任何帮助、指导或其他方法。这比我想承认的要耗费更多的时间,而且不是一种需要克服的有趣的bug。
再次感谢你!

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题